- ip = (struct ip *)bp2;
-
- if (!nflag)
- (void)printf("%s.%x > %s.sunrpc: %d",
- ipaddr_string(&ip->ip_src),
- (u_int32_t)ntohl(rp->rm_xid),
- ipaddr_string(&ip->ip_dst),
- length);
- else
- (void)printf("%s.%x > %s.%x: %d",
- ipaddr_string(&ip->ip_src),
- (u_int32_t)ntohl(rp->rm_xid),
- ipaddr_string(&ip->ip_dst),
- PMAPPORT,
- length);
+
+ if (!nflag) {
+ snprintf(srcid, sizeof(srcid), "0x%x",
+ (u_int32_t)ntohl(rp->rm_xid));
+ strlcpy(dstid, "sunrpc", sizeof(dstid));
+ } else {
+ snprintf(srcid, sizeof(srcid), "0x%x",
+ (u_int32_t)ntohl(rp->rm_xid));
+ snprintf(dstid, sizeof(dstid), "0x%x", PMAPPORT);
+ }
+
+ switch (IP_V((struct ip *)bp2)) {
+ case 4:
+ ip = (struct ip *)bp2;
+ printf("%s.%s > %s.%s: %d",
+ ipaddr_string(&ip->ip_src), srcid,
+ ipaddr_string(&ip->ip_dst), dstid, length);
+ break;
+#ifdef INET6
+ case 6:
+ ip6 = (struct ip6_hdr *)bp2;
+ printf("%s.%s > %s.%s: %d",
+ ip6addr_string(&ip6->ip6_src), srcid,
+ ip6addr_string(&ip6->ip6_dst), dstid, length);
+ break;
+#endif
+ default:
+ printf("%s.%s > %s.%s: %d", "?", srcid, "?", dstid, length);
+ break;
+ }
+