Warning, cross-references for /kernel/include/lwip/dhcp.h need to be fixed.
0001
0002
0003
0004 #ifndef __LWIP_DHCP_H__
0005 #define __LWIP_DHCP_H__
0006
0007 #include "lwip/opt.h"
0008
0009 #if LWIP_DHCP
0010
0011 #include "lwip/netif.h"
0012 #include "lwip/udp.h"
0013
0014 #ifdef __cplusplus
0015 extern "C" {
0016 #endif
0017
0018
0019 #define DHCP_COARSE_TIMER_SECS 60
0020
0021 #define DHCP_COARSE_TIMER_MSECS (DHCP_COARSE_TIMER_SECS * 1000UL)
0022
0023 #define DHCP_FINE_TIMER_MSECS 500
0024
0025 struct dhcp
0026 {
0027
0028 u32_t xid;
0029
0030 struct udp_pcb *pcb;
0031
0032 struct dhcp_msg *msg_in;
0033
0034 void *options_in;
0035
0036 u16_t options_in_len;
0037
0038 u8_t state;
0039
0040 u8_t tries;
0041
0042 struct pbuf *p_out;
0043 struct dhcp_msg *msg_out;
0044 u16_t options_out_len;
0045 u16_t request_timeout;
0046 u16_t t1_timeout;
0047 u16_t t2_timeout;
0048 struct ip_addr server_ip_addr;
0049 struct ip_addr offered_ip_addr;
0050 struct ip_addr offered_sn_mask;
0051 struct ip_addr offered_gw_addr;
0052 struct ip_addr offered_bc_addr;
0053 #define DHCP_MAX_DNS 2
0054 u32_t dns_count;
0055 struct ip_addr offered_dns_addr[DHCP_MAX_DNS];
0056
0057 u32_t offered_t0_lease;
0058 u32_t offered_t1_renew;
0059 u32_t offered_t2_rebind;
0060 #if LWIP_DHCP_AUTOIP_COOP
0061 u8_t autoip_coop_state;
0062 #endif
0063
0064
0065
0066 #if 0
0067 struct ip_addr offered_si_addr;
0068 u8_t *boot_file_name;
0069 #endif
0070 };
0071
0072
0073 #ifdef PACK_STRUCT_USE_INCLUDES
0074 # include "arch/bpstruct.h"
0075 #endif
0076 PACK_STRUCT_BEGIN
0077
0078 struct dhcp_msg
0079 {
0080 PACK_STRUCT_FIELD(u8_t op);
0081 PACK_STRUCT_FIELD(u8_t htype);
0082 PACK_STRUCT_FIELD(u8_t hlen);
0083 PACK_STRUCT_FIELD(u8_t hops);
0084 PACK_STRUCT_FIELD(u32_t xid);
0085 PACK_STRUCT_FIELD(u16_t secs);
0086 PACK_STRUCT_FIELD(u16_t flags);
0087 PACK_STRUCT_FIELD(struct ip_addr ciaddr);
0088 PACK_STRUCT_FIELD(struct ip_addr yiaddr);
0089 PACK_STRUCT_FIELD(struct ip_addr siaddr);
0090 PACK_STRUCT_FIELD(struct ip_addr giaddr);
0091 #define DHCP_CHADDR_LEN 16U
0092 PACK_STRUCT_FIELD(u8_t chaddr[DHCP_CHADDR_LEN]);
0093 #define DHCP_SNAME_LEN 64U
0094 PACK_STRUCT_FIELD(u8_t sname[DHCP_SNAME_LEN]);
0095 #define DHCP_FILE_LEN 128U
0096 PACK_STRUCT_FIELD(u8_t file[DHCP_FILE_LEN]);
0097 PACK_STRUCT_FIELD(u32_t cookie);
0098 #define DHCP_MIN_OPTIONS_LEN 68U
0099
0100 #if ((defined(DHCP_OPTIONS_LEN)) && (DHCP_OPTIONS_LEN < DHCP_MIN_OPTIONS_LEN))
0101 # undef DHCP_OPTIONS_LEN
0102 #endif
0103
0104 #if (!defined(DHCP_OPTIONS_LEN))
0105
0106 # define DHCP_OPTIONS_LEN DHCP_MIN_OPTIONS_LEN
0107 #endif
0108 PACK_STRUCT_FIELD(u8_t options[DHCP_OPTIONS_LEN]);
0109 } PACK_STRUCT_STRUCT;
0110 PACK_STRUCT_END
0111 #ifdef PACK_STRUCT_USE_INCLUDES
0112 # include "arch/epstruct.h"
0113 #endif
0114
0115
0116 err_t dhcp_start(struct netif *netif);
0117
0118 err_t dhcp_renew(struct netif *netif);
0119
0120 err_t dhcp_release(struct netif *netif);
0121
0122 void dhcp_stop(struct netif *netif);
0123
0124 void dhcp_inform(struct netif *netif);
0125
0126 void dhcp_network_changed(struct netif *netif);
0127
0128
0129 #if DHCP_DOES_ARP_CHECK
0130 void dhcp_arp_reply(struct netif *netif, struct ip_addr *addr);
0131 #endif
0132
0133
0134 void dhcp_coarse_tmr(void);
0135
0136 void dhcp_fine_tmr(void);
0137
0138
0139 #define DHCP_MSG_OFS (UDP_DATA_OFS)
0140 #define DHCP_OP_OFS (DHCP_MSG_OFS + 0)
0141 #define DHCP_HTYPE_OFS (DHCP_MSG_OFS + 1)
0142 #define DHCP_HLEN_OFS (DHCP_MSG_OFS + 2)
0143 #define DHCP_HOPS_OFS (DHCP_MSG_OFS + 3)
0144 #define DHCP_XID_OFS (DHCP_MSG_OFS + 4)
0145 #define DHCP_SECS_OFS (DHCP_MSG_OFS + 8)
0146 #define DHCP_FLAGS_OFS (DHCP_MSG_OFS + 10)
0147 #define DHCP_CIADDR_OFS (DHCP_MSG_OFS + 12)
0148 #define DHCP_YIADDR_OFS (DHCP_MSG_OFS + 16)
0149 #define DHCP_SIADDR_OFS (DHCP_MSG_OFS + 20)
0150 #define DHCP_GIADDR_OFS (DHCP_MSG_OFS + 24)
0151 #define DHCP_CHADDR_OFS (DHCP_MSG_OFS + 28)
0152 #define DHCP_SNAME_OFS (DHCP_MSG_OFS + 44)
0153 #define DHCP_FILE_OFS (DHCP_MSG_OFS + 108)
0154 #define DHCP_MSG_LEN 236
0155
0156 #define DHCP_COOKIE_OFS (DHCP_MSG_OFS + DHCP_MSG_LEN)
0157 #define DHCP_OPTIONS_OFS (DHCP_MSG_OFS + DHCP_MSG_LEN + 4)
0158
0159 #define DHCP_CLIENT_PORT 68
0160 #define DHCP_SERVER_PORT 67
0161
0162
0163 #define DHCP_REQUESTING 1
0164 #define DHCP_INIT 2
0165 #define DHCP_REBOOTING 3
0166 #define DHCP_REBINDING 4
0167 #define DHCP_RENEWING 5
0168 #define DHCP_SELECTING 6
0169 #define DHCP_INFORMING 7
0170 #define DHCP_CHECKING 8
0171 #define DHCP_PERMANENT 9
0172 #define DHCP_BOUND 10
0173
0174 #define DHCP_BACKING_OFF 12
0175 #define DHCP_OFF 13
0176
0177
0178 #define DHCP_AUTOIP_COOP_STATE_OFF 0
0179 #define DHCP_AUTOIP_COOP_STATE_ON 1
0180
0181 #define DHCP_BOOTREQUEST 1
0182 #define DHCP_BOOTREPLY 2
0183
0184 #define DHCP_DISCOVER 1
0185 #define DHCP_OFFER 2
0186 #define DHCP_REQUEST 3
0187 #define DHCP_DECLINE 4
0188 #define DHCP_ACK 5
0189 #define DHCP_NAK 6
0190 #define DHCP_RELEASE 7
0191 #define DHCP_INFORM 8
0192
0193 #define DHCP_HTYPE_ETH 1
0194
0195 #define DHCP_HLEN_ETH 6
0196
0197 #define DHCP_BROADCAST_FLAG 15
0198 #define DHCP_BROADCAST_MASK (1 << DHCP_FLAG_BROADCAST)
0199
0200
0201 #define DHCP_OPTION_PAD 0
0202 #define DHCP_OPTION_SUBNET_MASK 1
0203 #define DHCP_OPTION_ROUTER 3
0204 #define DHCP_OPTION_DNS_SERVER 6
0205 #define DHCP_OPTION_HOSTNAME 12
0206 #define DHCP_OPTION_IP_TTL 23
0207 #define DHCP_OPTION_MTU 26
0208 #define DHCP_OPTION_BROADCAST 28
0209 #define DHCP_OPTION_TCP_TTL 37
0210 #define DHCP_OPTION_END 255
0211
0212
0213 #define DHCP_OPTION_REQUESTED_IP 50
0214 #define DHCP_OPTION_LEASE_TIME 51
0215 #define DHCP_OPTION_OVERLOAD 52
0216
0217 #define DHCP_OPTION_MESSAGE_TYPE 53
0218 #define DHCP_OPTION_MESSAGE_TYPE_LEN 1
0219
0220
0221 #define DHCP_OPTION_SERVER_ID 54
0222 #define DHCP_OPTION_PARAMETER_REQUEST_LIST 55
0223
0224 #define DHCP_OPTION_MAX_MSG_SIZE 57
0225 #define DHCP_OPTION_MAX_MSG_SIZE_LEN 2
0226
0227 #define DHCP_OPTION_T1 58
0228 #define DHCP_OPTION_T2 59
0229 #define DHCP_OPTION_US 60
0230 #define DHCP_OPTION_CLIENT_ID 61
0231 #define DHCP_OPTION_TFTP_SERVERNAME 66
0232 #define DHCP_OPTION_BOOTFILE 67
0233
0234
0235 #define DHCP_OVERLOAD_NONE 0
0236 #define DHCP_OVERLOAD_FILE 1
0237 #define DHCP_OVERLOAD_SNAME 2
0238 #define DHCP_OVERLOAD_SNAME_FILE 3
0239
0240 #ifdef __cplusplus
0241 }
0242 #endif
0243
0244 #endif
0245
0246 #endif