@@ -90,7 +90,11 @@ int DHCPv6_server_respond_client(dhcpv6_gua_server_entry_s *serverBase, dhcpv6_r
90
90
dhcpv6_alloacted_address_entry_t * dhcp_allocated_address ;
91
91
dhcpv6_ia_non_temporal_address_s nonTemporalAddress ;
92
92
bool address_allocated = false;
93
- dhcp_allocated_address = libdhcpv6_address_allocated_list_scan (serverBase , replyPacket -> clientDUID .linkID , replyPacket -> clientDUID .linkType , dhcp_ia_non_temporal_params -> iaId , dhcp_ia_non_temporal_params -> T0 , dhcp_ia_non_temporal_params -> T1 , allocateNew );
93
+ //Validate Client DUID
94
+ dhcp_link_options_params_t clientDUID ;
95
+ if (libdhcpv6_get_link_address_from_duid (replyPacket -> clientDUID .duid , replyPacket -> clientDUID .duid_length , replyPacket -> clientDUID .type , & clientDUID ) == 0 ) {
96
+ dhcp_allocated_address = libdhcpv6_address_allocated_list_scan (serverBase , clientDUID .link_id , clientDUID .link_type , dhcp_ia_non_temporal_params -> iaId , dhcp_ia_non_temporal_params -> T0 , dhcp_ia_non_temporal_params -> T1 , allocateNew );
97
+ }
94
98
if (dhcp_allocated_address ) {
95
99
address_allocated = true;
96
100
nonTemporalAddress .requestedAddress = dhcp_allocated_address -> nonTemporalAddress ;
@@ -110,7 +114,7 @@ int DHCPv6_server_respond_client(dhcpv6_gua_server_entry_s *serverBase, dhcpv6_r
110
114
}
111
115
}
112
116
113
- response -> responseLength = libdhcpv6_address_reply_message_len (replyPacket -> clientDUID .linkType , replyPacket -> serverDUID .linkType , 0 , replyPacket -> rapidCommit , address_allocated );
117
+ response -> responseLength = libdhcpv6_address_reply_message_len (replyPacket -> clientDUID .duid_length , replyPacket -> serverDUID .duid_length , 0 , replyPacket -> rapidCommit , address_allocated );
114
118
response -> responsePtr = ns_dyn_mem_temporary_alloc (response -> responseLength );
115
119
if (response -> responsePtr ) {
116
120
if (address_allocated ) {
@@ -141,16 +145,13 @@ int DHCPV6_server_service_request_handler(uint16_t instance_id, uint32_t msg_tr_
141
145
if (serverBase ) {
142
146
//Here Allocate address
143
147
replyPacket .rapidCommit = libdhcpv6_rapid_commit_option_at_packet (msg_ptr , msg_len );
144
- replyPacket .serverDUID .linkID = serverBase -> serverDUID ;
145
- replyPacket .serverDUID .linkType = serverBase -> serverLinkType ;
148
+ replyPacket .serverDUID = serverBase -> serverDUID ;
146
149
replyPacket .T0 = dhcp_ia_non_temporal_params .T0 ;
147
150
replyPacket .T1 = dhcp_ia_non_temporal_params .T1 ;
148
151
replyPacket .iaId = dhcp_ia_non_temporal_params .iaId ;
149
152
replyPacket .transaction_ID = msg_tr_id ;
150
153
151
- uint16_t duid_length = libdhcpv6_duid_option_size (replyPacket .clientDUID .linkType );
152
- duid_length -= 8 ;
153
- tr_debug ("Response dhcp sol %s clientDUID" , trace_array (replyPacket .clientDUID .linkID , duid_length ));
154
+ tr_debug ("Response dhcp sol %s clientDUID" , trace_array (replyPacket .clientDUID .duid , replyPacket .clientDUID .duid_length ));
154
155
155
156
//Check First Current list
156
157
if (DHCPv6_server_respond_client (serverBase , & replyPacket , & dhcp_ia_non_temporal_params , & responseBuf , true) == 0 ) {
@@ -173,10 +174,7 @@ int DHCPV6_server_service_request_handler(uint16_t instance_id, uint32_t msg_tr_
173
174
// Discover SERVER
174
175
serverBase = libdhcpv6_server_data_get_by_prefix_and_socketinstance (instance_id , dhcp_ia_non_temporal_params .nonTemporalAddress );
175
176
if (serverBase ) {
176
- dhcp_link_options_params_t serverInfoDui ;
177
- serverInfoDui .linkID = serverBase -> serverDUID ;
178
- serverInfoDui .linkType = serverBase -> serverLinkType ;
179
- if (libdhcpv6_compare_DUID (& serverInfoDui , & replyPacket .serverDUID ) == 0 ) {
177
+ if (libdhcpv6_compare_DUID (& serverBase -> serverDUID , & replyPacket .serverDUID ) == 0 ) {
180
178
replyPacket .rapidCommit = libdhcpv6_rapid_commit_option_at_packet (msg_ptr , msg_len );
181
179
replyPacket .T0 = dhcp_ia_non_temporal_params .T0 ;
182
180
replyPacket .T1 = dhcp_ia_non_temporal_params .T1 ;
@@ -339,6 +337,25 @@ void DHCPv6_server_service_callback_set(int8_t interface, uint8_t guaPrefix[stat
339
337
serverInfo -> removeCb = remove_cb ;
340
338
}
341
339
340
+
341
+ int DHCPv6_server_service_duid_update (int8_t interface , uint8_t guaPrefix [static 16 ], uint8_t * duid_ptr , uint16_t duid_type , uint8_t duid_length )
342
+ {
343
+
344
+ //Validate length and type
345
+ if (!libdhcpv6_duid_length_validate (duid_type , duid_length )) {
346
+ return -1 ;
347
+ }
348
+
349
+
350
+ dhcpv6_gua_server_entry_s * serverInfo = libdhcpv6_server_data_get_by_prefix_and_interfaceid (interface , guaPrefix );
351
+ if (!serverInfo ) {
352
+ return -1 ;
353
+ }
354
+
355
+ return libdhcpv6_server_duid_set (serverInfo , duid_ptr , duid_type , duid_length );
356
+ }
357
+
358
+
342
359
/* SET max accepted clients to server, Default is 200
343
360
*
344
361
*
0 commit comments