- if (ip6) {
- if (ip6->ip6_nxt == IPPROTO_UDP) {
- if (sport == -1) {
- ND_PRINT((ndo, "%s > %s: ",
- ip6addr_string(ndo, &ip6->ip6_src),
- ip6addr_string(ndo, &ip6->ip6_dst)));
- } else {
- ND_PRINT((ndo, "%s.%s > %s.%s: ",
- ip6addr_string(ndo, &ip6->ip6_src),
- udpport_string(ndo, sport),
- ip6addr_string(ndo, &ip6->ip6_dst),
- udpport_string(ndo, dport)));
- }
- } else {
- if (sport != -1) {
- ND_PRINT((ndo, "%s > %s: ",
- udpport_string(ndo, sport),
- udpport_string(ndo, dport)));
- }
- }
- } else {
- if (ip->ip_p == IPPROTO_UDP) {
- if (sport == -1) {
- ND_PRINT((ndo, "%s > %s: ",
- ipaddr_string(ndo, &ip->ip_src),
- ipaddr_string(ndo, &ip->ip_dst)));
- } else {
- ND_PRINT((ndo, "%s.%s > %s.%s: ",
- ipaddr_string(ndo, &ip->ip_src),
- udpport_string(ndo, sport),
- ipaddr_string(ndo, &ip->ip_dst),
- udpport_string(ndo, dport)));
- }
- } else {
- if (sport != -1) {
- ND_PRINT((ndo, "%s > %s: ",
- udpport_string(ndo, sport),
- udpport_string(ndo, dport)));
- }
- }
+static void
+udpipaddr_noport_print(netdissect_options *ndo, const struct ip *ip)
+{
+ const struct ip6_hdr *ip6 = (const struct ip6_hdr *)ip;
+
+ if (IP_V(ip) == 4 && GET_U_1(ip->ip_p) == IPPROTO_UDP) {
+ ND_PRINT("%s > %s: ",
+ GET_IPADDR_STRING(ip->ip_src),
+ GET_IPADDR_STRING(ip->ip_dst));
+ } else if (IP_V(ip) == 6 && GET_U_1(ip6->ip6_nxt) == IPPROTO_UDP) {
+ ND_PRINT("%s > %s: ",
+ GET_IP6ADDR_STRING(ip6->ip6_src),
+ GET_IP6ADDR_STRING(ip6->ip6_dst));