- lastconn = ((struct ip *)&p[SLX_CHDR])->ip_p;
- hlen = ip->ip_hl;
- hlen += ((struct tcphdr *)&((int *)ip)[hlen])->th_off;
+ lastconn = ((const struct ip *)&p[SLX_CHDR])->ip_p;
+ ND_PRINT((ndo, "utcp %d: ", lastconn));
+ if (dir == -1) {
+ /* Direction is bogus, don't use it */
+ return 0;
+ }
+ ND_TCHECK(*ip);
+ hlen = IP_HL(ip);
+ ND_TCHECK(*((const struct tcphdr *)&((const int *)ip)[hlen]));
+ hlen += TH_OFF((const struct tcphdr *)&((const int *)ip)[hlen]);