Skip to content

Commit 80aedf3

Browse files
committed
UDP: Test ports < 1024 in port order to select the printer
Moreover: Replace 'ip6 != NULL' by 'IP_V(ip) == 6'. Replace '(IP_V(ip) == 6) ? 1 : 0)' by 'IP_V(ip) == 6'.
1 parent 5d2bbce commit 80aedf3

File tree

1 file changed

+47
-45
lines changed

1 file changed

+47
-45
lines changed

print-udp.c

+47-45
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,7 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
435435
break;
436436

437437
case PT_AODV:
438-
aodv_print(ndo, cp, length,
439-
ip6 != NULL);
438+
aodv_print(ndo, cp, length, IP_V(ip) == 6);
440439
break;
441440

442441
case PT_RADIUS:
@@ -541,40 +540,63 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
541540
if (IS_SRC_OR_DST_PORT(NAMESERVER_PORT))
542541
/* over_tcp: FALSE, is_mdns: FALSE */
543542
domain_print(ndo, cp, length, FALSE, FALSE);
544-
else if (IS_SRC_OR_DST_PORT(MULTICASTDNS_PORT))
545-
/* over_tcp: FALSE, is_mdns: TRUE */
546-
domain_print(ndo, cp, length, FALSE, TRUE);
547-
else if (IS_SRC_OR_DST_PORT(TIMED_PORT))
548-
timed_print(ndo, (const u_char *)cp);
543+
else if (IS_SRC_OR_DST_PORT(BOOTPC_PORT) ||
544+
IS_SRC_OR_DST_PORT(BOOTPS_PORT))
545+
bootp_print(ndo, cp, length);
549546
else if (IS_SRC_OR_DST_PORT(TFTP_PORT))
550547
tftp_print(ndo, cp, length);
551-
else if (IS_SRC_OR_DST_PORT(BOOTPC_PORT) || IS_SRC_OR_DST_PORT(BOOTPS_PORT))
552-
bootp_print(ndo, cp, length);
548+
else if (IS_SRC_OR_DST_PORT(KERBEROS_PORT))
549+
krb_print(ndo, (const u_char *)cp);
550+
else if (IS_SRC_OR_DST_PORT(NTP_PORT))
551+
ntp_print(ndo, cp, length);
552+
#ifdef ENABLE_SMB
553+
else if (IS_SRC_OR_DST_PORT(NETBIOS_NS_PORT))
554+
nbt_udp137_print(ndo, cp, length);
555+
else if (IS_SRC_OR_DST_PORT(NETBIOS_DGRAM_PORT))
556+
nbt_udp138_print(ndo, cp, length);
557+
#endif
558+
else if (IS_SRC_OR_DST_PORT(SNMP_PORT) ||
559+
IS_SRC_OR_DST_PORT(SNMPTRAP_PORT))
560+
snmp_print(ndo, cp, length);
561+
else if (IS_SRC_OR_DST_PORT(PTP_EVENT_PORT) ||
562+
IS_SRC_OR_DST_PORT(PTP_GENERAL_PORT))
563+
ptp_print(ndo, cp, length);
564+
else if (IS_SRC_OR_DST_PORT(CISCO_AUTORP_PORT))
565+
cisco_autorp_print(ndo, cp, length);
566+
else if (IS_SRC_OR_DST_PORT(ISAKMP_PORT))
567+
isakmp_print(ndo, cp, length, bp2);
568+
else if (IS_SRC_OR_DST_PORT(SYSLOG_PORT))
569+
syslog_print(ndo, cp, length);
553570
else if (IS_SRC_OR_DST_PORT(RIP_PORT))
554571
rip_print(ndo, cp, length);
572+
else if (IS_SRC_OR_DST_PORT(RIPNG_PORT))
573+
ripng_print(ndo, cp, length);
574+
else if (IS_SRC_OR_DST_PORT(TIMED_PORT))
575+
timed_print(ndo, (const u_char *)cp);
576+
else if (IS_SRC_OR_DST_PORT(DHCP6_SERV_PORT) ||
577+
IS_SRC_OR_DST_PORT(DHCP6_CLI_PORT))
578+
dhcp6_print(ndo, cp, length);
579+
else if (IS_SRC_OR_DST_PORT(LDP_PORT))
580+
ldp_print(ndo, cp, length);
555581
else if (IS_SRC_OR_DST_PORT(AODV_PORT))
556-
aodv_print(ndo, cp, length,
557-
ip6 != NULL);
558-
else if (IS_SRC_OR_DST_PORT(ISAKMP_PORT))
559-
isakmp_print(ndo, cp, length, bp2);
582+
aodv_print(ndo, cp, length, IP_V(ip) == 6);
583+
else if (IS_SRC_OR_DST_PORT(OLSR_PORT))
584+
olsr_print(ndo, cp, length, IP_V(ip) == 6);
585+
else if (IS_SRC_OR_DST_PORT(LMP_PORT))
586+
lmp_print(ndo, cp, length);
587+
else if (IS_SRC_OR_DST_PORT(KERBEROS_SEC_PORT))
588+
krb_print(ndo, (const u_char *)cp);
589+
else if (IS_SRC_OR_DST_PORT(LWRES_PORT))
590+
lwres_print(ndo, cp, length);
591+
else if (IS_SRC_OR_DST_PORT(MULTICASTDNS_PORT))
592+
/* over_tcp: FALSE, is_mdns: TRUE */
593+
domain_print(ndo, cp, length, FALSE, TRUE);
560594
else if (IS_SRC_OR_DST_PORT(ISAKMP_PORT_NATT))
561595
isakmp_rfc3948_print(ndo, cp, length, bp2, IP_V(ip), fragmented, ttl_hl);
562596
else if (IS_SRC_OR_DST_PORT(ISAKMP_PORT_USER1) || IS_SRC_OR_DST_PORT(ISAKMP_PORT_USER2))
563597
isakmp_print(ndo, cp, length, bp2);
564-
else if (IS_SRC_OR_DST_PORT(SNMP_PORT) || IS_SRC_OR_DST_PORT(SNMPTRAP_PORT))
565-
snmp_print(ndo, cp, length);
566-
else if (IS_SRC_OR_DST_PORT(NTP_PORT))
567-
ntp_print(ndo, cp, length);
568-
else if (IS_SRC_OR_DST_PORT(KERBEROS_PORT) || IS_SRC_OR_DST_PORT(KERBEROS_SEC_PORT))
569-
krb_print(ndo, (const u_char *)cp);
570598
else if (IS_SRC_OR_DST_PORT(L2TP_PORT))
571599
l2tp_print(ndo, cp, length);
572-
#ifdef ENABLE_SMB
573-
else if (IS_SRC_OR_DST_PORT(NETBIOS_NS_PORT))
574-
nbt_udp137_print(ndo, cp, length);
575-
else if (IS_SRC_OR_DST_PORT(NETBIOS_DGRAM_PORT))
576-
nbt_udp138_print(ndo, cp, length);
577-
#endif
578600
else if (dport == VAT_PORT)
579601
vat_print(ndo, cp, length);
580602
else if (IS_SRC_OR_DST_PORT(ZEPHYR_SRV_PORT) || IS_SRC_OR_DST_PORT(ZEPHYR_CLT_PORT))
@@ -587,10 +609,6 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
587609
(dport >= RX_PORT_LOW && dport <= RX_PORT_HIGH))
588610
rx_print(ndo, cp, length, sport, dport,
589611
(const u_char *) ip);
590-
else if (IS_SRC_OR_DST_PORT(RIPNG_PORT))
591-
ripng_print(ndo, cp, length);
592-
else if (IS_SRC_OR_DST_PORT(DHCP6_SERV_PORT) || IS_SRC_OR_DST_PORT(DHCP6_CLI_PORT))
593-
dhcp6_print(ndo, cp, length);
594612
else if (IS_SRC_OR_DST_PORT(AHCP_PORT))
595613
ahcp_print(ndo, cp, length);
596614
else if (IS_SRC_OR_DST_PORT(BABEL_PORT) || IS_SRC_OR_DST_PORT(BABEL_PORT_OLD))
@@ -602,8 +620,6 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
602620
*/
603621
else if (dport == WB_PORT)
604622
wb_print(ndo, cp, length);
605-
else if (IS_SRC_OR_DST_PORT(CISCO_AUTORP_PORT))
606-
cisco_autorp_print(ndo, cp, length);
607623
else if (IS_SRC_OR_DST_PORT(RADIUS_PORT) ||
608624
IS_SRC_OR_DST_PORT(RADIUS_NEW_PORT) ||
609625
IS_SRC_OR_DST_PORT(RADIUS_ACCOUNTING_PORT) ||
@@ -613,13 +629,6 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
613629
radius_print(ndo, cp, length);
614630
else if (dport == HSRP_PORT)
615631
hsrp_print(ndo, cp, length);
616-
else if (IS_SRC_OR_DST_PORT(LWRES_PORT))
617-
lwres_print(ndo, cp, length);
618-
else if (IS_SRC_OR_DST_PORT(LDP_PORT))
619-
ldp_print(ndo, cp, length);
620-
else if (IS_SRC_OR_DST_PORT(OLSR_PORT))
621-
olsr_print(ndo, cp, length,
622-
(IP_V(ip) == 6) ? 1 : 0);
623632
else if (IS_SRC_OR_DST_PORT(MPLS_LSP_PING_PORT))
624633
lspping_print(ndo, cp, length);
625634
else if (dport == BFD_CONTROL_PORT ||
@@ -630,8 +639,6 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
630639
bfd_print(ndo, cp, length, dport);
631640
else if (sport == SBFD_PORT)
632641
bfd_print(ndo, cp, length, sport);
633-
else if (IS_SRC_OR_DST_PORT(LMP_PORT))
634-
lmp_print(ndo, cp, length);
635642
else if (IS_SRC_OR_DST_PORT(VQP_PORT))
636643
vqp_print(ndo, cp, length);
637644
else if (IS_SRC_OR_DST_PORT(SFLOW_PORT))
@@ -644,8 +651,6 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
644651
lwapp_data_print(ndo, cp, length);
645652
else if (IS_SRC_OR_DST_PORT(SIP_PORT))
646653
sip_print(ndo, cp, length);
647-
else if (IS_SRC_OR_DST_PORT(SYSLOG_PORT))
648-
syslog_print(ndo, cp, length);
649654
else if (IS_SRC_OR_DST_PORT(OTV_PORT))
650655
otv_print(ndo, cp, length);
651656
else if (IS_SRC_OR_DST_PORT(VXLAN_PORT))
@@ -665,9 +670,6 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
665670
if (ndo->ndo_vflag)
666671
ND_PRINT("kip ");
667672
llap_print(ndo, cp, length);
668-
} else if (IS_SRC_OR_DST_PORT(PTP_EVENT_PORT) ||
669-
IS_SRC_OR_DST_PORT(PTP_GENERAL_PORT)) {
670-
ptp_print(ndo, cp, length);
671673
} else if (IS_SRC_OR_DST_PORT(SOMEIP_PORT))
672674
someip_print(ndo, cp, length);
673675
else if (IS_SRC_OR_DST_PORT(HTTPS_PORT) &&

0 commit comments

Comments
 (0)