Choco OS  V.0.16.9.0
Join to the chocolate world
oc_dhcp.h
Go to the documentation of this file.
1 
32 #ifndef SYSTEM_CORE_INC_NET_OC_DHCP_H_
33 #define SYSTEM_CORE_INC_NET_OC_DHCP_H_
34 
35 #include <oc_stdtypes.h>
36 #include <oc_compiler.h>
37 #include <oc_net.h>
38 #include <oc_netif.h>
39 
45 #define _________________________________________DEFINITIONS_SECTION________________________________________________________________________
46 
47 //==========================================================================================================================================
52 //==========================================================================================================================================
53 #define oC_DHCP_MAGIC_COOKIE 0x63825363
54 
55 //==========================================================================================================================================
60 //==========================================================================================================================================
61 #define oC_DHCP_END_OPTION 0xFF
62 
63 //==========================================================================================================================================
68 //==========================================================================================================================================
69 #define oC_DHCP_OPTIONS_BUFFER_SIZE 600
70 
71 #undef _________________________________________DEFINITIONS_SECTION________________________________________________________________________
72 
73 
79 #define _________________________________________TYPES_SECTION______________________________________________________________________________
80 
81 //==========================================================================================================================================
87 //==========================================================================================================================================
88 typedef enum
89 {
93 
94 //==========================================================================================================================================
101 //==========================================================================================================================================
102 typedef enum
103 {
116 
117 //==========================================================================================================================================
124 //==========================================================================================================================================
125 typedef enum
126 {
130 
131 //==========================================================================================================================================
141 //==========================================================================================================================================
142 typedef enum
143 {
156 
169 
170 //==========================================================================================================================================
174 //==========================================================================================================================================
175 typedef enum
176 {
187 
200 
201 //==========================================================================================================================================
208 //==========================================================================================================================================
209 typedef struct PACKED
210 {
211 #ifdef LITTLE_ENDIAN
212  uint32_t Operation:8;
213  uint32_t HardwareType:8;
215  uint32_t Hops:8;
216  uint32_t XID;
217  uint32_t Secs:16;
218  uint32_t Flags:16;
219  uint32_t CIAddr;
220  uint32_t YIAddr;
221  uint32_t SIAddr;
222  uint32_t GIAddr;
223  uint8_t CHAddr[16];
224  char SName[64];
225  char File[128];
226  uint32_t MagicCookie;
228 
229 #elif defined(BIG_ENDIAN)
230 # error The structure is not defined for BIG_ENDIAN
231 #else
232 # error Endianess is not correct
233 #endif
235 
236 #undef _________________________________________TYPES_SECTION______________________________________________________________________________
237 
243 #define _________________________________________FUNCTIONS_SECTION__________________________________________________________________________
244 
245 extern oC_ErrorCode_t oC_Dhcp_SendMessage ( oC_Netif_t Netif , oC_Dhcp_Message_t * Message , uint16_t Size, oC_Time_t Timeout );
246 extern oC_ErrorCode_t oC_Dhcp_ReceiveMessage ( oC_Netif_t Netif , oC_Dhcp_Message_t * outMessage , oC_Time_t Timeout );
247 extern oC_ErrorCode_t oC_Dhcp_RequestIp ( oC_Netif_t Netif , oC_Time_t Timeout );
248 extern oC_ErrorCode_t oC_Dhcp_SendDiscovery ( oC_Netif_t Netif , oC_Time_t Timeout );
249 extern oC_ErrorCode_t oC_Dhcp_ReceiveOffer ( oC_Netif_t Netif , oC_Time_t Timeout );
250 extern oC_ErrorCode_t oC_Dhcp_SendRequest ( oC_Netif_t Netif , oC_Time_t Timeout );
251 extern oC_ErrorCode_t oC_Dhcp_ReceiveAcknowledge ( oC_Netif_t Netif , oC_Time_t Timeout );
252 
253 #undef _________________________________________FUNCTIONS_SECTION__________________________________________________________________________
254 
255 
256 #endif /* SYSTEM_CORE_INC_NET_OC_DHCP_H_ */
oC_ErrorCode_t oC_Dhcp_RequestIp(oC_Netif_t Netif, oC_Time_t Timeout)
performs DHCP IP request procedure
Definition: oc_dhcp.c:232
uint32_t GIAddr
Gateway IP Address - a router IP
Definition: oc_dhcp.h:222
Minimum length in bytes for option #oC_Dhcp_Option_DnsServerMin.
Definition: oc_dhcp.h:180
oC_ErrorCode_t oC_Dhcp_ReceiveOffer(oC_Netif_t Netif, oC_Time_t Timeout)
receives offer from the DHCP server
Definition: oc_dhcp.c:423
uint8_t Options[oC_DHCP_OPTIONS_BUFFER_SIZE]
Additional options array.
Definition: oc_dhcp.h:227
The PAD value used to align word bound.
Definition: oc_dhcp.h:144
Length in bytes for option oC_Dhcp_Option_MessageType.
Definition: oc_dhcp.h:193
oC_Dhcp_Flags_t
stores flags for the DHCP message
Definition: oc_dhcp.h:125
Minimum length in bytes for option oC_Dhcp_Option_Bootfile.
Definition: oc_dhcp.h:198
Request to a server.
Definition: oc_dhcp.h:90
uint32_t YIAddr
Your IP Address - the server fills it as the proposed IP address for the client
Definition: oc_dhcp.h:220
The router option specifies a list of IP addresses on the client subnetwork.
Definition: oc_dhcp.h:148
Minimum length in bytes for option oC_Dhcp_Option_RequestedList.
Definition: oc_dhcp.h:192
The file contains definitions for the compiler, that helps to manage errors, etc. ...
uint32_t MagicCookie
Magic cookie - set to oC_DHCP_MAGIC_COOKIE (0x63825363) to identify the information as vendor indepen...
Definition: oc_dhcp.h:226
LocalNet (IBM PCNet or SYTEK LocalNET)
Definition: oc_dhcp.h:108
uint32_t Hops
Set to 0 by a client when transmitting a request and used by relay agents to control the forwarding o...
Definition: oc_dhcp.h:215
Broadcast flag - a client does not know its own IP address so it send the message as broadcast...
Definition: oc_dhcp.h:128
Used by the DHCP server to mark, that File or SName or both of these fields are overloaded to store D...
Definition: oc_dhcp.h:159
Length in bytes for option #oC_Dhcp_Option_T2RebindingTime.
Definition: oc_dhcp.h:195
Contains interface for netif object.
struct PACKED oC_Dhcp_Message_t
stores DHCP message
Length in bytes for option oC_Dhcp_Option_SubnetMask.
Definition: oc_dhcp.h:177
Used by the DHCP client to request values for specified configuration parameters. ...
Definition: oc_dhcp.h:161
uint32_t Secs
Seconds - In BOOTP this field was vaguely defined and not always used.
Definition: oc_dhcp.h:217
Address to use in client subnetwork for sending broadcast packets.
Definition: oc_dhcp.h:153
Destination IP address of DHCP server.
Definition: oc_dhcp.h:160
Default TTL value for TCP segments.
Definition: oc_dhcp.h:154
When the SName field is used for options, this field specifies name of the TFTP server.
Definition: oc_dhcp.h:166
Minimum length in bytes for option #oC_Dhcp_Option_ClientIdMin.
Definition: oc_dhcp.h:196
uint32_t Operation
Specifies type of the message.
Definition: oc_dhcp.h:212
oC_ErrorCode_t oC_Dhcp_SendDiscovery(oC_Netif_t Netif, oC_Time_t Timeout)
sends DHCP discovery message to DHCP server
Definition: oc_dhcp.c:286
Length in bytes for option oC_Dhcp_Option_RequestedIp.
Definition: oc_dhcp.h:188
oC_ErrorCode_t oC_Dhcp_SendRequest(oC_Netif_t Netif, oC_Time_t Timeout)
sends request message to the DHCP server
Definition: oc_dhcp.c:604
#define oC_DHCP_END_OPTION
Value for marking last entry in the options array.
Definition: oc_dhcp.h:61
Time interval from address assignment until the client have to renew the address. ...
Definition: oc_dhcp.h:163
uint32_t XID
Transaction ID Generated by the client to allow it to match up the request with replies received from...
Definition: oc_dhcp.h:216
Minimum length in bytes for option #oC_Dhcp_Option_HostnameMin.
Definition: oc_dhcp.h:181
uint32_t SIAddr
Server IP Address - the server fills it with its own address, that should be used for the states afte...
Definition: oc_dhcp.h:221
Asynchronous Transfer Mode (ATM)
Definition: oc_dhcp.h:111
Length in bytes for option oC_Dhcp_Option_Overload.
Definition: oc_dhcp.h:190
oC_ErrorCode_t oC_Dhcp_ReceiveAcknowledge(oC_Netif_t Netif, oC_Time_t Timeout)
receives ACK message from DHCP server
Definition: oc_dhcp.c:712
Minimum length in bytes for option #oC_Dhcp_Option_NtpMin.
Definition: oc_dhcp.h:186
Specifies MTU for the interface.
Definition: oc_dhcp.h:152
The option allows to request the specified static IP.
Definition: oc_dhcp.h:157
Specifies subnetwork mask.
Definition: oc_dhcp.h:146
char File[128]
Boot Filename - Optionally used by the client to request a particular type of boot file in a DISCOVER...
Definition: oc_dhcp.h:225
Length in bytes for option oC_Dhcp_Option_Broadcast.
Definition: oc_dhcp.h:184
Length in bytes for option oC_Dhcp_Option_DefaultTTL.
Definition: oc_dhcp.h:182
Minimum length in bytes for option #oC_Dhcp_Option_RouterMin.
Definition: oc_dhcp.h:179
The end option marks end of the options array.
Definition: oc_dhcp.h:145
uint8_t CHAddr[16]
Client Hardware Address - the hardware address of the client used for identification and communicatio...
Definition: oc_dhcp.h:223
Length in bytes for option oC_Dhcp_Option_MTU.
Definition: oc_dhcp.h:183
None flag is set.
Definition: oc_dhcp.h:127
Length in bytes for option oC_Dhcp_Option_TcpTTL.
Definition: oc_dhcp.h:185
oC_ErrorCode_t oC_Dhcp_ReceiveMessage(oC_Netif_t Netif, oC_Dhcp_Message_t *outMessage, oC_Time_t Timeout)
receives DHCP message from DHCP server
Definition: oc_dhcp.c:179
List of Network Time Protocol Servers available in the subnetwork.
Definition: oc_dhcp.h:155
char SName[64]
Server Name - The server can optionally put its name in this field
Definition: oc_dhcp.h:224
Time interval until the client transitions to the REBINDING state.
Definition: oc_dhcp.h:164
uint32_t HardwareAddressLength
Length of the hardware address in bytes.
Definition: oc_dhcp.h:214
Length in bytes for option oC_Dhcp_Option_TimeOffset.
Definition: oc_dhcp.h:178
Length in bytes for option oC_Dhcp_Option_ServerId.
Definition: oc_dhcp.h:191
Minimum length in bytes for option #oC_Dhcp_Option_TftpServerNameMin.
Definition: oc_dhcp.h:197
oC_Dhcp_Option_t
Stores DHCP options that can be added into the DHCP message.
Definition: oc_dhcp.h:142
List of DNS servers in the subnetwork.
Definition: oc_dhcp.h:149
When the File field is used for options, this field specifies a boot file name.
Definition: oc_dhcp.h:167
uint32_t HardwareType
Hardware Type - specifies type of the hardware used in the local network.
Definition: oc_dhcp.h:213
#define oC_DHCP_OPTIONS_BUFFER_SIZE
stores maximum number of bytes reserved for options in DHCP message
Definition: oc_dhcp.h:69
uint32_t CIAddr
Client IP Address - If a client has IP address and it is valid (while BOUND, RENEWING or REBINDING st...
Definition: oc_dhcp.h:219
Used by the DHCP clients to specify their unique ID.
Definition: oc_dhcp.h:165
oC_Dhcp_HardwareType_t
stores type of hardware for oC_Dhcp_Message_t type
Definition: oc_dhcp.h:102
File with interface for the NET module.
Allows the client to request a lease time for the IP address.
Definition: oc_dhcp.h:158
Used to mark type of the message - 1 for Discover, 2 - Offer, 3 - Request, 4 - Declide, 5 - Pack , 6 - Pnak, 7 - Release, 8 - Inform
Definition: oc_dhcp.h:162
oC_Dhcp_OperationCode_t
stores operation code The type is for storing operation code for field Operation in the oC_Dhcp_Messa...
Definition: oc_dhcp.h:88
Ethernet (10Mb)
Definition: oc_dhcp.h:104
Offset of the client subnetwork in seconds from Coordinated Universal Time (UTC). ...
Definition: oc_dhcp.h:147
Reply from the server.
Definition: oc_dhcp.h:91
oC_ErrorCode_t oC_Dhcp_SendMessage(oC_Netif_t Netif, oC_Dhcp_Message_t *Message, uint16_t Size, oC_Time_t Timeout)
sends DHCP message to DHCP server
Definition: oc_dhcp.c:112
Specifies default TTL value for packets.
Definition: oc_dhcp.h:151
Length in bytes for option #oC_Dhcp_Option_T1RenevalTime.
Definition: oc_dhcp.h:194
Specifies name of the client.
Definition: oc_dhcp.h:150
Length in bytes for option oC_Dhcp_Option_LeaseTime.
Definition: oc_dhcp.h:189
FILE__DESCRIPTION
uint32_t Flags
Flags of the message, look at oC_Dhcp_Flags_t type for more.
Definition: oc_dhcp.h:218
stores IPv6 address
Definition: oc_net.h:142
oC_Dhcp_OptionLength_t
stores length for options from oC_Dhcp_Option_t type
Definition: oc_dhcp.h:175