Skip to content

Commit 899b2c5

Browse files
author
Juha Heiskanen
committed
DHCPv6 client and server update:
Added back to support for do dhcp solicit without IA non temporary address. Server accept also slicit wthout IA non temporary address. Change-Id: Iaa6fef77f191889fdcb8b71d788eff37e438a208
1 parent a83472e commit 899b2c5

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

source/DHCPv6_client/dhcpv6_client_service.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,12 @@ int dhcp_solicit_resp_cb(uint16_t instance_id, void *ptr, uint8_t msg_name, uin
194194
int dhcp_client_get_global_address(int8_t interface, uint8_t dhcp_addr[static 16], uint8_t prefix[static 16], uint8_t mac64[static 8], uint16_t link_type, dhcp_client_global_adress_cb *error_cb)
195195
{
196196
dhcpv6_solication_base_packet_s solPacket = {0};
197-
dhcpv6_ia_non_temporal_address_s nonTemporalAddress = {0};
197+
198198
uint8_t *payload_ptr;
199199
uint32_t payload_len;
200200
dhcpv6_client_server_data_t *srv_data_ptr;
201201

202-
if (mac64 == NULL || prefix == NULL || dhcp_addr == NULL) {
202+
if (mac64 == NULL || dhcp_addr == NULL) {
203203
tr_error("Invalid parameters");
204204
return -1;
205205
}
@@ -210,7 +210,11 @@ int dhcp_client_get_global_address(int8_t interface, uint8_t dhcp_addr[static 16
210210
return -1;
211211
}
212212

213-
payload_len = libdhcpv6_solication_message_length(link_type, true, 0);
213+
if (prefix) {
214+
payload_len = libdhcpv6_solication_message_length(link_type, true, 0);
215+
} else {
216+
payload_len = libdhcpv6_solication_message_length(link_type, false, 0);
217+
}
214218
payload_ptr = ns_dyn_mem_temporary_alloc(payload_len);
215219
if (!payload_ptr) {
216220
libdhcvp6_nontemporalAddress_server_data_free(srv_data_ptr);
@@ -227,8 +231,14 @@ int dhcp_client_get_global_address(int8_t interface, uint8_t dhcp_addr[static 16
227231
solPacket.messageType = DHCPV6_SOLICATION_TYPE;
228232
solPacket.transActionId = libdhcpv6_txid_get();
229233
/*Non Temporal Address */
230-
nonTemporalAddress.requestedAddress = prefix;
231-
libdhcpv6_generic_nontemporal_address_message_write(payload_ptr, &solPacket, &nonTemporalAddress, NULL);
234+
235+
if (prefix) {
236+
dhcpv6_ia_non_temporal_address_s nonTemporalAddress = {0};
237+
nonTemporalAddress.requestedAddress = prefix;
238+
libdhcpv6_generic_nontemporal_address_message_write(payload_ptr, &solPacket, &nonTemporalAddress, NULL);
239+
} else {
240+
libdhcpv6_generic_nontemporal_address_message_write(payload_ptr, &solPacket, NULL, NULL);
241+
}
232242

233243
// send solicit
234244
srv_data_ptr->transActionId = dhcp_service_send_req(dhcp_client.service_instance, 0, srv_data_ptr, dhcp_addr, payload_ptr, payload_len, dhcp_solicit_resp_cb);

source/libDHCPv6/libDHCPv6.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,11 @@ int libdhcpv6_get_IA_address(uint8_t *ptr, uint16_t data_length, dhcp_ia_non_tem
687687
return 0;
688688
}
689689
}
690+
} else if (length == 0) {
691+
params->nonTemporalAddress = NULL;
692+
params->preferredValidLifeTime = 0;
693+
params->validLifeTime = 0;
694+
return 0;
690695
}
691696
}
692697
return -1;

source/libDHCPv6/libDHCPv6_server.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ dhcpv6_gua_server_entry_s *libdhcpv6_server_data_get_by_prefix_and_socketinstanc
132132
{
133133
ns_list_foreach(dhcpv6_gua_server_entry_s, cur, &dhcpv6_gua_server_list) {
134134
if (cur->socketInstance_id == socketInstance) {
135-
if (memcmp(cur->guaPrefix, prefixPtr, 8) == 0) {
135+
136+
if (!prefixPtr || memcmp(cur->guaPrefix, prefixPtr, 8) == 0) {
136137
return cur;
137138
}
138139
}

0 commit comments

Comments
 (0)