Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F137899420
D43248.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
14 KB
Referenced Files
None
Subscribers
None
D43248.diff
View Options
diff --git a/sbin/ipf/iplang/iplang_y.y b/sbin/ipf/iplang/iplang_y.y
--- a/sbin/ipf/iplang/iplang_y.y
+++ b/sbin/ipf/iplang/iplang_y.y
@@ -1045,9 +1045,9 @@
void set_tcpflags(char **arg)
{
- static char flags[] = "ASURPF";
+ static char flags[] = "ASURPFECa";
static int flagv[] = { TH_ACK, TH_SYN, TH_URG, TH_RST, TH_PUSH,
- TH_FIN } ;
+ TH_FIN, TH_ECE, TH_CWR, TH_AE } ;
char *s, *t;
for (s = *arg; *s; s++)
@@ -1059,7 +1059,7 @@
tcp->th_flags = strtol(*arg, NULL, 0);
break;
} else
- tcp->th_flags |= flagv[t - flags];
+ tcp_set_flags(tcp, tcp_get_flags(tcp) | flagv[t - flags]);
free(*arg);
*arg = NULL;
}
diff --git a/sbin/ipf/ipmon/ipmon.c b/sbin/ipf/ipmon/ipmon.c
--- a/sbin/ipf/ipmon/ipmon.c
+++ b/sbin/ipf/ipmon/ipmon.c
@@ -78,6 +78,7 @@
{ TH_PUSH,'P' },
{ TH_ECN, 'E' },
{ TH_CWR, 'C' },
+ { TH_AE, 'a' },
{ 0, '\0' }
};
@@ -1196,7 +1197,7 @@
*t++ = ' ';
*t++ = '-';
for (i = 0; tcpfl[i].value; i++)
- if (tp->th_flags & tcpfl[i].value)
+ if (tcp_get_flags(tp) & tcpfl[i].value)
*t++ = tcpfl[i].flag;
if (ipmonopts & IPMON_VERBOSE) {
sprintf(t, " %lu %lu %hu",
diff --git a/sbin/ipf/ipsend/ipsend.1 b/sbin/ipf/ipsend/ipsend.1
--- a/sbin/ipf/ipsend/ipsend.1
+++ b/sbin/ipf/ipsend/ipsend.1
@@ -40,7 +40,7 @@
packets to a destination host, using command line options to specify various
attributes present in the headers. The \fIdestination\fP must be given as
the last command line option, except for when TCP flags are specified as
-a combination of A, S, F, U, P and R, last.
+a combination of A, S, F, U, P, R, E, C and a, last.
.PP
The other way it may be compiled, with DOSOCKET defined, is to allow an
attempt at making a TCP connection using a with ipsend resending the SYN
diff --git a/sbin/ipf/ipsend/ipsend.5 b/sbin/ipf/ipsend/ipsend.5
--- a/sbin/ipf/ipsend/ipsend.5
+++ b/sbin/ipf/ipsend/ipsend.5
@@ -252,7 +252,8 @@
.TP
.B flags <tcp-flags>
sets the TCP flags field to match the flags specified. Valid flags are
-"S" (SYN), "A" (ACK), "R" (RST), "F" (FIN), "U" (URG), "P" (PUSH).
+"S" (SYN), "A" (ACK), "R" (RST), "F" (FIN), "U" (URG), "P" (PUSH),
+"E" (ECN), "C" (CWR), "a" (AE).
.TP
.B opt
indicates that TCP header options follow. As TCP options are added to the
diff --git a/sbin/ipf/ipsend/ipsend.c b/sbin/ipf/ipsend/ipsend.c
--- a/sbin/ipf/ipsend/ipsend.c
+++ b/sbin/ipf/ipsend/ipsend.c
@@ -364,23 +364,32 @@
for (s = argv[optind]; s && (c = *s); s++)
switch(c)
{
- case 'S' : case 's' :
- tcp->th_flags |= TH_SYN;
+ case 'S' :
+ tcp_set_flags(tcp, tcp_get_flags(tcp) | TH_SYN);
break;
- case 'A' : case 'a' :
- tcp->th_flags |= TH_ACK;
+ case 'A' :
+ tcp_set_flags(tcp, tcp_get_flags(tcp) | TH_ACK);
break;
- case 'F' : case 'f' :
- tcp->th_flags |= TH_FIN;
+ case 'F' :
+ tcp_set_flags(tcp, tcp_get_flags(tcp) | TH_FIN);
break;
- case 'R' : case 'r' :
- tcp->th_flags |= TH_RST;
+ case 'R' :
+ tcp_set_flags(tcp, tcp_get_flags(tcp) | TH_RST);
break;
- case 'P' : case 'p' :
- tcp->th_flags |= TH_PUSH;
+ case 'P' :
+ tcp_set_flags(tcp, tcp_get_flags(tcp) | TH_PUSH);
break;
- case 'U' : case 'u' :
- tcp->th_flags |= TH_URG;
+ case 'U' :
+ tcp_set_flags(tcp, tcp_get_flags(tcp) | TH_URG);
+ break;
+ case 'E' :
+ tcp_set_flags(tcp, tcp_get_flags(tcp) | TH_ECE);
+ break;
+ case 'C' :
+ tcp_set_flags(tcp, tcp_get_flags(tcp) | TH_CWR);
+ break;
+ case 'a' :
+ tcp_set_flags(tcp, tcp_get_flags(tcp) | TH_AE);
break;
}
@@ -390,8 +399,8 @@
printf("Source: %s\n", inet_ntoa(ip->ip_src));
printf("Dest: %s\n", inet_ntoa(ip->ip_dst));
printf("Gateway: %s\n", inet_ntoa(gwip));
- if (ip->ip_p == IPPROTO_TCP && tcp->th_flags)
- printf("Flags: %#x\n", tcp->th_flags);
+ if (ip->ip_p == IPPROTO_TCP && tcp_get_flags(tcp))
+ printf("Flags: %#x\n", tcp_get_flags(tcp));
printf("mtu: %d\n", mtu);
if (ip->ip_p == IPPROTO_UDP) {
diff --git a/sbin/ipf/ipsend/iptests.c b/sbin/ipf/ipsend/iptests.c
--- a/sbin/ipf/ipsend/iptests.c
+++ b/sbin/ipf/ipsend/iptests.c
@@ -903,7 +903,6 @@
int nfd, i;
t = (tcphdr_t *)((char *)ip + (IP_HL(ip) << 2));
- t->th_x2 = 0;
TCP_OFF_A(t, 0);
t->th_sport = htons(1);
t->th_dport = htons(1);
@@ -920,13 +919,13 @@
if (!ptest || (ptest == 1)) {
/*
- * Test 1: flags variations, 0 - 3f
+ * Test 1: flags variations, 0 - 1ff
*/
TCP_OFF_A(t, sizeof(*t) >> 2);
printf("5.1 Test TCP flag combinations\n");
- for (i = 0; i <= (TH_URG|TH_ACK|TH_PUSH|TH_RST|TH_SYN|TH_FIN);
+ for (i = 0; i <= (TH_URG|TH_ACK|TH_PUSH|TH_RST|TH_SYN|TH_FIN|TH_ECE|TH_CWR|TH_AE);
i++) {
- t->th_flags = i;
+ tcp_set_flags(t, i);
(void) send_tcp(nfd, mtu, ip, gwip);
printf("%d\r", i);
fflush(stdout);
@@ -936,7 +935,7 @@
}
if (!ptest || (ptest == 2)) {
- t->th_flags = TH_SYN;
+ tcp_set_flags(t, TH_SYN);
/*
* Test 2: seq = 0, seq = 1, seq = 0x7fffffff, seq=0x80000000,
* seq = 0xa000000, seq = 0xffffffff
@@ -979,7 +978,7 @@
}
if (!ptest || (ptest == 3)) {
- t->th_flags = TH_ACK;
+ tcp_set_flags(t, TH_ACK);
/*
* Test 3: ack = 0, ack = 1, ack = 0x7fffffff, ack = 0x8000000
* ack = 0xa000000, ack = 0xffffffff
@@ -1022,7 +1021,7 @@
}
if (!ptest || (ptest == 4)) {
- t->th_flags = TH_SYN;
+ tcp_set_flags(t, TH_SYN);
/*
* Test 4: win = 0, win = 32768, win = 65535
*/
@@ -1092,7 +1091,7 @@
/*
* Test 5: urp
*/
- t->th_flags = TH_ACK|TH_URG;
+ tcp_set_flags(t, TH_ACK|TH_URG);
printf("5.5.1 TCP Urgent pointer, sport %hu dport %hu\n",
ntohs(t->th_sport), ntohs(t->th_dport));
t->th_urp = htons(1);
@@ -1111,7 +1110,7 @@
(void) send_tcp(nfd, mtu, ip, gwip);
PAUSE();
t->th_urp = 0;
- t->th_flags &= ~TH_URG;
+ tcp_set_flags(t, tcp_get_flags(t) & ~TH_URG);
ip->ip_len = sizeof(ip_t) + sizeof(tcphdr_t);
}
@@ -1119,7 +1118,7 @@
/*
* Test 6: data offset, off = 0, off is inside, off is outside
*/
- t->th_flags = TH_ACK;
+ tcp_set_flags(t, TH_ACK);
printf("5.6.1 TCP off = 1-15, len = 40\n");
for (i = 1; i < 16; i++) {
TCP_OFF_A(t, ntohs(i));
@@ -1141,7 +1140,7 @@
TCP_OFF_A(t, 0);
if (!ptest || (ptest == 7)) {
- t->th_flags = TH_SYN;
+ tcp_set_flags(t, TH_SYN);
/*
* Test 7: sport = 0, sport = 1, sport = 32767
* sport = 32768, sport = 65535
@@ -1179,7 +1178,7 @@
if (!ptest || (ptest == 8)) {
t->th_sport = htons(1);
- t->th_flags = TH_SYN;
+ tcp_set_flags(t, TH_SYN);
/*
* Test 8: dport = 0, dport = 1, dport = 32767
* dport = 32768, dport = 65535
@@ -1221,7 +1220,7 @@
/* chose SMTP port 25 */
t->th_sport = htons(25);
t->th_dport = htons(25);
- t->th_flags = TH_SYN;
+ tcp_set_flags(t, TH_SYN);
ip->ip_src = ip->ip_dst;
(void) send_tcp(nfd, mtu, ip, gwip);
fflush(stdout);
diff --git a/sbin/ipf/ipsend/resend.c b/sbin/ipf/ipsend/resend.c
--- a/sbin/ipf/ipsend/resend.c
+++ b/sbin/ipf/ipsend/resend.c
@@ -50,9 +50,9 @@
if (ip->ip_p == IPPROTO_TCP) {
printf(" seq %lu:%lu flags ",
(u_long)t->th_seq, (u_long)t->th_ack);
- for (j = 0, i = 1; i < 256; i *= 2, j++)
- if (t->th_flags & i)
- printf("%c", "FSRPAU--"[j]);
+ for (j = 0, i = 1; i < 0x200; i *= 2, j++)
+ if (tcp_get_flags(t) & i)
+ printf("%c", "FSRPAUECa"[j]);
}
putchar('\n');
}
diff --git a/sbin/ipf/libipf/ipft_tx.c b/sbin/ipf/libipf/ipft_tx.c
--- a/sbin/ipf/libipf/ipft_tx.c
+++ b/sbin/ipf/libipf/ipft_tx.c
@@ -20,9 +20,10 @@
static int text_readip(mb_t *, char **, int *);
static int parseline(char *, ip_t *, char **, int *);
-static char myflagset[] = "FSRPAUEC";
-static u_char myflags[] = { TH_FIN, TH_SYN, TH_RST, TH_PUSH,
- TH_ACK, TH_URG, TH_ECN, TH_CWR };
+static char myflagset[] = "FSRPAUECa";
+static uint16_t myflags[] = { TH_FIN, TH_SYN, TH_RST,
+ TH_PUSH, TH_ACK, TH_URG,
+ TH_ECN, TH_CWR, TH_AE};
struct ipread iptext = { text_open, text_close, text_readip, R_DO_CKSUM };
static FILE *tfp = NULL;
@@ -265,15 +266,16 @@
if (*cpp != NULL) {
char *s, *t;
- tcp->th_flags = 0;
+ tcp_set_flags(tcp, 0);
for (s = *cpp; *s; s++)
- if ((t = strchr(myflagset, *s)))
- tcp->th_flags |= myflags[t-myflagset];
- if (tcp->th_flags)
+ if ((t = strchr(myflagset, *s)))
+ tcp_set_flags(tcp,
+ tcp_get_flags(tcp) | myflags[t-myflagset]);
+ if (tcp_get_flags(tcp))
cpp++;
}
- if (tcp->th_flags & TH_URG)
+ if (tcp_get_flags(tcp) & TH_URG)
tcp->th_urp = htons(1);
if (*cpp && !strncasecmp(*cpp, "seq=", 4)) {
@@ -436,15 +438,16 @@
if (*cpp != NULL) {
char *s, *t;
- tcp->th_flags = 0;
+ tcp_set_flags(tcp, 0);
for (s = *cpp; *s; s++)
- if ((t = strchr(myflagset, *s)))
- tcp->th_flags |= myflags[t-myflagset];
- if (tcp->th_flags)
+ if ((t = strchr(myflagset, *s)))
+ tcp_set_flags(tcp,
+ tcp_get_flags(tcp) | myflags[t-myflagset]);
+ if (tcp_get_flags(tcp))
cpp++;
}
- if (tcp->th_flags & TH_URG)
+ if (tcp_get_flags(tcp) & TH_URG)
tcp->th_urp = htons(1);
if (*cpp && !strncasecmp(*cpp, "seq=", 4)) {
diff --git a/sbin/ipf/libipf/printpacket.c b/sbin/ipf/libipf/printpacket.c
--- a/sbin/ipf/libipf/printpacket.c
+++ b/sbin/ipf/libipf/printpacket.c
@@ -13,7 +13,6 @@
# define IP_OFFMASK 0x3fff
#endif
-
void
printpacket(int dir, mb_t *m)
{
@@ -82,24 +81,26 @@
if (!(off & IP_OFFMASK)) {
if (ip->ip_p == IPPROTO_TCP || ip->ip_p == IPPROTO_UDP)
PRINTF(",%d", ntohs(tcp->th_dport));
- if ((ip->ip_p == IPPROTO_TCP) && (tcp->th_flags != 0)) {
+ if ((ip->ip_p == IPPROTO_TCP) && (tcp_get_flags(tcp) != 0)) {
putchar(' ');
- if (tcp->th_flags & TH_FIN)
+ if (tcp_get_flags(tcp) & TH_FIN)
putchar('F');
- if (tcp->th_flags & TH_SYN)
+ if (tcp_get_flags(tcp) & TH_SYN)
putchar('S');
- if (tcp->th_flags & TH_RST)
+ if (tcp_get_flags(tcp) & TH_RST)
putchar('R');
- if (tcp->th_flags & TH_PUSH)
+ if (tcp_get_flags(tcp) & TH_PUSH)
putchar('P');
- if (tcp->th_flags & TH_ACK)
+ if (tcp_get_flags(tcp) & TH_ACK)
putchar('A');
- if (tcp->th_flags & TH_URG)
+ if (tcp_get_flags(tcp) & TH_URG)
putchar('U');
- if (tcp->th_flags & TH_ECN)
+ if (tcp_get_flags(tcp) & TH_ECN)
putchar('E');
- if (tcp->th_flags & TH_CWR)
+ if (tcp_get_flags(tcp) & TH_CWR)
putchar('C');
+ if (tcp_get_flags(tcp) & TH_AE)
+ putchar('a');
}
}
diff --git a/usr.sbin/ppp/ip.c b/usr.sbin/ppp/ip.c
--- a/usr.sbin/ppp/ip.c
+++ b/usr.sbin/ppp/ip.c
@@ -371,14 +371,14 @@
}
sport = ntohs(th->th_sport);
dport = ntohs(th->th_dport);
- estab = (th->th_flags & TH_ACK);
- syn = (th->th_flags & TH_SYN);
- finrst = (th->th_flags & (TH_FIN|TH_RST));
+ estab = (tcp_get_flags(th) & TH_ACK);
+ syn = (tcp_get_flags(th) & TH_SYN);
+ finrst = (tcp_get_flags(th) & (TH_FIN|TH_RST));
if (log_IsKept(LogDEBUG)) {
if (!estab)
snprintf(dbuff, sizeof dbuff,
- "flags = %02x, sport = %d, dport = %d",
- th->th_flags, sport, dport);
+ "flags = %03x, sport = %d, dport = %d",
+ tcp_get_flags(th), sport, dport);
else
*dbuff = '\0';
}
@@ -561,7 +561,7 @@
{
char logbuf[200];
static const char *const TcpFlags[] = {
- "FIN", "SYN", "RST", "PSH", "ACK", "URG"
+ "FIN", "SYN", "RST", "PSH", "ACK", "URG", "ECE", "CWR", "AE"
};
const struct tcphdr *th;
const struct udphdr *uh;
@@ -829,19 +829,17 @@
snprintf(logbuf + loglen, sizeof logbuf - loglen,
"%s:%d", ncpaddr_ntoa(&dstaddr), ntohs(th->th_dport));
loglen += strlen(logbuf + loglen);
- n = 0;
- for (mask = TH_FIN; mask != 0x40; mask <<= 1) {
- if (th->th_flags & mask) {
+ for (mask = TH_FIN, n = 0; mask <= TH_AE; mask <<= 1, n++) {
+ if (tcp_get_flags(th) & mask) {
snprintf(logbuf + loglen, sizeof logbuf - loglen, " %s", TcpFlags[n]);
loglen += strlen(logbuf + loglen);
}
- n++;
}
snprintf(logbuf + loglen, sizeof logbuf - loglen,
" seq:%lx ack:%lx (%d/%d)",
(u_long)ntohl(th->th_seq), (u_long)ntohl(th->th_ack), len, nb);
loglen += strlen(logbuf + loglen);
- if ((th->th_flags & TH_SYN) && nb > 40) {
+ if ((tcp_get_flags(th) & TH_SYN) && nb > 40) {
const u_short *sp;
sp = (const u_short *)(payload + 20);
diff --git a/usr.sbin/ppp/slcompress.c b/usr.sbin/ppp/slcompress.c
--- a/usr.sbin/ppp/slcompress.c
+++ b/usr.sbin/ppp/slcompress.c
@@ -179,8 +179,8 @@
return (TYPE_IP);
}
th = (struct tcphdr *) & ((int *) ip)[hlen];
- if ((th->th_flags & (TH_SYN | TH_FIN | TH_RST | TH_ACK)) != TH_ACK) {
- log_Printf(LogDEBUG, "??? 2 th_flags = %x\n", th->th_flags);
+ if ((tcp_get_flags(th) & (TH_SYN | TH_FIN | TH_RST | TH_ACK)) != TH_ACK) {
+ log_Printf(LogDEBUG, "??? 2 th_flags = %x\n", tcp_get_flags(th));
log_DumpBp(LogDEBUG, "", m);
return (TYPE_IP);
}
@@ -283,7 +283,7 @@
* changes in the order: urgent, window, ack, seq (the order minimizes the
* number of temporaries needed in this section of code).
*/
- if (th->th_flags & TH_URG) {
+ if (tcp_get_flags(th) & TH_URG) {
deltaS = ntohs(th->th_urp);
ENCODEZ(deltaS);
changes |= NEW_U;
@@ -366,7 +366,7 @@
ENCODEZ(deltaS);
changes |= NEW_I;
}
- if (th->th_flags & TH_PUSH)
+ if (tcp_get_flags(th) & TH_PUSH)
changes |= TCP_PUSH_BIT;
/*
@@ -501,9 +501,9 @@
th->th_sum = htons((*cp << 8) | cp[1]);
cp += 2;
if (changes & TCP_PUSH_BIT)
- th->th_flags |= TH_PUSH;
+ tcp_set_flags(th, tcp_get_flags(th) | TH_PUSH);
else
- th->th_flags &= ~TH_PUSH;
+ tcp_set_flags(th, tcp_get_flags(th) & ~TH_PUSH);
switch (changes & SPECIALS_MASK) {
case SPECIAL_I:
@@ -522,10 +522,10 @@
default:
if (changes & NEW_U) {
- th->th_flags |= TH_URG;
+ tcp_set_flags(th, tcp_get_flags(th) | TH_URG);
DECODEU(th->th_urp)
} else
- th->th_flags &= ~TH_URG;
+ tcp_set_flags(th, tcp_get_flags(th) & ~TH_URG);
if (changes & NEW_W)
DECODES(th->th_win)
if (changes & NEW_A)
diff --git a/usr.sbin/ppp/tcpmss.c b/usr.sbin/ppp/tcpmss.c
--- a/usr.sbin/ppp/tcpmss.c
+++ b/usr.sbin/ppp/tcpmss.c
@@ -115,7 +115,7 @@
return;
/* MSS option only allowed within SYN packets. */
- if (!(tc->th_flags & TH_SYN))
+ if (!(tcp_get_flags(tc) & TH_SYN))
return;
for (olen = hlen - sizeof(struct tcphdr), opt = (u_char *)(tc + 1);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 28, 12:41 AM (2 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26268665
Default Alt Text
D43248.diff (14 KB)
Attached To
Mode
D43248: use tcp_[g|s]et_flags all over world
Attached
Detach File
Event Timeline
Log In to Comment