Open Ethernet Networking (OpEN) API Guide and Reference Manual  3.9.0.2
openapi_common.h
Go to the documentation of this file.
1 
9 /*********************************************************************
10 *
11 * Copyright 2016-2019 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_common.h
28 *
29 * @purpose Base Services.
30 *
31 * @component OpEN
32 *
33 * @create 07/13/2012
34 *
35 * @end
36 *
37 **********************************************************************/
38 #ifndef _OPENAPI_COMMON_H_
39 #define _OPENAPI_COMMON_H_
40 
41 #include <stdint.h>
42 #include <arpa/inet.h>
43 #include <netinet/in.h>
44 
45 /* Some structures need to be packed on platforms that use
46 ** 64 bit OpEN API libraries and 32 bit network operating system.
47 */
48 #if defined (__i386__) || defined (__x86_64__)
49  #define OPEN_PACKED_STRUCT typedef struct __attribute__((__packed__))
50 #else
51  #define OPEN_PACKED_STRUCT typedef struct
52 #endif
53 
54 
55 /*
56  * OPEN API error codes.
57  *
58  * Note: Values used in this enum for non-zero entries must
59  * be different than those used in L7_RPCCLT_RC_t.
60  * OPEN API calls via RPC may return error code values
61  * from L7_RPCCLT_RC_t in certain situations.
62  */
64 typedef enum
65 {
67  OPEN_E_RPC = -20,
69  OPEN_E_PARAM = -22,
70  OPEN_E_FULL = -23,
71  OPEN_E_EXISTS = -24,
73  OPEN_E_FAIL = -26,
77  OPEN_E_EMPTY = -30,
78  OPEN_E_ERROR = -31
79 } open_error_t;
80 
82 typedef enum
83 {
84  OPEN_EVENT_INTERFACE = 0, /* This first event must be 0 */
85  OPEN_EVENT_VLAN = 1,
86  OPEN_EVENT_ROUTE = 2,
87  OPEN_EVENT_ROUTING_INTERFACE = 3,
88  OPEN_EVENT_ISSU_START = 4,
89  OPEN_EVENT_READY_STATE = 5, /* Configurator transition to/from execute state */
90  OPEN_EVENT_CONFIG = 6,
91  OPEN_EVENT_LAST /* Must be last. Can be incremented as needed */
92 } OPEN_EVENT_e;
93 
94 typedef struct
95 {
96  unsigned char open_event_mask [((OPEN_EVENT_LAST) / 8) + 1];
98 
99 /* OpEN registration service identifiers supported for
100  * external OpEN API clients.
101  *
102  * Internal clients have their own set of identifiers
103  * (unpublished) that are not included here, hence the
104  * use of #define instead of an enumeration.
105  *
106  * NOTE: Defining values that are not likely to get
107  * confused with the actual service ID values.
108  * All values listed here get converted to their
109  * real server ID values by the API implementation.
110  */
111 #define OPEN_REGISTRATION_SERVICE_USERAPPS 100001 /* all user-provided applications */
112 
113 /* First instance number for a given RPC client (by convention).
114  *
115  * Note: Mirrors L7_RPCCLT_INSTANCE_FIRST definition.
116  */
117 #define OPEN_CLIENT_INSTANCE_FIRST 1
118 
120 typedef enum
121 {
125 
126 /* OpEN client handle struct. Only use provided accessor functions to
127  * retrieve any contents.
128  */
130 {
131  char content[256];
132 };
133 
135 
136 typedef struct
137 {
138  uint32_t size; /* total buffer size (IN) / content length (OUT) */
139  void *pstart; /* ptr to buffer starting location */
140 } open_buffdesc;
141 
142 typedef struct
143 {
144  uint8_t release;
145  uint8_t version;
146  uint8_t maint_level;
147  uint8_t build_num;
149 
150 /* Network interface */
151 typedef struct
152 {
153  uint8_t unit;
154  uint8_t slot;
155  uint16_t port;
156 
157 } open_USP_t;
158 
161 typedef enum
162 {
166 
168 typedef enum
169 {
174 
177 typedef enum
178 {
181 } OPEN_BOOL_t;
182 
184 typedef enum
185 {
190 
192 typedef enum
193 {
194  OPEN_ACTION_ADD = 0,
195  OPEN_ACTION_DELETE = 1
196 
197 } OPEN_ACTION_t;
198 
199 typedef enum
200 {
212 
214 typedef enum
215 {
220 
223 typedef enum
224 {
229 
230 #define OPEN_MAC_ADDR_LEN 6
231 #define OPEN_MIN_U64_STR_BUFFER_SIZE 21
235 typedef enum
236 {
240 } OPEN_AF_t;
241 
244 typedef enum
245 {
248 } OPEN_AFX_t;
249 
251 typedef enum
252 {
253  OPEN_PREF_RESERVED = 0, /* Not a valid protocol */
254  OPEN_PREF_LOCAL = 1,
255  OPEN_PREF_STATIC = 2,
256  OPEN_PREF_MPLS = 3,
257  OPEN_PREF_OSPF_INTRA_AREA = 4,
258  OPEN_PREF_OSPF_INTER_AREA = 5,
259  OPEN_PREF_OSPF_EXTERNAL = 6,
260  OPEN_PREF_RIP = 7,
261  OPEN_PREF_IBGP = 8,
262  OPEN_PREF_EBGP = 9,
263  OPEN_PREF_6TO4 = 10,
264  OPEN_PREF_GLOBAL_DEFAULT_GATEWAY = 11,
265  OPEN_PREF_DEFAULT_DHCP = 12,
266  OPEN_PREF_LOCAL_BGP = 13,
267  OPEN_PREF_LAST /* Always keep this last */
269 
271 typedef enum
272 {
273  OPEN_REDIST_RT_FIRST = 0,
274  OPEN_REDIST_RT_LOCAL = 1,
275  OPEN_REDIST_RT_STATIC = 2,
276  OPEN_REDIST_RT_RIP = 3,
277  OPEN_REDIST_RT_OSPF = 4,
278  OPEN_REDIST_RT_BGP = 5,
279  OPEN_REDIST_RT_OSPFV3 = 6,
280  OPEN_REDIST_RT_LAST
282 
285 typedef struct open_in6_addr_s
286 {
287  union
288  {
289  uint32_t addr32[4];
290  uint16_t addr16[8];
291  uint8_t addr8[16];
292  }u;
294 
295 typedef struct open_inet_addr_s
296 {
297  OPEN_AF_t family;
298  union
299  {
300  /* IPv4 address always in host byte order */
301  uint32_t ipv4;
302  open_in6_addr_t ipv6;
303  } addr;
305 
306 typedef struct open_inet_pfx_s
307 {
308  open_inet_addr_t ipAddr;
309  uint32_t pfxLen;
310 
312 
313 typedef enum
314 {
320 
321 #define OPEN_IS_ADDR_EQUAL(xaddr, yaddr) \
322  ( (OPEN_AF_INET6 == ((open_inet_addr_t *)(xaddr))->family) ? \
323  ( (((open_inet_addr_t *)(xaddr))->addr.ipv6.u.addr32[0] == \
324  ((open_inet_addr_t *)(yaddr))->addr.ipv6.u.addr32[0]) && \
325  (((open_inet_addr_t *)(xaddr))->addr.ipv6.u.addr32[1] == \
326  ((open_inet_addr_t *)(yaddr))->addr.ipv6.u.addr32[1]) && \
327  (((open_inet_addr_t *)(xaddr))->addr.ipv6.u.addr32[2] == \
328  ((open_inet_addr_t *)(yaddr))->addr.ipv6.u.addr32[2]) && \
329  (((open_inet_addr_t *)(xaddr))->addr.ipv6.u.addr32[3] == \
330  ((open_inet_addr_t *)(yaddr))->addr.ipv6.u.addr32[3]) ) : \
331  ( ((open_inet_addr_t *)(xaddr))->addr.ipv4 == \
332  ((open_inet_addr_t *)(yaddr))->addr.ipv4) )
333 
334 #define OPEN_INTF_NAME_MAX_LENGTH 60
335 #define OPEN_IP_ADDR_DISP_LENGTH 46
336 #define OPENAPI_VER_BUFF_MAX_SIZE 128
337 #define OPEN_IP_ADDR_LENGTH 16
338 #define OPENAPI_VER_BUFF_MAX_SIZE 128
339 
341 typedef enum
342 {
343  OPEN_PASSWORD_ENCRYPT_NONE = 0,
344  OPEN_PASSWORD_ENCRYPT_AES = 1,
345  OPEN_PASSWORD_ENCRYPT_MD5 = 2
347 
349 typedef enum
350 {
356 
358 typedef enum
359 {
365 
368 #define OPENAPI_PROTOCOL_HEX_IP 0x0800
369 #define OPENAPI_PROTOCOL_HEX_ARP 0x0806
370 #define OPENAPI_PROTOCOL_HEX_IPX 0x8137
371 #define OPENAPI_PROTOCOL_HEX_MIN 0x0600
372 #define OPENAPI_PROTOCOL_HEX_MAX 0xFFFF
374 /*****************************************************************/
388 open_error_t openapiApiVersionGet(openapiClientHandle_t *client_handle,
389  open_revision_data_t *version);
390 
391 /*****************************************************************/
405  uint32_t *intf);
406 
407 /*****************************************************************/
424  uint32_t *maxPaths);
425 
426 /*********************************************************************
427 * @purpose Clear all the bit mask of events
428 *
429 * @param[in] event_mask Bit mask of events which are to be cleared.
430 *
431 * @supportedinversion OpEN API Version: 1.1
432 *
433 * @end
434 *********************************************************************/
435 void openapiEventListClear(openapiEventList_t *event_mask);
436 
437 /*********************************************************************
438 * @purpose Set a particular event type to the event bit mask.
439 *
440 * @param[in] event_mask Bit mask of events in which an event has to set.
441 * @param[in] event_handle Storage to contain event information.
442 *
443 * @supportedinversion OpEN API Version: 1.1
444 *
445 * @end
446 *********************************************************************/
447 void openapiEventSet(openapiEventList_t *event_mask, OPEN_EVENT_e event_handle);
448 
449 /*****************************************************************/
461 int openapiEventIsSet(openapiEventList_t *event_mask, OPEN_EVENT_e event_handle);
462 
463 /*****************************************************************/
489 open_error_t openapiClientRegister(char *client_name,
490  openapiClientHandle_t *client_handle);
491 
492 /*****************************************************************/
533  OPEN_REGISTER_FLAGS_t reg_flags,
534  openapiClientHandle_t *client_handle);
535 
536 /*****************************************************************/
576  int32_t client_inst,
577  int32_t server_id,
578  openapiClientHandle_t *client_handle);
579 
580 /*****************************************************************/
608  openapiClientHandle_t *client_handle);
609 
610 /*****************************************************************/
626 
627 /*****************************************************************/
645 
646 /*****************************************************************/
664  openapiEventList_t *event_mask);
665 
666 /*****************************************************************/
685  openapiEventList_t *changed_mask,
686  openapiEventList_t *purged_mask);
687 
688 /*****************************************************************/
707  int32_t timeout_secs);
708 
709 
710 /*****************************************************************/
724  uint32_t *max_interface_count);
725 
726 /*****************************************************************/
742  uint32_t *system_is_ready);
743 
744 /*****************************************************************/
761  openapiClientHandle_t *client_handle,
762  uint32_t *system_is_ready);
763 
764 /*****************************************************************/
776 
777 /*****************************************************************/
793 
794 /*****************************************************************/
809  open_buffdesc *version);
810 /*****************************************************************/
829  open_buffdesc *version);
830 
831 /*****************************************************************/
848  open_buffdesc *ip1Str,
849  open_buffdesc *ip2Str,
850  OPEN_BOOL_t *equal);
851 
852 /*****************************************************************/
871  open_buffdesc *ipStr,
872  open_inet_addr_t *ipAddr);
873 
874 /*****************************************************************/
895  open_buffdesc *ipOrHostStr,
896  open_inet_addr_t *inetAddr);
897 
898 /*****************************************************************/
916  uint16_t seqNo, uint32_t rtt, uint32_t type, open_buffdesc *srcIp );
917 
918 /*****************************************************************/
939 open_error_t openapiTraceRouteCallbackFn(openapiClientHandle_t *client_handle, uint32_t num_probes, uint32_t ttl, uint32_t ipDa,
940  uint16_t hopCount, uint16_t probeCount, uint32_t rtt, uint8_t errSym);
941 
942 /*****************************************************************/
954 open_error_t openapiCurrentSDMGet(openapiClientHandle_t *client_handle, uint32_t *sdm_template);
955 
956 /*****************************************************************/
975  open_inet_addr_t ipAddr,
976  OPEN_BOOL_t * isZero);
977 
978 /*****************************************************************/
993  uint32_t * maxLen);
994 
995 /*****************************************************************/
1009  uint32_t intfNum,
1010  open_buffdesc * bufdName);
1011 
1012 /*****************************************************************/
1026  uint32_t * maxLen);
1027 
1028 /*****************************************************************/
1043  open_inet_addr_t openAddr,
1044  open_buffdesc * bufdName);
1045 
1046 /*****************************************************************/
1070  uint32_t *fileNameLen);
1071 
1072 /*****************************************************************/
1096  uint32_t *fileNameLen);
1097 
1098 /*****************************************************************/
1115  uint32_t unit,
1116  uint32_t slot,
1117  uint32_t port,
1118  open_buffdesc * bufdName);
1119 
1120 #endif /* _OPENAPI_COMMON_H_ */
1121