913 |
{ |
{ |
914 |
struct dhcp_state *list_state = client_list; |
struct dhcp_state *list_state = client_list; |
915 |
DEBUGF(DHCP_DEBUG, ("dhcp_stop()")); |
DEBUGF(DHCP_DEBUG, ("dhcp_stop()")); |
916 |
ASSERT("dhcp_stop: state != NULL", state != NULL); |
LWIP_ASSERT("dhcp_stop: state != NULL", state != NULL); |
917 |
ASSERT("dhcp_stop: state->pcb != NULL", state->pcb != NULL); |
LWIP_ASSERT("dhcp_stop: state->pcb != NULL", state->pcb != NULL); |
918 |
|
|
919 |
if (state != NULL) |
if (state != NULL) |
920 |
{ |
{ |
966 |
|
|
967 |
static void dhcp_option(struct dhcp_state *state, u8_t option_type, u8_t option_len) |
static void dhcp_option(struct dhcp_state *state, u8_t option_type, u8_t option_len) |
968 |
{ |
{ |
969 |
ASSERT("dhcp_option_short: state->options_out_len + 2 + option_len <= DHCP_OPTIONS_LEN", state->options_out_len + 2 + option_len <= DHCP_OPTIONS_LEN); |
LWIP_ASSERT("dhcp_option_short: state->options_out_len + 2 + option_len <= DHCP_OPTIONS_LEN", state->options_out_len + 2 + option_len <= DHCP_OPTIONS_LEN); |
970 |
state->msg_out->options[state->options_out_len++] = option_type; |
state->msg_out->options[state->options_out_len++] = option_type; |
971 |
state->msg_out->options[state->options_out_len++] = option_len; |
state->msg_out->options[state->options_out_len++] = option_len; |
972 |
} |
} |
973 |
static void dhcp_option_byte(struct dhcp_state *state, u8_t value) |
static void dhcp_option_byte(struct dhcp_state *state, u8_t value) |
974 |
{ |
{ |
975 |
ASSERT("dhcp_option_short: state->options_out_len < DHCP_OPTIONS_LEN", state->options_out_len < DHCP_OPTIONS_LEN); |
LWIP_ASSERT("dhcp_option_short: state->options_out_len < DHCP_OPTIONS_LEN", state->options_out_len < DHCP_OPTIONS_LEN); |
976 |
state->msg_out->options[state->options_out_len++] = value; |
state->msg_out->options[state->options_out_len++] = value; |
977 |
} |
} |
978 |
static void dhcp_option_short(struct dhcp_state *state, u16_t value) |
static void dhcp_option_short(struct dhcp_state *state, u16_t value) |
979 |
{ |
{ |
980 |
ASSERT("dhcp_option_short: state->options_out_len + 2 <= DHCP_OPTIONS_LEN", state->options_out_len + 2 <= DHCP_OPTIONS_LEN); |
LWIP_ASSERT("dhcp_option_short: state->options_out_len + 2 <= DHCP_OPTIONS_LEN", state->options_out_len + 2 <= DHCP_OPTIONS_LEN); |
981 |
state->msg_out->options[state->options_out_len++] = (value & 0xff00U) >> 8; |
state->msg_out->options[state->options_out_len++] = (value & 0xff00U) >> 8; |
982 |
state->msg_out->options[state->options_out_len++] = value & 0x00ffU; |
state->msg_out->options[state->options_out_len++] = value & 0x00ffU; |
983 |
} |
} |
984 |
static void dhcp_option_long(struct dhcp_state *state, u32_t value) |
static void dhcp_option_long(struct dhcp_state *state, u32_t value) |
985 |
{ |
{ |
986 |
ASSERT("dhcp_option_long: state->options_out_len + 4 <= DHCP_OPTIONS_LEN", state->options_out_len + 4 <= DHCP_OPTIONS_LEN); |
LWIP_ASSERT("dhcp_option_long: state->options_out_len + 4 <= DHCP_OPTIONS_LEN", state->options_out_len + 4 <= DHCP_OPTIONS_LEN); |
987 |
state->msg_out->options[state->options_out_len++] = (value & 0xff000000UL) >> 24; |
state->msg_out->options[state->options_out_len++] = (value & 0xff000000UL) >> 24; |
988 |
state->msg_out->options[state->options_out_len++] = (value & 0x00ff0000UL) >> 16; |
state->msg_out->options[state->options_out_len++] = (value & 0x00ff0000UL) >> 16; |
989 |
state->msg_out->options[state->options_out_len++] = (value & 0x0000ff00UL) >> 8; |
state->msg_out->options[state->options_out_len++] = (value & 0x0000ff00UL) >> 8; |
1177 |
static err_t dhcp_create_request(struct dhcp_state *state) |
static err_t dhcp_create_request(struct dhcp_state *state) |
1178 |
{ |
{ |
1179 |
u16_t i; |
u16_t i; |
1180 |
ASSERT("dhcp_create_request: state->p_out == NULL", state->p_out == NULL); |
LWIP_ASSERT("dhcp_create_request: state->p_out == NULL", state->p_out == NULL); |
1181 |
ASSERT("dhcp_create_request: state->msg_out == NULL", state->msg_out == NULL); |
LWIP_ASSERT("dhcp_create_request: state->msg_out == NULL", state->msg_out == NULL); |
1182 |
state->p_out = pbuf_alloc(PBUF_TRANSPORT, sizeof(struct dhcp_msg), PBUF_RAM); |
state->p_out = pbuf_alloc(PBUF_TRANSPORT, sizeof(struct dhcp_msg), PBUF_RAM); |
1183 |
if (state->p_out == NULL) |
if (state->p_out == NULL) |
1184 |
{ |
{ |
1213 |
|
|
1214 |
static void dhcp_delete_request(struct dhcp_state *state) |
static void dhcp_delete_request(struct dhcp_state *state) |
1215 |
{ |
{ |
1216 |
ASSERT("dhcp_free_msg: state->p_out != NULL", state->p_out != NULL); |
LWIP_ASSERT("dhcp_free_msg: state->p_out != NULL", state->p_out != NULL); |
1217 |
ASSERT("dhcp_free_msg: state->msg_out != NULL", state->msg_out != NULL); |
LWIP_ASSERT("dhcp_free_msg: state->msg_out != NULL", state->msg_out != NULL); |
1218 |
pbuf_free(state->p_out); |
pbuf_free(state->p_out); |
1219 |
state->p_out = NULL; |
state->p_out = NULL; |
1220 |
state->msg_out = NULL; |
state->msg_out = NULL; |
1229 |
|
|
1230 |
static void dhcp_option_trailer(struct dhcp_state *state) |
static void dhcp_option_trailer(struct dhcp_state *state) |
1231 |
{ |
{ |
1232 |
ASSERT("dhcp_option_trailer: state->msg_out != NULL", state->msg_out != NULL); |
LWIP_ASSERT("dhcp_option_trailer: state->msg_out != NULL", state->msg_out != NULL); |
1233 |
ASSERT("dhcp_option_trailer: state->options_out_len < DHCP_OPTIONS_LEN", state->options_out_len < DHCP_OPTIONS_LEN); |
LWIP_ASSERT("dhcp_option_trailer: state->options_out_len < DHCP_OPTIONS_LEN", state->options_out_len < DHCP_OPTIONS_LEN); |
1234 |
state->msg_out->options[state->options_out_len++] = DHCP_OPTION_END; |
state->msg_out->options[state->options_out_len++] = DHCP_OPTION_END; |
1235 |
// packet is still too small, or not 4 byte aligned? |
// packet is still too small, or not 4 byte aligned? |
1236 |
while ((state->options_out_len < DHCP_MIN_OPTIONS_LEN) || (state->options_out_len & 3)) |
while ((state->options_out_len < DHCP_MIN_OPTIONS_LEN) || (state->options_out_len & 3)) |
1237 |
{ |
{ |
1238 |
//DEBUGF(DHCP_DEBUG, ("dhcp_option_trailer: state->options_out_len=%u, DHCP_OPTIONS_LEN=%u", state->options_out_len, DHCP_OPTIONS_LEN)); |
//DEBUGF(DHCP_DEBUG, ("dhcp_option_trailer: state->options_out_len=%u, DHCP_OPTIONS_LEN=%u", state->options_out_len, DHCP_OPTIONS_LEN)); |
1239 |
ASSERT("dhcp_option_trailer: state->options_out_len < DHCP_OPTIONS_LEN", state->options_out_len < DHCP_OPTIONS_LEN); |
LWIP_ASSERT("dhcp_option_trailer: state->options_out_len < DHCP_OPTIONS_LEN", state->options_out_len < DHCP_OPTIONS_LEN); |
1240 |
state->msg_out->options[state->options_out_len++] = 0; |
state->msg_out->options[state->options_out_len++] = 0; |
1241 |
} |
} |
1242 |
} |
} |