Lines Matching defs:pcbinfo
190 in_pcballoc(struct socket *so, struct inpcbinfo *pcbinfo, __unused struct proc *p)
207 inp = (struct inpcb *) zalloc(pcbinfo->ipi_zone);
222 inp->inp_gencnt = ++pcbinfo->ipi_gencnt;
223 inp->inp_pcbinfo = pcbinfo;
229 zfree(pcbinfo->ipi_zone, inp);
240 inp->inpcb_mtx = lck_mtx_alloc_init(pcbinfo->mtx_grp, pcbinfo->mtx_attr);
252 zfree(pcbinfo->ipi_zone, inp);
267 lck_rw_lock_exclusive(pcbinfo->mtx);
268 inp->inp_gencnt = ++pcbinfo->ipi_gencnt;
269 LIST_INSERT_HEAD(pcbinfo->listhead, inp, inp_list);
270 pcbinfo->ipi_count++;
271 lck_rw_done(pcbinfo->mtx);
287 struct inpcbinfo *pcbinfo,
295 inp = in_pcblookup_local(pcbinfo, laddr, lport_arg, wild_okay);
354 struct inpcbinfo *pcbinfo = inp->inp_pcbinfo;
366 lck_rw_lock_exclusive(pcbinfo->mtx);
370 lck_rw_done(pcbinfo->mtx);
380 lck_rw_done(pcbinfo->mtx);
400 lck_rw_done(pcbinfo->mtx);
414 lck_rw_done(pcbinfo->mtx);
443 lck_rw_done(pcbinfo->mtx);
448 lck_rw_done(pcbinfo->mtx);
456 t = in_pcblookup_local_and_cleanup(pcbinfo, sin->sin_addr,
475 lck_rw_done(pcbinfo->mtx);
480 lck_rw_done(pcbinfo->mtx);
498 lastport = &pcbinfo->lasthi;
501 lck_rw_done(pcbinfo->mtx);
507 lastport = &pcbinfo->lastlow;
511 lastport = &pcbinfo->lastport;
528 lck_rw_done(pcbinfo->mtx);
537 } while (in_pcblookup_local_and_cleanup(pcbinfo,
547 lck_rw_done(pcbinfo->mtx);
556 } while (in_pcblookup_local_and_cleanup(pcbinfo,
565 lck_rw_done(pcbinfo->mtx);
568 lck_rw_done(pcbinfo->mtx);
978 in_pcbnotifyall(struct inpcbinfo *pcbinfo, struct in_addr faddr,
983 lck_rw_lock_shared(pcbinfo->mtx);
985 LIST_FOREACH(inp, pcbinfo->listhead, inp_list) {
1000 lck_rw_done(pcbinfo->mtx);
1115 in_pcblookup_local(struct inpcbinfo *pcbinfo, struct in_addr laddr,
1130 head = &pcbinfo->hashbase[INP_PCBHASH(INADDR_ANY, lport, 0, pcbinfo->hashmask)];
1160 porthash = &pcbinfo->porthashbase[INP_PCBPORTHASH(lport,
1161 pcbinfo->porthashmask)];
1207 struct inpcbinfo *pcbinfo,
1223 lck_rw_lock_shared(pcbinfo->mtx);
1228 head = &pcbinfo->hashbase[INP_PCBHASH(faddr.s_addr, lport, fport, pcbinfo->hashmask)];
1242 lck_rw_done(pcbinfo->mtx);
1246 lck_rw_done(pcbinfo->mtx);
1257 head = &pcbinfo->hashbase[INP_PCBHASH(INADDR_ANY, lport, 0, pcbinfo->hashmask)];
1272 lck_rw_done(pcbinfo->mtx);
1276 lck_rw_done(pcbinfo->mtx);
1295 lck_rw_done(pcbinfo->mtx);
1299 lck_rw_done(pcbinfo->mtx);
1304 lck_rw_done(pcbinfo->mtx);
1308 lck_rw_done(pcbinfo->mtx);
1312 lck_rw_done(pcbinfo->mtx);
1320 lck_rw_done(pcbinfo->mtx);
1332 struct inpcbinfo *pcbinfo = inp->inp_pcbinfo;
1343 inp->hash_element = INP_PCBHASH(hashkey_faddr, inp->inp_lport, inp->inp_fport, pcbinfo->hashmask);
1346 if (!lck_rw_try_lock_exclusive(pcbinfo->mtx)) {
1349 lck_rw_lock_exclusive(pcbinfo->mtx);
1354 pcbhash = &pcbinfo->hashbase[inp->hash_element];
1356 pcbporthash = &pcbinfo->porthashbase[INP_PCBPORTHASH(inp->inp_lport,
1357 pcbinfo->porthashmask)];
1373 lck_rw_done(pcbinfo->mtx);
1384 lck_rw_done(pcbinfo->mtx);
1439 in_pcb_grab_port (struct inpcbinfo *pcbinfo,
1454 pcbinfo->nat_dummy_socket.so_pcb = 0;
1455 pcbinfo->nat_dummy_socket.so_options = 0;
1465 pcbinfo->nat_dummy_socket.so_pcb = (caddr_t)pcbinfo->nat_dummy_pcb;
1469 inp = in_pcblookup_hash(pcbinfo, faddr, fport, laddr, *lport, 0, NULL);
1474 pcbinfo->nat_dummy_socket.so_pcb = (caddr_t)pcbinfo->nat_dummy_pcb;
1479 stat = in_pcballoc(&pcbinfo->nat_dummy_socket, pcbinfo, p);
1481 pcbinfo->nat_dummy_socket.so_pcb = (caddr_t)pcbinfo->nat_dummy_pcb;
1484 pcb = sotoinpcb(&pcbinfo->nat_dummy_socket);
1493 lck_rw_lock_exclusive(pcbinfo->mtx);
1495 lck_rw_done(pcbinfo->mtx);
1507 stat = in_pcballoc(&pcbinfo->nat_dummy_socket, pcbinfo, p);
1509 pcbinfo->nat_dummy_socket.so_pcb = (caddr_t)pcbinfo->nat_dummy_pcb;
1512 pcb = sotoinpcb(&pcbinfo->nat_dummy_socket);
1515 pcbinfo->nat_dummy_socket.so_options = options;
1522 socket_lock(&pcbinfo->nat_dummy_socket, 1);
1523 stat = in_pcbbind((struct inpcb *) pcbinfo->nat_dummy_socket.so_pcb,
1526 socket_unlock(&pcbinfo->nat_dummy_socket, 1); /*detach first */
1530 socket_unlock(&pcbinfo->nat_dummy_socket, 1);
1536 stat = in_pcballoc(&pcbinfo->nat_dummy_socket, pcbinfo, p);
1538 pcbinfo->nat_dummy_socket.so_pcb = (caddr_t)pcbinfo->nat_dummy_pcb;
1541 pcb = sotoinpcb(&pcbinfo->nat_dummy_socket);
1561 socket_lock(&pcbinfo->nat_dummy_socket, 1);
1562 stat = in_pcbbind((struct inpcb *) pcbinfo->nat_dummy_socket.so_pcb,
1565 socket_unlock(&pcbinfo->nat_dummy_socket, 1);
1570 socket_unlock(&pcbinfo->nat_dummy_socket, 1);
1571 inp = in_pcblookup_hash(pcbinfo, faddr, fport,
1580 lck_rw_lock_exclusive(pcbinfo->mtx);
1584 lck_rw_done(pcbinfo->mtx);
1592 socket_lock(&pcbinfo->nat_dummy_socket, 1);
1593 stat = in_pcbbind((struct inpcb *) pcbinfo->nat_dummy_socket.so_pcb,
1596 socket_unlock(&pcbinfo->nat_dummy_socket, 1);
1600 socket_unlock(&pcbinfo->nat_dummy_socket, 1);
1608 pcb->inp_ppcb = (caddr_t) pcbinfo->dummy_cb;
1609 pcbinfo->nat_dummy_socket.so_pcb = (caddr_t)pcbinfo->nat_dummy_pcb; /* restores dummypcb */
1619 struct inpcbinfo *pcbinfo = inp->inp_pcbinfo;
1621 if (so != &pcbinfo->nat_dummy_socket)
1623 inp->inp_gencnt = ++pcbinfo->ipi_gencnt;
1628 zfree(pcbinfo->ipi_zone, inp);
1629 pcbinfo->nat_dummy_socket.so_pcb = (caddr_t)pcbinfo->nat_dummy_pcb; /* restores dummypcb */
1633 in_pcb_letgo_port(struct inpcbinfo *pcbinfo, struct in_addr laddr, u_short lport,
1643 lck_rw_lock_exclusive(pcbinfo->mtx);
1644 head = &pcbinfo->hashbase[INP_PCBHASH(faddr.s_addr, lport, fport, pcbinfo->hashmask)];
1655 lck_rw_done(pcbinfo->mtx);
1660 lck_rw_done(pcbinfo->mtx);
1665 in_pcb_get_owner(struct inpcbinfo *pcbinfo,
1683 lck_rw_lock_shared(pcbinfo->mtx);
1684 porthash = &pcbinfo->porthashbase[INP_PCBPORTHASH(lport,
1685 pcbinfo->porthashmask)];
1692 lck_rw_done(pcbinfo->mtx);
1708 lck_rw_done(pcbinfo->mtx);
1712 inp = in_pcblookup_hash(pcbinfo, faddr, fport,
1736 in_pcb_new_share_client(struct inpcbinfo *pcbinfo, u_char *owner_id)
1743 if ((pcbinfo->all_owners & (1 << i)) == 0) {
1744 pcbinfo->all_owners |= (1 << i);
1754 in_pcb_rem_share_client(struct inpcbinfo *pcbinfo, u_char owner_id)
1759 lck_rw_lock_exclusive(pcbinfo->mtx);
1760 if (pcbinfo->all_owners & owner_id) {
1761 pcbinfo->all_owners &= ~owner_id;
1762 for (inp = pcbinfo->listhead->lh_first; inp != NULL; inp = inp->inp_list.le_next) {
1775 lck_rw_done(pcbinfo->mtx);
1779 lck_rw_done(pcbinfo->mtx);
1785 void in_pcb_nat_init(struct inpcbinfo *pcbinfo, int afamily,
1791 bzero(&pcbinfo->nat_dummy_socket, sizeof(struct socket));
1793 mac_socket_label_init(&pcbinfo->nat_dummy_socket, M_WAITOK);
1795 pcbinfo->nat_dummy_socket.so_proto = pffindproto_locked(afamily, pfamily, protocol);
1796 pcbinfo->all_owners = 0;
1797 stat = in_pcballoc(&pcbinfo->nat_dummy_socket, pcbinfo, p);
1800 pcbinfo->nat_dummy_pcb = (struct inpcb *)pcbinfo->nat_dummy_socket.so_pcb;