]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-udp.c
Translate UDP/1700 as RADIUS
[tcpdump] / print-udp.c
index 2b63318a41954a08afff19ebedcc3cc7628a88c7..37679eb169454e7b814a19dd47e55e9ee55a874e 100644 (file)
@@ -545,47 +545,46 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
        }
 
        if (!ndo->ndo_qflag) {
        }
 
        if (!ndo->ndo_qflag) {
-#define ISPORT(p) (dport == (p) || sport == (p))
-               if (ISPORT(NAMESERVER_PORT))
+               if (IS_SRC_OR_DST_PORT(NAMESERVER_PORT))
                        ns_print(ndo, (const u_char *)(up + 1), length, 0);
                        ns_print(ndo, (const u_char *)(up + 1), length, 0);
-               else if (ISPORT(MULTICASTDNS_PORT))
+               else if (IS_SRC_OR_DST_PORT(MULTICASTDNS_PORT))
                        ns_print(ndo, (const u_char *)(up + 1), length, 1);
                        ns_print(ndo, (const u_char *)(up + 1), length, 1);
-               else if (ISPORT(TIMED_PORT))
+               else if (IS_SRC_OR_DST_PORT(TIMED_PORT))
                        timed_print(ndo, (const u_char *)(up + 1));
                        timed_print(ndo, (const u_char *)(up + 1));
-               else if (ISPORT(TFTP_PORT))
+               else if (IS_SRC_OR_DST_PORT(TFTP_PORT))
                        tftp_print(ndo, (const u_char *)(up + 1), length);
                        tftp_print(ndo, (const u_char *)(up + 1), length);
-               else if (ISPORT(BOOTPC_PORT) || ISPORT(BOOTPS_PORT))
+               else if (IS_SRC_OR_DST_PORT(BOOTPC_PORT) || IS_SRC_OR_DST_PORT(BOOTPS_PORT))
                        bootp_print(ndo, (const u_char *)(up + 1), length);
                        bootp_print(ndo, (const u_char *)(up + 1), length);
-               else if (ISPORT(RIP_PORT))
+               else if (IS_SRC_OR_DST_PORT(RIP_PORT))
                        rip_print(ndo, (const u_char *)(up + 1), length);
                        rip_print(ndo, (const u_char *)(up + 1), length);
-               else if (ISPORT(AODV_PORT))
+               else if (IS_SRC_OR_DST_PORT(AODV_PORT))
                        aodv_print(ndo, (const u_char *)(up + 1), length,
                            ip6 != NULL);
                        aodv_print(ndo, (const u_char *)(up + 1), length,
                            ip6 != NULL);
-               else if (ISPORT(ISAKMP_PORT))
+               else if (IS_SRC_OR_DST_PORT(ISAKMP_PORT))
                         isakmp_print(ndo, (const u_char *)(up + 1), length, bp2);
                         isakmp_print(ndo, (const u_char *)(up + 1), length, bp2);
-               else if (ISPORT(ISAKMP_PORT_NATT))
+               else if (IS_SRC_OR_DST_PORT(ISAKMP_PORT_NATT))
                         isakmp_rfc3948_print(ndo, (const u_char *)(up + 1), length, bp2);
 #if 1 /*???*/
                         isakmp_rfc3948_print(ndo, (const u_char *)(up + 1), length, bp2);
 #if 1 /*???*/
-               else if (ISPORT(ISAKMP_PORT_USER1) || ISPORT(ISAKMP_PORT_USER2))
+               else if (IS_SRC_OR_DST_PORT(ISAKMP_PORT_USER1) || IS_SRC_OR_DST_PORT(ISAKMP_PORT_USER2))
                        isakmp_print(ndo, (const u_char *)(up + 1), length, bp2);
 #endif
                        isakmp_print(ndo, (const u_char *)(up + 1), length, bp2);
 #endif
-               else if (ISPORT(SNMP_PORT) || ISPORT(SNMPTRAP_PORT))
+               else if (IS_SRC_OR_DST_PORT(SNMP_PORT) || IS_SRC_OR_DST_PORT(SNMPTRAP_PORT))
                        snmp_print(ndo, (const u_char *)(up + 1), length);
                        snmp_print(ndo, (const u_char *)(up + 1), length);
-               else if (ISPORT(NTP_PORT))
+               else if (IS_SRC_OR_DST_PORT(NTP_PORT))
                        ntp_print(ndo, (const u_char *)(up + 1), length);
                        ntp_print(ndo, (const u_char *)(up + 1), length);
-               else if (ISPORT(KERBEROS_PORT) || ISPORT(KERBEROS_SEC_PORT))
+               else if (IS_SRC_OR_DST_PORT(KERBEROS_PORT) || IS_SRC_OR_DST_PORT(KERBEROS_SEC_PORT))
                        krb_print(ndo, (const void *)(up + 1));
                        krb_print(ndo, (const void *)(up + 1));
-               else if (ISPORT(L2TP_PORT))
+               else if (IS_SRC_OR_DST_PORT(L2TP_PORT))
                        l2tp_print(ndo, (const u_char *)(up + 1), length);
 #ifdef ENABLE_SMB
                        l2tp_print(ndo, (const u_char *)(up + 1), length);
 #ifdef ENABLE_SMB
-               else if (ISPORT(NETBIOS_NS_PORT))
+               else if (IS_SRC_OR_DST_PORT(NETBIOS_NS_PORT))
                        nbt_udp137_print(ndo, (const u_char *)(up + 1), length);
                        nbt_udp137_print(ndo, (const u_char *)(up + 1), length);
-               else if (ISPORT(NETBIOS_DGRAM_PORT))
+               else if (IS_SRC_OR_DST_PORT(NETBIOS_DGRAM_PORT))
                        nbt_udp138_print(ndo, (const u_char *)(up + 1), length);
 #endif
                else if (dport == VAT_PORT)
                        vat_print(ndo, (const void *)(up + 1), up);
                        nbt_udp138_print(ndo, (const u_char *)(up + 1), length);
 #endif
                else if (dport == VAT_PORT)
                        vat_print(ndo, (const void *)(up + 1), up);
-               else if (ISPORT(ZEPHYR_SRV_PORT) || ISPORT(ZEPHYR_CLT_PORT))
+               else if (IS_SRC_OR_DST_PORT(ZEPHYR_SRV_PORT) || IS_SRC_OR_DST_PORT(ZEPHYR_CLT_PORT))
                        zephyr_print(ndo, (const void *)(up + 1), length);
                /*
                 * Since there are 10 possible ports to check, I think
                        zephyr_print(ndo, (const void *)(up + 1), length);
                /*
                 * Since there are 10 possible ports to check, I think
@@ -595,64 +594,65 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
                         (dport >= RX_PORT_LOW && dport <= RX_PORT_HIGH))
                        rx_print(ndo, (const void *)(up + 1), length, sport, dport,
                                 (const u_char *) ip);
                         (dport >= RX_PORT_LOW && dport <= RX_PORT_HIGH))
                        rx_print(ndo, (const void *)(up + 1), length, sport, dport,
                                 (const u_char *) ip);
-               else if (ISPORT(RIPNG_PORT))
+               else if (IS_SRC_OR_DST_PORT(RIPNG_PORT))
                        ripng_print(ndo, (const u_char *)(up + 1), length);
                        ripng_print(ndo, (const u_char *)(up + 1), length);
-               else if (ISPORT(DHCP6_SERV_PORT) || ISPORT(DHCP6_CLI_PORT))
+               else if (IS_SRC_OR_DST_PORT(DHCP6_SERV_PORT) || IS_SRC_OR_DST_PORT(DHCP6_CLI_PORT))
                        dhcp6_print(ndo, (const u_char *)(up + 1), length);
                        dhcp6_print(ndo, (const u_char *)(up + 1), length);
-               else if (ISPORT(AHCP_PORT))
+               else if (IS_SRC_OR_DST_PORT(AHCP_PORT))
                        ahcp_print(ndo, (const u_char *)(up + 1), length);
                        ahcp_print(ndo, (const u_char *)(up + 1), length);
-               else if (ISPORT(BABEL_PORT) || ISPORT(BABEL_PORT_OLD))
+               else if (IS_SRC_OR_DST_PORT(BABEL_PORT) || IS_SRC_OR_DST_PORT(BABEL_PORT_OLD))
                        babel_print(ndo, (const u_char *)(up + 1), length);
                /*
                 * Kludge in test for whiteboard packets.
                 */
                else if (dport == WB_PORT)
                        wb_print(ndo, (const void *)(up + 1), length);
                        babel_print(ndo, (const u_char *)(up + 1), length);
                /*
                 * Kludge in test for whiteboard packets.
                 */
                else if (dport == WB_PORT)
                        wb_print(ndo, (const void *)(up + 1), length);
-               else if (ISPORT(CISCO_AUTORP_PORT))
+               else if (IS_SRC_OR_DST_PORT(CISCO_AUTORP_PORT))
                        cisco_autorp_print(ndo, (const void *)(up + 1), length);
                        cisco_autorp_print(ndo, (const void *)(up + 1), length);
-               else if (ISPORT(RADIUS_PORT) ||
-                        ISPORT(RADIUS_NEW_PORT) ||
-                        ISPORT(RADIUS_ACCOUNTING_PORT) ||
-                        ISPORT(RADIUS_NEW_ACCOUNTING_PORT) ||
-                        ISPORT(RADIUS_COA_PORT) )
+               else if (IS_SRC_OR_DST_PORT(RADIUS_PORT) ||
+                        IS_SRC_OR_DST_PORT(RADIUS_NEW_PORT) ||
+                        IS_SRC_OR_DST_PORT(RADIUS_ACCOUNTING_PORT) ||
+                        IS_SRC_OR_DST_PORT(RADIUS_NEW_ACCOUNTING_PORT) ||
+                        IS_SRC_OR_DST_PORT(RADIUS_CISCO_COA_PORT) ||
+                        IS_SRC_OR_DST_PORT(RADIUS_COA_PORT) )
                        radius_print(ndo, (const u_char *)(up+1), length);
                else if (dport == HSRP_PORT)
                        hsrp_print(ndo, (const u_char *)(up + 1), length);
                        radius_print(ndo, (const u_char *)(up+1), length);
                else if (dport == HSRP_PORT)
                        hsrp_print(ndo, (const u_char *)(up + 1), length);
-               else if (ISPORT(LWRES_PORT))
+               else if (IS_SRC_OR_DST_PORT(LWRES_PORT))
                        lwres_print(ndo, (const u_char *)(up + 1), length);
                        lwres_print(ndo, (const u_char *)(up + 1), length);
-               else if (ISPORT(LDP_PORT))
+               else if (IS_SRC_OR_DST_PORT(LDP_PORT))
                        ldp_print(ndo, (const u_char *)(up + 1), length);
                        ldp_print(ndo, (const u_char *)(up + 1), length);
-               else if (ISPORT(OLSR_PORT))
+               else if (IS_SRC_OR_DST_PORT(OLSR_PORT))
                        olsr_print(ndo, (const u_char *)(up + 1), length,
                                        (IP_V(ip) == 6) ? 1 : 0);
                        olsr_print(ndo, (const u_char *)(up + 1), length,
                                        (IP_V(ip) == 6) ? 1 : 0);
-               else if (ISPORT(MPLS_LSP_PING_PORT))
+               else if (IS_SRC_OR_DST_PORT(MPLS_LSP_PING_PORT))
                        lspping_print(ndo, (const u_char *)(up + 1), length);
                else if (dport == BFD_CONTROL_PORT ||
                         dport == BFD_ECHO_PORT )
                        bfd_print(ndo, (const u_char *)(up+1), length, dport);
                        lspping_print(ndo, (const u_char *)(up + 1), length);
                else if (dport == BFD_CONTROL_PORT ||
                         dport == BFD_ECHO_PORT )
                        bfd_print(ndo, (const u_char *)(up+1), length, dport);
-                else if (ISPORT(LMP_PORT))
+                else if (IS_SRC_OR_DST_PORT(LMP_PORT))
                        lmp_print(ndo, (const u_char *)(up + 1), length);
                        lmp_print(ndo, (const u_char *)(up + 1), length);
-               else if (ISPORT(VQP_PORT))
+               else if (IS_SRC_OR_DST_PORT(VQP_PORT))
                        vqp_print(ndo, (const u_char *)(up + 1), length);
                        vqp_print(ndo, (const u_char *)(up + 1), length);
-                else if (ISPORT(SFLOW_PORT))
+                else if (IS_SRC_OR_DST_PORT(SFLOW_PORT))
                         sflow_print(ndo, (const u_char *)(up + 1), length);
                else if (dport == LWAPP_CONTROL_PORT)
                        lwapp_control_print(ndo, (const u_char *)(up + 1), length, 1);
                 else if (sport == LWAPP_CONTROL_PORT)
                         lwapp_control_print(ndo, (const u_char *)(up + 1), length, 0);
                         sflow_print(ndo, (const u_char *)(up + 1), length);
                else if (dport == LWAPP_CONTROL_PORT)
                        lwapp_control_print(ndo, (const u_char *)(up + 1), length, 1);
                 else if (sport == LWAPP_CONTROL_PORT)
                         lwapp_control_print(ndo, (const u_char *)(up + 1), length, 0);
-                else if (ISPORT(LWAPP_DATA_PORT))
+                else if (IS_SRC_OR_DST_PORT(LWAPP_DATA_PORT))
                         lwapp_data_print(ndo, (const u_char *)(up + 1), length);
                         lwapp_data_print(ndo, (const u_char *)(up + 1), length);
-                else if (ISPORT(SIP_PORT))
+                else if (IS_SRC_OR_DST_PORT(SIP_PORT))
                        sip_print(ndo, (const u_char *)(up + 1), length);
                        sip_print(ndo, (const u_char *)(up + 1), length);
-                else if (ISPORT(SYSLOG_PORT))
+                else if (IS_SRC_OR_DST_PORT(SYSLOG_PORT))
                        syslog_print(ndo, (const u_char *)(up + 1), length);
                        syslog_print(ndo, (const u_char *)(up + 1), length);
-                else if (ISPORT(OTV_PORT))
+                else if (IS_SRC_OR_DST_PORT(OTV_PORT))
                        otv_print(ndo, (const u_char *)(up + 1), length);
                        otv_print(ndo, (const u_char *)(up + 1), length);
-                else if (ISPORT(VXLAN_PORT))
+                else if (IS_SRC_OR_DST_PORT(VXLAN_PORT))
                        vxlan_print(ndo, (const u_char *)(up + 1), length);
                        vxlan_print(ndo, (const u_char *)(up + 1), length);
-                else if (ISPORT(GENEVE_PORT))
+                else if (IS_SRC_OR_DST_PORT(GENEVE_PORT))
                        geneve_print(ndo, (const u_char *)(up + 1), length);
                        geneve_print(ndo, (const u_char *)(up + 1), length);
-               else if (ISPORT(LISP_CONTROL_PORT))
+               else if (IS_SRC_OR_DST_PORT(LISP_CONTROL_PORT))
                        lisp_print(ndo, (const u_char *)(up + 1), length);
                else {
                        if (ulen > length)
                        lisp_print(ndo, (const u_char *)(up + 1), length);
                else {
                        if (ulen > length)
@@ -661,7 +661,6 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
                        else
                                ND_PRINT((ndo, "UDP, length %u", ulen));
                }
                        else
                                ND_PRINT((ndo, "UDP, length %u", ulen));
                }
-#undef ISPORT
        } else {
                if (ulen > length)
                        ND_PRINT((ndo, "UDP, bad length %u > %u",
        } else {
                if (ulen > length)
                        ND_PRINT((ndo, "UDP, bad length %u > %u",