diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2010-10-28 16:28:57 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2010-10-28 16:28:57 +0000 |
commit | e44c4bf24e035a4ee356a282f077b8ef70c42f6a (patch) | |
tree | 0ad9c8960387ef53c5e16d6673667daf3bbd0f70 | |
parent | e455783169329159cfa21db088b71e9d116ae4b8 (diff) |
Add m_print() a function to print mbuf headers. Can be called from ddb
with an mbuf pointer as argument to see the contents of it.
OK thib@, deraadt@
-rw-r--r-- | sys/kern/uipc_mbuf.c | 46 | ||||
-rw-r--r-- | sys/sys/mbuf.h | 5 |
2 files changed, 49 insertions, 2 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index d484b0957aa..b082e35c4d1 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_mbuf.c,v 1.145 2010/10/05 13:29:40 mikeb Exp $ */ +/* $OpenBSD: uipc_mbuf.c,v 1.146 2010/10/28 16:28:56 claudio Exp $ */ /* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */ /* @@ -1370,3 +1370,47 @@ m_dup_pkthdr(struct mbuf *to, struct mbuf *from) return (0); } + +#ifdef DDB +void +m_print(struct mbuf *m) +{ + printf("mbuf %p\n", m); + printf("m_type: %hi\tm_flags: %b\n", m->m_type, m->m_flags, + "\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_CLUSTER\5M_PROTO1\6M_VLANTAG" + "\7M_LOOP\10M_FILDROP\11M_BCAST\12M_MCAST\13M_CONF\14M_AUTH" + "\15M_TUNNEL\16M_AUTH_AH\17M_LINK0"); + printf("m_next: %p\tm_nextpkt: %p\n", m->m_next, m->m_nextpkt); + printf("m_data: %p\tm_len: %u\n", m->m_data, m->m_len); + printf("m_dat: %p m_pktdat: %p\n", m->m_dat, m->m_pktdat); + if (m->m_flags & M_PKTHDR) { + printf("m_pkthdr.len: %i\tm_ptkhdr.rcvif: %p\t" + "m_ptkhdr.rdomain: %u\n", m->m_pkthdr.len, + m->m_pkthdr.rcvif, m->m_pkthdr.rdomain); + printf("m_ptkhdr.tags: %p\tm_pkthdr.tagsset: %hx\n", + SLIST_FIRST(&m->m_pkthdr.tags), m->m_pkthdr.tagsset); + printf("m_pkthdr.csum_flags: %hx\tm_pkthdr.ether_vtag: %hu\n", + m->m_pkthdr.csum_flags, m->m_pkthdr.ether_vtag); + printf("m_pkthdr.pf.flags: %b\n", + m->m_pkthdr.pf.flags, "\20\1GENERATED\2FRAGCACHE" + "\3TRANSLATE_LOCALHOST\4DIVERTED\5DIVERTED_PACKET" + "\6PF_TAG_REROUTE"); + printf("m_pkthdr.pf.hdr: %p\tm_pkthdr.pf.statekey: %p\n", + m->m_pkthdr.pf.hdr, m->m_pkthdr.pf.statekey); + printf("m_pkthdr.pf.qid:\t%u m_pkthdr.pf.tag: %hu\n", + m->m_pkthdr.pf.qid, m->m_pkthdr.pf.tag); + printf("m_pkthdr.pf.routed: %hhx\n", m->m_pkthdr.pf.routed); + } + if (m->m_flags & M_EXT) { + printf("m_ext.ext_buf: %p\tm_ext.ext_size: %u\n", + m->m_ext.ext_buf, m->m_ext.ext_size); + printf("m_ext.ext_type: %x\tm_ext.ext_backend: %i\n", + m->m_ext.ext_type, m->m_ext.ext_backend); + printf("m_ext.ext_ifp: %p\n", m->m_ext.ext_ifp); + printf("m_ext.ext_free: %p\tm_ext.ext_arg: %p\n", + m->m_ext.ext_free, m->m_ext.ext_arg); + printf("m_ext.ext_nextref: %p\tm_ext.ext_prevref: %p\n", + m->m_ext.ext_nextref, m->m_ext.ext_prevref); + } +} +#endif diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index e3a134669da..50ac4cad89b 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mbuf.h,v 1.142 2010/07/14 10:31:54 matthew Exp $ */ +/* $OpenBSD: mbuf.h,v 1.143 2010/10/28 16:28:56 claudio Exp $ */ /* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */ /* @@ -420,6 +420,9 @@ void m_zero(struct mbuf *); int m_apply(struct mbuf *, int, int, int (*)(caddr_t, caddr_t, unsigned int), caddr_t); int m_dup_pkthdr(struct mbuf *, struct mbuf *); +#ifdef DDB +void m_print(struct mbuf *); +#endif /* Packet tag routines */ struct m_tag *m_tag_get(int, int, int); |