5#ifndef __DHCPV6_INTERNAL_H
6#define __DHCPV6_INTERNAL_H
12#include <ipv6/dhcpv6_const.h>
13#include <ipv6/dhcpv6_msg.h>
15#define CLIENT_LONG_SERVID 18
20#define DHCPv6_DBSHOW(msg) msg.ShowMsg()
21#define DHCPv6_DBIPRINTF(...) \
23 iprintf("\n[T:%d-%ld]%s:%s:%d::", OSTaskID(), TimeTick, __FILE__, __FUNCTION__, __LINE__); \
24 iprintf(__VA_ARGS__); \
27#define DHCPv6_DBSHOW(msg) ((void)0)
28#define DHCPv6_DBIPRINTF(...) ((void)0)
44 DHCP_Message *dhcp_msg;
48 uint32_t opts_present[4];
51 static const IPADDR6 ALL_RELAY_AND_SERVERS;
52 static const IPADDR6 ALL_SERVERS;
55 DHCPv6Message(DHCP_Message *msg, uint16_t len);
63 PoolPtr ReleaseBuffer();
71 inline void SetTypeAndXid(MessageType type, uint32_t xid)
76 beuint32_t tXid = xid;
77 Msg.
AddData((uint8_t *)&tXid, 4);
81 void AddOption(Option &opt, uint16_t overrideLen = 0);
84 void AddORO(Option_ID ids[], uint16_t len,
int ifNum);
85 void AddElapsedTime(uint16_t elapsedTime);
86 void AddIA_NA(uint32_t IA_ID, uint32_t T1, uint32_t T2, uint16_t optLen = 0);
87 void AddFQDN(
const char *name);
89 inline MessageType GetType() {
return (MessageType)((dhcp_msg->typeAndXid) >> 24); }
90 inline uint32_t GetXid() {
return (dhcp_msg->typeAndXid) & 0xFFFFFF; }
92 Option *GetOption(Option_ID optID, Option *lastOpt = NULL);
95 void SendMsg(
const IPADDR6 &ServerIP = ALL_RELAY_AND_SERVERS,
int via_interface = -1);
97 static void SendSolicit(uint32_t ifNum, uint32_t xid, uint32_t timeElapsed);
98 static void SendRequest(uint32_t ifNum, uint32_t xid, uint32_t timeElapsed, Opt::ClientServerID *serverID, Opt::IA_NA *ia_na);
99 static void SendInfoReq(uint32_t ifNum, uint32_t xid);
107 STATE_SOLICIT_START = 0,
108 STATE_SOLICIT_DLYED = 1,
109 STATE_SOLICIT_MSG_REC = 2,
110 STATE_REQUEST_SENDING = 3,
114 STATE_INFO_REQ_SENDING = 7,
115 STATE_INFO_REP_REC = 8,
121 IPv6Interface *myInterface;
122 uint32_t nextActionTick;
123 uint32_t currentDelay;
124 uint32_t retransmitCount;
129 IPV6_DHCPD *activeDHCPD;
130 uint8_t activeServerID[CLIENT_LONG_SERVID];
132 PoolPtr actingMessage;
135 inline void SetState(ClientState newState)
137 DHCPv6_DBIPRINTF(
"Setting state: %s", GetStateString(newState));
140 static char const *GetStateString(ClientState state);
142 void SetCurrentDelay(uint32_t delayBase);
143 void IncrementCurrentDelay(uint32_t maxDelay);
144 uint32_t GetNewXid();
146 void ProcessReply(DHCPv6Message &msg);
147 void ProcessReply_Info(DHCPv6Message &msg);
148 void ProcessReply_Solicit(DHCPv6Message &msg,
bool needServerMatch);
150 void ProcessReply_DNSOpt(IPV6_DHCPD *server, Opt::DNS_Servers *dnsOpt, uint32_t time);
152 void ProcessAdvert(DHCPv6Message &msg);
153 void ProcessReconfig(DHCPv6Message &msg);
157 void SendRenewRebind(
bool renew);
160 DHCPClient(IPv6Interface *intf);
161 inline uint32_t GetNextActionTick() {
return nextActionTick; }
163 void ProcessMsg(DHCPv6Message &msg);
166 inline ClientState GetState() {
return state; }
170 static void ProcessDHCPAvail(IPv6Interface *intf, uint8_t raFlags);
171 static void ProcessDHCPMsg(
UDPPacket *pkt);
175extern Option_ID *(*pAddOROCB)(
int ifNum);
176extern void (*pRequestOptionCB)(
int ifNum, DHCPv6Message &msg);
177extern void (*pReplyCB)(
int ifNum, DHCPv6Message &msg);
Used to hold and manipulate IPv4 and IPv6 addresses in dual stack mode.
Definition ipv6_addr.h:41
UDP Packet Class.
Definition udp.h:81
IPADDR GetSourceAddress(void)
Get the source IP address a UDP Packet object.
Definition udp.h:285
void ResetData(void)
Set the data size of a UDP Packet object to 0.
void AddData(puint8_t pData, uint16_t len)
Add a number of data bytes to a UDP Packet object.
puint8_t GetDataBuffer(bool bReAllocateIfNeeded=false)
Get a pointer to the UDP Packet object's data buffer.
@ Option
Option.
Definition nbWifiConstants.h:385
NetBurner IPADDR4 Class. See the IPADDR4 Class page for complete documentation.
NetBurner User Datagram Protocol Header File.