Open Ethernet Networking (OpEN) API Guide and Reference Manual  3.6.0.3
openapi_dhcp_client.h
Go to the documentation of this file.
1 
9 /*********************************************************************
10 *
11 * Copyright 2016-2018 Broadcom.
12 *
13 * Licensed under the Apache License, Version 2.0 (the "License");
14 * you may not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
16 *
17 * http://www.apache.org/licenses/LICENSE-2.0
18 *
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS,
21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
24 *
25 **********************************************************************
26 *
27 * @filename openapi_dhcp_client.h
28 *
29 * @purpose DHCP Client configuration and Status
30 *
31 * @component OpEN
32 *
33 * @create 10/30/2015
34 *
35 * @end
36 *
37 **********************************************************************/
38 #ifndef OPENAPI_DHCP_CLIENT_H_INCLUDED
39 #define OPENAPI_DHCP_CLIENT_H_INCLUDED
40 
41 #include "openapi_common.h"
42 #include "openapi_dns.h"
43 #include "openapi_sntp.h"
44 
45 #define OPEN_DHCP_VENDOR_SPECIFIC_SUBOPTIONS_NUM 3
46 #define OPEN_DHCP_BOOTP_VEND_OPTIONS_LEN 64
47 #define OPEN_DHCP_OPT125_VENDOR_NUMBER_MAX 3
48 
49 #define OPEN_HOSTNAME_MAX_LEN 64
50 #define OPEN_BOOTP_FILE_LEN 128
51 #define OPEN_BOOTP_SNAME_LEN 64
52 #define OPEN_DNS_NAME_SERVER_ENTRIES 8
53 #define OPEN_SNTP_MAX_SERVER_ENTRIES 12
54 #define OPENAPI_DNS_HOST_NAME_LEN_MAX 255
55 
56 typedef struct
57 {
58  unsigned char type;
59  unsigned char len;
60  unsigned char option[OPEN_DHCP_BOOTP_VEND_OPTIONS_LEN];
62 
63 typedef struct
64 {
65  unsigned char numSubOptions;
66  open_tlv_option_t subOptions[OPEN_DHCP_VENDOR_SPECIFIC_SUBOPTIONS_NUM];
68 
69 typedef struct
70 {
71  uint32_t vendorID;
72  unsigned char numSubOptions;
73  open_tlv_option_t subOptions[OPEN_DHCP_VENDOR_SPECIFIC_SUBOPTIONS_NUM];
75 
76 typedef struct
77 {
78  open_dhcp_vendor_sub_opt_t vendor[OPEN_DHCP_OPT125_VENDOR_NUMBER_MAX];
80 
81 typedef enum
82 {
83  OPEN_BOOTP_DHCP_IP_ADDR = 1,
84  OPEN_BOOTP_DHCP_NETMASK = 2,
85  OPEN_BOOTP_DHCP_GATEWAY = 4,
86  OPEN_BOOTP_DHCP_SIADDR = 8,
87  OPEN_BOOTP_DHCP_BOOTFILE = 16,
88  OPEN_BOOTP_DHCP_SNAME = 32,
89  OPEN_BOOTP_DHCP_OPTION_TFTP_SVR_ADDR = 64,
90  OPEN_BOOTP_DHCP_OPTION_DNS_SVR_ADDR = 128,
91  OPEN_BOOTP_DHCP_OPTION_BOOTFILE = 256,
92  OPEN_BOOTP_DHCP_OPTION_TFTP_SVR_NAME = 512,
93  OPEN_BOOTP_DHCP_OPTION_VENDOR_SPECIFIC = 1024,
94  OPEN_BOOTP_DHCP_OPTION_VENDOR_IDENT = 2048,
95  OPEN_BOOTP_DHCP_OPTION_HOSTNAME = 4096,
96  OPEN_BOOTP_DHCP_OPTION_DEF_DOMAIN_NAME = 8192,
97  OPEN_BOOTP_DHCP_OPTION_NTP_SVR_ADDR = 16384,
98  OPEN_BOOTP_DHCP_OPTION_SYSLOG_SVR_ADDR = 32768
99 } open_bootp_dhcp_offered_options_e;
100 
101 typedef struct
102 {
103  uint32_t ip; /* Host ip address */
104  uint32_t netMask; /* Host netmask */
105  uint32_t gateway; /* Gateway */
106  uint32_t siaddr; /* Next server address */
107  uint32_t optTftpSvrIpAddr; /* IP addres of TFTP server, got from option 150 field */
108  uint32_t optDnsServerIpAddr[OPEN_DNS_NAME_SERVER_ENTRIES]; /* IP addres of DNS server, got from option 6 field */
109  unsigned char optDefDomainName[OPENAPI_DNS_HOST_NAME_LEN_MAX + 1]; /* Domain name, got from option 15 field */
110  unsigned char optHostName[OPEN_HOSTNAME_MAX_LEN + 1]; /* hostname name, got from option 12 field */
111  uint32_t optNtpServerIpAddr[OPEN_SNTP_MAX_SERVER_ENTRIES]; /* IP addres of NTP server, got from option 42 field */
112  unsigned char bootFile[OPEN_BOOTP_FILE_LEN + 1]; /* Bootfile name */
113  unsigned char optBootFile[OPEN_BOOTP_FILE_LEN + 1]; /* Bootfile name, got from option 67 field */
114  unsigned char sname[OPEN_BOOTP_SNAME_LEN + 1]; /* Server name */
115  unsigned char optTftpSvrName[OPEN_BOOTP_SNAME_LEN + 1]; /* TFTP server name, got from option 66 field */
116  open_dhcp_vendor_specific_option_t *vendSpecificOptions; /* DHCP Option-43.*/
117  uint32_t offeredOptionsMask; /* Mask holds offered options IDs. Set mask using OR operation
118  with flags defined in open_bootp_dhcp_offered_options_e */
119  open_dhcp_option125_t opt125; /* Opt 125. Vendor Identified option.*/
120  OPEN_BOOL_t dhcpAddressFlushFlag;
122 
123 /*****************************************************************/
140  uint32_t intIfNum,
141  open_inet_addr_t *clientAddr);
142 
143 /*****************************************************************/
160  uint32_t intIfNum,
161  open_inet_addr_t *netmask);
162 
163 /*****************************************************************/
180  uint32_t intIfNum,
181  open_inet_addr_t *serverAddr);
182 
183 /*****************************************************************/
202  open_bootp_dhcp_t *networkParams);
203 #endif /* OPENAPI_DHCP_CLIENT_H_INCLUDED */
204 
open_error_t openapiDhcpClientIPAddrGet(openapiClientHandle_t *client_handle, uint32_t intIfNum, open_inet_addr_t *clientAddr)
Get the DHCP Client IP Address on an interface.
#define OPEN_SNTP_MAX_SERVER_ENTRIES
maximum value
open_error_t openapiDhcpClientOptionsGet(openapiClientHandle_t *client_handle, open_bootp_dhcp_t *networkParams)
Get the DHCP Options returned by the DHCP Server.
open_error_t
OPEN uses these enumerators to indicate the error codes.
#define OPENAPI_DNS_HOST_NAME_LEN_MAX
maximum value
#define OPEN_DNS_NAME_SERVER_ENTRIES
maximum value
open_error_t openapiDhcpClientDhcpServerIPAddrGet(openapiClientHandle_t *client_handle, uint32_t intIfNum, open_inet_addr_t *serverAddr)
Get the DHCP Server IP Address on an interface.
OPEN_BOOL_t
OPEN uses these enumerators to indicate true or false for a given config or status parameter...
open_error_t openapiDhcpClientNetMaskGet(openapiClientHandle_t *client_handle, uint32_t intIfNum, open_inet_addr_t *netmask)
Get the DHCP Client subnet mask on an interface.