Open Ethernet Networking (OpEN) API Guide and Reference Manual  3.11.1.2
openapi_common.h
Go to the documentation of this file.
1 
9 /*********************************************************************
10 *
11 * Copyright 2016-2023 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,
80 } open_error_t;
81 
83 typedef enum
84 {
85  OPEN_EVENT_INTERFACE = 0, /* This first event must be 0 */
86  OPEN_EVENT_VLAN = 1,
87  OPEN_EVENT_ROUTE = 2,
88  OPEN_EVENT_ROUTING_INTERFACE = 3,
89  OPEN_EVENT_ISSU_START = 4,
90  OPEN_EVENT_READY_STATE = 5, /* Configurator transition to/from execute state */
91  OPEN_EVENT_CONFIG = 6,
92  OPEN_EVENT_LAST /* Must be last. Can be incremented as needed */
93 } OPEN_EVENT_e;
94 
95 typedef struct
96 {
97  unsigned char open_event_mask [((OPEN_EVENT_LAST) / 8) + 1];
99 
100 /* OpEN registration service identifiers supported for
101  * external OpEN API clients.
102  *
103  * Internal clients have their own set of identifiers
104  * (unpublished) that are not included here, hence the
105  * use of #define instead of an enumeration.
106  *
107  * NOTE: Defining values that are not likely to get
108  * confused with the actual service ID values.
109  * All values listed here get converted to their
110  * real server ID values by the API implementation.
111  */
112 #define OPEN_REGISTRATION_SERVICE_USERAPPS 100001 /* all user-provided applications */
113 
114 /* First instance number for a given RPC client (by convention).
115  *
116  * Note: Mirrors L7_RPCCLT_INSTANCE_FIRST definition.
117  */
118 #define OPEN_CLIENT_INSTANCE_FIRST 1
119 
121 typedef enum
122 {
126 
127 /* OpEN client handle struct. Only use provided accessor functions to
128  * retrieve any contents.
129  */
131 {
132  char content[256];
133 };
134 
136 
137 typedef struct
138 {
139  uint32_t size; /* total buffer size (IN) / content length (OUT) */
140  void *pstart; /* ptr to buffer starting location */
141 } open_buffdesc;
142 
143 typedef struct
144 {
145  uint8_t release;
146  uint8_t version;
147  uint8_t maint_level;
148  uint8_t build_num;
150 
151 /* Network interface */
152 typedef struct
153 {
154  uint8_t unit;
155  uint8_t slot;
156  uint16_t port;
157 
158 } open_USP_t;
159 
162 typedef enum
163 {
167 
169 typedef enum
170 {
175 
178 typedef enum
179 {
182 } OPEN_BOOL_t;
183 
185 typedef enum
186 {
191 
193 typedef enum
194 {
195  OPEN_ACTION_ADD = 0,
196  OPEN_ACTION_DELETE = 1
197 
198 } OPEN_ACTION_t;
199 
200 typedef enum
201 {
213 
215 typedef enum
216 {
221 
224 typedef enum
225 {
230 
231 #define OPEN_MAC_ADDR_LEN 6
232 #define OPEN_MIN_U64_STR_BUFFER_SIZE 21
236 typedef enum
237 {
241 } OPEN_AF_t;
242 
245 typedef enum
246 {
249 } OPEN_AFX_t;
250 
252 typedef enum
253 {
254  OPEN_PREF_RESERVED = 0, /* Not a valid protocol */
255  OPEN_PREF_LOCAL = 1,
256  OPEN_PREF_STATIC = 2,
257  OPEN_PREF_MPLS = 3,
258  OPEN_PREF_OSPF_INTRA_AREA = 4,
259  OPEN_PREF_OSPF_INTER_AREA = 5,
260  OPEN_PREF_OSPF_EXTERNAL = 6,
261  OPEN_PREF_RIP = 7,
262  OPEN_PREF_IBGP = 8,
263  OPEN_PREF_EBGP = 9,
264  OPEN_PREF_6TO4 = 10,
265  OPEN_PREF_GLOBAL_DEFAULT_GATEWAY = 11,
266  OPEN_PREF_DEFAULT_DHCP = 12,
267  OPEN_PREF_LOCAL_BGP = 13,
268  OPEN_PREF_LAST /* Always keep this last */
270 
272 typedef enum
273 {
274  OPEN_REDIST_RT_FIRST = 0,
275  OPEN_REDIST_RT_LOCAL = 1,
276  OPEN_REDIST_RT_STATIC = 2,
277  OPEN_REDIST_RT_RIP = 3,
278  OPEN_REDIST_RT_OSPF = 4,
279  OPEN_REDIST_RT_BGP = 5,
280  OPEN_REDIST_RT_OSPFV3 = 6,
281  OPEN_REDIST_RT_LAST
283 
286 typedef struct open_in6_addr_s
287 {
288  union
289  {
290  uint32_t addr32[4];
291  uint16_t addr16[8];
292  uint8_t addr8[16];
293  }u;
295 
296 typedef struct open_inet_addr_s
297 {
298  OPEN_AF_t family;
299  union
300  {
301  /* IPv4 address always in host byte order */
302  uint32_t ipv4;
303  open_in6_addr_t ipv6;
304  } addr;
306 
307 typedef struct open_inet_pfx_s
308 {
309  open_inet_addr_t ipAddr;
310  uint32_t pfxLen;
311 
313 
314 
315 typedef enum
316 {
325 
326 
327 #define OPEN_IS_ADDR_EQUAL(xaddr, yaddr) \
328  ( (OPEN_AF_INET6 == ((open_inet_addr_t *)(xaddr))->family) ? \
329  ( (((open_inet_addr_t *)(xaddr))->addr.ipv6.u.addr32[0] == \
330  ((open_inet_addr_t *)(yaddr))->addr.ipv6.u.addr32[0]) && \
331  (((open_inet_addr_t *)(xaddr))->addr.ipv6.u.addr32[1] == \
332  ((open_inet_addr_t *)(yaddr))->addr.ipv6.u.addr32[1]) && \
333  (((open_inet_addr_t *)(xaddr))->addr.ipv6.u.addr32[2] == \
334  ((open_inet_addr_t *)(yaddr))->addr.ipv6.u.addr32[2]) && \
335  (((open_inet_addr_t *)(xaddr))->addr.ipv6.u.addr32[3] == \
336  ((open_inet_addr_t *)(yaddr))->addr.ipv6.u.addr32[3]) ) : \
337  ( ((open_inet_addr_t *)(xaddr))->addr.ipv4 == \
338  ((open_inet_addr_t *)(yaddr))->addr.ipv4) )
339 
340 #define OPEN_INTF_NAME_MAX_LENGTH 60
341 #define OPEN_IP_ADDR_DISP_LENGTH 46
342 #define OPENAPI_VER_BUFF_MAX_SIZE 128
343 #define OPEN_IP_ADDR_LENGTH 16
344 #define OPENAPI_VER_BUFF_MAX_SIZE 128
345 
347 typedef enum
348 {
349  OPEN_PASSWORD_ENCRYPT_NONE = 0,
350  OPEN_PASSWORD_ENCRYPT_AES = 1,
351  OPEN_PASSWORD_ENCRYPT_MD5 = 2
353 
355 typedef enum
356 {
362 
364 typedef enum
365 {
371 
374 #define OPENAPI_PROTOCOL_HEX_IP 0x0800
375 #define OPENAPI_PROTOCOL_HEX_ARP 0x0806
376 #define OPENAPI_PROTOCOL_HEX_IPX 0x8137
377 #define OPENAPI_PROTOCOL_HEX_MIN 0x0600
378 #define OPENAPI_PROTOCOL_HEX_MAX 0xFFFF
380 /*****************************************************************/
394 open_error_t openapiApiVersionGet(openapiClientHandle_t *client_handle,
395  open_revision_data_t *version);
396 
397 /*****************************************************************/
411  uint32_t *intf);
412 
413 /*****************************************************************/
430  uint32_t *maxPaths);
431 
432 /*********************************************************************
433 * @purpose Clear all the bit mask of events
434 *
435 * @param[in] event_mask Bit mask of events which are to be cleared.
436 *
437 * @supportedinversion OpEN API Version: 1.1
438 *
439 * @end
440 *********************************************************************/
441 void openapiEventListClear(openapiEventList_t *event_mask);
442 
443 /*********************************************************************
444 * @purpose Set a particular event type to the event bit mask.
445 *
446 * @param[in] event_mask Bit mask of events in which an event has to set.
447 * @param[in] event_handle Storage to contain event information.
448 *
449 * @supportedinversion OpEN API Version: 1.1
450 *
451 * @end
452 *********************************************************************/
453 void openapiEventSet(openapiEventList_t *event_mask, OPEN_EVENT_e event_handle);
454 
455 /*****************************************************************/
467 int openapiEventIsSet(openapiEventList_t *event_mask, OPEN_EVENT_e event_handle);
468 
469 /*****************************************************************/
495 open_error_t openapiClientRegister(char *client_name,
496  openapiClientHandle_t *client_handle);
497 
498 /*****************************************************************/
539  OPEN_REGISTER_FLAGS_t reg_flags,
540  openapiClientHandle_t *client_handle);
541 
542 /*****************************************************************/
582  int32_t client_inst,
583  int32_t server_id,
584  openapiClientHandle_t *client_handle);
585 
586 /*****************************************************************/
614  openapiClientHandle_t *client_handle);
615 
616 /*****************************************************************/
632 
633 /*****************************************************************/
651 
652 /*****************************************************************/
670  openapiEventList_t *event_mask);
671 
672 /*****************************************************************/
691  openapiEventList_t *changed_mask,
692  openapiEventList_t *purged_mask);
693 
694 /*****************************************************************/
713  int32_t timeout_secs);
714 
715 
716 /*****************************************************************/
730  uint32_t *max_interface_count);
731 
732 /*****************************************************************/
748  uint32_t *system_is_ready);
749 
750 /*****************************************************************/
767  openapiClientHandle_t *client_handle,
768  uint32_t *system_is_ready);
769 
770 /*****************************************************************/
782 
783 /*****************************************************************/
799 
800 /*****************************************************************/
815  open_buffdesc *version);
816 /*****************************************************************/
835  open_buffdesc *version);
836 
837 /*****************************************************************/
854  open_buffdesc *ip1Str,
855  open_buffdesc *ip2Str,
856  OPEN_BOOL_t *equal);
857 
858 /*****************************************************************/
877  open_buffdesc *ipStr,
878  open_inet_addr_t *ipAddr);
879 
880 /*****************************************************************/
901  open_buffdesc *ipOrHostStr,
902  open_inet_addr_t *inetAddr);
903 
904 /*****************************************************************/
922  uint16_t seqNo, uint32_t rtt, uint32_t type, open_buffdesc *srcIp );
923 
924 /*****************************************************************/
945 open_error_t openapiTraceRouteCallbackFn(openapiClientHandle_t *client_handle, uint32_t num_probes, uint32_t ttl, uint32_t ipDa,
946  uint16_t hopCount, uint16_t probeCount, uint32_t rtt, uint8_t errSym);
947 
948 /*****************************************************************/
960 open_error_t openapiCurrentSDMGet(openapiClientHandle_t *client_handle, uint32_t *sdm_template);
961 
962 /*****************************************************************/
981  open_inet_addr_t ipAddr,
982  OPEN_BOOL_t * isZero);
983 
984 /*****************************************************************/
999  uint32_t * maxLen);
1000 
1001 /*****************************************************************/
1015  uint32_t intfNum,
1016  open_buffdesc * bufdName);
1017 
1018 /*****************************************************************/
1032  uint32_t * maxLen);
1033 
1034 /*****************************************************************/
1049  open_inet_addr_t openAddr,
1050  open_buffdesc * bufdName);
1051 
1052 /*****************************************************************/
1076  uint32_t *fileNameLen);
1077 
1078 /*****************************************************************/
1102  uint32_t *fileNameLen);
1103 
1104 /*****************************************************************/
1121  uint32_t unit,
1122  uint32_t slot,
1123  uint32_t port,
1124  open_buffdesc * bufdName);
1125 
1126 #endif /* _OPENAPI_COMMON_H_ */
1127 
Untagged or priority tagged frames.
open_error_t openapiImageFileNameMaxLengthGet(openapiClientHandle_t *client_handle, uint32_t *fileNameLen)
Get the maximum length of an image file name (excluding its path) in the file system.
Success.
open_error_t openapiIntfNameGet(openapiClientHandle_t *client_handle, uint32_t intfNum, open_buffdesc *bufdName)
Get interface name for a given internal interface number.
open_error_t openapiIntfNameMaxLengthGet(openapiClientHandle_t *client_handle, uint32_t *maxLen)
Get maximum length of interface name.
Port is enabled.
open_error_t openapiIntfDisplayNameGet(openapiClientHandle_t *client_handle, uint32_t unit, uint32_t slot, uint32_t port, open_buffdesc *bufdName)
Get the display name of given interface.
Rate in packets/sec.
struct open_in6_addr_s open_in6_addr_t
Hash Mode names.
Parameter/feature is not supported.
open_error_t openapiCurrentSDMGet(openapiClientHandle_t *client_handle, uint32_t *sdm_template)
Get the current active SDM template in the system.
open_error_t openapiConnectivityCheck(openapiClientHandle_t *client_handle)
Return code indicates whether the OpEN remote procedure call infrastructure is ready.
OPEN_AFX_t
OPEN uses these enumerators to indicate BGP address family index of routes or policy for IPV4 or IPV6...
Address type unknown.
Address type DNS.
Port is disabled by protocol.
OPEN_REGISTER_FLAGS_t
Open API enhanced registration flags.
OPEN_REDIST_RT_INDICES_t
Redistribution route types.
Operation Fail.
Error in RPC.
int openapiClientNotifySocketFDGet(openapiClientHandle_t *client_handle)
Accessor function to retrieve the socket FD for event notifications from OpEN.
CPU interface.
OPEN_DOT1Q_ACCEPT_FRAME_TYPE_t
OPEN uses these enumerators to indicate the types of frames that may be received on this port...
Rate in kilobytes/sec.
open_error_t
OPEN uses these enumerators to indicate the error codes.
Operation Timeout.
IPV6 address family.
open_error_t openapiSystemReadyStateGet(openapiClientHandle_t *client_handle, uint32_t *system_is_ready)
Determine whether the system is currently operational or not operational.
OPEN_INTF_TYPE_t
IPV6 address family.
Link Down.
Physical interface.
open_error_t openapiInternalClientTearDown(openapiClientHandle_t *client_handle)
Deregister an internal OpEN client.
open_error_t openapiInetAddrGet(openapiClientHandle_t *client_handle, open_buffdesc *ipStr, open_inet_addr_t *ipAddr)
Get the IP address in network byte order from string format.
Operation dependency not met.
open_error_t openapiPendingEventsGet(openapiClientHandle_t *client_handle, openapiEventList_t *changed_mask, openapiEventList_t *purged_mask)
Check what events are pending for this client.
OPEN_RATE_UNIT_t
OpEN uses this enumeration to define rate units.
No special flags needed.
open_error_t openapiHardwareVersionGet(openapiClientHandle_t *client_handle, open_buffdesc *version)
Returns hardware version of the switch.
open_error_t openapiMaxInterfaceCountGet(openapiClientHandle_t *client_handle, uint32_t *max_interface_count)
Get the maximum number of interfaces on this switch.
VLAN interface.
Already exists.
Parameter not found.
open_error_t openapiEventWait(openapiClientHandle_t *client_handle, int32_t timeout_secs)
Wait for Open API events for this client.
OPEN_AF_t
OPEN uses these enumerators to indicate address family, IPV4 or IPV6.
Invalid parameter.
OPEN_ACTION_t
OPEN uses these enumerators to indicate the interface types.
open_error_t openapiInetAddrCompare(openapiClientHandle_t *client_handle, open_buffdesc *ip1Str, open_buffdesc *ip2Str, OPEN_BOOL_t *equal)
Check if the two IP address strings refer to the same address.
open_error_t openapiClientRegister(char *client_name, openapiClientHandle_t *client_handle)
Register as a client with the OpEN API and wait until OpEN API services are available.
IPV4 address family.
Error conditions.
OPEN_PORT_STATE_t
OPEN uses these enumerators to indicate port admin mode enable, disable or diag_disable.
open_error_t openapiCpuIntfGet(openapiClientHandle_t *client_handle, uint32_t *intf)
Returns the CPU control plane interface number.
open_error_t openapiNetworkOSVersionGet(openapiClientHandle_t *client_handle, open_buffdesc *version)
Returns the revision of the network operating system running on the switch.
open_error_t openapiEventRegister(openapiClientHandle_t *client_handle, openapiEventList_t *event_mask)
Register the client to receive event notifications for one or more event types.
Useful on openapiIfNextGet() to get all interfaces.
open_error_t openapiTraceRouteCallbackFn(openapiClientHandle_t *client_handle, uint32_t num_probes, uint32_t ttl, uint32_t ipDa, uint16_t hopCount, uint16_t probeCount, uint32_t rtt, uint8_t errSym)
Send the traceroute response to the client(CLI/Telnet/SSH) session.
open_error_t openapiClientRegisterEnhanced(char *client_name, OPEN_REGISTER_FLAGS_t reg_flags, openapiClientHandle_t *client_handle)
Register as a client with the OpEN API using enhanced options and wait until OpEN API services are av...
open_error_t openapiInetAddrFromIPAddrHostNameStr(openapiClientHandle_t *client_handle, open_buffdesc *ipOrHostStr, open_inet_addr_t *inetAddr)
Converts network address string containing either an IPv4/IPv6 address or a host name into an inetAdd...
OPEN_CONTROL_t
OPEN uses these enumerators to indicate enable or disable for a given config or status parameter...
Nothing to report or table is empty.
Service port interface.
int openapiEventIsSet(openapiEventList_t *event_mask, OPEN_EVENT_e event_handle)
Check if a particular event is set in a bit mask of events.
open_error_t openapiClientTearDown(openapiClientHandle_t *client_handle)
Teardown and cleanup the connection resources.
OPEN_PREF_INDICES_t
Route Preference Types.
OPEN_VLAN_PARTICIPATION_MODE_t
OPEN uses these enumerators to indicate the VLAN participation of a given interface.
OPEN_BOOL_t
OPEN uses these enumerators to indicate true or false for a given config or status parameter...
OPEN_ACCESS_LINE_t
open_error_t openapiIsInetAddrZero(openapiClientHandle_t *client_handle, open_inet_addr_t ipAddr, OPEN_BOOL_t *isZero)
Check if the given IP address is zero or not.
open_error_t openapiServiceClientRegister(char *client_name, int32_t client_inst, int32_t server_id, openapiClientHandle_t *client_handle)
Register as a client of a specified OpEN API service and wait until the service is available...
Address type IPv4.
Rate in percentage of link speed.
OPEN_PASSWORD_ENCRYPT_ALG_t
OpEN uses this enumeration to define encryption types.
OPEN_IP_ADDRESS_TYPE_t
OpEN uses this enumeration to define IP address types.
Multi-threaded application.
open_error_t openapiSystemFileNameMaxLengthGet(openapiClientHandle_t *client_handle, uint32_t *fileNameLen)
Get the maximum length of a file name (including its path) in the file system.
Internal error.
Tunnel interface.
Neither IPV4 nor IPV6.
open_error_t openapiPingCallback(openapiClientHandle_t *client_handle, uint16_t seqNo, uint32_t rtt, uint32_t type, open_buffdesc *srcIp)
Send the ping response to the client(CLI/Telnet/SSH) session.
open_error_t openapiIpAddressMaxStringLength(openapiClientHandle_t *client_handle, uint32_t *maxLen)
Get maximum string length of IP address.
open_error_t openapiOspfEqualCostRoutesMax(openapiClientHandle_t *client_handle, uint32_t *maxPaths)
Get the number of equal cost routes supported by this platform.
open_error_t openapiSystemReadyStateTransitionNextGet(openapiClientHandle_t *client_handle, uint32_t *system_is_ready)
Get the next configurator state transition event.
Loopback interface.
IPV4 address family.
Address type IPv6.
OPEN_EVENT_e
Open API Events for which clients can register.
OPEN_LINK_STATE_t
OPEN uses these enumerators to indicate the link status.
Port is disabled.
Maximum count is already reached or table full.
Rate unit none.
open_error_t openapiOpenIPtoStringGet(openapiClientHandle_t *client_handle, open_inet_addr_t openAddr, open_buffdesc *bufdName)
Get human readable string format of given IP address.
Hash Mode names.
Any other interface type.
LAG interface.
open_error_t openapiInternalClientRegister(char *client_name, openapiClientHandle_t *client_handle)
Register as an internal client with the OpEN API and wait until OpEN API services are available...