Lines Matching defs:np

90 static int ndrv_setspec(struct ndrv_cb *np, struct sockopt *sopt);
94 static int ndrv_do_add_multicast(struct ndrv_cb *np, struct sockopt *sopt);
95 static int ndrv_do_remove_multicast(struct ndrv_cb *np, struct sockopt *sopt);
96 static struct ndrv_multiaddr* ndrv_have_multicast(struct ndrv_cb *np, struct sockaddr* addr);
97 static void ndrv_remove_all_multicast(struct ndrv_cb *np);
132 struct ndrv_cb *np = sotondrvcb(so);
133 struct ifnet *ifp = np->nd_if;
137 kprintf("NDRV output: %x, %x, %x\n", m, so, np);
153 result = ifnet_output_raw(ifp, np->nd_proto_family, m);
170 struct ndrv_cb *np;
185 np = ndrv_find_inbound(ifp, proto_family);
186 if (np == NULL)
190 so = np->nd_socket;
214 struct ndrv_cb *np = sotondrvcb(so);
220 kprintf("NDRV attach: %x, %x, %x\n", so, proto, np);
226 MALLOC(np, struct ndrv_cb *, sizeof(*np), M_PCB, M_WAITOK);
227 if (np == NULL)
229 so->so_pcb = (caddr_t)np;
230 bzero(np, sizeof(*np));
232 kprintf("NDRV attach: %x, %x, %x\n", so, proto, np);
234 TAILQ_INIT(&np->nd_dlist);
235 np->nd_signature = NDRV_SIGNATURE;
236 np->nd_socket = so;
237 np->nd_proto.sp_family = so->so_proto->pr_domain->dom_family;
238 np->nd_proto.sp_protocol = proto;
239 np->nd_if = NULL;
240 np->nd_proto_family = 0;
241 np->nd_family = 0;
242 np->nd_unit = 0;
243 TAILQ_INSERT_TAIL(&ndrvl, np, nd_next);
255 struct ndrv_cb *np = sotondrvcb(so);
257 if (np == 0)
259 return ndrv_do_detach(np);
275 struct ndrv_cb *np = sotondrvcb(so);
277 if (np == 0)
280 if (np->nd_faddr)
284 MALLOC(np->nd_faddr, struct sockaddr_ndrv*,
286 if (np->nd_faddr == NULL)
289 bcopy((caddr_t) nam, (caddr_t) np->nd_faddr, nam->sa_len);
321 struct ndrv_cb *np;
327 np = sotondrvcb(so);
328 if (np == 0)
331 if (np->nd_laddr)
335 np->nd_laddr = _MALLOC(sizeof(struct sockaddr_ndrv), M_IFADDR, M_WAITOK);
336 if (np->nd_laddr == NULL)
338 bcopy((caddr_t) sa, (caddr_t) np->nd_laddr, sizeof(struct sockaddr_ndrv));
343 kprintf("NDRV bind: %x, %x, %s\n", so, np, dname);
375 np->nd_proto_family = PF_NDRV;
378 np->nd_proto_family = 0;
381 np->nd_if = ifp;
382 np->nd_family = ifnet_family(ifp);
383 np->nd_unit = ifnet_unit(ifp);
391 struct ndrv_cb *np = sotondrvcb(so);
393 if (np == 0)
396 if (np->nd_faddr == 0)
399 ndrv_do_disconnect(np);
438 struct ndrv_cb *np = sotondrvcb(so);
440 if (np == 0)
443 ndrv_do_disconnect(np);
450 struct ndrv_cb *np = sotondrvcb(so);
453 if (np == 0)
456 if (np->nd_laddr == 0)
459 len = np->nd_laddr->snd_len;
463 bcopy((caddr_t)np->nd_laddr, *nam,
472 struct ndrv_cb *np = sotondrvcb(so);
475 if (np == 0)
478 if (np->nd_faddr == 0)
481 len = np->nd_faddr->snd_len;
485 bcopy((caddr_t)np->nd_faddr, *nam,
496 struct ndrv_cb *np = sotondrvcb(so);
510 error = ndrv_delspec(np);
513 error = ndrv_setspec(np, sopt);
516 error = ndrv_do_add_multicast(np, sopt);
519 error = ndrv_do_remove_multicast(np, sopt);
532 ndrv_do_detach(struct ndrv_cb *np)
535 struct socket *so = np->nd_socket;
540 kprintf("NDRV detach: %x, %x\n", so, np);
542 ndrv_remove_all_multicast(np);
544 ifp = np->nd_if;
546 TAILQ_REMOVE(&ndrvl, np, nd_next);
548 u_int32_t proto_family = np->nd_proto_family;
558 if (cur_np->nd_family == np->nd_family &&
559 cur_np->nd_unit == np->nd_unit) {
571 if (np->nd_laddr != NULL) {
572 FREE((caddr_t)np->nd_laddr, M_IFADDR);
573 np->nd_laddr = NULL;
575 FREE((caddr_t)np, M_PCB);
583 ndrv_do_disconnect(struct ndrv_cb *np)
585 struct socket * so = np->nd_socket;
587 kprintf("NDRV disconnect: %x\n", np);
589 if (np->nd_faddr)
591 FREE(np->nd_faddr, M_IFADDR);
592 np->nd_faddr = 0;
595 ndrv_do_detach(np);
658 ndrv_setspec(struct ndrv_cb *np, struct sockopt *sopt)
664 struct socket * so = np->nd_socket;
668 if (np->nd_proto_family != PF_NDRV)
670 if (np->nd_if == NULL)
762 error = ifnet_attach_protocol(np->nd_if, ndrvSpec.protocol_family,
766 np->nd_proto_family = ndrvSpec.protocol_family;
803 ndrv_delspec(struct ndrv_cb *np)
807 if (np->nd_proto_family == PF_NDRV ||
808 np->nd_proto_family == 0)
812 result = ifnet_detach_protocol(np->nd_if, np->nd_proto_family);
813 np->nd_proto_family = PF_NDRV;
821 struct ndrv_cb* np;
825 TAILQ_FOREACH(np, &ndrvl, nd_next) {
826 if (np->nd_proto_family == protocol &&
827 np->nd_if == ifp) {
828 return np;
847 struct ndrv_cb* np;
852 TAILQ_FOREACH(np, &ndrvl, nd_next) {
853 if (np->nd_family == family &&
854 np->nd_unit == unit)
858 ifp = np->nd_if;
859 if (np->nd_proto_family != 0)
860 ndrv_delspec(np);
863 ndrv_remove_all_multicast(np);
866 np->nd_if = NULL;
867 np->nd_unit = 0;
868 np->nd_family = 0;
870 so = np->nd_socket;
886 ndrv_do_add_multicast(struct ndrv_cb *np, struct sockopt *sopt)
894 if (np->nd_if == NULL)
896 if (!(np->nd_dlist_cnt < ndrv_multi_max_count))
912 if (result == 0 && ndrv_have_multicast(np, &ndrv_multi->addr))
918 result = ifnet_add_multicast(np->nd_if, &ndrv_multi->addr,
925 ndrv_multi->next = np->nd_multiaddrs;
926 np->nd_multiaddrs = ndrv_multi;
927 np->nd_dlist_cnt++;
939 ndrv_do_remove_multicast(struct ndrv_cb *np, struct sockopt *sopt)
948 if (np->nd_if == NULL || np->nd_dlist_cnt == 0)
967 ndrv_entry = ndrv_have_multicast(np, multi_addr);
982 struct ndrv_multiaddr* cur = np->nd_multiaddrs;
988 np->nd_multiaddrs = cur->next;
1002 np->nd_dlist_cnt--;
1013 ndrv_have_multicast(struct ndrv_cb *np, struct sockaddr* inAddr)
1016 for (cur = np->nd_multiaddrs; cur != NULL; cur = cur->next)
1031 ndrv_remove_all_multicast(struct ndrv_cb* np)
1035 if (np->nd_if != NULL)
1037 while (np->nd_multiaddrs != NULL)
1039 cur = np->nd_multiaddrs;
1040 np->nd_multiaddrs = cur->next;