Open Ethernet Networking (OpEN) API Guide and Reference Manual  3.4.4.5
openapi_common.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_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 
169 typedef enum
170 {
173 } OPEN_BOOL_t;
174 
176 typedef enum
177 {
182 
184 typedef enum
185 {
186  OPEN_ACTION_ADD = 0,
187  OPEN_ACTION_DELETE = 1
188 
189 } OPEN_ACTION_t;
190 
191 typedef enum
192 {
204 
206 typedef enum
207 {
212 
215 typedef enum
216 {
221 
222 #define OPEN_MAC_ADDR_LEN 6
223 #define OPEN_MIN_U64_STR_BUFFER_SIZE 21
227 typedef enum
228 {
232 } OPEN_AF_t;
233 
236 typedef enum
237 {
240 } OPEN_AFX_t;
241 
243 typedef enum
244 {
245  OPEN_PREF_RESERVED = 0, /* Not a valid protocol */
246  OPEN_PREF_LOCAL = 1,
247  OPEN_PREF_STATIC = 2,
248  OPEN_PREF_MPLS = 3,
249  OPEN_PREF_OSPF_INTRA_AREA = 4,
250  OPEN_PREF_OSPF_INTER_AREA = 5,
251  OPEN_PREF_OSPF_EXTERNAL = 6,
252  OPEN_PREF_RIP = 7,
253  OPEN_PREF_IBGP = 8,
254  OPEN_PREF_EBGP = 9,
255  OPEN_PREF_6TO4 = 10,
256  OPEN_PREF_GLOBAL_DEFAULT_GATEWAY = 11,
257  OPEN_PREF_DEFAULT_DHCP = 12,
258  OPEN_PREF_LOCAL_BGP = 13,
259  OPEN_PREF_LAST /* Always keep this last */
261 
263 typedef enum
264 {
265  OPEN_REDIST_RT_FIRST = 0,
266  OPEN_REDIST_RT_LOCAL = 1,
267  OPEN_REDIST_RT_STATIC = 2,
268  OPEN_REDIST_RT_RIP = 3,
269  OPEN_REDIST_RT_OSPF = 4,
270  OPEN_REDIST_RT_BGP = 5,
271  OPEN_REDIST_RT_OSPFV3 = 6,
272  OPEN_REDIST_RT_LAST
274 
277 typedef struct open_in6_addr_s
278 {
279  union
280  {
281  uint32_t addr32[4];
282  uint16_t addr16[8];
283  uint8_t addr8[16];
284  }u;
286 
287 typedef struct open_inet_addr_s
288 {
289  OPEN_AF_t family;
290  union
291  {
292  /* IPv4 address always in host byte order */
293  uint32_t ipv4;
294  open_in6_addr_t ipv6;
295  } addr;
297 
298 typedef struct open_inet_pfx_s
299 {
300  open_inet_addr_t ipAddr;
301  uint32_t pfxLen;
302 
304 
305 typedef enum
306 {
312 
313 #define OPEN_IS_ADDR_EQUAL(xaddr, yaddr) \
314  ( (OPEN_AF_INET6 == ((open_inet_addr_t *)(xaddr))->family) ? \
315  ( (((open_inet_addr_t *)(xaddr))->addr.ipv6.u.addr32[0] == \
316  ((open_inet_addr_t *)(yaddr))->addr.ipv6.u.addr32[0]) && \
317  (((open_inet_addr_t *)(xaddr))->addr.ipv6.u.addr32[1] == \
318  ((open_inet_addr_t *)(yaddr))->addr.ipv6.u.addr32[1]) && \
319  (((open_inet_addr_t *)(xaddr))->addr.ipv6.u.addr32[2] == \
320  ((open_inet_addr_t *)(yaddr))->addr.ipv6.u.addr32[2]) && \
321  (((open_inet_addr_t *)(xaddr))->addr.ipv6.u.addr32[3] == \
322  ((open_inet_addr_t *)(yaddr))->addr.ipv6.u.addr32[3]) ) : \
323  ( ((open_inet_addr_t *)(xaddr))->addr.ipv4 == \
324  ((open_inet_addr_t *)(yaddr))->addr.ipv4) )
325 
326 #define OPEN_INTF_NAME_MAX_LENGTH 60
327 #define OPEN_IP_ADDR_DISP_LENGTH 46
328 #define OPENAPI_VER_BUFF_MAX_SIZE 128
329 
331 typedef enum
332 {
333  OPEN_PASSWORD_ENCRYPT_NONE = 0,
334  OPEN_PASSWORD_ENCRYPT_AES = 1,
335  OPEN_PASSWORD_ENCRYPT_MD5 = 2
337 
339 typedef enum
340 {
346 
348 typedef enum
349 {
355 
358 #define OPENAPI_PROTOCOL_HEX_IP 0x0800
359 #define OPENAPI_PROTOCOL_HEX_ARP 0x0806
360 #define OPENAPI_PROTOCOL_HEX_IPX 0x8137
361 #define OPENAPI_PROTOCOL_HEX_MIN 0x0600
362 #define OPENAPI_PROTOCOL_HEX_MAX 0xFFFF
364 /*****************************************************************/
378 open_error_t openapiApiVersionGet(openapiClientHandle_t *client_handle,
379  open_revision_data_t *version);
380 
381 /*****************************************************************/
395  uint32_t *intf);
396 
397 /*****************************************************************/
414  uint32_t *maxPaths);
415 
416 /*********************************************************************
417 * @purpose Clear all the bit mask of events
418 *
419 * @param[in] event_mask Bit mask of events which are to be cleared.
420 *
421 * @supportedinversion OpEN API Version: 1.1
422 *
423 * @end
424 *********************************************************************/
425 void openapiEventListClear(openapiEventList_t *event_mask);
426 
427 /*********************************************************************
428 * @purpose Set a particular event type to the event bit mask.
429 *
430 * @param[in] event_mask Bit mask of events in which an event has to set.
431 * @param[in] event_handle Storage to contain event information.
432 *
433 * @supportedinversion OpEN API Version: 1.1
434 *
435 * @end
436 *********************************************************************/
437 void openapiEventSet(openapiEventList_t *event_mask, OPEN_EVENT_e event_handle);
438 
439 /*****************************************************************/
451 int openapiEventIsSet(openapiEventList_t *event_mask, OPEN_EVENT_e event_handle);
452 
453 /*****************************************************************/
479 open_error_t openapiClientRegister(char *client_name,
480  openapiClientHandle_t *client_handle);
481 
482 /*****************************************************************/
523  OPEN_REGISTER_FLAGS_t reg_flags,
524  openapiClientHandle_t *client_handle);
525 
526 /*****************************************************************/
566  int32_t client_inst,
567  int32_t server_id,
568  openapiClientHandle_t *client_handle);
569 
570 /*****************************************************************/
598  openapiClientHandle_t *client_handle);
599 
600 /*****************************************************************/
616 
617 /*****************************************************************/
635 
636 /*****************************************************************/
654  openapiEventList_t *event_mask);
655 
656 /*****************************************************************/
675  openapiEventList_t *changed_mask,
676  openapiEventList_t *purged_mask);
677 
678 /*****************************************************************/
697  int32_t timeout_secs);
698 
699 
700 /*****************************************************************/
714  uint32_t *max_interface_count);
715 
716 /*****************************************************************/
732  uint32_t *system_is_ready);
733 
734 /*****************************************************************/
751  openapiClientHandle_t *client_handle,
752  uint32_t *system_is_ready);
753 
754 /*****************************************************************/
766 
767 /*****************************************************************/
783 
784 /*****************************************************************/
799  open_buffdesc *version);
800 /*****************************************************************/
819  open_buffdesc *version);
820 
821 /*****************************************************************/
838  open_buffdesc *ip1Str,
839  open_buffdesc *ip2Str,
840  OPEN_BOOL_t *equal);
841 
842 /*****************************************************************/
861  open_buffdesc *ipStr,
862  open_inet_addr_t *ipAddr);
863 
864 /*****************************************************************/
885  open_buffdesc *ipOrHostStr,
886  open_inet_addr_t *inetAddr);
887 
888 /*****************************************************************/
906  uint16_t seqNo, uint32_t rtt, uint32_t type, open_buffdesc *srcIp );
907 
908 /*****************************************************************/
929 open_error_t openapiTraceRouteCallbackFn(openapiClientHandle_t *client_handle, uint32_t num_probes, uint32_t ttl, uint32_t ipDa,
930  uint16_t hopCount, uint16_t probeCount, uint32_t rtt, uint8_t errSym);
931 
932 /*****************************************************************/
944 open_error_t openapiCurrentSDMGet(openapiClientHandle_t *client_handle, uint32_t *sdm_template);
945 
946 /*****************************************************************/
965  open_inet_addr_t ipAddr,
966  OPEN_BOOL_t * isZero);
967 
968 /*****************************************************************/
983  uint32_t * maxLen);
984 
985 /*****************************************************************/
999  uint32_t intfNum,
1000  open_buffdesc * bufdName);
1001 
1002 /*****************************************************************/
1016  uint32_t * maxLen);
1017 
1018 /*****************************************************************/
1033  open_inet_addr_t openAddr,
1034  open_buffdesc * bufdName);
1035 
1036 /*****************************************************************/
1060  uint32_t *fileNameLen);
1061 
1062 /*****************************************************************/
1079  uint32_t unit,
1080  uint32_t slot,
1081  uint32_t port,
1082  open_buffdesc * bufdName);
1083 
1084 #endif /* _OPENAPI_COMMON_H_ */
1085