2 * Copyright (c) 2015 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 * client.h: dhcp client
19 #ifndef included_dhcp_client_h
20 #define included_dhcp_client_h
22 #include <vnet/ip/ip.h>
23 #include <vnet/dhcp/dhcp4_packet.h>
25 #define foreach_dhcp_client_state \
33 foreach_dhcp_client_state
35 } dhcp_client_state_t;
37 struct dhcp_client_t_;
40 * Callback function for DHCP complete events
42 typedef void (*dhcp_event_cb_t) (u32 client_index,
43 const struct dhcp_client_t_ * client);
45 typedef struct dhcp_client_t_
47 dhcp_client_state_t state;
49 /* the interface in question */
52 /* State machine retry counter */
55 /* Send next pkt at this time */
59 /* DHCP transaction ID, a random number */
62 /* leased address, other learned info DHCP */
63 ip4_address_t leased_address; /* from your_ip_address field */
64 ip4_address_t dhcp_server;
65 u32 subnet_mask_width; /* option 1 */
66 ip4_address_t router_address; /* option 3 */
67 u32 lease_renewal_interval; /* option 51 */
68 u32 lease_lifetime; /* option 59 */
70 /* Requested data (option 55) */
75 /* hostname and software client identifiers */
77 u8 *client_identifier; /* software version, e.g. vpe 1.0 */
79 /* Information used for event callback */
83 /* Set the broadcast Flag in the Discover/Request messages */
84 u8 set_broadcast_flag;
85 /* Interface MAC address, so we can do an rx-packet-for-us check */
86 u8 client_hardware_address[6];
87 u8 client_detect_feature_enabled;
89 dhcp_event_cb_t event_callback;
94 /* DHCP client pool */
95 dhcp_client_t *clients;
96 uword *client_by_sw_if_index;
100 vlib_main_t *vlib_main;
101 vnet_main_t *vnet_main;
102 } dhcp_client_main_t;
108 u8 set_broadcast_flag;
110 /* vectors, consumed by dhcp client code */
112 u8 *client_identifier;
114 /* Bytes containing requested option numbers */
117 /* Information used for event callback */
120 dhcp_event_cb_t event_callback;
121 } dhcp_client_add_del_args_t;
123 extern dhcp_client_main_t dhcp_client_main;
125 #define EVENT_DHCP_CLIENT_WAKEUP 1
127 int dhcp_client_for_us (u32 bi0,
130 udp_header_t * u0, dhcp_header_t * dh0);
133 * Add/Delete DHCP clients
135 extern int dhcp_client_config (u32 is_add,
141 dhcp_event_cb_t event_callback,
142 u8 set_broadcast_flag, u32 pid);
145 * callback function for clients walking the DHCP client configurations
147 * @param client The client being visitsed
148 * @param data The data passed during the call to 'walk'
149 * @return !0 to continue walking 0 to stop.
151 typedef int (*dhcp_client_walk_cb_t) (const dhcp_client_t * client,
155 * Walk (visit each) DHCP client configuration
157 * @param cb The callback function invoked as each client is visited
158 * @param ctx Context data passed back to the client in the invocation of
161 extern void dhcp_client_walk (dhcp_client_walk_cb_t cb, void *ctx);
163 #endif /* included_dhcp_client_h */
166 * fd.io coding-style-patch-verification: ON
169 * eval: (c-set-style "gnu")