Skip to content

Commit 08155b1

Browse files
author
Juha Heiskanen
committed
DHCPv6 service relay support
Support for enable and init DHCPv6 Relay agent instance. Server and relay cant work same time Relay instance have own socket callback which support to forward data mesages between client and server Server support Relay reply message build Change-Id: Ia9f53d8b2e40d0560d73090bd539cfc20f65e35b
1 parent 62812ab commit 08155b1

File tree

6 files changed

+722
-7
lines changed

6 files changed

+722
-7
lines changed

nanostack/dhcp_service_api.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@
6969
typedef enum dhcp_instance_type
7070
{
7171
DHCP_INSTANCE_CLIENT,
72-
DHCP_INSTANCE_SERVER
72+
DHCP_INSTANCE_SERVER,
73+
DHCP_INTANCE_RELAY_AGENT
7374
} dhcp_instance_type_e;
7475

7576
/**
@@ -124,6 +125,16 @@ typedef int (dhcp_service_receive_resp_cb)(uint16_t instance_id, void *ptr, uint
124125

125126
uint16_t dhcp_service_init(int8_t interface_id, dhcp_instance_type_e instance_type, dhcp_service_receive_req_cb *receive_req_cb);
126127

128+
/**
129+
* \brief Enable DHCPv6 Relay Agent to server.
130+
*
131+
*
132+
* \param instance The instance ID of the registered server.
133+
* \param server_address global server IPv6 address
134+
*/
135+
void dhcp_service_relay_instance_enable(uint16_t instance, uint8_t *server_address);
136+
137+
127138
/**
128139
* \brief Deletes a server instance.
129140
*
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* Copyright (c) 2018, Arm Limited and affiliates.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#ifndef DHCPV6_CLIENT_API_H_
19+
#define DHCPV6_CLIENT_API_H_
20+
#include <ns_types.h>
21+
22+
/* DHCP client implementation.
23+
*
24+
* Responsibilities of this module are:
25+
* - handle Global address queries and refresh inside network.
26+
*
27+
*/
28+
29+
/* Initialize dhcp client.
30+
*
31+
* This instance needs to bee initialized once for each network interface.
32+
* if only one thread instance is supported this is needed to call only once.
33+
*
34+
* /param interface interface id of this instance.
35+
*
36+
*/
37+
38+
void dhcp_client_init(int8_t interface);
39+
40+
/* Delete dhcp client.
41+
*
42+
* When this is called all addressed assigned by this module are removed from stack.
43+
*/
44+
void dhcp_client_delete(int8_t interface);
45+
46+
/* Global address handler.
47+
*
48+
* This module updates the addresses from dhcp server and sets them in stack.
49+
* this module makes refresh of address when needed.
50+
*
51+
*/
52+
53+
54+
/* give dhcp server and prefix for global address assignment
55+
*
56+
* /param interface interface where address is got
57+
* /param dhcp_addr dhcp server ML16 address where address is registered.
58+
* /param prefix dhcp server ML16 address where address is registered.
59+
* /param mac64 64 bit mac address for identifieng client.
60+
* /param error_cb error callback that is called if address cannot be created or becomes invalid.
61+
* /param register_status true if address registered.
62+
*
63+
*/
64+
typedef void (dhcp_client_global_adress_cb)(int8_t interface, uint8_t dhcp_addr[static 16], uint8_t prefix[static 16], bool register_status);
65+
66+
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], dhcp_client_global_adress_cb *error_cb);
67+
68+
/* Renew all leased adddresses might be used when short address changes
69+
*
70+
* /param interface interface where address is got
71+
*/
72+
void dhcp_client_global_address_renew(int8_t interface);
73+
74+
/* Delete address from device
75+
* if prefix is NULL all are deleted
76+
*
77+
* /param interface interface where address is got
78+
* /param prefix dhcp server ML16 address where address is registered.
79+
*
80+
*/
81+
void dhcp_client_global_address_delete(int8_t interface, uint8_t dhcp_addr[static 16], uint8_t prefix[static 16]);
82+
83+
84+
85+
#endif /* DHCPV6_CLIENT_API_H_ */

0 commit comments

Comments
 (0)