📄 wvnetlib.c
字号:
/* wvNetLib.c - WindView for Networking Interface Library *//* Copyright 1990 - 2000 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01d,10may02,kbw making man page edits01c,25oct00,ham doc: cleanup for vxWorks AE 1.0.01b,07jun00,ham fixed a compilation warning.01a,12jan00,spm written*//*DESCRIPTIONThis library provides the user interface to the network-related eventsfor the WindView system visualization tool. These events are divided intotwo WindView classes. The NET_CORE_EVENT class indicates events directlyrelated to data transfer. All other events (such as memory allocation andAPI routines) use the NET_AUX_EVENT class. Within each class, events areassigned one of eight priority levels. The four highest priority levels (EMERGENCY, ALERT, CRITICAL, and ERROR) indicate the occurrence of errors and the remaining four (WARNING, NOTICE, INFO, and VERBOSE) provide progressively more detailed information about the internal processing in the network stack. USER INTERFACEIf WindView support is included, the wvNetStart() and wvNetStop() routines will enable and disable event reporting for the network stack. The startroutine takes a single parameter specifying the minimum priority level forall network components. That setting may be modified with the wvNetLevelAdd() and wvNetLevelRemove() routines. Individual events may be included or removedwith the wvNetEventEnable() and wvNetDisable() routines.The wvNetAddressFilterSet() and wvNetPortFilterSet() routines provide further screening for some events.INTERNALThe WindView monitor executing on a VxWorks target transmits events to theWindView parser on the host based on the event class. Increasing the numberof classes beyond two would allow more precise control over event generation and reduce the load on the VxWorks target, but the total number of available classes is limited. Events are generated within each source code module using macros definedin the wvNetLib.h include file. The WV_BLOCK_START macro determines whether WindView is active and verifies that the given event class has been selected. All WindView related processing must be enclosed between a WV_BLOCK_START and WV_BLOCK_END pair.The WV_NET_EVENT_TEST macro immediately follows the start of the WindViewevent block. It verifies that an individual event is selected by testingthe contents of the event selection map. The event map contains bitmaps for all events within each of the eight priority levels. It is modified by the user interface routines as the settings are changed. Currently, no priority level contains more than 64 events. If that limit is exceeded, the EVENT_MASK structure must be expanded. Local variables indicate the number of events currently defined for each priority level.If an event is active, the WV_NET_FILTER_TEST macro verifies than any remaining conditions are satisfied.If an event fulfills all the conditions, the event identifier is constructedwith the WV_NET_EVENT_SET or WV_NET_MARKER_SET macros and the eventis logged with the evtLogOInt() routine. The event identifier encodesthe related system component (currently 0x30) and the source code module, priority level, and data transfer direction for all events.To use this feature, include the following component:INCLUDE_WVNETINCLUDE FILES:SEE ALSO:.I "WindView for Tornado User's Guide"*//* includes */#include "vxWorks.h"#include "wvLib.h"#include "wvNetLib.h"/* globals */EVENT_MASK wvNetEventMap [8]; /* Bitmasks for all event priorities. */BOOL wvNetAddressFilterTest (int, int, ULONG, ULONG);BOOL wvNetPortFilterTest (int, USHORT, USHORT);/* external variables */IMPORT EVENT_MASK * pWvNetEventMap;IMPORT u_long inet_addr (char * inetString);/* locals */LOCAL int maxEmergencyOffset = 45; /* */LOCAL int maxAlertOffset = 8; /* The maximum offset value for */LOCAL int maxCriticalOffset = 34; /* each priority level is one */LOCAL int maxErrorOffset = 47; /* less than the number of events. */LOCAL int maxWarningOffset = 19; /* If it exceeds 63, the bitmap */LOCAL int maxNoticeOffset = 22; /* size must be increased. */LOCAL int maxInfoOffset = 56;LOCAL int maxVerboseOffset = 57;LOCAL BOOL wvNetInputSrcAddrFlag = FALSE;LOCAL BOOL wvNetInputDstAddrFlag = FALSE;LOCAL int wvNetInputSrcAddr;LOCAL int wvNetInputSrcMask;LOCAL int wvNetInputDstAddr;LOCAL int wvNetInputDstMask;LOCAL BOOL wvNetOutputSrcAddrFlag = FALSE;LOCAL BOOL wvNetOutputDstAddrFlag = FALSE;LOCAL int wvNetOutputSrcAddr;LOCAL int wvNetOutputSrcMask;LOCAL int wvNetOutputDstAddr;LOCAL int wvNetOutputDstMask;LOCAL BOOL wvNetInputSrcPortFlag;LOCAL int wvNetInputSrcPort;LOCAL BOOL wvNetInputDstPortFlag;LOCAL int wvNetInputDstPort;LOCAL BOOL wvNetOutputSrcPortFlag;LOCAL int wvNetOutputSrcPort;LOCAL BOOL wvNetOutputDstPortFlag;LOCAL int wvNetOutputDstPort;/* forward declarations *//********************************************************************************* wvNetInit - stub routine for linker** This routine is called during system startup so that the global variables* storing the WindView settings for the networking instrumentation are * available. It also initializes the event bitmaps so that all events* are reported when logging begins. Event selection can be customized* with the appropriate library routines.** RETURNS: N/A** ERRNO: N/A** NOMANUAL*/void wvNetInit (void) { int index; int loop; /* * Enable all events for each level. Because of the array indexing, * the index into the event map is one less than the value assigned * to the priority level. */ for (index = WV_NET_EMERGENCY - 1; index < WV_NET_VERBOSE; index++) { /* * Currently, no priority level uses more than 64 events. This * inner loop must be increased if that limit is exceeded. */ for (loop = 0; loop < 8; loop++) wvNetEventMap [index].bitmap [loop] = 255; } /* Provide access to the event map from instrumented modules. */ pWvNetEventMap = wvNetEventMap; _func_wvNetAddressFilterTest = wvNetAddressFilterTest; _func_wvNetPortFilterTest = (FUNCPTR)wvNetPortFilterTest; return; } /********************************************************************************* wvNetEnable - begin reporting network events to WindView** This routine activates WindView event reporting for network components,* after disabling all events with a priority less than <level>. The* default value (or a <level> of WV_NET_VERBOSE) will not disable* any additional events. The available priority values are:** WV_NET_EMERGENCY (1)* WV_NET_ALERT (2)* WV_NET_CRITICAL (3)* WV_NET_ERROR (4)* WV_NET_WARNING (5)* WV_NET_NOTICE (6)* WV_NET_INFO (7)* WV_NET_VERBOSE (8)* * If an event is not explicitly disabled by the priority level, it uses the * current event selection map and class settings. The initial values enable* all events of both classes. ** RETURNS: N/A** ERRNO: N/A*/void wvNetEnable ( int priority /* minimum priority, or 0 for default of WV_NET_VERBOSE */ ) { int index; int loop; /* * Because of the array indexing, the <priority> parameter provides the * starting offset into the event map for the lower priority events. * Events with priorities greater than or equal to the given level * remain enabled. All other events are disabled. */ if (priority == 0) /* Set index so no events are disabled by default.*/ priority = WV_NET_VERBOSE; for (index = priority; index < WV_NET_VERBOSE; index++) { /* * Set event map so WV_NET_EVENT_TEST macro will reject events * with lower priority (currently up to 64 per level). */ for (loop = 0; loop < 8; loop++) wvNetEventMap [index].bitmap [loop] = 0; } /* * Begin reporting network events from both the primary and auxiliary * classes. Also enable the class 1 (context switching) events, * in case they are not already active. */ WV_EVTCLASS_SET (WV_NET_CORE_CLASS | WV_NET_AUX_CLASS); return; }/********************************************************************************* wvNetDisable - end reporting of network events to WindView** This routine stops WindView event reporting for all network components.** RETURNS: N/A** ERRNO: N/A*/void wvNetDisable (void) { /* Stop reporting events from either class. */ WV_EVTCLASS_UNSET (WV_NET_CORE_CLASS | WV_NET_AUX_CLASS); return; }/********************************************************************************* wvNetLevelAdd - enable network events with specific priority level** This routine changes the event selection map to allow reporting of any * events with priority equal to <level>. It will override current event * selections for the given priority, but has no effect on settings for * events with higher or lower priorities. The available priority values * are:** WV_NET_EMERGENCY (1)* WV_NET_ALERT (2)* WV_NET_CRITICAL (3)* WV_NET_ERROR (4)* WV_NET_WARNING (5)* WV_NET_NOTICE (6)* WV_NET_INFO (7)* WV_NET_VERBOSE (8)* * Events are only reported based on the current WindView class setting. The * initial (default) setting includes networking events from both classes.** RETURNS: OK, or ERROR for unknown event level.** ERRNO: N/A*/STATUS wvNetLevelAdd ( int priority /* priority level to enable */ ) { int index; int loop; if (priority < WV_NET_EMERGENCY || priority > WV_NET_VERBOSE) return (ERROR); /* * Because of array indexing, the index into the event map is one * less than the value assigned to the priority level. */ index = priority - 1; /* * Set event map so WV_NET_EVENT_TEST macro will accept any events * with selected priority (currently up to 64 per level). */ for (loop = 0; loop < 8; loop++) wvNetEventMap [index].bitmap [loop] = 255; return (OK); }/********************************************************************************* wvNetLevelRemove - disable network events with specific priority level** This routine changes the event selection map to prevent reporting of any * events with priority equal to <level>. It will override the current event * selection for the given priority, but has no effect on settings for events * with higher or lower priorities. The available priority values are:** WV_NET_EMERGENCY (1)* WV_NET_ALERT (2)* WV_NET_CRITICAL (3)* WV_NET_ERROR (4)* WV_NET_WARNING (5)* WV_NET_NOTICE (6)* WV_NET_INFO (7)* WV_NET_VERBOSE (8)* * Events are only reported based on the current WindView class setting. The* initial (default) setting includes networking events from both classes.** RETURNS: OK, or ERROR for unknown event level.** ERRNO: N/A*/STATUS wvNetLevelRemove ( int priority /* priority level to disable */ ) { int index; int loop; if (priority < WV_NET_EMERGENCY || priority > WV_NET_VERBOSE) return (ERROR); /* * Because of array indexing, the index into the event map is one * less than the value assigned to the priority level. */ index = priority - 1; /* * Set event map so WV_NET_EVENT_TEST macro will reject any events * with selected priority (currently up to 64 per level). */ for (loop = 0; loop < 8; loop++) wvNetEventMap [index].bitmap [loop] = 0; return (OK); }/********************************************************************************* wvNetEventEnable - activate specific network events** This routine allows reporting of a single event within the priority equal * to <level>. The activation is overridden if the setting for the entire * priority level changes. The available priority values are:** WV_NET_EMERGENCY (1)* WV_NET_ALERT (2)* WV_NET_CRITICAL (3)* WV_NET_ERROR (4)* WV_NET_WARNING (5)* WV_NET_NOTICE (6)* WV_NET_INFO (7)* WV_NET_VERBOSE (8)* * Offset values for individual events are listed in the documentation.** RETURNS: OK, or ERROR for unknown event.** ERRNO: N/A*/STATUS wvNetEventEnable ( int priority, /* priority level of event */ int offset /* identifier within priority level */ ) { STATUS result = OK; int index; UCHAR mask; int byteOffset; int byteIndex; switch (priority) { case WV_NET_EMERGENCY: if (offset > maxEmergencyOffset) result = ERROR; break; case WV_NET_ALERT: if (offset > maxAlertOffset) result = ERROR; break; case WV_NET_CRITICAL: if (offset > maxCriticalOffset) result = ERROR; break; case WV_NET_ERROR: if (offset > maxErrorOffset) result = ERROR; break; case WV_NET_WARNING: if (offset > maxWarningOffset) result = ERROR; break; case WV_NET_NOTICE: if (offset > maxNoticeOffset) result = ERROR; break; case WV_NET_INFO: if (offset > maxInfoOffset) result = ERROR; break; case WV_NET_VERBOSE: if (offset > maxVerboseOffset) result = ERROR; break; default: /* Unknown priority level */ result = ERROR; break; } /* * Because of array indexing, the index into the event map is one * less than the value assigned to the priority level. */ index = priority - 1; if (result == OK) { byteOffset = offset / 8;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -