static int tcp_verify_signature(netdissect_options *ndo,
const struct ip *ip, const struct tcphdr *tp,
static int tcp_verify_signature(netdissect_options *ndo,
const struct ip *ip, const struct tcphdr *tp,
-static void print_tcp_rst_data(netdissect_options *, register const u_char *sp, u_int length);
-static void print_tcp_fastopen_option(netdissect_options *ndo, register const u_char *cp,
+static void print_tcp_rst_data(netdissect_options *, const u_char *sp, u_int length);
+static void print_tcp_fastopen_option(netdissect_options *ndo, const u_char *cp,
{
return nextproto4_cksum(ndo, ip, (const uint8_t *)tp, len, len,
IPPROTO_TCP);
{
return nextproto4_cksum(ndo, ip, (const uint8_t *)tp, len, len,
IPPROTO_TCP);
- register const struct ip6_hdr *ip6,
- register const struct tcphdr *tp,
- register u_int len)
+ const struct ip6_hdr *ip6,
+ const struct tcphdr *tp,
+ u_int len)
{
return nextproto6_cksum(ndo, ip6, (const uint8_t *)tp, len, len,
IPPROTO_TCP);
{
return nextproto6_cksum(ndo, ip6, (const uint8_t *)tp, len, len,
IPPROTO_TCP);
- register const u_char *bp, register u_int length,
- register const u_char *bp2, int fragmented)
+ const u_char *bp, u_int length,
+ const u_char *bp2, int fragmented)
uint16_t sport, dport, win, urp;
uint32_t seq, ack, thseq, thack;
u_int utoval;
uint16_t magic;
uint16_t sport, dport, win, urp;
uint32_t seq, ack, thseq, thack;
u_int utoval;
uint16_t magic;
- if (!ND_TTEST(tp->th_dport)) {
- ND_PRINT((ndo, "%s > %s: [|tcp]",
+ if (!ND_TTEST_2(tp->th_dport)) {
+ ND_PRINT("%s > %s: [|tcp]",
- if (ip6->ip6_nxt == IPPROTO_TCP) {
- ND_PRINT((ndo, "%s.%s > %s.%s: ",
+ if (EXTRACT_U_1(ip6->ip6_nxt) == IPPROTO_TCP) {
+ ND_PRINT("%s.%s > %s.%s: ",
ip6addr_string(ndo, &ip6->ip6_src),
tcpport_string(ndo, sport),
ip6addr_string(ndo, &ip6->ip6_dst),
ip6addr_string(ndo, &ip6->ip6_src),
tcpport_string(ndo, sport),
ip6addr_string(ndo, &ip6->ip6_dst),
- ND_PRINT((ndo, "%s > %s: ",
- tcpport_string(ndo, sport), tcpport_string(ndo, dport)));
+ ND_PRINT("%s > %s: ",
+ tcpport_string(ndo, sport), tcpport_string(ndo, dport));
- if (ip->ip_p == IPPROTO_TCP) {
- ND_PRINT((ndo, "%s.%s > %s.%s: ",
+ if (EXTRACT_U_1(ip->ip_p) == IPPROTO_TCP) {
+ ND_PRINT("%s.%s > %s.%s: ",
ipaddr_string(ndo, &ip->ip_src),
tcpport_string(ndo, sport),
ipaddr_string(ndo, &ip->ip_dst),
ipaddr_string(ndo, &ip->ip_src),
tcpport_string(ndo, sport),
ipaddr_string(ndo, &ip->ip_dst),
- ND_PRINT((ndo, "%s > %s: ",
- tcpport_string(ndo, sport), tcpport_string(ndo, dport)));
+ ND_PRINT("%s > %s: ",
+ tcpport_string(ndo, sport), tcpport_string(ndo, dport));
- ND_PRINT((ndo, " tcp %d [bad hdr length %u - too short, < %lu]",
- length - hlen, hlen, (unsigned long)sizeof(*tp)));
+ ND_PRINT(" tcp %u [bad hdr length %u - too short, < %lu]",
+ length - hlen, hlen, (unsigned long)sizeof(*tp));
- seq = EXTRACT_32BITS(&tp->th_seq);
- ack = EXTRACT_32BITS(&tp->th_ack);
- win = EXTRACT_16BITS(&tp->th_win);
- urp = EXTRACT_16BITS(&tp->th_urp);
+ seq = EXTRACT_BE_U_4(tp->th_seq);
+ ack = EXTRACT_BE_U_4(tp->th_ack);
+ win = EXTRACT_BE_U_2(tp->th_win);
+ urp = EXTRACT_BE_U_2(tp->th_urp);
- ND_PRINT((ndo, " [bad hdr length %u - too long, > %u]",
- hlen, length));
+ ND_PRINT(" [bad hdr length %u - too long, > %u]",
+ hlen, length);
- flags = tp->th_flags;
- ND_PRINT((ndo, "Flags [%s]", bittok2str_nosep(tcp_flag_values, "none", flags)));
+ flags = EXTRACT_U_1(tp->th_flags);
+ ND_PRINT("Flags [%s]", bittok2str_nosep(tcp_flag_values, "none", flags));
- ND_PRINT((ndo, " [bad hdr length %u - too long, > %u]",
- hlen, length));
+ ND_PRINT(" [bad hdr length %u - too long, > %u]",
+ hlen, length);
sum = tcp_cksum(ndo, ip, tp, length);
sum = tcp_cksum(ndo, ip, tp, length);
- ND_PRINT((ndo, " (incorrect -> 0x%04x)",
- in_cksum_shouldbe(tcp_sum, sum)));
+ ND_PRINT(" (incorrect -> 0x%04x)",
+ in_cksum_shouldbe(tcp_sum, sum));
sum = tcp6_cksum(ndo, ip6, tp, length);
sum = tcp6_cksum(ndo, ip6, tp, length);
- ND_PRINT((ndo, " (incorrect -> 0x%04x)",
- in_cksum_shouldbe(tcp_sum, sum)));
+ ND_PRINT(" (incorrect -> 0x%04x)",
+ in_cksum_shouldbe(tcp_sum, sum));
- ND_PRINT((ndo, "%s", tok2str(tcp_option_values, "unknown-%u", opt)));
+ ND_PRINT("%s", tok2str(tcp_option_values, "unknown-%u", opt));
- ND_PRINT((ndo, " val %u ecr %u",
- EXTRACT_32BITS(cp),
- EXTRACT_32BITS(cp + 4)));
+ ND_PRINT(" val %u ecr %u",
+ EXTRACT_BE_U_4(cp),
+ EXTRACT_BE_U_4(cp + 4));
#ifdef HAVE_LIBCRYPTO
switch (tcp_verify_signature(ndo, ip, tp,
bp + TH_OFF(tp) * 4, length, cp)) {
case SIGNATURE_VALID:
#ifdef HAVE_LIBCRYPTO
switch (tcp_verify_signature(ndo, ip, tp,
bp + TH_OFF(tp) * 4, length, cp)) {
case SIGNATURE_VALID:
- ND_PRINT((ndo, " cap %02x id %u", cp[0], cp[1]));
+ ND_PRINT(" cap %02x id %u", EXTRACT_U_1(cp), EXTRACT_U_1(cp + 1));
- utoval = EXTRACT_16BITS(cp);
- ND_PRINT((ndo, " 0x%x", utoval));
+ utoval = EXTRACT_BE_U_2(cp);
+ ND_PRINT(" 0x%x", utoval);
print_tcp_fastopen_option(ndo, cp, datalen, FALSE);
break;
print_tcp_fastopen_option(ndo, cp, datalen, FALSE);
break;
if (IS_SRC_OR_DST_PORT(TELNET_PORT)) {
telnet_print(ndo, bp, length);
} else if (IS_SRC_OR_DST_PORT(SMTP_PORT)) {
if (IS_SRC_OR_DST_PORT(TELNET_PORT)) {
telnet_print(ndo, bp, length);
} else if (IS_SRC_OR_DST_PORT(SMTP_PORT)) {
smtp_print(ndo, bp, length);
} else if (IS_SRC_OR_DST_PORT(WHOIS_PORT)) {
smtp_print(ndo, bp, length);
} else if (IS_SRC_OR_DST_PORT(WHOIS_PORT)) {
txtproto_print(ndo, bp, length, "whois", NULL, 0); /* RFC 3912 */
} else if (IS_SRC_OR_DST_PORT(BGP_PORT))
bgp_print(ndo, bp, length);
txtproto_print(ndo, bp, length, "whois", NULL, 0); /* RFC 3912 */
} else if (IS_SRC_OR_DST_PORT(BGP_PORT))
bgp_print(ndo, bp, length);
else if (IS_SRC_OR_DST_PORT(OPENFLOW_PORT_OLD) || IS_SRC_OR_DST_PORT(OPENFLOW_PORT_IANA))
openflow_print(ndo, bp, length);
else if (IS_SRC_OR_DST_PORT(FTP_PORT)) {
else if (IS_SRC_OR_DST_PORT(OPENFLOW_PORT_OLD) || IS_SRC_OR_DST_PORT(OPENFLOW_PORT_IANA))
openflow_print(ndo, bp, length);
else if (IS_SRC_OR_DST_PORT(FTP_PORT)) {
ftp_print(ndo, bp, length);
} else if (IS_SRC_OR_DST_PORT(HTTP_PORT) || IS_SRC_OR_DST_PORT(HTTP_PORT_ALT)) {
ftp_print(ndo, bp, length);
} else if (IS_SRC_OR_DST_PORT(HTTP_PORT) || IS_SRC_OR_DST_PORT(HTTP_PORT_ALT)) {
http_print(ndo, bp, length);
} else if (IS_SRC_OR_DST_PORT(RTSP_PORT) || IS_SRC_OR_DST_PORT(RTSP_PORT_ALT)) {
http_print(ndo, bp, length);
} else if (IS_SRC_OR_DST_PORT(RTSP_PORT) || IS_SRC_OR_DST_PORT(RTSP_PORT_ALT)) {
rtsp_print(ndo, bp, length);
} else if (length > 2 &&
(IS_SRC_OR_DST_PORT(NAMESERVER_PORT))) {
rtsp_print(ndo, bp, length);
} else if (length > 2 &&
(IS_SRC_OR_DST_PORT(NAMESERVER_PORT))) {
ldp_print(ndo, bp, length);
}
else if ((IS_SRC_OR_DST_PORT(NFS_PORT)) &&
ldp_print(ndo, bp, length);
}
else if ((IS_SRC_OR_DST_PORT(NFS_PORT)) &&
/*
* If data present, header length valid, and NFS port used,
* assume NFS.
/*
* If data present, header length valid, and NFS port used,
* assume NFS.
- if (ND_TTEST(rp->rm_direction)) {
- direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
+ if (ND_TTEST_4(rp->rm_direction)) {
+ direction = (enum sunrpc_msg_type) EXTRACT_BE_U_4(rp->rm_direction);
- ND_PRINT((ndo, ": NFS request xid %u ", EXTRACT_32BITS(&rp->rm_xid)));
+ ND_PRINT(": NFS request xid %u ",
+ EXTRACT_BE_U_4(rp->rm_xid));
nfsreq_noaddr_print(ndo, (const u_char *)rp, fraglen, (const u_char *)ip);
return;
}
if (sport == NFS_PORT && direction == SUNRPC_REPLY) {
nfsreq_noaddr_print(ndo, (const u_char *)rp, fraglen, (const u_char *)ip);
return;
}
if (sport == NFS_PORT && direction == SUNRPC_REPLY) {
- ND_PRINT((ndo, ": NFS reply xid %u ", EXTRACT_32BITS(&rp->rm_xid)));
+ ND_PRINT(": NFS reply xid %u ",
+ EXTRACT_BE_U_4(rp->rm_xid));
nfsreply_noaddr_print(ndo, (const u_char *)rp, fraglen, (const u_char *)ip);
return;
}
nfsreply_noaddr_print(ndo, (const u_char *)rp, fraglen, (const u_char *)ip);
return;
}
static int
tcp_verify_signature(netdissect_options *ndo,
const struct ip *ip, const struct tcphdr *tp,
static int
tcp_verify_signature(netdissect_options *ndo,
const struct ip *ip, const struct tcphdr *tp,
MD5_Update(&ctx, (const char *)&ip->ip_dst, sizeof(ip->ip_dst));
MD5_Update(&ctx, (const char *)&zero_proto, sizeof(zero_proto));
MD5_Update(&ctx, (const char *)&ip->ip_p, sizeof(ip->ip_p));
MD5_Update(&ctx, (const char *)&ip->ip_dst, sizeof(ip->ip_dst));
MD5_Update(&ctx, (const char *)&zero_proto, sizeof(zero_proto));
MD5_Update(&ctx, (const char *)&ip->ip_p, sizeof(ip->ip_p));
tlen = htons(tlen);
MD5_Update(&ctx, (const char *)&tlen, sizeof(tlen));
} else if (IP_V(ip) == 6) {
ip6 = (const struct ip6_hdr *)ip;
MD5_Update(&ctx, (const char *)&ip6->ip6_src, sizeof(ip6->ip6_src));
MD5_Update(&ctx, (const char *)&ip6->ip6_dst, sizeof(ip6->ip6_dst));
tlen = htons(tlen);
MD5_Update(&ctx, (const char *)&tlen, sizeof(tlen));
} else if (IP_V(ip) == 6) {
ip6 = (const struct ip6_hdr *)ip;
MD5_Update(&ctx, (const char *)&ip6->ip6_src, sizeof(ip6->ip6_src));
MD5_Update(&ctx, (const char *)&ip6->ip6_dst, sizeof(ip6->ip6_dst));
MD5_Update(&ctx, (const char *)&len32, sizeof(len32));
nxt = 0;
MD5_Update(&ctx, (const char *)&nxt, sizeof(nxt));
MD5_Update(&ctx, (const char *)&len32, sizeof(len32));
nxt = 0;
MD5_Update(&ctx, (const char *)&nxt, sizeof(nxt));
* Step 2: Update MD5 hash with TCP header, excluding options.
* The TCP checksum must be set to zero.
*/
* Step 2: Update MD5 hash with TCP header, excluding options.
* The TCP checksum must be set to zero.
*/