Lines Matching refs:buflen
293 static uint8_t *dhcpv4_encode_magic_cookie(uint8_t *buf, size_t *buflen) in dhcpv4_encode_magic_cookie() argument
295 if (buf == NULL || *buflen < SIZE_OF_MAGIC_COOKIE) { in dhcpv4_encode_magic_cookie()
301 *buflen -= SIZE_OF_MAGIC_COOKIE; in dhcpv4_encode_magic_cookie()
306 static uint8_t *dhcpv4_encode_ip_lease_time_option(uint8_t *buf, size_t *buflen, in dhcpv4_encode_ip_lease_time_option() argument
309 if (buf == NULL || *buflen < DHCPV4_OPTIONS_IP_LEASE_TIME_SIZE) { in dhcpv4_encode_ip_lease_time_option()
317 *buflen -= DHCPV4_OPTIONS_IP_LEASE_TIME_SIZE; in dhcpv4_encode_ip_lease_time_option()
322 static uint8_t *dhcpv4_encode_message_type_option(uint8_t *buf, size_t *buflen, in dhcpv4_encode_message_type_option() argument
325 if (buf == NULL || *buflen < DHCPV4_OPTIONS_MSG_TYPE_SIZE) { in dhcpv4_encode_message_type_option()
333 *buflen -= DHCPV4_OPTIONS_MSG_TYPE_SIZE; in dhcpv4_encode_message_type_option()
338 static uint8_t *dhcpv4_encode_server_id_option(uint8_t *buf, size_t *buflen, in dhcpv4_encode_server_id_option() argument
341 if (buf == NULL || *buflen < DHCPV4_OPTIONS_SERVER_ID_SIZE) { in dhcpv4_encode_server_id_option()
349 *buflen -= DHCPV4_OPTIONS_SERVER_ID_SIZE; in dhcpv4_encode_server_id_option()
354 static uint8_t *dhcpv4_encode_client_id_option(uint8_t *buf, size_t *buflen, in dhcpv4_encode_client_id_option() argument
357 if (buf == NULL || *buflen < client_id->len + 2) { in dhcpv4_encode_client_id_option()
365 *buflen -= client_id->len + 2; in dhcpv4_encode_client_id_option()
370 static uint8_t *dhcpv4_encode_subnet_mask_option(uint8_t *buf, size_t *buflen, in dhcpv4_encode_subnet_mask_option() argument
373 if (buf == NULL || *buflen < DHCPV4_OPTIONS_SUBNET_MASK_SIZE) { in dhcpv4_encode_subnet_mask_option()
381 *buflen -= DHCPV4_OPTIONS_SUBNET_MASK_SIZE; in dhcpv4_encode_subnet_mask_option()
386 static uint8_t *dhcpv4_encode_router_option(uint8_t *buf, size_t *buflen, in dhcpv4_encode_router_option() argument
389 if (buf == NULL || *buflen < DHCPV4_OPTIONS_ROUTER_SIZE) { in dhcpv4_encode_router_option()
397 *buflen -= DHCPV4_OPTIONS_ROUTER_SIZE; in dhcpv4_encode_router_option()
402 static uint8_t *dhcpv4_encode_dns_server_option(uint8_t *buf, size_t *buflen) in dhcpv4_encode_dns_server_option() argument
406 if (buf == NULL || *buflen < DHCPV4_OPTIONS_DNS_SERVER_SIZE) { in dhcpv4_encode_dns_server_option()
420 *buflen -= DHCPV4_OPTIONS_DNS_SERVER_SIZE; in dhcpv4_encode_dns_server_option()
425 static uint8_t *dhcpv4_encode_end_option(uint8_t *buf, size_t *buflen) in dhcpv4_encode_end_option() argument
427 if (buf == NULL || *buflen < 1) { in dhcpv4_encode_end_option()
433 *buflen -= 1; in dhcpv4_encode_end_option()
440 static uint8_t *dhcpv4_encode_header(uint8_t *buf, size_t *buflen, in dhcpv4_encode_header() argument
446 if (buf == NULL || *buflen < sizeof(struct dhcp_msg)) { in dhcpv4_encode_header()
467 *buflen -= sizeof(struct dhcp_msg); in dhcpv4_encode_header()
472 static uint8_t *dhcpv4_encode_string(uint8_t *buf, size_t *buflen, char *str, in dhcpv4_encode_string() argument
475 if (buf == NULL || *buflen < max_len) { in dhcpv4_encode_string()
488 *buflen -= max_len; in dhcpv4_encode_string()
493 static uint8_t *dhcpv4_encode_sname(uint8_t *buf, size_t *buflen, char *sname) in dhcpv4_encode_sname() argument
495 return dhcpv4_encode_string(buf, buflen, sname, SIZE_OF_SNAME); in dhcpv4_encode_sname()
498 static uint8_t *dhcpv4_encode_file(uint8_t *buf, size_t *buflen, char *file) in dhcpv4_encode_file() argument
500 return dhcpv4_encode_string(buf, buflen, file, SIZE_OF_FILE); in dhcpv4_encode_file()
504 uint8_t *buf, size_t *buflen, in dhcpv4_encode_requested_params() argument
512 buf, buflen, &ctx->netmask); in dhcpv4_encode_requested_params()
520 buf, buflen, &ctx->iface->config.ip.ipv4->gw); in dhcpv4_encode_requested_params()
527 buf = dhcpv4_encode_dns_server_option(buf, buflen); in dhcpv4_encode_requested_params()
615 size_t buflen = sizeof(reply); in dhcpv4_send_offer() local
619 buf = dhcpv4_encode_header(buf, &buflen, msg, addr); in dhcpv4_send_offer()
620 buf = dhcpv4_encode_sname(buf, &buflen, NULL); in dhcpv4_send_offer()
621 buf = dhcpv4_encode_file(buf, &buflen, NULL); in dhcpv4_send_offer()
622 buf = dhcpv4_encode_magic_cookie(buf, &buflen); in dhcpv4_send_offer()
623 buf = dhcpv4_encode_ip_lease_time_option(buf, &buflen, lease_time); in dhcpv4_send_offer()
624 buf = dhcpv4_encode_message_type_option(buf, &buflen, in dhcpv4_send_offer()
626 buf = dhcpv4_encode_server_id_option(buf, &buflen, &ctx->server_addr); in dhcpv4_send_offer()
627 buf = dhcpv4_encode_client_id_option(buf, &buflen, client_id); in dhcpv4_send_offer()
628 buf = dhcpv4_encode_requested_params(buf, &buflen, ctx, params); in dhcpv4_send_offer()
629 buf = dhcpv4_encode_end_option(buf, &buflen); in dhcpv4_send_offer()
636 reply_len = sizeof(reply) - buflen; in dhcpv4_send_offer()
656 size_t buflen = sizeof(reply); in dhcpv4_send_ack() local
660 buf = dhcpv4_encode_header(buf, &buflen, msg, inform ? NULL : addr); in dhcpv4_send_ack()
661 buf = dhcpv4_encode_sname(buf, &buflen, NULL); in dhcpv4_send_ack()
662 buf = dhcpv4_encode_file(buf, &buflen, NULL); in dhcpv4_send_ack()
663 buf = dhcpv4_encode_magic_cookie(buf, &buflen); in dhcpv4_send_ack()
665 buf = dhcpv4_encode_ip_lease_time_option(buf, &buflen, lease_time); in dhcpv4_send_ack()
667 buf = dhcpv4_encode_message_type_option(buf, &buflen, in dhcpv4_send_ack()
669 buf = dhcpv4_encode_server_id_option(buf, &buflen, &ctx->server_addr); in dhcpv4_send_ack()
671 buf = dhcpv4_encode_client_id_option(buf, &buflen, client_id); in dhcpv4_send_ack()
673 buf = dhcpv4_encode_requested_params(buf, &buflen, ctx, params); in dhcpv4_send_ack()
674 buf = dhcpv4_encode_end_option(buf, &buflen); in dhcpv4_send_ack()
681 reply_len = sizeof(reply) - buflen; in dhcpv4_send_ack()
698 size_t buflen = sizeof(reply); in dhcpv4_send_nak() local
702 buf = dhcpv4_encode_header(buf, &buflen, msg, NULL); in dhcpv4_send_nak()
703 buf = dhcpv4_encode_sname(buf, &buflen, NULL); in dhcpv4_send_nak()
704 buf = dhcpv4_encode_file(buf, &buflen, NULL); in dhcpv4_send_nak()
705 buf = dhcpv4_encode_magic_cookie(buf, &buflen); in dhcpv4_send_nak()
706 buf = dhcpv4_encode_message_type_option(buf, &buflen, in dhcpv4_send_nak()
708 buf = dhcpv4_encode_server_id_option(buf, &buflen, &ctx->server_addr); in dhcpv4_send_nak()
709 buf = dhcpv4_encode_client_id_option(buf, &buflen, client_id); in dhcpv4_send_nak()
710 buf = dhcpv4_encode_end_option(buf, &buflen); in dhcpv4_send_nak()
717 reply_len = sizeof(reply) - buflen; in dhcpv4_send_nak()