2 * All very trivial - the simpler the better I say. We try and keep
3 * quqes of netbufs by squirreling a pointer away below the data area.
4 * This is done by the ppp_nb_alloc function. As long as everyone
5 * uses the ppp shrink and grow functions we should be o.k. This code
6 * has now been modified to keep the mark_t stuff nhere as well since
7 * we probably shafted that good and proper in the last version. oops !
16 #include <sys/types.h>
17 #if !(NS_TARGET >= 40)
18 #include <kernserv/prototypes.h>
19 #endif /* NS_TARGET */
24 #define NETBUF_T netbuf_t
25 #define NB_ALLOC ppp_nb_alloc
26 #define NB_FREE nb_free
28 #define NB_SIZE nb_size
29 #define NB_SHRINK_TOP ppp_nb_shrink_top
30 #define NB_GROW_TOP ppp_nb_grow_top
31 #define NB_SHRINK_BOT nb_shrink_bot
32 #define NB_GROW_BOT nb_grow_bot
33 #define NB_READ nb_read
34 #define NB_WRITE nb_write
35 #define NB_GET_MARK nb_get_mark
36 #define NB_SET_MARK nb_set_mark
37 #define NB_GET_NEXT nb_get_next
38 #define NB_SET_NEXT nb_set_next
39 #define nb_TO_NB(nb) (nb)
40 #define NB_TO_nb(NB) (NB)
44 u_char q_low, q_high, q_max;
50 int low, high, max, len, dropped;
54 #define NB_EXTRA (sizeof(mark_t)+sizeof(netbuf_t))
57 nb_set_next(netbuf_t nb, netbuf_t ptr)
59 if(nb) bcopy(&ptr,NB_MAP(nb)-sizeof(netbuf_t),sizeof(netbuf_t));
63 nb_get_next(netbuf_t nb, netbuf_t *ptr)
65 if(nb && ptr) bcopy(NB_MAP(nb)-sizeof(netbuf_t),ptr,sizeof(netbuf_t));
69 nb_set_mark(netbuf_t nb, mark_t ptr)
71 if(nb) bcopy(&ptr,NB_MAP(nb)-NB_EXTRA,sizeof(mark_t));
75 nb_get_mark(netbuf_t nb, mark_t *ptr)
77 if(nb && ptr) bcopy(NB_MAP(nb)-NB_EXTRA,ptr,sizeof(mark_t));
81 ppp_nb_shrink_top(netbuf_t nb, unsigned int size)
86 NB_GET_MARK(nb,&mark);
87 nb_shrink_top(nb,size);
93 ppp_nb_grow_top(netbuf_t nb, unsigned int size)
98 NB_GET_MARK(nb,&mark);
100 NB_SET_MARK(nb,mark);
105 static inline netbuf_t
106 ppp_nb_alloc(unsigned int size)
113 nb_shrink_top(nb,NB_EXTRA);
114 NB_SET_NEXT(nb,NULL);
119 #endif /* __NBQ_H__ */