Lines Matching refs:len

339 static int lease_parse_u32(const uint8_t *option, size_t len, uint32_t *ret, uint32_t min) {  in lease_parse_u32()  argument
343 if (len != 4) in lease_parse_u32()
353 static int lease_parse_u16(const uint8_t *option, size_t len, uint16_t *ret, uint16_t min) { in lease_parse_u16() argument
357 if (len != 2) in lease_parse_u16()
367 static int lease_parse_be32(const uint8_t *option, size_t len, be32_t *ret) { in lease_parse_be32() argument
371 if (len != 4) in lease_parse_be32()
378 static int lease_parse_string(const uint8_t *option, size_t len, char **ret) { in lease_parse_string() argument
382 if (len <= 0) in lease_parse_string()
391 if (memchr(option, 0, len - 1)) in lease_parse_string()
394 string = memdup_suffix0((const char *) option, len); in lease_parse_string()
404 static int lease_parse_domain(const uint8_t *option, size_t len, char **ret) { in lease_parse_domain() argument
411 r = lease_parse_string(option, len, &name); in lease_parse_domain()
434 static int lease_parse_in_addrs(const uint8_t *option, size_t len, struct in_addr **ret, size_t *n_… in lease_parse_in_addrs() argument
435 assert(option || len == 0); in lease_parse_in_addrs()
439 if (len <= 0) { in lease_parse_in_addrs()
446 if (len % 4 != 0) in lease_parse_in_addrs()
449 n_addresses = len / 4; in lease_parse_in_addrs()
463 static int lease_parse_sip_server(const uint8_t *option, size_t len, struct in_addr **ret, size_t *… in lease_parse_sip_server() argument
464 assert(option || len == 0); in lease_parse_sip_server()
468 if (len <= 0) in lease_parse_sip_server()
481 return lease_parse_in_addrs(option + 1, len - 1, ret, n_ret); in lease_parse_sip_server()
484 static int lease_parse_static_routes(sd_dhcp_lease *lease, const uint8_t *option, size_t len) { in lease_parse_static_routes() argument
488 assert(option || len <= 0); in lease_parse_static_routes()
490 if (len % 8 != 0) in lease_parse_static_routes()
493 while (len >= 8) { in lease_parse_static_routes()
503 len -= 8; in lease_parse_static_routes()
527 static int lease_parse_classless_routes(sd_dhcp_lease *lease, const uint8_t *option, size_t len) { in lease_parse_classless_routes() argument
529 assert(option || len <= 0); in lease_parse_classless_routes()
533 while (len > 0) { in lease_parse_classless_routes()
539 len--; in lease_parse_classless_routes()
544 if (dst_octets > 4 || len < dst_octets) in lease_parse_classless_routes()
549 len -= dst_octets; in lease_parse_classless_routes()
551 if (len < 4) in lease_parse_classless_routes()
556 len -= 4; in lease_parse_classless_routes()
571 static int lease_parse_6rd(sd_dhcp_lease *lease, const uint8_t *option, size_t len) { in lease_parse_6rd() argument
587 if (len < 2 + sizeof(struct in6_addr) + sizeof(struct in_addr) || in lease_parse_6rd()
588 (len - 2 - sizeof(struct in6_addr)) % sizeof(struct in_addr) != 0) in lease_parse_6rd()
612 n_br_addresses = (len - 2 - sizeof(struct in6_addr)) / sizeof(struct in_addr); in lease_parse_6rd()
626 int dhcp_lease_parse_options(uint8_t code, uint8_t len, const void *option, void *userdata) { in dhcp_lease_parse_options() argument
635 r = lease_parse_u32(option, len, &lease->lifetime, 1); in dhcp_lease_parse_options()
642 r = lease_parse_be32(option, len, &lease->server_address); in dhcp_lease_parse_options()
649 r = lease_parse_be32(option, len, &lease->subnet_mask); in dhcp_lease_parse_options()
657 r = lease_parse_be32(option, len, &lease->broadcast); in dhcp_lease_parse_options()
665 r = lease_parse_in_addrs(option, len, &lease->router, &lease->router_size); in dhcp_lease_parse_options()
671 …r = lease_parse_in_addrs(option, len, &lease->servers[SD_DHCP_LEASE_DNS].addr, &lease->servers[SD_… in dhcp_lease_parse_options()
677 …r = lease_parse_in_addrs(option, len, &lease->servers[SD_DHCP_LEASE_NTP].addr, &lease->servers[SD_… in dhcp_lease_parse_options()
683 …r = lease_parse_sip_server(option, len, &lease->servers[SD_DHCP_LEASE_SIP].addr, &lease->servers[S… in dhcp_lease_parse_options()
689 …r = lease_parse_in_addrs(option, len, &lease->servers[SD_DHCP_LEASE_POP3].addr, &lease->servers[SD… in dhcp_lease_parse_options()
695 …r = lease_parse_in_addrs(option, len, &lease->servers[SD_DHCP_LEASE_SMTP].addr, &lease->servers[SD… in dhcp_lease_parse_options()
701 …r = lease_parse_in_addrs(option, len, &lease->servers[SD_DHCP_LEASE_LPR].addr, &lease->servers[SD_… in dhcp_lease_parse_options()
707 r = lease_parse_static_routes(lease, option, len); in dhcp_lease_parse_options()
713 r = lease_parse_u16(option, len, &lease->mtu, 68); in dhcp_lease_parse_options()
724 r = lease_parse_domain(option, len, &lease->domainname); in dhcp_lease_parse_options()
733 r = dhcp_lease_parse_search_domains(option, len, &lease->search_domains); in dhcp_lease_parse_options()
739 r = lease_parse_domain(option, len, &lease->hostname); in dhcp_lease_parse_options()
748 r = lease_parse_string(option, len, &lease->root_path); in dhcp_lease_parse_options()
754 r = lease_parse_u32(option, len, &lease->t1, 1); in dhcp_lease_parse_options()
760 r = lease_parse_u32(option, len, &lease->t2, 1); in dhcp_lease_parse_options()
766 r = lease_parse_classless_routes(lease, option, len); in dhcp_lease_parse_options()
774 r = lease_parse_string(option, len, &tz); in dhcp_lease_parse_options()
792 if (len <= 0) in dhcp_lease_parse_options()
797 p = memdup(option, len); in dhcp_lease_parse_options()
805 lease->vendor_specific_len = len; in dhcp_lease_parse_options()
809 r = lease_parse_6rd(lease, option, len); in dhcp_lease_parse_options()
815 r = dhcp_lease_insert_private_option(lease, code, option, len); in dhcp_lease_parse_options()
830 int dhcp_lease_parse_search_domains(const uint8_t *option, size_t len, char ***domains) { in dhcp_lease_parse_search_domains() argument
836 assert_return(option && len > 0, -ENODATA); in dhcp_lease_parse_search_domains()
838 while (pos < len) { in dhcp_lease_parse_search_domains()
857 if (pos >= len) in dhcp_lease_parse_search_domains()
879 if (pos >= len) in dhcp_lease_parse_search_domains()
918 …hcp_lease_insert_private_option(sd_dhcp_lease *lease, uint8_t tag, const void *data, uint8_t len) { in dhcp_lease_insert_private_option() argument
939 option->length = len; in dhcp_lease_insert_private_option()
940 option->data = memdup(data, len); in dhcp_lease_insert_private_option()
1395 size_t len; in dhcp_lease_load() local
1400 r = unhexmem(options[i], SIZE_MAX, &data, &len); in dhcp_lease_load()
1406 … r = dhcp_lease_insert_private_option(lease, SD_DHCP_OPTION_PRIVATE_BASE + i, data, len); in dhcp_lease_load()