FD.io VPP  v21.06-3-gbb25fbf28
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 <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 */
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,
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  */
dhcp_client_add_del_args_t::client_identifier
u8 * client_identifier
Definition: client.h:142
dhcp_client_t_::option_55_data
u8 * option_55_data
Definition: client.h:95
dhcp_client_add_del_args_t::set_broadcast_flag
u8 set_broadcast_flag
Definition: client.h:138
dhcp_client_t_::ai_bcast
adj_index_t ai_bcast
Definition: client.h:112
dhcp_client_t_::event_callback
dhcp_event_cb_t event_callback
Definition: client.h:116
ip_dscp_t
enum ip_dscp_t_ ip_dscp_t
dhcp_client_t_::client_detect_feature_enabled
u8 client_detect_feature_enabled
Definition: client.h:109
dhcp_client_t_::lease_renewal_interval
u32 lease_renewal_interval
Definition: client.h:91
dhcp_client_t_::pid
u32 pid
Definition: client.h:103
dhcp_client_t_::client_index
u32 client_index
Definition: client.h:102
dhcp_client_t
struct dhcp_client_t_ dhcp_client_t
dhcp_client_main_t::client_by_sw_if_index
uword * client_by_sw_if_index
Definition: client.h:123
dhcp4_packet.h
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
dhcp_client_fwd_addresses_t
struct dhcp_client_fwd_addresses_t_ dhcp_client_fwd_addresses_t
The set of addresses/mask that contribute forwarding info and are installed.
dhcp_client_t_::next_transmit
f64 next_transmit
Definition: client.h:74
dhcp_client_state_t
dhcp_client_state_t
Definition: client.h:30
udp_header_t
Definition: udp_packet.h:45
ip4_header_t
Definition: ip4_packet.h:87
dhcp_client_t_::installed
dhcp_client_fwd_addresses_t installed
Definition: client.h:86
dhcp_client_walk
void dhcp_client_walk(dhcp_client_walk_cb_t cb, void *ctx)
Walk (visit each) DHCP client configuration.
Definition: client.c:1116
foreach_dhcp_client_state
#define foreach_dhcp_client_state
Definition: client.h:25
dhcp_client_add_del_args_t::client_index
u32 client_index
Definition: client.h:148
pid
u32 pid
Definition: dhcp.api:164
dhcp_client_add_del_args_t::option_55_data
u8 * option_55_data
Definition: client.h:145
hostname
string hostname[64]
Definition: dhcp.api:159
dhcp_client_main_t::vnet_main
vnet_main_t * vnet_main
Definition: client.h:131
dhcp_client_add_del_args_t::is_add
int is_add
Definition: client.h:136
dhcp_client_add_del_args_t::hostname
u8 * hostname
Definition: client.h:141
dhcp_client_t_::domain_server_address
ip4_address_t * domain_server_address
Definition: client.h:90
dhcp_client_t_::hostname
u8 * hostname
Definition: client.h:98
dhcp_client_add_del_args_t::event_callback
dhcp_event_cb_t event_callback
Definition: client.h:151
dhcp_client_for_us
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:276
dhcp_client_t_::retry_count
u32 retry_count
Definition: client.h:71
uword
u64 uword
Definition: types.h:112
dhcp_client_add_del_args_t
Definition: client.h:134
dhcp_event_cb_t
void(* dhcp_event_cb_t)(u32 client_index, const struct dhcp_client_t_ *client)
Callback function for DHCP complete events.
Definition: client.h:42
dhcp_client_t_::lease_lifetime
u32 lease_lifetime
Definition: client.h:92
dhcp_client_t_::transaction_id
u32 transaction_id
Definition: client.h:78
f64
double f64
Definition: types.h:142
dhcp_client_t_::client_identifier
u8 * client_identifier
Definition: client.h:99
dhcp_client_t_::learned
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
ip4_address_t
Definition: ip4_packet.h:50
dhcp_client_t_::lease_expires
f64 lease_expires
Definition: client.h:75
dhcp_client_t_::state
dhcp_client_state_t state
Definition: client.h:65
dhcp_client_fwd_addresses_t_::dhcp_server
ip4_address_t dhcp_server
the address of the DHCP server handing out the address.
Definition: client.h:57
data
u8 data[128]
Definition: ipsec_types.api:92
dhcp_client_config
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:1031
vnet_main_t
Definition: vnet.h:76
dhcp_client_t_::addresses_installed
u8 addresses_installed
Definition: client.h:88
dhcp_client_main
dhcp_client_main_t dhcp_client_main
Definition: client.c:24
dhcp_client_t_::dscp
ip_dscp_t dscp
Definition: client.h:114
dhcp_client_t_::client_hardware_address
u8 client_hardware_address[6]
Definition: client.h:108
ip.h
u32
unsigned int u32
Definition: types.h:88
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
dhcp_client_main_t::clients
dhcp_client_t * clients
Definition: client.h:122
dhcp_client_fwd_addresses_t_::router_address
ip4_address_t router_address
The address of this client's default gateway - may not be present.
Definition: client.h:60
dhcp_client_fwd_addresses_t_::leased_address
ip4_address_t leased_address
the address assigned to this client and it's mask
Definition: client.h:52
dhcp_client_fwd_addresses_t_::subnet_mask_width
u32 subnet_mask_width
Definition: client.h:53
dhcp_client_walk_cb_t
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
dhcp_client_add_del_args_t::pid
u32 pid
Definition: client.h:149
dhcp_header_t
Definition: dhcp4_packet.h:33
dhcp_client_add_del_args_t::sw_if_index
u32 sw_if_index
Definition: client.h:137
adj_index_t
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
dhcp_client_main_t::vlib_main
vlib_main_t * vlib_main
Definition: client.h:130
vlib_main_t
Definition: main.h:102
dhcp_client_add_del_args_t::dscp
ip_dscp_t dscp
Definition: client.h:150
dhcp_client_t_::sw_if_index
u32 sw_if_index
Definition: client.h:68
dhcp_client_main_t
Definition: client.h:119
u8
unsigned char u8
Definition: types.h:56
dhcp_client_main_t::ip4_lookup_node_index
u32 ip4_lookup_node_index
Definition: client.h:127
set_broadcast_flag
bool set_broadcast_flag
Definition: dhcp.api:162
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
dhcp_client_t_::set_broadcast_flag
u8 set_broadcast_flag
Definition: client.h:106
dscp
vl_api_ip_dscp_t dscp
Definition: dhcp.api:163
dhcp_client_main_t::seed
u32 seed
Definition: client.h:124
dhcp_client_t_
Definition: client.h:63
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
dhcp_client_fwd_addresses_t_
The set of addresses/mask that contribute forwarding info and are installed.
Definition: client.h:49