#define _KERNEL #include #include #include #include #include #include #include static void print_mbuf(const struct mbuf *m) { struct ip6_hdr *ip6; struct ip *ip; char bufa[50], bufb[50]; printf("mbuf %p: len %u, flags %b\n", m, m->m_len, m->m_flags, M_FLAG_PRINTF); if (m->m_len < sizeof(struct ip)) return; ip = mtod(m, struct ip *); printf("mbuf %p: ip_v %u ", m, ip->ip_v); switch (ip->ip_v) { case IPVERSION: printf("%s->%s %u\n", inet_ntop(AF_INET, &ip->ip_src, bufa, sizeof(ip->ip_src)), inet_ntop(AF_INET, &ip->ip_dst, bufb, sizeof(ip->ip_dst)), ip->ip_p); break; case IPV6_VERSION >> 4: ip6 = mtod(m, struct ip6_hdr *); printf("%s->%s %u\n", inet_ntop(AF_INET6, &ip6->ip6_src, bufa, sizeof(ip6->ip6_src)), inet_ntop(AF_INET6, &ip6->ip6_dst, bufb, sizeof(ip6->ip6_dst)), ip6->ip6_nxt); break; } } int main(int argc, char**argv) { return (0); }