summaryrefslogtreecommitdiffstats
path: root/contrib/ipfilter/iplang/iplang_y.y
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1998-06-20 18:29:38 +0000
committerpeter <peter@FreeBSD.org>1998-06-20 18:29:38 +0000
commit9529c38ad8859b9f325867d97f266101f2c4dca3 (patch)
tree7c9206c000e7ad493db842a3fecdf77deacb096a /contrib/ipfilter/iplang/iplang_y.y
parent58e3555d887b6a5b1f460d8ee84ca4e97c0a8217 (diff)
downloadFreeBSD-src-9529c38ad8859b9f325867d97f266101f2c4dca3.zip
FreeBSD-src-9529c38ad8859b9f325867d97f266101f2c4dca3.tar.gz
Import trimmed version of ipfilter 3.2.7.
Obtained from: Darren Reed via http://cheops.anu.edu.au/~avalon/
Diffstat (limited to 'contrib/ipfilter/iplang/iplang_y.y')
-rw-r--r--contrib/ipfilter/iplang/iplang_y.y53
1 files changed, 32 insertions, 21 deletions
diff --git a/contrib/ipfilter/iplang/iplang_y.y b/contrib/ipfilter/iplang/iplang_y.y
index 0906680..e01bb37 100644
--- a/contrib/ipfilter/iplang/iplang_y.y
+++ b/contrib/ipfilter/iplang/iplang_y.y
@@ -6,7 +6,7 @@
* provided that this notice is preserved and due credit is given
* to the original author and the contributors.
*
- * $Id: iplang_y.y,v 2.0.2.18.2.5 1997/12/10 09:54:45 darrenr Exp $
+ * $Id: iplang_y.y,v 2.0.2.18.2.7 1998/05/23 14:29:53 darrenr Exp $
*/
#include <stdio.h>
@@ -48,7 +48,9 @@
#include "ipf.h"
#include "iplang.h"
+#ifndef __NetBSD__
extern struct ether_addr *ether_aton __P((char *));
+#endif
extern int opts;
extern struct ipopt_names ionames[];
@@ -345,7 +347,7 @@ tcpopts:
tcpopt: IL_TCPO_NOP ';' { set_tcpopt(IL_TCPO_NOP, NULL); }
| IL_TCPO_EOL ';' { set_tcpopt(IL_TCPO_EOL, NULL); }
| IL_TCPO_MSS optoken { set_tcpopt(IL_TCPO_MSS,&$2);}
- | IL_TCPO_WSCALE optoken { set_tcpopt(IL_TCPO_MSS,&$2);}
+ | IL_TCPO_WSCALE optoken { set_tcpopt(IL_TCPO_WSCALE,&$2);}
| IL_TCPO_TS optoken { set_tcpopt(IL_TCPO_TS, &$2);}
;
@@ -779,6 +781,8 @@ char **arg;
*t++ = (u_char)(val & 0xff);
todo = 0;
}
+ if (todo)
+ continue;
}
if (quote) {
if (isdigit(c)) {
@@ -807,8 +811,8 @@ char **arg;
*t++ = '\t';
break;
}
- quote = 0;
}
+ quote = 0;
continue;
}
@@ -817,6 +821,8 @@ char **arg;
else
*t++ = c;
}
+ if (todo)
+ *t++ = (u_char)(val & 0xff);
if (quote)
*t++ = '\\';
len = t - (u_char *)canip->ah_data;
@@ -910,7 +916,7 @@ char **arg;
void set_ipv4off(arg)
char **arg;
{
- ip->ip_off = strtol(*arg, NULL, 0);
+ ip->ip_off = htons(strtol(*arg, NULL, 0));
free(*arg);
*arg = NULL;
}
@@ -961,7 +967,7 @@ char **arg;
void set_ipv4id(arg)
char **arg;
{
- ip->ip_id = strtol(*arg, NULL, 0);
+ ip->ip_id = htons(strtol(*arg, NULL, 0));
free(*arg);
*arg = NULL;
}
@@ -999,7 +1005,7 @@ void new_tcpheader()
ip->ip_p = IPPROTO_TCP;
tcp = (tcphdr_t *)new_header(IPPROTO_TCP);
- tcp->th_win = 4096;
+ tcp->th_win = htons(4096);
tcp->th_off = sizeof(*tcp) >> 2;
}
@@ -1047,7 +1053,7 @@ char **arg;
void set_tcpseq(arg)
char **arg;
{
- tcp->th_seq = strtol(*arg, NULL, 0);
+ tcp->th_seq = htonl(strtol(*arg, NULL, 0));
free(*arg);
*arg = NULL;
}
@@ -1056,7 +1062,7 @@ char **arg;
void set_tcpack(arg)
char **arg;
{
- tcp->th_ack = strtol(*arg, NULL, 0);
+ tcp->th_ack = htonl(strtol(*arg, NULL, 0));
free(*arg);
*arg = NULL;
}
@@ -1078,7 +1084,7 @@ char **arg;
void set_tcpurp(arg)
char **arg;
{
- tcp->th_urp = strtol(*arg, NULL, 0);
+ tcp->th_urp = htons(strtol(*arg, NULL, 0));
free(*arg);
*arg = NULL;
}
@@ -1087,7 +1093,7 @@ char **arg;
void set_tcpwin(arg)
char **arg;
{
- tcp->th_win = strtol(*arg, NULL, 0);
+ tcp->th_win = htons(strtol(*arg, NULL, 0));
free(*arg);
*arg = NULL;
}
@@ -1298,7 +1304,8 @@ void packet_done()
u_char *s = (u_char *)ipbuffer, *t = (u_char *)outline;
if (opts & OPT_VERBOSE) {
- for (i = ip->ip_len, j = 0; i; i--, j++, s++) {
+ ip->ip_len = htons(ip->ip_len);
+ for (i = ntohs(ip->ip_len), j = 0; i; i--, j++, s++) {
if (j && !(j & 0xf)) {
*t++ = '\n';
*t = '\0';
@@ -1338,6 +1345,7 @@ void packet_done()
}
fputs(outline, stdout);
fflush(stdout);
+ ip->ip_len = ntohs(ip->ip_len);
}
prep_packet();
@@ -1542,35 +1550,35 @@ char **type;
void set_icmpid(arg)
int arg;
{
- icmp->icmp_id = arg;
+ icmp->icmp_id = htons(arg);
}
void set_icmpseq(arg)
int arg;
{
- icmp->icmp_seq = arg;
+ icmp->icmp_seq = htons(arg);
}
void set_icmpotime(arg)
int arg;
{
- icmp->icmp_otime = arg;
+ icmp->icmp_otime = htonl(arg);
}
void set_icmprtime(arg)
int arg;
{
- icmp->icmp_rtime = arg;
+ icmp->icmp_rtime = htonl(arg);
}
void set_icmpttime(arg)
int arg;
{
- icmp->icmp_ttime = arg;
+ icmp->icmp_ttime = htonl(arg);
}
@@ -1578,7 +1586,7 @@ void set_icmpmtu(arg)
int arg;
{
#if BSD >= 199306
- icmp->icmp_nextmtu = arg;
+ icmp->icmp_nextmtu = htons(arg);
#endif
}
@@ -1730,7 +1738,9 @@ void end_ipv4()
aniphdr_t *aip;
ip->ip_sum = 0;
+ ip->ip_len = htons(ip->ip_len);
ip->ip_sum = chksum((u_short *)ip, ip->ip_hl << 2);
+ ip->ip_len = ntohs(ip->ip_len);
free_anipheader();
for (aip = aniphead, ip = NULL; aip; aip = aip->ah_next)
if (aip->ah_p == IPPROTO_IP)
@@ -1761,9 +1771,10 @@ void end_udp()
iptmp.ip_p = ip->ip_p;
iptmp.ip_src = ip->ip_src;
iptmp.ip_dst = ip->ip_dst;
- iptmp.ip_len = ip->ip_len - (ip->ip_hl << 2);
+ iptmp.ip_len = htons(ip->ip_len - (ip->ip_hl << 2));
sum = p_chksum((u_short *)&iptmp, (u_int)sizeof(iptmp));
- udp->uh_sum = c_chksum((u_short *)udp, (u_int)iptmp.ip_len, sum);
+ udp->uh_ulen = htons(udp->uh_ulen);
+ udp->uh_sum = c_chksum((u_short *)udp, (u_int)ntohs(iptmp.ip_len), sum);
free_anipheader();
for (aip = aniphead, udp = NULL; aip; aip = aip->ah_next)
if (aip->ah_p == IPPROTO_UDP)
@@ -1781,10 +1792,10 @@ void end_tcp()
iptmp.ip_p = ip->ip_p;
iptmp.ip_src = ip->ip_src;
iptmp.ip_dst = ip->ip_dst;
- iptmp.ip_len = ip->ip_len - (ip->ip_hl << 2);
+ iptmp.ip_len = htons(ip->ip_len - (ip->ip_hl << 2));
sum = p_chksum((u_short *)&iptmp, (u_int)sizeof(iptmp));
tcp->th_sum = 0;
- tcp->th_sum = c_chksum((u_short *)tcp, (u_int)iptmp.ip_len, sum);
+ tcp->th_sum = c_chksum((u_short *)tcp, (u_int)ntohs(iptmp.ip_len), sum);
free_anipheader();
for (aip = aniphead, tcp = NULL; aip; aip = aip->ah_next)
if (aip->ah_p == IPPROTO_TCP)
OpenPOWER on IntegriCloud