Lines Matching defs:nhc
13 #include "nhc.h"
19 static int lowpan_nhc_insert(struct lowpan_nhc *nhc)
29 len_dif = nhc->idlen - this->idlen;
31 if (nhc->idlen < this->idlen)
32 len = nhc->idlen;
36 result = memcmp(nhc->id, this->id, len);
50 rb_link_node(&nhc->node, parent, new);
51 rb_insert_color(&nhc->node, &rb_root);
56 static void lowpan_nhc_remove(struct lowpan_nhc *nhc)
58 rb_erase(&nhc->node, &rb_root);
67 struct lowpan_nhc *nhc = rb_entry(node, struct lowpan_nhc,
72 if (nhcid_skb_ptr + nhc->idlen > skb->data + skb->len)
76 memcpy(nhcid_skb_ptr_masked, nhcid_skb_ptr, nhc->idlen);
77 for (i = 0; i < nhc->idlen; i++)
78 nhcid_skb_ptr_masked[i] &= nhc->idmask[i];
80 result = memcmp(nhcid_skb_ptr_masked, nhc->id, nhc->idlen);
86 return nhc;
95 struct lowpan_nhc *nhc;
100 nhc = lowpan_nexthdr_nhcs[hdr->nexthdr];
101 if (!(nhc && nhc->compress))
113 struct lowpan_nhc *nhc;
117 nhc = lowpan_nexthdr_nhcs[hdr->nexthdr];
118 /* check if the nhc module was removed in unlocked part.
120 * of nhc modules while unlocked part, this will always drop
128 if (unlikely(!nhc || !nhc->compress)) {
139 ret = nhc->compress(skb, hc_ptr);
144 skb_pull(skb, nhc->nexthdrlen);
156 struct lowpan_nhc *nhc;
161 nhc = lowpan_nhc_by_nhcid(skb);
162 if (nhc) {
163 if (nhc->uncompress) {
164 ret = nhc->uncompress(skb, sizeof(struct ipv6hdr) +
165 nhc->nexthdrlen);
172 netdev_warn(dev, "received nhc id for %s which is not implemented.\n",
173 nhc->name);
178 netdev_warn(dev, "received unknown nhc id which was not found.\n");
182 hdr->nexthdr = nhc->nexthdr;
185 skb_transport_header(skb), nhc->nexthdrlen);
192 int lowpan_nhc_add(struct lowpan_nhc *nhc)
196 if (!nhc->idlen || !nhc->idsetup)
199 WARN_ONCE(nhc->idlen > LOWPAN_NHC_MAX_ID_LEN,
201 nhc->idlen);
203 nhc->idsetup(nhc);
207 if (lowpan_nexthdr_nhcs[nhc->nexthdr]) {
212 ret = lowpan_nhc_insert(nhc);
216 lowpan_nexthdr_nhcs[nhc->nexthdr] = nhc;
223 void lowpan_nhc_del(struct lowpan_nhc *nhc)
227 lowpan_nhc_remove(nhc);
228 lowpan_nexthdr_nhcs[nhc->nexthdr] = NULL;