/******************************************************************************* ** ** Cabletron Systems Incorporated ** Post Office Box 5005 ** Rochester, NH 03866-5005 ** (c) Copyright Cabletron Systems Inc. 1999 ** ** Workfile: %M% ** Logfile: %P% ** Original Author: Todd Crowley ** SCCS Delta ID: %I% ** Last Delta Date/Time: %G% %U% ** *******************************************************************************/ /******************************************************************************/ /* */ /* File: LfapCCEos_h */ /* */ /* This file is an example (template) header file for the CCE. These */ /* functions must be implemented by the CCE developers. The comments before */ /* the functions describe them in detail. */ /* */ /******************************************************************************/ #ifndef LFAPCCEOS_H_ #define LFAPCCEOS_H_ #include "LfapStruct.h" #ifdef __cplusplus extern "C" { #endif /* * max number of timers that can be outstanding at one time */ #define LFAP_MAX_TIMERS_OUTSTANDING (20) #define LFAP_TIMER_SET (0) #define LFAP_TIMER_RESET (1) #define LFAP_TIMER_WAIT (2) #define LFAP_TIMER_DISABLED (3) #define LFAP_TIMER_DISABLED_SET (4) typedef struct { int status; #ifdef MLS_SOL_BUILD NU_TIMER timer; #else unsigned int timer; #endif LFAP_CB_ENTRYPOINT cb; lfapui32_t handle; lfapui32_t wait_time; } lfap_timer_t; /* this event sent when master socket receives connection */ #define LFAP_EVENT_SOCKET_BIT 0 #define LFAP_EVENT_SOCKET_FLAG (1 << LFAP_EVENT_SOCKET_BIT) /* bit #1 is in lfap_main.h */ /* this event sent when config change is made */ #define LFAP_TIMER_EXPIRED_BIT 2 #define LFAP_TIMER_EXPIRED_FLAG (1 << LFAP_TIMER_EXPIRED_BIT) /* used to timeout on tcp reads */ #define EVFLAG_RD_BIT 3 #define EVFLAG_RD_MASK (1 << EVFLAG_RD_BIT) /* Bit #4 is in lfap_main.h */ /* this event sent when master socket receives connection */ #define LFAP_EVENT_SOCKET_WRT_BIT 5 #define LFAP_EVENT_SOCKET_WRT_FLAG (1 << LFAP_EVENT_SOCKET_WRT_BIT) #ifndef MLS_BUILD /* for builds outside CCE environment */ #define LFAP_W_UNKNOWN_MSG -1 #define LFAP_W_INVALID_LEN -1 #define LFAP_E_DIFF_SERVERS -1 #define LFAP_E_PART_MSG_RCVD -1 #define LFAP_W_MSG_SHORT -1 #define LFAP_E_BAD_VERSION -1 #define LFAP_W_MSG_CORRUPT -1 #endif /* globals */ extern lfap_timer_t lfap_timers[LFAP_MAX_TIMERS_OUTSTANDING]; /* pre: buf & len valid ptrs * post: return 0 on success, else -1 */ int get_lfap_msg(char *buf, int *len); /******************************************************************************/ /* */ /* FUNCTION */ /* */ /* LFAPGeCurTime - return the current time (UTC) */ /* */ /* SYNOPSIS */ /* */ /* lfapui32_t LFAPGetCurTime (void) */ /* */ /* DESCRIPTION */ /* */ /* This function is called by the LFAP API to get current wall clock time. */ /* The value is the number of seconds since 1970. */ /* */ /* RETURN */ /* */ /* Unsigned long value indicating the current time. */ /* */ /* CAVEATS */ /* */ /* This function should be autonomous (no context switches if on a */ /* threaded operating system). */ /* */ /******************************************************************************/ lfapui32_t LFAPGetCurTime (void); /******************************************************************************/ /* */ /* FUNCTION */ /* */ /* LFAPGetSysUptime - return the CCE uptime value in hundredths of seconds */ /* */ /* SYNOPSIS */ /* */ /* lfapui32_t LFAPGetSysUptime (void) */ /* */ /* DESCRIPTION */ /* */ /* This function is called by the LFAP API to get the CCE uptime value. */ /* The uptime returned is of type SNMPv2 TimeStamp (RFC 1443), therefore */ /* it is the length of time in hundredths of seconds that the CCE has */ /* been operational. */ /* */ /* RETURN */ /* */ /* Unsigned long value indicating the CCE uptime in hundredths of seconds. */ /* */ /* CAVEATS */ /* */ /* This function should be autonomous (no context switches if on a */ /* threaded operating system). */ /* */ /******************************************************************************/ lfapui32_t LFAPGetSysUptime (void); /******************************************************************************/ /* */ /* FUNCTION */ /* */ /* LFAPGetStatistics - get the statistics for a flow */ /* */ /* SYNOPSIS */ /* */ /* void LFAPGetStatistics (lfapui32_t flow_id, LFAPFlowStats* flow_stats) */ /* */ /* flow_id - lfapui32_t indicating the identifier for the flow. */ /* */ /* flow_stats - pointer to a zero initialized LFAPFlowStats */ /* structure (see LfapStruct.h for a description) to be */ /* filled in by this function. */ /* */ /* DESCRIPTION */ /* */ /* This function is called by the LFAP API to get the statistics on a flow */ /* with identifier flow_id. A pointer to a zero initialized LFAPFlowStats */ /* structure is passed in to be filled in by this function. */ /* */ /* RETURN */ /* */ /* Nothing. */ /* */ /* CAVEATS */ /* */ /* This function should be autonomous (no context switches if on a */ /* threaded operating system). */ /* */ /******************************************************************************/ void LFAPGetStatistics (lfapui32_t flow_id, LFAPFlowStats* flow_stats); /******************************************************************************/ /* */ /* Function: LFAPDoesFlowExist */ /* */ /* This function is called by the LFAP API to determine if the flow still */ /* exists in the CCE environment. Since the flow may have been deleted by */ /* the hardware some time ago, care must be take to implement this function */ /* in such a way that time is not a factor (i.e. if hardware flow handles */ /* are reused, this function should not depend on them */ /* */ /******************************************************************************/ int LFAPDoesFlowExist (lfapui32_t flow_id); /******************************************************************************/ /* */ /* FUNCTION */ /* */ /* LFAPSynchronize - allow the CCE to run other tasks */ /* */ /* SYNOPSIS */ /* */ /* void LFAPSynchronize (void) */ /* */ /* DESCRIPTION */ /* */ /* This function is called by the LFAP API to allow a non-preemptive */ /* system to run other tasks. The CCE should complete whatever work it */ /* wishes to complete, then return from this function. Returning from */ /* this function will allow the LFAP API to continue with its work. This */ /* function should (at a minimum) allow a context switch to occur. */ /* */ /* RETURN */ /* */ /* Nothing. */ /* */ /* CAVEATS */ /* */ /* None. */ /* */ /******************************************************************************/ void LFAPSynchronize (void); /******************************************************************************/ /* */ /* FUNCTION */ /* */ /* LFAPSetSystemTimer - set a one-shot timer */ /* */ /* SYNOPSIS */ /* */ /* void LFAPSetSystemTimer (const LFAP_CB_ENTRYPOINT lfap_cb_entry, */ /* lfapui32_t return_handle, */ /* lfapui32_t time_val) */ /* */ /* lfap_cb_entry - callback entrypoint to be called back when the */ /* timer expires. */ /* */ /* return_handle - argument the lfap_cb_entry should be called back */ /* with. */ /* */ /* time_val - lfapui32_t value indicating the time to wait (in */ /* milliseconds) before the lfap_cb_entry should be */ /* called back. */ /* */ /* DESCRIPTION */ /* */ /* This function is called by the LFAP API to set a timer for time_val */ /* milliseconds. lfap_cb_entry is the callback entrypoint that is called */ /* with the parameter return_handle upon completion of the timer. */ /* */ /* RETURN */ /* */ /* Nothing. */ /* */ /* CAVEATS */ /* */ /* More than one timer can be outstanding at one time. */ /* */ /******************************************************************************/ void LFAPSetSystemTimer (const LFAP_CB_ENTRYPOINT lfap_cb_entry, lfapui32_t return_handle, lfapui32_t time_val); /******************************************************************************/ /* */ /* FUNCTION */ /* */ /* LFAPSendMessage - send a message to the server on the TCP connection */ /* */ /* SYNOPSIS */ /* */ /* int LFAPSendMessage (void* buf, lfapui16_t buf_len, int clear) */ /* */ /* buf - pointer to an encoded message allocated on the heap, to be */ /* sent to the server. */ /* */ /* buf_len - length of the encoded message. */ /* */ /* clear - clears any partially sent message. */ /* */ /* DESCRIPTION */ /* */ /* This function is called by the LFAP API to send the (void*) buf to the */ /* server. buf_len includes the length of the header of the LFAP message. */ /* LFAP_SEND_FAILURE is returned if the send failed, LFAP_SEND_SUCCESS is */ /* returned if it was successful. Clear causes any partially sent messages */ /* to be cleared. */ /* */ /* RETURN */ /* */ /* Integer indicating if the send was successful. If successful, */ /* LFAP_SEND_SUCCESS is returned, else LFAP_SEND_FAILURE is returned. */ /* */ /* CAVEATS */ /* */ /* None. */ /* */ /******************************************************************************/ int LFAPSendMessage (void* buf, lfapui16_t buf_len, int clear); /******************************************************************************/ /* */ /* FUNCTION */ /* */ /* LFAPSendVector - send an array of messages to the server */ /* */ /* SYNOPSIS */ /* */ /* int LFAPSendVector (LFAPMsgHolder* vec, */ /* lfapui16_t vec_len, */ /* lfapui16_t total_len) */ /* */ /* vec - pointer to an array of LFAPMsgHolder structures, each of */ /* which has an encoded message allocated on the heap, to be */ /* sent to the server. */ /* */ /* vec_len - number of LFAPMsgHolders in the array */ /* */ /* total_len - total number of bytes of the messages in the array */ /* */ /* DESCRIPTION */ /* */ /* This function is called by the LFAP API to send the messages in the */ /* LFAPMsgHolder array to the server. */ /* */ /* RETURN */ /* */ /* Integer indicating if the send was successful. If successful, */ /* LFAP_SEND_SUCCESS is returned, else LFAP_SEND_FAILURE is returned. */ /* */ /* CAVEATS */ /* */ /* None. */ /* */ /******************************************************************************/ int LFAPSendVector (LFAPMsgHolder* vec, lfapui16_t vec_len, lfapui16_t total_len, lfapui16_t lost_conn_count); /******************************************************************************/ /* */ /* FUNCTION */ /* */ /* LFAPConnect - attempt to make a TCP connection to a server */ /* */ /* SYNOPSIS */ /* */ /* int LFAPConnect (lfapui32_t server_ip) */ /* */ /* server_ip - lfapui32_t form of the server's IP address that */ /* the CCE should attempt to make a TCP connection to. */ /* */ /* DESCRIPTION */ /* */ /* This function is called by the LFAP API to attempt to make a TCP */ /* connection to the server specified by server_ip. The server is */ /* listening on the LFAP_PORT. */ /* */ /* RETURN */ /* */ /* Integer indicating if the TCP connection was created. If the */ /* connection was created, LFAP_TCP_CONNECTION_ESTABLISHED is returned, */ /* else LFAP_TCP_CONNECTION_FAILED is returned. */ /* */ /* CAVEATS */ /* */ /* None. */ /* */ /******************************************************************************/ int LFAPConnect (lfapui32_t server_ip); /******************************************************************************/ /* */ /* FUNCTION */ /* */ /* LFAPDisconnect - attempt to break the TCP connection to a server */ /* */ /* SYNOPSIS */ /* */ /* int LFAPDisconnect (lfapui32_t server_ip) */ /* */ /* server_ip - lfapui32_t form of the server's IP address that */ /* the CCE should attempt to break the TCP connection */ /* with. */ /* */ /* DESCRIPTION */ /* */ /* This function is called by the LFAP API to attempt to break the TCP */ /* connection to a server specified by server_ip. */ /* */ /* RETURN */ /* */ /* Integer indicating if the TCP connection was broken. If the */ /* connection was broken, LFAP_TCP_DISCONNECT_SUCCESS is returned, else */ /* LFAP_TCP_DISCONNECT_FAILED is returned. */ /* */ /* CAVEATS */ /* */ /* None. */ /* */ /******************************************************************************/ int LFAPDisconnect (lfapui32_t server_ip); /******************************************************************************/ /* */ /* FUNCTION */ /* */ /* LFAPLock - Obtain a system lock */ /* */ /* SYNOPSIS */ /* */ /* int LFAPLock() */ /* */ /* */ /* DESCRIPTION */ /* */ /* This function is called by the LFAP API to insure single thread access */ /* to data structures. */ /* */ /* WARNING - any new platform implementations must do a thread analysis */ /* to ensure all data structures are locked. This implementation */ /* is where flows are admitted on one thread and processed by */ /* another thread */ /* RETURN */ /* */ /* Integer value which may be passed to LFAPUnlock. */ /* */ /* CAVEATS */ /* */ /* None. */ /* */ /******************************************************************************/ int LFAPLock(); /******************************************************************************/ /* */ /* FUNCTION */ /* */ /* LFAPUnlock - Release a system lock */ /* */ /* SYNOPSIS */ /* */ /* void LFAPUnlock(int lockVal) */ /* */ /* lockVal - return value from LFAPLock() */ /* */ /* DESCRIPTION */ /* */ /* This function is called by the LFAP API to insure single thread access */ /* to data structures. */ /* */ /* WARNING - any new platform implementations must do a thread analysis */ /* to ensure all data structures are locked. This implementation */ /* is where flows are admitted on one thread and processed by */ /* another thread */ /* RETURN */ /* */ /* */ /* CAVEATS */ /* */ /* None. */ /* */ /******************************************************************************/ void LFAPUnLock(int lockVal); #ifdef __cplusplus } #endif #endif /* LFAPCCEOS_H_ */