key.gwy.port = 0;
key.gwy.port = dport;
pf_get_sport(sa_family_t af, u_int8_t proto, struct pf_rule *r,    struct pf_addr *saddr, struct pf_addr *daddr, u_int16_t dport,    struct pf_addr *naddr, u_int16_t *nport, u_int16_t low, u_int16_t high,    struct pf_src_node **sn){	struct pf_state		key;	struct pf_addr		init_addr;	u_int16_t		cut;	bzero(&init_addr, sizeof(init_addr));	if (pf_map_addr(af, r, saddr, naddr, &init_addr, sn))		return (1);	do {		key.af = af;		key.proto = proto;		PF_ACPY(&key.ext.addr, daddr, key.af);		PF_ACPY(&key.gwy.addr, naddr, key.af);		key.ext.port = dport;		/*		 * port search; start random, step;		 * similar 2 portloop in in_pcbbind		 */		if (!(proto == IPPROTO_TCP || proto == IPPROTO_UDP)) {			key.gwy.port = 0;			if (pf_find_state_all(&key, PF_EXT_GWY, NULL) == NULL)				return (0);		} else if (low == 0 && high == 0) {			key.gwy.port = *nport;			if (pf_find_state_all(&key, PF_EXT_GWY, NULL) == NULL)				return (0);		} else if (low == high) {			key.gwy.port = htons(low);			if (pf_find_state_all(&key, PF_EXT_GWY, NULL) == NULL) {				*nport = htons(low);				return (0);			}		} else {			u_int16_t tmp;			if (low > high) {				tmp = low;				low = high;				high = tmp;			}			/* low < high */			cut = htonl(arc4random()) % (1 + high - low) + low;			/* low <= cut <= high */			for (tmp = cut; tmp <= high; ++(tmp)) {				key.gwy.port = htons(tmp);				if (pf_find_state_all(&key, PF_EXT_GWY, NULL) ==				    NULL) {					*nport = htons(tmp);					return (0);				}			}			for (tmp = cut - 1; tmp >= low; --(tmp)) {				key.gwy.port = htons(tmp);				if (pf_find_state_all(&key, PF_EXT_GWY, NULL) ==				    NULL) {					*nport = htons(tmp);					return (0);				}			}		}		switch (r->rpool.opts & PF_POOL_TYPEMASK) {		case PF_POOL_RANDOM:		case PF_POOL_ROUNDROBIN:			if (pf_map_addr(af, r, saddr, naddr, &init_addr, sn))				return (1);			break;		case PF_POOL_NONE:		case PF_POOL_SRCHASH:		case PF_POOL_BITMASK:		default:			return (1);		}	} while (! PF_AEQ(&init_addr, naddr, af) );	return (1);					/* none available */}