Lines Matching refs:ep

199 	struct encaptab *ep, *match;  in encap4_lookup()  local
227 while ((ep = thmap_get(emap, &key, sizeof(key))) != NULL) { in encap4_lookup()
230 KASSERT(ep->af == AF_INET); in encap4_lookup()
232 if (ep->proto >= 0 && ep->proto != proto) { in encap4_lookup()
237 psref_acquire(&elem_psref, &ep->psref, in encap4_lookup()
239 if (ep->func) { in encap4_lookup()
241 prio = (*ep->func)(m, off, proto, ep->arg); in encap4_lookup()
248 psref_release(&elem_psref, &ep->psref, in encap4_lookup()
262 match = ep; in encap4_lookup()
265 psref_release(&elem_psref, &ep->psref, in encap4_lookup()
270 PSLIST_READER_FOREACH(ep, &encap_table, struct encaptab, chain) { in encap4_lookup()
273 if (ep->af != AF_INET) in encap4_lookup()
275 if (ep->proto >= 0 && ep->proto != proto) in encap4_lookup()
278 psref_acquire(&elem_psref, &ep->psref, in encap4_lookup()
282 prio = (*ep->func)(m, off, proto, ep->arg); in encap4_lookup()
297 psref_release(&elem_psref, &ep->psref, in encap4_lookup()
310 match = ep; in encap4_lookup()
316 psref_release(&elem_psref, &ep->psref, in encap4_lookup()
363 struct encaptab *ep, *match; in encap6_lookup() local
389 while ((ep = thmap_get(emap, &key, sizeof(key))) != NULL) { in encap6_lookup()
392 KASSERT(ep->af == AF_INET6); in encap6_lookup()
394 if (ep->proto >= 0 && ep->proto != proto) { in encap6_lookup()
399 psref_acquire(&elem_psref, &ep->psref, in encap6_lookup()
401 if (ep->func) { in encap6_lookup()
403 prio = (*ep->func)(m, off, proto, ep->arg); in encap6_lookup()
410 psref_release(&elem_psref, &ep->psref, in encap6_lookup()
424 match = ep; in encap6_lookup()
426 psref_release(&elem_psref, &ep->psref, in encap6_lookup()
431 PSLIST_READER_FOREACH(ep, &encap_table, struct encaptab, chain) { in encap6_lookup()
434 if (ep->af != AF_INET6) in encap6_lookup()
436 if (ep->proto >= 0 && ep->proto != proto) in encap6_lookup()
439 psref_acquire(&elem_psref, &ep->psref, in encap6_lookup()
444 prio = (*ep->func)(m, off, proto, ep->arg); in encap6_lookup()
449 psref_release(&elem_psref, &ep->psref, in encap6_lookup()
462 match = ep; in encap6_lookup()
468 psref_release(&elem_psref, &ep->psref, in encap6_lookup()
514 encap_add(struct encaptab *ep) in encap_add() argument
519 PSLIST_WRITER_INSERT_HEAD(&encap_table, ep, chain); in encap_add()
525 encap_remove(struct encaptab *ep) in encap_remove() argument
531 PSLIST_WRITER_REMOVE(ep, chain); in encap_remove()
553 struct encaptab *ep; in encap_attach_func() local
571 ep = kmem_alloc(sizeof(*ep), KM_SLEEP); in encap_attach_func()
572 memset(ep, 0, sizeof(*ep)); in encap_attach_func()
574 ep->af = af; in encap_attach_func()
575 ep->proto = proto; in encap_attach_func()
576 ep->func = func; in encap_attach_func()
577 ep->esw = esw; in encap_attach_func()
578 ep->arg = arg; in encap_attach_func()
579 psref_target_init(&ep->psref, encaptab.elem_class); in encap_attach_func()
581 error = encap_add(ep); in encap_attach_func()
589 return ep; in encap_attach_func()
592 kmem_free(ep, sizeof(*ep)); in encap_attach_func()
642 struct encaptab *ep; in encap_attach_addr() local
670 ep = kmem_zalloc(sizeof(*ep), KM_SLEEP); in encap_attach_addr()
671 ep->addrpack = kmem_zalloc(l, KM_SLEEP); in encap_attach_addr()
672 ep->addrpack->sa_len = l & 0xff; in encap_attach_addr()
673 ep->af = af; in encap_attach_addr()
674 ep->proto = proto; in encap_attach_addr()
675 ep->flag = IP_ENCAP_ADDR_ENABLE; in encap_attach_addr()
678 pack4 = (struct ip_pack4 *)ep->addrpack; in encap_attach_addr()
679 ep->src = (struct sockaddr *)&pack4->mine; in encap_attach_addr()
680 ep->dst = (struct sockaddr *)&pack4->yours; in encap_attach_addr()
684 pack6 = (struct ip_pack6 *)ep->addrpack; in encap_attach_addr()
685 ep->src = (struct sockaddr *)&pack6->mine; in encap_attach_addr()
686 ep->dst = (struct sockaddr *)&pack6->yours; in encap_attach_addr()
690 memcpy(ep->src, src, src->sa_len); in encap_attach_addr()
691 memcpy(ep->dst, dst, dst->sa_len); in encap_attach_addr()
692 ep->esw = esw; in encap_attach_addr()
693 ep->arg = arg; in encap_attach_addr()
694 ep->func = func; in encap_attach_addr()
695 psref_target_init(&ep->psref, encaptab.elem_class); in encap_attach_addr()
697 encap_key_init(&ep->key, src, dst); in encap_attach_addr()
698 while ((retep = thmap_put(emap, &ep->key, sizeof(ep->key), ep)) != ep) in encap_attach_addr()
699 encap_key_inc(&ep->key); in encap_attach_addr()
700 return ep; in encap_attach_addr()
717 struct encaptab *ep; in encap6_ctlinput() local
775 PSLIST_READER_FOREACH(ep, &encap_table, struct encaptab, chain) { in encap6_ctlinput()
778 if (ep->af != AF_INET6) in encap6_ctlinput()
780 if (ep->proto >= 0 && ep->proto != nxt) in encap6_ctlinput()
786 psref_acquire(&elem_psref, &ep->psref, in encap6_ctlinput()
788 esw = ep->esw; in encap6_ctlinput()
792 (*esw->encapsw6.pr_ctlinput)(cmd, sa, d, ep->arg); in encap6_ctlinput()
795 psref_release(&elem_psref, &ep->psref, in encap6_ctlinput()
806 encap_detach_addr(const struct encaptab *ep) in encap_detach_addr() argument
815 KASSERT(ep->flag & IP_ENCAP_ADDR_ENABLE); in encap_detach_addr()
817 switch (ep->af) { in encap_detach_addr()
830 retep = thmap_del(emap, &ep->key, sizeof(ep->key)); in encap_detach_addr()
831 if (retep != ep) { in encap_detach_addr()
839 encap_key_copy(&key, &ep->key); in encap_detach_addr()
864 const struct encaptab *ep = cookie; in encap_detach() local
870 if (ep->flag & IP_ENCAP_ADDR_ENABLE) in encap_detach()
871 return encap_detach_addr(ep); in encap_detach()
874 if (p == ep) { in encap_detach()