Lines Matching refs:inp
154 pcb_getports(struct inpcb *inp, uint16_t *lastport,
157 struct inpcbtable * const table = inp->inp_table;
163 so = inp->inp_socket;
176 switch (inp->inp_af) {
180 if (inp->inp_flags & INP_LOWPORT) {
197 if (inp->inp_flags & IN6P_LOWPORT) {
240 check_suitable_port(uint16_t port, struct inpcb *inp, kauth_cred_t cred)
242 struct inpcbtable * const table = inp->inp_table;
254 switch (inp->inp_af) {
263 sin.sin_addr = in4p_laddr(inp);
275 if (inp->inp_flags & INP_LOWPORT) {
287 req, inp->inp_socket, &sin, NULL);
307 sin6.sin6_addr = in6p_laddr(inp);
308 so = inp->inp_socket;
341 if (inp->inp_flags & IN6P_LOWPORT) {
374 algo_bsd(int algo, uint16_t *port, struct inpcb *inp, kauth_cred_t cred)
382 error = pcb_getports(inp, &lastport, &mymin, &mymax,
393 if (check_suitable_port(myport, inp, cred)) {
410 algo_random_start(int algo, uint16_t *port, struct inpcb *inp,
420 error = pcb_getports(inp, &lastport, &mymin, &mymax,
436 if (check_suitable_port(*next_ephemeral, inp, cred)) {
464 algo_random_pick(int algo, uint16_t *port, struct inpcb *inp,
474 error = pcb_getports(inp, &lastport, &mymin, &mymax,
489 if (check_suitable_port(*next_ephemeral, inp, cred)) {
510 Fhash(const struct inpcb *inp)
521 switch (inp->inp_af) {
524 MD5Update(&f_ctx, (const u_char *)&const_in4p_laddr(inp),
525 sizeof(const_in4p_laddr(inp)));
526 MD5Update(&f_ctx, (const u_char *)&const_in4p_faddr(inp),
527 sizeof(const_in4p_faddr(inp)));
528 MD5Update(&f_ctx, (const u_char *)&inp->inp_fport,
529 sizeof(inp->inp_fport));
535 MD5Update(&f_ctx, (const u_char *)&const_in6p_laddr(inp),
536 sizeof(const_in6p_laddr(inp)));
537 MD5Update(&f_ctx, (const u_char *)&const_in6p_faddr(inp),
538 sizeof(const_in6p_faddr(inp)));
539 MD5Update(&f_ctx, (const u_char *)&inp->inp_fport,
540 sizeof(inp->inp_fport));
562 iscompletetuple(struct inpcb *inp)
565 switch (inp->inp_af) {
568 if (inp->inp_fport == 0 || in_nullhost(in4p_faddr(inp))) {
571 inp->inp_bindportonsend = true;
574 inp->inp_bindportonsend = false;
581 if (inp->inp_fport == 0 || memcmp(&in6p_faddr(inp),
582 &in6addr_any, sizeof(in6p_faddr(inp))) == 0) {
585 inp->inp_bindportonsend = true;
588 inp->inp_bindportonsend = false;
602 algo_hash(int algo, uint16_t *port, struct inpcb *inp,
613 error = pcb_getports(inp, &lastport, &mymin, &mymax,
618 if (!iscompletetuple(inp)) {
628 offset = Fhash(inp);
637 if (check_suitable_port(myport, inp, cred)) {
651 algo_doublehash(int algo, uint16_t *port, struct inpcb *inp,
664 error = pcb_getports(inp, &lastport, &mymin, &mymax,
669 if (!iscompletetuple(inp)) {
680 offset = Fhash(inp);
681 idx = Fhash(inp) % __arraycount(dhtable); /* G */
689 if (check_suitable_port(myport, inp, cred)) {
704 algo_randinc(int algo, uint16_t *port, struct inpcb *inp,
716 error = pcb_getports(inp, &lastport, &mymin, &mymax,
734 if (check_suitable_port(myport, inp, cred)) {
747 portalgo_randport(uint16_t *port, struct inpcb *inp, kauth_cred_t cred)
755 if (inp->inp_portalgo == PORTALGO_DEFAULT) {
756 switch (inp->inp_af) {
777 algo = inp->inp_portalgo;
782 switch (inp->inp_af) {
786 DPRINTF("local addr: %s\n", IN_PRINT(buf, &in4p_laddr(inp)));
787 DPRINTF("local port: %d\n", inp->inp_lport);
788 DPRINTF("foreign addr: %s\n", IN_PRINT(buf, &in4p_faddr(inp)));
789 DPRINTF("foreign port: %d\n", inp->inp_fport);
796 DPRINTF("local addr: %s\n", IN6_PRINT(buf, &in6p_laddr(inp)));
797 DPRINTF("local port: %d\n", inp->inp_lport);
799 &in6p_laddr(inp)));
800 DPRINTF("foreign port: %d\n", inp->inp_fport);
810 error = (*algos[algo].func)(algo, &lport, inp, cred);
816 error = pcb_getports(inp, &lastport, &mymin,
842 /* Sets the algorithm to be used by the pcb inp. */
844 portalgo_algo_index_select(struct inpcb *inp, int algo)
847 DPRINTF("%s called with algo %d for pcb %p\n", __func__, algo, inp );
853 inp->inp_portalgo = algo;