Пример #1
0
STATIC const uint8_t *
find_source_link_address(ptrlist_t * options_p, int * ret_len)
{
    int		count;
    int		i;

    count = ptrlist_count(options_p);
    *ret_len = 0;
    for (i = 0; i < count; i++) {
	const struct _nd_opt_linkaddr *	opt;

	opt = (const struct _nd_opt_linkaddr *)ptrlist_element(options_p, i);
	if (opt->nd_opt_linkaddr_type == ND_OPT_SOURCE_LINKADDR) {
	    int		opt_len = opt->nd_opt_linkaddr_len * ND_OPT_ALIGN;

	    if (opt_len < (_ND_OPT_LINKADDR_HDR_SIZE + ETHER_ADDR_LEN)) {
		/* invalid option */
		break;
	    }
	    *ret_len = opt_len - _ND_OPT_LINKADDR_HDR_SIZE;
	    return (opt->nd_opt_linkaddr_data);
	}
    }
    return (NULL);
}
Пример #2
0
STATIC const struct in6_addr *
find_rdnss(ptrlist_t * options_p, int * how_many)
{
    int		count;
    int		i;

    count = ptrlist_count(options_p);
    *how_many = 0;
    for (i = 0; i < count; i++) {
	const struct nd_opt_rdnss *	opt;

	opt = (const struct nd_opt_rdnss *)ptrlist_element(options_p, i);
	if (opt->nd_opt_rdnss_type == ND_OPT_RDNSS) {
	    int		opt_len = opt->nd_opt_rdnss_len * ND_OPT_ALIGN;

	    if (opt_len < ND_OPT_RDNSS_MIN_LENGTH) {
		/* invalid option */
		break;
	    }
	    if (opt->nd_opt_rdnss_lifetime == 0) {
		/* skip it */
		continue;
	    }
	    *how_many = (opt_len - ND_OPT_RDNSS_HEADER_LENGTH)
		/ sizeof(struct in6_addr);
	    return (opt->nd_opt_rdnss_addr);
	}
    }
    return (NULL);
}
Пример #3
0
__private_extern__ int
ptrlist_index(ptrlist_t * list, void * element)
{
    int i;
    for (i = 0; i < ptrlist_count(list); i++) {
	if (ptrlist_element(list, i) == element)
	    return (i);
    }
    return (-1);
}
Пример #4
0
STATIC void
print_nd_options(ptrlist_t * options_p)
{
    int		count;
    int		i;

    count = ptrlist_count(options_p);
    printf("There are %d options\n", count);
    for (i = 0; i < count; i++) {
	const struct nd_opt_hdr *	opt;
	const char *			opt_name;

	opt = (const struct nd_opt_hdr *)ptrlist_element(options_p, i);
	opt_name = S_nd_opt_name(opt->nd_opt_type);
	printf("%s (%d) length %d\n", opt_name, opt->nd_opt_type,
	       opt->nd_opt_len * ND_OPT_ALIGN);
    }
    return;
}
Пример #5
0
void *
dhcpol_element(dhcpol_t * list, int i)
{
    return (ptrlist_element((ptrlist_t *)list, i));
}