FD.io VPP  v19.08.3-2-gbabecb413
Vector Packet Processing
client.h
Go to the documentation of this file.
1 /*
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:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15 /*
16  * client.h: dhcp client
17  */
18 
19 #ifndef included_dhcp_client_h
20 #define included_dhcp_client_h
21 
22 #include <vnet/ip/ip.h>
23 #include <vnet/dhcp/dhcp4_packet.h>
24 
25 #define foreach_dhcp_client_state \
26 _(DHCP_DISCOVER) \
27 _(DHCP_REQUEST) \
28 _(DHCP_BOUND)
29 
30 typedef enum
31 {
32 #define _(a) a,
34 #undef _
36 
37 struct dhcp_client_t_;
38 
39 /**
40  * Callback function for DHCP complete events
41  */
42 typedef void (*dhcp_event_cb_t) (u32 client_index,
43  const struct dhcp_client_t_ * client);
44 
45 /**
46  * The set of addresses/mask that contribute forwarding info
47  * and are installed.
48  */
50 {
51  /** the address assigned to this client and it's mask */
54 
55  /** the address of the DHCP server handing out the address.
56  this is used to send any unicast messages */
58 
59  /** The address of this client's default gateway - may not be present */
62 
63 typedef struct dhcp_client_t_
64 {
66 
67  /* the interface in question */
69 
70  /* State machine retry counter */
72 
73  /* Send next pkt at this time */
76 
77  /* DHCP transaction ID, a random number */
79 
80  /**
81  * leased address, other learned info DHCP
82  * the learned set is updated by new messages recieved in the DP
83  * the installed set is what's actually been added
84  */
87  /* have local Addresses and default route been installed */
89 
91  u32 lease_renewal_interval; /* option 51 */
92  u32 lease_lifetime; /* option 59 */
93 
94  /* Requested data (option 55) */
96 
97  /* hostname and software client identifiers */
99  u8 *client_identifier; /* software version, e.g. vpe 1.0 */
100 
101  /* Information used for event callback */
104 
105  /* Set the broadcast Flag in the Discover/Request messages */
107  /* Interface MAC address, so we can do an rx-packet-for-us check */
108  u8 client_hardware_address[6];
110 
111  /* the broadcast adjacency on the link */
113  /* IP DSCP to set in sent packets */
115 
117 } dhcp_client_t;
118 
119 typedef struct
120 {
121  /* DHCP client pool */
125 
126  /* ip4-lookup node index */
128 
129  /* convenience */
133 
134 typedef struct
135 {
136  int is_add;
139 
140  /* vectors, consumed by dhcp client code */
143 
144  /* Bytes containing requested option numbers */
146 
147  /* Information used for event callback */
153 
155 
156 #define EVENT_DHCP_CLIENT_WAKEUP 1
157 
158 int dhcp_client_for_us (u32 bi0,
159  vlib_buffer_t * b0,
160  ip4_header_t * ip0,
161  udp_header_t * u0, dhcp_header_t * dh0);
162 
163 /**
164  * Add/Delete DHCP clients
165  */
166 extern int dhcp_client_config (u32 is_add,
167  u32 client_index,
168  vlib_main_t * vm,
170  u8 * hostname,
171  u8 * client_id,
172  dhcp_event_cb_t event_callback,
173  u8 set_broadcast_flag,
174  ip_dscp_t dscp, u32 pid);
175 
176 /**
177  * callback function for clients walking the DHCP client configurations
178  *
179  * @param client The client being visitsed
180  * @param data The data passed during the call to 'walk'
181  * @return !0 to continue walking 0 to stop.
182  */
183 typedef int (*dhcp_client_walk_cb_t) (const dhcp_client_t * client,
184  void *data);
185 
186 /**
187  * Walk (visit each) DHCP client configuration
188  *
189  * @param cb The callback function invoked as each client is visited
190  * @param ctx Context data passed back to the client in the invocation of
191  * the callback.
192  */
193 extern void dhcp_client_walk (dhcp_client_walk_cb_t cb, void *ctx);
194 
195 #endif /* included_dhcp_client_h */
196 
197 /*
198  * fd.io coding-style-patch-verification: ON
199  *
200  * Local Variables:
201  * eval: (c-set-style "gnu")
202  * End:
203  */
u8 client_detect_feature_enabled
Definition: client.h:109
dhcp_client_main_t dhcp_client_main
Definition: client.c:24
struct dhcp_client_fwd_addresses_t_ dhcp_client_fwd_addresses_t
The set of addresses/mask that contribute forwarding info and are installed.
ip4_address_t router_address
The address of this client&#39;s default gateway - may not be present.
Definition: client.h:60
u32 retry_count
Definition: client.h:71
u32 lease_lifetime
Definition: client.h:92
ip_dscp_t dscp
Definition: client.h:114
u8 * option_55_data
Definition: client.h:95
dhcp_client_t * clients
Definition: client.h:122
u32 sw_if_index
Definition: client.h:68
u8 data[128]
Definition: ipsec.api:251
dhcp_client_fwd_addresses_t installed
Definition: client.h:86
dhcp_event_cb_t event_callback
Definition: client.h:151
dhcp_client_state_t state
Definition: client.h:65
unsigned char u8
Definition: types.h:56
u32 transaction_id
Definition: client.h:78
ip4_address_t dhcp_server
the address of the DHCP server handing out the address.
Definition: client.h:57
double f64
Definition: types.h:142
u32 lease_renewal_interval
Definition: client.h:91
u32 ip4_lookup_node_index
Definition: client.h:127
vl_api_interface_index_t sw_if_index
Definition: gre.api:50
dhcp_event_cb_t event_callback
Definition: client.h:116
adj_index_t ai_bcast
Definition: client.h:112
unsigned int u32
Definition: types.h:88
#define foreach_dhcp_client_state
Definition: client.h:25
u8 set_broadcast_flag
Definition: client.h:106
dhcp_client_state_t
Definition: client.h:30
struct dhcp_client_t_ dhcp_client_t
vlib_main_t * vlib_main
Definition: client.h:130
int dhcp_client_for_us(u32 bi0, vlib_buffer_t *b0, ip4_header_t *ip0, udp_header_t *u0, dhcp_header_t *dh0)
Definition: client.c:274
long ctx[MAX_CONNS]
Definition: main.c:144
ip4_address_t leased_address
the address assigned to this client and it&#39;s mask
Definition: client.h:52
void(* dhcp_event_cb_t)(u32 client_index, const struct dhcp_client_t_ *client)
Callback function for DHCP complete events.
Definition: client.h:42
vlib_main_t * vm
Definition: buffer.c:323
f64 next_transmit
Definition: client.h:74
ip4_address_t * domain_server_address
Definition: client.h:90
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
u32 client_index
Definition: client.h:102
void dhcp_client_walk(dhcp_client_walk_cb_t cb, void *ctx)
Walk (visit each) DHCP client configuration.
Definition: client.c:1111
The set of addresses/mask that contribute forwarding info and are installed.
Definition: client.h:49
enum ip_dscp_t_ ip_dscp_t
int dhcp_client_config(u32 is_add, u32 client_index, vlib_main_t *vm, u32 sw_if_index, u8 *hostname, u8 *client_id, dhcp_event_cb_t event_callback, u8 set_broadcast_flag, ip_dscp_t dscp, u32 pid)
Add/Delete DHCP clients.
Definition: client.c:1026
u8 * client_identifier
Definition: client.h:99
int(* dhcp_client_walk_cb_t)(const dhcp_client_t *client, void *data)
callback function for clients walking the DHCP client configurations
Definition: client.h:183
VLIB buffer representation.
Definition: buffer.h:102
u64 uword
Definition: types.h:112
uword * client_by_sw_if_index
Definition: client.h:123
u8 * hostname
Definition: client.h:98
f64 lease_expires
Definition: client.h:75
vnet_main_t * vnet_main
Definition: client.h:131
dhcp_client_fwd_addresses_t learned
leased address, other learned info DHCP the learned set is updated by new messages recieved in the DP...
Definition: client.h:85
u8 addresses_installed
Definition: client.h:88