mikroSDK Reference Manual
dhcp_server.h
Go to the documentation of this file.
1
31#ifndef _DHCP_SERVER_H
32#define _DHCP_SERVER_H
33
34//Dependencies
35#include "core/net.h"
36
37//DHCP server support
38#ifndef DHCP_SERVER_SUPPORT
39 #define DHCP_SERVER_SUPPORT DISABLED
40#elif (DHCP_SERVER_SUPPORT != ENABLED && DHCP_SERVER_SUPPORT != DISABLED)
41 #error DHCP_SERVER_SUPPORT parameter is not valid
42#endif
43
44//DHCP server tick interval
45#ifndef DHCP_SERVER_TICK_INTERVAL
46 #define DHCP_SERVER_TICK_INTERVAL 1000
47#elif (DHCP_SERVER_TICK_INTERVAL < 10)
48 #error DHCP_SERVER_TICK_INTERVAL parameter is not valid
49#endif
50
51//Maximum number of clients
52#ifndef DHCP_SERVER_MAX_CLIENTS
53 #define DHCP_SERVER_MAX_CLIENTS 16
54#elif (DHCP_SERVER_MAX_CLIENTS < 1)
55 #error DHCP_SERVER_MAX_CLIENTS parameter is not valid
56#endif
57
58//Default lease time, in seconds
59#ifndef DHCP_SERVER_DEFAULT_LEASE_TIME
60 #define DHCP_SERVER_DEFAULT_LEASE_TIME 86400
61#elif (DHCP_SERVER_DEFAULT_LEASE_TIME < 1)
62 #error DHCP_SERVER_DEFAULT_LEASE_TIME parameter is not valid
63#endif
64
65//Maximum number of DNS servers
66#ifndef DHCP_SERVER_MAX_DNS_SERVERS
67 #define DHCP_SERVER_MAX_DNS_SERVERS 2
68#elif (DHCP_SERVER_MAX_DNS_SERVERS < 1)
69 #error DHCP_SERVER_MAX_DNS_SERVERS parameter is not valid
70#endif
71
72//Application specific context
73#ifndef DHCP_SERVER_PRIVATE_CONTEXT
74 #define DHCP_SERVER_PRIVATE_CONTEXT
75#endif
76
77//Forward declaration of DhcpServerContext structure
79#define DhcpServerContext struct _DhcpServerContext
80
81//C++ guard
82#ifdef __cplusplus
83extern "C" {
84#endif
85
86
91typedef void (*DhcpServerAddOptionsCallback)(DhcpServerContext *context,
92 DhcpMessage *message, size_t *length, DhcpMessageType type);
93
94
99typedef error_t (*DhcpServerParseOptionsCallback)(DhcpServerContext *context,
100 const DhcpMessage *message, size_t length, DhcpMessageType type);
101
102
118
119
138
139
145{
147 bool_t running;
149 DhcpServerBinding clientBinding[DHCP_SERVER_MAX_CLIENTS];
150 DHCP_SERVER_PRIVATE_CONTEXT
151};
152
153
154//DHCP server related functions
155void dhcpServerGetDefaultSettings(DhcpServerSettings *settings);
156
157error_t dhcpServerInit(DhcpServerContext *context,
158 const DhcpServerSettings *settings);
159
160error_t dhcpServerStart(DhcpServerContext *context);
161error_t dhcpServerStop(DhcpServerContext *context);
162
163void dhcpServerDeinit(DhcpServerContext *context);
164
165//C++ guard
166#ifdef __cplusplus
167}
168#endif
169
170#endif
DhcpMessageType
DHCP message types.
Definition dhcp_common.h:88
error_t(* DhcpServerParseOptionsCallback)(DhcpServerContext *context, const DhcpMessage *message, size_t length, DhcpMessageType type)
Parse DHCP options callback.
Definition dhcp_server.h:99
void(* DhcpServerAddOptionsCallback)(DhcpServerContext *context, DhcpMessage *message, size_t *length, DhcpMessageType type)
Add DHCP options callback.
Definition dhcp_server.h:91
error_t
Error codes.
Definition error.h:43
uint32_t Ipv4Addr
IPv4 network address.
Definition ipv4.h:267
TCP/IP stack core.
uint32_t systime_t
System time.
Definition os_port_none.h:90
DHCP binding.
Definition dhcp_server.h:112
MacAddr macAddr
Client's MAC address.
Definition dhcp_server.h:113
Ipv4Addr ipAddr
Client's IPv4 address.
Definition dhcp_server.h:114
bool_t validLease
Valid lease.
Definition dhcp_server.h:115
systime_t timestamp
Timestamp.
Definition dhcp_server.h:116
DHCP server settings.
Definition dhcp_server.h:125
NetInterface * interface
Underlying network interface.
Definition dhcp_server.h:126
bool_t rapidCommit
Quick configuration using rapid commit.
Definition dhcp_server.h:128
DhcpServerAddOptionsCallback addOptionsCallback
Add DHCP options callback.
Definition dhcp_server.h:135
DhcpServerParseOptionsCallback parseOptionsCallback
Parse DHCP options callback.
Definition dhcp_server.h:136
uint_t ipAddrIndex
Index of the IP address assigned to the DHCP server.
Definition dhcp_server.h:127
uint32_t leaseTime
Lease time, in seconds, assigned to the DHCP clients.
Definition dhcp_server.h:129
Ipv4Addr ipAddrRangeMin
Lowest IP address in the pool that is available for dynamic address assignment.
Definition dhcp_server.h:130
Ipv4Addr ipAddrRangeMax
Highest IP address in the pool that is available for dynamic address assignment.
Definition dhcp_server.h:131
Ipv4Addr defaultGateway
Default gateway.
Definition dhcp_server.h:133
Ipv4Addr subnetMask
Subnet mask.
Definition dhcp_server.h:132
DHCP server context.
Definition dhcp_server.h:145
DhcpServerBinding clientBinding[DHCP_SERVER_MAX_CLIENTS]
List of bindings.
Definition dhcp_server.h:149
bool_t running
This flag tells whether the DHCP server is running or not.
Definition dhcp_server.h:147
DhcpServerSettings settings
DHCP server settings.
Definition dhcp_server.h:146
Ipv4Addr nextIpAddr
Next IP address to be assigned.
Definition dhcp_server.h:148