summaryrefslogtreecommitdiffstats
path: root/tinyNET/src/dhcp6
diff options
context:
space:
mode:
Diffstat (limited to 'tinyNET/src/dhcp6')
-rw-r--r--tinyNET/src/dhcp6/tnet_dhcp6.c269
-rw-r--r--tinyNET/src/dhcp6/tnet_dhcp6.h128
-rw-r--r--tinyNET/src/dhcp6/tnet_dhcp6_duid.c288
-rw-r--r--tinyNET/src/dhcp6/tnet_dhcp6_duid.h185
-rw-r--r--tinyNET/src/dhcp6/tnet_dhcp6_message.c137
-rw-r--r--tinyNET/src/dhcp6/tnet_dhcp6_message.h143
-rw-r--r--tinyNET/src/dhcp6/tnet_dhcp6_option.c336
-rw-r--r--tinyNET/src/dhcp6/tnet_dhcp6_option.h246
8 files changed, 1732 insertions, 0 deletions
diff --git a/tinyNET/src/dhcp6/tnet_dhcp6.c b/tinyNET/src/dhcp6/tnet_dhcp6.c
new file mode 100644
index 0000000..cc52476
--- /dev/null
+++ b/tinyNET/src/dhcp6/tnet_dhcp6.c
@@ -0,0 +1,269 @@
+/*
+* Copyright (C) 2009-2010 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+/**@file tnet_dhcp6.c
+ * @brief Dynamic Host Configuration Protocol for IPv6 (DHCPv6) as per RFC 3315.
+ * Also implement: RFC 3319, 3633, 3646, 3736, 4242, 5007 ...
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+#include "tnet_dhcp6.h"
+
+#include "tsk_string.h"
+#include "tsk_debug.h"
+#include "tsk_memory.h"
+#include "tsk_time.h"
+#include "tsk_thread.h"
+
+
+/**@defgroup tnet_dhcp6_group DHCPv6 (RFC 3315) implementation.
+* Dynamic Host Configuration Protocol for IPv6 (DHCPv6) as per RFC 3315.
+* Also implement: RFC 3319, 3633, 3646, 3736, 4242, 5007 ...
+*/
+
+tnet_dhcp6_ctx_t* tnet_dhcp6_ctx_create()
+{
+ return tsk_object_new(tnet_dhcp6_ctx_def_t);
+}
+
+/**@ingroup tnet_dhcp6_group
+*/
+tnet_dhcp6_reply_t* tnet_dhcp6_send_request(const tnet_dhcp6_ctx_t* ctx, tnet_dhcp6_request_t* request)
+{
+ tsk_buffer_t *output;
+ tnet_dhcp6_reply_t* reply = 0;
+ int ret;
+ struct timeval tv;
+ fd_set set;
+ uint64_t timeout = 0;
+ tsk_list_item_t *item;
+ const tnet_interface_t *iface;
+ tnet_ip_t bestsource;
+
+ tnet_socket_t *localsocket6 = 0;
+ struct sockaddr_storage server;
+
+ if(!ctx || !request){
+ goto bail;
+ }
+
+ if((ret = tnet_getbestsource(TNET_DHCP6_All_DHCP_Relay_Agents_and_Servers, ctx->server_port, tnet_socket_type_udp_ipv6, &bestsource))){
+ TSK_DEBUG_WARN("Failed to get best source for [%s]:%u.", TNET_DHCP6_All_DHCP_Relay_Agents_and_Servers, ctx->server_port);
+ //fe80::21b:63ff:fea9:c14e%4
+ localsocket6 = tnet_socket_create(TNET_SOCKET_HOST_ANY, ctx->port_client, tnet_socket_type_udp_ipv6);
+ }
+ else{
+ localsocket6 = tnet_socket_create(bestsource, ctx->port_client, tnet_socket_type_udp_ipv6);
+ }
+
+ /* Check local socket. */
+ if(!TNET_SOCKET_IS_VALID(localsocket6)){
+ TSK_DEBUG_ERROR("Failed to create/bind DHCPv6 client socket.");
+ goto bail;
+ }
+
+ /* Always wait for 200ms before retransmission */
+ tv.tv_sec = 0;
+ tv.tv_usec = (200 * 1000);
+
+ if(tnet_sockaddr_init(TNET_DHCP6_All_DHCP_Relay_Agents_and_Servers, ctx->server_port, tnet_socket_type_udp_ipv6, &server)){
+ TNET_PRINT_LAST_ERROR("Failed to initialize the DHCPv6 server address.");
+ goto bail;
+ }
+
+ /* Set timeout */
+ timeout = tsk_time_epoch() + ctx->timeout;
+
+ do
+ {
+ tsk_list_foreach(item, ctx->interfaces){
+ iface = item->data;
+
+ /* Set FD */
+ FD_ZERO(&set);
+ FD_SET(localsocket6->fd, &set);
+
+ ///* ciaddr */
+ //if(request->type == dhcp_type_inform){
+ // struct sockaddr_storage ss;
+ // if(!tnet_get_sockaddr(localsocket4->fd, &ss)){
+ // uint32_t addr = tnet_htonl_2(&((struct sockaddr_in*)&ss)->sin_addr);
+ // memcpy(&request->ciaddr, &addr, 4);
+ // }
+ //}
+
+ ///* chaddr */
+ //memset(request->chaddr, 0, sizeof(request->chaddr));
+ //request->hlen = iface->mac_address_length > sizeof(request->chaddr) ? sizeof(request->chaddr) : iface->mac_address_length;
+ //memcpy(request->chaddr, iface->mac_address, request->hlen);
+
+ /* Serialize and send to the server. */
+ if(!(output = tnet_dhcp6_message_serialize(ctx, request))){
+ TSK_DEBUG_ERROR("Failed to serialize the DHCPv6 message.");
+ goto next_iface;
+ }
+ /* Send the request to the DHCP server */
+ if((ret =tnet_sockfd_sendto(localsocket6->fd, (const struct sockaddr*)&server, output->data, output->size))<0){
+ TNET_PRINT_LAST_ERROR("Failed to send DHCPv6 request.");
+
+ tsk_thread_sleep(150); // wait 150ms before trying the next iface.
+ goto next_iface;
+ }
+ /* wait for response */
+ if((ret = select(localsocket6->fd+1, &set, NULL, NULL, &tv))<0){ /* Error */
+ TNET_PRINT_LAST_ERROR("select have failed.");
+ tsk_thread_sleep(150); // wait 150ms before trying the next iface.
+ goto next_iface;
+ }
+ else if(ret == 0){ /* timeout ==> do nothing */
+ }
+ else{ /* there is data to read. */
+ tsk_size_t len = 0;
+ void* data = 0;
+
+ /* Check how how many bytes are pending */
+ if((ret = tnet_ioctlt(localsocket6->fd, FIONREAD, &len))<0){
+ goto next_iface;
+ }
+
+ /* Receive pending data */
+ data = tsk_calloc(len, sizeof(uint8_t));
+ if((ret = tnet_sockfd_recv(localsocket6->fd, data, len, 0))<0){
+ TSK_FREE(data);
+
+ TNET_PRINT_LAST_ERROR("Failed to receive DHCP dgrams.");
+ goto next_iface;
+ }
+
+ /* Parse the incoming response. */
+ reply = tnet_dhcp6_message_deserialize(ctx, data, (tsk_size_t)ret);
+ TSK_FREE(data);
+
+ if(reply)
+ { /* response successfuly parsed */
+ if(request->transaction_id != reply->transaction_id)
+ { /* Not same transaction id ==> continue*/
+ TSK_OBJECT_SAFE_FREE(reply);
+ }
+ }
+ }
+
+ next_iface:
+ TSK_OBJECT_SAFE_FREE(output);
+ if(reply){
+ goto bail;
+ }
+ }
+ break;//FIXME
+ }
+ while(timeout > tsk_time_epoch());
+
+bail:
+ TSK_OBJECT_SAFE_FREE(localsocket6);
+
+ return reply;
+}
+
+
+
+
+
+
+/**@ingroup tnet_dhcp6_group
+*/
+tnet_dhcp6_reply_t* tnet_dhcp6_requestinfo(const tnet_dhcp6_ctx_t* ctx, const tnet_dhcp6_option_orequest_t *orequest)
+{
+ tnet_dhcp6_reply_t* reply = 0;
+ tnet_dhcp6_request_t* request = tnet_dhcp6_request_create(dhcp6_type_information_request);
+ tnet_dhcp6_option_t* option = 0;
+
+ if(!ctx || !orequest || !request){
+ goto bail;
+ }
+
+ if((option = tnet_dhcp6_option_create(dhcp6_code_oro, orequest, sizeof(*orequest)))){
+ tsk_list_push_back_data(request->options, (void**)&option);
+ }
+
+ /* Vendor class */
+ {
+
+ }
+
+ reply = tnet_dhcp6_send_request(ctx, request);
+
+bail:
+
+ return reply;
+}
+
+
+
+
+
+//=================================================================================================
+// [[DHCPv6 CONTEXT]] object definition
+//
+static tsk_object_t* tnet_dhcp6_ctx_ctor(tsk_object_t * self, va_list * app)
+{
+ tnet_dhcp6_ctx_t *ctx = self;
+ if(ctx){
+ ctx->pen = TNET_IANA_PEN;
+ ctx->vendor_class_data = tsk_strdup(TNET_DHCP6_VENDOR_CLASS_DATA_DEFAULT);
+
+ ctx->port_client = TNET_DHCP6_CLIENT_PORT;
+ ctx->server_port = TNET_DHCP6_SERVER_PORT;
+ ctx->interfaces = tnet_get_interfaces();
+
+ ctx->timeout = 0xffff; /* FIXME */
+
+ if(!ctx->interfaces || TSK_LIST_IS_EMPTY(ctx->interfaces)){
+ TSK_DEBUG_ERROR("Failed to retrieve network interfaces.");
+ }
+
+ tsk_safeobj_init(ctx);
+ }
+ return self;
+}
+
+static tsk_object_t* tnet_dhcp6_ctx_dtor(tsk_object_t * self)
+{
+ tnet_dhcp6_ctx_t *ctx = self;
+ if(ctx){
+ tsk_safeobj_deinit(ctx);
+
+ TSK_FREE(ctx->vendor_class_data);
+
+ TSK_OBJECT_SAFE_FREE(ctx->interfaces);
+ }
+ return self;
+}
+
+static const tsk_object_def_t tnet_dhcp6_ctx_def_s =
+{
+ sizeof(tnet_dhcp6_ctx_t),
+ tnet_dhcp6_ctx_ctor,
+ tnet_dhcp6_ctx_dtor,
+ tsk_null,
+};
+const tsk_object_def_t *tnet_dhcp6_ctx_def_t = &tnet_dhcp6_ctx_def_s;
diff --git a/tinyNET/src/dhcp6/tnet_dhcp6.h b/tinyNET/src/dhcp6/tnet_dhcp6.h
new file mode 100644
index 0000000..893aaa4
--- /dev/null
+++ b/tinyNET/src/dhcp6/tnet_dhcp6.h
@@ -0,0 +1,128 @@
+/*
+* Copyright (C) 2009-2010 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+/**@file tnet_dhcp6.h
+ * @brief Dynamic Host Configuration Protocol for IPv6 (DHCPv6) as per RFC 3315.
+ * Also implement: RFC 3319, 3633, 3646, 3736, 4242, 5007 ...
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+
+#ifndef TNET_DHCP6_H
+#define TNET_DHCP6_H
+
+#include "tinynet_config.h"
+
+#include "tnet_dhcp6_message.h"
+
+#include "tnet_utils.h"
+
+#include "tsk_object.h"
+#include "tsk_safeobj.h"
+
+TNET_BEGIN_DECLS
+
+#define TNET_DHCP6_VENDOR_CLASS_DATA_DEFAULT "doubango/v0.0.0"
+
+/** RFC 3315 - 5.1. Multicast Addresses
+* A link-scoped multicast address used by a client to communicate with
+* neighboring (i.e., on-link) relay agents and servers.
+* All servers and relay agents are members of this multicast group.
+*/
+#define TNET_DHCP6_All_DHCP_Relay_Agents_and_Servers "FF02::1:2"
+
+/** RFC 3315 - 5.1. Multicast Addresses
+* A site-scoped multicast address used by a relay agent to communicate with servers, either
+* because the relay agent wants to send messages to all servers or because it does not know the unicast
+* addresses of the servers. Note that in order for a relay agent to use this address, it must have an
+* address of sufficient scope to be reachable by the servers. All servers within the site are members of
+* this multicast group.
+*/
+#define TNET_DHCP6_All_DHCP_Servers "FF05::1:3"
+
+/*== RFC 3315 - 5.5. Transmission and Retransmission Parameters
+ * This section presents a table of values used to describe the message
+ * transmission behavior of clients and servers.
+*/
+#define TNET_DHCP6_RT_SOL_MAX_DELAY 1 /**< 1 sec Max delay of first Solicit */
+#define TNET_DHCP6_RT_SOL_TIMEOUT 1 /**< 1 sec Initial Solicit timeout */
+#define TNET_DHCP6_RT_SOL_MAX_RT 120 /**< 120 secs Max Solicit timeout value */
+#define TNET_DHCP6_RT_REQ_TIMEOUT 1 /**< 1 sec Initial Request timeout */
+#define TNET_DHCP6_RT_REQ_MAX_RT 30 /**< 30 secs Max Request timeout value */
+#define TNET_DHCP6_RT_REQ_MAX_RC 10 /**< 10 Max Request retry attempts */
+#define TNET_DHCP6_RT_CNF_MAX_DELAY 1 /**< 1 sec Max delay of first Confirm */
+#define TNET_DHCP6_RT_CNF_TIMEOUT 1 /**< 1 sec Initial Confirm timeout */
+#define TNET_DHCP6_RT_CNF_MAX_RT 4 /**< 4 secs Max Confirm timeout */
+#define TNET_DHCP6_RT_CNF_MAX_RD 10 /**< 10 secs Max Confirm duration */
+#define TNET_DHCP6_RT_REN_TIMEOUT 10 /**< 10 secs Initial Renew timeout */
+#define TNET_DHCP6_RT_REN_MAX_RT 600 /**< 600 secs Max Renew timeout value */
+#define TNET_DHCP6_RT_REB_TIMEOUT 10 /**< 10 secs Initial Rebind timeout */
+#define TNET_DHCP6_RT_REB_MAX_RT 600 /**< 600 secs Max Rebind timeout value */
+#define TNET_DHCP6_RT_INF_MAX_DELAY 1 /**< 1 sec Max delay of first Information-request */
+#define TNET_DHCP6_RT_INF_TIMEOUT 1 /**< 1 sec Initial Information-request timeout */
+#define TNET_DHCP6_RT_INF_MAX_RT 120 /**< 120 secs Max Information-request timeout value */
+#define TNET_DHCP6_RT_REL_TIMEOUT 1 /**< 1 sec Initial Release timeout */
+#define TNET_DHCP6_RT_REL_MAX_RC 5 /**< 5 MAX Release attempts */
+#define TNET_DHCP6_RT_DEC_TIMEOUT 1 /**< 1 sec Initial Decline timeout */
+#define TNET_DHCP6_RT_DEC_MAX_RC 5 /**< 5 Max Decline attempts */
+#define TNET_DHCP6_RT_REC_TIMEOUT 2 /**< 2 secs Initial Reconfigure timeout */
+#define TNET_DHCP6_RT_REC_MAX_RC 2 /**< 8 Max Reconfigure attempts */
+#define TNET_DHCP6_RT_HOP_COUNT_LIMIT 32 /**< 32 Max hop count in a Relay-forward message */
+
+/** RFC 3315 - 5.6 Representation of time values and "Infinity" as a time value */
+#define TNET_DHCP6_TIMEVAL_INFINITY 0XFFFFFFFF
+
+/**< Local port(client) to bind to for incoming DHCP messages as per RFC 3315 subclause 5.2. */
+#define TNET_DHCP6_CLIENT_PORT 546
+/**< Destination port(Server) for outgoing DHCP messages as per RFC 3315 subclause 5.2. */
+#define TNET_DHCP6_SERVER_PORT 547
+
+/**@ingroup tnet_dhcpv_group
+* DHCPv6 context.
+*/
+typedef struct tnet_dhcp6_ctx_s
+{
+ TSK_DECLARE_OBJECT;
+
+ uint16_t pen; /**< Private Enterprise Number assigned by the IANA. Default= @ref TNET_IANA_PEN.*/
+ char* vendor_class_data;
+
+ uint64_t timeout;
+
+ tnet_port_t port_client; /**< Local port to bind to for incloming DHCPv6 messages. Default: 546 */
+ tnet_port_t server_port; /**< Destination port for outgoing DHCPv6 messages. Default: 547 */
+ tnet_interfaces_L_t *interfaces;
+
+ TSK_DECLARE_SAFEOBJ;
+}
+tnet_dhcp6_ctx_t;
+
+TINYNET_API tnet_dhcp6_reply_t* tnet_dhcp6_requestinfo(const tnet_dhcp6_ctx_t* ctx, const tnet_dhcp6_option_orequest_t *orequest);
+
+TINYNET_API tnet_dhcp6_ctx_t* tnet_dhcp6_ctx_create();
+
+TINYNET_GEXTERN const tsk_object_def_t *tnet_dhcp6_ctx_def_t;
+
+TNET_END_DECLS
+
+#endif /* TNET_DHCP6_H */
diff --git a/tinyNET/src/dhcp6/tnet_dhcp6_duid.c b/tinyNET/src/dhcp6/tnet_dhcp6_duid.c
new file mode 100644
index 0000000..378ba3c
--- /dev/null
+++ b/tinyNET/src/dhcp6/tnet_dhcp6_duid.c
@@ -0,0 +1,288 @@
+/*
+* Copyright (C) 2009-2010 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+/**@file tnet_dhcp6_duid.c
+ * @brief DHCPv6 (RFC 3315) DHCP Unique Identifier (DUID) as defined in subclause 9.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+#include "tnet_dhcp6_duid.h"
+
+#include "../tnet_types.h"
+#include "../tnet_endianness.h"
+
+int tnet_dhcp6_duid_llt_serialize(const tnet_dhcp6_duid_llt_t* self, tsk_buffer_t *output);
+int tnet_dhcp6_duid_en_serialize(const tnet_dhcp6_duid_en_t* self, tsk_buffer_t *output);
+int tnet_dhcp6_duid_ll_serialize(const tnet_dhcp6_duid_ll_t* self, tsk_buffer_t *output);
+
+
+tnet_dhcp6_duid_llt_t* tnet_dhcp6_duid_llt_create(const void* payload, tsk_size_t payload_size)
+{
+ return tsk_object_new(tnet_dhcp6_duid_llt_def_t, payload, payload_size);
+}
+
+tnet_dhcp6_duid_en_t* tnet_dhcp6_duid_en_create(const void* payload, tsk_size_t payload_size)
+{
+ return tsk_object_new(tnet_dhcp6_duid_en_def_t, payload, payload_size);
+}
+
+tnet_dhcp6_duid_ll_t* tnet_dhcp6_duid_ll_create(const void* payload, tsk_size_t payload_size)
+{
+ return tsk_object_new(tnet_dhcp6_duid_ll_def_t, payload, payload_size);
+}
+
+int tnet_dhcp6_duid_init(tnet_dhcp6_duid_t *self, tnet_dhcp6_duid_type_t type)
+{
+ if(self){
+ if(!self->initialized){
+ self->type = type;
+ self->initialized = tsk_true;
+ return 0;
+ }
+ return -2;
+ }
+ return -1;
+}
+
+int tnet_dhcp6_duid_deinit(tnet_dhcp6_duid_t *self)
+{
+ if(self){
+ if(self->initialized){
+ self->initialized = tsk_true;
+ return 0;
+ }
+ return -2;
+ }
+ return -1;
+}
+
+tnet_dhcp6_duid_t* tnet_dhcp6_duid_deserialize(const void* data, tsk_size_t size)
+{
+ tnet_dhcp6_duid_t *duid = 0;
+ uint8_t* dataPtr = ((uint8_t*)data);
+ //uint8_t* dataEnd = (dataPtr+size);
+
+ tnet_dhcp6_duid_type_t type;
+ //uint8_t len = 0;
+
+ /* Check validity */
+ if(!dataPtr || size<2/*Type*/){
+ goto bail;
+ }
+
+ type = (tnet_dhcp6_duid_type_t) tnet_ntohs_2(dataPtr);
+ dataPtr += 2;
+
+bail:
+ return duid;
+}
+
+int tnet_dhcp6_duid_serialize(const tnet_dhcp6_duid_t* self, tsk_buffer_t *output)
+{
+ int ret = -1;
+
+ if(!self || !output){
+ return ret;
+ }
+
+ switch(self->type){
+ case dhcp6_duid_linklayer_plus_time:
+ {
+ ret = tnet_dhcp6_duid_llt_serialize(TNET_DHCP6_DUID_LLT(self), output);
+ break;
+ }
+
+ case dhcp6_duid_Vendor_assigned_id:
+ {
+ ret = tnet_dhcp6_duid_en_serialize(TNET_DHCP6_DUID_EN(self), output);
+ break;
+ }
+
+ case dhcp6_duid_linklayer:
+ {
+ ret = tnet_dhcp6_duid_ll_serialize(TNET_DHCP6_DUID_LL(self), output);
+ break;
+ }
+
+ default:
+ {
+ ret = -2;
+ goto bail;
+ }
+ }
+
+bail:
+ return ret;
+}
+
+/*=======================================================================================
+* RFC 3315 - 9.2. DUID Based on Link-layer Address Plus Time [DUID-LLT]
+*=======================================================================================*/
+
+int tnet_dhcp6_duid_llt_serialize(const tnet_dhcp6_duid_llt_t* self, tsk_buffer_t *output)
+{
+ return -1;
+}
+
+//
+// [[DHCPv6 DUID-LLT]] object definition
+//
+static tsk_object_t* tnet_dhcp6_duid_llt_ctor(tsk_object_t * self, va_list * app)
+{
+ tnet_dhcp6_duid_llt_t *duid = self;
+ if(duid){
+ const void* payload = va_arg(*app, const void*);
+ tsk_size_t payload_size = va_arg(*app, tsk_size_t);
+
+ /* init base */
+ tnet_dhcp6_duid_init(TNET_DHCP6_DUID(duid), dhcp6_duid_linklayer_plus_time);
+
+ if(payload && payload_size){
+ /* DESERIALIZATION */
+ }
+ }
+ return self;
+}
+
+static tsk_object_t* tnet_dhcp6_duid_llt_dtor(tsk_object_t * self)
+{
+ tnet_dhcp6_duid_llt_t *duid = self;
+ if(duid){
+ /* deinit base */
+ tnet_dhcp6_duid_deinit(TNET_DHCP6_DUID(duid));
+
+ TSK_OBJECT_SAFE_FREE(duid->address);
+ }
+ return self;
+}
+
+static const tsk_object_def_t tnet_dhcp6_duid_llt_def_s =
+{
+ sizeof(tnet_dhcp6_duid_llt_t),
+ tnet_dhcp6_duid_llt_ctor,
+ tnet_dhcp6_duid_llt_dtor,
+ tsk_null,
+};
+const tsk_object_def_t *tnet_dhcp6_duid_llt_def_t = &tnet_dhcp6_duid_llt_def_s;
+
+
+/*=======================================================================================
+* RFC 3315 - 9.3. DUID Assigned by Vendor Based on Enterprise Number [DUID-EN]
+*=======================================================================================*/
+
+int tnet_dhcp6_duid_en_serialize(const tnet_dhcp6_duid_en_t* self, tsk_buffer_t *output)
+{
+ return -1;
+}
+
+//
+// [[DHCPv6 DUID-EN]] object definition
+//
+static tsk_object_t* tnet_dhcp6_duid_en_ctor(tsk_object_t * self, va_list * app)
+{
+ tnet_dhcp6_duid_en_t *duid = self;
+ if(duid){
+ const void* payload = va_arg(*app, const void*);
+ tsk_size_t payload_size = va_arg(*app, tsk_size_t);
+
+ /* init base */
+ tnet_dhcp6_duid_init(TNET_DHCP6_DUID(duid), dhcp6_duid_Vendor_assigned_id);
+
+ if(payload && payload_size){
+ /* DESERIALIZATION */
+ }
+ }
+ return self;
+}
+
+static tsk_object_t* tnet_dhcp6_duid_en_dtor(tsk_object_t * self)
+{
+ tnet_dhcp6_duid_en_t *duid = self;
+ if(duid){
+ /* deinit base */
+ tnet_dhcp6_duid_deinit(TNET_DHCP6_DUID(duid));
+
+ TSK_OBJECT_SAFE_FREE(duid->indentifier);
+ }
+ return self;
+}
+
+static const tsk_object_def_t tnet_dhcp6_duid_en_def_s =
+{
+ sizeof(tnet_dhcp6_duid_en_t),
+ tnet_dhcp6_duid_en_ctor,
+ tnet_dhcp6_duid_en_dtor,
+ tsk_null,
+};
+const tsk_object_def_t *tnet_dhcp6_duid_en_def_t = &tnet_dhcp6_duid_en_def_s;
+
+
+/*=======================================================================================
+* RFC 3315 - 9.4. DUID Based on Link-layer Address [DUID-LL]
+*=======================================================================================*/
+
+int tnet_dhcp6_duid_ll_serialize(const tnet_dhcp6_duid_ll_t* self, tsk_buffer_t *output)
+{
+ return -1;
+}
+
+//
+// [[DHCPv6 DUID-LL]] object definition
+//
+static tsk_object_t* tnet_dhcp6_duid_ll_ctor(tsk_object_t * self, va_list * app)
+{
+ tnet_dhcp6_duid_ll_t *duid = self;
+ if(duid){
+ const void* payload = va_arg(*app, const void*);
+ tsk_size_t payload_size = va_arg(*app, tsk_size_t);
+
+ /* init base */
+ tnet_dhcp6_duid_init(TNET_DHCP6_DUID(duid), dhcp6_duid_linklayer);
+
+ if(payload && payload_size){
+ /* DESERIALIZATION */
+ }
+ }
+ return self;
+}
+
+static tsk_object_t* tnet_dhcp6_duid_ll_dtor(tsk_object_t * self)
+{
+ tnet_dhcp6_duid_ll_t *duid = self;
+ if(duid){
+ /* deinit base */
+ tnet_dhcp6_duid_deinit(TNET_DHCP6_DUID(duid));
+
+ TSK_OBJECT_SAFE_FREE(duid->address);
+ }
+ return self;
+}
+
+static const tsk_object_def_t tnet_dhcp6_duid_ll_def_s =
+{
+ sizeof(tnet_dhcp6_duid_ll_t),
+ tnet_dhcp6_duid_ll_ctor,
+ tnet_dhcp6_duid_ll_dtor,
+ tsk_null,
+};
+const tsk_object_def_t *tnet_dhcp6_duid_ll_def_t = &tnet_dhcp6_duid_ll_def_s;
diff --git a/tinyNET/src/dhcp6/tnet_dhcp6_duid.h b/tinyNET/src/dhcp6/tnet_dhcp6_duid.h
new file mode 100644
index 0000000..9331ab3
--- /dev/null
+++ b/tinyNET/src/dhcp6/tnet_dhcp6_duid.h
@@ -0,0 +1,185 @@
+/*
+* Copyright (C) 2009-2010 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+/**@file tnet_dhcp6_duid.h
+ * @brief DHCPv6 (RFC 3315) DHCP Unique Identifier (DUID) as defined in subclause 9.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+#ifndef TNET_DHCP6_duid_H
+#define TNET_DHCP6_duid_H
+
+#include "tinynet_config.h"
+
+#include "tnet_hardwares.h"
+#include "tsk_list.h"
+#include "tsk_buffer.h"
+
+TNET_BEGIN_DECLS
+
+#define TNET_DHCP6_DUID(self) ((tnet_dhcp6_duid_t*)(self))
+#define TNET_DHCP6_DUID_LLT(self) ((tnet_dhcp6_duid_llt_t*)(self))
+#define TNET_DHCP6_DUID_EN(self) ((tnet_dhcp6_duid_en_t*)(self))
+#define TNET_DHCP6_DUID_LL(self) ((tnet_dhcp6_duid_ll_t*)(self))
+
+/** List of DHCPv6 DUIDs types as per RFC 3315 subclause 9.1.
+*/
+typedef enum tnet_dhcp6_duid_type_e
+{
+ dhcp6_duid_linklayer_plus_time = 1, /**< Link-layer address plus time. */
+ dhcp6_duid_Vendor_assigned_id = 2, /**< Vendor-assigned unique ID based on Enterprise Number. */
+ dhcp6_duid_linklayer = 3, /**< Link-layer address. */
+}
+tnet_dhcp6_duid_type_t;
+
+/** DHCP Unique Identifier (DUID) base class (subclause 9).
+*/
+typedef struct tnet_dhcp6_duid_s
+{
+ TSK_DECLARE_OBJECT;
+
+ tsk_bool_t initialized;
+
+ tnet_dhcp6_duid_type_t type; /* DUID type. 2-bytes value. */
+}
+tnet_dhcp6_duid_t;
+
+typedef tsk_list_t tnet_dhcp6_duids_L_t;
+
+#define TNET_DECLARE_DHCP6_DUID tnet_dhcp6_duid_t tnet_dhcp6_duid
+
+int tnet_dhcp6_duid_init(tnet_dhcp6_duid_t *self, tnet_dhcp6_duid_type_t type);
+int tnet_dhcp6_duid_deinit(tnet_dhcp6_duid_t *self);
+
+tnet_dhcp6_duid_t* tnet_dhcp6_duid_deserialize(const void* data, tsk_size_t size);
+int tnet_dhcp6_duid_serialize(const tnet_dhcp6_duid_t* self, tsk_buffer_t *output);
+
+/*=======================================================================================
+* RFC 3315 - 9.2. DUID Based on Link-layer Address Plus Time [DUID-LLT]
+*=======================================================================================*/
+
+/** DUID Based on Link-layer Address Plus Time [DUID-LLT]
+*/
+typedef struct tnet_dhcp6_duid_llt_s
+{
+ TNET_DECLARE_DHCP6_DUID;
+ /*
+ 0 1 2 3
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | 1 | hardware type (16 bits) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | time (32 bits) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ . .
+ . link-layer address (variable length) .
+ . .
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+ /* The hardware type code as maintained by IANA. */
+ tnet_hardware_type_t htype;
+ /* The time value is the time that the DUID is generated represented in seconds
+ since midnight (UTC), January 1, 2000, modulo 2^32. */
+ uint32_t time;
+ /* The link-layer address. */
+ tsk_buffer_t *address;
+}
+tnet_dhcp6_duid_llt_t;
+
+
+/*=======================================================================================
+* RFC 3315 - 9.3. DUID Assigned by Vendor Based on Enterprise Number [DUID-EN]
+*=======================================================================================*/
+
+/** DUID Assigned by Vendor Based on Enterprise Number [DUID-EN]
+*/
+typedef struct tnet_dhcp6_duid_en_s
+{
+ TNET_DECLARE_DHCP6_DUID;
+ /*
+ 0 1 2 3
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | 2 | enterprise-number |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | enterprise-number (contd) | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
+ . identifier .
+ . (variable length) .
+ . .
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+ /* Tthe vendor's registered Private Enterprise Number as maintained by IANA.
+ For more information: http://www.iana.org/assignments/enterprise-numbers. */
+ uint32_t en;
+ /* The link-layer address. */
+ tsk_buffer_t *indentifier;
+}
+tnet_dhcp6_duid_en_t;
+
+/*=======================================================================================
+* RFC 3315 - 9.4. DUID Based on Link-layer Address [DUID-LL]
+*=======================================================================================*/
+
+/** DUID Based on Link-layer Address [DUID-LL]
+*/
+typedef struct tnet_dhcp6_duid_ll_s
+{
+ TNET_DECLARE_DHCP6_DUID;
+ /*
+ 0 1 2 3
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | 3 | hardware type (16 bits) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ . .
+ . link-layer address (variable length) .
+ . .
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+ /* The hardware type code as maintained by IANA. */
+ tnet_hardware_type_t htype;
+ /* The link-layer address. */
+ tsk_buffer_t *address;
+}
+tnet_dhcp6_duid_ll_t;
+
+
+
+
+
+
+TINYNET_API tnet_dhcp6_duid_llt_t* tnet_dhcp6_duid_llt_create(const void* payload, tsk_size_t payload_size);
+TINYNET_API tnet_dhcp6_duid_en_t* tnet_dhcp6_duid_en_create(const void* payload, tsk_size_t payload_size);
+TINYNET_API tnet_dhcp6_duid_ll_t* tnet_dhcp6_duid_ll_create(const void* payload, tsk_size_t payload_size);
+
+
+
+
+TINYNET_GEXTERN const tsk_object_def_t *tnet_dhcp6_duid_llt_def_t;
+TINYNET_GEXTERN const tsk_object_def_t *tnet_dhcp6_duid_en_def_t;
+TINYNET_GEXTERN const tsk_object_def_t *tnet_dhcp6_duid_ll_def_t;
+
+TNET_END_DECLS
+
+#endif /* TNET_DHCP6_duid_H */
diff --git a/tinyNET/src/dhcp6/tnet_dhcp6_message.c b/tinyNET/src/dhcp6/tnet_dhcp6_message.c
new file mode 100644
index 0000000..28304e1
--- /dev/null
+++ b/tinyNET/src/dhcp6/tnet_dhcp6_message.c
@@ -0,0 +1,137 @@
+/*
+* Copyright (C) 2009-2010 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+/**@file tnet_dhcp6_message.c
+ * @brief DHCPv6 (RFC 3315) Messages.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+#include "tnet_dhcp6_message.h"
+#include "tnet_dhcp6.h"
+
+#include "../tnet_endianness.h"
+
+#include "tsk_string.h"
+#include "tsk_debug.h"
+
+#include <string.h>
+
+tnet_dhcp6_message_t* tnet_dhcp6_message_create(tnet_dhcp6_message_type_t type)
+{
+ return tsk_object_new(tnet_dhcp6_message_def_t, type);
+}
+
+tnet_dhcp6_request_t* tnet_dhcp6_request_create(tnet_dhcp6_message_type_t type)
+{
+ return tnet_dhcp6_message_create(type);
+}
+
+tsk_buffer_t* tnet_dhcp6_message_serialize(const tnet_dhcp6_ctx_t *ctx, const tnet_dhcp6_message_t *self)
+{
+ tsk_buffer_t* output = 0;
+ //uint8_t _1byte;
+ uint16_t _2bytes;
+ uint32_t _4bytes;
+
+ /* Check message validity */
+ if(!self){
+ goto bail;
+ }
+
+ output = tsk_buffer_create_null();
+
+ /*== msg-type + transaction-id */
+ _4bytes = (((uint32_t)(self->type)) << 24) | (self->transaction_id & 0xFFFFFF);
+ _4bytes = tnet_ntohl(_4bytes);
+ tsk_buffer_append(output, &(_4bytes), 4);
+
+ /*== Vendor class
+ */
+ {
+ _2bytes = tnet_htons(dhcp6_code_vendor_class);
+ tsk_buffer_append(output, &(_2bytes), 2);
+ _2bytes = tnet_htons(4 + tsk_strlen(ctx->vendor_class_data));
+ tsk_buffer_append(output, &(_2bytes), 2);
+ _4bytes = tnet_ntohl(ctx->pen);
+ tsk_buffer_append(output, &(_4bytes), 4);
+ tsk_buffer_append(output, ctx->vendor_class_data, tsk_strlen(ctx->vendor_class_data));
+ }
+
+ /*== DHCP Options
+ */
+ {
+ tsk_list_item_t *item;
+ tnet_dhcp6_option_t* option;
+ tsk_list_foreach(item, self->options)
+ {
+ option = (tnet_dhcp6_option_t*)item->data;
+ if(tnet_dhcp6_option_serialize(option, output)){
+ TSK_DEBUG_WARN("Failed to serialize DHCPv6 OPTION (%u)", option->code);
+ }
+ }
+ }
+bail:
+ return output;
+}
+
+tnet_dhcp6_message_t* tnet_dhcp6_message_deserialize(const tnet_dhcp6_ctx_t *ctx, const uint8_t *data, tsk_size_t size)
+{
+ return 0;
+}
+
+
+
+//=================================================================================================
+// [[DHCPv6 MESSAGE]] object definition
+//
+static tsk_object_t* tnet_dhcp6_message_ctor(tsk_object_t * self, va_list * app)
+{
+ tnet_dhcp6_message_t *message = self;
+ if(message){
+ static uint16_t __dhcp6message_unique_tid = 0;//(uint32_t)tsk_time_epoch();
+
+ message->type = va_arg(*app, tnet_dhcp6_message_type_t);
+ message->transaction_id = ++__dhcp6message_unique_tid;
+ message->options = tsk_list_create();
+ }
+ return self;
+}
+
+static tsk_object_t* tnet_dhcp6_message_dtor(tsk_object_t * self)
+{
+ tnet_dhcp6_message_t *message = self;
+ if(message){
+ TSK_OBJECT_SAFE_FREE(message->options);
+ }
+ return self;
+}
+
+static const tsk_object_def_t tnet_dhcp6_message_def_s =
+{
+ sizeof(tnet_dhcp6_message_t),
+ tnet_dhcp6_message_ctor,
+ tnet_dhcp6_message_dtor,
+ tsk_null,
+};
+const tsk_object_def_t *tnet_dhcp6_message_def_t = &tnet_dhcp6_message_def_s;
+
diff --git a/tinyNET/src/dhcp6/tnet_dhcp6_message.h b/tinyNET/src/dhcp6/tnet_dhcp6_message.h
new file mode 100644
index 0000000..fdf545f
--- /dev/null
+++ b/tinyNET/src/dhcp6/tnet_dhcp6_message.h
@@ -0,0 +1,143 @@
+/*
+* Copyright (C) 2009-2010 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+/**@file tnet_dhcp6_message.h
+ * @brief DHCPv6 (RFC 3315) Messages.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+#ifndef TNET_DHCP6_MESSAGE_H
+#define TNET_DHCP6_MESSAGE_H
+
+#include "tinynet_config.h"
+
+#include "tnet_dhcp6_option.h"
+
+#include "tsk_object.h"
+
+TNET_BEGIN_DECLS
+
+struct tnet_dhcp6_ctx_s;
+
+/** List of all supported DHCPv6 messages.
+* For more info: RFC 3315 - 5.3. DHCP Message Types
+*/
+typedef enum tnet_dhcp6_message_type_e
+{
+ /* A client sends a Solicit message to locate servers. */
+ dhcp6_type_solicit = 1,
+ /* A server sends an Advertise message to indicate that it is available for DHCP service, in
+ response to a Solicit message received from a client. */
+ dhcp6_type_advertise = 2,
+ /* A client sends a Request message to request configuration parameters, including IP
+ addresses, from a specific server. */
+ dhcp6_type_request = 3,
+ /* A client sends a Confirm message to any available server to determine whether the
+ addresses it was assigned are still appropriate to the link to which the client is connected. */
+ dhcp6_type_confirm = 4,
+ /* A client sends a Renew message to the server that originally provided the client's addresses
+ and configuration parameters to extend the lifetimes on the addresses assigned to the
+ client and to update other configurationparameters. */
+ dhcp6_type_renew = 5,
+ /* A client sends a Rebind message to any available server to extend the lifetimes on the
+ addresses assigned to the client and to update other configuration parameters; this message is
+ sent after a client receives no response to a Renew message.*/
+ dhcp6_type_rebind = 6,
+ /* A server sends a Reply message containing assigned addresses and configuration parameters
+ in response to a Solicit, Request, Renew, Rebind message received from a client. A
+ server sends a Reply message containing configuration parameters in response to an
+ Information-request message. A server sends a Reply message in response to a Confirm message
+ confirming or denying that the addresses assigned to the client are appropriate to the
+ link to which the client is connected. A server sends a Reply message to acknowledge
+ receipt of a Release or Decline message.*/
+ dhcp6_type_reply = 7,
+ /* A client sends a Release message to the server that assigned addresses to the client to
+ indicate that the client will no longer use one or more of the assigned addresses.*/
+ dhcp6_type_release = 8,
+ /* A client sends a Decline message to a server to indicate that the client has determined that
+ one or more addresses assigned by the server are already in use on the link to which the
+ client is connected.*/
+ dhcp6_type_decline = 9,
+ /*A server sends a Reconfigure message to a client to inform the client that the server has
+ new or updated configuration parameters, and that the client is to initiate a Renew/Reply
+ or Information-request/Reply transaction with the server in order to receive the updatedinformation. */
+ dhcp6_type_reconfigure = 10,
+ /* A client sends an Information-request message to a server to request configuration
+ parameters without the assignment of any IP addresses to the client.*/
+ dhcp6_type_information_request = 11,
+ /* A relay agent sends a Relay-forward message to relay messages to servers, either directly
+ or through another relay agent. The received message, either a client message or a
+ Relay-forward message from another relay agent, is encapsulated in an option in the Relay-forward message.*/
+ dhcp6_type_relay_forw = 12,
+ /* A server sends a Relay-reply message to a relay agent containing a message that the relay
+ agent delivers to a client. The Relay-reply message may be relayed by other relay agents
+ for delivery to the destination relay agent.
+ The server encapsulates the client message as an option in the Relay-reply message, which the
+ relay agent extracts and relays to the client.*/
+ dhcp6_type_relay_repl = 13,
+}
+tnet_dhcp6_message_type_t;
+
+
+/** DHCPv6 message (common fields) as per RFC 3315 subclause 6.
+*/
+typedef struct tnet_dhcp6_message_s
+{
+ TSK_DECLARE_OBJECT;
+ /*
+ 0 1 2 3
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | msg-type | transaction-id |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ . options .
+ . (variable) .
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+ /* Identifies the DHCP message type. 1-byte value. */
+ tnet_dhcp6_message_type_t type;
+ /* The transaction ID for this message exchange. 3-bytes value. */
+ uint32_t transaction_id;
+ /* Options carried in this message. */
+ tnet_dhcp6_options_L_t *options;
+}
+tnet_dhcp6_message_t;
+
+typedef tsk_list_t tnet_dhcp6_messages_L_t;
+typedef tnet_dhcp6_message_t tnet_dhcp6_request_t;
+typedef tnet_dhcp6_message_t tnet_dhcp6_reply_t;
+
+tsk_buffer_t* tnet_dhcp6_message_serialize(const struct tnet_dhcp6_ctx_s *ctx, const tnet_dhcp6_message_t *self);
+tnet_dhcp6_message_t* tnet_dhcp6_message_deserialize(const struct tnet_dhcp6_ctx_s *ctx, const uint8_t *data, tsk_size_t size);
+
+TINYNET_API tnet_dhcp6_message_t* tnet_dhcp6_message_create(tnet_dhcp6_message_type_t type);
+TINYNET_API tnet_dhcp6_request_t* tnet_dhcp6_request_create(tnet_dhcp6_message_type_t type);
+
+TINYNET_GEXTERN const tsk_object_def_t *tnet_dhcp6_message_def_t;
+
+
+TNET_END_DECLS
+
+#endif /* TNET_DHCP6_MESSAGE_H */
diff --git a/tinyNET/src/dhcp6/tnet_dhcp6_option.c b/tinyNET/src/dhcp6/tnet_dhcp6_option.c
new file mode 100644
index 0000000..7f7aca4
--- /dev/null
+++ b/tinyNET/src/dhcp6/tnet_dhcp6_option.c
@@ -0,0 +1,336 @@
+/*
+* Copyright (C) 2009-2010 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+/**@file tnet_dhcp6_option.c
+ * @brief DHCPv6 Options as per RFC 3315 subclause 22.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+#include "tnet_dhcp6_option.h"
+
+#include "../tnet_types.h"
+#include "../tnet_endianness.h"
+
+#include "tsk_memory.h"
+
+#include <string.h>
+
+tnet_dhcp6_option_t* tnet_dhcp6_option_create(tnet_dhcp6_option_code_t code, const void* payload, tsk_size_t payload_size)
+{
+ return tsk_object_new(tnet_dhcp6_option_def_t, code, payload, payload_size);
+}
+
+tnet_dhcp6_option_identifier_t* tnet_dhcp6_option_indentifer_create(tnet_dhcp6_option_code_t code, const void* payload, tsk_size_t payload_size)
+{
+ return tsk_object_new(tnet_dhcp6_option_identifier_def_t, code, payload, payload_size);
+}
+
+tnet_dhcp6_option_identifier_t* tnet_dhcp6_option_clientid_create(const void* payload, tsk_size_t payload_size)
+{
+ return tnet_dhcp6_option_indentifer_create(dhcp6_code_clientid, payload, payload_size);
+}
+
+tnet_dhcp6_option_identifier_t* tnet_dhcp6_option_serverid_create(const void* payload, tsk_size_t payload_size)
+{
+ return tnet_dhcp6_option_indentifer_create(dhcp6_code_serverid, payload, payload_size);
+}
+
+tnet_dhcp6_option_orequest_t* tnet_dhcp6_option_orequest_create(const void* payload, tsk_size_t payload_size)
+{
+ return tsk_object_new(tnet_dhcp6_option_orequest_def_t, payload, payload_size);
+}
+
+tnet_dhcp6_option_orequest_t* tnet_dhcp6_option_orequest_create_null()
+{
+ return tnet_dhcp6_option_orequest_create(tsk_null, 0);
+}
+
+tnet_dhcp6_option_vendorclass_t* tnet_dhcp6_option_vendorclass_create(const void* payload, tsk_size_t payload_size)
+{
+ return tsk_object_new(tnet_dhcp6_option_vendorclass_def_t, payload, payload_size);
+}
+
+tnet_dhcp6_option_vendorclass_t* tnet_dhcp6_option_vendorclass_create_null()
+{
+ return tnet_dhcp6_option_vendorclass_create(tsk_null, 0);
+}
+
+tnet_dhcp6_option_t* tnet_dhcp6_option_deserialize(const void* data, tsk_size_t size)
+{
+ tnet_dhcp6_option_t *option = 0;
+ uint8_t* dataPtr = ((uint8_t*)data);
+ //uint8_t* dataEnd = (dataPtr+size);
+
+ tnet_dhcp6_option_code_t code;
+ uint16_t len;
+
+ /* Check validity */
+ if(!dataPtr || size<4/*Code Len*/){
+ goto bail;
+ }
+
+ code = (tnet_dhcp6_option_code_t) tnet_ntohs_2(dataPtr);
+ dataPtr += 2;
+
+ len = tnet_ntohs_2(dataPtr);
+ dataPtr += 2;
+
+ switch(code){
+ case dhcp6_code_clientid:
+ case dhcp6_code_serverid:
+ {
+ break;
+ }
+
+ default:
+ {
+ break;
+ }
+ }
+bail:
+ return option;
+}
+
+int tnet_dhcp6_option_serialize(const tnet_dhcp6_option_t* self, tsk_buffer_t *output)
+{
+ uint16_t _2bytes;
+ int ret = -1;
+
+ if(!self || !output){
+ goto bail;
+ }
+
+ /*== Code */
+ _2bytes = tnet_htons(self->code);
+ tsk_buffer_append(output, &(_2bytes), 2);
+
+ switch(self->code){
+ case dhcp6_code_clientid:
+ case dhcp6_code_serverid:
+ {
+ break;
+ }
+
+ case dhcp6_code_oro:
+ default:
+ {
+ if(self->data)
+ {
+ const tnet_dhcp6_option_orequest_t* opt = (const tnet_dhcp6_option_orequest_t*)self->data;
+ if(opt->codes){
+ /* option-len */
+ _2bytes = tnet_htons(opt->codes->size);
+ tsk_buffer_append(output, &(_2bytes), 2);
+ /* option-data */
+ ret = tsk_buffer_append(output, opt->codes->data, opt->codes->size);
+ }
+
+ }
+ break;
+ }
+ }
+bail:
+ return ret;
+}
+
+int tnet_dhcp6_option_serializeex(tnet_dhcp6_option_code_t code, uint8_t length, const void* value, tsk_buffer_t *output)
+{
+ return -1;
+}
+
+//
+// [[DHCPv6 OPTION]] object definition
+//
+static tsk_object_t* tnet_dhcp6_option_ctor(tsk_object_t * self, va_list * app)
+{
+ tnet_dhcp6_option_t *option = self;
+ if(option){
+ tnet_dhcp6_option_code_t code = va_arg(*app, tnet_dhcp6_option_code_t);
+ const void* payload = va_arg(*app, const void*);
+ tsk_size_t payload_size = va_arg(*app, tsk_size_t);
+
+ option->code = code;
+ if(payload && payload_size){
+ if((option->data = (tnet_dhcp6_option_data_t*)tsk_calloc(payload_size, sizeof(uint8_t)))){
+ memcpy(option->data, payload, payload_size);
+ option->len = payload_size;
+ }
+ }
+ }
+ return self;
+}
+
+static tsk_object_t* tnet_dhcp6_option_dtor(tsk_object_t * self)
+{
+ tnet_dhcp6_option_t *option = self;
+ if(option){
+ TSK_OBJECT_SAFE_FREE(option->data);
+ }
+ return self;
+}
+
+static const tsk_object_def_t tnet_dhcp6_option_def_s =
+{
+ sizeof(tnet_dhcp6_option_t),
+ tnet_dhcp6_option_ctor,
+ tnet_dhcp6_option_dtor,
+ tsk_null,
+};
+const tsk_object_def_t *tnet_dhcp6_option_def_t = &tnet_dhcp6_option_def_s;
+
+/*======================================================================================
+* RFC 3315 -
+ 22.2. Client Identifier Option
+ 22.3. Server Identifier Option
+*=======================================================================================*/
+//
+// [[DHCPv6 Option Request Option]] object definition
+//
+static tsk_object_t* tnet_dhcp6_option_identifier_ctor(tsk_object_t * self, va_list * app)
+{
+ tnet_dhcp6_option_identifier_t *option = self;
+ if(option){
+ //tnet_dhcp6_option_code_t code = va_arg(*app, tnet_dhcp6_option_code_t);
+ const void* payload = va_arg(*app, const void*);
+ tsk_size_t payload_size = va_arg(*app, tsk_size_t);
+
+ if(payload && payload_size){
+ /* DESERIALIZATION */
+ }
+ }
+ return self;
+}
+
+static tsk_object_t* tnet_dhcp6_option_identifier_dtor(tsk_object_t * self)
+{
+ tnet_dhcp6_option_identifier_t *option = self;
+ if(option){
+ TSK_OBJECT_SAFE_FREE(option->duid);
+ }
+ return self;
+}
+
+static const tsk_object_def_t tnet_dhcp6_option_identifier_def_s =
+{
+ sizeof(tnet_dhcp6_option_identifier_t),
+ tnet_dhcp6_option_identifier_ctor,
+ tnet_dhcp6_option_identifier_dtor,
+ tsk_null,
+};
+const tsk_object_def_t *tnet_dhcp6_option_identifier_def_t = &tnet_dhcp6_option_identifier_def_s;
+
+/*======================================================================================
+* RFC 3315 - 22.7. Option Request Option
+*=======================================================================================*/
+
+int tnet_dhcp6_option_orequest_add_code(tnet_dhcp6_option_orequest_t* self, uint16_t code)
+{
+ uint16_t _2bytes;
+ int ret = -1;
+ if(self){
+ if(!self->codes){
+ if(!(self->codes = tsk_buffer_create_null())){
+ return -3;
+ }
+ }
+ _2bytes = tnet_ntohs(code);
+ if(!(ret = tsk_buffer_append(self->codes, &_2bytes, 2))){
+ TNET_DHCP6_OPTION(self)->len += 2;
+ }
+ }
+ return ret;
+}
+
+//
+// [[DHCPv6 Option Request Option]] object definition
+//
+static tsk_object_t* tnet_dhcp6_option_orequest_ctor(tsk_object_t * self, va_list * app)
+{
+ tnet_dhcp6_option_orequest_t *option = self;
+ if(option){
+ const void* payload = va_arg(*app, const void*);
+ tsk_size_t payload_size = va_arg(*app, tsk_size_t);
+
+ if(payload && payload_size)
+ { /* DESERIALIZATION */
+ }
+ }
+ return self;
+}
+
+static tsk_object_t* tnet_dhcp6_option_orequest_dtor(tsk_object_t * self)
+{
+ tnet_dhcp6_option_orequest_t *option = self;
+ if(option){
+ TSK_OBJECT_SAFE_FREE(option->codes);
+ }
+ return self;
+}
+
+static const tsk_object_def_t tnet_dhcp6_option_orequest_def_s =
+{
+ sizeof(tnet_dhcp6_option_orequest_t),
+ tnet_dhcp6_option_orequest_ctor,
+ tnet_dhcp6_option_orequest_dtor,
+ tsk_null,
+};
+const tsk_object_def_t *tnet_dhcp6_option_orequest_def_t = &tnet_dhcp6_option_orequest_def_s;
+
+/*======================================================================================
+* RFC 3315 - 22.16. Vendor Class Option
+*=======================================================================================*/
+
+//
+// [[DHCPv6 Option Request Option]] object definition
+//
+static tsk_object_t* tnet_dhcp6_option_vendorclass_ctor(tsk_object_t * self, va_list * app)
+{
+ tnet_dhcp6_option_vendorclass_t *option = self;
+ if(option){
+ const void* payload = va_arg(*app, const void*);
+ tsk_size_t payload_size = va_arg(*app, tsk_size_t);
+
+ if(payload && payload_size){
+ /* DESERIALIZATION */
+ }
+ }
+ return self;
+}
+
+static tsk_object_t* tnet_dhcp6_option_vendorclass_dtor(tsk_object_t * self)
+{
+ tnet_dhcp6_option_vendorclass_t *option = self;
+ if(option){
+ TSK_OBJECT_SAFE_FREE(option->vendor_class_data);
+ }
+ return self;
+}
+
+static const tsk_object_def_t tnet_dhcp6_option_vendorclass_def_s =
+{
+ sizeof(tnet_dhcp6_option_vendorclass_t),
+ tnet_dhcp6_option_vendorclass_ctor,
+ tnet_dhcp6_option_vendorclass_dtor,
+ tsk_null,
+};
+const tsk_object_def_t *tnet_dhcp6_option_vendorclass_def_t = &tnet_dhcp6_option_vendorclass_def_s;
diff --git a/tinyNET/src/dhcp6/tnet_dhcp6_option.h b/tinyNET/src/dhcp6/tnet_dhcp6_option.h
new file mode 100644
index 0000000..efa843f
--- /dev/null
+++ b/tinyNET/src/dhcp6/tnet_dhcp6_option.h
@@ -0,0 +1,246 @@
+/*
+* Copyright (C) 2009-2010 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*
+*/
+/**@file tnet_dhcp6_option.h
+ * @brief DHCPv6 Options as per RFC 3315 subclause 22.
+ *
+ * @author Mamadou Diop <diopmamadou(at)doubango.org>
+ *
+ * @date Created: Sat Nov 8 16:54:58 2009 mdiop
+ */
+
+#ifndef TNET_DHCP6_OPTION_H
+#define TNET_DHCP6_OPTION_H
+
+#include "tinynet_config.h"
+
+#include "tnet_dhcp6_duid.h"
+
+#include "tsk_list.h"
+#include "tsk_buffer.h"
+
+TNET_BEGIN_DECLS
+
+#define TNET_DHCP6_OPTION(self) ((tnet_dhcp6_option_t*)(self))
+
+/** List of DHCPv6 option as registered by IANA (RFC 3315 subcaluse 24.3)*/
+typedef enum tnet_dhcp6_option_code_e
+{
+ dhcp6_code_clientid = 1, /**< Client Identifier Option. */
+ dhcp6_code_serverid = 2, /**< Server Identifier Option. */
+ dhcp6_code_ia_na = 3, /**< Identity Association for Non-temporary Addresses Option. */
+ dhcp6_code_ia_ta = 4, /**< Identity Association for Temporary Addresses Option. */
+ dhcp6_code_iaaddr = 5, /**< IA Address Option. */
+ dhcp6_code_oro = 6, /**< Option Request Option. */
+ dhcp6_code_preference = 7, /**< Preference Option. */
+ dhcp6_code_elapsed_time = 8, /**< Elapsed Time Option. */
+ dhcp6_code_relay_msg = 9, /**< Relay Message Option. */
+ dhcp6_code_auth = 11, /**< Authentication Option. */
+ dhcp6_code_unicast = 12, /**< Server Unicast Option. */
+ dhcp6_code_status_code = 13, /**< Status Code Option. */
+ dhcp6_code_rapid_commit = 14, /**< Rapid Commit Option. */
+ dhcp6_code_user_class = 15, /**< User Class Option. */
+ dhcp6_code_vendor_class = 16, /**< Vendor Class Option. */
+ dhcp6_code_vendor_opts = 17, /**< Vendor-specific Information Option. */
+ dhcp6_code_interface_id = 18, /**< Interface-Id Option. */
+ dhcp6_code_reconf_msg = 19, /**< Reconfigure Message Option. */
+ dhcp6_code_reconf_accept = 20, /**< Reconfigure Accept Option. */
+}
+tnet_dhcp6_option_code_t;
+
+/** List of DHCPv6 status codes as registered by IANA (RFC 3315 subclause 24.4) */
+typedef enum tnet_dhcp6_statuscode_e
+{
+ /* Success */
+ dhcp6_statuscode_Success = 0,
+ /* Failure, reason unspecified; this status code is sent by either a client
+ or a server to indicate a failure not explicitly specified in this document (RFC 3315). */
+ dhcp6_statuscode_UnspecFail = 1,
+ /* Server has no addresses available to assign to the IA(s). */
+ dhcp6_statuscode_NoAddrsAvail = 2,
+ /* Client record (binding) unavailable. */
+ dhcp6_statuscode_NoBinding = 3,
+ /* The prefix for the address is not appropriate for the link to which the client is attached. */
+ dhcp6_statuscode_NotOnLink = 4,
+ /* Sent by a server to a client to force the client to send messages to the server.
+ using the All_DHCP_Relay_Agents_and_Servers address.*/
+ dhcp6_statuscode_UseMulticast = 5
+}
+tnet_dhcp6_statuscode_t;
+
+/*=======================================================================================
+* RFC 3315 - 22.1. Format of DHCP Options
+*=======================================================================================*/
+
+/**@ingroup tnet_dhcpv_group
+* DHCPv6 option-data.
+*/
+typedef struct tnet_dhcp6_option_data_s
+{
+ TSK_DECLARE_OBJECT;
+}
+tnet_dhcp6_option_data_t;
+#define TNET_DECLARE_DHCP6_OPTION_DATA tnet_dhcp6_option_data_t dhcp6_option_data
+
+typedef struct tnet_dhcp6_option_s
+{
+ TSK_DECLARE_OBJECT;
+
+ /* RFC 3315 - 22.1. Format of DHCP Options
+ 0 1 2 3
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | option-code(2) | option-len(2) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | option-data |
+ | (option-len octets) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ /* An unsigned integer identifying the specific option type carried in this option.*/
+ tnet_dhcp6_option_code_t code;
+ /* Option length. Same as tsk_strlen(data buffer)*/
+ uint16_t len;
+ /* opton-data */
+ tnet_dhcp6_option_data_t *data;
+}
+tnet_dhcp6_option_t;
+
+typedef tsk_list_t tnet_dhcp6_options_L_t;
+
+#define TNET_DECLARE_DHCP6_OPTION tnet_dhcp6_option_t dhcp6_option
+
+tnet_dhcp6_option_t* tnet_dhcp6_option_deserialize(const void* data, tsk_size_t size);
+int tnet_dhcp6_option_serialize(const tnet_dhcp6_option_t* self, tsk_buffer_t *output);
+int tnet_dhcp6_option_serializeex(tnet_dhcp6_option_code_t code, uint8_t length, const void* value, tsk_buffer_t *output);
+
+
+
+
+/*======================================================================================
+* RFC 3315 -
+ 22.2. Client Identifier Option
+ 22.3. Server Identifier Option
+*=======================================================================================*/
+/** DHCPv6 Client /server Identifier Option (subclause 22.2 and 22.3).
+*/
+typedef struct tnet_dhcp6_option_identifier_s
+{
+ TNET_DECLARE_DHCP6_OPTION_DATA;
+ /*
+ 0 1 2 3
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | OPTION_XXXXXXID | option-len |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ . .
+ . DUID .
+ . (variable length) .
+ . .
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ OPTION_XXXXXXID = OPTION_CLIENTID or OPTION_SERVERID
+ */
+ tnet_dhcp6_duid_t *duid;
+}
+tnet_dhcp6_option_identifier_t;
+typedef tnet_dhcp6_option_identifier_t tnet_dhcp6_option_clientid_t;
+typedef tnet_dhcp6_option_identifier_t tnet_dhcp6_option_serverid_t;
+
+
+/*======================================================================================
+* RFC 3315 - 22.4. Identity Association for Non-temporary Addresses Option
+*=======================================================================================*/
+
+/*======================================================================================
+* RFC 3315 - 22.7. Option Request Option
+*=======================================================================================*/
+
+/** DHCPv6 Option Request Option (subclause 22.7).
+*/
+typedef struct tnet_dhcp6_option_orequest_s
+{
+ TNET_DECLARE_DHCP6_OPTION_DATA;
+ /*
+ 0 1 2 3
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | OPTION_ORO | option-len |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | requested-option-code-1 | requested-option-code-2 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | ... |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+ tsk_buffer_t* codes;
+}
+tnet_dhcp6_option_orequest_t;
+
+TINYNET_API int tnet_dhcp6_option_orequest_add_code(tnet_dhcp6_option_orequest_t* self, uint16_t code);
+
+/*======================================================================================
+* RFC 3315 - 22.16. Vendor Class Option
+*=======================================================================================*/
+
+/** DHCPv6 Vendor Class Option (subclause 22.16).
+*/
+typedef struct tnet_dhcp6_option_vendorclass_s
+{
+ TNET_DECLARE_DHCP6_OPTION_DATA;
+ /*
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | OPTION_VENDOR_CLASS | option-len |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | enterprise-number |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ . .
+ . vendor-class-data .
+ . . . . .
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+ uint32_t enterprise_number;
+ /*
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...-+-+-+-+-+-+-+
+ | vendor-class-len | opaque-data |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...-+-+-+-+-+-+-+
+ */
+ tsk_buffer_t* vendor_class_data;
+}
+tnet_dhcp6_option_vendorclass_t;
+
+
+TINYNET_API tnet_dhcp6_option_t* tnet_dhcp6_option_create(tnet_dhcp6_option_code_t code, const void* payload, tsk_size_t payload_size);
+TINYNET_API tnet_dhcp6_option_identifier_t* tnet_dhcp6_option_indentifer_create(tnet_dhcp6_option_code_t code, const void* payload, tsk_size_t payload_size);
+TINYNET_API tnet_dhcp6_option_identifier_t* tnet_dhcp6_option_clientid_create(const void* payload, tsk_size_t payload_size);
+TINYNET_API tnet_dhcp6_option_identifier_t* tnet_dhcp6_option_serverid_create(const void* payload, tsk_size_t payload_size);
+TINYNET_API tnet_dhcp6_option_orequest_t* tnet_dhcp6_option_orequest_create(const void* payload, tsk_size_t payload_size);
+TINYNET_API tnet_dhcp6_option_orequest_t* tnet_dhcp6_option_orequest_create_null();
+TINYNET_API tnet_dhcp6_option_vendorclass_t* tnet_dhcp6_option_vendorclass_create(const void* payload, tsk_size_t payload_size);
+TINYNET_API tnet_dhcp6_option_vendorclass_t* tnet_dhcp6_option_vendorclass_create_null();
+
+TINYNET_GEXTERN const tsk_object_def_t *tnet_dhcp6_option_def_t;
+TINYNET_GEXTERN const tsk_object_def_t *tnet_dhcp6_option_identifier_def_t;
+TINYNET_GEXTERN const tsk_object_def_t *tnet_dhcp6_option_orequest_def_t;
+TINYNET_GEXTERN const tsk_object_def_t *tnet_dhcp6_option_vendorclass_def_t;
+
+TNET_END_DECLS
+
+#endif /* TNET_DHCP6_OPTION_H */
OpenPOWER on IntegriCloud