SYSTEM AND METHOD FOR GENERAL PURPOSE NETWORK ANALYSIS

Abstract: A network interface system and related methods. A single logic control module, which may be implemented in hardware or software, is utilized to perform any of a number of data manipulation functions including, for example, parsing, filtering, data generation or analysis, based upon one or more programmably configurable protocol descriptions which may be stored in and retrieved from an associated memory.

Description: DESCRIPTION System and Method for General Purpose Network Analysis Technical Field The present invention relates to network communications systems and, in particular, to improved systems and methods for parsing, filtering, generating and analyzing data composed of inter-related structures such as protocols found within network frames. Background Art Existing network interface devices provide systems for receiving, analyzing, filtering and transmitting network data or frames of data. Network Protocol Analyzers, Bridges, and Routers are among the most common network interface devices currently available. Conventional network protocol analyzers provide, for a predefined set of network frame structures or protocols, a system for monitoring the activity of a network and the stations on it by allowing network traffic to be captured and stored for later analysis. Common capture and analysis capabilities include the gathering of statistics, subsequent report generation, the ability to filter frames based on specific criteria, and the ability to generate network traffic. Bridges and routers are network devices that pass frames from one network interface to another. Bridges operate at the data-link layer and routers at the network layer of the OSI reference model. Like protocol analyzers, both bridges and routers may gather statistics and filter incoming network frames based on specific criteria, however incoming frames also may be forwarded to other networks based on information collected by the bridge or router. Routers typically support only a limited number of network protocols. Each of these network devices requires an ability to separate network frames into individual protocols and their components (typically referred to as parsing) , an ability to filter incoming frames based on a logical combination of one or more field values extracted during parsing, and an ability to gather statistics based :.n part on extracted field values. Typically, it is a requirement that network frames be received, analyzed and forwarded at full network speeds, sometimes on many different networks at one time. A frame filter consists of one or more criteria which specify one or more valid values for a frame (or segments of a frame) . Frame filtering criteria are typically implemented using an offset (from frame or protocol header start) , a length in bits which defines a field, e. value for comparison, and mask values for identifying relevant and irrelevant bits within the field. For multiple value filter criteria, the result from each filter value is logically OR'ed together to obtain an overall result. Therefore, each additional result adds to the processing required to filter a given field. For filtering on optional protocol fields that do not occur at the same relative offset in each protocol frame, this method is time-consuming. Thus, it would be desirable to perform filtering on both fixed and optional variable offset fields for any number of values or ranges of values without incurring any additional overhead. Parsing, the process wherein network frames are broken up into their individual protocols and fields, is necessary for filtering with offsets relative to protocol headers, gathering field based statistics, generating network traffic, routing data frames, verifying field values, and displaying network frames in human readable form. In conventional systems, the parsing process has an overall structure which incorporates control logic for each supported protocol. Therefore, additional control logic must be developed when support for a new protocol is added to a conventional system. As the development of additional control logic, whether implemented in hardware or software, may be both time consuming and expensive, it would be highly desirable to be able to parse all protocols with a single configurable software (or hardware) module so that support for additional protocols could be added to a system without requiring substantial modification to the system or its control logic. Further, although microprocessors (or CPUs) avail- able today can execute tens or even hundreds of millions of instructions per second, vendors often must provide dedicated hardware assistance and/or front-end processors with hand-coded assembly language routines to achieve the necessary processing rates for more than one pair of networks. Unfortunately, this solution requires hardware and/or software modifications whenever changes are made to the number of supported features or protocols. Finally, as networks become larger and more complex, the maintenance of a comprehensive statistics database by each network device becomes more important. Because these statistics databases typically are not utilized by a maintaining device, but instead are collected by a network management device, the collection process may affect performance adversely without any corresponding benefit to the collecting device. In light of the considerations discussed above, it is believed that a network interface system having a con¬ figurable protocol analysis capability with common control logic applicable to many different network devices would be highly desirable. Summary of Invention The present invention is directed to improved systems and methods for parsing, filtering, generating and analyzing data (or frames of data) transmitted over a data communications network. In one particularly innovative aspect of the present invention, a single logic control module, which may be implemented in hardware or software, is utilized to perform any of a number of data manipulation functions (for example, parsing, filtering, data generation or analysis functions) based upon one or more programmably configurable protocol descriptions which may be stored in and retrieved from an associated memory. The use of common control logic (i.e. the use of a single logic control module) and programmably configurable protocol descriptions allows changes to existing protocols to be made and support for new protocols to be adde:d to a system in accordance with the present invention t.hrough configuration only -- without the need for hardware and/or software system modifications. Thus, those skilled in the art will appreciate that a network interface in accordance with the present invention may be configured and reconfigured, if necessary, in a highly efficient and cost effective manner to implement numerous data manipulation functions and to accommodate substantial network modifica¬ tions (for example, the use of different data transnission hardware, protocols or protocol suites) without necessitating substantial system changes. In one preferred form, the system of the present invention may employ a CPU or other hardware implementable method for analyzing data from a network in response to selectively programmed parsing, filtering, statistics gathering, and display requests. Moreover, the system of the present invention may be incorporated in a network device, such as a network analyzer, bridge, router, or traffic generator, including a CPU and a plurality of input devices, storage devices, and output devices, wherein frames of network data may be received from an associated network, stored in the storage devices, and processed by the CPU based upon one or more programmably configurable protocol descriptions also stored in the storage devices. The protocol descriptions may take the form of one or more protocol description files for each supported network protocol and may include a protocol header record and plurality of field sub-records having data corresponding to an associated protocol and fields defined therein. The system of the present invention also preferably includes logic for extracting field values from particular network frames, performing validation and error checking, and making parsing decisions based upon field values and information in the programmably configurable protocol descriptions. The system of the present invention also preferably includes logic for filtering a subset of network frames received from the input or storage devices which satisfy a filter criteria based upon information defined in the programmably configurable protocol descriptions. The system of the present invention also preferably includes logic for filtering network frames which satisfy a plurality of filter criteria which, if desired, may be joined together by Boolean operators. The system of the present invention also preferably includes logic for analyzing a filter request by breaking the request into its component criteria to determine whether the result from evaluating a particular filter request criteria when combined with results from earlier criteria can be used to filter (i.e. discard) a particular network frame. The system of the present invention also preferably includes logic for collecting statistics based upon extracted field values satisfying a statistics criteria based upon information defined in the programmably con- figurable protocol descriptions. The system of the present invention also preferably includes logic for determining a next protocol description structure required to continue analyzing a network frame. The system of the present invention also preferably includes logic for determining a frame length and individual protocol header lengths from extracted field values in a network frame. The system of the present invention also preferably includes logic for making routing decisions based upon information contained in the programmably configurable protocol descriptions. The system of the present invention also preferably includes logic for determining display formats based on information contained in the programmably configurable protocol descriptions. The system of the present invention also preferably includes logic for verifying individual field values and making parsing decisions based on the validity of the value. The system of the present invention also preferably includes logic for constructing and transmitting retwork frames with varying field contents based on information contained in the programmably configurable protocol descriptions. The system of the present invention may be employed in any system where it is useful to be able to examine and perform various operations on contiguous bit-fields in data structures, wherein each data structure is composed of predefined fields of one or more contiguous bits. Further, the system of the present invention is particularly efficient where operations must be performed on a subset of included fields. Those skilled in the art will recognize that the system of the present invention gains a distinct advantage in size and maintainability over conventional network devices by implementing analysis capabilities for multiple known and unknown protocols using common control logic. Furthermore, the system gains a distinct advantage in speed and efficiency over conventional network devices when the control logic is implemented in hardware or a front-end processor, without incurring the penalty of additional hardware and/or software development when protocol definitions change. Accordingly, it is an object of the present invention to provide an improved system for network analysis wherein the system may determine which protocols and which protocol fields exist in a network frame (also referred herein as parsing) using common control logic combined with configurable protocol descriptions. It is yet another object of the present invention to provide an improved system for network analysis wherein the control logic may be implemented in hardware as well as software. It is yet another object of the present invention to provide an improved system for network analysis wherein each supported analysis capability is configurable even when the control logic is implemented in hardware. It is another object of the present invention to provide an improved system for network analysis wherein the system may determine whether a particular network frame includes a field that satisfies a particular filter, criteria based upon information stored in a programmably configurable protocol description. It is yet another object of the present invention to provide an improved system for network analysis wherein the system may determine if a particular network frame includes a protocol field that satisfies a particular statistics gathering criteria defined in a programmably configurable protocol description. It is yet another object of the present invention to provide an improved system for network analysis wherein the system may generate network traffic in the form of frames constructed from selected protocol descriptions with the ability to specify a variety of methods for varying individual field values. It is still another object of the present invention to provide an improved system for network analysis wherein the system may route network frames (determine the appropriate destination interface) that satisfy a particular routing criteria defined in a programmably configurable protocol description while providing a capability to specify a variety of methods for varying individual field values during the routing process. It is still another object of the present invention to provide an improved system for network analysis wherein the system may determine if a particular network frame includes a protocol field that contains a value related to either the overall length of the frame or the current protocol header length. Brief Description Of The Drawings Fig. 1 is a block diagram of a network interface system in accordance with one form of the present invention. Fig. 2 is a diagram representing a set of data records of a typical network frame which may be contained in the data files of the network interface system illustrated in Fig. 1. Fig. 3 is a diagram representing a set of data records of a protocol description in accordance wi;h one form of the present invention. Fig. 4 is a diagram representing a control recsrd of an Ethernet protocol description which may be utilized in a network interface system in accordance with one fDrm of the present invention. Fig. 4a is a diagram representing five defined field sub-records of the Ethernet protocol description illustrated in Fig. 4. Figs. 4b, 4c, and 4d are diagrams representing lookup structures referenced in Fig. 4a fields 0, 2 and 4 respectively. Fig. 5 is a diagram representing a control record of an imaginary Generic Protocol description which may be utilized in a network interface system in accordance with one form of the present invention. Fig. 5a is a diagram representing eleven defined field sub-records of the GP description illustrated in Fig. 5. Figs. 5b, 5c, 5d, and 5e are diagrams representing lookup structures referenced in Fig. 5(a) fields 1, 3, 7 and 8, respectively. Figs. 6, 6a, and 6b are diagrams representing the control record and field sub-record of a protocol description structure that allows parsing of optional fields of the GP description shown in Figs. 5 - 5e. Figs. 7, 7a, and 7b are diagrams representing the control record and field sub-records of a protocol description structure that describes the End Of List option of the GP description shown in Figs. 5 - 5e . Figs. 8, 8a, and 8b are diagrams representing the control record and field sub-records of a protocol description structure that describes the No Operation option of the GP description shown in Figs. 5 - 5e. Figs. 9, 9a, and 9b are diagrams representing the control record and field records of a protocol description file that describes the Maximum Frame Size option of the GP description shown in Figs. 5 - 5e . Figs. 10, 10a, 10b, 10c, lOd and lOe are diagrams representing data records of a filter expression control and associated field filter structures. Fig. 11 is a flow chart illustrating top level frame parsing control logic in accordance with one form of the present invention. Fig. 12 is a flow chart illustrating protocol parsing control logic in accordance with one form of the present invention. Fig. 13 is a flow chart of the field parsing control logic in accordance with one form of the present invention. Fig. 14 is a flow chart representing value verification, error checking, next protocol and branch determination control logic in accordance with one form of the present invention. Fig. 15 is a flow chart representing field filtering control logic in accordance with one form of the present invention. Fig. 16 is a flow chart illustrating field value extraction and varying control logic in accordance with one form of the present invention. Description of Preferred Embodiments Referring now to Fig. 1, a network interface system in accordance with one form of the present invention, generally referred to as 10, may be implemented in a network device including input devices 12, data storage devices 14, analysis control logic 16 for facilitating the input, storage, retrieval, and analysis of network frames, and output devices 18 for forwarding frames or displaying or printing the results of analyses. A data storage device 14 may include a data file 20 of network frames having n protocol data records, wherein each data record contains data stored in a plurality of predefined fields. Protocol description files 22 also may be stored in the data storage device 14. The protocol description files 22 may include a protocol control record and n fieli sub- records, which together may describe a subset of a r.etwork protocol and include rules for analyzing that protocol. The network device control logic 16 is capaσle of retrieving a subset of network frames from the input devices 12 or data files 20 which satisfy one or more criteria based upon extracted field values and filtering criteria contained in one or more of the protocol description files 22. The network device control logic 16 also includes logic for determining frame and protocol header lengths, gathering statistics, verification and error checking, determining routes, varying values, and formatting output. A personal computer or conventional network device, such as an IBM PC (or compatible) , Apple Macintosh ® , or any Unix ® , or Zenix ® workstation, protocol analyzer, bridge, router, traffic generator, or similar system may be utilized in accordance with the system of the present invention. The data input devices 12 may comprise any of a number of commercially available network interface devices and may include a conventional keyboard or mouse if required. The data storage devices 14 may take the form of any of a number of commercially available data storage options (such as RAM, ROM, EPROM, or various sized fixed disk drives) , and the data output devices 18 may comprise any of a number of commercially available user interface devices, such as CRT displays, monitors, network interface devices and/or printers (if required) . The analysis control logic 16 may be implemented as a computer program written in any language suitable for systems programming or may be implemented in hardware if better performance is required. In one presently preferred form, the analysis control logic 16 may be implemented via the programming files set forth in the attached Appendix, which is herein incorporated by reference. However, those skilled in the art will appreciate that the analysis control logic 16 might equivalently be implemented in dedicated hardware using, for example, one or more application specific integrated circuits ("ASICs") or one or more field programmable gate arrays ("FPGAs") . The network interface system 10 of the present invention is preferably implemented on a personal computer, workstation or conventional network device having a 32-bit or larger bus and register set, an optional math co-processor, at least one megabyte of available RAM, and for personal computer and workstation applications, a fixed disk having at least 10 megabytes of available storage space. As shown in the attached Appendix, the analysis control logic 16 may be programmed in the C++ language, with abstract data types defined for statistics gathering, value verification, next protocol determination, filtering, varying values, checksumming and route determination capabilities, and protocol control and field records. Referring now to Fig. 2, a data file 20 in accordance with one form of the present invention may include a plurality (n) of protocol header data records and optional Data and Pad records . Each protocol record contains data organized into a plurality of predefined fields. Each field comprises a collection of 1 or more contiguous bits and includes a set of valid values for that field. For example, a particular protocol specification might include a 6 bit header length field that limits the protocol header length to values between 20 and 60 inclusive, thereby excluding values less than 20 and values from 61 to 64. The number of possible contiguous bit fields for a protocol header of length N bits where N is greater than 1 can be expressed by the following formula: Number of Possible Fields = It will be appreciated by those skilled in the art that any possible organization of fields for any possible protocol specification is contemplated for the network interface system 10 of the present invention. Referring now to Fig. 3, a protocol description file 22 in accordance with one form of the present invention may include a protocol control record, and a plurality (n) of field data records. In a particularly preferred embodiment, the protocol control record (shown below in Table 1) may define the overall structure of a network protocol and reference other information relating to the network protocol . TABLE 1 The field records referenced at bytes 28-31 n the table above are preferably organized as shown in Table 2: TABLE 2 The statistics records referenced in Table 2, above, at bytes 24-27 are preferably organized as shown in Table 3: TABLE 3 The next protocol lookup records referenced in the field sub-record table (Table 2) at bytes 28-.J1 are preferably organized as shown in Table 4: TABLE 4 Lookup structures can be used for determining the next protocol control record to use, terminating protocol processing on illegal values, branching decisions for variable length headers or overlapping fields, and for translation of numeric values to mnemonic or written language equivalents. This ability to specify branches on field values allows protocols with multiple overlapping structures to be specified and parsed dynamically. The vary field value records referenced n the field sub-record table (Table 2) at bytes 32-35 are preferably organized as shown m Table 5: TABLE 5 The checksum records referenced in the fielc. sub- record table (Table 2) at bytes 36-39 are preferably organized as shown in Table 6: TABLE 6 The filter criteria records referenced in the field sub-record table (Table 2) at bytes 40-43 are preferably organized as shown in Table 7: TABLE 7 The filter channel records referenced in the Filter Criteria record (Table 7) above at 4-7 are preferably organized as shown in Table 8: TABLE 8 Each configured filter consists of one or more filter criteria and the filter criteria may be organized into Filter Criteria records. The Filter Criteria records may refer to lookup structures which allow the filter criteria to determine from a field value the current state of the filter expression at each criteria. These states may include: PASS_FRAME (accept this frame) and FILTER_FRAME (discard this frame) . The NextCriterialndex field referenced in Table 8 above at bytes 0-3 is used to ensure that all filter expressions are applied in the required order. The Ptl and Fid fields at bytes 12-19 allow filter criteria to be associated with specific protocols and protocol fields. The lookup records referenced in the Filter Criteria record (Table 7) at bytes 8-11 are preferably organized as shown in Table 9 : TABLE 9 The Route Table records referenced in the Field Sub- Records table (Table 2) at bytes 44-47 are preferably organized as shown in Table 10: TABLE 10 The Route Table Entry records referenced in the table above at bytes 16-19 are preferably organized as shown in Table 11: TABLE 11 In Tables 1-11 the records of the protocol description and associated field, statistics, lookup, checksum, vary, route determination and filter records are shown as they appear when resident in memory. In the presently preferred embodiment, each of these protocol description records with its associated field, statistics, lookup, and filter record information is also written to a protocol specific protocol description file (PDF) . In the presently preferred embodiment, the following sequence of data is written to a PDF: For the Protocol Control Record: the length of the protocol name including NULL terminator, the name of the protocol, the total bit length of the protocol header, the number of fields required to describe records, the index of the field currently referenced, the display bit width, for each of the field records that describe the protocol header, a call is made to write the field related data (This sequence is described below) . if the pointer to the option control record is NULL, zero, if there are options, the length of the protocol option name including the NULL terminator, the option name, the option's protocol control record or the Field Record: the flag indicating the value is the actual length of frame, the length of the field in bits, the byte offset from the start of the protocol header, the number of bits to left shift of the 32-bit Eield, the number of bits to right shift of the 32-bit field, the number indicating the display type, the flag indicating the value is the actual length of the protocol header, the reserved byte, the multiplier to apply to value prior to display, the flag indicating whether to byte swap the 32-bit value, the flag indicating that the field is :o be displayed, the length of the field name including the NULL terminator, or zero if the pointer to the statistics structure/class is NULL, zero if the pointer to the statistics structure/class is not NULL, a call is made to write the statistics type if the pointer to the lookup structure/class is NULL, zero if the pointer to the lookup structure/class is not NULL, a call is made to write the lookup typs, the number of lookups, and the lookup values The pointer to vary field, pointer to checksum, pointer to filter, and pointer to route determination are handled similarly. In the presently preferred embodiment, the iritial- ization of the system includes a determination of the presence of PDF files and the extraction of the protocol and associated control record information from all of the PDF files found. The number of PDF files is determined, and a ProtocolList is constructed consisting of a sorted vector of protocol records at least the size of the number of PDF files found. The name of each protocol record found is inserted in the ProtocolList. The PDF files are then read to memory in the sequence described above for the PDF file writing. The lookup records that indicate a next protocol are associated with the appropriate entries in the ProtocolList. Two simple protocol descriptions are provided in Tables 12 and 13 (below) to assist in the description of the system of the present invention. The Ethernet Protocol specification shown below is a simplification of an actual Ethernet protocol header. TABLE 12 ETHERNET v2.0 PROTOCOL SPECIFICATION 0 15 23 47 Destination Hardware Address Source Hardware Address Ethernet Protocol Type Destination Hardware Address - destination hardware station address (48 ' bits) Source Hardware Address source hardware station address (48 bits) Ethernet Protocol Type upper layer protocol designator (16 bits) 0x8888=GP The Ethernet protocol definition described above specifies only one possible upper level protocol, the Generic Protocol (GP) which is indicated by placing a hexadecimal 0x8888 value in the protocol type field. The Generic Protocol (GP) specification shown below in Table 13 has been fabricated to provide examples of dif :erent types of field functionalities found in actual network protocols. TABLE 13 GENERIC PROTOCOL (GP) SPECIFICATION 15 23 31 Version Number ( 4 bits! software version numter HeaderLen ( 4 bits) length of GP header in 32 bit words . 0- 4 illegal 5 = No Optional fields, 6-15 = 32-320 bits of options Frame Type ( 8 bits! upper level protocol identifier 0 = Unknown 1 = GP1 2 = GP2 3-255 = Unknown Frame Length ( 16 bits) frame length in bytes including header Checksum (16 bits) Checksum of header includ¬ ing options Control ( 8 bits) reserved (must be zero) Hop Count ( 8 bits) Count of number of networks traversed Src Socket (16 bits) Socket of Upper-layer protocol sender Dst Socket (16 bits) Socket of Upper-layer protocol receiver Src Address (32 bits) Sender protocol address Dst Address (32 bits) Receiver protocol address The GP options have two possible formats. Type 1 consists of a single 8-bit option type field containing an option type value. Type 2 contains the 8-bit option type field, but also contains an 8-bit option length field to allow implementation of variable length options in the GP. Two type 1 options and one type 2 option defined in the GP specification are shown below in Table 13 : TABLE 13 End of Option (8 bits) Indicates end of List options l ist . Consists of an 8-bit option type field with value 0. Necessary only for list that does not end on 32-bit boundary. No Operation (8 bits) Performs no function. Consists of an 8-bit option type byte with value 1. Used for alignment of other GP options. MinMax Size ( 3 2 / 4 8 Allows minimum and bits) maximum al l owable frame lengths to be specified . Consists of an 8-bit option type field with value 2, an 8-bit Dption length field, an 16- bit minimum frame length field, and an optional 16-bit maximum frame length field. If the maximum frame length is specified, the option length field will have value 4, otherwise it will have value 6 specified in units of 8-bit bytes. Describing the flow charts of Figs. 11-16 requires the definition of several variables. These variables (described in Table 14 below) are used to implement and monitor the current control logic state of a network interface system in accordance with the present invention: TABLE 14 FramePtr Pointer to start of network frame being parsed HwLen Bit length of network frame as reported by input device ParseLen Number of bits parsed in the current network frame Current Protocol Pointer to protocol description control record in use CurField Index of field in CurrentProtocol being parsed ParsePtr Pointer to start of protocol header in frame being parsed FrameLen Number of meaningful bits in the current network frame ProtoParse Len Number of bits parsed in the current protocol header HeaderLen Size in bits of protocol header being parsed ParseLvl Zero based protocol level in ISO reference model of protocol being parsed (current protocol) ParseList - Array of pointers to protocol headers in frame being parsed (only 0 to (ParseLvl-1) are valid) Srclntf Index of interface on which frame being parsed was received (useful for bridging applications and interface operations) IntfTypes Array of values defining the type of each interface in the network system (useful for bridging operations and type specific operations) Network frames contain one or more protocol headers, an optional number of data bits, and an optional number of pad bits. Frame bits up to the frame length extracted during parsing for which no protocol description exists are considered data. Bits beyond the frame length extracted during parsing are considered to be pad. Two network frames are provided as examples to be used during discussion of the control logic of the present invention: Frame 1 shown below has a hardware length of eighty- two 8-bit bytes and consists of a fourteen byte Ethernet header, a twenty byte GP header with no option bytes, and forty-eight bytes of application data. No hardware pad is required because the frame length exceeds the Ethernet minimum of sixty bytes. Frame ( 1 ) (1) 08 00 00 00 00 03 08 00 00 00 00 04 88 88 Ethernet Header(14) (2) 35 00 00 44 Bl 5F 00 01 08 00 01 47 01 02 03 04 05 06 07 08 GP Healer (20) (3) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Data (24) (4) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Data (24) Frame 2 shown below has a hardware length of sixty 8- bit bytes and consists of a fourteen byte Ethernet hsader, a twenty-eight byte GP header including eight option bytes, and eighteen bytes of pad to achieve the sixty byte Ethernet minimum frame length requirement. Frame (2) (1) 08 00 00 00 00 01 08 00 00 00 00 02 88 Ethernet Header (14) 08 00 01 00 01 02 03 04 GP Header (20) GP NoOp Option (1) GP MaxSizeOpt (4) GP EOL Options (1) GP Option Pad (2) 00 00 00 00 00 00 00 00 Frame Ead (18) A flow chart is provided for each of the major control logic components of the present invention. The flow chart shown in Fig. 11 outlines ParseFrame control logic in accordance with the present invention and shows how successive protocol headers are parsed, and how remaining information is parsed as application data and frame pad. The flow chart in Fig. 12 outlines ParseProtocol control logic in accordance with one iorm of the present invention and shows how fixed and optional fields may be parsed in a selected protocol. The flow chart shown in Fig. 13 outlines ParseFields control logic in accordance with the present invention and shows how decisions are made and operations performed on extracted field values. The flow chart shown in Fig. 14 outlines ValidateValue control logic in accordance with the present invention and shows how branching, next protocol determination, and validity decisions are made with extracted field values. The flow chart shown in Fig. 15 outlines ApplyFilter control logic in accordance with one form of the present invention and shows how filter criteria are applied to fields in network frames. The flow chart shown in Fig. 16 outlines GetValue control logic in accordance with one form of the present invention and shows how field values are extracted from network frames. These six components of the control logic of a network interface system in accordance with the present invention are described in detail below. Referring now to Fig. 13, a value is extracted by the GetValue control logic (shown in Fig. 16) of the system (at 210) for each configured field that is relevant to the current network frame. As shown in Fig. 16, the fdwoff value is added to ParsePtr to locate and extract a 32-bit value (at 502) containing the field value, which is then byteswapped (at 510) if the fswap field is TRUE. If the ptr2vary field is NULL (at 512 or 518) , indicating that the value does not need to be modified or varied, the field value is extracted (at 506) by shifting the 32-bit value left fshl bits and then right by fshr bits to eliminate any extraneous bits. If the ptr2vary field is non-NULL, the extracted 32-bit value is modified using the configured method (at 514 or 520) and the resulting 32-bit value overwrites the extracted 32-bit value (at 516 or 522) . If the extracted value was byteswapped (at 510) , the modified value is swapped back (at 516) prior to overwriting the original value. The extracted value is returned (at 508) by the GetValue control logic. It will be appreciated by those skilled in the art that the system of the present invention can handle different machine endian architectures (at 210) by rearranging the bit and byte order of the extracted 32-bit network frame value to match the target hardware architecture, and can be adapted easily to RISC" based architectures where all memory accesses must be aligned in some fashion. If the GetValue control logic was about to extract a value for the GP HeaderLen field from frame (2) , ParsePtr would point at the first value of line 2, from Fig. 5a, fdwoff would be 0, fshl would be 4, and fshr would be 28, so that 32-bits of data would be extracted (at 502) and, possibly, byteswapped (at 510) to obtain a hexadecimal value equal to 0x3703002A. In binary notation this is: 0011 0111 0000 0011 0000 0000 0010 1010 Shifting left 4 bits (at 506) yields: 0111 0000 0011 0000 0000 0010 1010 0000 Shifting right 28 bits (at 506) yields: 0000 0000 0000 0000 0000 0000 0000 0111 Which in decimal notation is: 7 Therefore, the actual length of the GP header in frame (2) is seven 32-bit words, which is 28 bytes or 224 bits. Although the presently preferred embodiment of the system of the present invention is designed to handle a maximum field width of 32 bits, it will be appreciated by those skilled in the art that the system may be designed to handle any required maximum field width, and is particularly efficient where the maximum field width matches the underlying hardware architecture. [t will also be appreciated by those skilled in the art that it is possible to divide larger protocol fields into sut-fields as demonstrated by the Ethernet protocol field descriptions shown in Fig. 4a where the 48-bit hardware address fields have each been defined as two 24-bit sub- fields. The ValidateValue control logic shown in Fig. 14 is performed on each extracted field value by the ParseFields control logic (at 214) shown in Fig. 13. Each field may have an associated lookup structure reference containing one or more values and/or ranges of values that have a particular meaning for that field. If no lookup structure is configured for a particular field, all values are deemed to be valid (at 318 and 312) , which causes parsing to continue with the next sequentially defined field of the current protocol description. If a lookup structure exists for a particular field but the extracted value is not found therein (at 314 and 316) , parsing still continues with the next defined field of the current protocol. However, the value is considered invalid. Values or ranges of values found in configured lookup structures are considered to be valid. The Prot and Nextlndex values associated with a value or range found are used to specify NextProtocol, the protocol description (at 308) to be used after current protocol header parsing is completed, and the index of the next field (at 310) is used to determine where parsing of the current protocol will continue after the current field. The first valid field parsed in a protocol that specifies the NextProtocol has precedence over all subsequent NextProtocol specifiers (at 306) . The ValidateValue control logic returns an updated CurField value (at 312 and 316) together with a valid/invalid indication, and where indicated (at 308) may return an updated value for NextProtocol . Using value 0x8888 as an example, if the ValidateValue control logic is applied to the Ethernet Type field and associated lookup structure shown in Figs. 4a and 4d respectively, the lookup structure would be found (at 302) , the value will be found in it (at 304) , the associated Protocol field found with the range containing 0x8888 value will be used to update the NextProtocol variable (at 308) if it is NULL (at 306) , and the associated Next Index field will be used to update the CurField variable. Using Fig. 5c as an example, it may be seen how values may be used to continue parsing at difEerent locations in the current protocol description. In this case, value 0x02 for the Frame Type field causes Checksum field processing to be skipped. Referring back to the ParseFields control logic shown in Fig. 13, the ParseFields control logic parses the fields in each protocol header contained in a particular network frame by using field values obtained in accordance with information specified in associated prDtocol descriptions. The ParseFields control logic is applied for each protocol description required for a particular network frame. If the ParseFields control logic: were applied to the exemplary frame, "Frame (1)," described above, the network interface system 10 of the present invention would apply the ParseFields control logi^ with the protocol descriptions for the Ethernet protocol shown in Table 12, the GP shown in Table 13, and an unspecified Data protocol description. The ParseFields routine is entered (at 200) with ParsePtr pointing at the start of a protocol header in a particular network frame and CurrentProtocol set to an appropriate protocol description. Parsing starts at Protocol bit and field zero when CurField and ProtoParseLen are cleared (at 202) , also, HeaderLen is set to the configured protocol control record NumBits value, and LocalProto, the local next protocol return value variable is cleared. Using the Ethernet protocol description shown in Fig. 4 as an example, HeaderLer. would be set to 112 bits. The control loop (at 204 through 224) continues: until the last field has been parsed (at 206) , all bits in the header have been parsed (at 208) , or all bits in the frame have been parsed (at 209) . For each field a value is retrieved by the system (at 210) . If there is a filter criteria for the field it is applied (at 232) by the ApplyFilter control logic. The System Filter Status is set to FILTER_FRAME and NextCriterialndex is set to zero for every configured filter channel prior to the start of frame processing and after each frame is processed (at 124 in Fig. 11) . Referring now to the overall system filter channel control structure shown in Fig. 10, and using the filter expression shown below as an example: if ((the Ethernet Dst Vendor Address is OxOδFFFF AND the Ethernet Dst Station Address is 0x334455) OR (the GP Frame Type is 1 OR the GP Frame Type is 2) ) keep this network frame we can divide the expression into three distinct filter criteria: (0) if the Ethernet Dst Vendor Address is OxOΘFFFF (1) if the Ethernet Dst Station Address is 0x334455 (2) if the GP Frame Type is 1 OR the GP Frame Type is 2 Fig. 10(a) shows an example Filter channel structure for the expression shown above and refers to the three Filter Criteria Records of Fig. 10(b) that implement the three filter criteria shown above and refer respectively to Figs. 10(c) , 10(d) and 10(e) which implement the three criteria as lookup structures. Referring now to Fig. 15, after the ApplyFilter control logic is entered (at 400) , the Index of one of the filter criteria records shown in Fig. 10(b) is computed with NextCriterialndex (at 402 and 404) for the associated filter channel shown in Fig. 10(a) . If Index is less than NextCriterialndex (at 402) it indicates that this filter criteria does not need to be evaluated. This may occur because a filter channel has been satisfied and NextCriterialndex has been set to TotalCriteria to disable further filter processing. If Index is greater than NextCriterialndex (at 404) this indicates that a filter criteria was skipped in the evaluation of this filter channel which invalidates the filter result. In this case, further filter evaluation is disabled (at 414) by setting NextCriterialndex to TotalCriteria and ApplyFilter returns to the caller . If Index and NextCriterialndex are equal, the field value is found (at 406) in the associated lookup table, NextCriterialndex is updated with the associated Nextlndex value and if the associated return value status is PASS_FRAME, the System Filter Status is updated to PASS_FRAME. In this preferred embodiment, the range of possible values for a field must be fully covered. Similarly, in the preferred embodiment a frame W:L11 be completely parsed for statistics gathering. Criteria (0) cannot be used to determine a PASS/FILTER_FRAME result for the filter expression above because it must be logically AND'ed with criteria (1) . This is illustrated in Fig. 10b, where every value results in no change to the status. The logical AND with criteria (1) is implemented using the Nextlndex value. If criteria (0) is FALSE then Nextlndex is 2 which causes criteria (1) to be skipped, otherwise Nextlndex is 1. Criteria (1) when TRUE can be used to determine that the filter expression is TRUE because it is not evaluated unless criteria (0) is also TRUE, and the filter expression is the result of ((0) and (1)) or (2] . If criteria (2) is FALSE then a PASS/FILTER_FRAME result cannot be determined for the filter expression. This is illustrated by Fig. 10c, where the criteria value results in a PASS_FRAME status, and every other value results in no change to the status. The filter expression Count value is reset on completion of frame processing. Criteria (2) when TRUE can be used to determine that the filter expression is TRUE because it is logically OR'ed with the result of the first two criteria. It should be noted that the system of the present invention will collect statistics on all fields evaluated regardless of the decision to pass or filter the frame, which may not be acceptable in some instances. It will be appreciated by those skilled in the art that the system of the present invention may be implemented as sequential parsing loops, so that filtering decisions may be made prior to the application of statistics or other field operations. It will be appreciated by those skilled in the art that the system of the present invention offers significant advantages over traditional filtering methods by allowing filtering criteria to be specified for any subset of bits in any field, by allowing criteria to be applied to every instance of a field that appears more than once in a network frame, and by providing a simple method for easily specifying ranges of values. Returning again to Fig. 13 after applying a filter criteria, the extracted value is processed by the ValidateValue control logic (at 214) , which updates the NextProtocol and CurField variables and returns a valid/invalid value indication. If ValidateValue returns invalid, parsing of the current field stops (at 216) and restarts with the updated CurField value (at 204) , otherwise each configured parsing operation is applied based on the extracted value. The statistics entity of the field sub-record may be used to indicate categories of statistics to be maintained for each protocol header field (at 218 and 236) . Details about mechanisms for collecting statistics are not relevant to the present discussion. However, it will be appreciated by those skilled in the art that the addition of various classes of statistics such as field counters, summing of field contents, and arrays of counters/sums based on field contents may be used in accordance w:.th the present invention. Using Fig. 5a as an example, it would be possible to configure the FrameLength field to accumulate an array of counts for each possible field value. From this array, the distribution of GP frames sizes is immediately available, and the length of all GP frames and each frame size may be computed. Although checksum verification/computation (at 217 and 235) and route determination capabilities (at 219 and 237) are not described in detail in Fig. 13, those skilled in the art will recognize that a system in accordance with the present invention may be configured easily to implement those capabilities. Further, exemplary software listings for implementing these capabilities are provided in the Appendix which is attached hereto and incorporated herein by reference. Moreover, upon review the listings in the Appendix entitled csum.asm, checksum.hpp, route.cpp and route.hpp, those skilled in the art will appreciate that the ability to configure IP, TCP, UDP and IPX checksum capabilities may readily be incorporated into a system in accordance with the present invention. The same is true for a general purpose 16 bit ones complement checksum capability. Finally, those skilled in t.he art will appreciate that the system of the present invention may be configured in virtually infinite ways to implement virtually any desired checksum capability or, indeed, any desired data manipulation function. Although in the preferred form the Verify checksum control logic is integrated into the ParseFields control logic (at 217 and 235) , the result is not used ecause processing of frames with bad checksums is device dependent. For example, frames with bad checksums would be counted and saved by a protocol analyzer, while a routing device would count and discard them. An ability to route frames based on values contained in fields of up to 96 contiguous bits is also demonstrated in the software listings included in the Appendix, and those skilled in the art will recognize that the 96 bit limit may be changed easily to allow for proper handling of protocols with route determination fields longer than 96 bits. Moreover, those skilled in the art with appreciate that the system of the present invention may be augmented to support virtually any field based operations through modification of the ParseFields control logic loop (at 204-224) . For example, it is believed that field based encryption and decryption operations may be added to the system of the present invention with minimal effort. The HeaderLength field of a protocol description sub- record when non-zero is used to indicate that the extracted value of the current field may be used to compute the length of the current protocol header. The extracted value when multiplied with the configured HeaderLength field value yields the length of the protocol header in the current network frame (at 238) . The HeaderLength field is configured to be 32 for the FrameLength field of the GP description shown in Fig. 5a. If HeaderLength is used together with the HeaderLen value extracted from frame (2) , an actual GP header length of 224 bits (32 * 7) is calculated. Because the fields defined in Fig. 5a add up to only 160 bits, it will then be possible to determine that the (224 - 160) or 64 bits of optional fields exist in frame (2) . For each field with a valid value, the BitLength field is added to ProtoParseLen, the number of bits parsed in the current protocol, and ParseLen, the number of bits parsed in the network frame (at 222) . The FrameLength field of a protocol description sub- record when non-zero is used to indicate that the extracted value of the current field may be used to compute the length of the current network frame. The extracted value when multiplied with the configured FrameLength value yields the number of meaningful bits in the current frame (at 240) . The FrameLength field is configured to be 8 for the FrameLength field of the GP description shown in Fig. 5a. If FrameLength is used together with the FrameLen value extracted from frame (1) , an actual frame length of 336 bits is calculated (8 * 42) . Because the hardware length of frame (1) is 480 bits (8 * 60 bytes) , it is now possible to determine that the last ( (480-366) bits) of frame (2) is pad, added to the frame in this case, to achieve the required Ethernet minimum length of (8 * 60 bytes) . In a preferred form, the length computed for the frame is verified against the length provided by the hardware, and the minimum of the two values is be used as FrameLen. If every field in the current protocol has been parsed (at 206) , or every bit in the current protocol header has been parsed (at 208) , or every bit :.n the current frame has been parsed (at 209) , parsing of the current protocol terminates. If LocalProto is NULL (at 225) when parsing of the current protocol terminates, ParseProtoLen is added to ParsePtr (at 228) so that it points to the start of the next protocol header in the frame. If LocalProto is not NULL (at 225) when parsing of the current protocol terminates and there are unparsed header bits remaining (at 226) , ParseLen and ProtoParseLen are adjusted to account for each unparsed header bit (at 227) before adding ProtoParseLen to ParsePtr (at 226) . In every case, ParseFields control logic returns LocalProto (at 230) . Referring now to Fig. 11, the ParseFrame control logic of the present invention, network frames are composed of one or more protocol headers which in turn are composed of one or more predefined contiguous bit fields. The ParseFrame control logic systematically parses t.hrough each network frame (at 104 to 108 and 128) until all known protocol headers have been parsed. Any remaining frame bits are parsed as application data (at 110, 112 and 130) and/or pad data (at 114, 116 and 132) . Referring now to Fig. 12, ParseProtocol control logic where all fixed and optional protocol fields are parsed is entered (at 200) with ParsePtr and ParseLen initialized from prior processing. All protocol fields that are fixed in location are parsed (at 152) . If all bits in the frame are parsed (at 154) after parsing fixed fields, frame parsing is complete and ParseProtocol returns NULL (at 168) . If there are more bits in the frame to parse and the current protocol description supports optional fields (at 156) and the current frame contains optional fields (at 160) they are parsed (at 160 to 166) using the current protocol option control protocol description as a starting point (at 158) . Once all options are parsed (at 172) ParseProtocol will return NULL (at 168) if all bits in the frame have been parsed or will return LocalProto (at 170) if more bits remain to be parsed. Referring again to Fig. 11, once the system has received a network frame (at 100) , defined by an interface number (Srclntf) , a frame location (FramePtr) and a hardware length (HwLen) , the frame is resolved into its protocol and field components using the system of the present invention. Using the exemplary frame, "Frame (2) , " described above as an example, the system (at 102) in Fig. 11 would obtain from the receiving network interface device Srclntf, the receiving interface number, FramePtr, a pointer to the frame, and HwLen, the hardware frame length. The hardware length of frame (2) is 480 bits. ParseLen, the number of bits in the frame that have been parsed, ParseLvl and CurField, the index of the protocol field being processed are reset to zero, and CurrentProtocol, is set up with the initial protocol description structure of the receiving interface number which for frame (2) is the Ethernet Protocol description defined in Figs. 4 - 4d. FrameLen is set to the value of HwLen, and ParsePtr is set to the value of FramePtr. Each field in the Ethernet Protocol description as shown in Fig. 4a is parsed (at 106) using the ParseProtocol control logic shown in Fig. 13. The ParseProtocol control logic updates ProtoParseLen, the number of bits parsed in the CurrentProtocol, HeaderLen, the protocol header size determined during parsing, and returns NextProtocol, a reference to the next applicable protocol description structure to use during parsing. ParseProtocol also updates ParsePtr and ParseLen by adding ProtoParseLen to them. If NextProtocol is NULL, the remaining frame bits will be treated as Data and/or Pad bits. After the Ethernet protocol fields in frame (2) are parsed (at 106) by the ParseProtocol control logic shown in Fig. 13, HeaderLen, ParseLen and ProtoParseLen will be 112 bits, NextProtocol will refer to the GP shown in Figs. 5-5 (e) , and ParsePtr will point at the start of line 2 in frame (2) . CurrentProtocol will be updated with the NextProtocol value of GP (at 130) and the GP fields in frame (2) are parsed (at 106) by the ParseFields control logic shown in Fig. 13, which will update HeaderLen and ProtoParseLen to be 160 bits, and return NextProtocol as NULL. ParsePtr will point at the start of line 3 in frame (2) , and ParseLen will be updated to 272 bits. Referring now to Fig. 12, if a CurrentProtocol such as GP shown in Figs. 5 - 5e supports optional fields, which is indicated by the Options field of the control record, then any options in the network frame are sequentially parsed (at 160 - 166) using the ParseFields control logic (at 164) until ProtoParseLen, the number of bits parsed in the protocol header is equal to HeaderLen, the protocol header size determined during parsing with the original protocol description (at 152) . Using the exemplary frame, "Frame (2) , " described above as an example, after the GP fields are parsed (at 152) , HeaderLen will be updated to 224 bits, while ProtoParseLen will be updated to 160 bits, which indicates the presence of (224 - 160) bits of optional fields (at 160) . Every protocol description with optional fields will have a master protocol option description, and one option protocol description for each supported option. Using the GP protocol control record shown in Fig. 5 as an example of how optional fields might be described, the Options field will refer to a master option control record similar to Fig. 6. The master option control record will contain one field (see Fig. 6a) that does not contribute to the number of bits parsed (BitLength zero) with an associated lookup structure (see Fig. 6b) for each possible option. Using Fig. 6b as an example, each defined option refers to an appropriate protocol option description. The first field of each option description has an associated lookup structure (see Figs. 7b, 8b, and 9b) that refers back to the master option control record. Fig. 9a shows how optional fields with variable length may be handled by computing the frame length. Referring now to Fig. 13, in a preferred form the Option Type field in a frame is examined twice, once with the master protocol option description and once with the appropriate option protocol description. If an unknown option is encountered (any value between 0x03 and Oxff inclusive for Fig. 6b) , ParseLen, ProtoParseLen, and ParsePtr are updated (at 227 in Fig. 13) to skip any remaining options and parsing of the frame continues with the LocalProto protocol description returned (at 230) . Referring again to Fig. 12, and using the GP control record shown in Fig. 4 as an example, the system would determine (at 156) that the CurrentProtocol supports options and (at 158) will update CurrentProtocol to the master option descriptor of Fig. 6. The master option control record has one field shown in Fig. 6a, which is used to select the appropriate option protocol description structure to use. The lookup structure shown in Fig. 6b allows option descriptions to be associated with option type values extracted from network frames. The system (at 160-166) will parse one option at a time in the current network frame until all options are parsed. Before each option is parsed, the number o!: bits parsed using the previous option protocol control record is subtracted from HeaderLen (at 162) . The ParseFields control logic is alternately processed (at 164) with the master protocol option control record, and an appropriate option control record. The CurrentProtocol is updated (at 166) with the NextOption value returned by ParseFields, and the loop is re-entered (at 160) . Using the exemplary frame, "Frame (2) ," described above as an example with ParsePtr pointing at line 3, and CurrentProtocol pointing at the GP master option description shown in Fig. 6, it may be seen how a NumBits value of zero prevents the master option description from contributing to the number of bits parsed (at 162) , and how ParseFields and ValidateValue use the master option description field to select an appropriate GP option description structure from the lookup structure of Fig. 6b. For frame (2) , the first option byte at line 3 contains value 1, which causes the GP NoOp option description structure shown in Fig. 8 to be selected (at 166) . The NoOp NumBits value of 8 is added to ProtoParseLen (at 162) , and the single field defined in Fig. 8a is parsed at 164. In a preferred form, each option description structure must have a field with an associated lookup structure that is always processed and refers back to the master option description structure. Thus, for "frame (2)" the option processing control loop (at 160 through 166) is alternately applied w:.th the description structures of Fig. 6 and Figs. 8, 9, and 7. The GP End Of List Option does not refer back to the master option description because it indicates an end to option processing. Any remaining option bits are .assumed to be pad and are disregarded so that the check for more options (at 160 in Fig. 12) will fail and return to frame protocol parsing (at 108 in Fig. 11) . Once all options have been parsed in frame (2) or the system (at 160) determines that the current frame has no optional fields as in frame (1) , the system control logic (at 168 or 170) will return to the main parsing loop (at 108 in Fig. 11) . While the invention of this application is susceptible to various modifications and alternative forms, specific examples thereof have been shown in the drawings and are herein described in detail. It should be understood, however, that the invention is not to be limited to the particular forms or methods disclosed, but to the contrary, the invention is to cover all modifications, equivalents, and alternatives falling within the spirit and scope of the appended claims. Appendix The following software was developed using the Watcom C/C++ 10.0 Multi-Platform 16- and 32-bit Development System. The following files are included: csum.asm data.cpp decode .cpp filter.cpp lookup.cpp main.cpp nxtptl .cpp pcols.cpp popfile.cpp stat .cpp xmit.cpp checksum.hpp decode .hpp filter.hpp gen.hpp lookup.hpp pa.hpp pcols.hpp route.hpp stat .hpp xmit.hpp / CSUM.ASM .586 _TEXT segment dword public 'CODE' _TEXT ends DATA segment word public 'DATA' Mask values for extracting 1, 2, or 3 misaligning bytes at the front of the requested checksum calculation so that the remaining quadword accesses will be quadword aligned PreMask:DD OOOOOOOOOH ; Address & 3 - - 0 is quadword alignedfnot used) DD OffffffOOH ; Address & 3 - = 1 Mask 3 bytes to next quadword DD OffffOOOOH ; Address & 3 - - 2 Mask 3 bytes to next quadword DD OffOOOOOOH ; Address & 3 - = 3 Mask 3 bytes to next quadword Table to convert low 2 bits of starting address into number of bytes of quadword misalignment Adjust: DD 0 ; Address & 3 - = 0 is quadword alignedfnot used) DD 3 Address & 3 - = 1 has 3 bytes to next quadword DD 2 Address & 3 - = 2 has 2 bytes to next quadword DD 1 Address & 3 - = 3 has 2 bytes to next quadword Table to extract 1, 2, or 3 bytes from non-quadword multiple checksum lengths Maskit: DD 0 ; Length is a multiple of 4 (not used) DD OOOOOOff H ; Length is a multiple of 4 plus 1 DD OOOOffffH ; Length is a multiple of 4 plus 2 DD OOffffffH ; Length is a multiple of 4 plus 3 Jump Table for entering checksum loop with number not a multiple of 256 bytes DGROUP group _DATA TEXT segment dword public 'CODE' assume CS:_TEXT assume DS:DGROUP unsigned short csumPseudo(U32 ChkSum, U32 *lpHdr) parameters - Sum of IP data (i.e. TCP/UDP header and data) - pointer to start of associated IP header returns - 16 bit ones complement of the ones complement sum of the IP pseudo header, and IP data public csumPseudo_ csumPseudo_ proc near push ecx push ebx mov cx,+08H[edx] ; extract TTL and Protocol fields mov ebx,+OOH[edx] ; extract Version, HdLen, TOS, TotalLen fields and ecx,OffOOH ; isolate Protocol field (remove TTL) shl bx, + OcH ; isolate HdLen field (remove Version, TOS) shr bx, + 02H ; convert HdLen to byte count in bh not bx ; invert Hdlen bits to subtract from TotalLen add eax.ebx ; add TotalLen, subtract HdLen fields adc eax,ecx ; add Protocol field with carry adc eax,+OcH[edx] ; add Source Address with carry adc eax, + 1 OHfedx] ; add Destination Address with carry adc ax,0 ; add final carry mov ebx, eax shr eax, 16 add ax,bx ; add upper and lower 16 bit values together adc ax,0 ; add any resulting carry not ax ; return ones complement of sum pop ebx pop ecx ret csumPseudo endp unsigned short csumBytesfunsigned long *pktptr, unsigned long iplen); parameter ■ pointer to associated IP header (should be passed in EAX) returns - 16 bit ones complement sum of specified bytes public csumBytes_ csumBytes_ proc near ; ebx - pktptr ; sum - 0; ; Is data aligned on DWORD ? ; go to next lowest DWORD ; get previous quadword mov ecx,PreMask[ebp*4] ; extraction Mask for misaligned bytes sub edx,Adjust[ebp*4] ; subtract misaligning bytes from length and eax,ecx ; Mask out unnecessary bytes add ebx,4 ; go to next DWORD for regular processing Aligned ush ebp ; save number of bits to roll result left mov esi.edx ; length = edx shr esi,02H ; dlen - esi = length/4 Lswitch:xor ebp,ebp ; Clear initial register for checksum cmp esι,00000040H ; if (dlen < 64) jae L64 ; (switch default case) xor ecx.ecx ; Clear Checksum Registers... xor edi,edi ; and... lea ebx,|ebx+esi*41 ; pkt + = fdlen - 64) sub ebx, + 100H jmp dword ptr lndex[esi * 4] ; switchfdlen) L64: mov ecx,[ebx] ; sum + = *(pkt+0) adc eax.ebp L63: mov edi, +4H[ebx] ; sum + = *(pkt+ 1) adc eax,ecx L62: mov ebp, + 8H[ebx] ; sum + = *fpkt+ 2) adc eax, edi L61: mov ecx,+OcH[ebx] ;sum + - *(pkt+3) adc eax,ebp L60: mov edi, + 10H[ebx) ;sum +- *fpkt+4) adc eax,ecx L59: mov ebp, + 14H[ebx] ; sum + = *(pkt+5) adc eax,edi L58: mov ecx,+ 18HIebx] ;sum += *(pkt+6) adc eax,ebp L57: mov edi, + 1cH(ebx] ;sum +- *(pkt+7) adc eax.ecx L56: mov ebp,+20H[ebx] ;sum += *(pkt+8) adc eax,edi L55: mov ecx, + 24H[ebx] ;su + = *(pkt+9) adc eax,ebp L54: mov edi, + 28H[ebx] ;sum +- *(pkt+10) adc eax.ecx L53: mov ebp, + 2cH[ebx] ; sum + = * (pkt +11) adc eax.edi L52: mov ecx, + 30H[ebx] ;sum +- *(pkt+12) adc eax,ebp L51 : mov edi, + 34H[ebx) ; sum + - * (pkt + 13) adc eax.ecx L50: mov ebp,+38H|ebxl ;sum +- • (pkt+14) adc eax,edi L49: mov ecx,+3cH[ebx] ;sum += *(pkt+15) adc eax,ebp L48: mov edi,+40Hlebx] ;sum +- *(pkt+16) adc eax,ecx L47: mov ebp,+44H[ebx] ;sum += *(pkt+17) adc eax,edi L46: mov ecx,+48H[ebx) ;sum +- *(pkt+18) adc eax,ebp L45: mov edi,+4cH[ebx] ;sum += *(pkt+19) adc eax,ecx L44: mov ebp, + 50H[ebx] ;sum += *(pkt+20) adc eax.edi L43: mov ecx, + 54H[ebx] ;sum += *(pkt+21) adc eax.ebp L42: mov edi, + 58H[ebx] ;sum += *(pkt+22) adc eax, ecx L41: mov ebp, + 5cHIebx] ;sum += *(pkt+23) adc eax,edi L40: mov ecx, + 60H(ebx] ; sum += *(pkt+24) adc eax,ebp L39: mov edi,+64H[ebx) ;sum + - *fρkt+25) adc eax.ecx L38: mov ebp, + 68H[ebx] ;sum + « *(pkt+26) adc eax,edi L37: mov ecx, + 6cH[ebx] ;sum += *(pkt+27) adc eax,ebp L36: mov edi, + 70H[ebx] ;sum +- *(pkt+28) adc eax,ecx L35: mov ebp, + 74H[ebx] ;sum += *(pkt+29) adc eax,edi L34: mov ecx, + 78H[ebx] ;sum += *(pkt+30) adc eax.ebp L33: mov edi, + 7cH[ebx] ; sum +- *(pkt+31) adc eax,ecx L32: mov ebp, + 80H[ebx] ;sum += *(pkt+32) adc eax,edi L31: mov ecx, + 84H[ebx] ;sum += *(pkt+33) adc eax.ebp L30: mov edi, + 88H[ebx] ;sum +- *(pkt+34) adc eax,ecx L29: mov ebp, + 8cH[ebxj ;sum + - *(pkt+35) adc eax,edi L28: mov ecx, + 90H[ebx] ;sum +- *(pkt+36) adc eax.ebp L27: mov edi, + 94H[ebx] ; sum + - *(pkt+37) adc eax,ecx L26: mov ebp, + 98H[ebx] ;sum += *(pkt+38) adc eax,edi L25: mov ecx, + 9cH[ebx) ;sum + - *(pkt+39) adc eax,ebp L24: mov edi, + OaOH[ebx] ;sum + = * (pkt+40) adc eax,ecx L23: mov ebp,+0a4H[ebxl ;sum += *(pkt+41) adc eax.edi L22: mov ecx, + 0a8H[ebx] ;sum + = *(pkt+42) adc eax,ebp L21: mov edi, + 0acHlebx] ;sum +- *(pkt+43) adc eax,ecx L20: mov ebp,+ObOH[ebx] ; sum +- *(pkt+44) adc eax,edi L19: mov ecx, + 0b4H[ebx] ;sum += *(pkt+45) adc eax,ebp L18: mov edi,+0b8H[ebx] ;sum += *(pkt+46) adc eax,ecx L17: mov ebp,+ObcH[ebx] ;sum +- *(pkt+47) adc eax.edi L16: mov ecx,+OcOH|ebx] ;sum += *(pkt+48) adc eax,ebp L15: mov edi, + 0c4H[ebx] ; sum + = *(pkt+49) adc eax.ecx L14: mov ebp, + 0c8Hlebx] ;sum += *(pkt+50) adc eax,edi L13: mov ecx, + OccH[ebx] ;sum + - *(pkt+51) adc eax,ebp L12: mov edi,+OdOH|ebx] ;sum +- *(pkt+52) adc eax.ecx L11: mov ebp,+0d4H[ebx] ; sum +- *(pkt+53) adc eax, edi L10: mov ecx,+0d8HIebx] ;sum += *(pkt+54) adc eax,ebp L09: mov edi, + OdcHlebx] ;sum + - *(pkt+55) adc eax.ecx L08: mov ebp, + OeOH[ebx] ;su += *(pkt+56) adc eax,edi L07: mov ecx, + 0e4H[ebx] ;sum +- *(pkt+57) adc eax,ebp L06: mov edi,+0e8H[ebx] ;sum += *(pkt+58) adc eax,ecx L05: mov ebp,+0ecH[ebx] ; sum + - *(pkt+ 59) adc eax.edi L04: mov ecx, + OfOH[ebx] ; sum + - *(pkt+60) adc eax,ebp L03: mov edi, + Of4H[ebx] ; sum + = *(pkt+61) adc eax,ecx L02: mov ebp,+0f8H[ebx] ; sum + = * (pkt +62) adc eax,edi L01: mov ecx,+0fcH[ebx] ; sum + - *(pkt+ 63) adc eax,ebp adc eax,ecx adc eax.O LOO: add ebx, + 10OH ; pktptr + = 256 bytes sub esi, +40H ; dlen — 64 quadwords jg Lswitch ; if more quadwords ... go checksum them and edx, + 3H ; len &- 3 je Finish ; if len is multiple of quadwords mov edi,[ebx] ; get following quadword and edi,Maskit[edx*4] ; 'pktptr &- Maskit[len&3] add eax,edi ; add leftover bytes to checksum adc eax.O Finish: pop ecx ; retrieve number of misalignment bytes shl ecx, 3 ; convert to bits jz NoRoll ; if was not misaligned ror eax,cl ; roll checksum by misalignment bits NoRoll: mov ecx,eax shr eax, 16 add ax,cx ; add upper and lower 16 bit values adc ax,0 ; returπ(sum) (not ones complement) Lret: pop ebp pop edi pop esi pop ecx pop ebx ret csumBytes_ endp TEXT ends end // DATA.CPP 'include "gen.hpp" U32 ParseLevel; WCValVector< S8 * > ParseList(20); S8 * FramePtr, "ParsePtr; U32 HwLen, FrameLen, ParseLen, ProtoParseLen, HeaderLen; U32 Srclntf -0, lntfTypes[256] - {ETHERNET, FDDI, TOKEN RING}; RouteTableEntry 'RtePtr; Filters CfgFilters; // Configured Filters Object II II Lookup table for bit-swapping a byte value II II S8 bs[256] - // Table to perform bit-swapping { 0x00 r 0x80,0x40,0xc0,0x20,0xa0,0x60,0xe0,0x 10,0x90,0x50,0xd0,0x30,0xbO,0x70,0x fO, 0x08,0x88,0x48,0xc8,0x28,0xa8,0x68,0xe8,0x18,0x98,0x58,0xd8,0x38,0xb8,0x78,0)f8, Ox04,0x84,0x44,0xc4,0x24,0xa4,0x64,0xe4,0x14,0x94,0x54,0xd4,0x34,0xb4,0x74,0>f4, 0x0c,0x8c,0x4c,0xcc,0x2c,0xac,0x6c r 0xec,0x1c,0x9c,0x5c,0xdc,0x3c,0xbc,0x7c,0xfc, 0x02,0x82,0x42,0xc2,0x22,0xa2,0x62,0xe2,0x 12,0x92,0x52,0xd2,0x32,0xb2,0x72,0):f 2, 0x0a,0x8a,0x4a,0xca,0x2a,0xaa,0x6a,0xea,0x1a,0x9a,0x5a,0xda,0x3a,0xba,0x7a,0xfϊi, 0x06,0x86,0x46,0xc6,0x26,0xa6,0x66,0xe6,0x16,0x96,0x56,0xd6,0x36,0xb6,0x76,0::f6 r 0x0e,0x8e,0x4e,0xce,0x2e,0xae r 0x6e,0xee,0x1e,0x9e,0x5e,0xde,0x3e,0xbe,0x7e,0xfe, 0x01,0x81,0x41,0xc1,0x21,0xa1,0x61,0xe1,0x11,0x91,0x51,0xd1,0x31,0xb1,0x71,0:tf1, 0x09,0x89,0x49,0xc9,0x29,0xa9,0x69,0xe9,0x 19,0x99,0x59,0xd9,0x39,0xb9,0x79,0:(f 9, 0x05,0x85,0x45,0xc5,0x25,0xa5,0x65,0xe5,0x15,0x95,0x55,0xd5,0x35,0xb5,0x75,0:<f5, 0x0d,0x8d,0x4d,0xcd,0x2d,0xad,0x6d,0xed,0x1d,0x9d,0x5d,0xdd,0x3d,0xbd,0x7d,0xfιi, 0x03,0x83,0x43,0xc3,0x23,0xa3,0x63,0xe3,0x 13,0x93,0x53,0xd3,0x33,0xb3,0x73,0 <f 3, 0x0b,0x8b,0x4b,0xcb,0x2b,0xab,0x6b,0xeb,0x1b,0x9b,0x5b,0xdb,0x3b,0xbb,0x7b,0xfb, 0x07,0x87,0x47,0xc7,0x27,0xa7,0x67,0xe7,0x17,0x97,0x57,0xd7,0x37,0xb7,0x77,0xf7, 0x0f,0x8f,0x4f,0xcf,0x2f,0xaf,0x6f,0xef,0x1f,0x9f,0x5f,0xdf,0x3f,0xbf,0x7f,0xff }; DEC0DE.CPP ^include "gen.hpp" extern HDC hdc ; int datalines-O; int padlines-O; void protocol::add_field_after(U32 idx, protocol *ptl) { field 'tmpfs - fs; + +num_fields; fs = new field[num_fields]; field f((U16)tmpfs[idxj.offset(), (U8)tmpfs[idx].shlbits(), (U8)tmpfs[idx].shrbits{)); numbits(numbits()+ f.bitlenf)); for (U32 i=0; i < -idx; i+ +) { fs[i] - tmpfsD]; if (fs[i].lookptr()) fslij.lookptrO- > incjndexfidx); } fs[idx + 1] - f; if (f s[idx + 1 J.lookptrO) fs[idx + 1 j.lookptrf)- > incjndexfidx); U32 actualoff, off - fs[idx+ 1].bitoffsetf) + f.bitlenf); actualoff - of f & ( — 31); fs[idx+ 1].offset(fU16)(actualoff/8)); fsfidx + 1 ].shlbits((U8)(of f • actualoff)); fs[idx + 1].shrbits((U8){32 - f.bitlen())); if fnum ields > (idx + 2)) { for (i - idx + 2; i < num f ields; i + + ) { fs[i] = tmpfs[M]; if (fs[i].lookptr()) fs[i].lookptr()- > incjndexfidx); off - fs[i].bitoffset() + f.bitlenf); actualoff - off & ( ~ 31); fs[i].offset((U16)(actualoff,8)); fs[i].shlbits((U8)(off - actualoff)); fs[i].shrbits((U8)(32 ■ fs[i].bitlenf»); } } if (num fields < - 2) delete tmpfs; else deletelltmpfs; ptl-ptl; II for the compiler } // Add a protocol field via ptl dialog box insert: Before key // void protocoi::add_field(U32 idx, protocol *ptl) { field * tmpfs - fs; + +num_f ields; fs - new field[num_fields]; field f(tmpfs[idx].offset(), (U8)tmpfs[idx].shlbits(), (U8)tmpfs[idx].shrbits()); numbitsfptl- > numbitsf) + f.bitlenf)); for (U32 i-0; i < idx; i+ +) { fs[ij = tmpfs[i]; if (fs[i].lookptr()) fs[i].lookptr()- > incjndexfidx); } fsfidx] - f; if (fs[i].lookptr{)) fsljj.lookptrf)- > incjndexfidx); f or (i = idx + 1 ; i < num f ields; i + + ) { fs[i] - tmpfs[i-1]; if (fs[i].lookptr()) fslij.lookptrf)- > incjndexfidx); U32 actualoff, off - fslij.bitoffsetf) + f.bitlenf); actualoff = off & ( - 31); fs[i].offset((U16)(actualoff/8)); fs[i].shlbits((U8)(off • actualoff)); fs[i].shrbits((U8)(32 - fs[i].bitlen(»); } if (num f ields < = 2) delete tmpfs; else delete[]tmpfs; ptl-ptl; } // Delete a protocol field via nxtpti dialog box delete key // void protocol::delete _field(U32 idx, protocol *ptl) { field *tmpfs - fs; • num fields; fs - new field[num_fields]; numbitsfnumbitsf) - tmpfs(idx).bitlenθ); U32 tmpfsidxbitlen - tmpfs[idx].bitleπ(); U32 noadjust - 0; for (U32 i=0; i < num fields; i+ + ) { if (ϋ - idx) { if f (tmpfs[il.bitlen() - = tmpfs[idx].bitlen()) && (tmpfsfjl.offsetO = = tmpfs[idx].offset()) && (tmpfs[i].shlbits{) = = tmpfs[idx].shlbits()) && (tmpfslij.shrbitsf) - - tmpfslidxj.shrbitsf)) ) { noadjust = TRUE; break; } } } // ON DECJNDEX: IF LAST FIELD IS BEING DELETED, POINT TO WHAT? f or (i - 0; (i < idx && i < numj ields) ; i + + ) { if (tmpfs[i].lookptr()) tmpfs[i].lookptr()- > dec indexfidx); fs[i] ■ = tmpfs[i]; } if (idx ! -num_fields) for (i-idx; i < num_fields; i+ +) { fs[i] - tmpfs[i + 1]; if (fs[i].lookptrO) fs(ij.lookptrf)- > decjndexfidx); if (Inoadjust) { U32 actualoff, off - tmpfs[i+ Ij.bitoffsetO - tmpfsidxbitlen; actualoff - off & ( - 31); fs[i].offset((U16)(actualoff|8)); fs[i].shlbits((U8)(off - actualoff)); fs[i].shrbits((U8)(32 - fs[i].bitlen())); } } if (num fields < - 2) delete tmpfs; else deleteljtmpfs; cur field = U16(idx- -0 ? 0 : idx-1); II NEED to free memory for the one that's deleted ptl-ptl; } r * Get protocol information from file •/ void protocol::get_from_file(FILE *fp) { // What to do about file name ??? fread(&num_bits, sizeoffnum bits), 1, fp); // Read fixed header length in bits freadf&num f ields, sizeoffnum fields), 1, fp); // Read number of fields in protocol description freadf&cur field, sizeoffcur field), 1, fp); II Read index of last field displayed during configuration cur field - minfcur field, (U16)(πum elds-1)); freadf&dbW, sizeoffdbW), 1, fp); // Read value of last requested display width in bits out flag - 0; fs = new fieldfnum fields]; for (U32 i - 0; i < num f ields; i + + ) fs[i].get_from ϊle{fp); if (dbW < 8) dbW - 8; if (dbW > 112) dbW - 112; l/ TMP TMP TMP TMP TMP !!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!! // // Setup option pointer if any configured II U32 tmp; freadf&tmp, sizeofftmp), 1, fp); if ftmp ! - 0) { char name - new charjtmp]; freadftname, tmp, l, fp); protocols pftname, 0), t; // Reads name length and name ProtocolList- > findfp, t); opts - t.protf); } else opts - 0; } S32 xL, xR, yT-0, yB; static S32 bitWidth, rowHeight; extern S32 cxClient, cyClient, cxChar, cyChar, nVscrollPos, nPaintBeg, nPaintEπd; void protocol::setupOutlineCoords() { S32 protHeight, protWidth, numRows; protWidth - (cxClient/dbW - 1 )*dbW; // Width in pixels of protocol header bitWidth = protWidth/dbW; // Width of 1 bit of header in pixels protWidth - bitWidth *dbW; // make protWidth an even multiple of bits numRows - (num bits + dbW - 1 )/dbW; // Number of rows in protocol header + 1 for Title rowHeight - cyChar*2 + 1; // Height of 1 header row in pixels protHeight - πumRows*rowHeight; // Height in pixels of protocol header xL - (cxClient - protWidth)/2; // Leftmost position of protocol header xR = xL + protWidth + 1; // Rightost position of protocol header yT - nPaintBeg + rowHeight/2; // Topmost position of protocol header vB = yT + protHeight + 1; // Lowermost position of protocol header } r S32 AxL, AxR, AyT=0, AyB; static S32 AbitWidth; void protocol::setupOutlineCoordsMult{int continu) { S32 protHeight, protWidth, numRows; char buffer[4j; // protWidth - (cxClient/dbW - 1)*dbW; // Width in pixels of protocol header protWidth - 3*(cxClient/dbW - 1)*dbW/4; // Width in pixels of protocol header AbitWidth - protWidth/dbW; // Width of 1 bit of header in pixels protWidth - AbitWidth'dbW; // make protWidth an even multiple of bits numRows - (num_bits + dbW • 1 )/dbW; // Number of rows in protocol header + I for Title rowHeight - cyChar*2 + 1; // Height of 1 header row in pixels protHeight - numRows*rowHeight; // Height in pixels of protocol header AxL = (cxClient - protWidth)/2; // Leftmost position of protocol header AxR - AxL + protWidth + 1; // Rightost position of protocol header if (continu) AyT-AyB; else AyT - nPaintBeg nVscrollPos; // + rowHeight|2; // Topmost position of protocol header AyB = AyT + protHeight + 1; // Lowermost position of protocol header if ( ((AyT + cyChar) > nPaintBeg) && (datalines < 2)) { TextOutfhdc, WORD(AxL), WORD(fAyT+ cyChar)), //+yB-2*cyChar)/2), (LPCSTR)protocol name, (WORDHπameJength-1 )); // WORDfptI- > pnamelenf); ); AyT + -(3*cy Char); AyB+ =(3*cyChar); } else { TextOutfhdc, W0RD(AxL-3*cxChar), WORDf(AyT+ cyChar)), (LPCSTR)(itoa(datalines,buffer,10)), (WORD)strlen(buffer)); } } void field::OutiiπeField(HDC hdc, protocol # p, U32 dspbW) const { HBRUSH hbr, hbrOld; RECT r; // // Compute top of rectangle defining this field // if (fyB < nPaintBeg) j | (yT > nPaintEnd)) return; // If out off scroll range, return r.top - WORD(((fdwoff*8 + fshl)/dspbW)*rowHeight + yT); II Topmost position of field if (r.top > nPaintEnd) return; r.bottom= WORD(r.top + rowHeight + 1); // Bottommost position of field if (r.bottom < nPaintBeg) return; r.left - WORDffffshk fdwoff *8)%dspbW)*bitWidth + xL); // Leftmost position of field r.right - W0RD((32 - fshr)*bitWidth + r.left + 1 ); // Rightmost position of field // // Draw Rectangle around protocol field; Display Field Name; Display Value // SetBkColorfhdc, (this - - p- > fieldptrfp- > curfieldf))) ? RGB(192,192,192) : RGB(255,255,255)); SetTextColorfhdc, RGB(0,0,0)); hbr - CreateSolidBrushffthis - = p- > fieldptrfp- > curfieldf))) ? RGB(192,192,192) : RGB(255,255,255)); hbrOld - SelectObjectfhdc, hbr); if (r.right < = xR) Rectaπglefhdc, r.left, r.top, r.right, r.bottom); else { S32 tmp = r.right - xR + 1; r.right = (WORD)xR; Rectanglefhdc, r.left, r.top, r.right, r.bottom); + + r.left; + + r.top; -r.bottom; FillRectfhdc, &r, hbr); r.top - r.bottom; if (r.top > nPaintEnd) return; r.bottom = WORDfr.top + rowHeight + 1); if (r.bottom < nPaintBeg) return; r.left - (WORD)xL; r.right = (WORD)(tmp + r.left); Rectanglefhdc, r.left, r.top, r.right, r.bottom); + + r.top; -r.bottom; -r.right; FillRectfhdc, &r, hbr); } SetTextAlignfhdc, TA CENTER); + + r.top; + + .left; - r.bottom; -r.right; if (fname ! - 0) ExtText0ut(hdc, W0RD((r.left+r.right)/2), WORDffr.top + r.bottom-cy Char)l2), ETO CLIPPED, (LPRECT)&r, (LPSTR)fname, (WORD)strlen(fname), (LPINT)O); r * Restore original Brush and release resources */ hbr - SelectObjectfhdc, hbrOld); DeleteObjectfhbr); } void field::OutlineFieldVal(HDC hdc, protocol *p, U32 dspbW, unsigned long val, unsigned char fmat, unsigned long bitwid) const { HBRUSH hbr, hbrOld; RECT r; char buffer[33j; char tbuffer[33j; //TEST //return; p-p; // Compute top of rectangle defining this field // if ((AyB < nPaintBeg) | | (AyT > nPaintEnd)) return; // If out off scroll range, return r.top - WORDffffdwoff *8 + fshl)/dspbW)*rowHeight + AyT); // Topmost position of field if (r.top > nPaintEnd) return; r.bottom- WORDfr.top + rowHeight + 1); // Bottommost position of field if (r.bottom < nPaintBeg) return; r.left = WORD(({fshl+ fdwoff *8)%dspbW)*AbitWidth + AxL); // Leftmost position of field r.right = W0RD((32 - fshr)*AbitWidth + r.left + 1); // Rightmost position of field // // Draw Rectangle around protocol field; Display Field Name; Display Value // //SetBkColorfhdc, (this - - p- > fieldptrfp- > curfieldf))) ? RGB(192,192,192) : RGB(255,255,255)); //SetTextColorfhdc, RGB(0,0,0)); //hbr = CreateSolidBrushffthis — p- > fieldptrfp- > curfieldf))) ? RGB(192,192,192) : RGB(255,255,255}); hbrOld - SeiectObjectfhdc, hbr); if (r.right < - AxR) Rectanglefhdc, r.left, r.top, r.right, r.bottom); else { S32 tmp - r.right - AxR + 1; r.right - (WORD)AxR; Rectanglefhdc, r.left, r.top, r.right, r.bottom); + + r.left; + + r.top; -r.bottom; FillRectfhdc, &r, hbr); r.top = r.bottom; if fr.top > nPaintEnd) return; r.bottom = WORDfr.top + rowHeight + 1); if (r.bottom < nPaintBeg) return; r.left - (WORD)AxL; r.right - (WORD)ftmp + r.left); Rectanglefhdc, r.left, r.top, r.right, r.bottom); + + r.top; -r.bottom; -r.right; FillRectfhdc, &r, hbr); } SetTextAlignfhdc, TA_CENTER); + + r.top; + + r.left; -r.bottom; - r.right; if (fname ! - 0) ExtTextOutfhdc, WORDffr.lef t + r.right)/2), W0RD((r.top+r.bottom-2*cyChar)/2), ETO CLIPPED, (LPRECT)Sr, (LPSTR)fπame, fWORD)strlen(fname), (LPINT)O); ltoa(val,tbuffer,frnat- -= 1 ? 10:16); // All this to get zeros to print - something better?? if ((bitwid+3)/4 > strlenftbuffer)) { strcpyfbuffer, "0 "); for (int i = 1 ; i < (Ibitwid + 3)/4-strlen(tbuf fer)); i + + ) strcpyfstrrchrfbuffer, OVL'W); strcpy(strrchr(buffer, O')+ l, tbuffer); // if (fval - - 0) && // strcpyfstrrchrfbuffer OV VO"); } else strcpyfbuffer, tbuffer); ExtTextOutfhdc, WORDffr.left + r.right)/2), WORD((r.top+r.bottom)/2), // ETO CLIPPED, (LPRECT)&r, (LPSTR)f), (W0RD)(4), (LPINT)O); ETO LIPPED, (LPRECT)&r, (LPSTR)fbuffer), fWORD)fstrlen(buffer)), (LPINT)Ol; /* * Restore original Brush and release resources */ hbr - SelectObjectfhdc, hbrOld); DeleteObjectfhbr); } void protocol::FiπdField(HWND hwnd, U32 x, U32 y) { for (U32 i-0; i < num fields; i+ + ) { if (fslij.FindFfx, y, dbW) && i !- cur ield) { cur field - (U16)i; InvalidateRectfhwnd, NULL, TRUE); return; } } } U32 field::FindF(U32 x, U32 y, U32 dspbW) const { RECT r; r.top - W0RD(((fdwoff*8 + fshl)/dspbW)*rowHeight + yT); // Topmost position of field if (r.top > nPaintEnd) return(FALSE); r.bottom- WORDfr.top + rowHeight + 1); // Bottommost position of field if (r.bottom < nPaintBeg) return(FALSE); r.left - W0RD(((fshl+fdwoff # 8)%dspbW)*bitWidth + xL); // Leftmost position of field r.right - W0RD((32 - fshr)*bitWidth + r.left + 1); // Rightmost position of field returnffx > - r.left) && (x < - r.right) && (y > -r.top) && (y < - r.bottom)); } void protocol-QutlineProtocoffHDC hdc) const { for (U32 i-0; i < num f ields; i+ +) // if (i ! - cur ield && fs[i].bitleπ()) if (i ! - cur field) II && fs|i].bitlen()) fs[i].OutlineField(hdc, (protocol *)this, dbW); fslcur ield].OutlineField(hdc, fprotocol * )thιs, dbW); } r * ** ™ • .....,....♦♦♦ » • » » l * * • » J // Parse Fields static protocol *ParseFields2(protocol *p, U32 &HeaderLen) 5 { protocol * LocalProto -0; field *f, *g; ProtoParseLen - 0; HeaderLen - p- > numbitsf); i o f = g - p- > fieldptrO; for (U32 i - 0; i < p- > numfieldsf) && ProtoParseLen < HeaderLen && ParseLen < FrameLer; f = &g[ij) { 15 // // Retrieve Current Field Value U32 al - f- > get_value(); 20 // If there is a filter criteria associated with the current field... // apply it to the frame if (f- > fltptr() ! - 0) f- > fltptrf)- > ApplyFilterCriteriafval); 25 // II If the current field value is legal... // if (f- > value_ok(val, i, LocalProto)) { 30 // // If the current field contains a checksum value... // verify it ... and if incorrect do something ? // if (f- > csumptr() ! - 0) 35 f- > csumptrf)- > verifyf); // If the current field needs statistics coIlected...collect them II if (f- > statsptr() ! - 0) f- > statsptrf)- > collectfval, HeaderLen); // // If the current field contains routing information... // lookup the specified routing information // (Only use first routing protocol found to allow statistics gathering // and filtering to be performed on every field in the frame) // if (RtePtr - - 0 && f- > rteptrf)) RtePtr - f- > rteptrf)- > RouteFramef); // // If the current field contains the protocol header length... // extract and save it in global variable HeaderLen // if (f- > hdlenO) HeaderLen - val*f- > hdlenO; // // Update # of bits parsed in the current frame (ParseLen) // Update # of bits parsed in the current protocol header(ProtoParseLen) // ParseLen + - f- > bitlenf); ProtoParseLen + - f- > bitlenf); // // If current field contains frame len (from start of current protocol)... // extract and save it in global variable FrameLen // If length extracted is larger than hardware frame length... // this is a malformed network frame...do device specific response // if (f- > protlenf)) // will be val*f- > protlenf) + ... when done with intf FrameLen = minfHwLeπ, (vaP8 + ParseLen ■ ProtoParseLen)); #ifndef notdef f- > OutiineFieldValfhdc, p, p- > dspbWf), val, f- > formatf), f- > bitlenf)); #eπdif } } // // Check required to skip over unsupported/unparsed options II if (LocalProto - = 0 && HeaderLen > ProtoParseLen) // Not all Options Parsed { // so skip over them ParseLen + = (HeaderLen - ProtoParseLen); ProtoParseLen - HeaderLen; } ParsePtr + - ProtoParseLen/8; returnfLocalProto); } Parse Protocol protocol *ParseProtocol2(protocol *p) { // // Parse each field in the protocol header // protocol * LocalProto - ParseFields2(p, HeaderLen); if {ParseLen > - HwLen) returnfO); // Finished if all hardware bits are parsed II II If fthis protocol supports optional fields and... // this protocol header contains one or more optional fields) // Process each option bit contained in the protocol header // if (fp « p- > options!.)) ! - 0) { // this protocol supports optional fields whilefProtoParseLen < HeaderLen) {// There are (HeaderLen-ProtoParseLen) bits of optional data remaining U32 optlen; HeaderLen •- ProtoParseLen; p - ParseFields2(p, optlen); } if fParseLen > - HwLen) returnfO);// Finished if all hardware bits are parsed } // // return next protocol to use in parsing this frame // return(LocalProto); } /////////////////////////////////////////////////////////////////////////////// ParseFramefprotocol *lnitialProtocolPtr); / Parameters: p - pointer to initial protocol description object Globals must be set as follows: HwLen - set to number of bits received from interface device FramePtr- set to start of frame received from interface device Srclntf - set to indicate the interface number which received frame void ParseFrame2(protocol *ProtPtr) { RtePtr - 0; // Clear Routing Table Entry Pointer at start of frame ParseLen = 0; // Set # of Bits Parsed in Frame to 0 at start of frame ParseLevel - 0; // ISO 7 layer position indication FrameLen - HwLen; // Set Frame Length to Hardware Length as best guess ParsePtr - FramePtr; // Set ParsePtr to point at start of Frame // ////////Update Number of Frames and Bits Received // // Parse each protocol in the Frame (Save pointer to protocol header first) // while(ProtPtr l - O) { ParseList.operator[](ParseLevel+ + ) - ParsePtr; // Save header pointer // ProtPtr = ParseProtocol2(ProtPtr); } // II If there is data...parse it // whilefParseLen < FrameLen) ParseProtocol2(DataPtlPtr); // // If there is pad...parse it // FrameLen - HwLen; whilefParseLen < FrameLen) ParseProtocol2(PadPtlPtr); // // If Frame passed at least one configured filter...Determine where to send it // if (CfgFilters.FrameFilterStatusf) - - PASS FRAME) { if (RtePtr - = 0 | | RtePtr- > RouteFramef) - - 0) // Increment number of slow-path frames ; // Send frame up to software else // Increment number of fast-path frames ; // Send frame to designated interface // increment number of frames passed } else { ////////Update Number of Frames and Bits Filtered } CfgFilters. reset)); // Reset criteria in each onfigured filter } ****/ static protocol *ParseFields(protocol *p, U32 &HeaderLen) { protocol *tp-0; field *f, 'g; ProtoParseLen - 0; HeaderLen = p- > numbitsf); f = g - p- > fieldptrf); for (U32 i-0; i < p- > numfieldsf) && ProtoParseLen < HeaderLen; f - &g[ij) { unsigned long val - f- > get_value(); // if (f- > swapfl) val - wordswapfval); if (f- > value okfval, i, tp)) { if ff- > csumptr() !- 0) f- > csumptrfj- > verifyf); if (f- > statsptrf) ! - 0) // If the user has requested stats be kept on this field f- > statsptrf)- > collectfval, HeaderLen); // collect it in whatever format has been requested // if (f- > hdienO) // If this field contains the protocol header length HeaderLen - val*f- > hdlenf); // save it for determining option length // ParseLen + - f- > bitlenf); // Keep total number of packet bits parsed ProtoParseLen + - f- > bitlenf); // Keep total number of protocol bits parsed if (f- > protlenf)) FrameLen - val*8 + ParseLen - ProtoParseLen; // Need to return an error value, otherwise, e.g., if IP with bad ten returns && we crash //trying to parse options.... f ■ > OutiineFieldValfhdc, p, p- > dspbWf), val, f- > formatf), f- > bitlenf)); if (ParseLen > - HwLen) returnfO); } } ParsePtr + - ProtoParseLen/8; returnftp); } protocol # ParseFrame(protocol *p) { unsigned long HeaderLen; protocol *tp-0; tp = ParseFieldsfp, HeaderLen); // Parse each field in the basic protocol // // Process options until all option bytes // if ( (FrameLen < - HwLen) && (ParseLen < = HwLen) ) // these are the error returns from parse fields { // returns - do something better with these if (fp - p- > options))) !- 0) // If this protocol has any optional fields and ... whilefProtoParseLen < HeaderLen) // there are some in this packet { // process them unsigned long optlen; HeaderLen - ProtoParseLen; p - ParseFieldsfp, optlen); } } else // do something with the error cases { if (ParseLen > HwLen) returnfO); FrameLen = HwLen; } if (tp — 0) { if (FrameLen < = HwLen) { protocols dataC'DATA", 0), t; ProtocolList- > findfdata, t); while (ParseLen < FrameLen) { dataiines+ +; t.protf)- > setupOutlineCoordsMult(TRUE); ParseFieldsft.protf), HeaderLen); } } protocols padf'PAD", 0), t; ProtocolList- > findfpad, t); while (ParseLen < HwLen) // Pad { padlines+ +; t.protf)- > setupOutlineCoordsMult(TRUE); ParseFieldsft.protf), HeaderLen); } return(O); } else returnftp); } - // FILTER.CPP iiimiimimmimiiiimiiiiimiimiiiiiiiiiiiiiiiiiiiiiiiiiiiiii ^include "geπ.hpp" // Channel Class Functions // Destructor: - channel // channel:: - channel)} { if (Criteria ! - 0) delete [jCriteria; if (ChannelName ! - 0) delete [JChannelName; } // void channel::Update(verify *v) { NextCriterialndex - v- > πxtidx; if (v- > prot - = (protocol *)PASS_FRAME) { + +FramesAccepted; FrameBitsAccepted + - HwLen; CfgFilters.FrameFilterStatus(PASS FRAME); // Set Status to PASS } // criteria Class Functions // ApplyFilterCriteria Applies the configured filter criteria to a received field value If index of this criteria - - index of the next expected criteria lookup the value and update the associated filter If index of this criteria > index of the next expected criteria disable further application of this filter void criteria::ApplyFilterCriteria(U32 value) { if (Index - - ChPtr- > NciValuef)) // Next criteria to evaluate ? ChPtr- > UpdatefRanges- > value jιk(value)); else if (Index > ChPtr- > NciValuef)) // Filter Criteria skipped ? ChPtr- > Disabled; // Disable filter evaluation // if (Index < ChPtr- > NciValuef)) // Skip this criteria ? } // LOOKUP.CPP ^include "gen.hpp" void verify::outJo_file(FILE *fp) const { U32 tmp; if fprot - - 0 I I prot- > pnamef) - - 0) { tmp - 0; fwritef&tmp, sizeofftmp), 1, fp); } else { tmp - prot- > pnamelenf); fwritef&tmp, sizeofftmp), 1, fp); fwritefprot- > pnamef), tmp, 1, fp); prot- > out_to_file(); } fwritef&nxtidx, sizeoffnxtidx), 1, fp); fwritef&miπval, sizeoffminval), 1, fp); fwritef&maxval, sizeoffmaxval), 1, fp); fwritef&okbits, sizeoffokbits), 1, fp); } // // // void verify::get from_file(FILE *fp) { protocols psearchffp), t; // Because destructor does not delete pname memory will be lost if ( (ProtocolList ! = NULL) && fProtocolList- > findfpsearch, t) ! - 0)) prot - t.protf); else prot - 0; // // Read remainder of verify structure (relates value/range to protocol) // freadf&nxtidx, sizeoffnxtidx), 1, fp); freadf&minval, sizeoffminval), 1, fp); freadf&maxval, sizeoffmaxval), 1, fp); freadf&okbits, sizeoffokbits), 1, fp); } // // // lookup *allocJookup_structs(U32 type, field *f) { switchftype) { default: cout < < "LOOKUP Yipesϋϋn"; case NOLOOKUP: returnfO); // No p case ONEVALUE: returnfnew lookup valuf)); case ARRAY: returnfnew lookup vectf 1 < < (32-f- > shrbitsf)))); case TREE: returnfnew lookup _tree{)); } } lookup *allocJookup_tree() { returnfnew lookup jreef)); // allocs WCDEFAULT_VECTOR_LENGTH which is 10 } //////////////////////////////////////////////////////////////////////////////// // MAIN.CPP ^include "gen.hpp" ^define NUMLINES 4800 ^define minfa.b) (((a) < fb)) ? (a) : (b)) ^define maxfa.b) (((a) > <b)) ? (a) : (b)) S32 nVscrolllnc, nHscrolllnc ; // TEMP extern int datalines; extern int padlines; // TEMP #define UNTITLED "(untitled)" // Functions in POPFILE.C make such for pa, use this for now static S32 nMaxWidth, nVscrollMax, nHscrollPos, nHscrollMax ; void PopFilelnitializeTr (HWND); void PopFilelnitialize (HWND, char * ) ; BOOL PopFileOpenDIg (HWND, LPSTR, LPSTR) ; BOOL PopFileSaveDIg (HWND, LPSTR, LPSTR) ; protocol *PopFileRead (HWND, LPSTR) ; //BOOL PopFileWrite (HWND, LPSTR) ; BOOL NAME0K100; BOOL BITLEN0K100; BOOL 0FFSET0K100; BOOL ANLZ_0K100; S32 cxClient, cyClient, cxChar, cyChar, nVscrollPos, nPaintBeg, nPaintEnd; long FAR PASCAL export FrameWndProc (HWND, UINT, UINT, LONG) ; BOOL FAR PASCAL export CloseEπumProc (HWND, LONG) ; long FAR PASCAL _export ImageWndProc (HWND, UINT, UINT, LONG) ; long FAR PASCAL _export ConfigWndProc (HWND, UINT, UINT, LONG) ; long FAR PASCAL export NxtPtlWndProc (HWND, UINT, UINT, LONG) ; long FAR PASCAL _export DisplaylmageWndProc (HWND, UINT, UINT, LONG) ; long FAR PASCAL _export AnlzWndProc (HWND, UINT, UINT, LONG) ; // global variables char szFrameClass [] - "MdiFrame" ; char szlmageClass [] - "Protocol Image" ; char szConfigClassf] - "PtICfg" ; char szNxtPtlClassI] = "NxtPtlCfg" ; char szFilterClassjj = "FILTER" ; char szDImageClass [] - "Frame Image" ; char szAnlzClassl - "ANLZ" ; HANDLE hlnst ; HMENU hMenu ; HMENU hMenuWindow ; static HWND hDlgModeless ; static char szAppNamefl - "NbPa" ; // Temp Temp S8 *savepkt; S8 *savemalloc; HDC hdc ; // Temp Temp int PASCAL WinMain (HANDLE hlnstance, HANDLE hPrevlnstance, LPSTR IpszCmdLine, WORD nCmdShow) { HANDLE hAccel ; HWND hwndFrame, hwndClient ; MSG msg ; WNDCLASS wndclass ; hlnst - hlnstance ; IpszCmdLine - 0; // Eliminate compiler warning if (ihPrevlnstance) { // Register the frame window class wndclass.style - CS_HREDRAW | CSJ7REDRAW ; wndclass.lpfnWndProc - (WNDPROC)FrameWndProc ; wndclass.cbClsExtra = 0 ; wndclass.cbWndExtra - 0 ; wπdclass.hlnstance - hlnstance ; wπdclass.hlcon = Loadlcon (hlnstance , "IC0N 2"); // IDI APPUCATION) ; ndclass.hCursor - LoadCursor (NULL, IDC ARROW) ; wndclass.hbrBackground - COLOR_APPWORKSPACE + 1 ; wndclass.lpszMenuName - NULL ; wndclass.lpszClassName - szFrameClass ; RegisterClass (&wndclass) ; // Register the Image child window class wndclass.style - CS HREDRAW | CSjVREDRAW ; wndclass.lpfπWndProc - (WNDPROC)imageWndProc ; wndclass.cbClsExtra - 0 ; wndclass.cbWndExtra = sizeof (LONG) ; wndclass.hlnstance = hlnstance ; wndclass.hlcon = Loadlcon (hlnstance , "ICON 1 "); //IDI APPLICATION) ; wndclass.hCursor = LoadCursor (NULL, IDC_ARR0W) ; wndclass.hbrBackground = COLOR APPWORKSPACE + 1; wndclass.lpszMeπuName = NULL ; wndciass.lpszClassName - szlmageClass ; RegisterClass (δtwndclass) ; // Register the Configuration child window class wndclass.style = CS_HREDRAW | CSJVREDRAW ; wndclass.lpfnWndProc - (WNDPROC)ConfigWndProc ; wndclass.cbClsExtra - 0 ; wndclass.cbWndExtra = 0 ; wndclass.hlnstance - hlnstance ; wndclass.hlcon - NULL ; wndclass.hCursor - LoadCursor (NULL, IDC_ARROW) ; wndclass.hbrBackground - GetStockObject (LTGRAY BRUSH) ; wndclass.lpszMenuName - NULL ; wndciass.lpszClassName - szConfigClass ; RegisterClass f&wndclass) ; // Register the Next Protocol Configuration grandchild window class wndclass.style - CS HREDRAW | CS VREDRAW | CS DBLCLKS; wndclass.style - CS_HREDRAW | CSjVREDRAW ; wndclass.lpfnWndProc - (WNDPROC)NxtPtlWndProc ; wndclass.cbClsExtra - 0 ; wndclass.cbWndExtra - 0 ; wndclass.hlnstance - hlnstance ; wndclass.hlcon - NULL ; wndclass.hCursor - LoadCursor (NULL, IDC ARROW) ; wndclass.hbrBackground = GetStockObject (LTGRAY BRUSH) ; wndclass.lpszMenuName - NULL ; wndciass.lpszClassName - szNxtPtlClas ; RegisterClass (&wndclass) ; // Register the Display Image child window class wndclass.style - CS HREDRAW | CS VREDRAW ; wndclass.lpfnWndProc - (WNDPROC)DisplaylmageWndProc ; wndclass.cbClsExtra - 0 ; wndclass.cbWndExtra - sizeof (LONG) ; wndclass.hlnstance - hlnstance ; wndclass.hlcon = Loadlcon (hlnstance , "ICONJ "); //ID1 APPLICATI0N) ; wndclass.hCursor - LoadCursor (NULL, IDC ARROW) ; wndclass-hbrBackground - COLOR APPWORKSPACE + 1; wndclass.lpszMenuName - NULL ; wndciass.lpszClassName - szDImageClass ; RegisterClass f&wndclass) ; // Register the ANLZ dialog box child window class wπdclass.style = CS HREDRAW | CS VREDRA ; wndclass.lpfnWndProc = (WNDPROC)AnlzWndProc ; wndclass.cbClsExtra - 0 ; wndclass.cbWndExtra - 0 ; wndclass.hlnstance - hlnstance ; wndclass.hlcon - NULL ; wndclass-hCursor = LoadCursor (NULL, IDC ARROW) ; wndclass.hbrBackground - GetStockObject (LTGRAY BRUSH) ; wndclass.lpszMenuName - NULL ; wndciass.lpszClassName = szAnlzClass ; RegisterClass (&wndclass) ; } // Get all filter channel info etup iltersf); // Get all protocol info setup protocolsf); // Obtain handles to three possible menus & submenus hMenu - LoadMenu (hlnst, "MdiMenuMain") ; hMenuWindow- GetSubMenu (hMenu, MAIN_MENU_POS) ; // Load accelerator table hAccel - LoadAccelerators (hlnst, "MdiAccel") ; // Create the frame window hwndFrame - CreateWindow fszFrameClass, "NbPa", WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, 0, 0, GetSystemMetricsfSM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), NULL, hMenu, hlnstance, NULL) ; hwndClient = GetWindow (hwndFrame, GW_CHILD) ; ShowWindow (hwndFrame, nCmdShow) ; UpdateWindow (hwndFrame) ; // Enter the modified message loop //while fGetMessage (&msg, NULL, WM KEYFIRST, WM KEYLAST)) while fGetMessage (&msg, NULL, 0, 0)) { if fhDIgModeless - - 0 | | llsDialogMessagefhDIgModeless, &msg)) { if (i.TranslateMDISysAccel (hwndClient, &msg) && !TranslateAccelerator (hwndFrame, hAccel, &msg)) { TranslateMessage (&msg) ; DispatchMessage (&msg) ; } } } return msg.wParam ; } iimiiiimiiniiiiiiiiiiiiiiiiini #ifndef notdef void DoCaption (HWND hwnd, char *szTitleName) { SetWindowText (hwnd, (szTitleName (0] ? szTitleName : UNTITLED)) ; } void OkMessage (HWND hwnd, char *szMessage, char 'szTitleName) { char szBuffer [64 + MAX FNAME + MAX EXT] ; wsprintf (szBuffer, szMessage, (LPSTR) (szTitleName [OJ ? szTitleName : UNTITLED)) ; MessageBox (hwnd, szBuffer, szAppName, MB_OK | MBJCONEXCLAMATION) ; } short AskAboutSave (HWND hwnd, char 'szTitleName) { char szBuffer [64 + ΛAX FNAME + MAX XT] ; short nReturn ; wsprintf (szBuffer, "Save current changes in %s?", (LPSTR) (szTitleName [0] ? szTitleName : UNTITLED)) ; nReturn - MessageBox (hwnd, szBuffer, szAppName, MB_YESNOCANCEL | MBJCONQUESTION) ; if (nReturn - - IDYES) if (ISendMessage (hwnd, WM COMMAND, IDM_SAVE, OL)) nReturn - IDCANCEL ; return nReturn ; } lendif // extern S32 xL, xR, yT, yB; static U32 soughtindex - 0; static U16 total- 0; long FAR PASCAL export FrameWndProc (HWND hwnd, UINT message, UINT wParam, LONG IParam) { RECT r; static HWND hwndClient ; CLIENTCREATESTRUCT clientcreate ; FARPROC IpfnEnum ; HWND hwndChildl ; MDICREATESTRUCT mdicreate ; static protocol *tptl; static protocol *aptl-0; // pointer to base MAC ptl: length field not flagged static protocol *fptl-0; // pointer to trace file format ptl: length field used // to set FrameLen && HwLen and skip balance of frame static U32 sought - 0; int i; static BOOL bNeedSave - FALSE ; static char szFileName [ MAX PATH] ; static char szTitleName [ MAX FNAME + MAX EXT] ; static char TraceFileName [ MAX PATH] ; //?? static char TraceTitleName [ MAX FNAME + MAX EXTj ; // ?? static char tmpszFileName [ MAX PATH] ; // find something better FILE *fp; protocol *ptl=0; protocol *lptl=NULL; switch (message) { case WM CREATE: // Create the client window TraceFileName [0] - TraceTitleName [0] - '\Q' ; // some other place? clientcreate.hWindowMenu - hMenuWindow ; clientcreate.idFirstChild - IDM FIRSTCHILD ; hwndClient = CreateWindow ("MDICLIENT", NULL, WS CHILD I WS CL1PCHILDREN | WS VISIBLE | WS V3CR0LL SCROLL, 0, 0, 0, 0, hwnd, 1, hlnst, (LPSTR) &clientcreate) ; return 0 ; case WM OMMAND: switch (wParam) { // Messages from File menu case IDM NEW: PopFilelnitialize (hwnd, -.PDF") ; if (bNeedSave && IDCANCEL - - AskAboutSave (hwnd, szTitleName)) return 0 ; bNeedSave - FALSE ; // ?? if (PopFileOpenDIg (hwnd, szFileName, szTitleName)) { if ((tptl = PopFileRead (hwnd, szFileName)) - - 0) { if (0 - - strrchr(szFileName, '.')) strcpy(strrchr(szFileName, ' '), ".PDF"); else strcpyfstrrchrfszFileName, '.'), ".PDF"); /* change extension */ if fftpti - setup newprotocol(szFileName))- -FALSE) returnfO); } GetClientRect(hwndClient, (LPRECT)&r); mdicreate.szCiass - szlmageClass; mdicreate.szTitle = tptl- > pnamef); mdicreate.hOwner - hlnst; mdicreate.x = r.left; mdicreate.y = r.top; mdicreate.cx = WORDfr.right • r.left); mdicreate.cy - WORDffr.bottom - r.top) / 1 ); mdicreate.style = 0; mdicreate.lParam - (LONG)tpti; hwndChild 1 = (HWND)SendMessage (hwndClient, WM_MDICREATE, 0, (long) (LPMDICREATESTRUCT) &mdicreate); NAMEOK 100 -FALSE; // indicate first sight of PTL NAME BITLENOK 100 = FALSE; // indicate first sight of FIELD BITLEN OFFSETOK 100 -FALSE; // indicate first sight of FIELD OFFSET hDlgModeless - CreateDialogParamfhInst, szConfigClass, hwndChildl, MakeProclπstance f(FARPROC) ConfigWndProc, hlnst), 0); } return 0 ; case IDM JPEN: PopFilelnitialize (hwnd, "*.PDF") ; if (bNeedSave && IDCANCEL - - AskAboutSave fhwnd, szTitleName)) return 0 ; if (PopFileOpenDIg (hwnd, szFileName, szTitleName)) { if ((tptl - PopFileRead (hwnd, szFileName)) - - 0) { OkMessage (hwnd, "Could not read protocol template file %s!", szTitleName) ; szFileName [0] = szTitleName [0] - '\0' ; returnfO); } if (tptl- > fieldptrf)= = NULL) { OkMessage (hwnd, "Null Field Pointer - Could not read protocol template file %s", tptl- > filenameO ) ; return (0); } GetClientRect(hwndClient, (LPRECT)Sr); mdicreate.szClass = szlmageClass; mdicreate.szTitle - tptl- > pnamef); mdicreate.hOwner - hlnst; mdicreate.x - r.left; mdicreate.y = r.top; mdicreate.cx - WORDfr.right • r.left); mdicreate.cy = WORDffr.bottom - r.top) / 1 ); mdicreate.style - 0; mdicreate.lParam - (LONG)tptl; hwndChild 1 - (HWND)SeπdMessage (hwndClient, WM MDICREA1 E, 0, (long) (LPMDICREATESTRUCT) &mdicreate); NAMEOK 100 -FALSE; // indicate first sight of PTL NAME BITLEN0K100 = FALSE; // indicate first sight of FIELD BITLEN 0FFSET0K100 -FALSE; // indicate first sight of FIELD OFFSET hDlgModeless - CreateDialogParamfhInst, szConfigClass, hwndChildl, MakeProclnstance f(FARPROC) ConfigWndProc, hlnst), 0); } bNeedSave - FALSE ; return 0 ; case IDM SAVE: if fszFileNametO]) { if (0- = strrchr( szFileName, O strcpyftmpszFileName, szFileName); else strcpyftmpszFileName, strrchrfszFileName, '\\')+ 1 ); for ( i - 0; i < ProtocolList- > entriesf); i + + ) { if fstrcmpf tmpszFileName, ProtocolList- > operator[](i).prot()- > filename!)) - - 0) { ProtocolList- > operator[](i).prot()- > clear _out lagf); ProtocolList- > operator[](i).prot()- > out Jo _file{); ProtocolList- > operator[](i).prot()- > clear j lagf); bNeedSave - FALSE ; return 1 ; } } OkMessagefhwnd, "Could not write file %s", szTitleName) ; return 0 ; } // Fall through case 1DM SAVEAS: if (PopFileSaveDIg fhwnd, szFileName, szTitleName)) { DoCaption (hwnd, szTitleName) ; f or ( i - 0; i < ProtocolList- > entriesO; i + + ) { if fstrcmpftptl- > pnamef), ProtocolList- > operator[](i).prot()- > pnamef)) - - 0) break; } // // Finds last file opened && writes current values for that entry // if (i - = ProtocolList- > entriesO) { OkMessage (hwnd, "Could not write file %s", szTitleName); returnfO); } if (szFileName[0]) { if (0- =strrchr( szFileName, '\\')) strcpyftmpszFileName, szFileName); else strcpyftmpszFileName, strrchrfszFileName, 'IV) + 1 ); if ((fp = fopen(tmpszFileName, "wb"))- -0) return (0); ProtocolList- > operator[](i).prot()- > clear out flagf); ProtocolList- > operator[](i).prot|)- > out Jo Jile(fp); ProtocolList- > operator[](i).prot()- > clear jjut flagf); // bNeedSave - FALSE ; return (1) ; } } return (0); case IDM CLOSE: // Close the active window hwndChildl - LOWORD (SendMessage (hwndClient, WM MDIGETACTIVE, 0, OL)) ; // if (SendMessage (hwndChildl, WM QUERYENDSESSION, 0, OL)) SendMessage (hwndClient, WM MDIDESTROY, hwndChildl, OL) ; if (szFileName[Oj) // Save the changes- make this a query?? { if (0- -strrchrf szFileName, '\\')) strcpyftmpszFileName, szFileName); else strcpyftmpszFileName, strrchrfszFileName, '\\')+ 1 ); f or ( i - 0; i < ProtocolList- > entriesO; i + + ) { if fstrcmpf tmpszFileName, ProtocolList- > operator[](i).prot()- > filename))) - - 0) { ProtocolList- > operator[](i).prot()- > clear out flagO; ProtocolList- > operator[](i).prot()- > out to ProtocolList- > operatorf (i).prot()- > clear out flagO; // // Save all filter channels when CLOSE - // bNeedSave - FALSE ; return 1 ; } } OkMessagefhwnd, "Could not write file %s", szTitleName) ; } return 0 ; case IDM_EX1T: // Exit the program f or (i - 0; i < ProtocolList- > entries ; i + + ) ProtocolList- > operator[](i).prot()- > clear out flagO; f or ( i - 0; i < ProtocolList- > entriesO; i + + ) ProtocolList- > operator[](i).prot()- > out to filef); // // ? Check for duplicate protocol names, Ok/Cancel Message? // SendMessage (hwnd, WM CLOSE, 0, OL) ; return 0 ; // Messages for arranging windows case IDM TILE: SendMessage (hwndClient, WMJΛDITILE, 0, OL) ; return 0 ; case IDM_CASCADE: SendMessage (hwndClient, WM MDICASCADE, 0, OL) ; return 0 ; case IDM_ARRANGE: SendMessage (hwndClient, WM MDIICONARRANGE, 0, OL) ; return 0 ; case ID CLOSEALL: // Attempt to close all children IpfnEπum = MakeProclnstance ffFARPROC) CloseEnumProc, hlnst) ; EnumChildWindows (hwndClient, IpfnEnum, OL) ; FreeProclπstance (IpfnEnum) ; return 0 ; case IDM MACPTL: PopFilelnitialize fhwnd, " .PDF") ; if (PopFileOpenDIg (hwnd, szFileName, szTitleName)) { if ffaptl = PopFileRead fhwnd, szFileName)) - - 0) { OkMessage fhwnd, "Could not read protocol template file %s!", szTii leName) ; szFileName [0] = szTitleName [0] - '\0' ; returnfO); } if (aptl- > fieldptr()= -NULL) { OkMessage (hwnd, "Null Field Pointer - Could not read protocol template file %s", aptl- > filename)) ) ; return (0); } } return (0); case IDM RAMENAME: PopFilelnitialize fhwnd, " *. PDF") ; if (PopFileOpenDIg (hwnd, szFileName, szTitleName)) { if (ffptl - PopFileRead (hwnd, szFileName)) - - 0) { OkMessage fhwnd, "Could not read protocol template file %s!", szTitleName) ; szFileName [0] = szTitleName [0] = '\0' ; returnfO); } if ffptl- > fieldptr()- - NULL) { OkMessage (hwnd, "Null Field Pointer - Could not read protocol template file %s", fptl- > filename!) ) ; return (0); } } sought - soughtindex - 0; return (0); case 1DM FRAMEFILE: case IDM_RUN: if (TraceFileName [0] ! - '\0') { hwndChildl - LOWORD (SendMessage (hwndClient, WMJvlDIGETACTIVE, 0, OL)) ; SendMessage (hwndClient, WM MDIDESTROY, hwndChildl, OL) ; TraceFileName [0] - TraceTitleName [0] - '\0' ; } // if (ffptl - - 0) | | (aptl — NULL)) if {aptl - - NULL) { SendMessage (hwnd, WM OMMAND, IDM_MACPTL, OL) ; if (aptl - = NULL) { OkMessage fhwnd, "Could not read protocol template file %s!", szTitleName) ; szFileName [0] - szTitleName [0] - '\0' ; returnfO); } } PopFilelnitializefhwnd, "'.TRI"); if (PopFileOpenDIg (hwnd, TraceFileName, TraceTitleName)) { // // In Lanz .tri ether file: first frame record is Oxbca bytes into file. The frame record // format is 0x1005, followed by a length. This length + 4 bytes is the length of the frame // record. 36 bytes of this is Lanz header, tmps-32 - HwLen. tmps+4 - - next fseek (from the // location at which current tmps is read). // Some files: begin at eO rather than bca. // Delimiter is 10 xx followed by length to next delimiter from first byte after current // length. Network data delimiter is 10 05 // Try a search for first 10 05 in file?? // sought - 2; U16 tmps; int qq; if (ffptl ! - 0) { while fstrcmpf IptI- > pnamef), aptl- > pnamef)) ! - 0) { FILE *f p = fopenfTraceFileName, "rb"); if <f p ! = 0) { qq = fseekffp, sought-2, SEEK SET); // length field if (qq- -O) { freadf&tmps, sizeofftmps), 1, fp); if (tmps- -0x1003) { fseekffp, 4, SEEK CUR); freadf&total, sizeofftotal), 1, fp); fseekffp, -6, SEEK_CUR); } qq = fseekffp, sought, SEEK_SET); // length field if (qq — 0) { freadf&tmps, sizeof(tmps), 1, fp); if (tmps < Oxfff) II some # { sought + = (tmps +4); // position of next length field qq - fseekffp, -4, SEEK_CUR); // start of frame if (ParsePtr - - NULL) savemalloc - ParsePtr - (char *)malloc(Oxfff); else ParsePtr -savemalloc; if (freadfParsePtr, tmps, 1, fp) !- 0) { HwLen - FrameLen - (tmps +4) * 8; // lanz issue, or work w/ .pfds fcloseffp); IptI - ParseProtocol2(fptl); if (IptI - - NULL) break; if (IptI - - aptl) { ParsePtr-4; break; } } } else { OkMessage (hwnd, "Could not read more frames %s!". TraceTitleName) ; szFileName [0] - TraceTitleName [0] - ; return(O); } } } fcloseffp); ParseLen = padlines - datalines - 0; } } } else { FILE *fp - fopenfTraceFileName, "rb"); if ffp l - O) { qq = fseekffp, sought, SEEK SET); // length field if (qq- -0) { freadf&tmps, sizeof(tmps), 1, fp); if (tmps < Oxfff) // some $ { sought + -(tmps+4); II position of next length field qq - fseek(fp, -4, SEEK CUR); // start of frame if (ParsePtr - = NULL) savemalloc = ParsePtr - (char *)malloc(Oxfff); else ParsePtr -savemalloc; if ffreadfParsePtr, tmps, 1, fp) ! - 0) { HwLen - FrameLen - (tmps +4) * 8; // lanz issue, or woik w/ .pfds fcloseffp); } } else { OkMessage (hwnd, "Could not read more frames %s!", TraceTitleName) ; szFileName [0] = TraceTitleName [0] - '10' ; return(O); } } } } soughtindex = 1; if (aptl - = NULL) { OkMessage (hwnd, "No base protocol file selected %s", " ") ; szFileName [0] = szTitleName [0] = '\0' ; returnfO); } GetClientRectfhwndCiient, (LPRECT)Str); mdicreate.szClass - szDImageClass; mdicreate.szTitle = TraceTitleName; //aptl- > pnamef); mdicreate.hOwner - hlnst; mdicreate.x = r.left; mdicreate.y - r.top; mdicreate.cx - WORDIr. right • r.left); mdicreate.cy - WORDffr.bottom - r.top) / 1); mdicreate.style - 0; mdicreate.lParam = (LONG)aptl; hwndChild 1 - (HWND)SendMessage (hwndClient, WM MDICREAI ' E, 0, (long) (LPMDICREATESTRUCT) &mdicreate); ANLZ_0K 100 - FALSE; // indicate first sight of ANLZ CUR change hDlgModeless - CreateDialogParamfhInst, szAnlzClass, hwndChildl, MakeProclnstance ffFARPROC) AnIzWndProc, hlnst), 0); } return (0); case IDMjMEXTFRAME: if (aptl - - 0) { OkMessage fhwnd, "Could not read protocol template file %s!", TraceTitleName) ; szFileName [0] = TraceTitleName [0] - '10' ; returnfO); } else if (soughtindex > 0) { FILE *fp = fopeπfTraceFileName, "rb"); if ( fp ! - NULL) { int qq - fseekffp, sought, SEEK 3ET); // length field U16 tmps; if fqq= =0) { freadf&tmps, sizeofftmps), 1, fp); if ftmps < Oxfff) // some # { sought + -ftmps +4); // position of next length field qq = fseekffp, -4, SEEK_CUR); // start of frame if (ParsePtr - - NULL) savemalloc = ParsePtr - (char *)malloc(Oxfff); if (freadfParsePtr, tmps+4, 1, fp) !- 0) HwLen = FrameLen - (tmps +4) * 8; // lanz issue, or work w/ .pfds soughtindex + +; } } else { OkMessage (hwnd, "Could not read more frames %s!", TraceTitM ame) ; szFileName [0] = TraceTitleName [0] - '\0' ; fcloseffp); returnfO); } fcloseffp); ParseLen = padlines - datalines - 0; } hwndChildl = LO WORD (SendMessage (hwndClient, WM MDIGETACTIVE, 0, OL)) ; InvalidateRect (hwndChildl, NULL, TRUE) ; } else { OkMessage (hwnd, "Analyzer has not been RUN yet %s!", TraceTitleName) ; szFileName [0] = TraceTitleName [0] - '\0' ; } return (0); case IDM_PREVFRAME: if (aptl - - 0) { OkMessage (hwnd, "Could not read protocol template file %s!", TraceTitleName) ; szFileName [0] = TraceTitleName [0] - '\0' ; returnfO); } else if (soughtindex > 1) { sought- 0; FILE *fp - fopen(TraceFileName, "rb"); U16 tmps; if (fρ ! - 0) for (U32 i=0; i < 100; i+ +) { int qq = fseekffp, sought, SEEK SET); // length field if (qq- -O) { freadf&tmps, sizeofftmps), 1, fp); if (tmps ! = 0x1005) { freadf&tmps, sizeofftmps), 1, fp); if (tmps < Oxfff) // some # sought + -(tmps +4); // position of next length field else { fclose(fp); OkMessage (hwnd, "Could not read more frames %s!", TraceTitleName) ; szFileName [0] = TraceTitleName [0] - '\0' ; returnfO); // give some message } } } else break; } int qq; for (U32 i - 0; i < (soughtindex- 1); i+ +) { qq - fseekffp, sought + 2, SEEK SET); // length field freadf&tmps, sizeofftmps), 1, fp); if (tmps < Oxfff) II some # sought + = (tmps + 4); // position of next length field else { fcloseffp); OkMessage (hwnd, "Could not read more frames %s!", TraceTitleName) ; szFileName [0] = TraceTitleName [0] - '\0' ; returnfO); // give some message } } qq - fseekffp, -4, SEEK CUR); // start of frame if (ParsePtr = - NULL) savemalloc = ParsePtr = (char *)malloc(Oxfff); if (fread(ParsePtr, tmps+4, 1, fp) ! - 0) { HwLen = FrameLen - (tmps +4) * 8; // lanz issue, or work w/ .pfds fcloseffp); ParseLen - padlines - datalines - 0; soughtindex--; sought + =2; hwndChildl - LOWORD (SendMessage (hwndClient, WM MDIGETACTIVE, 0, OL)) ; InvalidateRect (hwndChildl, NULL, TRUE) ; } } returnfO); case IDM ALYZERCLOSE: TraceFileName [0] = TraceTitleName [0] = '\0' ; hwndChildl - LOWORD (SendMessage (hwndClient, WM MDIGETACTIVE, 0, OL)) ; if (SendMessage (hwndChildl, WM_QUERYENDSESSION, 0, OL)) SendMessage (hwndClient, WM MDIDESTROY, hwndChildl, OL) ; if (savemalloc ! - NULL) { free(savemalloc); savemalloc - ParsePtr -NULL; } return(O); default: // Pass to active child hwndChildl - LOWORD {SendMessage (hwndClient, WM_MDIGETACTIVE, 0, OL» ; if (IsWindow (hwndChildl)) SendMessage (hwndChildl, WM OMMAND, wParam, IParam) ; break ; // and then to DefFrameProc } break ; case WM OUERYENDSESSION: case WM_CLOSE: // Attempt to close all children SendMessage (hwnd, WM COMMAND, IDM_CLOSEALL, OL) ; if (NULL ! - GetWindow (hwndClient, GW CHILD)) return 0 ; break ; // ie, call DefFrameProc ; case WM_DESTROY : PostOuitMessage (0) ; return 0 ; } // Pass unprocessed messages to DefFrameProc (not DefWindowProc) return DefFrameProc fhwnd, hwndClient, message, wParam, IParam) ; } BOOL FAR PASCAL _export CloseEnumProc (HWND hwnd, LONG IParam) { if (GetWindow (hwnd, GW OWNER)) // check for icon title return 1 ; SendMessage (GetParent (hwnd), WM MDIRESTORE, hwnd, OL) ; if (ΪSendMessage (hwnd, WM QUERYENDSESSION, 0, OL)) return 1 ; SendMessage (GetParent (hwnd), WM MDIDESTROY, hwnd, OL) ; IParam - 0; II To eliminate compiler warning !!! return 1 ; } long FAR PASCAL export DisplaylmageWndProc (HWND hwnd, UINT message, UINT wPsram, LONG IParam) { CLIENTCREATESTRUCT clientcreate ; static HWND hwndClient; //, hwndFrame ; PAINTSTRUCT ps ; TEXTMETRIC tm ; U32 x = 0, y - 0; protocol *ptl-0; ptl - (protocol *)GetWindowLong(hwnd, 0); switch fmessage) { case WM_CREATE: IParam - ((MDICREATESTRUCT far *)MK_FP32(((CREATESTRUCT far *)MKJ P32((void *)IParam))- > IpCreateParams))- > IParam; SetWindowLong fhwnd, 0, IParam) ; clientcreate.hWiπdowMenu - hMenuWindow ; clientcreate.idFirstChild = IDM FIRSTCHILD ; hwndClient - CreateWiπdow ("MDICLIENT", NULL, WS HILD I WS LIPCHILDREN | WS VISIBLE | WS V.3CR0LL | WS HSCROLL, 0, 0, 0, 0, hwnd, 1, hlnst, (LPSTR) &clientcreate) ; savepkt - ParsePtr; // = pkt2; //pktl; return 0 ; case WM_M0VE: ptl- > setupOutlineCoordsMult(O); IπvalidateRect (hwnd, NULL, TRUE) ; return 0 ; case WM SIZE: hdc - GetDC (hwnd) ; GetTextMetrics (hdc, &tm) ; cyChar = tm.tmHeight + tm.tmExternalLeading ; cxChar = tm.tmAveCharWidth; ReleaseDC (hwnd, hdc) ; cxClient - LOWORD (IParam); cyClient = HIWORD (IParam); ptl- > setupOutlineCoordsMult(O); InvalidateRect (hwnd, NULL, TRUE) ; return(O); nVscrollMax = max (0, NUMLINES + 2 - cyClient / cyChar) ; nVscrollPos = min (nVscrollPos, nVscrollMax) ; SetScrollRange (hwnd, SB_VERT, 0, (WORD)nVscrollMax, FALSE) ; SetScrollPos (hwnd, SB_VERT, (WORD)nVscrollPos, TRUE) ; nHscrollMax - max (0, 2 + (nMaxWidth - cxClient) / cxChar) ; nHscrollPos - min (nHscrollPos, nHscrollMax) ; SetScrollRange (hwnd, SB HORZ, 0, (WORD)nHscrollMax, FALSE) ; SetScrollPos (hwnd, SB HORZ, (WORD)nHscrollPos, TRUE) ; return 0 ; case WM VSCROLL: switch (wParam) { case SB TOP: nVscrollInc = -nVscrollPos ; break ; case SB_BOTTOM: nVscrollInc - nVscrollMax • nVscrollPos ; break ; case SBJJNEUP: nVscrollInc - -1 ; break ; case SBJ NEDOWN: nVscrollInc = 1 ; break ; case SB_PAGEUP: nVscrollInc = min (-1, -cyClient I cyChar) ; break ; case SB PAGEDOWN: nVscrollInc = max (1, cyClient / cyChar) ; break ; case SB HUMBTRACK: nVscrollInc - LOWORD (IParam) - nVscrollPos ; break ; default: nVscrollInc = 0 ; } nVscrollInc - max ( nVscrollPos, min (nVscrollInc, nVscrollMax - nVscrollPos)) ; if (nVscrollInc ! - 0) { nVscrollPos + = nVscrollInc ; ScrollWindow fhwnd, 0, WORDf-cyChar • nVscrollInc), NULL, NULL) ; SetScrollPos (hwnd, SB VERT, (WORD)nVscrollPos, TRUE) ; InvalidateRect (hwnd, NULL, TRUE) ; DestroyWiπdowfhDIgModeless); hDlgModeless - CreateDialogParamfhInst, szAnlzClass, hwnd, MakeProclnstance ffFARPROC) AnIzWndProc, hlnst), 0); SendMessage (hDlgModeless, WMJNITDIALOG, 0, OL) ; } return 0 ; case WM COMMAND: return 0 ; case WM_PAINT: / Paint the window hdc - BeginPaint (hwnd, &ps) ; nPaintBeg = ps.rcPaiπt.top; nPaintEnd - ps.rcPaint.bottom; ptl- > setupOutlineCoordsMult(O); whilefptl ! - 0) { ptl = ParseProtocol2(ptl); if (ptl! =0) ptl- > setupOutlineCoordsMult(TRUE); } ParsePtr -savepkt; ParseLen - padlines - datalines - 0; EndPaint (hwnd, &ps) ; return 0 ; case WM MDIACTIVATE: return 0 ; case WMj UERYENDSESSION: case WM CLOSE: if (IDOK ! - MessageBox (hwnd, "OK to close window?", "", MBJCONOUESTION | MB OKCANCEL)) return 0 ; break ; // ie, call DefMDIChildProc case WM DESTROY: return 0 ; case WMJ.BUTTONDOWN: x - LOWORD(IParam); y - HIWORD(IParam); ptl- > FindFieldfhwnd, x, y); SetFocus(GetWindow(hwnd, GW_CHILD»; return 0 ; } // Pass unprocessed message to DefMDIChildProc returnfDefMDIChildProc fhwnd, message, wParam, IParam)); } long FAR PASCAL export ImageWndProc (HWND hwnd, UINT message, UINT wParam, LONG IParam) { static HWND hwndClient; //, hwndFrame ; HDC hdc ; PAINTSTRUCT ps ; TEXTMETRIC tm ; U32 x - 0, y - 0; protocol *ptl-0; ptl - (protocol *)GetWindowLong(hwnd, 0); switch (message) { case WM CREATE: // IParam is ptr to CREATESTRUCT; IpCreateParams is ptr to MDICREATESTRUCT; IParam is from WM MDICREATE msg IParam - ((MDICREATESTRUCT far # )MK_FP32(((CREATESTRUCT far *)MK_FP32((void *)IParam))- > IpCreateParams))- > IParam; SetWindowLong fhwnd, 0, IParam) ; hwndClient - GetParent fhwnd) ; // Save CLIENT window handle // hwndFrame - GetParent (hwndClient) ; // Save FRAME window handle return 0 ; case WM_MOVE: ptl- > setupOutlineCoordsMult(O); InvalidateRect (hwnd, NULL, TRUE) ; return 0 ; case WM SIZE: hdc - GetDC (hwnd) ; GetTextMetrics (hdc, &tm) ; cyChar = tπ mHeight + tm.tmExternalLeading ; cxChar - tm.tmAveCharWidth; ReleaseDC (hwnd, hdc) ; cxClient - LOWORD (IParam); cyClient - HIWORD (IParam); ptl- > setupOutlineCoordsf); InvalidateRect fhwnd, NULL, TRUE) ; returnfO); case WM_COMMAND: return 0 ; case WM_PAINT: // Paint the window hdc = BeginPaint (hwnd, &ps) ; nPaintBeg - ps.rcPaint.top; nPaintEnd - ps.rcPaiπt.bottom; if {ptl ϊ - 0) ptl- > OutlineProtocol(hdc); EndPaint (hwnd, &ps) ; return 0 ; case WM_MDIACTIVATE: return 0 ; case WMjQUERYENDSESSION: case WM CLOSE: if (IDOK ! - MessageBox (hwnd, "OK to close window?", "", MBJCONQUESTION | MB_OKCANCEL)) return 0 ; break ; // ie, call DefMDIChildProc case WM DESTROY: return 0 ; case WM LBUTTONDOWN: x - LOWORD(IParam); y - HIWORD(IParam); ιf (ptϋ - O) ptl- > FindFieldfhwnd, x, y); SetFocus(GetWindow(hwnd, GW_CHILD)); return 0 ; } // Pass unprocessed message to DefMDIChildProc returnfDefMDIChildProc (hwnd, message, wParam, IParam)); } void InsertComboBoxNumbersfHWND hwnd, WORD Controlld, WORD Default, U32 minimum, U32 maximum, U32 increment) { U32 i, idx, def-1; char bufferI80]; hwnd - GetDlgltemfhwnd, Controlld); SendMessagefhwnd, CB_RESETCONTENT, 0, 0); for (i -minimum; i < -maximum; i+ -increment) { wsprintffbuffer, "%u", i); idx - SendMessagefhwnd, CB_ADDSTRING, 0, (LPARAM)f(LPSTR)buffer)); if (i - - Default) def - idx; } if (def ! — 1 ) SendMessagefhwnd, CB ETCURSEL, (WORD)def, 0); } void SetupPtlParametersfHWND hwnd, protocol *ptl) { SendDlgltemMessagethwnd, PTL OPTSAVAIL, CB_RESETCONTENT, 0, 0); SetDlgltemlntfhwnd, PTLj3ITLEN, ( ORD)ptl- > numbitsf), FALSE); SetDlgltemlntfhwπd, PTL NUMFIELDS, (WORD)ptl- > numfieldsf), FALSE); SetDlgltemTextfhwnd, PTL NAME, (LPCSTR )ptl- > pnameO); protocol * popts-ptl- > options!); if ( popts ! ~ 0) SetDlgltemText(hwnd, PTL OPTSAVAIL, (LPCSTR )popts- > pnameO); else SetDlgltemText(hwnd, PTL OPTSAVAIL, (LPCSTR)("[None]" )); SendDlgltemMessage(hwnd, PTL_OPTSAVAIL, CBJNSERTSTRING, (WPARAM)0, (LPARAM)fLPSTR)("[None]")); for (U32 i = 1; i < ProtocolList- > entriesO; i + + ) SendDlgltemMessagefhwnd, PTL OPTSAVAIL, CBJNSERTSTRING, (WPARAM)i, (LPARAMHLPSTR)ProtocolList- > operator[](i).prot()- > pnamef)); } void SetupFieldParameters(HWND hwnd, protocol *ptl) { static HWND hwndTmp=0; static HWND hwπdTmp2-0; field # fld - ptl- > fieldptr(ptl- > curfieldf)); // Edit Boxes SetDlgltemlnt (hwnd, FIELD NUMBER, (UINT)tptl- > curfield()+ 1 ), FALSE); SetDlgltemTextfhwnd, FIELD IAME, (LPCSTR)fld- > namef)); // Combo Boxes SetDlgltemlnt(hwnd, FIELD OFFSET, (WORD)fld- > bitoffsetO, FALSE); SetDlgltemlntfhwnd, FIELD LEN, (WORD)fld- > bitlenf), FALSE); //InsertComboBoxNumberslhwnd, FIELD NEXT, (WORD)(fld- > curf ieldO + 1 ), 1 , 256, I ); // Check Boxes CheckDlgButton(hwnd, FIELD NEXTPTL, (WORDHfld- > lookptr() ! - 0)); CheckDlgButton(hwnd, FIELD PKTLEN, (WORDHfld- > protlenO ! - 0)); CheckDlgButton(hwπd, FIELD_HDRLEN, (WORDHfld- > hdlen() ! - 0)); CheckDIgButton(hwnd, FIELD BYTESWAP, (WORDHfld- > swapf) ! - 0)); //CheckDIgButtoπfhwnd, FIELD FI LTER, (WORDHfld- > critptrf) ! - 0)); CheckDlgButtonfhwnd, FIELD OUNTBITS, (WORDHfld- > bitlenO - - 0)); if (hwndTmp ! - NULL) { DestroyWindow(hwndTmp); hwπdTmp - 0; } if (hwndTmp2 ! - NULL) { DestroyWindow(hwndTmp2); hwndTmρ2 - 0; } if (fid- > lookptrO) { hwπdTmp - CreateDialogParamfhInst, szNxtPtlClass, GetParentfhwnd), MakeProclnstance ffFARPROC) NxtPtlWndProc, hlnst), (LPARAM)r tϊ); SetFocusfhwndTmp); } /if (fid- > critptrf)) ϊ { // hwndTmp2 = CreateDialogParamfhInst, szFilterClass, GetParentfhwnd), / MakeProclnstance ffFARPROC) FilterWndProc, hlnst), (LPARAM)ptl); / SetFocus(hwndTmp2); / } field f; long FAR PASCAL export ConfigWndProc fHWND hwnd, UINT message, UINT wParam, LONG IParam) { HWND hwndParent; BOOL err; U32 tmp, len, off, actualoff, ii; static S32 newbits; char bufr[50]; static protocol *ptl-0; static field *fld-0; field * f, *g; // for searching for duplicate/overlayed fields FIELD OFFSET // // Get handle for Parent window // Get pointer to protocol associated with Parent window // Set up current field pointer // hwndParent - GetParentfhwnd); ptl - (protocol *)GetWindowLong(hwndParent, 0); fld - ptl- > fieldptr(ptl- > curfieldf)); protocols pfptl- > pnamef), ptl); switch (message) { case WM_ACTIVATE: if (wParam - - 0) // Window has been deactivated !!! return(FALSE); case WM SETFOCUS: case WMJNITDIALOG: // Set up Protocol Specific Parameters SetDlgltemlntfhwnd, PTL BITLEN, (WORD)ptl- > numbitsf), FALSE); SetDlgltemlntfhwnd, PTLjMUMFIELDS, (WORD)ptl- > numfieldsf), FALSE); InsertComboBoxNumbersfhwnd, PTL_DSPWIDTH, (WORD)ptl- > dspbWf), 8, 112, 8); // Set up Field Specific Parameters SetupFieldParametersfhwnd, ptl); SetupPtlParametersfhwnd, ptl); return(FALSE); case WM COMMAND: switchfwParam) { case PTL_DSPWIDTH: tmp = GetDlgltemlπtfhwnd, wParam, &err, FALSE); if (err - - FALSE | | tmp < 8 1 1 tmp > 1 12) return(O); ptl- > dspbW(tmp); ptl- > setupOutlineCoordsO; break; case PTLjMAME: GetDlgltemTextfhwnd, wParam, (LPSTR)buf r, sizeoffbufr)- 1 ); if (HIWORD(IParam) = = 0x100) NAME0K100 = TRUE; if (NAMEOK100 = = FALSE) returnfO); if (HIWORD(IParam) - - 0x300) { for { ii - 0; ii < ProtocolList- > entriesO; ii + + ) if fstrcmpf ptl- > pnamef), ProtocolList- > operator[](ii).prot()- > pnamef)) - - 0) { ProtocolList- > removeAtfii); break; } ptl- > pnamefbufr); ptl- > pnamelen(strlen(bufr)+ 1); ProtocolList- > insertfp); } break; case PTL_OPTSAVAIL: U32 idx; if (fidx-SeπdDlgltemMessagefhwnd, PTL_OPTSAVAIL, CBJ3ETCURSEL, 0, 0)) ! - CB RR) { // Put selected text into NEXTPTLS edit and list boxes SendDlgltemMessagefhwnd, PTL OPTSAVAIL, CB GETLBTEXT, (WPARAM)idx, (LPARAMHLPSTR)bufr); for (U32 i = 0; i < ProtocolList- > entriesO; i + + ) { if fstrcmpf ProtocolList- > operator[](i).prot()- > pnamef), bufr) - - 0) break; } if (ϋ- ProtocolList- > entriesO) ptl- > optionsfProtocolϋst- > operatorD(i).protf)); else ptl- > options(NULL); } return(FALSE); case PTL ITLEN: case PTL NUMFIELDS: break; case PTL ADD: if (ptl- > numfieldsf) > ptl- > curfieldf)) ptl- > add fieldfptl- > curf ieldflptl); SetupFieldParametersfhwnd, ptl); SetupPtlParametersfhwnd, ptl); ptl- > setupOutlineCoordsf); InvalidateRect (GetParentfhwnd), NULL, TRUE); // NEED STUFF FOR CHECKING FIELD BIT OFFSET, NOT ADDING LENGTH IF OVERLAP.... break; case PTL AFTER : if (ptl- > numfieldsf) > ptl- > curfieldO) ptl- > add Jield_after(ptl- > curJield(),ptl); SetupFieldParametersfhwnd, ptl); SetupPtlParameters(hwnd, ptl); ptl- > setupOutlineCoordsO; InvalidateRect (GetParentfhwnd), NULL, TRUE); STUFF FOR CHECKING FIELD BIT OFFSET, NOT ADDING LENGTH IF OVERLAP, break; case PTL_DELETE: if (ptl- > numfieldsf) > 1) ptl- > delete Jieldfptl- > curfield(),ptl); SetupFieldParametersfhwnd, ptl); SetupPtlParametersfhwnd, ptl); break; case FIELD NAME: if (GetDlgltemTextfhwnd, wParam, (LPSTR)bufr, sizeoffbufr)- 1) ! - 0) fid- > namefbufr); break; case FIELD_COUNTBITS: switchflsDlgButtonCheckedfhwnd, wParam)) { case 1 : // don't count bits in total bit leπ fid- > bitlen(O); break; case 0: // use bit len in offset/len calcs SendMessagefhwnd, WM OMMAND, FIELD LEN, (LPARAM)(IParam=CBN_SELENDOK < < 16)); break; } case FIELD OFFSET: case FIELDJ.EN: if (wParam - - FIELD OFFSET) { if (HIWORD(IParam) = = 0x100) OFFSETOK100 - TRUE; if (OFFSETOK100 - = FALSE) returnfO); if (HIWORD(IParam) ! - 0x300) returnfO); } else if (wParam = = FIELDJ.EN) { if (HIWORD(IParam) = = 0x100) BITLENOK100 - TRUE; if (BITLENOK100 = = FALSE) returnfO); if (HIWORD(IParam) !- 0x300) returnfO); } off - GetDlgltemlntfhwnd, FIELD OFFSET, &err, FALSE); if (err!- FALSE) { len - GetDlgltemlntfhwnd, FIELDJ.EN, &err, FALSE); if ferr!- FALSE) { πewbits - len - fid- > bitlenf); // // Case where the field is not word aligned // U32 xx; if(((xx-(off&31))!-0)&&(len > (32-xx))) actualoff -off &(~ 7); else actualoff -off &(~ 31 ); fld->offset((U16)(actualoff/8)); fid- > shlbits((U8)(off • actualoff)); fld->shrbits((U8)(32-len)); ptl- > numbitsfptl- > numbitsf)- fid- > bitlenf) + len); fid- > bitlenflen); // // Check for duplicate fields - get new total bitlen // f - g - ptl- > fieldptrf); // ptl- > numbits(O); for (ii-O; ii < ptl- > numfieldsf); ii+ + ) { f - &g[ϋ]; if (ii!-ptl-> curfieldf)) { // // Adjust position of following fields // if (fid- > bitoffsetf) < f- > bitoffsetf)) { off = f- > bitoffsetf) + newbits; len = f- > bitlenf); actualoff -off &( -31); f->offset(fU16)(actualoff/8)); f- >shlbits((U8)(off- actualoff)); f->shrbitsf(U8)(32-len)); } } } } } SetupPtlParametersfhwnd, ptl); break; case FIELD IUMBER: break; case FIELD_PREVIOUS_BUTTON: if (ptl->prevfield()== FALSE) returnfO); SetupFieldParametersfhwnd, ptl); break; case FIELD NEXT BUTTON: if (ptl- > πextf ieldO - - FALSE) return(O); SetupFieldParametersfhwnd, ptl); break; case FIELD IEXTPTL: switchflsDIgButtonCheckedfhwnd, wParam)) { case 0: if ffld- > lookptrf)! -0) fid- > lookptrf)- > - lookup!); fld- > lookptr(NULL); // -verifyf); for array & onevalue: need to - verify break; case 1: if (fid- > loαkptrO — NULL) fid- > lookptr(alloc_lookup_structs(ONEVALUE, fid)); // something better than this? break; } SetupFieldParametersfhwnd, ptl); break; // case FIELD FILTER: switchflsDIgButtonCheckedfhwnd, wParam)) { case O: if (fid- > critptrf)! =0) fid- > critptrf)- > — criteria!); fld- > critptr(NULL); // any need for? —verifyf); for array & onevalue: need to —verify // delete!]??? break; case 1: if (fid- > critptrf) - - NULL) { criteria *c - new criteria; fid- > critptrfc); fid- > critptrf)- > FilllnCriteriafO, NULL, NULL, ptl- > pnamef), fid- > named); fid- > critptrf)- > critrangefalloc Jookup treef)); } break; } SetupFieldParametersfhwnd, ptl); break; // case FIELD_PKTLEN: CheckDIgButtonfhwnd, wParam, (WORD)fld- > protlenflfid- > protlenf))); break; case FIELD J3YTESWAP: f Id ■ > swapf !f Id- > swapf}); CheckDIgButtonfhwnd, wParam, fid- > swapf)); break; case FIELD HDRLEN: // CheckDIgButtonfhwnd, wParam, (WORD)fld- > hdlenfifid- > hdlenf))); // CHANGE TYPE IN DECODE.HPP...? CheckDIgButtonfhwnd, wParam, (WORD)flsDlgButtonChecked(hwnd, wParam) ? 0:1)); fld- > hdlenflsDIgButtonCheckedfhwnd, wParam) ? 0:1); SetupFieldParametersfhwnd, ptl); break; default: retum(O); } // r.top - (WORD)nPaintBeg; r.bottom = (WORD)yB; r.left - (WORD)xL; r.right - (WORD)xR; InvalidateRectfhwndParent, NULL, TRUE); // Invalidate entire Image Window rectangle (Our Parent) returnfO); case WM SIZE: case WM_MOVE: InvalidateRectfhwndParent, NULL, TRUE); // Invalidate entire image Window rectangle (Our Parent) returnfO); case WM CLOSE: InvalidateRectfhwndParent, NULL, TRUE); SendMessagefhwndParent, WM_CLOSE, 0, 0); DestroyWindow(hwnd); return(O); } SetActiveWindow(hwnd); IParam - 0; // Make compiler complaint go away return(FALSE); } long FAR PASCAL export AnIzWndProc (HWND hwnd, UINT message, UINT wParam, LONG IParam) { static HWND hwndParent, hwndFrame, hwndTmp; BOOL err; hwndParent - GetParentfhwnd); hwndFrame - GetParent (hwndParent) ; // Save FRAME window handle hwndTmp - GetParent(hwndFrame); switch (message) { case WM_ACTIVATE: if (wParam - - 0) // Window has been deactivated !!! return(FALSE); case WM ETFOCUS: case WMJNITDIALOG: SetDlgltemlntfhwnd, ANLZ CUR, (WORD)soughtindex, FALSE); SetDlgltemlntfhwnd, ANLZ TOTAL, (WORD)total, FALSE); ShowWindow(hDlgModeless, SW_SHOW); return(FALSE); //Setup ?? case WM COMMAND: switchfwParam) { case ANLZjMEXT: SendMessage(hwndTmp,WM_COMMAND, IDMjMEXTFRAME,0); SetDlgltemlntfhwnd, ANLZ_CUR, (WORD)soughtindex, FALSE); break; case ANLZ PREV: SendMessage(hwndTmp,WM_COMMAND, IDM PREVFRAME.O); SetDlgltemlntfhwnd, ANLZ CUR, (WORD)soughtindex, FALSE); break; case ANLZ_CUR: if (HIWORD(IParam) - - 0x100) ANLZ_OK100 = TRUE; if (ANLZ_0K100 = = FALSE) returnfO); if (HIWORD(IParam) - - 0x300) { soughtindex = GetDlgltemlntfhwnd, ANLZ_CUR, &err, FALSE); if (err ! - FALSE) { soughtindex+ +; SendMessagefhwndTmp, WM COMMAND, IDM PREVFRAME, OL ); } ////?? set ANLZ_OK100 back to FALSE } break; case ANLZ RUN: SendMessagefhwndTmp, WM COMMAND, IDM RUN, OL ); break; case ANLZ QUIT: SendMessagefhwndTmp, WM_COMMAND, IDM CLOSE, OL ); break; default: break; } case WM SIZE: case WM MOVE: InvalidateRectfhwndParent, NULL, TRUE); // Invalidate entire Image Window rectangle (Our Parent) returnfO); case WM CLOSE: InvalidateRectfhwndParent, NULL, TRUE); SendMessagefhwndParent, WM_CLOSE, 0, 0); DestroγWindowfhwnd); returnfO); } SetActiveWindowfhwnd); return(FALSE); // NXTPTL.CPP imiiimmiiiimmmiiiiiiiimiiiiiiiiiiiiiiiiimiiiiiiiiiiiiiii ^include "gen.hpp" void SetupNxtPtlFieldsfHWND hwnd, field * fld) { verify *vptr; U32 i, num, curidx-O; // Get from field class member eventually ??? char buffer[80]; CheckRadioButtonfhwnd, NP SIGNED, NPj NSIGNED, NP UNS1GNED); // def aulting to unsigned for the moment CheckRadioButtoπfhwnd, NP_DECIMAL, NP HEX, (WORD)ffld > formatf)- - 1 ? NP DECIMAL : NP_HEX)); CheckRadioButtonfhwnd, NP ODD, NP_ALL, (WORDHNP ALL)); CheckDIgButtonfhwnd, (W0RD)(NP_0NEVALUE-1 +fld- > lookptrf)- > getjypef)), TRUE); SendDlgltemMessagefhwnd, NP MINLIST, LB_RESETCONTENT, 0, 0); SendDlgltemMessagefhwnd, NP MAXLIST, LB RESETCONTENT, 0, 0); SendDlgltemMessagefhwnd, P NEXTIDXUST, LB RESETCONTENT, 0, 0); SendDlgltemMessagefhwnd, NP NEXTPTLUST, LB_RESETC0NTENT, 0, 0); SendDlgltemMessagefhwnd, NP NEXTPTLUST, LB SETHORIZONTALEXTENT, 200, 0); SendDlgltemMessagefhwnd, NP PTLS, LB_RESETCONTENT, 0, 0); SendDlgltemMessagefhwnd, NP MINEDIT, EM_SETSEL, 0, MAKEL0NG([I,-D); SendDlgltemMessagefhwnd, NP MINEDIT, WM_CLEAR, 0, 0); SendDlgltemMessagefhwnd, NP MAXEDIT, EM ETSEL, 0, MAKELONGIO,-!)); SendDlgltemMessagefhwnd, NP MAXEDIT, WM_CLEAR, 0, 0); SendDlgltemMessagefhwnd, P NEXTIDXEDIT, EM SETSEL, 0, MAKELO 3(0,-1 )); SendDlgltemMessagefhwnd, NP_NEXTIDXEDIT, WM_CLEAR, 0, 0); SendDlgltemMessagefhwnd, NP NEXTPTLEDIT, EM SETSEL, 0, MAKEL0NG{0,-1)); SendDlgltemMessagefhwnd, NPjNEXTPTLEDIT, WM CLEAR, 0, 0); if (fid- > lookptrf) - - NULL) return; if (fnum - fid- > lookptrf)- > entriesO) ! -0) { for (i - 0; i < num; i + + ) { vptr - fid- > lookptrf)- > find indexfi); wsprintffbuffer, (fid- > format"- - 1) ? "%u" : "Ox%x", vptr- > minval); SendDlgltemMessage(hwnd, NP MINLIST, LBJNSERTSTRING, (WPARAM)i, (LPARAMHLPSTR)buffer); if (i - - curidx) SetDlgltemTextfhwnd, NP MINEDIT, (LPCSTR)buffer); wsprintffbuffer, (fid- > formatf)- - 1 ) ? "%u" : "Ox%x", vptr- > maxval); if (i - = curidx) SetDlgltemTextfhwnd, NP MAXEDIT, (LPCSTR)buffer); SendDlgltemMessagefhwnd, NP MAXLIST, LBJNSERTSTRING, (WPARAM)i, (LPARAMHLPSTR)buffer); if (i « - curidx) CheckRadioButtonfhwnd, NP ODD, NP ALL, (WORD)(NP_ODD + vptr- > okbits- 1 )); // Controls must be in ODD, EVEN, BOTH order wsprintffbuffer, "%u", vptr- > nxtidx+ 1); if (i = = curidx) SetDlgltemTextfhwnd, NP EXTIDXEDIT, (LPCSTR)buffer); SendDlgltemMessagefhwnd, NP IEXTIDXLIST, LBJNSERTSTRING, (WPARAM)i, (LPARAMHLPSTR)buffer); wsprintffbuffer, "%s", (vptr- > prot = = 0) ? "[None]" : vptr- > prot- > pnameO); if (i = = curidx) SetDlgltemTextfhwnd, NP NEXTPTLEDIT, (LPCSTR)buffer); SendDlgltemMessagefhwnd, NP NEXTPTLUST, LBJNSERTSTRING, (WPARAM)i, (LPARAMJ(LPSTR)buffer); } //SendDlgltemMessagefhwnd, NP MINEDIT, EM SETMODIFY, 0, 0); SendDlgltemMessage(hwπd, NPj INLIST, LB_SETCURSEL, 0, 0); SeπdDlgltemMessagediwnd, NP MAXLIST, LB SETCURSEL, 0, 0); SendDlgltemMessage(hwnd, NP NEXTIDXLIST, LB_SETCURSEL, 0, 0); SendDlgltemMessagefhwnd, NP NEXTPTLLIST, LB ETCURSEL, 0, 0); } for (i=0; i < ProtocolList- > entriesO; i+ +) SendDlgltemMessagefhwnd, NP PTLS, LBJNSERTSTRING, (WPARAM)i, (LPARAMHLPSTR)ProtocolList- > operatorU(i).prot()- > pnamef)); //SendDlgltemMessagefhwnd, NP_PTLS, LB DIR, 0x37, (LONG )(LPSTR)"\pfd n ); } lifdef notdef void InsertNewRangefHWND hwnd, U32 &rangeldx, U32 editld, U32 listld) { S8 cbString[50]; SendDlgltemMessagefhwnd, (WORD)editld, EM SETSEL, 0, MAKEL0NG(0,-1)); GetDlgltemText (hwnd, (WORD)editld, (LPSTR)cbString, sizeof(cbString)); rangeldx - SendDlgltemMessage(hwnd, (WORD)listld, LBJNSERTSTRING, (WPARAM)rangeldx, (LPARAMHLPSTR)cbString); SendDlgltemMessagefhwnd, (WORD)listld, LB_SETCURSEL, (WPARAM)rangeldx, (I); } #endif long FAR PASCAL export NxtPtlWndProc (HWND hwnd, UINT message, UINT wParam, LONG IParam) { static U32 rangeldx =0; HWND hwndParent; BOOL err; U32 tmp; static protocol *ptl-0; static field *fld=0; static verify *vptr=0; char buffer[801; static verify tvptr; switch (message) { case WM ACTIVATE: if (wParam - - 0) // Window has been deactivated !!! return(FALSE); case WMJNITDIALOG: ptl - (protocol *)IParam; // Setup ptl each time Dialog is created // Fall Thru case WM_SETFOCUS: if (fid- > lαokptrϋ ! - NULL) fid - ptl- > fieldptrfptl- > curfieldf)); // Recompute fid when acquire input focus vptr - fid- > lookptrf)- > find iπdexfrangeldx); SetupNxtPtlFieldsfhwnd, fid); // Setup each control return(FALSE); case WM COMMAND: switchfwParam) { case NP_ONEVALUE: // 314 case NP_ARRAY: // 315 case NP TREE: // 317 if (fid- > lookptrf)! =0) { fid- > lookptrf)- > - lookup!); fld- > lookptr(NULL); } fid- > lookptrfalloc lookup j>tructs(wParam-NP JNEVALUE+ 1, fid)); SetupNxtPtlFieldsfhwnd, fid); // Display cleared-out ranges // // Requires that the ONEVALUE,ARRAY,TREE match the order & spacing of the // enum lookuptypes{ NOLOOKUP, ONEVALUE, ARRAY, HASH, TREE } // returnfO); case NP MINLIST: case NP_MAXLIST: case NP IEXTIDXLIST: case NPj EXTPTLLIST: rangeldx = SendDlgltemMessagefhwnd, wParam, LB GETCURSEL, 0, 0); vptr - fid- > lookptrf)- > find indexfrangeldx); tvptr.prot = vptr- > prot; tvptr.πxtidx = vptr- > nxtidx; tvptr.okbits = vptr- > okbits; tvptr.minval = vptr- > minval; tvptr.maxval = vptr- > maxval; break; case NP ODD: case NP EVEN: case NP ALL: tvptr.okbits - wParam - NPJ3DD + 1; return (0); case NP_DECIMAL: fld > format|DEC); SetupNxtPtlFieldsfhwnd, fid); // Setup each control return (0); case NP HEX: fid- > format(HEX); SetupNxtPtlFieldsfhwnd, fid); // Setup each control return fO); case NP PTLS: // if (HIWORD(IParam) ! - LBN DBLCLK) // retum(FALSE); case NP USE: U32 idx; //, len; if ((idx -SendDlgltemMessagefhwnd, NP PTLS, LB GETCURSEL, 0, 0)) ! = LB ERR) { // Put selected text into NEXTPTLS edit and list boxes SendDlgltemMessagefhwnd, NP_PTLS, LBJ3ETTEXT, (WPΛRAM)idx, (LPARAMHLPSTR)buffer); // if (strlenfbuffer)!- 0) SetDlgltemTextfhwnd, NP EXTPTLEDIT, (LPCSTR)buffer); { f or f U32 i = 0; i < ProtocolList- > entriesO; i + + ) { if fstrcmpf ProtocolList- > operator[](i).protf - > pnameO, if (f Id- > formatO = = HEX) { GetDlgltemTextfhwnd, NP MINEDIT, (LPSTR)buffer, sizeof(buffer)-l); tvptr.minval -strtolffchar *)buffer,NULL,16); GetDlgltemTextfhwnd, NP MAXEDIT, (LPSTR)buffer, sizeof(buffer)-l ); tmp -strtolffchar *)buffer,NULL,16); tvptr.maxval = tmp; } else // (fid- > formatj) - - DEC) { tmp - GetDlgltemlntfhwnd, NP MINEDIT, &err, FALSE); if (err - = FALSE) returnfO); tvptr.minval = tmp; tmp - GetDlgltemlntfhwnd, NPJ IAXEDIT, &err, FALSE); if (err - - FALSE) returnfO); tvptr.maxval = tmp; } tmp - GetDlgltemlntfhwnd, NP_NEXTIDXEDIT, &err, FALSE); if (err = = FALSE) returnfO); tvptr.nxtidx - tmp-1; GetDlgltemTextfhwnd, NP_NEXTPTLEDIT, (LPSTR)buffer, sizeof(buffer)-l); this with find instead? if (strlenfbuffer)!- 0) { for fU32 i=0; i < ProtocolList- > entriesO; i+ + ) { if fstrcmpf ProtocolList- > operator[](i).prot()- > pnamef), buffer) = = 0) break; } if (i! = ProtocolList- > entriesO) tvptr.prot -ProtocolList- > operatorl](i).protf); else tvptr.prot = 0; } if (IsDIgButtonCheckedfhwnd, NP_ALL)) tvptr.okbits - ALLNUMBERS; else if (IsDIgButtonCheckedfhwnd, NP_0DD)) tvptr.okbits = ODDNUMBERS; else if (IsDIgButtonCheckedfhwnd, NP EVEN)) tvptr.okbits = EVENNUMBERS; if (wParam = = NP MODIFY) { fid- > lookptrf)- > modify entryfrangeldx, tvptr.prot, tvptr.nxtidx, tvptr.minval, tvptr.maxval, tvptr.okbits); } if (wParam - - NP INSERT) { fid- > lookptrf)- > insert entryftvptr.prot, tvptr.nxtidx, tvptr.minval, tvptr.maxval, tvptr.okbits); } SetupNxtPtlFieldsfhwnd, fid); // Setup each control returπ(FALSE); case NPJ3ELETE: SendDlgltemMessagefhwnd, NPJvllNLIST, LBj ELETESTRING, (WPARAM)rangeldx, 0); SendDlgltemMessagefhwnd, NP MAXLIST, LB DELETESTRING, (WPARAM)rangeldx, 0); SendDlgltemMessagefhwnd, NP NEXTIDXLIST, LB DELETESTRING, (WPARAM)rangeldx, 0); SendDlgltemMessagefhwnd, NP NEXTPTLLIST, LB_DELETESTRING, (WPARAM)rangeldx, 0); if (fid- > lookptrf)- > entries!) > 0) fid- > lookptrf)- > delete entryfrangeldx, tvptr.minval); break; default: return(FALSE); } SendDlgltemMessagefhwnd, NP MINLIST, LB SETCURSEL, (WPARAM)rangeldx, 0); SendDlgltemMessagefhwnd, NP MAXLIST, LBjSETCURSEL, (WPARAM)rangeldx, 0); SendDlgltemMessagefhwnd, NP NEXTIDXLIST, LBjSETCURSEL, (WPARAM)rangeldx, 0); SendDlgltemMessagefhwnd, NP NEXTPTLLIST, LBjSETCURSEL, (WPARAM)rangeldx, 0); SendDlgltemMessagefhwnd, NP MINLIST, LBjSETTOPINDEX, (WPARAM)rangeldx, 0); SendDlgltemMessagefhwnd, NP MAXLIST, LBjSETTOPINDEX, (WPARAM)rangeldx, 0); SendDlgltemMessagefhwnd, NP NEXTIDXLIST, LBjSETTOPINDEX, (WPARAM)rangeldx, 0); SendDlgltemMessagefhwnd, NP NEXTPTLLIST, LB SETTOPINDEX, (WPARAM)raπgeldx, 0); SendDlgltemMessagefhwnd, NP MINEDIT, MAKEL0NG(0,-D); SendDlgltemMessagefhwnd, NP MINEDIT, 0); SendDlgltemMessagefhwnd, NP_MAXEDIT, MAKELONG(0,-D); SendDlgltemMessagefhwnd, NP MAXEDIT, 0); SendDlgltemMessagefhwnd, NPjMEXTIDXEDIT, EM_SETSEL, 0, MAKELONG(0,-D); SendDlgltemMessagefhwnd, NP NEXTIDXEDIT, WMjSLEAR, 0, 0); SendDlgltemMessagefhwnd, NPjMEXTPTLEDIT, EMjSETSEL, 0, MAKELONG(0,-D); SendDlgltemMessagefhwnd, NPjMEXTPTLEDIT, WM_CLEAR, 0, 0); wsprintffbuffer, (fid- > formatf)- - 1 ) ? "%u" : "0x%x", tvptr.minval); SetDlgltemTextfhwnd, NP MINEDIT, (LPCSTR)buffer); wsprintffbuffer, (fid- > formatO- = 1) ? "%u" : "Ox%x", tvptr.maxval); SetDlgltemTextfhwnd, P MAXEDIT, (LPCSTR)buffer); wsprintffbuffer, "%u", tvptr.nxtidx + 1); SetDlgltemTextfhwnd, NP NEXTIDXEDIT, (LPCSTR)buffer); wsprintffbuffer, "%s", (tvptr.prot = = 0) ? "[None]" : tvptr.prot- > pnamef)); SetDlgltemText(hwπd, NP NEXTPTLEDIT, (LPCSTR)buffer); CheckRadioButtonlhwnd, NP_0DD, NP ALL, (WORDHNP ODD+ tvptr.okbits- 1)); // Controls must be in ODD, EVEN, BOTH order returπ(FALSE); case WM SIZE: // Force size to original (don't allow user to change size of dialog box) ??? case WM MOVE: returnfO); case WM CLOSE: hwndParent - GetParentfhwnd); InvalidateRectfhwndParent, NULL, TRUE); SendMessagefhwndParent, WM CLOSE, 0, 0); DestroγWindowfhwnd); returnfO); } IParam - 0; // Make compiler complaint go away return(FALSE); } // PCOLS.CPP ^include "geπ.hpp" static protocols DataPtl, PadPtl; protocol "DataPtlPtr, 'PadPtlPtr; // PUT THIS IN setup protocolsf) WCValSortedVector < protocols > 'ProtocolList; // Pointer to sorted list for loo up values protocol *base_protocol(S8 'ProtocolName) { for (U32 i-0; i < ProtocolList- > entriesO; i+ +) if fstrcmpfProtocolName, ProtocolList- > operator[]fi).prot()- > filenamef)) = - 0) returnfProtocolϋst- > operator[](i).prot()); returnfO); } void setup_protocols() { U32 number -0; find J fileblock; // // Determine number of protocol definitions that exist by counting files // if f_dosJindfirstr.pdf", _A_N0RMAL, &fileblock) - - 0) { do { + + number; } while(_dos indnextf&fileblock) - - 0); } // // Setup a vector twice the size of the current number with number for the grow size // ProtocolList = new WCValSortedVector < protocols > (number*2, number); // // Open each protocol definition file; create a protocol definition in memory; insert it into the vector // if (_dos indfirst("*.pdf", _A_NORMAL, &fileblock) = - 0) { do { FILE *fp - fopen(fileblock.name, "rb"l; if f(fp ! - 0) && ffileblock.size > 56)) { U32 tmp; freadf&tmp, sizeofftmp), 1, fp); // Get length of protocol name // S8 * pname - (S8 # )malloc(tmp); freadfpname, tmp, 1, fp); // Get file name fcloseffp); protocol *proto - new protocolfpπame, fileblock.name); // protocols pfpname, proto); freefpname); ProtocolList- > insertfp); } } whilef dos fiπdnextf&fileblock) - - 0); } ? Do we want to do something about duplicate protocol names here? for f U32 ii - 0, jj - 1 ; ii < ProtocolList- > entriesO; " + + , jj + + ) { if ffii ! - jj) && fstrcmpf ProtocolList- > operator[](ii).prot()- > pnamef), ProtocolList- > operator[](jj).prot()- > pnamef)) - - 0)) ProtocolList- > removeAtfjj); } II II Open each protocol definition file; create all required data structures // if (Jos findfirstP.pdf ", _A_NORMAL, &fileblock) - - 0) { do { FILE *fp - fopen(fileblock.name, "rb"); if <(fp ! - 0) && (fileblock.size > 56)) { protocols pffp), t; // Reads namejength and name if (ProtocolList- > find(p, t) ! - FALSE) t.protf)- > get Jrom Jileffp); fcloseffp); } } while(_dosJiπdnext(&fileblock) = = 0); } protocols datafDATA", 0), padf'PAD", 0); // PUT THIS IN setup_protocols() ProtocolList- > findfdata, DataPtl); // PUT THIS IN setup protocolsf) ProtocolList- > findfpad, PadPtl); // PUT THIS IN setup protocolsf) DataPtlPtr = DataPtl.protf); // PUT THIS IN setup protocolsf) PadPtlPtr - PadPtl.protf); // PUT THIS IN setup protocolsf) //setup criteriaf); // filter channels are setup - tie criteria to fields } protocol *setup_πewprotocol(S8* szFileName) { U32 number =0; find J fileblock; S8 'pname = (S8 *)malloc(50); // strcpy(pname,szFileName); strcpyfstrrchrfpname, '.'), "\0 "); strcpyfpname, (strrchrfpname, '\V)+ D); strcpyfszFileName, fstrrchrfszFileName, '1V)+ D); // // See if there are any protocols // if (_dos_findfirst("*.pdf n , A NORMAL, &fileblock) - - 0) { do { + + number; } whilef dos Jindnextf&fileblock) = - 0); } // Setup a vector if there are no .pdfs // if (number - - 0) ProtocolList - new WCValSortedVector < protocols > (10, 5); // use some other define/dufault protocol *proto = new protocolfpname, szFileName); protocols pfpname, proto); field *tmpfs - new field] 1]; field f(0,0,24); t pfslO] - f; proto- > fieldptrftmpfs); proto- > numbitsftmpfs- > bitlenf)); proto- > numfields(l); freefpname); ProtocolList- > insertfp); FILE *fp - fopenfszFileName, "wb"); if (fp ! - 0) { p.protO- > out Jo Jilef); fcloseffp); p.protO- > clear out flagO; returnfproto); } return(FALSE); } r P0PFILE.C -• Popup Editor File Functions •/ #define INCLUDE_COMMDLG_H 1 ^include < windows.h > include < stdlib.h > ^include "gen.hpp" #define PDF "\PDF" ^define TR1 "*.TR1" static OPENFILENAME ofn ; // / / make all the initialize pop files on rtn, pass extension >> >> >> > >> > >> >>> >> // void PopFilelnitialize fHWND hwnd, char *ext) { static char *szFilter[] - { }; ofn.lStructSize = sizeof (OPENFILENAME) ; ofn.hwndOwner = hwnd ; ofπ.hlnstaπce - NULL ; if (strcmp(ext,PDF)--0) { ofn pstrDefExt - "pdf"; ofn.lpstrFilter - szFilter [0] ; } elseif(strcmp(ext,TR1)=-0) { ofn.lpstrDefExt = "tri"; ofn.lpstrFilter - szTFilter [0] ; } ofn.nMaxCustFilter - 0 ; ofn.nFilterlndex - 0 ; ofn.lpstrFile - NULL ; // Set in Open and Close functions ofπ.nMaxFile - _MAX_PATH ; ofn.lpstrFileTitle - NULL ; // Set in Open and Close functions ofπ.n axFileTitle = _MAX_FNAME + _MAX_EXT ; ofn.lpstrlnitialDir - NULL ; ofn.lpstrTitle = NULL ; ofn.Flags - 0 ; // Set in Open and Close functions ofn.nFileOffset - 0 ; ofn.nFileExtension - 0 ; ofπ.lCustData - OL ; ofn.lpfnHook - NULL ; ofn.lpTemplateNa e - NULL ; } BOOL PopFileOpenDIg (HWND hwnd, LPSTR IpstrFileName, LPSTR IpstrTitleName) { BOOL rv; DWORD t; ofn.hwndOwner = hwnd ; ofn.lpstrFile = IpstrFileName ; ofn.lpstrFileTitle = IpstrTitleName ; ofn.Flags - OFN REATEPROMPT ; rv - GetOpenFileName (&ofn) ; t = CommDIgExtendedErrorO; return rv ; } BOOL PopFileSaveDIg (HWND hwnd, LPSTR IpstrFileName, LPSTR IpstrTitleName) { ofn.hwndOwner = hwnd ; ofn.lpstrFile - IpstrFileName ; ofn.lpstrFileTitle = IpstrTitleName ; ofn.Flags = OFN_OVERWRITEPROMPT ; return GetSaveFileName (&ofn) ; } static long PopFileLength (WORD hFile) { long ICurrentPos = llseek (hFile, OL, 1) ; long IFileLength - llseek (hFile, OL, 2) ; llseek (hFile, ICurrentPos, 0) ; return IFileLength ; } protocol ^PopFileRead (HWND hwndEdit, LPSTR IpstrFileName) { for (int i - 0; i < ProtocolList- > entries)); i + + ) { if (strcmp(strrchr(lpstrFileName, '\\')+ ], ProtocolList- > operator[](i).prot()- > filenamef)) - - 0) { hwndEdit = 0; // Display Protocol in Windows returnfProtocolList- > operator[](i).prot()); } } // Open any file not already in list...add to list and directory of pdf files if user requests it returnfO); } #ifdef notdef BOOL PopFileWrite (HWND hwndEdit, LPSTR IpstrFileName) { HANDLE hBuffer ; WORD hFile ; LPSTR IpstrBuffer ; WORD wLength ; if (-1 - - (hFile = Jopen (IpstrFileName, OF_WRITE | OF SHARE EXCLUSIVE))) if (-1 - - (hFile - lcreat (IpstrFileName, 0))) return FALSE ; wLength - GetWindowTextLength (hwndEdit) ; hBuffer - fHANDLE) SendMessage (hwndEdit, EMJSETHANDLE, 0, OL) ; IpstrBuffer = (LPSTR) LocalLock (hBuffer) ; if (wLength ! = Jwrite (hFile, IpstrBuffer, wLength)) { Jclose (hFile) ; return FALSE ; } Jclose (hFile) ; LocalUnlock (hBuffer) ; return TRUE ; } #endif → STAT.CPP ^include "gen.hpp" Generate Required data structure from user statistics selections Parameters: field - pointer to protocol template field (should only be called for fields with stats configured) Returns: status • OK / NOTOK stats *alloc_stat_structs(U32 type, field *f) { switch(type) { default: case NOSTATS: returnfO); // No statistics to be kept for this protocol field case SUM: returnfnew sum statsff- > namef))); case INC: returnfnew inc statsff- > namef))); case SUMINC: returnfnew suminc statsff- > namef))); case IDXSUM: returnfnew idxsumjstatsff- > namef), (32-f- > shrbitsf)))); case IDXINC: returnfnew idxinc _stats(f- > namef), (32-f- > shrbitsf)})); case IDXSUMINC: returnfnew idxsuminc statsff- > namef), (32-f- > shrbitsO))); case HASHSUM: returnfnew hashsum_stats(f- > namef))); case HASHINC: returnfne hashinc statsff- > namef))); case HASHSUMINC:return(new hashsuminc_stats(f-> namef))); case IDXINCSUM: returnfnew idxincsum statsff- > namef), (32-f- > shrbitsf)))); case HASHINCSUM:return(new hashincsum statsff- > nameO)); case CSUMINC: returnfO); } } // XMIT.CPP iiiiimmimiiiiiimmiiimiimiiiiiiimiiiiiiiiiiiiiiiiiiiiiiii include "gen.hpp" // // IPX checksum incremental update routine (bitswapped) // extern U32 lpxCsumUpd(U32 value, U32 change); ^pragma aux IpxCsumUpd - \ "mov ecx,FrameLen" 1 "sub ecx,ParseLen" \ "sub ecx,ProtoParseLen" \ U32 vary Jpxcsum::vary_value(U32 val) { returnflpxCsumUpdfval, operand)); } // CHECKSUM.HPP //////////////////////////////////////////////////////////////////////////////// // Base Class definition for verifying and computing protocol checksums class CheckSum { public: // // Constructor CheckSumf) {} virtual — CheckSumf) {} // // Member Functions virtual BOOL verifyf) { returnfO); } // Verify checksum virtual void compute)) {} // Compute checksum }; // Derived Class definition verifying and computing IP Checksums // Verify IP Header Checksum in Network Byte Order...No byte swapping required // (Assumes Header Length is greater than 4 32-bit words) // (Returns 0 if checksum OK, non-zero otherwise) ιιmιιιιιιiMmmιmιιιιιιιιmιιιιιιιιmmιιιιιιιιιιι\ιιιιιιι\ιι extern U32 ChklρCsum(S8 *h); // Clocks - 14 + #OptionBytes ^pragma aux ChklpCsum - \ "mov ebx,[edx]" \ "mov eax,ebx" \ "and ebx, + OfH" \ "mov ecx,+4H[edx]" \ "sub ebx,5" \ "jle Header" \ "Options:adc eax,+ 10H[ebx * 4+edx]" \ "dec ebx" \ "jg Options" \ "Header: mov ebx, + 8H[edx]" \ "adc eax,ecx" \ "mov ecx, + OcH[edx]" \ "adc eax.ebx" \ "mov ebx, + 10H[edx]" \ "adc eax,ecx" \ "adc eax.ebx" \ "adc eax,0" \ "mov ecx,eax" \ "shr eax, 16" 1 "add ax,cx" 1 "adc ax,0" \ "not ax" \ parm [edx] \ modify [ebx ecx] 1 value [eax] class CheckSumJP: public CheckSum { public: // Constructor CheckSumJPO {} // // Verify IP Checksum (Return TRUE if OK, FALSE otherwise) BOOL verifyO { return(ChklpCsum(ParsePtr) = = 0); } // // Compute IP checksum and insert into IP header void computed {// (35/36 + 3*(0ption DWORDS)) (20 - 0.360 usecs; 60 - 0.660 usecs) U16 *csum = ((U16 *)ParsePtr + 5); // Declare Pointer to Checksum Field *csum - 0; // Clear Checksum in IP Header *csum = (U16)ChklpCsum(ParsePtr); // Compute and Update Checksum } private: }; // Derived Class definition verifying and computing IPX Checksums // Verify IPX Header Checksum in Network Byte Order...No byte swapping required // (Assumes Checksum Field is NOT Oxffff, and 30 > = Length Field < = Oxffff) // (Returns 0 if checksum OK, non-zero otherwise) extern U32 ChklpxCsum(S8 *h); // Clocks = 5 + V(tt Words) ^pragma aux ChklpxCsum - 1 "cmp edx,ecx" I "jl NxtWord" I parm [ebx] \ modify [ecx edx] 1 value [eax] class CheckSum IPX: public CheckSum { public: // // Constructor CheckSumJPXf) {} // // Verify IPX Checksum (Return TRUE if OK, FALSE otherwise) BOOL verifyf) { return(*(U16 *)ParsePtr - - Oxffff | | *(U16 *)ParsePtr = = ChklpxCsum(ParsePtr)); } // // Compute IPX checksum and insert into IPX header void computef) {// (20/21 + 7*W0RDS) (30 - 1.26; 96 - 3.57; 512 - 18.13 usecs) *(U16 * )ParsePtr - (U16)ChklpxCsum(ParsePtr); } private: }; extern "C" U32 csumBytes(S8 'Data, U32 Len); // ASM TCP/IP Checksum Routine extern "C" U32 csumPseudo(U32 Csum, S8 # lpHdr); // ASM PseudoHeader Checksum // Derived Class definition verifying and computing TCP Checksums class CheckSum TCP: public CheckSum { public: // // Constructor CheckSumJTCPO {} // Verify TCP Checksum (Return TRUE if OK, FALSE otherwise) BOOL verifyf) { U32 csum - csumBytesfParsePtr, (FrameLen-ParseLen+ ProtoParseLeπ)/8); returnfcsumPseudofcsum, ParseList.operator[](ParseLevel-2)) - - 0); } // // Compute TCP checksum and insert into TCP header void computeO { f(U16 *)ParsePtr)[8] = 0; // Clear checksum field U32 csum - csumBytesfParsePtr, fFrameLen-ParseLen + ProtoParseLen)/8); (1U16 *)ParsePtr)[8] = (U16)csumPseudo(csum, ParseList.operator[](ParseLevel-2)); } private: }; // Derived Class definition verifying and computing UDP Checksums class CheckSumjJDP: public CheckSum { public: // // Constructor CheckSum JJDPf) {} // // Verify UDP Checksum (Return TRUE if OK, FALSE otherwise) BOOL verifyO { U32 csum - csumBytes(ParsePtr, (FrameLen-ParseLen+ ProtoParseLen)/8); returnfcsumPseudofcsum, ParseList.operator[](ParseLevel-2)) = - 0); } // // Compute UDP checksum and insert into UDP header void computed { f(U16 *)ParsePtr)[3] - 0; // Clear Checksum field U32 csum = csumBytesfParsePtr, (FrameLen-ParseLen + ProtoParseLen)/8); (fU16 *)ParsePtr)[3] = (U16)csumPseudo(csum, ParseList.operator[](ParseLevel-2)); } } ; // DECODE.HPP // // Protocol Field Class Description // // enum out Jmt {BIN, DEC, HEX, HW, ASC }; enum rangetypes { ODDNUMBERS- 1, EVENNUMBERS, ALLNUMBERS}; class lookup; II forward reference class protocol; class field { public: // Constructors fieldf): fdwoff(O), fshl(O), fshr(O), f fmt(2), flflag(O), fπame(O), fblen(8), reserved(O), fmultU), fdspfieldfl), fswapf l), fplenfO), ptr2stats(0), ptr2np(0), ptr2vary(0), ptr2csum(0), ptr2flt{0), ptr2rte(0) {} field(U32 o, U8 1, U8 r): ffmt(2), flflag(O), fname(O), reserved(O), fmultd ), fdspfieldfl), fswapd ), fplenfO), ptr2stats(0), ptr2np(0), ptr2varyf0), ptr2csum(0), ptr2flt(0), ptr2rte(0) { fdwoff - o; fshl - I; fshr - r; fblen = 32 • fshr; } // Destructor - fieldf) { #ifdef notdef if (fπame ! - 0) delete []fname; if <ptr2stats ! - 0) delete ptr2stats; if (ptr2np ! - 0) delete ptr2np; if (ptr2vary ! = 0) delete ptr2vary; if (ptr2csum ! - 0) delete ptr2csum; if (ptr2flt !- 0) delete ptr2f It; if fptr2rte ! - 0) delete ptr2rte; #endif } // Overloaded operators field& operator - (const f ield& f ) { fplen - f.fplen; fblen = f.fbleπ; fdwoff - f.fdwoff; fshl - f.fshl; fshr - f.fshr; ffmt = f.ffmt; flflag - f.flflag; reserved = f.reserved; fmult = f.fmult; fswap - f.fswap; fdspfield- f.fdspfield; fname - f.fname; ptr2stats= f.ptr2stats; ptr2np - f.ptr2np; ptr2vary - f.ptr2vary; ptr2csum = f.ptr2csum; ptr2flt = f.ptr2flt; ptr2rte = f.ptr2rte; return(*this); } Routine to compute bit offset of field from start of protocol header U32 bitoffsetO const { retumffdwoff*8 + fshl); } Routine to read/write field offset value U32 offsetf) const { returπffdwoff); } void offset(U32 o) { fdwoff - o; } Routines to read/write left shift value U32 shlbitsO const { retum(fshl); } void shlbits(U8 1) { fshl - I; } Routines to read/write right shift value U32 shrbitsO const { retumffshr); } void shrbits(U8 r) { fshr - r; } Routines to read/write field format value U8 formatf) const { returnfffmt); } void format(U8 f) { ffmt - f; } Routines to read/write display this field flag U8 dspfieldf) const { returnffdspfield); } void dspfield(U8 f) { fdspfield - f; } Routines to read/write field name S8 *name{) const { returnffname); } void namefSδ *n) { if (n !- 0) { if (fname ! - 0) delete []fname; fname = new S8[strlen(n)+ 1]; strcpyffπame, n); } } // // Routines to read/write header length flag U8 hdlenf) const { retumfflflag); } void hdlen(U8 1) { flflag - I; } // // Routines to read/write field length in bits U32 bitlenO { returnffblen); } void bitlen(U32 1) { fblen - I; } // // Routines to read/write field multiplier value (for display) Uδ multiplier)) const { returnffmult); } void multiplierfUβ m) { fmult = m; } // // Routines to read/write end of display line character U8 swapf) const { returnffswap); } void swapfUδ c) { fswap - c; } // // Routines to read/write overall protocol length field U32 protlenf) const { returnffplen); } U32 protlen(U32 p) { returnffplen - p); } // // Routines to read/write pointer to statistics collection object stats * statsptrf) const { return(ptr2stats); } void statsptrfstats *s) { ptr2stats - s; } II // Routines to read/write pointer to lookup value validation object lookup 'lookptrf) const { return(ptr2np); } void lookptrflookup *l) { ptr2np - I; } // // Routines to read/write pointer to vary field value object vary *varyptr() const { retum(ptr2vary); } void varyptr(vary *v) { ptr2vary = v; } // // Routines to read/write pointer to checksum verification object CheckSum *csumptr() const { return(ptr2csum); } void csumptrfCheckSum *c) { ptr2csum = c; } // // Routines to read/write pointer to filter criteria object criteria *fltptr() const { return(ptr2flt); } void fltptrfcriteria *c) { ptr2flt - c; } // // Routines to read/write pointer to Routing Table object RouteTable "rteptrf) const { returπ(ptr2rte); } void rteptrfRouteTable *r) { ptr2rte - r; } // // Routine to extract field values using offset, left and right shift values // value - ((values at offset) < < left shift) > > right shift // // Value could also be extracted by: // ((value & predetermined MASK) > > predetermined SHR) // ... to eliminate a 4 clock left shift by ci on 486/Pentium // U32 get valueO { U32 *ptr - (U32 *)(ParsePtr + fdwoff); U32 val = *ptr; if (fswap !- 0) { val - wordswap(val); if (ptr2vary - - 0) returnffval < < fshl) > > fshr); else // This field needs its value varied retum(*ptr - wordswap(ptr2vary- > vary yalue(val))); } else { if (ptr2vary - - 0) returnffval < < fshl) > > fshr); else // This field needs its value varied return(*ptr - ptr2vary- > vary valuefval)); } } // // Routine to check field value for validity // U32 value_ok(U32 value, U32 &i, protocol * &tp) { verify *v; if (ptr2np - - 0) { + +i; return(TRUE); } if ((v = ptr2np- > value ok(value)) - - 0) { + +i; return(FALSE); } else { if (tp - - 0) tp - v- > prot; i - v- > nxtidx; return(TRUE); } } // // Routine to write field to designated output file // void out Jo Jile(FILE *fp) { fwritef&fplen, sizeofffpleπ), 1, fp); fwritef&fblen, sizeof (fblen), 1, fp); fwritef&fdwoff, (S8 *)&fname - (S8 *)&fdwoff, 1, fp); // U32 tmp; if (fname ! - 0) { tmp - strlenffname) + 1; fwritef&tmp, sizeofftmp), 1, fp); // Write out length of field name fwriteffname, tmp, 1, fp); // Write out field name } else { tmp = 0; fwritef&tmp, sizeofftmp), 1, fp); // Write out length of field name } // tmp = (ptr2stats - - 0) ? NOSTATS : ptr2stats- > getjypef); fwritef&tmp, sizeofftmp), 1, fp); // Write out type of stats to gather // if (ptr2np = - 0) { tmp = NOLOOKUP; fwritef&tmp, sizeofftmp), 1, fp); } else { tmp - ptr2np- > getjypef); fwritef&tmp, sizeofftmp), 1, fp); ptr2np- > out Jo Jileffp); // Write out values/ranges in lookup } } // // Routine to set up existing field object from designated file // void get romJilefFILE *fp) { U32 tmp; freadf&fplen, sizeofffplen), 1, fp); f readf&f blen, sizeof (fblen), 1 , fp); fread(&fdwoff, (S8 *)&fname - (Sδ *)&fdwoff, 1, fp); // freadf&tmp, sizeofftmp), 1, fp); // Read length of field name if (tmp ! - 0) { fname - new S8[tmp]; freadffname, tmp, 1, fp); // Read field name } else fname = 0; fread(&tmp, sizeof(tmp), 1, fp); // Read type of stats to be gathered ptr2stats - alloc_stat_structs(tmp, this); freadf&tmp, sizeof(tmp), 1, fp); // Read type of lookup structure if ((ptr2np = alloc Jookup_structs(tmp, this)) ! - 0) ptr2np- > get fromjile(fp); // Read all lookup values for field } void OutlineFieldlHDC hdc, protocol *p, U32 dspbW) const; void OutlineFieldVaKHDC hdc, protocol *p, U32 dspbW, unsigned long val, unsigned char fmat, unsigned long bitwid) const; U32 field::FindF(U32 x, U32 y, U32 dspbW) const; // Data Representation private: // General purpose field descriptors U32 fplen; // if not 0, value * field contents is FrameLen U32 fblen; // field length in bits U32 fdwoff; // field offset in bytes U8 fshl; // Number of bits to shift left U8 fshr; // Number of bits to shift right Uδ ffmt; // Field output display format Uδ flflag; // if TRUE this field contains length of option Uδ reserved; // not used...pad to align following fields Uδ fmult; // multiply value by this amount before display U8 fswap; // Flag indicating the need to swap bytes and words Uδ fdspfield; // display this field on output S8 *fname; // user defined field name stats *ptr2stats; // Pointer to derived statistics class lookup *ptr2np; // Pointer to derived lookup class (next_protocol) vary *ptr2vary; // Pointer to Vary field value class CheckSum *ptr2csum; // Pointer to Checksum class for current protocol criteria *ptr2flt; // Pointer to Filter Criteria class for this field RouteTable *ptr2rte; // Pointer to Route Determination class }; // Template class for defining fixed length protocol header fields // // class protocol { public: // // Constructors protocolf): name lengthfO), protocoljιame(O), fname(O), num Jields(O), num_hits(0), out Jlag(O), fs(O), dbW{32), opts(O), Rt(O) {} // protocol(S8 *pn, S8 *fn, protocol *p-0): num ields(θ), num_bits(0), out_flag(0), fsfO), cur Jield(O), dbW(32), RtfO) { name length = strlenfpn) + 1 ; protocoljiame = (S8 *)malloc(nameJength); strcpyfprotocoljiame, pn); fname - (S8 *)mailoc(strlen(fn)+ 1); strcpyffπame, fn); opts = p; // Pointer to protocol for parsing options } // protocolfint fd) { readffd, &nuπ Jields, sizeoffnum fields)); fs = new fieldfnum fields]; readffd, fs, numjields'sizeofffield)); } // open file and init structure in memory // Destructor ~ protocolf) { if (protocol name ! - O)free(protocol name); if (fname ! - 0) free(fname); if (fs!-0) delete []fs; if (opts ! - 0) delete opts; if {Rt !- Oi delete Rt; } // Routines to read/write protocol name length field U32 pnamelenO const { returnfname length); } void pnamelen(U32 nl) { name length - nl; } // // Routines to read/write protocol name field S8 "pnamef) const { returnfprotocol name); } void pnamefSδ *π) { if (n!-0) { if (protocol name ! = 0) delete []protocol_name; protocoljiame = newS8[strlen(n)+1]; strcpy(protocol_name, n); } } // // Routines to read/write protocol file name Sδ "filenameO const { return(fname); } void filenamef S8 *π) { if (n !- 0) { if (fname ! - 0) delete []fπame; fname = newS8[strlen(n)+1]; strcpyffname, n); } } II II Routines to read/write number of fields U32 numfieldsf) const { returnfnumjields); } void numfields(U16 nf) { numjϊelds - nf; } // // Routines to read/write current field U32 curfieldf) const { returnfcur ield); } void curf ield(U32 idx) { cur Jield - (U 16)idx; } // // Routines to read/write number of bits U32 numbitsf) const { return(num_bits); } void numbits(U32 nb) { num_bits = nb; } // // Routines to read/write fields pointer field "fieldptrf) const { returnffs); } field *fieldptr(U32 i) const{ retum(&fs[i]); } // Indexing void fieldptrffield *f) { f s - f; } // // Routines to read/write options pointer protocol "options!) const { returnfopts); } void optionsfprotocol *o) { opts - o; } // // Routines to read/write pointer to Routing Table RouteTable * RouteTblf) const { return(Rt); } void RouteTblfRouteTable *r){ Rt - r; } // // Routine to clear the protocol already output flag void clear out flagO { out flag = 0; } // // Routines to read/write the display bit width field U32 dspbWO const { return(dbW); } void dspbW(U32 bW) { dbW = bW; } // // Routine to set current field to previous // U32 prevfieldt) { if (cur ield > 0) -curjield; else return(FALSE); return(TRUE); } // // Routine to set current field to next // U32 πextfieldf) { if (curjield < (numJields-D) + + cur field; else return(FALSE); returnfTRUE); } // // Routine to output entire protocol to file...Save As passes parameter fp // void out Jo Jile(FILE "fp-0) { if (out flag ! = 0) return; out flag - 1; if (fp ! - 0 | | (fp - fopenffname, "wb")) ! = 0) { fwritef&namejength, sizeof (name Jength), 1, fp); fwrite(protocol_name, name Jength, 1, fp); fwrite(&num_bits, sizeof(num bits), 1 , f p); fwrite(&num fields, sizeof (num fields), 1, fp); fwritet&numjields, sizeof (num fields), 1, fp); fwrite(&dbW, sizeof (dbW), 1, fp|; // // Write out each field // for (U32 i-0; i < num fields; i+ + ) fs[i].out_toJile(fp); // // Write out option name length and any options // U32 tmp = (opts - - 0) ? 0 : opts- > name Jength; fwrite(&tmp, sizeof (tmp), 1, fp); if (opts ! - 0) { fwrite(opts- > protocoljiame, opts- > name Jength, 1, fp); fcloseffp); opts- > out Jo Jilef); } else fcloseffp); } } // // Routine to initialize a protocol from a file // void get JromJilefFILE *fp); // // Routines for configuration and display purposes // void setupOutlineCoordsf); void setupOutlineCoordsMultfint continu); void OutliπeProtocolfHDC hdc) const- void OutiineProtocolValfHDC hdc) const- void FindFieldfHWND hwnd, U32 x, U32 y); void addJield(U32 idx, protocol *p); void add Jield_after(U32 idx, protocol *ptl); void delete Jield(U32 idx.protocol *ptl); // // Data fields private: U32 name Jength; // Length of protocol name in bytes Sδ "protocol name; // Protocol name in Ascii Sδ "fname; // File name in Ascii U32 num bits; // ff of bits in fixed portion of protocol header U 16 num fields; // # of fields used to describe protocol header U16 curjield; // Index of last field displayed U32 out Jlag; // Protocol has been output 'flag' U32 dbW; II Display bit width (i.e. #bits per line) field "fs; // Fields for fixed portion of protocol header protocol "opts; // Pointer to protocol for parsing options RouteTable "Rt; // Pointer to Protocol Route Table }; extern void create templates!); extern protocol "ParseProtocoKprotocol *p); extern protocol *ParseProtocol2(protocol *p); extern protocol "DataPtlPtr, "PadPtlPtr; FILTER.HPP enum FilterStuff { FILTER FRAME, PASS_FRAME, MAX ILTERS- 20 }; extern U32 FrameFilterStatus; #define MODIFY 0 define INSERT 1 class Filters; class channel; iiiiiiiiiiiiiimiimiimiiiimimiiiiiiimiiiimmiiiiiiiiiiiiii II Filter Channel Criteria Class // Consists of: • Index # of this filter channel criteria - Pointer back to filter channel of this criteria - Pointer to lookup class containing criteria values Pointer to associated protocol class Pointer to associated protocol field class class criteria // Filter Channel Criteria Class { public: // // Constructor criteria!): IndexfO), ChPtr(O), Ranges(O), Ptl(O), Fld(O) { } // // Destructor - criteria!) { if (Ranges ! = 0) delete Ranges; } // // Member Functions // // Allows pre-declared criteria class to be filled in void FilllnCriteria(U32 i, channel *c, lookup *r, protocol *p, field *f) { Index - i; ChPtr = c; Ranges = r; Ptl = p; Fid = f; } // // Applies the configured filter channel criteria to a received field value void ApplγFilterCriteria(U32 value); // private: U32 Index; // Zero-based index number for this filter criteria channel "ChPtr; // Pointer to Associated Filter Class lookup "Ranges; // Pointer to lookup instance for this filter criteria protocol "Ptl; // Required for Configuration/Display purposes only field "Fid; II Required for Configuration/Display purposes only }; Filter Channel Class NextCriterialndex • Index of next filter criteria to apply TotalCriteria - Number of criteria that define this filter Criteria - Pointer to defining Criteria classes ChannelName - Pointer to Channel Name string FramesAccepted • # of Frames that passed filter channel criteria FrameBitsAccepted - it of Frame Bits that passed filter channel criteria class channel { public: // Constructors/Destructor channel(U32 nci-0, U32 tot-0, criteria *ptr-0, Sδ *πame-0) : NextCriterialπdexfnci), TotalCriteriaftot), Criteriafptr), ChannelNamefname), FramesAccepted(O), FrameBitsAccepted(O) { } ~ channelf); // must be defined in .cpp file to compile // // Equivalence operator ... required by WCPtrOrderedVector < channel > class int operator- -(const channels f) const { return(strcmp(CfιanπelName, f.ChannelName) - - 0); } // // Member Functions // // Disables channel criteria application by indicating all criteria applied void Disabled { NextCriterialndex - TotalCriteria; } II II Load/Store Functions for NextCriterialndex field U32 NciValuef) { returnfNextCriterialndex); } void NciValuefU32 value) { NextCriterialndex - value; } // // Uses verify class pointer to update NextCriterialndex // if the channel criteria status (prot) is not PASS FRAME // returns FALSE // else // Returns TRUE and updates the # of frames/bits accepted thru this channel // void Update(verify *v); // private: U32 NextCriterialndex; // Index of next channel criteria to be applied U32 TotalCriteria; // For display and disabling filter evaluation criteria "Criteria; // Pointer to array of channel criteria Sδ "ChannelName; // Pointer to name of channel U64 FramesAccepted; // Number of Frames Accepted by this channel U64 FrameBitsAccepted; // Number of Bits Accepted by this channel }; // Active Filters Class (e.g. CfgFilters, DisplayFilters, ... class Filters { public: // // Constructor FiltersO { FilterStat - PASS FRAME; Filters - new WCPtrOrderedVector < channel > ; } // // Destructor ~ FiltersO { if (Filters != 0) delete Filters; } // // Member Functions // // Number of Configured Filters U32 entriesO const { returnfFilters- > entriesO); } // // Insert filter into FilterTable int insertfchanπel *f) { FilterStat - FILTER RAME; returnfFilters- > insertff)); } // // Remove filter from FilterTable channel "removefchaππel *chn) { if ((chn - Filters- > remove(chn)) ! - 0 && entriesO = ■= 0) FilterStat = PASS RAME; returnfchn); } // U32 FrameFilterStatusO { return(FilterStat); } void FrameFilterStatus(U32 Status) { FilterStat - Status; } // // Reset all Configured Filters void resetf) { FilterStat - entriesO ? FILTER RAME : PASS FRAME; for (U32j-0;j< entriesO; j++) Filters- > operator[](j)- > NciValue(O); } private: U32 FilterStat; WCPtrOrderedVector < channel > "Filters; // Pointer to Configured Filters Table }; extern Filters CfgFilters; // Configured Filters Object // GEN.HPP //////////////////////////////////////////////////////////////////////////////// ^define INCLUDE COMMDLG H 1 ^include <windows.h> ^include < iostream.h > ^include <stdio.h> include <stdlib.h> ^include <malloc.h> ^include < string.hpp > include < conio.h > ^include <time.h> ^include <iomanip.h> include <wchash.h> ^include <wcvector.h> include <io.h> include <dos.h> ^include "pa.hpp" // // Menu Item identifiers for now // // ^define MAIN_MENU_POS 1 ^define HELLO_MENU_POS 2 ^define RECT_MENU_POS 1 #define IDM NEWHELLO 10 #define IDMJYEWRECT 11 //^define IDM CLOSE 12 //^define IDM XIT 13 ^define IDM BLACK 20 ^define IDM_RED 21 #define IDM GREEN 22 #define IDM LUE 23 ^define IDM WHITE 24 ^define IDM FIRSTCHILD 100 // TEMP Menu bar stuff for demo #define IDM MACPTL 101 #define IDM RAMENAME 102 #define IDM RAMEFILE 103 #define IDM_NEXTFRAME 104 #define IDM PREVFRAME 105 #define IDM RUN 106 #define IDM ALYZERCLOSE 107 #definelDM_TRACEFILE0PEN110 ^define IDM TRACEFILENEW 111 "/ enum status { OTOK, OK }; extern U32 ParseLevel; extern WCValVector < S8 " > ParseList; extern S8 "FramePtr, "ParsePtr; extern U32 HwLen, FrameLen, ParseLen, ProtoParseLen, HeaderLen; extern U32 Srclntf, lntfTypes[256]; extern S8 bs[256]; // // Data and code for efficiently performing byte swapping // // // Generic 2 byte swap routine (inline assembly) // // extern U16 bγteswap(U16 w); #pragma aux bγteswap - \ "rol ax,8" 1 parm [ax] \ modify [ax] 1 value [ax] // // Generic 2 word swap routine (inline assembly) // // extern U32 wordswap(U32 d); ^pragma aux wordswap - 1 "bswap eax" 1 parm [eax] \ modify [eax] \ value [eax] // // Function templates for implementing miπ() and max!) functions // // template < class TYPE > inline TYPE miπ(TYPE a, TYPE b) { returnϋa < b) ? a : b); } // template < class TYPE > inline TYPE max(TYPE a, TYPE b) { returnffa > b) ? a : b); } // template < class TYPE > inline TYPE "swapminmaxfTYPE "a, TYPE *b) { if (a.minval < a.maxval) returnfa); b.minval - a.maxval; b.maxval - a.minval; returnfb); } // // 64 bit numbers class and associated pragmas // class U64; extern void add64(U64 *u, U32 val); ^pragma aux add64 - \ "add [edx],esi" 1 "adc +4H[edx],dword ptr O" 1 parm [edx] [esi] extern void sub64(U64 *u, U32 val); pragma aux sub64 - \ "sub [edx],esi" \ "sbb +4H[edx],dword ptr O" \ parm [edx] [esi] class U64 { // constructors public: U64(): hi(O), lo(0) {} U64(U321):hi(0) {lo - I; } U64(U32h, U321) { hi - h;lo - I; } // destructor ~ U64() {} // Member functions // void printf) const; // upto 99,999,999,999 (100 billion) (14 characters) U32 lovaK) { returnflo); } U32 hivalO { return(hi); } U32 sumf) { U32 h = hi; hi - 0; lo + - h; if (hi ! - 0) + +lo; returπ(lo); } void clearO { lo = hi = 0; } U64 *init(U32 value) { lo - value; return(this); } // overloaded operators U64 operator + + () { add64fthis, 1 ); returnf "this); } U64 operator--!) { sub64(this, 1 ); return( * this); } U64 operator + = (U32 sz) { add64(this, sz); retumfthis); } U64 operator- - (U32 sz) { sub64(this, sz); return(*this); } U64& operator -(U32 sz) { hi - 0; lo - sz; retumfthis); } U64 operator+(U32 sz) { add64(this, sz); retumfthis); } U64 operator-(U32 sz) { sub64(this, sz); retumfthis); } int operator- -(const U64 &u) const { returndo - - u.lo && hi - - u.hi); } // data representation private: U32 lo, hi; }; include "stat.hpp" ^include "lookup.hpp" include "xmit.hpp" ^include "checksum.hpp" ^include "filter.hpp" ^include "route.hpp" ^include "decode.hpp" ^include "pcols.hpp" LOOKUP.HPP /♦««*»♦..♦.**»»**».»*»»*.*•**»»*»**•»»»**»****. »**.»»**..*..»..*.l. » # »» # *♦ **♦*»»#»♦*..*.»«*»*«**».*»***»****»»«*»*»»*»*.*.*»»»«..*.»»«... # ( ## » #♦ »» // Lookup Next Protocol Base Class Definition // Virtual member functions // ιr class protocol; class verify { public: // // Constructors verifyf): minval(O), maxval(O), okbitsfO), nxtidxf-1), xlat(O) {} // verifyfprotocol *p, S32 indx, U32 miπv, U32 maxv, U32 bits, Sδ* xl) { prot - p; minval - minv; maxval - maxv; okbits - bits; nxtidx - indx; xlat - xl; } // verifyfconst verify& t) { prot - t.prot; minval - t.minval; maxval - t.maxval; okbits - t.okbits; nxtidx - t.πxtidx; xlat - t.xlat; } // // destructor — verifyO {} // // overloaded operators int operator- -(const verify &t) const { returnfminval > - t.minval && maxval < - t.maxval); } // int operator < (const verify &t) const { returnfmaxval < t.minval); } // verify & operator -(const verify &t) { prot - t.prot; nxtidx - t.nxtidx; minval - t.minval; maxval - t.maxval; okbits - t.okbits; xlat - t.xlat; retumfthis); } // // Routine to output verify object to file void out Jo JilefFILE *fp) const; // // Routine to setup verify object from file void get Jrom JilefFILE *fp); // // data representation (PUBLIC DATA) protocol "prot; S32 nxtidx; U32 minval; U32 maxval; U32 okbits; S8 "xlat; }; enum lookuptypes{ NOLOOKUP, ONEVALUE, ARRAY, HASH, TREE }; imiiiiiiiimimiimimiiiiimiiiiiiimimiiiiiiiiiiiiiiiiiiiiii II class protocol; class lookup { public: // No constructors !!! // // Destructor virtual ~ lookup)) {} // default behavior // // Routine to insert verify structure into lookup class virtual BOOL insert protocolfprotocol *p, S32 idx, U32 minv=0, U32 maxv-O, U32 bits-O, Sδ • xlat-O) { p - 0; idx - 0; minv - maxv - bits - 0; xlat - 0; return(TRUE); } virtual U32 entries!) { returnfO); } // default behavior virtual verify *find index(U32 idx) { idx - 0; returnfO); } virtual verify *inc index(U32 insertidx) {iπsertidx-O; returnfO); } virtual verify *dec index(U32 deleteidx) {deleteidx-O; returnfO); } virtual BOOL insert entryfprotocol "prot, S32 nxtidx, U32 minval-0, U32 maxv.l-0, U32 okbits-0, S8 *xlat-0) { prot - 0; nxtidx - 0; minval - maxval - okbits - 0; xlat = 0; returnfTRUE); } virtual BOOL delete_entry(U32 idx, U32 min-0) { idx - min - 0; returnfTRUE); } virtual BOOL modify_entry(U32 idx, protocol "prot, S32 nxtidx, U32 minval-0, U32 maxval-0, U32 okbits-0, S8 *xlat-0) { prot = 0; idx - 0; nxtidx - 0; minval - maxval = okbits - 0; xlat - 0; retum(TRUE); } virtual protocol *next_protocol(U32 value) { value = 0; return(O); } // default behavior virtual verify *value_ok(U32 value) { value - 0; return(O); } virtual U32 get typed { returπ(NOLOOKUP); } virtual void out to JilefFILE *fp) const { fp - 0; } virtual void get from JilefFILE "fp) { fp = 0; } protected: private: }; ///////////////////////////////////////////////////////////////////////I//////// // Derived Single Entry (Next Protocol) Lookup Class Definition // For use where the current protocol has only 1 upper level protocol // // Virtual member functions // insert_protocol(protocol *p) • Insert protocol pointer // protocol *next_protocol(U32 value) - returns protocol pointer class lookup valu: public lookup { public: // // Constructor lookup valu() { range - new verify; range- > prot - 0; range- > nxtidx - -1; entrees - 0; } // / Destructor ~ lookup valuf) { delete range; entrees -0; } / / return number of entries in derived class U32 entriesO { returnfentrees); } / verify *findJndex(U32 idx) { idx - idx; returnfrange); } verify *inc index(U32 idx) { if (idx < - range- > nxtidx) range- > nxtidx + +; return(O); } verify *decJndex(U32 idx) {if (idx < - range- > nxtidxS&range- > nxtidx ! = 0) -range- > nxtidx; return(O);} / Insert field range structure '/ BOOL insert entryfprotocol "prot, S32 nxtidx, U32 minval-O, U32 maxval-O, U32 oktits=0, Sδ *xlat-0) { if (minval > maxval) { U32 tmp - minval; minval - maxval; maxval - tmp; xlat - 0; } range- > prot = prot; range- > minval - minval; range- > maxval - maxval; range- > okbits - okbits; range- > nxtidx = nxtidx; entrees - 1; returnfTRUE); } // // Delete field range structure // BOOL delete_entry(U32 idx, U32 min-0) { if (idx > - entriesO) // Only delete existing entries return(FALSE); min -entrees -0; returnfTRUE); //tptr- > removeAtfidx)); } // // Modify (update) existing field range structure values // BOOL modify_entry(U32 idx, protocol "prot, S32 nxtidx, U32 minval-0, U32 maxval=0, U32 okbits-0, Sδ *xlat-0) { xlat - 0; if (idx > - entriesO) return(FALSE); if (minval > maxval) { U32 tmp - minval; minval - maxval; maxval = tmp; } range- > prot = prot; range- > minval - minval; range- > maxval - maxval; range- > okbits - okbits; range- > nxtidx = nxtidx; returnfTRUE); } // // Inserts pointer to protocol into prot BOOL insert protocolfprotocol "prot, S32 idx, U32 minv-0, U32 maxv-O, U32 bits- D) { range- > prot = prot; range- > nxtidx - idx; rβπge- > minval = minv; range- > maxval = maxv; range- > okbits = bits; returnfTRUE); } // // Returns pointer to protocol class protocol *next_protocol(U32 value = 0) { value - value; returnfrange- > prot); } // // Verify that value is within specified range verify *value_ok(U32 value) { if fvalue > = range- > minval && value < = range- > maxval) { if fvalue & 1) // It's an odd number { if (range- > okbits & 1 ) // ODD and ALL numbers ok returnfrange); } else // It's an even number { if (range- > okbits > 1 ) // EVEN and ALL numbers ok returnfrange); } } returnfO); } ' / 7 return lookup type U32 get ypef) { return(ONEVALUE); } 7 Output lookup object to file void out Jo JilefFILE *fp) const { if (entrees- - 1 ) range- > out to fileffp); } setup lookup structure from file void get from JilefFILE *fp) { entrees = 1; range- > get from fileffp); } 7 // Data Representation private: verify "range; // Pointer to protocol class U32 entrees; // Indicates whether the entry has been setup }; iiiiiiiiiiiimmiiiiiimiimiiiiiiiiiiiimiiiiiimiiimmiiiiiii II Derived Multiple Entry (Next Protocol) Table Lookup Class Definition // For use where the values are small in size and number and closely // spaced. The IP protocol field is an excellent example of this // case. The numbers range from 0 to 255 so an array of pointers // requires 256 * sizeoffprotocol *) or 1024 bytes. // // Virtual member functions // insert protocolfprotocol *p) - Insert protocol into lookup // protocol *πext_protocol(U32 value) - Returns pointer to next protocol class lookup j/ect: public lookup { public: // // Constructor lookup_vect(U32 maxsz-256) { size - maxsz; array - new verify[size+1]; memsetfarray, 0, (size + 1 )*sizeoffverify)); } // //Destructor ~ lookup vectf) { memset(array, 0, (size+ 1)*sizeof(verify)); delete [Jarray; entrees -0; } // // Member functions U32 entriesO { for (U32 i-0, num - 0; i< size; i+ + ) if (array [il.okbits !- 0) + +num; returnfnum); } // // verify *findJndex(U32 idx) { for (U32 i-0, j=0, num-entriesf); i<size&&j< num; i++) if (array[i].okbits != 0 &&idx -- j++) returπf&arrayfi]); returnfO); } // // verify "inc index(U32 insertidx) { for(U32i-0;i<size;i++) if((array[i].okbϊts! = 0)&& (insertidx < - array[i].nxtidx)) array[i].πxtidx++; return(O); } // // verify "dec Jndex(U32 deleteidx) { for (U32 i-0; i < size; i+ + ) if ffarray[i].okbits!-0)&& fdeleteidx < - array[i].nxtidx)) arrayhl.nxtidx--; returnfO); } // Insert field range structure into binary tree // BOOL insert entryfprotocol "prot, S32 nxtidx, U32 minval =0, U32 maxval -0, U32 okbits -0, Sδ *xlat-0) { xlat - 0; if (minval > - size | | array[minval].okbits ! - 0) return(FALSE); if (minval > maxval) { U32 tmp - minval; minval - maxval; maxval - tmp; } for (U32 i = minval; i< -maxval; i+ + ) { if(array[i].okbits!- 0) { if ( ((array[i].minval > - minval) && (array[i].miπval < = maxval)) | | f(array[i].maxval > - minval) && (array[i].maxval < = maxval)) ) return(FALSE); } } array[minval].prot - prot; array[minval].minval - minval; array[minval].maxval - maxval; array[minval].okbits - okbits; array[miπval].nxtidx = nxtidx; + + entrees; returnfTRUE); } // // Delete field range structure from binary tree // BOOL delete_entry(U32 idx, U32 min) { if (min > = size) // Only delete existing entries return(FALSE); array[min].okbits - 0; -entrees; idx -idx; returnfTRUE); } // // Modify (update) existing fieled range structure values // BOOL modify_entry(U32 idx, protocol "prot, S32 nxtidx, U32 minval =0, U32 maxv,ιl-0, U32 okbits -0, S8 * xlat-0) { xlat - 0; if (idx > - size) retum(FALSE); if (minval > maxval) { U32 tmp = minval; minval - maxval; maxval = tmp; } array[minval].prot - prot; array[miπval].minval - minval; arraγ[minval].maxval - maxval; array[minval]. okbits - okbits; array[minval].nxtidx = nxtidx; returnfTRUE); } // Insert protocol pointer into lookup table at element value BOOL insert protocolfprotocol *p, S32 idx, U32 minv-O, U32 maxv=0, U32 bits-O) { maxv - minfmaxv, size); for (U32 i-minv; i < =maxv; i+ + ) { if f(fi & 1) && (bits & 1)) | | f(i & 1) = = 0 && bits > 1)) { array[i].prot - p; array[i].nxtidx - idx; array[i].minval = minv; array[i].maxval - maxv; array[i].okbits - bits; } } returπ(FALSE); } // // Return protocol pointer at lookup table element value protocol *nextjprotocol(U32 value) { return(array[min(value, size)].prot); } // // verify "value j>k(U32 value) { if (value > size) returnfO); else { verify *v - &array [value]; if (v- > okbits 1- 0) { if (value > - v- > minval && value < - v- > maxval) { if (value & 1) // It's an odd number { if (v- > okbits & 1 ) // ODD and ALL numbers ok return(v); } else // It's an even number { if (v- > okbits > 1 ) // EVEN and ALL numbers ok return(v); } } } return(O); // Value was not found } } // // return lookup type U32 getjypef) { return(ARRAY); } // // Output lookup to file void out Jo filefFILE *fp) const { for (U32 i=0, num = 0; i < size; i+ +) if (array[i].okbits !- 0) + +num; fwrite(&num, sizeof (num), 1 , fp); // Write out number of valid array entries for (i-0; i < size; i+ + ) if (array[i].okbits !- 0) array[i].out Jo Jileffp); // Write out single range } // // Setup lookup from file void get JromJilefFILE *fp) { U32 num; freadf&num, sizeoffπum), 1, fp); // Write out number of valid array entries for (U32 j = 0; j < num; j+ + ) { verify v; v.getjrom ileffp); v.maxval - miπfv. maxval, size); for (U32 i-v.miπval; i < -v.maxval; i+ +) { if (ffi & 1 ) && fv.okbits & 1 )) | | ffi & 1 ) - - 0 && v.okbits > 1 )) { array[i].prot = v.prot; arraγ[i].nxtidx = v.nxtidx; arraylij.minval = i; array[i].maxval - i; array[i].okbits - v.okbits; } } } } // // Data Representation private: U32 size; // Array size in entries U32 entrees; // Number of entries in array verify "array; // Array of pointers to protocol classes }; iiiiiiiiimimiiiiiiimiimiiiimiimiiiiiiiiiMiiiiiiiiiiiiiiiiii // Derived binary tree class for storing field ranges, indices and protocols // iimimiimimmimiiiiiMiiiiiiimiiiiiiiiiiiiiiiiiiiiiiiiiiiii class lookup tree: public lookup { public: II II Constructor lookup tree(U32 treesz-WCDEFAULT_VECT0R_LENGTH) { tptr - new WCValSortedVector < verify > (treβsz); } // // Destructor ~ lookup treef) { delete tptr; } // // Return number of field ranges stored in binary tree U32 entriesO { returπftptr- > entries))); } // // Return pointer to field range structure at specified index verify *find index(U32 idx) { return((idx < entriesO) ? &tptr- > operator[](idx) : 0); } // // verify *iπcJndexfU32 insertidx) { for (U32 i-0; i < entries)); i+ + ) { verify *t - find indexfi); if (insertidx < - t- > nxtidx) t- > nxtid + +; } returnfO); } verify "dec Jndex(U32 deleteidx) { for (U32 i=0; i < eπtriesf); i+ + ) { verify *t - findjπdex(i); if (deleteidx < - t- > nxtidx) t- > nxtidx -; } return(O); } // Insert field range structure into binary tree BOOL insert entryfprotocol "prot, S32 nxtidx, U32 minval-O, U32 maxval-O, U32 okbits-O, S8 *xlat-0) { // swapmiπmaxfminval, maxval); if (minval > maxval) { U32 tmp = minval; minval - maxval; maxval = tmp; } for (U32 i=0; i < entries ; i+ + ) { verify *t = findjndexfi); if f (ft- > minval > = minval) && ft- > minval < -maxval)) | | (ft- > maxval > - minval) && ft- > maxval < -maxval)) ) return(FALSE); } verify rfprot, nxtidx, minval, maxval, okbits, xlat); tptr- > insertfr); returnfTRUE); } // // Delete field range structure from binary tree BOOL delete_entry(U32 idx, U32 min-O) { if (idx > - entriesO) // Only delete existing entries returπ(FALSE); min - min; returnftptr- > removeAt(idx)! - 0); } // // Modify (update) existing fieled range structure values BOOL modify _entry(U32 idx, protocol "prot, S32 nxtidx, U32 minval -0, U32 max al=0, U32 okbits-0, S8 "xlat-0) { if (idx > = entriesO) return(FALSE); if (minval > maxval) { U32 tmp - minval; minval - maxval; maxval - tmp; } verify "vptr = &tptr- > operator[](idx); vptr- > prot = prot; vptr- > minval = minval; vptr- > maxval - maxval; vptr- > okbits = okbits; vptr- > nxtidx - nxtidx; vptr- > xlat - xlat; returnfTRUE); } // // Return protocol pointer in binary tree with specified value protocol *πext_protocol(U32 value, S32& idx) { verify srchfO, 0, value, value, 0, 0), t; idx - -1; if (tptr- > findtsrch, t) = - 0) returnfO); idx - t.nxtidx; return(t.prot); } verify *vaiue_ok(U32 value) { static verify t; verify srchfO, 0, value, value, 0, 0); if (tptr->find(srch,t)!= 0) { if (value & 1) // It's an odd number { if (t.okbits & 1 ) // ODD and ALL numbers ok returnf&t); } else // It's an even number { if (t.okbits > 1) // EVEN and ALL numbers ok return(&t); } } return(O); } // // return lookup type U32 get JypeO { return(TREE); } // II output lookup to file void out to Jile(FILE *fp) const { U32 num - tptr- > entriesO; fwrite(&num, sizeof (num), 1, fp); // Write out number of sorted list entries for(U32i=0;i<num;i++) tptr- > operator[](i).out Jo ile(fp); // Write out single range } // // setup lookup from file void getJromJilefFILE *fp) { U32num; freadf&num, sizeof (num), 1 , fp); // Write out number of valid array entries for(U32i-0;i<πum;i+ + ) { verify r; r.get from file(fp); tptr- > insert(r); } } // // Data Representation private: WCValSortedVector < verify > "tptr; // Pointer to sorted list for lookup valuns }; class field; extern lookup *allocJookup_structs(U32 type, field *f); miiimimiiiiiiiiiiimmiiiiiiiimiiiiimiiiiiiiiiiiiiiiiiiiiiiii // PA.HPP // PCOLS.CPP ^include "gen.hpp" static protocols DataPtl, PadPtl; protocol "DataPtlPtr, "PadPtlPtr; // PUT THIS IN setup_protocols() WCValSortedVector < protocols > * ProtocolList; // Pointer to sorted list for lookup values protocol *base_protocol(S8 "ProtocolNa e) { for (U32 i = 0; i < ProtocolList- > entriesO; i + + ) if (strcmp(ProtocolName, ProtocolList- > operator[](i).prot()- > filename!)) - - 0) return(ProtocolList- > operator[](i).prot()); retum(O); } void setup_protocols() { U32 number -0; find J fileblock; // // Determine number of protocol definitions that exist by counting files // if ( os findfirst("*.pdf", A NORMAL, δifileblock) - - 0) { do { + + number; } while(_dos_findnext(&fileblock) - - 0); } // // Setup a vector twice the size of the current number with number for the grow size // ProtocolList - new WCValSortedVector < protocols > (number* 2, number); // // Open each protocol definition file; create a protocol definition in memory; insert it into the vector // if (_dosJindfirst("*.pdf", _A_NORMAL, fifileblock) - - 0) { do { FILE "fp - fopen(fileblock.πame, "rb"); if ((fp !- 0) && (fileblock.size > 56)) { U32 tmp; fread(&tmp, sizeof (tmp), 1, fp); // Get length of protocol name // S8 "pname - (S8 *)malloc(tmp); f readfpname, tmp, 1 , f p); // Get file name fclose(fp); protocol "proto - new protocoKpname, fileblock.name); // protocols p(pname, proto); free(pname); ProtocolList- > insert(p); } } while(_dos Jindnext(Sfileblock) - - 0); } / ? Do we want to do something about duplicate protocol names here? for (U32 ii=0, jj - 1; ii < ProtocolList- > entriesO; ii+ +, jj+ + ) { if ((ii ! - jj) && (strcmp( ProtocolList- > operator[](ii).prot()- > pnameO, ProtocolList- > operator[](jj).prot()- > pnameO) - - 0)) ProtocolList- > removeAt(jj); } // Open each protocol definition file; create all required data structures // if (_dosJindfirst{ M *.pdf", _A_NORMAL, &fileblock) - - 0) { " do { FILE "fp - fopen(fileblock.name, "rb"); if |(fp ! - 0) && (filebiock.size > 56)) { protocols p(fp), t; // Reads name_length and name if (ProtocolList- > find(p, t) ! = FALSE) t.protO- > get Jrom Jile(fp); fciose(fp); } } while(_dosJindnext(&fileblock) = - 0); } protocols dataC'DATA", 0), padC'PAD", 0); // PUT THIS IN setup_protocols() ProtocolList- > findfdata, DataPtl); // PUT THIS IN setup protocolsO ProtocolList- > find(pad, PadPtl); // PUT THIS IN setup protocolsO DataPtlPtr = DataPtl.protO; // PUT THIS IN setup protocolsf) PadPtlPtr = PadPtl.prot ; // PUT THIS IN setup protocolsO //setup criteriaO; // filter channels are setup - tie criteria to fields } protocol "setup jιewprotocol(S8* szFileName) { U32 number -0; find J fileblock; Sδ "pname = (S8 *)malloc(50); // strcpγ(pname,szFileName); strcpy(strrchr(pname, '.'), "10 "); strcpyfpname, (strrchrfpname, '\V)+ D); strcpyfszFileName, (strrchr(szFileName, '\\')+ ])); II // See if there are any protocols // if (_dos_findfirst("*.pdf", _A_NORMAL, Sfileblock) - - 0) { do { + + number; } while(jJos findnextf&fileblock) - - 0); } // // Setup a vector if there are no .pdfs // if (number - - 0) ProtocolList - new WCValSortedVector < protocols > (10, 5); // use some other define/default protocol "proto = new protocoKpname, szFileName); protocols pipname, proto); field "tmpfs - new field[1]; field f(0,0,24); tmpfsIO) - f; proto- > fieldptr(tmpfs); proto- > numbits(tmpfs- > bitlen(l); proto- > numfieldsf 1); free(pname); ProtocolList- > insert(p); FILE "fp - fopenfszFileName, "wb"); if (fp ! - 0) { p.protO- > out to ileO; fcloseffp); p.protO- > clear out flagO; return(proto); } return(FALSE); // ROUTE.HPP enum {NUMJNTFS-256}; enum InterfaceTypes {NOINTF, FDDI, TOKEN RING, ETHERNET}; enum FrameTypes {E802_3=4, E80D5, Ev2, TR SNAP}; class RouteTableEntry { public: // // Constructors RouteTableEntryO { memset(DstNetAddr, 0, sizeoffRouteTableEntry)); } // // Used for creating actual Table Entry RouteTableEntry(Sδ "Dna, Sδ "DnM, U32 Ft, U32 Di, U32 Mhl, S8 "Mh, U32 MinSz, U32 MaxSz) : DstFrameType((U16)Ft), Dstlnterface«U16)Di), MacHdrLen((U16)Mhl), DataLen(O), DataPtr(O), MinLen((U16)MiπSz), MaxLen((U16)MaxSz) { DstNetAddr[0] - ((U32 ")Dna)[0] & ((U32 *)DnM)[0]; DstNetAddr[1] = ((U32 *)Dna)[1] & ((U32 *)DnM)[1]; DstNetAddr[2] - ((U32 ")Dna)[2] & ((U32 *)DnM)[2]; if (MacHdrLen l- O) { MacHdr = new Sβ[MacHdrLen]; memcpyfMacHdr, Mh, MacHdrLen); } } // // Destructor - RouteTableEntryO { if (MacHdr ! = 0) delete I MacHdr; } // // Overloaded ■ = - operator...for WCPtrSortedVector < RouteTableEntry > class int operator- -(const RouteTableEntry & rte) const { returπ(DstNetAddr[0] - - rte.DstNetAddr[0] && DstNetAddrlJ] - - rte.DstNetAddr[1] && DstNetAddr[2] - - rte.DstNetAddr[2]); } // // Overloaded < operator int operator < (const RouteTableEntry &rte) const { return(wordswap(DstNetAddr[0]) < wordswap(rte.DstNetAddr[0]) wordswap(DstNetAddr[1]) < wordswap(rte.DstNetAddr[1]) j | wordswap(DstNetAddrl2]) < wordswap(rte.DstNetAddr[2])); } UpdateRteDataO Function: Update Data pointer and Length if destination is 802.3 setup length field void UpdateRteDataO { DataPtr = ParsePtr; DataLen = (U16)(FrameLβn - (ParsePtr ■ FramePtr)*8); if (DstFrameType - - E802 3) // Compute and Update 802.3 Length Field ((U16 ")MacHdr)l6] = byteswap((U16)(((U32)DataLen + (U32)MacHdrLen)/8 - 14)); } // // Used for updating lookup address only UpdateAddr(S8 *Dna, S8 *DnM) { DstNetAddrlJ)] = ((U32 *)Dna)[0] & f(U32 ")DnM)[0]; DstNetAddrlJ] = ((U32 *)Dna)[1] & ((U32 ")DnM)[1]; DstNetAddr[2] - f(U32 ")Dna)[2] & ((U32 ")DnM)[2]; } '/ / RouteTableEntry::RouteFrame() Function: Setup Data pointer and Length / / Returns.TRUE • If Frame is ready to transmit FALSE • If Frame is too small/large for device // FALSE - If Destination is Internal (Dstlnterface - - NUMJNTFS) // U32 RouteFramef) { if (Dstlnterface - - NUMJNTFS) return(FALSE); U32 TotalLen - DataLen + MacHdrLen; if (TotalLen < MinLen | | TotalLen > MaxLen) return(FALSE); returnfTRUE); } // private: U32 DstNetAddr[3]; // This Value is used to look up a route U16 DstFrameType; // 802.3, Ethernet v2, "60D5", FDDI, Token Ring, . U 16 Dstlnterface; // Interface to transmit this frame on U16 MacHdrLen; // Length of MAC header and encapsulation U16 DataLen; // Length of data less MAC header and encapsulation U 16 MinLen; // Allow selectable minimum size per device U 16 MaxLen; // Allow selectable maximum size per device Sδ "MacHdr; // Pointer to MAC header and encapsulation Sδ "DataPtr; // Pointer to data to transmit for this station }; static RouteTableEntry TmpRte; class RouteTable { public: // // Constructor... Route tables are not allowed to resize RouteTable(U32 AddrSz, U32 TableSize =8192) { // Use Address Size to generate mask...allocate fixed size Route Table for(U32 i - 0; i < AddrSz; i + + )NetMask[i] - Oxff; for( ; i < 12; i+ + )NetMask[i] - 0; Table - new WCPtrSortedVector < RouteTableEntry > (TableSize, 0); } // // Destructor ~ RouteTableO {delete Table;} // // Remove Entry from Routing Table...returns NULL if entry not found RouteTableEntry *remove(RouteTableEntry *rte) {returnfTable- > remove(rte));} // // Insert Entry into Routing Table...Returns NULL if unsuccessful int insertfRouteTableEntry *rte) {returnfTable- > insertfrte));} // // Lookup Address in Route Table RouteTableEntry "RouteFramef) { RouteTableEntry "RtePtr; TmpRte.UρdateAddr(ParsePtr + ProtoParseLen/8, NetMask); if ((RtePtr - Table- > f iπdf&TmpRte)) ! - 0) RtePtr- > UpdateRteDataO; return(RtePtr); } // private: S8 NetMask[12]; // Address Mask WCPtrSortedVector < RouteTableEntry > "Table; // Pointer to Routing Table }; // extern RouteTableEntry "RtePtr; // STAT.HPP Statistics Base Class Definition Virtual member functions collect!) • accumulate statistics // clearf) - clear statistics counter enum stattypes { NOSTATS, SUM, INC, SUMINC, IDXSUM, IDXINC, IDXSUMINC, HASHSUM, HASHINC, HASHSUMINC, IDXINCSUM, HASHINCSUM, CSUMINC }; class stats { public: stats(S8 * name -0): stat jιame(O) { if (name ! - 0) { statjiame - new S8[strlen(name)+ 1]; strcpyfstatjtame, name); } } virtual - statsf) {if (statjiame ! = 0) delete statjiame;} virtual void collect(U32 value, U32 flen-O) {value-flen;}// default behavior virtual void clearf) {} // default behavior virtual void clear (U32 idx) { idx - idx; } // default behavior virtual U32 get Jype() { return(NOSTATS); } protected: Sδ "statjiame; // Pointer to user supplied statistic name private: }; // Derived Summation Statistics Class Definition // For use where the contents of a protocol field need to be accumulated // // Virtual member functions // collect(U32 value) • adds value to summation variable // clearf) - sets summation variable to 0 MMMmιmmιιmiMiιιιιιιιιιιιιιιιιιιιιιιιιιιι\ιιιιιιιιιιιιιιι class sum_stats: public stats { public: // // Constructor sum statsfSδ "name): stats(name), sum(0,0) {} // // Destructor - sum statsf) {} // // Input/Output Routines void out to JilefFILE *fp) const; void getJromJile(FILE *fp); // // Add field value to sum of previous values void collect(U32 value, U32 flen-O) { flen - flen; sum + - value; } // // Clear statistic void clearf) { sum = 0; } // // return Statistic type U32 get ypef) const { return(SUM); } // // Data Representation private: U64 sum; // Pointer to U64 variable for summing }; Derived Increment Statistics Class Definition For use where the occurances of a protocol field need to be counted Virtual member functions collect(U32 value) - increments count variable clearf) - sets count variable to 0 class inc stats: public stats { public: / / Constructor iπc_stats(S8 "name): statsfname), count(0,0) {} 1 / Destructor — incjstatsf) {} 7 Input/Output Routines void out Jo JilefFILE *fp) const; void get from Jile(FILE *fp); 7 'I Increment number of times this field parsed void collect(U32 value, U32 flen-O) { flen -flen; value -value ; + + count; } 7 / Clear statistic void clearf) { count = 0; } return statistic type U32 getjypef) { return(INC); } // Data Representation private: U64 count; // Pointer to U64 variable for counting }; Derived Summation Statistics Class Definition // For use where the contents of a protocol field need to be accumulated // as well as a count mainatined Virtual member functions collect(U32 value) - adds field content value to summation variable and increments count variable clearf) - sets summation and count variables to 0 class suminc stats: public stats { public: // // Constructor suminc_stats(S8 "name): stats(name), sum(0,0), couπt(0,0) {} // // Destructor ~ suminc statsO {} // // Input/Output Routines void out to Jile(FILE *fp) const- void get JromJile(FILE *fp); // II Add field value to sum of previous values and increment counter void collect(U32 value, U32 flen-O) { flen -flen; sum + - value; + + count; } // // Clear statistic void clearf) { sum = count = 0; } // // return statistic type U32 getjypef) { return(SUMINC); } // // Data Representation private: U64 sum; // Pointer to U64 variable for summing U64 count; // Pointer to U64 variable for counting }; Derived Indexed Summation Statistics Class Definition For use where the contents of a protocol field need to be accumulated in an array indexed by the value itself Virtual member functions collect(U32 value) - adds field content value to counter and increments array indexed by value // clearf) - sets each array element to 0 // clear(U32 idx) - sets arrayfidx] to 0 class idxsum stats: public stats { public: Constructor idxsum statsfSδ "name, U32 maxsz): statsfname), sizefmaxsz) { array - new U64[maxsz+ 1]; } 7 Destructor ~ idxsum statsf) { delete []array; } 7 Input/Output Routines void out to JilefFILE *fp) const; void get Jrom JilefFILE "fp); 7 Index using field value and add field value to sum of previous values void collect(U32 val, U32 flen-O) { flen=0; array [minfval, size)] + - val; } / Clear statistic void clearf) { memsetfarray, 0, size*sizeof(U64)); } void clear(U32 idx) { if (idx < - size) arraytidx] - 0; } / return statistic type U32 getJypeO { retum(IDXSUM); } // Data Representation private: U32 size; // Maximum possible statistic value + 1 U64 "array; // Space for (size+ 1) elements }: // Derived Index Increment Statistics Class Definition // For use where occurances of a protocol field need to be counted // Virtual member functions // collect(U32 value) - adds 1 to counter // clearf) - sets counter value to 0 //////////////////////////////////////////////////////////////////////////////// class idxinc stats: public stats { public: // // Constructor idxinc_stats(S8 "name, U32 maxsz): statsfname), sizefmaxsz) { array - new U64[maxsz+ 1]; } // // Destructor ~ idxinc_stats() { delete [Jarray; } // // Input/Output Routines void out to Jile(FILE *fp) const- void get from JilefFILE *fp); // // Index on field value and increment counter void collect(U32 value, U32 flen-0){ flen -flen; + +array[min(value, size)]; } // // Clear statistic void clearf) { memsetfarray, 0, size*sizeof(U64)); } void clear(U32 idx) { if (idx < - size) arraylidx] = 0; } // // return statistic type U32 get ypeO { return(IDXINC); } // // Data representation private: U32 size; // Maximum possible statistic value + 1 U64 "array; // Space for (size+ 1) elements }; imiiiiimmimmiimiiiiimimiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 11 Derived Index Sum and Increment Statistics Class Definition For use where occurances of a protocol field need to be counted in an array indexed by the value itself, and the contents of a protocol field need to be accumulated Virtual member functions collect(U32 value) - adds field content value to counter and increments array indexed by value and adds 1 to counter clearf) - sets counter value and entire array to 0 clear(U32 idx) - sets arraylidx] to 0 and sets counter value to 0 class idxsumincjUats: public stats { public: // // Constuctor idxsuminc statsfSδ "name, U32 maxsz):stats(name), sizefmaxsz) { asum = new U64[maxsz+ 1]; ainc - new U64[maxsz+ 1]; } / / Destructor ~ idxsuminc statsf) { delete []asum; delete [jainc; } / 7 Input/Output Routines void outjo JilefFILE *fp) const- void get from ilefFILE *fp); / 7 Index on field value, increment counter, add value to sum of previous values void collect(U32 val, U32 flen-O) { flen -flen; val = minfval, size); asumh/al] + - val; + +ainc[val]; } / 7 Clear statistic void clearf) { memsetfasum, 0, size*sizeof(U64)); memsBt(ainc, 0, size"sizeof(U64)); } void clear(U32 idx) { if (idx < - size) asum[idx] - ainc[idx] - 0; } 7 return statistic type U32 get JypeO { retum(IDXSUMINC); } // // Data Representation private: U32 size; // Maximum possible statistic value + 1 U64 "asum; // Space for (size + 1 ) elements U64 "ainc; // Space for (size-*- 1) elements }; Derived Sum Hash Table Entry Class Definition For use where the contents of a protocol field with many possible values needs to acumulate the total at each received value Virtual member functions collect(U32 value) • adds 1 to counter clearf) - sets counter value to 0 inline void *u64_alloc(sizeJ sz) { sz = sz; return((void *)malloc(WCPtrHashDictltemSize(U32, U64))); } // inline void u64_dealloc(void "ptr, sizej sz) { sz = sz; delete ptr; } // class hashsum stats: public stats { public: static unsigned h fnfconst U32& u) { return(u); } // // Constructor hashsum_stats(Sδ "name, U32 hsz-WC_DEFAULT_HASH_SIZE): stats(name) { ht = new WCPtrHashDict < U32, U64 > (h Jn, hsz, u64_alloc r u64_dealloc); } // // Destructor ~ hashsum stats!) { delete ht; } // // Input/Output Routines void out to file(FILE *fp) const; void get Jrom JilefFILE *fp); (I // use value to hash into table and add value to sum of previous values void collect(U32 value, U32 flen-O) { flen - flen; U64 "u; U32 "uptr, * &val = uptr; if ((u - ht- > findKeyAndValuet&vaiue, val)) - = 0) ht- > insertf&value, u = new U64); *u + - value; } // static void zero(U32 "key, U64 "value, void "data) { key = key; data - data; value- > clearf); } // // Clear statistic void clearf) { ht- > forAIKzero, 0); } // // return statistic type U32 getjypef) { return(HASHSUM); } // // Data Representation private: WCPtrHashDict < U32, U64 > "ht; // Pointer to hash table for U64 values }; / Derived Increment Hash Table Entry Class Definition For use where occurances of a protocol field need to be counted and / the contents are sparsely distributed 7 7 Virtual member functions collect(U32 value) - adds 1 to counter clearf) - sets counter value to 0 class hashinc stats: public stats { public: static unsigned h fnfconst U32& u) { returnfu); } // // Constructor hashinc_stats(S8 "name, U32 hsz-WC_DEFAULT_HASH_SIZE): statsfname) { ht - new WCPtrHashDict < U32, U64> fhjn, hsz, u64_alloc, u64_dealloc); } // // Destructor ~ hashinc_stats() { delete ht; } // // Input/Output Routines void out to Jile(FILE *fp) const- void get from JiMFILE *fp); 11 II use value to hash into table and increment counter void collect(U32 value, U32 flen-O) { U64 *u; U32 "uptr, * δtval = uptr; flen = flen; if ((u - ht- > findKeyAndValuef&value, val)) - - 0) ht- > insertf&value, u - new U64); + +(*u); } // static void zero(U32 "key, U64 "value, void "data) { key - key; data = data; value- > clearf); } // // Clear statistic void clear!) { ht- > forAIKzero, 0); } // // return statistic type U32 get JypeO { returnfHASHINC); } // // Data Representation private: WCPtrHashDict < U32, U64 > "ht; // Pointer to hash table for U64 values }: // Derived Sum Hash Table Entry Class Definition // For use where the contents of a protocol field with many possible // values needs to accumulate the total at each received value // // Virtual member functions // collect(U32 value) - adds 1 to counter // clearf) - sets counter value to 0 //////////////////////////////////////r///////////////////////////////////////// class suminc { public: // // Constructor suminc!): count(O), summ(O) {} // // Destructor — sumincO {} // // Input/Output Routines void out Jo JilefFILE *fp) const; void get JromJilefFILE *fp); // // increment counter incf) { + + count; } // // add value to sum of previous values sum(U32 value) { sum + - value; } // // increment counter and add value to sum of previous values incsum(U32 value) { + + count; summ + - value; } // // Clear statistic void clearf) { count = summ - 0; } // // Data Representation private: U64 count, summ; // Pointer to counter and summation statistic variables }; iiiiiiiiMimiiimiiiiiiiiiiiiiiimiiimiimiiimmiiiiiiiiiiiii II //////////////////////////////////////////////////////////////////////////////// class hashsuminc_stats: public stats { public: static unsigned h Jnfconst U32& u) { return(u); } static void *si_alloc(size J sz) { sz = sz; return((void *)malloc(WCPtrHashDictltemSize(U32, suminc))); } static void si deallocfvoid "ptr, size J sz) { sz = sz; delete ptr; } // // Constructor hashsuminc_stats(Sδ "name, U32 sz = WC_DEFAULT_HASH_SIZE): statsfname) { ht - new WCPtrHashDict < U32, suminc > (h fn, sz, si alloc, si dealloc); } // / Destructor — hashsuminc statsf) { delete ht; } / 7 Input/Output Routines void out to JilefFILE *fp) const; void get from JilefFILE *fp); 7 use value to hash into table, increment counter and sum value void coilect(U32 value, U32 flen-O) { suminc *u; U32 "uptr, * &val - uptr; flen - flen; if ((u - ht- > findKeγAndValuef&value, val)) - - 0) ht- > insertf&value, u = new suminc); u- > incsum(value); } // static void zero(U32 "key, suminc "value, void "data) { key =■ key; data - data; value- > clearf); } // // Clear statistic void clearf) { ht- > forAilfzero, 0); } // // return statistic type U32 get ypef) { return(HASHSUMINC); } // // Data Representation private: WCPtrHashDict < U32, suminc > "ht; // Pointer to hash table < suminc > }; 7 Derived Increment Index Sum and Sum length field Statistics Class Definition 7 For use where the occurances of a protocol field need to be counted in an array indexed by the value itself, and the supplied protocol length 7 needs to be accumulated 7 7 Virtual member functions collect(U32 value) - adds field content value to counter and increments array indexed by value and adds 1 to counter clearf) - sets counter value and entire array to 0 clear(U32 idx) - sets array[idx] to 0 and sets counter value to 0 class idxincsum_stats: public stats { public: // // Constuctor idxincsum_stats(Sδ "name, U32 maxsz): statsfname), sizefmaxsz) { asum - new U64[maxsz+ 1]; ainc = new U64[maxsz+ 1]; } // Destructor — idxincsum statsf) { delete []asum; delete [Jainc; } // // Input/Output Routines void out to JilefFILE *fp) const- void get Jrom filefFILE *fp); // // index on value, increment counter, void collect(U32 value, U32 flen-O) { value - minfvalue, size); + + ainclvalue]; asum[value] + - flen; } // // clear statistics void clearf) { memsetfasum, 0, size*sizeof(U64));memset(aiπc, 0, sizB*sizeof(U64)); } // void clear(U32 idx) { if (idx < = size) asum[idx] - ainc[idx] = 0; } // // return statistic type U32 getjypef) { retum(IDXINCSUM); } // // Data Representation private: U32 size; // Maximum possible statistic value + 1 U64 "asum; // Space for (size + 1) elements U64 "ainc; // Space for (size-*- 1) elements }; Derived Increment Hash Table Entry and Sum Length Field Class Definition For use where the number of occurances of a protocol field must be counted and associated packet length summed Virtual member functions // coliβct(U32 value) - adds 1 to counter // clear!) - sets counter value to 0 class hashincsum stats: public stats { public: // static unsigned h Jnfconst U32& u) { return(u); } static void "is allocfsize J sz) { sz = sz; return((void *)malloc(WCPtrHashDictltemSize(U32, suminc))); } static void isjieallocfvoid "ptr, size t sz) { sz = sz; delete ptr; } / / Constructor hashincsum_stats(Sδ "name, U32 sz-WC_DEFAULT_HASH_SIZE): stats(name) { ht - new WCPtrHashDict < U32, suminc > (h fn, sz, is alloc, is dealloc); } / / Destructor ~ hashincsum_stats() { delete ht; } / // Input/Output Routines void out to Jile(FILE *fp) const; void get rom file(FILE *fp); 7 // use value to hash into table, increment counter, sum value void coliect(U32 value, U32 flen-O) // Hash, sum and increment entry values { suminc *u; U32 "uptr, * &val = uptr; if (fu - ht- > findKeyAndValuef&value, val)) - - 0) ht- > insertf&value, u - new suminc); u- > incf); u- > sum(flen); } // static void zero(U32 "key, suminc "value, void "data) { key - key; data - data; value- > clear(); } // // Clear statistic void clear!) { ht- > forAIKzero, 0); } // // return statistic type U32 get JypeO { return(HASHINCSUM); } // // Data Representation private: WCPtrHashDict < U32, suminc > "ht; // Pointer to hash table < suminc > }; class field; extern stats *alloc_stat_structs(U32 type, field *f); // XMIT.HPP //////////////////////////////////////////////////////////////////////////////// Base Class definition for Varying Field Values Rules::: Right shift value must always be > - left shift value If Right and Left shift values are equal ... field contains LSB Field bitlength : = 32 - right shift value Left shift value to original position :- right - left shift value class vary { public: // Constructor vary(U32 shl, U32 shr, U32 op=0) { mask - ((Oxffffffff < < shr) > > shl); notmask - — mask; operand = (fop < < shr) > > shl); if (shl - - shr) invalue = 0; else minvalue - (Oxffffffff > > (shl + (32-shr))); maxvalue - (Oxffffffff > > shl) & mask; } virtual ~ vary() {} // Member Functions virtual U32 vary_value(U32 value) {// (8/10 + 7/5) ... (insts/clocks) return((value & notmask) | ((value + operand) & mask)); } protected: U32 mask; U32 notmask; U32 operand; U32 minvalue; U32 maxvalue; private: }; // Derived class for incrementing field values class varyjncwrap: public vary { public: // Constructors vary Jncwrap(U32 shl, U32 shr): vary(shl, shr, 1 ) {} private: }; // Derived class for incrementing field values within a (minrmax) range class varyjncwrapminmax: public vary { public: // Constructors varyJncwrapmiπmaxfU32 shl, U32 shr): varyfshl, shr, 1) {} // Member Functions U32 vary_value(U32 value) { // (8/10 + 10/11 ) ... (instrs/clocks) ... Total ((181 19)/(191 20)) U32 newv - (value & mask); if (newv - - maxvalue) newv - minvalue; else newv + = operand; returnϋvalue & notmask) | newv); } private: }; //////////////////////////////////////////////////////////////////////////////// // Derived class for decrementing field values class varyjiecwrap: public vary { public: // Constructors vary_decwrap(U32 shl, U32 shr): varyfshl, shr, -1) {} private: }; mmiiimiiiiMiiiiimiiiimiiiiiimiimiiiiiiiiiiiiiiiiiiiiiiii // Derived class for decrementing field values within a (min:max) range class vary_decwrapminmax: public vary { public: // Constructors vary lecwrapminmax(U32 shl, U32 shr): varyfshl, shr, -1 ) {} // Member Functions U32 vary_value(U32 value) { // (8/10 + 101 1 1 ) ... (instrs/clocks) ... Total ((181 19)/(191 20)) U32 newv - (value & mask); if (newv = - minvalue) newv = maxvalue; else newv + - operand; return((value & notmask) | newv); } private: }; // Derived class for adding a value to a field class vary ϊddwrap: public vary { public: // Constructors vary_addwrap(U32 shl, U32 shr, U32 op = 1 ): varyfshl, shr, op) {} private: }; // Derived class for adding a value to a field within a (min:max) range iiimiiimiiiiimimiiiimiiiiiimiiiiiiiimiiiiiiiiiiiiiiimw class vary addwrapminmax: public vary { public: II Constructors vary_addwrapmiπmax(U32 shl, U32 shr, U32 op- 1): varyfshl, shr, op) {} / Member Functions U32 vary_value(U32 value) { // (10/12 + 1 1 1 12) ... (instrs/clocks) ... Total ((21 1 221/(21 1 22)) U32 newv - maxvalue • (value & mask); if (newv > - operand) newv + = operand; returnffvalue & notmask) | newv); } private: }; // Derived class for subtracting a value from a field class vary subwrap: public vary { public: // Constructors vary_subwrap(U32 shl, U32 shr, U32 op- 1): varyfshl, shr, -op) {} private: }; // Derived class for subtracting a value from a field within a (min:max) range class vary subwrapminmax: public vary { public: // Constructors vary_subwrapminmax(U32 shl, U32 shr, U32 op- 1): varyfshl, shr, -op) {} // Member Functions U32 vary_valueminmax(U32 value) { // (10/12 + 11 1 12) ... (instrs/clocks) ... Total ((21 1 22)/(21 1 22)) U32 newv - (value & mask) • minvalue; if (newv > - operand) newv + - operand; returnffvalue & notmask) | newv); } private: }; // Derived class for rotating left a field value class vary rotl: public vary { public: II II Constructor vary_rotl(U32 shr, U32 shl, U32 op): varyfshl, shr) { operand - op; } // // rotate the field value left 1 bit U32 vary_value(U32 value) { returπf rotlfvalue, 1)); } private: }; // Derived class for rotating right a field value class vary rotr: public vary { public: // // Constructor vary rotr(U32 shr, U32 shl, U32 op): varyfshl, shr) { operand - op; } // // rotate the field value right 1 bit U32 vary_value(U32 value) { return) jotrfvalue, 1)); } private: }; // Derived class for performing incremental update of IP checksum field //////////////////////////////////////////////////////////////////////////////// // IP checksum incremental update routine (bitswapped) extern U32 lpCsumUpd{U32 value, U32 change); ^pragma aux IpCsumUpd - \ value [eax] class vary ipcsum: public vary { public: // // Constructor vary ipcsum(U32 shr-0, U32 shl-0, U32 op-0): varyfshl, shr) { operand -op; } // // Member Functions U32 vary_value(U32 value) { returπflpCsumUpdfvalue, operand)); } private: }; i iimiim iiiiiiii immiiii miiiiiiiiiiMiiimiiiiiiiiimii II Derived class for performing incremental update of IPX checksum field class vary ipxcsum: public vary { public: // // Constructor vary ipxcsum(U32 shr-0, U32 shl-0, U32 op = 1): varyfshl, shr) { operand -op; } // // Member Functions U32 vary ra!ue(U32 value); private: }; // Derived class for performing bitswapping class varγ bitswap: public vary { public: // // Constructor fop is the number of bytes to bitswap !!!) vary_bitswap(U32 shr-0, U32 shl-0, U32 oρ- 1): varyfshl, shr) { operand -op; } // // Member Functions U32 vary_value(U32 i) 5 { for fi-0; i < operand; i+ +) ParsePtrfj] - bs[ParsePtr[i[]; returnfO); } private: }; class vary jTiinmaxincwrap: public vary { i o public: // Constructors vary_minmaxincwrap(U32 shr, U32 shl, U32 minv-O, U32 maxv--1 ) : varyfshl, shr, 1) { 15 minvalue - (minv > > (shl + (31 -shr))) + 1; maxvalue - maxv > > shl; } // Member Functions private: 20 }; #ifdef notdef class vary jninmaxdecwrap: public vary { public: 5 // Constructors varyjninmaxdecwrap(U32 minv-O, U32 maxv=-1): vary(-1) { minval- minv- 1; maxval -maxv; } // Member Functions U32 vary_value(U32 value, U32 shl, U32 shr); 0 private: U32 minval; U32 maxval; }; #endif 5 -

Claims: lai s 1. A system for manipulating data transmitted over one or more data communications networks, said system comprising: a logic control module capable of accessing a plurality of programmably configurable protocol descriptions stored in a memory, said programmably configurable protocol descriptions each including a protocol control record and at least one field sub-record for defining a selected portion of a network protocol to be manipulated and a plurality of rules for manipulating said portion of said protocol; said logic control module including frame and protocol header length determining logic, statistics gathering logic, verification and error checking Logic, filtering logic, next protocol determining logic, routing logic and output formatting logic for defining and controlling, based upon said programmably configurable protocol descriptions, a series of data manipulation functions to be implemented by said system. 2. A protocol analyzer comprising: a logic control module capable of accessing a plurality of programmably configurable protocol descriptions stored in a memory, said progranmably configurable protocol descriptions each including a protocol control record and at least one field sub- record for defining a selected portion of a network protocol to be analyzed and a plurality of rules for conducting an analysis of said portion of said protocol; said logic control module including frame and protocol header length determining logic, statistics gathering logic, verification and error checking logic, filtering logic, and next protocol determining logic for defining and controlling, based upon said prograτιmably configurable protocol descriptions, a series of parsing, filtering, statistics gathering and display functions implemented by said protocol analyzer. 3. A machine implemented process for parsing data transmitted over a data communications network, said process comprising the steps of : storing at least one programmably configurable protocol description in a memory, said at least one programmably configurable protocol description comprising a protocol control record and at least one field sub- record for defining a plurality of characteristics of said data transmitted over said data communications network; retrieving said at least one protocol description from said memory; and providing said at least one protocol description to a logic control module, said logic control module, upon receiving said at least one protocol description, being configured to parse data received from said data communications network based upon said characteristics defined by said protocol description. 4. The process of claim 3, wherein a plurality of programmably configurable protocol descriptions are stored in said memory, and wherein said programmably configurable protocol descriptions are selectively retrieved from said memory in response to selected data sequences received from said data communications network. 5. A machine implemented process for filtering data transmitted over a data communications network, said process comprising the steps of: storing at least one programmably configurable protocol description in a memory, said at least one programmably configurable protocol description comprising a protocol control record and at least one field sub- record for defining a plurality of characteristics of said data transmitted over said data communications network; retrieving said at least one protocol description from said memory; and providing said at least one protocol description to a logic control module, said logic control module, upon receiving said at least one protocol description, being configured to filter data received from said data communications network based upon said characteristics defined by said protocol description. 6. The process of claim 5, wherein a plurality of programmably configurable protocol descriptions are stored in said memory, and wherein said programmably configurable protocol descriptions are selectively retrieved from said memory in response to selected data sequences received from said data communications network. 7. A machine implemented process for routing data transmitted over a data communications network, said process comprising the steps of: storing at least one programmably configurable protocol description in a memory, said at least one programmably configurable protocol description comprising a protocol control record and at least one fielc sub- record for defining a plurality of characteristics oE said data transmitted over said data communications network; retrieving said at least one protocol description from said memory; and providing said at least one protocol description to a logic control module, said logic control module, upon receiving said at least one protocol description, being configured to route data within said data communications network based upon said characteristics defined by said protocol description. 8. The process of claim 7, wherein a plurality of programmably configurable protocol descriptions are stored in said memory, and wherein said programmably configurable protocol descriptions are selectively retrieved from said memory in response to selected data sequences received from said data communications network. 9. A method for parsing data transmitted over a data communications network, said method comprising the steps of : storing in a first memory a plurality of programmably configurable protocol descriptions, said programmably con¬ figurable protocol descriptions defining a plurality of characteristics of said data transmitted over said data communications network; storing in a second memory a program for controlling a data parsing function to be executed by a processing unit, said program including instructions for causing said processing unit to selectively retrieve at least one of said programmably configurable protocol descriptions from said first memory and to vary the execution of said data parsing function based upon said at least one retrieved protocol description; delivering to said processing unit said program for controlling said data parsing function; enabling said processing unit to execute said data parsing function; and delivering to said processing unit said data transmitted over said data communications network. 10. A method for filtering data transmitted over a data communications network, said method comprising the steps of : storing in a first memory a plurality of programmably configurable protocol descriptions, said programmably con¬ figurable protocol descriptions defining a one or more filter criteria; storing in a second memory a program for controlling a data filtering function to be executed by a processing unit, said program including instructions for causing said processing unit to selectively retrieve at least one of said programmably configurable protocol descriptions from said first memory and to vary the execution of sail data filtering function based upon said at least one retrieved protocol description; delivering to said processing unit said program for controlling said data filtering function; enabling said processing unit to execute said data filtering function; and delivering to said processing unit said data transmitted over said data communications network. 11. A method for routing data transmitted over a data communications network, said method comprising the steps of : storing in a first memory a plurality of programmably configurable protocol descriptions, said programmably con¬ figurable protocol descriptions defining one or more rules for routing data within said data communications network; storing in a second memory a program for controlling a data routing function to be executed by a processing unit, said program including instructions for causing said processing unit to selectively retrieve at least one of said programmably configurable protocol descriptions from said first memory and to vary the execution of said data routing function based upon said at least one retrieved protocol description; delivering to said processing unit said program for controlling said data routing function; enabling said processing unit to execute said data routing function; and delivering to said processing unit said data transmitted over said data communications network. 12. A network interface system comprising: at least one network interface unit for communicating with a data communications network; at least one memory coupled to said network interface unit, said memory being configured to store a plurality of network data files and a plurality of programmably configurable protocol descriptions; and a logic control module coupled to said at least one network interface unit and to said at least one memory, said logic control module having the capability to selectively retrieve one or more of said programmably configurable protocol descriptions from said memory and to implement a selected data manipulation function in a manner defined by said one or more retrieved protocol descriptions. 13. The network interface system of claim 12, wherein said logic control module comprises a microprocessor and a computer program which may be executed by said microprocessor. 14. The network interface system of claim 13 , wherein said computer program comprises a C++ computer program having abstract data types defined for statistics gathering, value verification, next protocol determina¬ tion, filtering, value modification, display and route determination capabilities. 15. The network interface system of claim 13, wherein each of said programmably configurable protocol descriptions comprises a protocol control record and a plurality of field data records. 16. The network interface system of claim 15, wherein each said protocol control record defines an overall structure of a network protocol. 17. The network interface system of claim 16, wherein each protocol control record comprises a plurality of field sub-records, a plurality of statistics records, a plurality of lookup records, a plurality of expression records, a plurality of filter criteria records, and a plurality of value verification records. 18. A protocol analyzer comprising: at least one network interface unit for communicating with a data communications network; at least one memory coupled to said network interface unit, said memory being configured to store a plurality of network data files and a plurality of programmably configurable protocol descriptions, each programmably configurable protocol description comprising a protocol control record and a plurality of field sub-records, wherein said protocol control record defines an overall data structure of a selected data communication protocol; a logic control module coupled to said at least one network interface unit and to said at least one memory, said logic control module having the capability to selectively retrieve one or more of said programmably configurable protocol descriptions from said memory and to execute one or more network analysis functions defined by said one or more retrieved protocol descriptions; nd at least one output device coupled to said logic control module for displaying a result of a network analysis function performed by said logic control module.

Inventors: BAKER PETER D, NEAL KAREN, BAKER, PETER, D., NEAL, KAREN
Applicants: N B NETWORKS
Application year: 1996
Main classification: H04L12
IPC codes: H04L12, H04L29