X-Git-Url: http://git.onelab.eu/?p=ipfw.git;a=blobdiff_plain;f=dummynet2%2Finclude%2Fsys%2Fmbuf.h;fp=dummynet2%2Finclude%2Fsys%2Fmbuf.h;h=e65bbb6eded55969c95ba9005e52b1b2a9399ce7;hp=a752ebdfc3c3ac13e3c3fb6bcfbd9c74b27b5bda;hb=28a7fe9d930667786b902af6697c01eb87694173;hpb=2a8b6c544cf5ea3c84f763144c7ecfa79daea969 diff --git a/dummynet2/include/sys/mbuf.h b/dummynet2/include/sys/mbuf.h index a752ebd..e65bbb6 100644 --- a/dummynet2/include/sys/mbuf.h +++ b/dummynet2/include/sys/mbuf.h @@ -164,10 +164,20 @@ m_tag_delete(struct mbuf *m, struct m_tag *t) static __inline struct m_tag * m_tag_locate(struct mbuf *m, u_int32_t n, int x, struct m_tag *t) { - return NULL; + struct m_tag *tag; + + tag = m_tag_first(m); + if (tag == NULL) + return NULL; + + if (tag->m_tag_cookie != n || tag->m_tag_id != x) + return NULL; + else + return tag; }; #define M_SETFIB(_m, _fib) /* nothing on linux */ + static __inline void m_freem(struct mbuf *m) { @@ -187,6 +197,29 @@ m_freem(struct mbuf *m) #define M_GETFIB(_m) 0 +/* macro used to create a new mbuf */ +#define MT_DATA 1 /* dynamic (data) allocation */ +#define MSIZE 256 /* size of an mbuf */ +#define MGETHDR(_m, _how, _type) ((_m) = m_gethdr((_how), (_type))) + +/* allocate and init a new mbuf using the same structure of FreeBSD */ +static __inline struct mbuf * +m_gethdr(int how, short type) +{ + struct mbuf *m; + + m = malloc(MSIZE, M_IPFW, M_NOWAIT); + + if (m == NULL) { + return m; + } + + /* here we have MSIZE - sizeof(struct mbuf) available */ + m->m_data = m + 1; + + return m; +} + #endif /* __linux__ || _WIN32 */ /*