Open Ethernet Networking (OpEN) API Guide and Reference Manual  3.13.1.2
openapi_event_notify.h
Go to the documentation of this file.
1 
9 /**********************************************************************
10 *
11 * Copyright 2024 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_event_notify.h
28 *
29 * @purpose This code implements the APIs required for OpEN Event Notifications
30 *
31 * @component OPEN
32 *
33 * @create 04/10/2024
34 *
35 * @end
36 *
37 *********************************************************************/
38 #ifndef OPENAPI_EVENT_NOTIFY_H_INCLUDED
39 #define OPENAPI_EVENT_NOTIFY_H_INCLUDED
40 
41 #include "openapi_common.h"
42 #include "openapi_fdb.h"
43 #include "openapi_if.h"
44 #include "openapi_poe.h"
45 #include "openapi_flow_control.h"
47 #include "openapi_dhcp_client.h"
48 
50 typedef enum
51 {
61 
62 
63 #define OPEN_EVENT_CREATE 1
64 #define OPEN_EVENT_DELETE 2
65 #define OPEN_EVENT_UPDATE 3
67 #define OPEN_PORT_MDIX_AUTO 0
68 #define OPEN_PORT_MDIX_FORCE_AUTO 1
69 #define OPEN_PORT_MDIX_NORMAL 2
70 #define OPEN_PORT_MDIX_XOVER 3
71 #define OPEN_PORT_MDIX_UNKNOWN 4
77 #define OPEN_IP_INFO_MIN_EVENTS 1
78 #define OPEN_IP_INFO_MAX_EVENTS 32
80 #define OPEN_ARP_MIN_EVENTS 16
81 #define OPEN_ARP_MAX_EVENTS 256
83 #define OPEN_IPV4_ROUTE_MIN_EVENTS 16
84 #define OPEN_IPV4_ROUTE_MAX_EVENTS 256
86 #define OPEN_PORT_INFO_MIN_EVENTS 1
87 #define OPEN_PORT_INFO_MAX_EVENTS 256
89 #define OPEN_LLDP_NEIGHBORS_MIN_EVENTS 1
90 #define OPEN_LLDP_NEIGHBORS_MAX_EVENTS 8
92 #define OPEN_POE_STATUS_MIN_EVENTS 1
93 #define OPEN_POE_STATUS_MAX_EVENTS 256
95 #define OPEN_FDB_ENTRY_MIN_EVENTS 16
96 #define OPEN_FDB_ENTRY_MAX_EVENTS 512
102 #define OPEN_IP_INFO_MIN_TIMEOUT 10
103 #define OPEN_IP_INFO_MAX_TIMEOUT 600
105 #define OPEN_ARP_MIN_TIMEOUT 10
106 #define OPEN_ARP_MAX_TIMEOUT 600
108 #define OPEN_IPV4_ROUTE_MIN_TIMEOUT 10
109 #define OPEN_IPV4_ROUTE_MAX_TIMEOUT 600
111 #define OPEN_PORT_INFO_MIN_TIMEOUT 10
112 #define OPEN_PORT_INFO_MAX_TIMEOUT 600
114 #define OPEN_LLDP_NEIGHBORS_MIN_TIMEOUT 10
115 #define OPEN_LLDP_NEIGHBORS_MAX_TIMEOUT 600
117 #define OPEN_POE_STATUS_MIN_TIMEOUT 10
118 #define OPEN_POE_STATUS_MAX_TIMEOUT 600
120 #define OPEN_FDB_ENTRY_MIN_TIMEOUT 20
121 #define OPEN_FDB_ENTRY_MAX_TIMEOUT 600
124 #define OPEN_EVENT_NOTIFY_MAX_STR_LEN 256
125 #define OPEN_EVENT_NOTIFY_DATA_MAX_SIZE 16384
126 #define OPEN_EVENT_NOTIFY_SOCK_NAME "/tmp/event_notify/sockets/client-notify-sock-%d"
130 typedef struct
131 {
132  uint32_t ifNum;
140  uint8_t mdixMode;
143 
145 typedef struct
146 {
147  uint32_t eventChangeType;
148  uint32_t ifNum;
150  /* The unique values to identify an interface remote entry
151  * are ifNum, remote index and timestamp. Any details about
152  * the entry can be fetched using OpENAPI once we have the indices.
153  *
154  * For add and update info can be fetched.
155  * For delete use srcMac as additional info to clean up
156  * Future: if there is usecase we should consider providing
157  * chassis id, port id ( lldpRemDataKey_s ).
158  */
159  uint32_t remIndex;
160  uint32_t timestamp;
161  unsigned char srcMac[OPEN_MAC_ADDR_LEN];
163 
165 typedef enum
166 {
172 
174 typedef struct
175 {
176  uint32_t ifNum;
180  uint32_t powerLimit;
181  uint32_t maxPower;
185 
187 typedef struct
188 {
189  uint8_t eventChangeType;
190  unsigned char mac[OPEN_MAC_ADDR_LEN];
191  uint32_t vlanId;
193  uint32_t ifNum;
195 
197 typedef struct
198 {
200  uint8_t eventChangeType;
202 
204 typedef struct
205 {
207  uint32_t intIfNum;
208  uint32_t ipAddr;
209  uint32_t netMask;
210  uint32_t gateway;
211  uint32_t dnsServerIpAddr[OPEN_DNS_NAME_SERVER_ENTRIES];
212  unsigned char hostName[OPEN_HOSTNAME_MAX_LEN + 1];
213  uint8_t eventChangeType;
215 
217 typedef struct
218 {
219  uint8_t eventChangeType;
220  uint32_t routeDest;
221  uint32_t routeMask;
222  uint16_t vrfId;
223  uint32_t routeProto;
224  uint32_t routePref;
226 
228 typedef struct
229 {
230  uint32_t eventSeqNum;
231  uint32_t globalSeqNum;
233  uint32_t eventCount;
235  /* buffdesc should be last field in this structure */
238 
240 typedef struct
241 {
243  uint32_t timeout;
244  uint32_t eventCount;
246 
247 
248 /*************************************************************************/
263  open_buffdesc *clientDescription);
264 
265 /*************************************************************************/
279 
280 /*************************************************************************/
296  uint32_t numOfNotifyEvents,
297  open_buffdesc *eventNotifyCfg);
298 
299 /*************************************************************************/
315 
316 /*************************************************************************/
333  open_error_t (*callBack) (OPEN_DEVICE_EVENT_t *eventInfo));
334 
335 #endif /* OPENAPI_EVENT_NOTIFY_H_INCLUDED */
336 
OPEN_POE_TRAP_PORT_CHANGE_t
enum values to indicate the change on POE port
OPEN_MGMT_PORT_TYPE_t
OPEN_PORT_SPEEDS_t
OpEN port speed enum values.
Definition: openapi_if.h:109
OPEN_NOTIFY_EVENT_t eventType
Event type to interpret the eventData.
OPEN_PORT_DUPLEX_t duplex
duplex mode
uint32_t timestamp
timestamp also a part index to identify remote port data
Information received in notification for event OPEN_NOTIFY_EVENT_IP_INFO.
OPEN_POE_TRAP_PORT_CHANGE_t state
Current port state.
uint32_t intIfNum
Internal interface number if port type is not service or network.
uint32_t remIndex
part index to identify remote port data
uint32_t ifNum
Port number on which the station is learned.
OPEN_FDB_ADDR_FLAG_t
Definition: openapi_fdb.h:51
OPEN_PORT_SPEEDS_t ifSpeed
port speed
uint32_t ipAddr
Host IP address.
Information received in notification for event OPEN_NOTIFY_EVENT_PORT_INFO.
Change in admin/oper status or speed/AN/duplex/mdix of port.
OPEN_PORT_AUTO_NEG_t autoneg
auto-negotiation enabled/disabled
OPEN_PORT_CABLE_MEDIA_TYPE_t
OPEN uses these enumerators to indicate the interface active media type.
Definition: openapi_if.h:159
OPEN_LINK_STATE_t linkState
Link state up/down.
OPEN_FLOWCONTROL_OPER_t
port is turned off
OPEN_POE_DETECTION_t
PoE detection mode.
Definition: openapi_poe.h:115
open_error_t
OPEN uses these enumerators to indicate the error codes.
Add/Remove LLDP neighbor.
uint8_t eventChangeType
Create, delete or update.
uint32_t powerLimit
Allowed power on the port.
port admin state is enable
For bounds checking.
OPEN_NOTIFY_EVENT_t eventType
Type of the event.
open_error_t openapiEventNotifyClientDeregister(openapiClientHandle_t *client_handle)
Deregister a client from receiving OpEN Event Notifications.
open_error_t openapiEventNotifyEventDeregister(openapiClientHandle_t *client_handle)
Deregister for receiving OpEN Event Notifications for all events.
Add/Remove/Change of ipv4 route entry.
uint32_t gateway
Gateway.
uint32_t netMask
Host network mask.
open_buffdesc eventData
Buffer with event information for eventCount number of events of eventType.
OPEN_DISABLE_REASON_t
OPEN uses these enumerators to indicate the reason a port is diagnostically disabled.
Definition: openapi_if.h:135
uint32_t eventCount
Number of events in this notification packed in eventData.
uint32_t routePref
Route preference (administrative distance).
OPEN_NOTIFY_EVENT_t
OpEN events for which clients can register.
open_error_t openapiEventNotifyEventRegister(openapiClientHandle_t *client_handle, uint32_t numOfNotifyEvents, open_buffdesc *eventNotifyCfg)
Register for receiving notifications of specific events.
uint32_t globalSeqNum
Sequence number of all the events delievered so far.
uint32_t routeMask
Route mask.
OPEN_ARP_ENTRY_t arpEntry
Arp entry information.
uint8_t eventChangeType
Create, delete or update.
#define OPEN_DNS_NAME_SERVER_ENTRIES
maximum value
uint32_t eventCount
Number of events before triggering Notification.
OPEN_PORT_CABLE_MEDIA_TYPE_t medium
active medium for this port copper/fiber
OPEN_POE_PORT_POWER_CLASS_t
PoE port power class.
Definition: openapi_poe.h:63
uint32_t vlanId
VLAN ID on which the station is learned.
OPEN_POE_PORT_FAULT_STATUS_t status
Fault code on the POE port.
OPEN_PORT_STATE_t
OPEN uses these enumerators to indicate port admin mode enable, disable or diag_disable.
Information received in notification for event OPEN_NOTIFY_EVENT_ARP.
Add/Remove of ARP entries.
Add/Remove/Age-out of FDB entries.
uint32_t routeDest
IP address of the route destination.
Change in IP address/Gateway/DNS server/Hostname.
Configuration for each event to control the frequency of notifications.
OPEN_PORT_AUTO_NEG_t
OpEN port auto neg enum values.
Definition: openapi_if.h:189
OPEN_BOOL_t
OPEN uses these enumerators to indicate true or false for a given config or status parameter...
uint32_t maxPower
Maximum power possible to deliver on the port.
OPEN_POE_DETECTION_t detectionStatus
Detection status of power device connected on the port.
OPEN_DISABLE_REASON_t disableReason
disable reason applicable when portState is diag-disabled
port admin state is disable
OPEN_BOOL_t eventMissFlag
Flag indicating one or more events of this eventType are missed.
Delivering power/disabled/fault status of PoE port.
OPEN_POE_TYPE_t
PoE types.
Definition: openapi_poe.h:50
Information received in notification for event OPEN_NOTIFY_EVENT_IPV4_ROUTE.
uint32_t eventChangeType
indicates add/remove
uint32_t routeProto
Value of OPEN_RTO_PROTOCOL_INDICES_t (refer to IP route table).
The notification event encapsulating all event types.
OPEN_POE_PORT_POWER_CLASS_t pdClass
Class of the connected power device.
uint32_t ifNum
Index to identify port uniquely.
port is turned on
OPEN_PORT_STATE_t portState
Admin state disabled/enabled/diag-disabled.
OPEN_POE_PORT_FAULT_STATUS_t
PoE port error code.
Definition: openapi_poe.h:93
open_error_t openapiEventNotifyDataReceive(openapiClientHandle_t *client_handle, open_error_t(*callBack)(OPEN_DEVICE_EVENT_t *eventInfo))
Initialize the socket to receive notification data, register a callback function and wait on socket t...
Information received in notification for event OPEN_NOTIFY_EVENT_FDB_ENTRY.
uint32_t timeout
Time interval between two notifications.
OPEN_PORT_DUPLEX_t
OpEN port duplex enum values.
Definition: openapi_if.h:180
uint8_t eventChangeType
Create or delete.
OPEN_POE_TYPE_t pdType
Device type (poe/pos+/upoe/BT)
OPEN_LINK_STATE_t
OPEN uses these enumerators to indicate the link status.
uint8_t eventChangeType
Create, delete or update.
uint32_t ifNum
index to identify port uniquely
uint32_t ifNum
index to identify local port
open_error_t openapiEventNotifyClientRegister(openapiClientHandle_t *client_handle, open_buffdesc *clientDescription)
Register a client for receiving OpEN Event Notifications.
uint32_t eventSeqNum
Sequence number for the event identified by eventType.
Information received in notification for event OPEN_NOTIFY_EVENT_POE_STATUS.
OPEN_FLOWCONTROL_OPER_t flowControl
Active or inactive.
OPEN_MGMT_PORT_TYPE_t mgmtPortType
Management port type.
Information received in notification for event OPEN_NOTIFY_EVENT_LLDP_NEIGHBORS.
OPEN_FDB_ADDR_FLAG_t entryType
Flag indicate the learnt mode.