CA2382836A1 - Low latency, high bandwidth multi-computer system interconnect - Google Patents

Low latency, high bandwidth multi-computer system interconnect Download PDF

Info

Publication number
CA2382836A1
CA2382836A1 CA002382836A CA2382836A CA2382836A1 CA 2382836 A1 CA2382836 A1 CA 2382836A1 CA 002382836 A CA002382836 A CA 002382836A CA 2382836 A CA2382836 A CA 2382836A CA 2382836 A1 CA2382836 A1 CA 2382836A1
Authority
CA
Canada
Prior art keywords
status
padapter
ndis
data
shim
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Abandoned
Application number
CA002382836A
Other languages
French (fr)
Inventor
Vince Bridgers
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Times N Systems Inc
Original Assignee
Individual
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Individual filed Critical Individual
Publication of CA2382836A1 publication Critical patent/CA2382836A1/en
Abandoned legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/40Network security protocols

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Multi Processors (AREA)
  • Bus Control (AREA)

Abstract

Methods, systems and devices are described for a low latency, high bandwidth multi-computer system interconnect. A method includes passing a set of interconnect fabric data through a shim layer (420, 450) that is interposed between an interconnect fabric interface layer (410, 440) and a protocol layer (430, 460) including: receiving said set of interconnect fabric data with said shim layer (420, 450), classifying said set of interconnect fabric data with said shim layer (420, 450), and handling said set of interconnect fabric data with said shim layer (420, 450) as a function of a transport application program interface (435, 465) with which said set of interconnect fabric data is associated. The methods, systems and devices provide advantages because the speed and scalability of parallel processor systems is enhanced.

Description

LOW LATENCY, HIGH BANDWIDTH MULTI-COMPUTER SYSTEM
INTERCONNECT
REFERENCE TO APPENDIX
An appendix is included in this application by way of attachment, the totality of which is hereby incorporated by reference as an integral part of this application. The appendix includes printed source code that is discussed below in more detail as a nonlimiting example of the invention.
BACKGROUND OF THE INVENTION
Field of the Invention The invention relates generally to the field of computer systems which have multiple processing nodes and in which each processing node is provided with private, local memory and also in which each processing node has access to a range of memory which is shared with other processing nodes. More particularly, the invention relates to computer science techniques that utilize a low latency, high bandwidth multi-computer system interconnect.
2. Discussion of the Related Art The clustering of workstations is a well-known art. In the most common cases, the clustering involves workstations that operate almost totally independently, utilizing the network only to share such services as a printer, license-limited applications, or shared files.
In more-closely-coupled environments, some software packages (such as NQS) allow a cluster of workstations to share work. In such cases the work arrives, typically as batch jobs, at an entry point to the cluster where it is queued and dispatched to the workstations on the basis of load.
In both of these cases, and all other known cases of clustering, the operating system and cluster subsystem are built around the concept of message-passing. The term message-passing means that a given workstation operates on some portion of a job until communications (to send or receive data, typically) with another workstation is necessary. Then, the first workstation SUBSTITUTE SHEET (RULE 26) prepares and communicates with the other workstation.
Another well-known art is that of clustering processors within a machine, usually called a Massively Parallel Processor or MPP, in which the techniques are essentially identical to those of clustered workstations. Usually, the bandwidth and latency of the interconnect network of an MPP are more highly optimized, but the system operation is the same.
In the general case, the passing of a message is an extremely expensive operation; expensive in the sense that many CPU cycles in the sender and receiver are consumed by the process of sending, receiving, bracketing, verifying, and routing the message, CPU cycles that are therefore not available for other operations. A highly streamlined message-passing subsystem can typically require 10,000 to 20,000 CPU cycles or more.
There are specific cases wherein the passing of a message requires significantly less overhead. However, none of these specific cases is adaptable to a general-purpose computer system.
Message-passing parallel processor systems have been offered commercially for years but have failed to capture significant market share because of poor performance and difficulty of programming for typical parallel applications. Message-passing parallel processor systems do have some advantages. In particular, because they share no resources, message-passing parallel processor systems are easier to provide with high-availability features.
What is needed is a better approach to parallel processor systems.
There are alternatives to the passing of messages for closely-coupled cluster work. One such alternative is the use of shared memory for inter-processor communication.
Shared-memory systems, have been much more successful at capturing market share than message-passing systems because of the dramatically superior performance of shared-memory systems, up to about four-processor systems. In Search of Clusters, Gregory F. Pfister 2nd ed. (January 1998) Prentice Hall Computer Books, ISBN: 0138997098 describes a computing system with multiple processing nodes in which each processing node is provided with private, local memory and also has access to a range of memory which is shared with other processing nodes. The disclosure of this publication in its entirety is SUBSTITUTE SHEET (RULE 26) hereby expressly incorporated herein by reference for the purpose of indicating the background of the invention and illustrating the state of the art.
However, providing high availability for traditional shared-memory systems has proved to be an elusive goal. The nature of these systems, which share all code and all data, including that data which controls the shared operating systems, is incompatible with the separation normally required for high availability. What is needed is an approach to shared-memory systems that improves availability. .
Although the use of shared memory for inter-processor communication is a well-known art, prior to the teachings of U.S. Ser. No. 09/273,430, filed March 19, 1999, entitled Shared Memory Apparatus and Method for Multiprocessing Systems, the processors shared a single copy of the operating system. The problem with such systems is that they cannot be efficiently scaled beyond four to eight way systems except in unusual circumstances. All known cases of said unusual circumstances are such that the systems are not good price-performance systems for general-purpose computing.
The entire contents of U.S. Patent Applications 09/273,430, filed March 19, 1999 and PCT/LTS00/01262, filed January 18, 2000 are hereby expressly incorporated by reference herein for all purposes. U.S. Ser. No. 09/273,430, improved upon the concept of shared memory by teaching the concept which will herein be referred to as a tight cluster. The concept of a tight cluster is that of individual computers, each with its own CPU(s), memory, I/O, and operating system, but for which collection of computers there is a portion of memory which is shared by all the computers and via which they can exchange information. U.S. Ser. No. 09/273,430 describes a system in which each processing node is provided with its own private copy of an operating system and in which the connection to shared memory is via a standard bus. The advantage of a tight cluster in comparison to an SMP is "scalability" which means that a much larger number of computers can be attached together via a tight cluster than an SMP with little loss of processing efficiency.
What is needed are improvements to the concept of the tight cluster.
What is also needed is an expansion of the concept of the tight cluster.
SUBSTITUTE SHEET (RULE 26) SUMMARY OF THE INVENTION
A goal of the invention is to simultaneously satisfy the above-discussed requirements of improving and expanding the tight cluster concept which, in the case of the prior art, are not satisfied.
One embodiment of the invention is based on a method comprising:
passing a set of interconnect fabric data through a shim layer that is interposed between an interconnect fabric interface layer and a protocol layer including:
receiving said set of interconnect fabric data with said shim layer, classifying said set of interconnect fabric data with said shim layer, and handling said set of interconnect fabric data with said shim layer as a function of a transport application program interface with which said set of interconnect fabric data is associated. Another embodiment of the invention is based on an apparatus, comprising: a shared memory unit; a first system coupled to said shared memory unit; and a second system coupled to said shared memory unit, wherein a data set transfered between said shared memory unit and at least one member selected from the group consisiting of said first system and said second system is received by a shim that is interposed between either i) a network device/driver and a protocol layer or ii) an interconnect fabric interface and said protocol layer, classified by said shim and handled by said shim as a function of a transport application program interface with which said data set is associated.
Another embodiment of the invention is based on an apparatus comprising: a switch; a first system coupled to said switch; and a second system node coupled to said switch, wherein a data set transfered from said first system to said second system through said switch is received by a shim that is interposed between either i) a network device/driver and a protocol layer or ii) an interconnect fabric interface and said protocol layer, classified by said shim and handled by said shim as a function of a transport application program interface with which said data set is associated.
These, and other, aspects of the present invention will be better appreciated and understood when considered in conjunction with the following description and the accompanying drawings. It should be understood, however, that the following description, while indicating preferred embodiments of the present invention and numerous specific details thereof, is given by way of SUBSTITUTE SHEET (RULE 26) illustration and not of limitation. Many changes and modifications may be made within the scope of the present invention without departing from the spirit thereof, and the invention includes all such modifications.
BRIEF DESCRIPTION OF THE DRAWINGS
A clear conception of the advantages and features constituting the present invention, and of the components and operation of model systems provided with the present invention, will become more readily apparent by referring to the exemplary, and therefore nonlimiting, embodiments illustrated in the drawings accompanying and forming a part of this specification, wherein like reference numerals designate the same elements. It should be noted that the features illustrated in the drawings are not necessarily drawn to scale.
FIG. 1 illustrates a block schematic diagram of a network, representing an embodiment of the invention.
FIG. 2 illustrates a schematic diagram of a system architecture including a network switch, representing an embodiment of the invention.
FIG. 3 illustrates a block schematic diagram of a system architecture including a dedicated shared memory node device, representing an embodiment of the invention.
FIG. 4 illustrates a block schematic diagram of an interconnect fabric, representing an embodiment of the invention.
DESCRIPTION OF PREFERRED EMBODIMENTS
The present invention and the various features and advantageous details ' thereof are explained more fully with reference to the nonlimiting embodiments that are illustrated in the accompanying drawings and detailed in the following description. Descriptions of well known components and processing techniques are omitted so as not to unnecessarily obscure the present invention in detail.
The teachings of U.S. Ser. No. 09/273,430 include a system which is a single entity; one large supercomputer. The invention is also applicable to a cluster of workstations, or even a network.
The invention is applicable to systems of the type of Pfister or the type of U.S. Ser. No. 09/273,430 in which each processing node has its own copy of SUBSTITUTE SHEET (RULE 26) an operating system. The invention is also applicable to other types of multiple processing node systems; even an interconnect fabric such as, for example, Infiniband.
The invention can be combined with a tight cluster as described in U.S.
Ser. No. 09/273,430. A tight cluster is defined as a cluster of workstations or an arrangement within a single, multiple-processor machine in which the processors are connected by a high-speed, low-latency interconnection, and in which some but not all memory is shared among the processors. Within the scope of a given processor, accesses to a first set of ranges of memory addresses will be to local, private memory but accesses to a second set of memory address ranges will be to shared memory. The significant advantage to a tight cluster in comparison to a message-passing cluster is that, assuming the environment has been appropriately established, the exchange of information involves a single STORE instruction by the sending processor and a subsequent single LOAD
instruction by the receiving processor.
The establishment of the environment, taught by U.S. Ser. No.
09/273,430 and more fully by companion disclosures (U.S. Provisional Application Ser. No. 60/220,794, filed July 26, 2000; U.S. Provisional Application Ser. No. 60/220,748, filed July 26, 2000; WSGR 15245-71 l;
WSGR 15245-712; WSGR 15245-713; WSGR 15245-715; WSGR 15245-716;
WSGR 15245-717; WSGR 15245-718; WSGR 15245-719; WSGR 15245-720, the entire contents of all which are hereby expressly incorporated herein by reference for all purposes) can be performed in such a way as to require relatively little system overhead, and to be done once for many, many information exchanges. Therefore, a comparison of 10,000 instructions for message-passing to a pair of instructions for tight-clustering, is valid.
The invention can include systems software to implement a low latency, high bandwidth multi-computer using existing readily commercially available commodity computer hardware and network devices. The invention can include a method to implement system software support for harnessing multiple, independent compute nodes using existing readily commercially available systems and network equipment or an interconnect fabric.
In general, the invention can include the use of a network driver shim SUBSTITUTE SHEET (RULE 26) between a network driver layer, and a protocol software layer. The shim passes packets from the protocol software layer through to the network driver layer.
Similarly, packets received from the network driver layer side are passed up to the protocol software layer.
A particular packet type identification can be used to decide how to handle received packets. As an example, in the case of the TCP/IP protocol, the Ethernet type identifier is 0x80-0x00, and is used by the shim to decide to pass the packet up to the protocol software layer for proper handling. In the case of low-latency packets taught by this invention, the shim can decide how best to handle the packet. The invention can include transformation of a data set. For some cases, the shim can also implement a lightweight protocol in order to recover from errors encountered on the network media (such as CRC errors, hung network controllers, dropped packets, buffer errors, etc.). The advantages of the invention include improved cost/performance over existing proprietary solutions.
The shim can expose an API (application program interface) for transport middle-ware to use in order to transmit packets, obtain information on local and remote multi-computer nodes, to setup packet receive sinks, and to control the lightweight protocol. Fault tolerance can be achieved by ganging multiple network interface cards in a single system, and either duplicating traffic over multiple network interface cards in a single system, or failing over when a failed NIC or system is detected. Fast recovery methods can be implemented by using network cards which give media sense interrupt indications, or by using relatively frequent "heartbeat" packets across the media.
Referring to FIG. 1, the invention can be implemented in the context of a network. A first network device/driver 110 is coupled to a network 100. A
first shim 120 is coupled to the first network device/driver 110. A first protocol layer 130 is coupled to the first shim 120. The first shim 120 and the first protocol layer 130 can both interface with a first transport application program interface (API) 135.
Still referring to FIG. 1, a second network device/driver 140 is coupled to the network 100. A second shim 1 SO is coupled to the second network device/driver 140. A second protocol layer 160 is coupled to the second shim SUBSTITUTE SHEET (RULE 26) 150. The second shim 150 and the second protocol layer 160 can both interface with a second transport API 165.
The shims 120, 150 permit handling of data (e.g., routing and/or transformation) based on the type of data and/or the type of application associated with the transport APIs 135 and 165. The transport APIs may be for the same, or.different, applications.
Referring to FIGS. 2-3, different types of system interconnects may be used. One example is the use of a true peer-to-peer interconnect through a network interconnect fabric (such as network switch). FIG. 2 depicts this arrangement. A system 0, a system 1, a system 2 and a system n-1 are all coupled to a network swich 200. System-to-system communication is accomplished through network communication provided by the network interface cards, media and network communications devices in the network.
Another system architecture that makes use of this capability is comprised of multiple compute nodes interconnected through a dedicated shared memory device. This model utilizes a "load-store" approach to remote memory access rather than message passing. This method reduces the cost associated with using a network communications switching fabric, and provides each system with a low latency, high bandwidth path to memory that is accessible by each compute node present in a particular configuration. An example of such a system structure is depicted in FIG. 3. In this embodiment, the system 0, the system 1, the system 2 and the system n-1 are all coupled to a dedicated shared memory node device 300. The dedicated shared memory node device may be RAM and/or a disk.
The system architecture of the invention may be used to implement any or all of the following subsystems:
1. Network access through shared memory.
2. A shared memory disk, where each system's hacking store may be cached, and available in the dedicated shared memory node device.
3. Locking primitives for controlled access to shared regions of memory.
Having a portion of shared memory common to each system allows each of the individual systems to have access to their own memory without the SUBSTITUTE SHEET (RULE 26) normal overhead of cache coherency mechanisms usually used for tightly-coupled, shared memory multiprocessor systems.
Referring to FIG. 4, the invention can be implemented in the context of an interconnect fabric. A first interconnect fabric interface 410 is coupled to an interconnect fabric 400. A first shim 420 is coupled to the first interconnect fabric interface 410. A first protocol layer 430 is coupled to the first shim 420.
The first shim 420 and the first protocol layer 430 can both interface with a first transport application program interface (API) 435.
Still referring to FIG. 4, a second interconnect fabric interface 440 is coupled to the network 400. A second shim 450 is coupled to the second interconnect fabric interface 440. A second protocol layer 460 is coupled to the second shim 450. The second shim 450 and the second protocol layer 460 can both interface with a second transport API 465.
Again, the shims 420, 450 permit handling of data (e.g., routing and/or transformation) based on the type of data and/or the type of application associated with the transport APIs 435 and 465. Again, the transport APIs may be for the same, or different, applications.
The context of the invention c.an .include mufti-computing. The context of the invention can include fault tolerance. The context of the invention can include shared-system network access. The context of the invention can include a shared network. The invention can include a network driver shim. The context of the invention can include an interconnect fabric, such as, for example, Infmiband.
The invention is an improvement over current clustering implementations in that traffic is intercepted and acted upon at the network device driver layer, and sent at the network device driver layer, and the invention also allows existing communication protocols to still use the same media. This provides a cost/performance benefit to the end customer.
This invention can be primarily systems software. Hardware accelerations can be applied by selecting network interface cards, which provide programmable packet type identification, and automatic media sense detection indications.
The invention can be implemented in the context of an ethernet network.
SUBSTITUTE SHEET (RULE 26) The ethernet can be connected to each of a plurality of PC machines by a NIC
card (network interface card) inside each PC. A NIC has its own required appllication interface (API). NIC's are intended to pass messages between PC's.
These messages tend to be somewhat long and somewhat infrequent, so are not 5 well suited for shared memory, which is why the preferred design does not use NTC's . Additionally, they tend to be very simple, which means that more processing is required in the software.
The invention can include a device driver which presents an API to the OS and also does all of the processing NICs require. The invention can then 10 also present the data to the NIC using its require API (the "transport API"). The invention permit a shared-memory machine to be run over a standard network, albeit slower than the machine disclosed in U.S. Ser. No. 09/273,430. Certain applications may not have many LOADS and STORES to shared memory, in which case they will run about as well over a standard set of PC's with industry standard network interconnections as they will on the hardware disclosed in U.S. Ser. No. 09/273,430.
The invention can also be implemented in the context of an interconnect fabric where a separate processor with some of its own memory is provided on a NIC. An example of an appropriate interconnect fabric is Infiniband. In this way, a much simpler method can be defined by which a main processor, when it needs to send or receive some data, just presents a special, short descriptor to the processor on the NIC and lets this NIC processor actually GET or PUT the data.
While not being limited to any particular performance indicator or diagnostic identifier, preferred embodiments of the invention can be identified one at a time by testing for the substantially highest performance. The test for the substantially highest performance can be carried out without undue experimentation by the use of a simple and conventional benchmark (speed) experiment.
The term substantially, as used herein, is defined as at least approaching a given state (e.g., preferably within 10% of, more preferably within 1% of, and most preferably within 0.1% of). The term coupled, as used herein, is defined as connected, although not necessarily directly, and not necessarily mechanically.
SUBSTITUTE SHEET (RULE 26) The term means, as used herein, is defined as hardware, firmware and/or software for achieving a result. The term program or phrase computer program, as used herein, is defined as a sequence of instructions designed for execution on a computer system. A program may include a subroutine, a function, a procedure, an object method, an object implementation, an executable application, an applet, a servlet, a source code, an object code, and/or other sequence of instructions designed for execution on a computer system.
EXAMPLE
A specific embodiment of the present invention will now be further described by the following, nonlimiting example which will serve to illustrate in some detail various features of significance. The example is intended merely to facilitate an understanding of ways in which the present invention may be practiced and to further enable those of skill in the art to practice the present invention. Accordingly, the examples should not be construed as limiting the scope of the present invention.
The printed source code attached to this invention disclosure is an example of how this invention would be implemented on Windows NT 4.0 and an Intel or Intel compatible processor based personal computer, using the NDIS
intermediate driver model. This example is intended to be exemplary, and does not preclude an implementation on a different system, operating system, or type of network. This example also does not exclude hardware accelerations for network controllers to enhance the capability of that controller for this application. A description of the attached software modules follows (this description is in the order that the files are presented in the appendix):
1. D:\nt4ddk\src\timesn\tnsdrvr\sources - A makefile description for creating the binary image.
2. D:\nt4ddk\src\timesn\tnsdrvr\tnsemul.rc - A file for describing the resource information to be embedded in the binary image.
3. D:\nt4ddk\arc\timesn\tnsdrvr\tnsemul.def - A file for describing the exported functions of the final binary image.
4. D:\nt4ddk\src\times\tnsdrvr\tnsif.h - Describes the constants and structures needed for an application to interface directly with the loaded, executing, binary image.
SUBSTITUTE SHEET (RULE 26) 5. D:\nt4ddk\src\timesn\tnsdrvr\tnsdef.h - Times N Systems Specific macros and constants.
6. D:\nt4ddk\src\timesn\tnsdrvr\tnsdebug.h - Header file for describing function prototypes. Constants, structures, and macros needed for using debug S services.
7. D:\nt4ddk\src\timesn\tnsdrvr\tnsapi.h - Header file for describing the exported Times N Systems services for emulating a high-speed interconnect.
8. D:\nt4ddk\src\timesn\tnsdrvr\tns.h - Structures, function prototypes, constants, and macros for the module in whole, including managing the object context, and interfacing to an existing, commodity network interface device.
9. D:\nt4ddk\src\timesn\tnsdrvr\tnsdebug.c - Debug services 10. D:\nt4ddk\src\timesn\tnsdrvr\tnsapi.c - Implementations for the Times N
Systems application programming interfaces for an emulated high-speed interconnect.
11. D:\nt4ddk\src\timesn\tnsdrvr\tnsemul.c - Main initialization file, Driver entry, relatively infrequently used functions 12. D:\nt4ddk\src\timesn\tnsdrvr\recv.c - Receive packet processing, including high-speed interconnect transport processing 13. D:\nt4ddk\src\timesn\tnsdrvr\send.c -Send packet processing 1. D:\nt4ddk\src\timesn\tnsclien\tnsclien.h - Client driver header file 2. D:\nt4ddk\src\timesn\tnsclien\tnsclient.c - Client driver implementation (an example of how interconnect transport services would be used).
An experimental system was prototyped using 100Mbit/sec full and half duplex network equipment, and gave very good throughput numbers.
Practical Applications of the Invention A practical application of the invention that has value within the technological arts is waveform transformation. Further, the invention is useful in conjunction with data input and transformation (such as are used for the purpose of speech recognition), or in conjunction with transforming the appearance of a display (such as are used for the purpose of video games), or the like. There are virtually innumerable uses for the invention, all of which need not be detailed here.
SUBSTITUTE SHEET (RULE 26) Advantages of the Invention A system, representing an embodiment of the invention, can be cost effective and advantageous for at least the following reasons. The invention improves the speed of parallel computing systems. The invention improves the scalability of parallel computing systems. The invention improves the overall system throughput for a system multi-computer implementation.
All the disclosed embodiments of the invention described herein can be realized and practiced without undue experimentation. Although the best mode of carrying out the invention contemplated by the inventor is disclosed above, practice of the invention is not limited thereto. Accordingly, it will be appreciated by those skilled in the art that the invention may be practiced otherwise than as specifically described herein.
For example, although the low latency, high bandwidth multi-computer system interconnect described herein can be a separate module, it will be manifest that the low latency, high bandwidth multi-computer system interconnect may be integrated into the system with which it is associated.
Furthermore, all the disclosed elements and features of each disclosed embodiment can be combined with, or substituted for, the disclosed elements and features of every other disclosed embodiment except where such elements or features are mutually exclusive.
It will be manifest that various additions, modifications and rearrangements of the features of the invention may be made without deviating from the spirit and scope of the underlying inventive concept. It is intended that the scope of the invention as defined by the appended claims and their equivalents cover all such additions, modifications, and rearrangements.
The appended claims are not to be interpreted as including means-plus-function limitations, unless such a limitation is explicitly recited in a given claim using the phrase "means for." Expedient embodiments of the invention are differentiated by the appended subclaims.
SUBSTITUTE SHEET (RULE 26) qP~e~~X
File: D:\nt4DDK\src\timesn\tnsdrvr\sources Page y of y 1 !IF o 2 Copyright (c) 1989-1993 Microsoft Corporation 4 Module Name:
sources.

7 Abstract:
8 This file specifies the target component being built and the list of 9 sources files needed to build that component. Also specifies optional compiler switches and libraries that are unique for the component being 11 built.
12 !ENDIF

14 MAJORCOMPmntos MINORCOMP~ndis 17 TARGETNAME~tnsemul 18 TARGETTYPE~EXPORT DRIVER
19 TARGETPATH~S(HASEDIR)\lib 21 TARGETLIHS=S(HASEDIR)\lib\'\S(DDKBUILDENV)\ndis.lib 23 INCLUDES-S(BASEDIR)\inc;S(HASEDIR)\src\network\inc;..\inc C_DEFINES~S(C DEFINES) -DNDIS_MINIPORT_DRIVER
26 C_DEFINES~S(C_DEFINES) -DNDIS40 27 C DEFINESaSIC DEFINES) -DNDIS40 MINIPORT
28 C DEFINES~$(C DEFINES) -DHINARY COMPATIBLE~O
29 - _ MSC_WARNING_LEVEL~/W3 /WX

32 SOURCES-tnsemul.c \
33 recv.c \
34 send.c \
tnsapi.c \
36 tnsdebug.c \
37 tnsemul.rc ~na.a by cwsP.~e.s.» 9:04 am Thursday, 30 September 7 999 File: D:\nt4DDlC\src\timesn\tnsdrvr\tnsemul.rc Page 1 of 7 1 (include <windows.h>
2 linclude <ntverp.h>

q /~_______________________________________________~/
5 /~ the following lines are specific to this file ~/
/~_______________________________________________./

8 /' VER FILETYPE, VER FILESUHTYPE, VER FILEDESCRIPTION STR
9 ~ and VER INTERNALNAME STR must be defined before including COMMON.VER
10 ~ The strings don't need a '\0', since common.ver has them.
11 '/
12 9define VER FILETYPE VFT DRV
13 9define VER FILESUBTYPE VFT2 DRV_NETWORK
14 9define VER FILEDESCRIPTION STR "Times N Systems Emulation Layer"
15 6define VER_INTERNALNAME_STR "TNSEMUL.SYS"
17 Ninclude "common.ver"
19 iinclude "evtmsg.rc"
vr~~.abru~ev.~e.z-~. 9:01 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsemul.det Page 7 of 1 DEF File for TNSEMUL.SYS
NAME TNSEMUL.SYS
DESCRIPTION 'TNSEMUL.SYS' EXPORTS
Pnr~ewbyCRI8PvE3.l~ 9:02 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsff.h Page 1 of y 36 ;~;

38 /define DEBUG INFO 0 39 (define DEBUG_MESSAGE 1 idefine DEBUG WARNING 2 41 ldefine DEBUG VERBOSE 3 42 9define DEBUG_ERROR 4 49 9define DEBUG_MASKEN ERROR 0x01 (define DEBUG MASKEN RECV 0x02 51 (define DEBUG MASKEN_SEND 0x04 52 (define DEBUG MASKEN_INIT 0x08 53 idefine DEBUG MASKEN PACKETDUMP 0x10 54 (define DEBUG_MASKEN_ENTRYEXIT 0x20 57 idefine FILE DEVICE TNS 0x00008301 58 idefine TNS IOCTL BASE 0x830 59 idefine IOCTL_TNS_SETDEBUGINFO CTL CODE(FILE_DEVICE_TNS, \
TNS_IOC1'L_BASE+0, \
61 METHOD_BUFFERED, \
62 (FILE READ ACCESS I FILE WRITE ACCESS)) 63 _ _ _ _ 64 typedef struct TNS IOCTLPACKET
ULONG DebugLevel:
66 ULONG DebugMask;
67 ULONG DebugHreakFlag:
68 ) TNS IOCTLPACKET, 'pTNS IOCTLPACKET:

71 tendif Pn,s.dbr~b.z.~~ 9:01 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsdefs.h Page 1 of 2 s 33 typedef LONG LOCKID;
34 typedef LOCKID 'PLOCKID:
36 typedef LONG LOCKSTATUS;
37 typedef LOCKSTATUS 'PLOCKSTATUS;

39 typedef LONG TNSKEY;
typedef TNSKEY 'PTNSKEY;

42 typedef LONG TNSCPUID;
43 typedef TNSCPUID 'PTNSCPUID:

typedef LONG TNSNOTIFYSTATUS;
46 typedef TNSNOTIFYSTATUS 'PTNSNOTIFYSTATUS;

49 typedef LONG TNSCOUNTER:
typedef TNSCOUNTER 'PTNSCOUNTER:

52 typedef LONG TNSQUEUE:
53 typedef TNSQUEUE 'PTNSQUEUE:

typedef LONG TNSQUEUEINFO;
56 typedef TNSQUEUEINfO 'PTNSQUEUEINFO;

58 typedef LONG TNSMEMSIZE; .

typedef LONG TNSMEMFLAGS:

63 $define NTSTATUS CUSTOMER CODE 0x20000000 $define TNS STATUS CODE(Severity, StatusCode) (\
66 (NTSTATfIS CUSTOMER CODE I (Severity « 30) I StatusCode)) ~.... .~9 74 typedef enum TNS SUCCESS~O, 76 TNS NOT IMPLEZ~fENTED, 77 ]; - _ 79 $define _TNS STATUS SUCCESS TNS STATUS CODE(STATUS SEVERITY SUCCESS, TNS
SUCCESS) 81 $define - _TNS STATUS NOT IMPLEMENTED TNS STATUS CODE(STATUS SEVERITY
ERROR, TNS NOT IMPLEMENTED) Pn.raeycwePVe.2i~ 9:02 am Thursday, 30 September 1999 Ffle: D:\nt4DDK\src\timesn\tnsdrvr\tnsdefs.h Page 2 of 2 ~~~~'~°"°z'~ 9:02 am Thursday, 30 September 1999 File: D:\nt4DDIC\src\timesn\tnsdrvr\tnsdebug.h Pege 1 ,of 2 z ~ f 36. ~9~=%g '.~~--.-'~'~'~3' ."....~!s.~~~."~...cr'~'''~~eP:..'i 38void 39TNSMakeBeep(void):

42(include "tnsif.h"

51(Idefine DEBUG QQUOTE(y) DEBUG QUOTE(y) 52Ndefine REMIND(sz) FILE-"("DEBUGLINE)"):~sz QQUOTE( 59iifdef DBG

56char GetNDIS0IdString(NDIS
OID NdisOID, PULONG pFoundFlag):

57char GetNDISStatusstring(NDISPULONG pFoundFlag):
STATUS Status.

58char GetNDISEventString(NDIS
ERROR CODE ErrorCode, PULONG pFOUndFlag):

61NdisDumpPacket( 62PNDIS_PACKET Packet):

64(idefine STATIC

67DebugPrint( 68ULONG DebugPrintLevel, 69PCS2 DebugMessage, 70...

71):

74MaskDebugPrint( 75ULONG DebugPrintLevel, 76ULONG DebugPrintMask, 77PCS2 DebugMessage, 78...

79);

81extern ULONG gDebugPrintLevel;
-82_gDebugPrintMask;
extern ULONG

~~~r~P~~-'~ 9:03 am Thursday, 30 September 1999 File: D:\nt4DDIC\src\timesn\tnsdrvr\tnsdebug.h Page 2 of 2 83 extern ULONG _gDebugBreakFlag:

85 Ndefine DEHUG_MODULE "DEBUG: ~

87 Ndefine DINF'O(x, y) \
88 DebugPrint(x, ~8s~, DEBUG MODULE): \
89 DebugPrint(x, ~File e> 8s: " FILE ): \
90 DebugPrint(x, ~Line => 8d: ", -LINE-): \
91 DebugPrint y:

93 Udefine D(x) DebugPrint x:

95 Ndefine DM(x) MaskDebugPrint x:

97 $define DUMP PACIDrT(x) NdisDumpPacket(x) 99 8define INT3 ( _asm int 3 ) 101 Ndefine HreakPoint() \
102 ( DbgPrint("Debug Break in file => 8s, at line 8d\n", FILE- LINE-); \
103 1f ( gDebugHreakFlag) f asm int 3 ) 105 8define MyASSert(c) if (!(c)) (\
106 ( DbgPrint("Assertion failure: Debug Break in file => 8s, at line %d\n", FILE- LINE-): \
107 if (_gDebugHreakFlag) ( asm int 3 ) : ) 109 6else ~t~~.GBG

111 Adefine STATIC static 112 Adefine DINFO(x,y) 113 4define D(x) 114 %define DM(x) 115 6define Breakpoint() 116 Adefine INT3 117 idefine MyASSert(c) 118 8define DUMP_PACKET(x) 120 iendif ~'~1 121 iendif ~'_,:

~n.r.abrcwsP.~n-s-~~ 9:03 am Thursday, 30 September X999 Ftle: D:\nt4DDlC\src\timesr,~tnsdrvr~trtsapt.h Page 'I of y y 31 (fdefine DECLSPEC EXPORT declspec(dllexport) 33 ~~uwr~~~rrsa,~ . ... ." . ~aF-~~t~wv.:a~~~ri.,~w~rn.~.ay-~cr!
- ,... - ~~szau:arcr~~rm"wr:fras;r ~~umars.ttr~axn,.<. . ».,~

ULONG
36 DECLSPEC_EXPORT
37 _TNS READ REGISTER ULONG( 38 IN PVOID DeviceHandle, 39 IN PULONG Register):

54 TNS tiRITE_REGISTER ULONG( - IN- PVOID DeviceHandle, 56 IN PULONG Register, 57 IN ULONG RegisterData):

USHORT

72 _TNS READ REGISTER USHORT( 73 IN PVOID DeviceHandle, 74 IN PUSHORT Register):

78 . _ , ~nne.d ey cweP vezu 9:03 am Thursday, 30 September 7999 Flle: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.h Page 2 of 11 83 .~~'~.~. ,,....,r.~,xerx.~y~,~.-Sla.,i..mriis~.~.i.~r3i;~~iLrr.~W..ei~arrri~r.f~:~.,rsw~.xiir~,ri~lYtasw3ci.~i~
r~ri.~ir'i.me.
cr s~,:':...ta.~,~::::::x......t...:;:::~~.~..u._.:..:c~..:F.~:.ad,s"urb.....r~.,~
,u~x.~.::.::.~".,owl.,.". ...~...-.e.a:...,.,.._",.~'.._ , , ~"ly~Yaai'6~i1'.~:f~l:~its'i'H'~r21.i~1'iYi17Y4~Fia7i",iii~iala~~i'i~i:,iiia~l.
f"iulaYrUa~r~i' ali!i?~ifl1'ii~
B 5 "',,~--,.14 d'Y.x w *.~ .~~:,"~:.~: ."~a:»:~:a;ywv..~;::.c~ ;~~;~a :..,x~e a.~;,~~,.". wc,. ,?.:..~.~.x ,»,.,~.,. .~....s ....;.,.~,~,..-=z,~
86 ~fy 89 _TNS WRITE REGISTER USHORT( 90 IN PVOID DeviceHandle, 91 IN PUSHORT Register, 92 IN USHORT RegisterData);

103 ~.~>-a."-",six'.r~..~.ra;,~.~.r~.ra~~ig~.~,.~.:~rxax.i.r..rr~.
104 ~~. ~"-°wr...., ,. x . .,~."...a x ~...~..,... r. ....~.~....-~r r.".. .:., ....,. ,~.

107 _TNS READ REGISTER UCHAR( 10A IN PVOID DeviceHandle.
109 IN PUCHAR Register):

lls lls lle 120 '":~3~'~~F,w'~?s~a~.~~~.;ex'."a~,rx~r.
121 _~,~e~a,,ayw:xr~n wEk~~?si?r,,xi s~.m:a3:~xawi.~..rx x'~as2~; ~.~.~~:,rr kheat:...ar..~..-~.ra.~;

124 _TNS_WRITE REGISTER_UCHAR( 125 IN PVOID DeviceHandle, 126 IN PUCHAR Register, 127 IN UCHAR RegisterData);

140 x '.~ar~~a~._'.~ ~~an-~~

143 DECLSPEC_EXPORT
144 _TNS READ REGISTER BUFFER ULONG( 145 IN PVOID DeviceHandle.
146' IN PULONG Register, 147 IN PULONG pulBuffer, 148 IN ULONG Count):

15 9 -*a'~i?s"'r 163 _TNS WRITE_AEGISTER BUFFER ULONG( 164 IN PVOID DeviceHandle, 9:03 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.h Page 3 of y 1 165 IN PULONG Register, 166 IN PULONG pulBuffer, 167 IN ULONG Count);

178 . "'~r.r~".tt7rsra~kZ3iTS~.i!~l.~aP~iiid,iw~'''>rrXir'.~'~~.- ~:
.........,:a~ii'dTi~'.ra,:Wir'v'37iYtiSRY~JE~YAYw:Y
.3:~faw~"Y~215t~3~C~So~~~'S'e~~ ~r~Ni31'.iK'~~ b.6.:~i:3iF:w'b.

181 DECLSPEC_EXPORT
1B2 _TNS READ REGISTER BUFFER USHORT( 183 IN PVOID DeviceHandle, 184 IN PUSHORT Register, 185 IN PUSHORT pus8uffer, 186 IN ULONG Count):

196 _ _ e.... -~. . _,. _ " ._ , .. ; . : ~. . . : . ,, y'x~~Y.. .._...
197 p -° 'siai'r~;~w~' 201 _TNS WRITE REGISTER_BUFFER USHORT( 202 IN PVOID DeviceHandle, 203 IN PUSHORT Register, 204 IN PUSHORT pusHuffer, 205 IN ULONG Count);

221 _TNS READ REGISTER BUFFER UCHAR( 222 IN PVOID DeviceHandle, 223 IN PUCHAR Register, 224 IN PUCHAR pucBuffer, 225 IN ULONG Count):

240 _TNS WRITE REGISTER BUFFER UCHAR( 241 IN PVOID DeviceHandle, 242 IN PUCHAR Register, 243 IN PUCHAR pucHuffer, 244 IN ULONG Count);

296 (' ~rr.a br ~ va.s.,~
9:03 am Thursday. 30 September 1999 Flle: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.h Page 4 oT 1 y 255 ' .~»;~s~..-,"~''F~''~~'~'"~ '~~~'s'~r",'~"'.~~ia:
256 ' ' ~ v, to ,smx...~i»;~ ..rta~xa~,r.see.,o .m,.".

259 _TNSAcquireLockP( 260 IN PVOID DeviceHandle, 261 IN PLOCKID pLockID);

272 "'~ri-*a~~ .s~""x~'rts'~~~s"=bV.'~Wis~~,. i'~
r~t:xa~atYtY~sa3h'.fexaxr' .~k~.~its~FSr. ~u;::. pus..-~~srrrt~,=.~».".ar~,~~~~..

276 _TNSReleaseLockP( 277 IN PVOID DeviceHandle, 27B IN PLOCKID pLockID);

2e4 zes 290 ~ _ 293 TNSQueryLockP( 294 - IN PVOID DeviceHandle, 295 OUT PLOCKSTATUS phockStatus):

312 _TNSAllocateLockP( 313 IN PVOID DeviceHandle, 314 IN TNSKEY Key, 315 OUT PLOCKID 'pLockID):

326 , 328 TNS xSTATUS
P"'e'°°r'~~"°~" 9:03 am Thursday, 30 September 1999 Flle: D:\nt4DDK\src\tlmesn\tnsdrvr\tnsapi.h Page 6 of 71 330 _TNSFreeLockP( 331 IN PVOID DeviceHandle, 332 IN TNSKEY Key, 333 IN PLOCKID pLOCkZD):

34 4 ~ ~~~xa~~~~ a ~~ .. .. , 39 5 ~ _'~~~~m>c~" iii' ~.~y~y,;ammxcsw-_~, -s 348 _TNSNotifyCPU( 349 IN PVOID DeviceHandle, 350 IN TNSCPUID CpuID, 351 IN PVOID pMessageHuffer, 352 IN ULONG MessageLength):

f60 368 IN PVOZD DeviceHs3ndle, 369 IN TNSCPUID CpuID, 370 IN PVOID pMessageHUffer, 371 IN ULONG MessageLength, 372 IN PVOID pCallback, 373 IN PVOID pContext):

379.

389 _TNSpueryNotifyStatus( 390 IN PVOID DeviceHandle, 391 IN TNSCPUID CpuID, 392 IN OUT PTNSNOTIFYSTATUS pCpuNotifyInfo):

409 IN PVOID DeviceHandle, 410 IN PVOID pCallBack, -" 9:03 am Thursday. 30 September 1999 Ffle: D:\nt4DDK\src\tfmesn\tnsdrvr\tnsapi.h Page 6 of 1 y 411 IN PVOID SysPaiml, 412 IN PVOID SysParm2, 413 IN PVOID SysParm3):

t 'ir.7ikfill~wis:ai~iii'i~'f~~~its:~saiir~i~.
425 ~,~,.,_.M_,..~s~.....,~;,w:~..: .. -..~°.~~.~c~cto ..._._.__ :, :. _..
4 2 6 j~:lt~.
427 TNS_STATUS

429 _TNSRegisterNotificationCallback( 430 IN PVOID DeviceHandle, 431 IN PVOID pCallBack, 432 IN PVOID SysParml, 433 IN PVOID SysParm2, 434 IN PVOID SysParm3):

4 4 6 a~.~,au7v:~~ r~ca~:.s .,.~~~-~a-~;kx~,-~ry.....':~i.~:at.dix. ..~,~.uxi»,:Ek 450 _TNSDeRegisterNOtificationCallback( 451 IN PVOID DeviceHandle, 452 IN PVOID pCallBack):

464 ~5~*~~".~.~,~'''~'~~f~",~'~~~~~~'-~''~~~-~~~"
4 65 .~:

468 _TNSWhoAmI( 469 IN PVOID DeviceHandle):

480 . aah~~~r.~~'~' 4 81 ~;

484 _TNSReadOrdinalCounter( 485 IN PVOID DeviceHandle):
486 ~~!:

488 ' 4 8 9 ~r...~~

491 ~:. ~~?
492 ~ ~:: ~,.;
rr~.wweyG~.~e.z-i. 9:03 am Thursday. 30 September 1999 File: D:\nt4DDK\s~c\timesn\tnsdrvr\tnsapi.h Page 7 of 1' 4 93 ~'°"~
4 94 ~'~.~~&:s'a'i~,Y~s»wr~s .W,a,~rai6~err~:'?tr~,~c ;iirrJr4it~iYyi'ryi~'I4:;ic' ~r..~.;,,.r~rc sa:~,...ausc:~,::~ra;;..,..~_~:~~~~ a:u:::.as:",.-.."z..
.~,:~,~ut~'-~~xa.:;.-:z:~,.,.~:~~tr~,.:.~ w,..sY.,r.M

4 97 ~/~y.,~~yc..t~~''.a..w,~~~~'~?'~"~.w,:~:azsu;a:~a:::c°.,~.....:.»r 498 ~I~~~~~

501 _TNSAllocateSharedNemory( 502 IN PVOID DeviceHandle, 503 IN TNSKEY Key, 504 IN TNSMEMFLAGS Flags, 505 IN TNSMEMSIZE Size, 506 IN OUT PVOID ~ppBuffer):

518 ~'~Tf.~r~mrer~W~e~ea~ac'#',wrwtd;.r... s..~~r ,s-.xr~sax.~ee~az~~ - ' s~ai~risemmr..,~~~..-.,a~z~c:.~mcu~~:xz5 521 DECLSPEC_EXPORT
522 _TNSFreeSharedNemory( ' 523 IN PVOID DeviceHandle, 524 IN TNSKEY Key, 525 IN PVOID Ptr, 526 IN TNSMEMSIZE Size):

541 _TNSReadSharedMemory( 592 IN PVOID DeviceHandle, 593 IN PVOID pSharedMemoryAddress, 544 IN ULONG Length, 545 IN PVOID pBuffer):

559 TNS_STATUS

561 _TNSWriteSharedMemory( 562 IN .PVOID DeviceHandle, 563 IN PVOID pSharedMemoryAddress, 564 IN ULONG Length, 565 IN PVOID pHuffer):

" 9:03 am Thursday, 30 September 199!

File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.h Page 8 of 11 57s 576 ~
.~'~"~''a"~~.i."IGS'3t°Gr~ui.'8'Saw"i3i.'Cafir.rwa.si+'Sn.i~'rt1'~wxmS7~
xi~'i3~X~r3Yy~3r~3vk~rr"'S~a.'~
..,..c,.,...,..d~.~rc.~'"Sut,.;...~.,:~:~'»., M...,.rx..:,.:a,:-.,.:.u ~x> ..
,<..~... va~.a...,:..N.,.-".c. ..~.."».. . .. ...r..~., <.>. . x " r n4 s~

580 _TNSDmaReadSharedMemory( 581 IN PVOID DeviceHandle, 582 IN PVOID pSharedMemoryAddress, 583 IN ULONG Length, 584 IN PVOID pBuffer, 585 IN PVOID pCallback, 586 IN PVOID DMAReadCompleteComtextl, 587 IN PVOID DMAReadCompleteComtext2):

598 ~~TS~r7~ .'~' a . . ~.~;~si~si~>s~'ar'~~r'~~#~e.~sl.# ~.~-~ra.__'~:~%~*~w.»
599 "~'~,~'a'~aaa~,rnu ~i~ttn:.~,~:, .~.r.,.s~.~~ ._ ..~.'~m u~eurtq,.:zav.~zsev~:~-e~. .... .xx~._.. r.~,~...~ar~. ~ < ...s ~?~-.~f 600 TNS_STATUS

602 _TNSDmaWriteSharedMamory( 603 IN PVOID DeviceHandle, 604 IN PVOID pSharedMemoryAddress, 605 IN ULONG Length, 606 IN PVOID pHuffer, 607 IN PVOID pCallback, 60B IN PVOID DMAWriteCompleteComtextl, 609 IN PVOID DMAWriteCompleteComtext2):

619 _ 620 Ix ; ~7~~~~ ~.~~,= _~ =..~~°~wxaeoa~~~~.
621 ~~ _ 623 DECLSPEC_EXPORT
624 _TNSAllocateWorkQueue( 625 IN PVOID DeviceHandle, 626 IN TNSKEY Key, 627 IN PULONG pQueueLength, 628 IN OUT PTNSQUEUE ~ppTNSQueuel:

640 ~;ru~;~.::c>~.-;ac.sa~::d~.a:::astcxr-a 641 ~~

644 _TNSFreeWOrkQueue( 645 IN PVOID DeviceHandle, 646 IN TNSKEY Key, 647 IN PTNSQUEUE pTNSQueue):

~n~rwbr~.~e-z.i~ 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.h Page 9 of y y 6 S 8 )~'~'~'~'w''r;~'*t'a"~'~'°"~**y'aaaa~a aiawa v.rai*s>9~caiasaaa.~rrasiu,rss.a-aaaNa.i:ya-r*a.a~i7lsias~.l~xa ~..,.:_., "."~.~.:.~.,-,.z..,.: . ~~:.,:.a_., ........r ..,. "a:~.z:,. -..
Y=.. ..., .m, ,.,... " :. . ..... ~...., ...._-..,>.~,.,........."~..,...
65 9 r -'7~'r J.._..
660 TNS.~STATUS
661 DECLSPEC_E7CPORT
662 _TNSInterlockedEnqueueToDoP( 663 IN PVOID DeviceHandle, 664 IN PTNSQUEUE pTNSQueue, 665 IN PVOID pItem, 666 IN ULONG Length):

r'"~?ti~a»,r~7.,s~iii.i~s~.aiialrxy,.',i:,r..'/L~,i~aa.r.x.~~fi'i.,aa~.~i~~~,~F
ixi.,'~"~~#a~f.ia'Y.i .,..,~";_....";,~;,_". -.,r..,--~_~~.es.>~'.~ i.. ..-.:.e..~x ~~_.r . ...._ >,~,.xr..-,x~«r..,.,G<u:.. .4__._-..- .f.,-..~_._-x-:.-;...;
679 ~~~., 680 TNS_~STATUS

682 _TNSInterlockedDequeueToDOP( 683 IN PVOID DeviceHandle, 684 IN PTNSQUEUE pTNSQueue, 685 IN PVOID pItem, 686 IN PULONG pLength):

696 _ 697 ~' _ i~ ''9~,x;i~'r'~,'~'.,TGt~si,rni~r~*'s~sr~i:~irit!-~'~w.~r?!~ic'~ava'et ~'~,~.~.Vimmd~~twixSis.G~Vt,ts"'. ~ . -Y5~- 4ur ~i'~.u-l~.ivw.~A.
698 I~~--~

700 DECLSPEC_EXPORT
701 TNSQueryQLengthP( 702 - IN PVOID DeviceHandle, 703 IN PTNSQUEUE pTNSQueue, 704 IN PULONG pLength);

,rte . _ ~ _ _ . . . _. ..
717 4=T mma~aaa:.acuae~.:s~'mra.-X~m~-=~~...,..~,wd:xnts~:~"s.-.a~mzeae.°CCai~-esieS.s.~satrsx:xs~aie~!~..s,.;vsc:~oeascs....~!ec! -:.~::v ~r,~:

719 DECLSPEC_EXPORT
720 _TNSQueueHeadP( 721 IN PVOID DeviceHandle, 722 IN PTNSQUEUE pTNSQueue, 723 IN OUT PTNSQUEUE ~ppTNSQueue):

734 _ 7 3 5 .~x~~rcw~;~rrvrya~a~s~r~rr~x~~.:~:.~
~....a~ ~r.~-~ ,_~~.,.;~am~xaw-v:rx -sxu..a..:~ ~..xc:ca.~s:~a2 .c:
736 ~:

9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapl.h Page 10 of y y 739 _TNSQueueTailP( 740 IN PVOID DeviceHandle, 741 IN PTNSQUEUE pTNSQueue, 742 IN OUT PTNSQUEUE ~ppTNSQueue):

754 ~''~N~t~"w~rsrr~e~,r"~"hw~iic*i~lisC.~~Hi~.:yGi~r"awl~.wie~7s:~"d,°
es;~e3cass~.xxuKC..:a:..ea:rJaxxaaa~:.e..c- -:a;~a.:~.~a;~:;a,:aL.c~.n,;.,...ss~t a:~:ar'Mxcsstcz.~::.:"...E- .;.~,.~.....

757 DECLSPEC_EXPORT
758 _TNSQueuePayloadP( 759 IN PVOID DeviceHandle, 760 IN PTNSQUEUE pTNSQueue, 761 IN PVOID pItem, 762 IN PULONG pLength):

774 are gay. ~:w'rra~'yr'~a ~ ~.a~.~?avcicz 3G_..;
~rc. ,....... ~.....~..~.,..:vcY~.:.°s;.a;s... ,.. ,;::,~.......~..~.e ~~.r~'s'--~.:,~~. ".~.~.''..~xu;~

776 TNS_STATUS

778 _TNSQueueNextP( 779 IN PVOID DeviceHandle, 780 IN PTNSQUEUE pTNSQueue, 781 IN OUT PTNSQUEUE ~ppTNSQueue):

792 .: . .. _ ._, ... ...... .~_. . .. ..~.. _.... .~... ' :'...:_ 796 _TNSInterlockedInsertQueueItemP( 797 IN PVOID DeviceHandle, 798 IN PTNSQUEUE pTNSQueue, 799 IN PTNSQUEUE pTNSQueueInsert):

811 . , .

813 TNS_~STATUS

815 _TNSInterlockedDeleteQueueItemP( 816 IN PVOID DeviceHandle, 817 IN PTNSQUEUE pTNSQueue, 818 IN PTNSQUEUE pTNSQueueDelete):

9:03 am Thursday. 30 September 1998 File: D:\nt4DDK\src\tfmesn\tnsdrvr\tnsapi.h Page 11 of 71 e21 828 _ "~'.at~!', .'c ~'e »*,c~.s'Yr*~-'. .~i~*~?kxrE'.~,~'3i,~s.', 829 I',..xa~~~,~,~.n: ~:.r~ ~ ~raw.c7 833 _TNSQueueItemInfoP( 834 IN PVOID DeviceHandle, 835 IN PTNSQUEUE pTNSQueue, 836 IN PTNSQUEUEINFO pTNSQueueInfo):

850 _TNSGetFirstDeviceInstance( 851 PVOID ~ppDeviceInstance):

854 DECLSPEC_EXPORT
855 _TNSGetNextDeviceInstance( 856 PVOID pDeviceInstance, 857 PVOID ~ppDeviceInstance):

~~.ebreweP.~e.Q.~~ 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tns.h Page 1 of y 1 z 31 8ifndef _TNS H
32 9define TNS H
33 Uinclude <ntddk.h>
34 iinclude <ndis.h>
$include <ntddndis.h>
36 pinclude <tdikrnl.h>
37 9lnclude "tnsstats.h"

39 Ndefine MIN PACKET POOL SIZE Oxff 90 Ifdefine MAX PACKET POOL SIZE Oxffff 41 - _ _ 43 ~~A~C~
~,. _......_.......
4 9 ~,3f) 46 Ndefine SHUTDOWN_DEALLOC PACKET POOL 0x00000001 47 pdefine SHUTDOWN_DEALLOC_--LOOKAHEAD POOL 0x00000002 48 9define SHUTDOWN_DEALLOC RESIDUAL POOL 0x00000004 49 Ndefine SHUTDOWN_DEINIT DEN INSTANCE 0x00000008 6define SHUTDOWN DELETE PIPE 0x00000010 51 8define SHUTDOWN TERMINATE WRAPPER 0x00000040 52 8define SHUTDOWN_DEREGISTER PROTOCOL 0x00000080 53 9define SHUTDOWN_DELETE DEVICE 0x00000100 54 9define SHUTDOWN_DELETE_SYNB.INK 0x00000200 56 Ndefine READ_HIDDFd4-CONFIG( Field, ParamType ) \
57 [ \
58 ConfigurationInfo-> Field = \
59 ReadSingleParameter(COnfigHandle, \
Str $N Field, \
61 ConfigurationInfo-> Field, \
62 ParamType): \
63 ?

~define DECLARE-STRING( str- ) STATIC WCHAR Str 98 str-() ~ L9 str_ 67 Ndefine ETH_ADDRESS_LEN 6 Gra~~xa"er~e"'~~,~ ~FP~..~'~:~.9~.~.~0 71 ~~Es~~~
72 a 74 Ndefine MPNAME EXTENSION SIZE ( 3 ~ sizeof(WCHAR)) 77 $define MAX COMPUTER NAME SIZE 16 78 - _ _ 79 typedef struct SMNNodeTable int LocationSet;

81 unsigned char TNMacAddress(HARDWARE ADDRESS LENGTH]:
82 unsigned long TNNOdeID:
9:04 am Thursday. 30 September 1999 File: D:\nt4DDK\s~c\timesn\tnsdrvr\tns.h Page 2 of y 1 83 unsigned char TNComputerName[MAX_COMPUTER NAME SIZE]:
84 ) SMNNodeTable, 'pSMNNOdeTable:
86 6define MAX_TEAM_NODES 128 a 9 Y~e~;Adaptg=:s:~ca~1-~~Ta~k ~:J
91 typedef struct ADAPTER

93 %f~E read sL~xrci~ure~mem~r for :us ~~DPC r tvyritled~st_:.mana _.....e. ... _,_.. ~:,....._..~ . .. ,.~. _ _ 94 1~~~q~ppg: _ ' _ ~f 96 LIST_ENTRY Linkage:

99 BOOLEAN TNSDriverInitialized;

101 '/y 102 ~",~:,'~'t~Ze,o3-f~i3~~c~,sP3,u$,~f~,'iorYa_tact ~s~~~~gs 103 l?7 104 int AdapterStructSize:

118 NDIS STRING TNSDeviceName:
119 NDIS STRING MPDeviceName:
120 ULONG ShutdovnMask:
121 ULONG TNSMPState:

146 - BOOLEAN CopyLOOkaheadData:
147 NDIS HANDLE TNSNdisHandle:
148 NDIS EVENT BlockingEvent:
149 NDIS STATUS FinalStatus:
150 NDIS_HANDLE PacketPoolHandle:

153 ~'fi~i1'-:~Ge'~'&~ua~..~~.~.~~~

157 ULONG LookaheadHUfferSize:
158 NDIS_HANDLE LookaheadPoolHandle:

160 r~~"~.
161 ~3~i~~~,8ati~T~,'~'~i~'."'.~tiC=

162 ~J' t ibPBandie'~"r ~e~'~a~ Sao .gz3.
163 ~T_..._..____. __,N,. .~.. ,fir.... 3':..,._..

RInEW by CR19P vE2lw 9:04 am Thursday. 3o Se~ptembe~ 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tns.h Pege 3 of 17 175 NDIS_HANDLE LowerMPHandle;
176 UCHAR LowerMPMacAddress[HARDWARE ADDRESS LENGTH];

180 NDIS HANDLE BindContext:
181 NDIS MEDIUM MediaType;
182 ULONG LinkSpeed;
183 ULONG TotalSize:
184 LIST_ENTRY CllentList:
185 _ 186 ""'"ate,-u.~ois~..x~~~~~ ~'~~ _.~~i 187 "~~""'a"a':,.xa.~x.r~.r,~...-,.~--r~,~~. ax 188 ~~Tiatgagftt]~~~n.~a'tl a s. -: r. .r.3-H..... ~x. ..:-f wrrxrra:a~r..~~.~~m,r:v~
18 9 ,,- ",~;",~",x ~.,"~'~. ,;b;,..r.,~en;..,~mr~n . _' a~,~~.,~~"ssua"
..~.~ew~.a.,n,.....;.

191 ULONG ListEntryItems:

193 HANDLE CllentworkerThreadHandle;
194 HANDLE ServerWorkerThreadHandle;

196 ~_ ~o'e'3~5.~'~t"~~"' 198 KSPIN LOCK ListEntryPoolLOCk;

200 ~5 ", ... ~- . .. ~.1....,~~

202 LhST ENTRY workerListEntryPool;

207 KSEMAPHORE CllentWorkerRequestSemaphore;

210 .~,.~w ~., ~q' 212 KSEMAPHORE ClientworkerResponseSemaphore:

215 ~~ .,. _. a 216 ' ..
217 KSPIN LOCK CllentWorkerListSpinLOCk;

219 . ... . .. s"~t~

221 LIST_ENTRY ClientiiorkerListEntry;.

223 _ ~_~~~ _ 225 'ray - '~ "~. x , 226 ' ~ . ~.._, ray s,tse:~ ~x«,.r~...,u~u. ,tee ~fiTA28f1E~H~ ~ Ril6Y/f911~i1~911d6~11ti~tiH°.~2.K'i 229 _'...,~".g 231 ICSEMAPHORE ServerWorkerRequestSemaphore;

233 ~ ~ c"~~, _.

235 KSPIN LOCK ServerWOrkerl.istSpinLock;

237 Y .. ~ e~.~

239 LIST ENTRY ServerWorkerListEntry:

241 UCHAR SMNMaCAddress[HARDWARE ADDRESS LENGTH]:

za2 244 ~ _ r, 246 NDIS REQUEST Request;
9:04 am Thurssday. 30 September 1 999 File: D:\nt4DDIC\src\timesn\tnsdrvr\tns.h Page 4 of 11 247 PULONG HytesNeeded;
248 PULONG BytesReadOrWritten;
249 BOOLEAN LocalRequest;

252 PVOID TNSSharedMemoryPtr;
253 ULONG TNSSharedMemorySize;

255 define VIRTUAL MEMORY 1 256 Ndefine NONPAGED_MEMORY 2 258 int TNSMemoryType:

260 ULONG TNSCIIentNodeID;

262 SMNNodeTable TeamNodeTable(MAX TEAM_NODES];

264 STATISTICS MyStats;
265 MPSTATS mpStats;

267 KSPIN_LOCK MyStatsLock;

269 unsigned char LocalComputerName(MAX COMPUTER NAME_SIZE]:

271 unsigned char SMNMachineName[16];

273 ) ADAPTER, 'PADAPTER;

275 9define MAX_READWRITE BUFFER SIZE 1024 28 0 1~~I~~a?F""~° .

282 9define NdisRequestLOCalSetInfo NdisRequestGenericl 283 bdefine NdisRequestLOCalQueryinfo NdisRequestGeneric2 297 __ 298 PNDIS PACKET OriglnalPacket;
299 PNDIS_HUFFER LookaheadHuffer;
300 int SMNEmulationPacket;
301 ) TNS PACtCEI'-CONTEXT, 'PTNS PACKET CONTEXT;

303 Ndefine PACtCET_CONTEXT FROM PACKET( pkt ) ((PTNS PACKET CONTEXT)(( pkt)->ProtocolReserved)) 306 (define MEDIA INf'O_SIZE (sizeof( MEDIA SPECIFIC_INFORMATION ) + sizeof( ULONG )) 319 typedef struct BUFFER CONTEXT
320 SINGLE LIST ENTRY SListEntry;
321 PNDIS BUFFER Ndis8uffer;
322 ) BUFFER CONTEXT. 'PHUFFER_CONTEXT:

325 i 328 typedef struct CONFIG DATA ( Pn.r.a by c~s~.~.~~ 9:04 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tns.h Page 5 of 71 329 ULONG PacketPOOlSize:
330 ULONG DebugLevel:
331 ULONG DebugMask:
332 ULONG TNSSMNEmulationMode:
333 j CONFIG DATA, 'PCONFIG DATA;

335 ~y _ 336 ~~~~~ g &~"~;~FErspr.~3og ~'es 337 y~: ..

339 $define TNS_ERROR_MISSING OID 0x00010000 340 $define TNS_ERROR BAD REGISTRY DATA 0x00020000 341 $define TNS_ERROR CANT INITIALIZE_IMSAMP_DEVICE 0x00040000 342 $define TNS ERROR PACKET 0x00060000 343 $define TNS ERROR PACKET POOL 0x00070000 344 $define TNS_ERROR_LOOKAHEAD_POOL 0x00080000 345 $define TNS_ERROR VM LOOKAHEAD_BUFFER 0x00090000 346 $define TNS ERROR LOOKAHEAD BUFFER Ox000A0000 347 $define TNS ERROR RESIDUAL POOL Ox000H0000 348 $define TNS ERAOR_VM RESIDUAL BUFFER Ox000C0000 349 $define TNS_ERROR RESIDUAL_BUFFER Ox000D0000 350 $define TNS_ERROR_PROTOCOL_INIT OXOOOF0000 352 ac~~x:~Dt 354 $define TNS_ERROR_INVALID_IMSAMP_MP_INSTANCE 0x00000004 3 5 6 i!:x:
357 ~J;~.''c~'",'.e'~.~'x~e'~i~$'C~1SC~~
358 Eli 359 extern ULONG TNSSharedMemoryNodeEmulation:

361 extern LIST ENTRY AdapterList:
362 extern NDIS SPIN LOCK AdapterListLock:
363 extern NDIS HANDLE ClientProtocolHandle:
364 extern NDIS HANDLE MPWrapperHandle;
365 extern NDIS HANDLE LMDriverHandle:
366 extern PDRIVER OBJECT IMDriverObject:
367 extern PDEVICE OBJECT IMDevice0bject:

369 extern CONFIG DATA ConfigData; "~F~~~~' 371 extern NDIS STRING IMSymbolicName:
372 extern NDIS STRING'IMDriverName:
373 extern NDIS_STRING IMMPName:

377 MPSendPackets( 378 IN NDIS HANDLE MiniportAdapterContext, 379 IN PPNDIS PACKET PacketArray, 380 IN UINT -- NumberOfPacketsl:

383 CLSendComplete( 384 IN NDIS_HANDLE ProtocolHindingContext, 385 IN PNDIS_PACKET Packet, 386 IN NDIS_STATUS Status):

389 PacketCompletion( 390 IN PADAPTER Adapter, 391 IN PNDIS PACKET Packet, 392 IN NDIS_STATUS Status):

395 CLReceivePacket( 396 IN NDIS_HANDLE ProtocolBindingContext, 397 IN PNDIS_PACKET Packet):

400 MPReturnPacket( 401 IN NDIS HANDLE MiniportAdapterCOntext, 402 IN PNDIS_PACKET Packet):

405 CLReceiveIndication( 406 IN NDIS HANDLE ProtocalHindingCOntext, 407 IN NDIS HANDLE MacReceiveContext, 408 IN PVOID HeaderHuffer, 409 IN DINT HeaderHufferSize, 410 IN PVOID LookAheadBuffer, 9:04 am Thursday. 30 September 1999 File: D:\nt4DDIC\src\timesn\tnsdrvr\tns.h Page 6 of 11 911IN DINT LookaheadBufferSize, 412IN DINT PacketSize):

415CLReceiveComplete( 416IN NDIS_HANDLE ProtocolBindingContext):

418NDIS_STATUS

419MPTransferData( 420OUT PNDIS_PACKET Packet, 921OUT PUINT BytesTransferred, 922IN NDIS HANDLE MiniportAdapterContext, 423IN NDIS HANDLE MiniportReceiveContext, 924IN UINT HyteOffset, 425IN DINT BytesToTransfer):

428CLTransferDataComplete( 929IN NDIS HANDLE Protocol8indingContext, 930PACKET pNdisPacket, IN PNDIS

431_ IN NDIS STATUS Status, 432IN DINT HytesTransferred):

435HindToLoaerMP( 436OUT PNDIS_STATUS Status, 437IN NDIS HANDLE HindContext, 438IN PNDIS STRING MPDeviceName, 439IN PVOID SystemSpecificl, 440IN PVOID SystemSpecific2):

443LowerMPOpenAdapterComplete( 444IN NDIS_HANDLE ProtocolHindingContext, 445IN NDIS STATUS Status, 446IN NDIS_STATUS OpenErrorStatus):

449MPInitialize( 450OUT PNDIS STATUS OpenErrorStatus, 451OUT PUINT SelectedMediumIndex, 452IN PNDIS_MEDIUM MediumArray, 453IN DINT MediumArraySize, 454IN NDIS HANDLE MiniportAdapterHandle, 455HANDLE WrapperConfigurationContext):
IN NDIS

456_ 458FindAdapterHyName( 459PfiCHAR AdapterName):

462UnbindFromLoverMP( 463OUT PNDIS STATUS Status, 464HANDLE ProtocolBindingContext, IN NDIS

465_ UnbindContext):
IN NDIS_HANDLE

468DerefAdapter( 969PADAPTER Adapter):

972CleanupAdapter( 473PADAPTER Adapter):

476LoverMPCloseAdapterComplete( 477IN NDIS_HANDLE ProtocolBindingContext, 478IN NDIS_STATUS Status):

481CLUnloadProtocol( 482VOID):

485MPHalt( 486IN NDIS_HANDLE MiniportAdapterContext);

989MPReset( 490OUT PBOOLEAN AddressingReset, 491IN NDIS_HANDLE MiniportAdapterContext):

vn~,ew ey cwaP Ve2~. 9:04 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tns.h Page 7 of y 7 494 NDIS_STATUS
495 MPQueryInformation( 496 IN NDIS_HANDLE MiniportAdapterContext, 497 IN NDIS OID Oid, 498 IN PVOID InformationBuffer, 499 IN ULONG Information8ufferLength, 500 OUT PULONG BytesWritten, 501 OUT PULONG BytesNeeded):

504 MPSetInfozmation( 505 IN NDIS HANDLE MiniportAdapterContext, 506 IN NDIS OID Oid, 507 IN PVOID Information8uffer, 508 IN ULONG InformationHufferLength, 509 OUT PULONG HytesRead, 510 OUT PULONG HytesNeeded):

513 CLRequestComplete( 514 IN NDIS_HANDLE ProtocolBindingContext, 515 IN PNDIS REQUEST NdisRequestHUf, 516 IN NDIS_STATUS Status);

519 MakeLOCalNdisRequest( 520 PADAPTER Adapter, 521 NDIS OID Oid, 522 PVOID Buffer, 523 ULONG BufferSize):

526 MakeLocalNdisRequestSet( 527 PADAPTER Adapter, 528 NDIS OID Oid, 529 PVOID Buffer, 530 ULONG BufferSize);

532 , 534 WDMInitialize( 535 PDRIVER OBJECT DriverObject, 536 PULONG InitShutdownMask):

539 WDMCleanup( 540 ULONG ShutdownMask);

543 ConfigureDriver 544 IN PUNICODE_STRING RegistryPath, 545 IN PCONFIG_DATA ConfigurationInfo):

548 CLStatusIndication( 549 IN NDIS_HANDLE ProtocolBindingContext, 550 IN NDIS STATUS GeneralStatus, 551 IN PVOID StatusHuffer, 552 IN UINT StatusHufferSize):

555 CLStatusIndicationComplete( 556 IN NDIS HANDLE HindingContext):

559 CLResetComplete( 560 IN NDIS HANDLE ProtocolBindingContext, 561 IN NDIS_STATUS Status):

565 TNSClientworkerThreadIPVOID Context):

568 TNSServerWOrkerThread(PVOID Context):

571 ._, .,.. .~~.3..~5~~=

574 ~define RF'CTYPELEN HEUI Ox80d5 vn.,e.aer~eP~e.a-~~ 9:04 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tns.h Page 8 of 11 575 1ldefine RFCTYPELEN IPX 0x8137 576 Ndefine RFCTYPELEN IP 0x800 577 pdefine RFCTYPELEN ARP 0x806 578 Ndefine RFCTYPELEN APPLE Ox80F3 579 $define RFCTYPELEN XNS 0x600 580 Ndefine RFCTYPELEN_RASAUTH OxBfff 582 Ndefine TNS_EMULATION ETHERTYPE Oxc001 '%~):~suppbBeCIlto°=be,COOl, 583 1ldefine MIN_MTU_PADDING_SIZE 69 5a5 !'/:
586 i/J~ Thes~fare af~~'TNS "~13~i~t to anrl ,~mii tp-client 'cammand!,' 587 /./ Or~~~packet type~!~indicators:~. ,.
588 ;<-Y;
589 enum 590 TNS HELLO BROADCAST=1, 591 TNS_HELLO_REPLY, 592 TNS_HELLO GOINGDOWN, //.High psi.viisty broadcastypacket 593 TNS_READ_REQUEST, 594 TNS READ REPLY, 595 TNS_STRING_READ_REQUEST, 596 TNS_STRING_READ_REPLY, 597 TNS_WRITE_REQUEST, 598 TNS WRITE ACK, 599 TNS_STRING_WRITE_REQUEST, 600 TNS_STRING_WRITE_ACK, 601 TNS_ACQUIRE_LOCK_REQUEST, 602 TNS RELEASE LOCK REQUEST, 603 TNS_RELEASE_LOCK ACK, 609 TNS_ALLOCATE_LOCK_REQUEST, 605 TNS_ALLOCATE LOCK REPLY, 606 TNS DOORHELL_REQUEST, 607 TNS_DOORBELL NOTIFICATION, 608 TNS_DOORBELL_NOTIFICATION_ACK, 609 TNS_ATOMIC_COMPLEX_ALLOCATE_REQUEST, 610 TNS ATOMIC_COMPLEX_ALLOCATE_REPLY, 611 TNS_ATOMIC_COMPLEX_READ_REQUEST, 612 TNS ATOMIC COMPLEX_READ REPLY, 613 TNS ATOMIC_COMPLEX_WRITE REQUEST, 619 TNS_ATOMIC_COMPLEX_WRITE_REPLY, 615 TNS_INTERLOCKED ENQUEUE, 616 TNS INTERLOCKED DEQUEUE, 617 TNS READ_MONOTONIC COUNTER REQUEST, 618 TNS_READ_MONOTONIC_COUNTER_REPLY, 619 TNS QUERY STATS, 620 TNS QUERY STATS REPLY, 621 TNS_QUERY_NODE_INFO, 622 TNS QUERY NODE INFO_REPLY, 623 TNS CLEAR STATS, 624 }; - _ 626 typedef struct _TNSPacketHeader 627 unsigned char MACDstAddress[ETH ADDRESS LEN]:
628 unsigned char MACSrcAddress[ETH ADDRESS LEN];
629 unsigned short MACEtherType;
630 unsigned short TNSCo~nandReply:

632 ] TNSPacketHeader, 'PTNSPacketHeader;

634 typedef struct _TNSPacketHelloHroadcast 635 unsigned char MACDstAddress[ETH ADDRESS LEN]:
636 unsigned char MACSrcAddress[ETH ADDRESS LEN];
637 unsigned short MACEtherType:
638 unsigned short TNSCommandReply;

640 unsigned long RequestTag;
691 LARGE INTEGER RequestStartTSC;
642 unsigned char ClientMacAddress[HARDWARE ADDRESS_LENGTH];
693 unsigned char ClIentMachineName[MAX_COMPUTER NAME SIZE];

645 ) TNSPacketHelloBroadcast, 'PTNSPacketHelloBroadcast;

698 typedef struct TNSPacketHelloReply [
649 unsigned char MACDStP.ddress[ETH ADDRESS LEN]:
650 unsigned char MACSrcAddress[ETH ADDRESS LEN]:
651 unsigned short MACEtherType;
652 unsigned short TNSCommandReply;

654 unsigned long RequestTag;
655 unsigned char SMNServerMacAddress[HARDWARE ADDRESS LENGTH];
656 ULONG TNSClientNodeID;
v.r~ew by cFUSP.~s.z.,. 9:04 am Thursday, 30 September 1 999 File: D:\nt4DDK\src\timesn\tnsdrvr\tns.h Page 9 of y 1 657ULONG TNSSharedMemorySize;

658INTEGER RequestStartTSC;
LARGE

659_ SMNMachineNameSize;
ULONG

660unsigned SMNMachineName[MAX
char COMPUTER NAME
SIZE];

662} TNSPacketHelloReply, *PTNSPacketHelloReply;

665typedef struct _TNSPacketReadRequest 666unsigned MACDstAddress[ETHLEN]:
char ADDRESS

667unsigned MACSrcAddress[ETHLEN];
char ADDRESS

668unsigned MACEtherType;
short 669unsigned TNSCommandReply;
short 671unsigned RequestTag;
long 672unsigned RequestWidth;
long 673unsigned RequestLength;
long 674ULONG RequestOffset;

675LARGE_INTEGERRequestStartTSC;

677) TNSPacketReadRequest, *PTNSPacketReadRequest;

680typedef struct TNSPacketReadReply 681unsigned MACDStAddress[ETHLEN]:
char ADDRESS

682unsigned MACSrcAddress[ETHLEN]:
char ADDRESS

683unsigned MACEtherType;
short 684unsigned TNSCommandReply;
short 686unsigned RequestTag;
long 687unsigned RequestLength;
long 688INTEGER RequestStartTSC;
LARGE

689_ dwData:
ULONG

691} TNSPacketReadRep1y, *PTNSPacketReadReply;

693TNSPacketWriteRequest ( typedef struct 694_ MACDstAddress[ETHLEN]:
unsigned ADDRESS
char 695unsigned MACSrcAddress[ETHLEN]:
char ADDRESS

696unsigned MACEtherType;
short 697unsigned TNSCommandReply;
short 699unsigned RequestTag:
long 700unsigned RequestWidth;
long 701unsigned RequestLength;
long 702ULONG RequestOffset;

703ULONG dwData:

704USHORT wData;

705UCHAR bData:

706LARGE_INTEGERRequestStartTSC;

708) TNSPacketWriteRequest, *PTNSPacketWriteRequest;

711typedef SPacketwriteReply struct t TN

712unsigned MACDstAddress(ETHLEN];
char ADDRESS

713unsigned MACSrcAddress[ETHLEN]:
char ADDRESS

714unsigned MACEtherType;
short 715unsigned TNSCommandReply:
short 717unsigned RequestTag;
long 718unsigned RequestWidth;
long 719unsigned RequestLength;
long 720ULONG RequestOffset:

721ULONG dwData;

722USHORT wData;

723UCHAR bData:

724LARGE INTEGERRequestStartTSC;

726) TNSPacketWriteReply, *PTNSPacketWriteReply;

729typedef struct TNSPacketOueryStats 730unsigned MACDStAddress(ETH_ADDRESS_LEN]:
char 731unsigned MACSrcAddress[ETH-LEN];
char ADDRESS

732unsigned MACEtherType;
short 733unsigned TNSCommandReply:
short 735unsigned RequestTag;
long 736LARGE_INTEGERRequestStartTSC;

738) TNSPacketQueryStats, *PTNSPacketQueryStats;

Prirpvd by GFIl6P ~.2. t v 9:04 am Thursday, 30 September t 999 File: D:\nt4DDK\src\timesn\tnsdrvr\tns.h Page 10 of 11 740 typedef struct TNSPacketQueryStatsReply ( 741 unsigned char MACDStAddress(ETH ADDRESS LEN];
742 unsigned char MACSrcAddress[ETH ADDRESS_LEN];
743 unsigned short MACEtherType;
744 unsigned short TNSCommandReply;

746 unsigned long RequestTag;
747 LARGE_INTEGER RequestStartTSC;
748 MPSTATS MpStats;
749 NDIS STATUS NdisStatus;
750 STATISTICS TnsNOdeStatistics;

752 } TNSPacketQueryStatsReply, *PTNSPacketQueryStatsReply;

755 typedef struct _TNSPacketQueryNodeinfo ( 756 unsigned char MACDstAddress[ETH ADDRESS LEN];
757 unsigned char MACSrcAddress[ETH ADDRESS LEN];
758 unsigned short MACEtherType;
759 unsigned short TNSCommandReply;

761 unsigned long RequestTag;
762 LARGE INTEGER RequestStartTSC;
763 unsigned long ClientNodeID;

765 ) TNSPacketQueryNOdeInfo, *PTNSPacketQueryNodeInfo;

767 typedef struct _TNSPacketQueryNodeInfoReply ( 768 unsigned char MACDstAddress[ETH ADDRESS LEN];
769 unsigned char MACSrcAddress(ETH ADDRESS_LEN];
770 unsigned short MACEtherType;
771 unsigned short TNSCommandReply;

773 unsigned long RequestTag:
779 LARGE INTEGER RequestStartTSC;

781 unsigned long ClientNOdeID;
782 unsigned char ClientNOdeMACAddress[HARDWARE ADDRESS LENGTH];
783 unsigned char CllentNOdeComputerName[MAX_COMPUTER NAME SIZE];

785 ) TNSPacketQueryNOdeInfoReply, *PTNSPacketQueryNOdeInfoReply;

787 typedef struct TNSPacketClearStats ( 788 unsigned char MACDstAddress[ETH ADDRESS_LEN];
789 unsigned char MACSrcAddress[ETH ADDRESS LEN];
790 unsigned short MACEtherType;
791 unsigned short TNSCommandReply;

793 unsigned long RequestTag:
799 LARGE_INTEGER RequestStartTSC;
795 ] TNSPacketClearStats, *PTNSPacketClearStats;

797 Ndefine TNS PACKET SIZE(x) ( (sizeof(struct (iNx) <= 60) ? 60 :
sizeof(struct N(fx) ) 798 - _ _ _ 799 typedef struct REQUEST DATA ( B00 ULONG requestOpcode;
801 LIST ENTRY Linkage;
802 unsigned char TnsPacket(2000];
803 PNDIS_PACKET pNdisPacket;
804 ) REQUEST DATA, 'PREQUEST DATA:

806 void 807 TNSHuildHroadcastReplyAndSend( 808 PADAPTER pAdapter, 809 PVOID pTnsPacket, 810 unsigned char *pHeader);

812 unsigned long 813 TNSGetSharedMemoryNodeNodeID( B14 PADAPTER pAdapter, 815 unsigned char *pHeader);

818 TnsDumpTnsPacket( 819 PUCHAR pucHuffer, 820 ULONG bufLength);
~'~~°~'~SP"~s-'~ 9:04 am Thursday. 30 September 1999 File: D:\nt4DDK\src\tlmesn\tnsdrvr\tns.h Page y y of 11 ezl 825 ZwAllocateVirtualMemory( 826 IN HANDLE ProcessHandle, 827 IN OUT PVOID 'HaseAddress, 828 IN ULONG ZeroBits, 829 IN OUT PULONG RegionSize, 830 IN ULONG AllocationType, 831 IN ULONG Protect):

836 ZwYieldExecution(VOID):

841 ZwFreeVirtualMemory( 842 IN HANDLE ProcessHandle, 843 IN PVOID *HaseAddress, 849 IN PULONG RegionSize, 845 IN ULONG FreeType):

848 TNSSendPackets( 899 IN NDIS HANDLE NdisBindingHandle, 850 IN PPNDIS_PACKET PacketArray, 851 IN UINT NumberOfPackets):

854 TNSInitializeClientNodeSendPacket( 855 IN PADAPTER . pAdapter, 856 IN OUT PNDIS_PACKET *ppNdisPacket, 857 IN OUT PVOID 'ppTnsHuffer, 858 IN ULONG PacketLength);

860 NDIS_STATUS
861 TnsGetNICStats( 862 PADAPTER pAdapter, 863 pMPSTATS pMpStats):

865 int 866 sprintf(char 's, const char *format, ...);

868 volD
869 TnsIncrementStat( 870 PADAPTER pAdapter, 871 PLARGE_INTEGER pLi);

879 TnsAddStatsUlong( 875 PADAPTER pAdapter, 876 PLARGE INTEGER pLi, 877 ULONG Added):

879 void 880 GetProcessorSpeed( 881 PADAPTER pAdapter):

eae ea9 ~r 890 ~~~SS89~_'~'~~'~p~7~G~bTEKED
891 ~!/:
892 ~/~"s~sa9!~~.:z 893 ;~a7 894 srf a2Y.~~~2 ~9" tl~~rmed3~8L~ M3~t~; oxt .,~ .~~.um.~ P,. ~.w_.
895 ~I~:
896 (fdefine TNS_EVENT_MINIPORT_REGISTER_FAILED ((NTSTATUS)OxC0080002L) 898 Nendif ~.~~1 ~~~er~~sP~~2~'~ 9:04 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsdebug.c Page y of 8 !<!'Desciip~ion;
21 %%:
22 !! 8nvironment 23 J/ ~~a, ~ ,~i-ndCws NTaICernelz~Mode~.. Ndis dzi-ver Models:.:
24 /,/:.
J/ ~aports 26 /l ;. . _Seap~,i~lodn~e,~functaons ,generated bye script pxocessiag';
27 //: ~~ _. ._ . :.: , . .. ..
28 Y./.~JUiitiar:
29 J/ ~r~ Mince Hr~cig~r's /1 : ,~ vi~aceb@tamesn coal 32 /l ., 3 arid:aixsaa3tiy~H:aatr~w,r-***++sbi**~~.rr~r.taa****rst**r**.t+fsW
ws*tayi.r~s~*:~*y.w.*ia:s.s.
3 ll;;~. _y°",:.~:~.,~"._:.,~,_..:m.~...~_....~,.M.~,..a_._..
._~.,:.,..,~.. ~,, .~.... ~ b~.~..". ._.,> . ,._ x.<.__...,_. ~.. :<...~.~.."-.~.=

Ainclude <stdarg.h>
36 Ninclude <stdio.h>
37 Ninclude <ndis.h>
38 Ninclude ~tnsdebug.h~
39 Ainclude "x86. h"
41 !./ ~--~ ~' ~ _.~-42 ,/,! Defi~ie ttie ~~wtd ~'far,..LhE~et~YClden tunad~umented ~~whaievet'~
HAL funeLlon 4 3 ~L~ 'tcfFmalce~~ beep' 44 // '~ ~- _ _ ...~. ",~,,,~~, .r ~.~ » .._...-.
9s 48 HalMakeBeep(ULONG Freq):

51 (lifdef DBG

53 ULONG _gDebugPrintLevel = 0; ~I .acj t:o~con~zp"l~,debug ovpput .xer"'bosity, 59 ULONG gDebugPrintMask = DESUG_MASKEN_INIT : l/ stag to control debttgroiitpllt aterlaosity ULONG gDebugBreakFlag = TRUE; Y/;~1~9 to~cDiyroh.l~.~r~ execute ~g:Greaks 57 J~'",~"~,r~r*iir*vr*~a~r~*st+.~:~-ir***-****r*=r*'i*+w****rr*er,1.t,*','i.Ft**st*ir.*a*i'~aa*~**f.ri~*.*,ri;~i' .
._."e z.~c";.-~~c<,>..s.m .aa.- _... . ...._~ , .-~;..... ..nara x~.cae,.«,.~.> ,~.,~-,.a~.><" s <.. s,..p v. 2a -.. - , vv.. , M a. .e ;~
s.d.,u..~.a.~s.
58 girl:+..~
59 char GetNDISOidString( 61 NDIS OID NdisOID, /l 'iNPEi~ jNBIS DID ftD aeoaVert~o-'str.~ag 62 PULONG pFoundFlag) //~~ED2,e~~Flag, setD TRUE ~f ~Citindr ~ y~.f.~stc~t=.

69 lrl:

76 int i:

78 typedef struct NDISOidTable( 79 NDIS OID NdisOID:
BO char *OidString;
81 ) NDISOidTable, *pNDISOidTable;

~~br~~sP~~z~~~ 9:03 am Thursday, 30 September 1999 Fil~: D:\nt4DDK\src\timesn\tnsdrvr\tnsdebug.c Page 2 of 8 83 static NDISOidTable NDISOidStringTable(]
_ 89 { OID ADDRESS , "OID 802 3 PERMANENT ADDRESS~, }, 85 { OID _ 802 3 CURRENT ADDRESS , "OID 802_3 CURRENT_ADDRESS", ).

86 { OID 802 3 MULTICAST LIST , ~OID 802 3 MULTICAST LIST~, ), 87 [ OID _ SIZE . "OID 802 3 MAXIMUM LIST SIZE~, ), MAXIMUM
LIST

88 _ _ [ OID _ _ _ 802 3 MAC OPTIONS "OID 802 3 MAC OPTIONS", ), 89 ( OID GEN SUPPORTED LIST, ~OID GEN SUPPORTED_LIST", ), 90 ( OID LIST, "OID GEN SUPPORTED_LIST~, }, GEN SUPPORTED

91 ( OID_ _ GEN HARDWARE STATUS, "OID GEN HARDWARE STATUS", ).

92 ( OID_ SUPPORTED, ~OID GEN MEDIA SUPPORTED", ), GEN_MEDIA

93 ( OID _ IN USE, "OID GEN MEDIA IN USE ~ }, GEN MEDIA

99 ( OID _ GEN MAXIMUM_LOOKAHEAD, "OID GEN MAXIMUM_LOOKAHEAD
" 1, 95 { OID SIZE, "OID GEN MAXIMUM_FRAME SIZE ", ), GEN MAXIMUM FRAME

96 ( OID _ SPEED, "OID GEN LINK SPEED " }, GEN
LINK

97 _ _ ( OID _ SPACE, "OID GEN_TRANSMIT_BUFFER SPACE ~, ), GEN TRANSMIT BUFFER

98 ( OID _ GEN RECEIVE BUFFER SPACE, "OID GEN_RECEIVE BUFFER
SPACE " ), 99 ( OID GEN TRANSMIT BLOCK_SIZE, "OID GEN TRANSMIT_HLOCK_SIZE

100 [ OID SIZE. "OID GEN RECEIVE BLOCK SIZE ~, }, GEN RECEIVE
BLOCK

101 _ _ ( OID _ GEN
ID, ~OID GEN VENDOR ID ~ ), VENDOR

102 _ _ { OID _ VENDOR DESCRIPTION, "OID GEN VENDOR DESCRIPTION
~ }, GEN

103 { OID _ GEN CURRENT PACKET FILTER, "OID GEN CURRENT PACKET_FILTER
", }, 104 { OID_ GEN CURRENT_LOOKAHEAD, "OID GEN CURRENT LOOKAHEAD
", ), 105 [ OID GEN DRIVER VERSION, "OID GEN DRIVER VERSION " ), 106 ( OID GEN MAXIMUM TOTAL_SIZE, "OID GEN MAXIMUM TOTAL_SIZE
", ), 107 [ OID GEN PROTOCOL OPTIONS, "OID GEN PROTOCOL_OPTIONS
", }, 108 ( OID GEN MAC OPTIONS, "OID GEN MAC OPTIONS " ), , 109 ( OID_ CONNECT_STATUS ~ }, GEN MEDIA CONNECT_STATUS, "OID GEN MEDIA

110 ( OID PACKETS, "OID GEN MAXIMUM SEND PACKETS " ), GEN
MAXIMUM
SEND

111 _ _ ( OID_ _ _ GEN VENDOR DRIVER VERSION, "OID GEN_VENDOR DRIVER
VERSION ~, ], 112 ( OID GEN_XMIT OK, "OID GEN XMIT OK " }, ~

113 ( OID_ GEN RCV OK, "OID GEN RCV OK ~
}, I

119 { OID ERROR ~, }, GEN XMIT ERROR, "OID GEN XMIT

115 { OID_ GEN_RCV_ERROR, "OID GEN RCV ERROR ~ }, 116 { OID HUFFER, ~OID GEN RCV NO BUFFER " }, GEN RCV NO

117 { OID _ XMIT, "OID GEN DIRECTED HYTES_XMIT " }, GEN DIRECTED BYTES

118 [ OID _ FRAMES_XMIT, "OID GEN DIRECTED FRAMES XMIT " }, GEN_DIRECTED

119 _ _ { OID GEN MULTICAST BYTES XMIT, ~OID GEN MULTICAST BYTES
XMIT ~ }, 120 { OID XMIT, "OID GEN MULTICAST FRAMES XMIT ", 1.
GEN MULTICAST FRAMES

121 [ OID _ XMIT, "OID GEN BROADCAST BYTES XMIT ", }, HROADCAST
BYTES
GEN

122 _ _ { OID _ _ GEN BROADCAST FRAMES XMIT, ~OID GEN BROADCAST FRAMES_XMIT
~, }, 123 ( OID GEN DIRECTED BYTES RCV, "OID GEN DIRECTED BYTES_RCV
~ ), 124 { OID DIRECTED FRAMES RCV, ~OID GEN DIRECTED FRAMES_RCV
" ), GEN

125 [ OID _ GEN_MULTICAST BYTES RCV, "OID GEN MULTICAST_BYTES
RCV " ), 126 [ OID_ GEN MULTICAST FRAMES RCV, "OID GEN MULTICAST FRAMES
RCV " ).

127 [ OID BYTES RCV, "OID GEN_BROADCAST_BYTES RCV
GEN
BROADCAST

128 _ _ [ OID _ FRAMES RCV, "OID GEN BROADCAST FRAMES RCV ~, }, GEN
BROADCAST
-129 _ _ [ OID _ GEN RCV
CRC ERROR, ~OID GEN RCV CRC ERROR " ), 130 _ GEN TRANSMIT QUEUE LENGTH, "OID GEN TRANSMIT QUEUE
( OID LENGTH ", ), 131 };

(sizeof NDISOidStringTable / sizeof(struct NDISOidTable)) #define NUM_NDIS_OID_STRING

133 _ 134 #define NDIS_OID_NOT_FOUND_STR
"NDIS
OID Code Not Found"

136 'pFoundFlag = FALSE;

137 for (i=0:i<NUM NDIS OID STRING_ENTRIES: i++) {

138 if (NdisOID
== NDISOidStringTable[i].NdisOID) {

139 'pFoundFlag = TRUE:

140 return NDISOidStringTable(1].OidSt'ring:

141 ) 192 }

143 BreakPoint();

149 return NDIS_OID_NOT_FOUND_STR:

145 }

'.*'s:iis~.~:;it"a.;ts"su.acf~~k'stsa:aaa~i:~,W
197 yr';t;6"lr':~~*iyirstaf*t~**r*sa.~~st..,t.r.,ve*ar~s~+.nt.vui*sw*W
:atxa#
ir. ~
.~~ ~~
. ,.~
-- _ _. dr..
... ~
~u_..._.._ :;~._m._.
~. ..~_~;:~ri~~<A~:M.
..r .
. ..
_ . .~.~:~.:,~...~.~s:
_.. _ _.. .
_.. ~..

14B JI .

149 char 150 GetNDISStatusString( Status, fY~'NDfS.Staus-o convert to srtag NDIS

152 _ PULONG
pFoundFlag) /:T~921,~'PqTflag,~ttrat,,says ~AUE"3 fQUnrl,:FAL,S
~ W of --_ .
,.

163 %:/-:.ttr.r~**i.tts*saa*sv."",,r,iw;t*r,rs*i~i.*E*a:rw~wr**y.rrira*~:+rsrt+i~sa~f*s r.~~.*,e****.rt**
. . ~. _.r : ---.. , w,.~, .., .. ":. ,~ . .. ..,., ~ ._ _ . ,r.. ,.~ ~. -.
P"~~~~°$P"°2~'~ 9:03 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsdebug.c Page 3 of 8 166 int 1;

168 l7 169 pct.ion onlyyH
this fn anitwtab3e wn tf~~a' scope o~
~/~la"~:e~structure'-def 170 ~ , ~ _ ; ;
'/7~iiot , mo3ale, scope;

171 I%-..

172 typedef struct NDISStatusTable{

STATUS
Status;

174 char 'StatusString;

175 ) NDISStatusTable, ;
'pNDISStatusTable 177 static ingTable[]
NDISStatusTable _ NDISStatusStr 178 ( NDIS STATUS SUCCESS. "NDISSTATUS_SUCCESS~, ), 179 / NDIS STATUS PENDING, "NDISSTATUS PENDING", }, 180 ( NDIS STATUS NOT RECOGNIZED,"NDISSTATUS NOT RECOGNIZED", }, 181 { NDIS STATUS_NOT COPIED,"NDISSTATUS NOT COPIED", }, 182 { NDIS STATUS_NOT ACCEPTED,"NDISSTATUS_NOT ACCEPTED~, }, 183 { NDIS CALL ACTIVE, "NDISSTATUS CALL ACTIVE~, STATUS }, 184 ( NDIS _ "NDISSTATUS ONLINE", }, STATUS
ONLINE, 185 [ NDIS _ "NDISSTATUS RESET START", RESET START, }, STATUS

186 _ _ "NDISSTATUS_RESET END", ), [ NDIS_STATUS_RESET_END, 187 ( NDIS STATUS "NDISSTATUS RING STATUS~, RING ), STATUS, 188 ( NDIS _ "NDISSTATUS_CLOSED~, ), _ STATUS CLOSED, 1B9 _ STATUS WAN LINE "NDISSTATUS_WAN_LINE UP", ( NDIS UP, }, 190 _ WAN ~NDISSTATUS WAN LINE DOWN", { NDIS DOWN, ).
STATUS
LINE

191 _ _ "NDISSTATUS WAN_FRAGMENT~, { NDIS _ ), _ STATUS_WAN_FRAGMENT, 192 ( NDIS STATUS MEDIA "NDISSTATUS_MEDIA CONNECT~, CONNECT, }, 193 _ MEDIA DISCONNECT,~NDISSTATUS MEDIA DISCONNECT~, ( NDIS STATUS }, 194 _ _ ~NDISSTATUS_HARDWARE LINEUP", ( NDIS HARDWARE }, LINE UP, STATUS

195 _ _ ( NDIS _ STATUS_HARDWARE_LINE_DOWN, "NDIS STATUS_HARDWARE_LINE_DOWN", }, 196 { NDIS STATUS INTERFACE_UP,"NDISSTATUS INTERFACE UP~, }, 197 _ INTERFACE_DOWN, ~NDISSTATUS_INTERFACE DOWN", { NDIS STATUS }, 198 _ _ "NDISSTATUS_MEDIA BUSY", }, { NDIS STATUS_MEDIA
BUSY, 199 { NDIS STATUS WW INDICATION,~NDISSTATUS WW INDICATION", ), 200 ( NDIS STATUS_LINK SPEED"NDISSTATUS LINK SPEED CHANGE~, CHANGE, }, 201 ( NDIS_STATUS_NOT_RESETTABLE,~NDISSTATUS NOT RESETTAHLE", 1, 202 L NDIS STATUS_SOFT_ERRORS,"NDISSTATUS SOFT ERRORS~, }, 203 _ STATUS HARD ERRORS,~NDISSTATUS_HARD ERRORS~, ( NDIS }, 204 { NDIS STATUS BUFFER "NDISSTATUS BUFFER OVERFLOW", OVERFLOW, 1, 205 / NDIS STATUS FAILURE, ~NDISSTATUS_FAILURE", ), 206 _ STATUS RESOURCES,"NDISSTATUS RESOURCES", ), { NDIS ' 207 _ STATUS_CLOSING, "NDISSTATUS CLOSING~. }, ( NDIS_ 208 { NDIS STATUS "NDISSTATUS HAD_VERSION", BAD VERSION, }.

209 _ _ { NDIS CHARACTERISTICS, ~NDIS_STATUS_BAD_CHARACTERISTICS~, }, STATUS
BAD

210 _ _ "NDIS
( NDIS__ STATUS
STATUS_ADAPTER ADAPTER
NOT_FOUND, NOT
FOUND~, }, 211 { NDIS_STATUS_OPEN_FAILED,~NDISSTATUS OPEN FAILED", ), 212 ( NDIS STATUS DEVICE "NDISSTATUS DEVICE_FAILED~, FAILED, ), 213 ( NDIS STATUS "NDISSTATUS_MULTICAST FULL~, MULTICAST FULL, ), 214 { NDIS _ "NDISSTATUS MULTICAST_EXISTS~, MULTICAST EXISTS, ), STATUS

215 { NDIS _ FOUND, "NDIS_STATUS_MULTICAST_NOT_FOUND~, }, NOT
STATUS
MULTICAST

216 _ _ "NDISSTATUS REQUEST ABORTED~, f NDIS _ ), _ STATUS REQUEST
ABORTED, 217 { NDIS_STATUS "NDIS
RESET IN PROGRESS,STATUS
RESET_IN_PROGRESS~, }, 218 { NDIS _ STATUS CLOSING
INDICATING, ~NDIS STATUS_CLOSING_INDICATING~, }, 219 [ NDIS _STATUS_NOT_SUPPORTED,"NDISSTATUS NOT SUPPORTED", ), 220 { NDIS INVALID ~NDISSTATUS INVALID PACKET~, STATUS ), PACKET, 221 ( NDIS _ "NDISSTATUS_OPEN LIST FULL~, _ }, _ STATUS OPEN_LIST_FULL, 222 { NDIS ADAPTER NOT READY,~NDIS
STATUS STATUS
ADAPTER
NOT_READY", }, 223 { NDIS _ "NDISSTATUS ADAPTER NOT OPEN", _ ), _STATUS_ADAPTER_NOT
OPEN, 224 { NDIS NOT "NDISSTATUS NOT_INDICATING", INDICATING, ), STATUS

225 { NDIS _ "NDISSTATUS INVALID LENGTH~, _ }, STATUS INVALID
LENGTH, 226 ( NDIS _ "NDISSTATUS INVALID DATA", _STATUS INVALID }, DATA, 227 ( NDIS BUFFER TOO SHORT,"NDISSTATUS_SUFFER T00_SHORT", STATUS ), 228 ( NDIS _ ~NDISSTATUS INVALID OID~, _STATUS_INVALID_OID, }, 229 { NDIS STATUS_ADAPTER_REMOVED,~NDISSTATUS ADAPTER_REMOVED~, ), 230 { NDIS _ "NDIS
UNSUPPORTED_MEDIA,STATUS_UNSUPPORTED_MEDIA~, STATUS ), 231 { NDIS _ _ _STATUS GROUP_ADDRESS
IN USE, "NDIS
STATUS GROUP
ADDRESS_IN USE~, ), 232 [ NDIS FILE NOT FOUND, ~NDISSTATUS FILE NOT_FOUND", STATUS ), 233 { NDIS _ _ ERROR READING
FILE, ~NDIS_STATUS_ERROR_READING_FILE", }, _STATUS

239 [ NDIS _ ~NDISSTATUS ALREADY MAPPED~, STATUS_ALREADY_MAPPED, ), 235 f NDIS STATUS_RESOURCE_CONFLICT,"NDIS_STATUS_RESOURCE_CONFLICT~, 1, 236 ( NDIS _STATUS NO CABLE,~NDISSTATUS NO_CAHLE", }, 237 ( NDIS _STATUS INVALID_SAP,~NDISSTATUS INVALID SAP", }, 238 ( NDIS _STATUS_SAP IN "NDISSTATUS SAP IN_USE~, }, USE, 239 { NDIS _STATUS_INVALID_ADDRESS,"NDISSTATUS INVALID ADDRESS~, l, 240 ( NDIS STATUS_VC_NOT_ACTIVATED,"NDISSTATUS_VC_NOT_ACTIVATED~, ), 241 ( NDIS _ STATUS DEST_OUT_OF_ORDER~, _STATUS_DEST_OUT ), OF_ORDER,"NDIS

242 { NDIS AVAILABLE, ~NDISSTATUS VC_NOT_AVAILABLE~, STATUS VC }, NOT

243 { NDIS _ "NDIS_STATUS_CELLRATE_NOT_AVAILABLE", _ ) _ _STATUS_CELLRATE_NOT_AVAILABLE, 299 { NDIS INCOMPATABLE_QOS,"NDISSTATUS INCOMPATAHLE QOS~, STATUS }, 295 [ NDIS _ AAL PARAMS UNSUPPORTED~, _ ) AAL PARAMS UNSUPPORTED, ~NDIS STATUS
STATUS

296 f NDIS _ _ STATUS-NO ROUTE , "NDIS STATUS NO ROUTE
TO DESTINATION TO DESTINATION", 9:03 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsdebug.c Page 4 of 8 247 ( NDIS STATUS TOKEN RING OPEN ERROR, "NDIS STATUS TOKEN RING OPEN ERROR~, ], 248 ]:

250 #define NUM NDIS STATUS STRING ENTRIES (sizeof NDISStatusStringTable /
sizeof(struct NDISStatusTable -2 )) - _ _ _ 251 #define NDIS STATUS NOT FOUND STR "NDIS Status Code Not Found"
252 - _ _ _ 253 'pFOUndFlag = FALSE:
254 for (i=0: i<NUM_NDIS STATUS_STRING ENTRIES; i++) ( 255 if (Status =a NDISStatusStringTable[i].Status) {
256 'pFoundFlag = TRUE:
257 return NDISStatusStringTable[i].StatusString;
258 ) 259 ]
260 BreakPoint();
261 return NDIS_STATUS_NOT_FOUND_STR:
262 ) ',!~i**art.*%!~i*iii~4**iii*i,1*il4iii'b*i**-~~4*.i~i***4'*i.f:P**~t~!~*4**~Ii** **~~,l~d*~Ir*~~
264 /I -: . <. .~..., rt<..u< ....,M<,...~.. .. ,... , ..< ..< .<."~-~, >,..
<,<., . ,~..~. .<., ..< . _ ~ .... .. .,.> . .... . . . ,~..~
265 17;
266 char 'GetNDISEventString( 267 NDIS ERROR CODE ErrorCode, IIINPfTf 'NDZS error code 268 PULONG pFoundFlag) !/ '.OUTPUT TRUE 31f.,.GOde:foiind :FAI:SE if ~iiot 269 J%

280 ~*a~*x*:~*w ":..... . ..

282 int 1:

284 l'~
285 1l Mace structuze..de!".and-table:vlthin ;acope_of:~ihis furiciion ortTy.~
286 /l not°~module~5cope~; ' .. _ - . .
287 %%
288 typedef struct NDISEventTable( 289 NDIS_ERROR CODE ErrorCode;
290 char 'ErrorCodeString;
291 } NDISEventTable, 'pNDISEventTable:

293 static NDISEventTable NDISEventStrinqTable[] _ ( 294 [ NDIS_ERROR_CODE_RESOURC~_CONFLICT, "NDIS_ERROR_CODE_RESOURCE_CONFLICT", ), 295 ( NDIS ERROR_CODE OUT OF RESOURCES, "NDIS ERROR CODE_OUT OF_RESOURCES". ).
296 ( NDIS_ERROR CODE_HARDWARE_FAILURE, ~NDIS ERROR CODE HARDWARE FAILURE", }, 297 ( NDIS_ERROR_CODE_ADAPTER_NOT_FOUND, "NDIS_ERROR_CODE_ADAPTER_NOT_FOUND", }, 298 { NDIS_ERROR CODE_INTERRUPT_CONNECT, "NDIS ERROR CODE_INTERRUPT CONNECT", }, 299 { NDIS ERROR_CODE DRIVER FAILURE, "NDIS ERROR CODE_DRIVER_FAILURE", ), 300 ( NDIS ERROR_CODE BAD VERSION, "NDIS ERROR CODE BAD VERSION~, }, 301 ( NDIS_ERROR_CODE_TIMEOUT, "NDIS ERROR CODE TIMEOUT~~, ), 302 ( NDIS ERROR CODE NETWORK ADDRESS, ~NDIS ERROR CODE NETWORK ADDRESS", }, 303 ( NDIS ERROR CODE UNSUPPORTED CONFIGURATION, "NDIS ERROR CODE UNSUPPORTED
CONFIGURATION~, ), 304 ( NDIS ERROR CODE INVALID VALUE_FROM ADAPTER, "NDIS ERROR CODE INVALID
VALUE_FROM_ADAPTER~, }, 305 ( NDIS ERROR CODE MISSING CONFIGURATION PARAMETER, "NDIS ERROR CODE
MISSING CONFIGURATION_PARAMET
-2 ER~, }, 306 { NDIS ERROR CODE SAD IO BASE ADDRESS, ~NDIS ERROR CODE BAD IO BASE
ADDRESS", ), 307 { NDIS ERROR CODE RECEIVE SPACE_SMALL, "NDIS ERROR CODE_RECEIVE
SPACE_SMALL", ], 308 ( NDIS ERROR CODe ADAPTER DISABLED, "NDIS ERROR CODE ADAPTER DISABLED~, ), 309 ]:

311 #define NUM NDIS EVENT STRING_ENTRIES (sizeof NDISEventStringTable /
sizeof(struct NDISEventTable)) 312 #define NDIS EVENT NOT FOUND STR "NDIS Event Code Not Found"
313 - _ _ _ 314 'pFoundFlag = FALSE:
315 for (i=0; i<NUM_NDIS_EVENT_STRING ENTRIES: i++) ( 316 if (ErrorCode ~- NDISEventStringTable[i].ErrorCode) 317 'pFoundFlag = TRUE;
318 return NDISEventStringTable[i].ErrorCodeString:
319 ) 320 }

322 return NDIS EVENT NOT FOUND STR:
323 ) 325 /l'".wx****i~**a»***s.*xx***.is****+~s*.*aix:.,.:*,r.*.~*,wi*****~
yr.~***+rerf**4*.~* ***fs~+*r*tw 326 /.~m~ .-~"",., ~...,._~ ~.A....,~...,. r...
~~M~u$P~-2~» 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\tfmesn\tnsdrvr\tnsdebug.c Page 5 of 8 328 DebugPrint( 329 ULONG DebugPrintLevel, '/y::TNPOT~>:Debnij':°p~at'Ieo'el 330 PCSZ DebugMessage, //, INEUT ~ P~tr ~to~faimatted"prin~;~stri~ng,;,~ala>piintf 331 ...) : _....

345 va_list ap;
346 va_start(ap, DebugMessage);
347 if ( (DebugPrintLevel <= gDebugPrintLevel) II (DebugPrintLevel == DEHUG
ERROR) ) ( 348 CHAR buffer[512];

350 (VOID) vsprintf(buffer, DebugMessage, ap);

352 DbgPrint(buffer):
353 if (DebugPrintLevel == DEBUG ERROR) t 359 if (~gDebugHreakFlag) 355 /1:
3 5 6 /X ~$us_ e_ ~anl~.3nL ~,3 ~e san ;hatch ~3t 'easier 357 !=l ~~
.
3 58 . Jay Bi'e2~c~oia~ ~ ~:
~_Am.9~M.A._......_ ~r~p:
359 _asm int 3 360 ) 361 }
362 ) 363 va_end(ap);
364 }

366 _ 367 [~~~"'~'x~r*akir°3rx*a~+wsrwrr*rrw.w**.*r*i~~~ar****rs~rs-***~4~r~t~ii,~,~~k.~*,r~ ~~rwsi~+~wi*,*irw.
~.m."~.,7,5,~,~,yres~.~"-zrc--.~r..~".a.~.w.%s,n~a.~..~.=.sxv_,.e~,r..s,s.":awza....unrnurr. -_,,.
,,~~,,.,,~:.,._~,~.u~.v~-.~:;~e , 370 MaskDebugPrint( 371 ULONG DebugPrintLevel, y_7a°~PUi' ;~h'~tg-~i°~r .~3:evel~''' ~ ~' 372 ULONG DebugPrintMask, /~ ~;Ds~apl.s~~s ~~'~'~u ~ ~
373 PCSZ DebugMessage, ~'"~°""' ~~t~mattie~tl~p~ ~i~~ Vila 4 ..,~r~. ~..'-v::~ ...,~. .
374 ...) 398 va list ap;
389 va_start(ap, DebugMessage);

391 if (DebugPrintMask 6 _gDebugPrintMask) 392 if ( (DebugPrintLevel <= gDebugPrintLevel) II (DebugPrintLevel == DEBUG
ERROR) ) 393 CHAR buffer[512];

395 (VOID) vsprintf(buffer, DebugMessage, ap);

397 DbgPrint(buffer):
398 if (DebugPrintLevel == DEBUG ERROR) 399 if ( gDebugHreakFlag) 4 O 1 i!%

402 i~,ll e'- ~~'9D"~'~~T~n dG~?'3t-t ~~:3i2i ._. . ~r~'~ ~'~.w'.~.''E!.-_..._~:................

4 04 ~I~,.9Hxe.., 405 _asm int 3 906 }
407 ) 408 ]
~~~~sP~~~~~ 9:03 am Thursday. 30 September 1999 File: D:\nt4DDK\src\tlmesn\tnsdrvr\tnsdebug.c Page 6 of 8 909 ) 411 va end(ap):
412 ) 414 *r'st***n.y;rwi.7.
ib+**~r.**a..~,*1,*******r*~r.*a.~i~v*~r.*,v*.i**********.***.*~**+:~i~n*
*r*ri*;ri s~
//. .,..,. " ,." ..~:. ,..,.a._.~.~, ,.: .. ., ~,~. .., ... r .~.y -..."
.......,.... .,..
.,.x.,.>. ..,... .... ~-.. _.... s ",.. , , ._,.,... . ,..... .
415 lv/:-+
416 void 417 TNSMakeBeep(void) 4 2 5 *'e'' 428 l'7 429 /:/,.;-Sca=t z~t~e:vtreep 430 ~-/
431 HalMakeHeep(900):
4 3 2 '/'/:
433 // Stall so theapeep ~s;,pe=ceptible 434 '/,./
43s I(eStallExecutionProcessor(1000 ' 100);
436 /L:
437 %J Stop .the: beep .by settiag:,the fi~quency;. to ~U

439 HelMakeBeep(0):
490 }

442 Ndefine NUMCLOCKSPEEDSAMPLES 100 949 typedef struct _ProcSpeedData 945 ULONG ProcSpeed;
446 ULONG Occurence;
947 ) ProcSpeedData, 'pProcSpeedData;

4s0 /l>**~""*"*"*~1~~*x*~x~i.r*~r*ss***iri~*-i**:;r*~**,r.r**:,t******»+*r*****~*****~*e:,vr.**,r*ir*t.*-i .. _.....:rs. Am_x...u:;:"_.::.~.....»... .._.._._. <.,. ......r...~~.... ,-..,. .....;.~.A:~. ..._.c..-....
9s1 ,~r-~

953 NdisDumpBuffer( 454 PUCHAR va6uffer, %~~IN~UT . Ptr °G,p coa~guons °va.~ual space 455 ULONG bufferLength) %1;~~",LangtL,nf,,sp<ace~tP~,;grtnt 470 ULONG i:

477 for (i=0; i<bufferLength; i++) ( 978 if (i%16) ( 979 D((0, "802x ", 'vaBuffer++));
480 ) else 481 D((0, ~\n8x : , vaHuffer));
482 D((0, "!02x ", 'vaBuffer++));
483 ) 484 ) 48s D((0, ~\n~));
986 ) /%'+,irs.c+*'s*.ri*~e***,*r*.****~t***sr*a.*rs*a*c*****t******x**r*.~r*ers:*a-**,r*s~**svav*.~*~
..,. . : ,.
. . ..._ - , rxa:. . ...,....... ,- . ,-<..,.. .. -.. - . ~...,..~,..~... _, .. .... . . ,.. ..,.~..e.....,.... ...". , ..., .,..~, ..a._ , 9 8 9 ./-!=+

9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsdebug.c Page 7 of 8 491 NdisDumpPacket( 492 PNDIS-PACKET Packet) J/ ~NPDT ND2S~PaCket, What: else;,?

506 UINT PhysBufferCount, BufferCOUnt, PacketLength:
507 PNDIS BUFFER FirstBuffer, NextBUffer:
508 PVOID va:
509 UINT bufferLength;
510 int i:

513 lT~et~;the packet~infasmatioi~'~ortbiscpacket=~nd,xlumP;*f.
519 /J- ... ._ 515 NdisQueryPacket(Packet, 6PhysBUfferCount, sBufferCount, bFirstBuffer, 6PacketLength):
516 DM((DEHUG MESSAGE, DEBUG MASKEN PACKETDUMP, "DumpPacket: Packet => %x, PhysBufferCount => %d, BufferC
-2 ount => %d, FirstBuffer => %x, PacketLength => %d\n", 517 Packet, 518 PhysBufferCount, 519 BufferCount, 520 FirstBuffer, 521 PacketLength));

524 %~tu~cti~i~l8 525 '"
l 526 NextBuffer = FirstBuffer;

528 ir.(j_ 529 ,lk~yf~~g..P~r~~~d lert~Lb.3n~otiap 530 ~~I
531 for (i=0: NextBuffer!=NULL: i++) 532 NdisQueryBuffer(NextHUffer, &va, 6bufferLength):

539 DM((DEHUG_MESSAGE, DEBUG_MASKEN_PACKETDUMP, "Buffer => %d, va => %x, bufferLength => %d\n~, i, va -2 , bufferLength));

537 ~~:~?n1 acket,coateats..~~ we ~s_a"~d "we sots:.of udeta~l . It_..-.~ ~H_..._._..~

539 if ( ( gDebugPrintMask b DEBUG MASKEN-PACKETDUMP) ~6 ( gDebugPrintLevel >=
DEBUG VERBOSE) ) {
540 D((0, "Buffer Contents =>\n")):
591 NdisDumpHuffer(va, bufferLength);
542 ) 544 NdisGetNextHuffer(NextBuffer, 6NextBuffer):
545 ) 546 ) 550 TnsDumpTnsPacketl 551 PUCHAR pucBuffer, 552 ULONG bufl,ength) 555 '%.~....~'.~~t-~aess 557 D((0. "Tns Packet Dest => %02x-%02x-%02x-%02x-802x-%02x\n", 558 pucBuffer(0], 559 pucBuffer(1], 560 pucBuffer(2], 561 pucBuffer[3], 562 pucBuffer(9], 563 pucBuffer[5])):

565 D((0. "Tns Packet Source => %02x-%02x-%02x-%02x-%02x-%02x\n~, 566 pucBuffer[6], 567 pucBUffer[7], 568 pucHuffer[8], 569 pucBuffer(9], 570 pucHuffer(10], P"~"°°~'~~8°'w2~'~ 9:03 am Thursday. 30 September Fite: D:\nt4DDK\src\timesn\tnsdrvr\tnsdebug.c Page 8 of 8 571 pucBuffer[11))):

573 D((0, ~Tns packet Type => %02x%02x\n", pucBUffer[12), pucBuffer[13)));
579 ) 577 Nendif y7.b~G, PrIrKbbyCRl8PvB.2.l~ 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 1 of 39 z 37 #include <ntddk.h>
38 #include <tnsdefs.h>
39 #include ~tns.h"
#include ~tnsioctl.h~
41 #include "tnsdebug.h"
42 #include ~tnsapi.h~
43 #include "x86. h"

46 #undef BINARY_COMPATIHLE
47 #define BINARY_COMPATIBLE 0 NTSTATUS
51 WDMInitialize( 52 PDRIVER_OBJECT DriverObject, 53 PULONG InitShutdownMask 54 ):

57 WDMCleanup( 58 ULONG ShutdownMask 59 ):

62 TNSProcessIOCTLs( 63 IN PDEVICE_OBJECT Device0bject, 64 IN PIRP Irp ):

69 TNSEmulSetPacketHeader( PADAPTER pAdapter, 71 PVOID pTnsPacket, 72 UINT PacketLength):

74 unsigned long TNSGetRequestTag(void);

78 #pragma NDIS PAGEAHLE FUNCTION(TNSProcessIOCTLS) 8 0 !J' 81 ~I ~hi.~ -sec~'i.on ~ef3nes °the ~fanctfflns'~equi~red ~~iar an ::applsca~Ei:an -ta-~bi:nd _ . . .,..mid to ~e, a2 ~Jlcsly.~sa,~o~onr~dryex,~a.actl~~Zmctio~~.di~a~~c~:a~~,.~.~,...M.......~?!
~n.xwbrc~usP.~e.z-i~ 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 2 of 39 83 JJ ttiose~'tails'~' In ,general;~ swet~ill only.Vesport'funct3~o°nal.i.ty'?~'hat 3s' 84 !1 useful to an~appiicatian,x plus dome 3ateresting debug and;ronfiguiatiori 85 ~l information:'; ~- . . . _ : : . ...
~,_..<~ ..
86 %

89 WDMInitialize( 90 PDRIVER_OBJECT DriverObject, 91 PULONG InitShutdownMask) 93 NTSTATUS Status;
99 UINT FuncIndex:
96 rl J
97 %~ inlrti~alaze,;'theadr~ier~6b~~t'~s;en~rym~ahits 98 ~ j.

100 DriverObject->FastIODispatch = NULL:

102 for (FuncIndex = 0; FuncIndex <= IRP MJ_MAXIMUM FUNCTION: FuncIndex++) ( 103 DriverObject->MajorFunction[FuncIndex] = TNSProcessIOCTLs;
104 }

106 Status = IoCreateDevice(DriverObject, 107 0, 108 6IMDriverName, 109 FILE_DEVICE_NETWORK, 110 0, 111 FALSE, 112 sIMDevice0bject);

114 if ( NT SUCCESS( Status )) 115 *InitShutdownMask I° SHUTDOWN_DELETE_DEVICE:

117 IMDevice0bject->Flags I= DO BUFFERED-I0;

119 Status = IoCreateSymbolicLink( 6IMSymbolicName, 6IMDriverName ):

121 if ( NT SUCCESS( Status )) ( 122 'InitShutdownMask I° SHUTDOWN_DELETE_SYMLINK:
123 ) else ( 129 D((0, "IoCreateSymbolic Link Failed (%08X): %1s -> %ls\n", Status, IMSymbolicName.Buffer, -2 riverName.Huffer)):
125 ) 126 ) else ( 127 D((0, ~IoCreateDevice Failed - %08x\n~, Status )):
128 BreakPoint():

130 IMDeviceObject = NULL;
131 }

133 return Status;
139 ) 137 TNSProcessIOCTLs( 138 IN PDEVICE_OBJECT Device0bject, 139 IN PIRP Irp) 190 ( 141 PIO_STACK_LOCATION irpStack:
142 pTNS IOCTLPACKET ioBuffer;
143 ULONG inputBufferLength;
194 ULONG outputBufferLength;
145 ULONG ioControlCode:
146 NTSTATUS Status = STATUS_SUCCESS:

148 PAGED_CODE();

150 %~' _ 151 ~~~=G=.'~a~~~..~x' 152 Irp->IOStatus.Status = STATUS SUCCESS;
153 Irp->IOStatus.information = 0;

156 JJ~e~°'~a3~~er~~curr~a~c~tian ~°'~tie,i~,s~~iae~ee 157 l~_ -.~'~'~°.~~.D1,1,,:~'~Od~.~dEtl,~F~tel8,,..2Fii2.~7.CC35~d <

160 irpStack = IoGetCurrentIrpStackLocation(Irp):

162 %'!:
''.- ,~:~Ft.~ ~' offer ~ ~~,s"~~e 163 %,k3~eo3~at~c ts~ tts atf~,~ ,,"."K
9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 3 of 39 169 %'!
16 5 -' 166 ioBuffer = (pTNS IOCTLPACKET)Irp->AssociatedIrp.SystemBUffer;
167 inputBufferLength = irpStack->Parameters.DeviceIoControl.InputBufferLength;
168 outputBufferLength = irpStack->Parameters.DeviceIoControl.OutputBufferLength;

170 switch (irpStack->MajorFunction) 171 case IRP_MJ CREATE:
172 D((0, "IRP Create\n"));
173 break;

175 case IRP_MJ_CLOSE:
176 D((0, ~IRP Close\n~));
177 break;

179 case IRP_MJ_CLEANUP:
180 D((0, "IRP Cleanup\n~));
181 break;

183 case IRP_MJ_SHUTDOWN:
184 D((0. ~IRP Shutdown\n"));
185 break;

187 case IRP_MJ_DEVICE_CONTROL:

18 9 1.1:
190 /! ~et.~ceatrol'corle, from Mack and,~erfo~m ~th~ operation 193 ioControlCode = irpStack->Parameters.DeviceIoControl.IoControlCode:
194 switch (ioControlCode) {

196 /less 3awhere ~S'oii Would adcf ~youz 2L7~an~ler~,.~,,. ~..."_. .
197 case IOCTL_TNS_SETDEBUGINFO:
198 Nifdef DBG
199 gDebugPrintLevel = loBUffer->DebugLevel;
20p gDebugPrintMask = ioBuffer->DebugMask;
201 gDebugBreakFlag = ioBuffer->DebugHreakFlag;
202 {lendif 203 break:

205 default:
206 D((0, "unknown IRP MJ_DEVICE_CONTROL\n = 8X\n~,ioControlCode));
207 Status = STATUS INVALID-PARAMETER;
208 HreakPoint();
209 break;

211 ) 212 break;

219 default:
215 D((0, "unknown IRP major function = 808X\n", irpStack->MajorFunction));
216 Status = STATUS_UNSUCCESSFUL;
217 BreakPOint();
218 break;
219 ) 222 C~ s~s'~"' e"te s i~sao~~ t 'ac~'x ~~~,,"~~~a~us 223 ~/""....»..~. ,~~~..>_._.."..._...,W.~.."....Y, 224 -....
225 Irp->IoStatus.Status = Status;
226 Irp->IoStatus.Information = outputBufferLength;

228 IoCompleteRequest(Irp, IO NO_INCREMENT);

230 return Status:

235 WDMCleanup( 236 ULONG ShutdownMask) 23B if ( ShutdownMask b SHUTDOWN_DELETE SYhILINK ) 239 IoDeleteSymbolicLink( 6IMSymbolicName );
240 ) 292 if ( ShutdownMask & SHUTDOWN DELETE DEVICE ) {

293 IoDeleteDevice( IMDeviceObject );

vn.u.e by cnisP Vs.z.~~ 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 4 of 39 247 void 248 TNSBuildBroadcastReplyMdSend( 249 PADAPTER pAdapter, 250 PVOID pTnsPacket, 251 unsigned char ~pHeader) 253 NTSTATUS Status:
254 KIRQL OldIrql;
255 PNDIS_PACKET MyPacket:
256 ULONG PacketLength:
257 PTNSPacketHelloReply pTnsBuffer:
258 PLIST ENTRY pRequestObj;
259 PREQUEST_DATA pRqstData:
260 int i;

262 !T
263 /l compute packet lencjth, based on reqnest;'ran3 264 !:/ set. ;the vaziable accordihgly- (the=:paciCetv:atructii=e Length 265 v/rrw!ill_get.aet::according toafils:variable),,.~
266 %/:- . ..
267 PacketLength = TNS-PACKET SIZE(TNSPacketHelloReply);

269 Status = TNSInitializeClientNOdeSendPacket(pAdapter, 270 &MyPacket, 271 6pTnsHuffer, 272 PacketLength):

274 °%l:
275 y! Set_t-hey~esttnation,address-appropiiately 276 /7. w.- - ._ 277 RtlCopyMemory(pTnsHuffer, &pHeader(6], 6):

279 !!:
280 /'I F~"3a~relavent ,packet ,: information here- , e~.
2 81 %'(: . . ..
282 pTnsHUffer->TNSCommandReply = wswap(TNS HELLO REPLY):

284 pTnsHuffer->RequestTag = dwswap(((PTNSPacketHelloHroadcast)pTnsPacket)->RequestTag);
285 for (i=0: i<HARDWARE ADDRESS LENGTH; i++) {
286 pTnsBuffer->SMNServerMacAddress[i] = pAdapter->LowerMPMacAddress[i]: , 287 ]
288 pTnsHuffer->RequestStartTSC = ((PTNSPacketHelloHroadcast)pTnsPacket)->RequestStartTSC;
289 pTnsBuffer->TNSClientNOdeID = TNSGetSharedMemoryNodeNodeID(pAdapter, pHeader);
290 pTnsBuffer->TNSSharedMemorySize = dwswap(pAdapter->TNSSharedMemorySize):

292 D((0, "SRV: TNSSharedMemorySize => %x\n", pTnsBuffer->TNSSharedMemorySize));

294 %7 295 %-l-~Copy~=the sam ~uachine name stn the;x~eply,.packet 296 /l _.~ . -.
297 for (i=0; i<MAX COMPUTER NAME SIZE: i++) {
298 pTnsBuffer->SMNMachineName[i] = pAdapter->LOCalComputerName[i]:
299 ) 301 /l:
302 )// ~Dequeue ~~~xee=~element, fro~rt our available, object,queue 303 /'/;
309 pRequestObj = ExInterlockedRemoveHeadList( 305 &pAdapter->WorkerListEntryPOOl, 306 SpAdapter->ListEntryPoolLock);

308 pRqstData = CONTAINING_RECORD(pRequestObj, 309 REQUEST DATA, 310 Linkage):

312 !I
313 %.T~'~e~r~,he seiver'"~hiead srtiat, ro.do 314 7/ ,_. .. , .

316 pRqstData->requestOpcode = TNS_HELLO REPLY:
317 pRqstData->pNdisPacket = MyPacket;

319 %%;
320 ~Y 3nsert,~~b~~c~ ontu.~servEr, Lhread:-~ob~ect" ciueiie 321 %%: - _..
322 ExinterlockedinsertTailListl 323 6pAdapter->ServerWOrkerListEntry, 329 6pRqstData->Linkage, 325 6pAdapter->ServerWorkerListSpinLOCk):

327 %7 9:03 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 5 of 39 328 %:l'-~Noi~tsi iial~tiie~"~seive=-:tklreaii . ~..~ ~....:<I~.- ~_~,.._~.>..._..
329 /'/
330 KeReleaseSemaphore( 331 6pAdapter->ServerWOrkerRequestsemaphore, 332 (KPRIORITY) 0, 333 (LONG) 1, 334 FALSE);

336 return:
337 }

339 Adefine MAX_HELLO_RETRIES 20 342 TNSCIIentWorkerThread( 393 PVOID Context 344 ) 396 NTSTATUS waitStatus:
347 LARGE INTEGER queuewait:
348 LARGE_INTEGER waittime:
349 PADAPTER serverContext = (PADAPTER)Context;
350 PADAPTER pAdapter = (PADAPTER) Context:
351 int HelloRetryCount;
352 int HelloReceivedReply = FALSE:

359 PLIST ENTRY clientRequest:
355 PREQUEST_DATA pClientRequestData:

357 ULONG RegisterData=OxbaddcOde:
358 NTSTATUS Status:
359 KIRQL OldIrql;
360 PNDIS_PACKET MyPacket;
361 ULONG PacketLength:
362 PTNSPacketHelloBroadcast pTnsBUffer;
363 int i;

365 queueWait.QuadPart = -(3'1000~10000);
366 waittime.QuadPart = -(3'10000):

368 D((0, ~TNSClientWorkerThread\n"));

370 KeSetPriorityThread(KeGetCurrentThread(), LOW REALTIME PRIORITY+7);

373 ~~.. ~andn~~'~uY~~'roatlcast hel'~.an"r~t~~"°~T~"~respiort~ew:;
379 ~ ' eect~t ~ e~ h~ anaa. addzess~~~ ~Tt-~~e 375 )= ~~~""~t'i,~,o~-.'~..~..._....- _... ......~.

379 ~ 3?su~ a~re~'has beam yntf~ed ~xt~pe~°y~~:Etf~s ~s'i;
380 j an '°"~e~~ '~~.~r_3,sen~°ahou3:d~even h 'end,.:
'.~a" *»~..,..: ..~.._., 3 81 j°
382 j7c 383 jtr~k~haGk~~rQa~&aiidlyg 384 ~l 385 while (!pAdapter->TNSDriverInitialized) 387 ~ 'a~Yh~fi"'~i.v8i; 1'338'X7ie8n~'~et~:~~~3At.~'i~3l~j"
388 ~,then~:x~atie.

390 KeDelayExecutionThread( 391 KernelMode, 392 FALSE, 393 6waittime);
394 ) 403 if (TNSSharedMemoryNOdeEmulation == FALSE) ( 405 t ~~Ie n.~has'"°'e"ci.~e si,~~and 406 ~~"le ~oxd~92y~(ttte ~ Y t s~~~' r..,:n~h~tii .~._ ._ ... ~~
407 ~/u~,xs~t~,accordi~g,~o~t.~;s.~uar~hle~s:
408 l:l, vN.r.abycwsP.~a.z.,. 9:03 am Thursday, 30 September 1999 File: D:\nt4DDlC\src\timesn\tnsdrvr\tnsapi.c Page 6 of 39 910 HelloRetryCount = 0;

412 while ( (HelloRetryCount++ < MAX HELLO RETRIES) 6b (HelloReceivedReply ==
FALSE) ) {

414 PacketLength = TNS PACKET_SIZE(TNSPacketHelloBroadcast);
915 Status = TNSInitializeClientNOdeSendPacket(pAdapter, 416 6MyPacket, 417 spTnsHuffer, 418 PacketLength);

420 D((0, ~HelloRetryCount => %d\n", HelloRetryCount));
4 21 ~i%
422 1~~3'11: ~~:.rel.3vent ~p~cket~ ~eyozmata.on~hex~ :. ~~_.
9 2 3 l'j:
429 pTnsBuffer->TNSCommandReply = wswap(TNS HELLO BROADCAST);

426 pTnsBuffer->RequestTag = dwswap(TNSGetRequestTag());
427 pTnsBuffer->Request5tartTSC = rdtsc();
928 for (i=0; i<6; i++) ( 429 pTnsBuffer->ClientMacAddress(ij = pAdapter->LowerMPMacAddress[i];
430 }
431 RtlCopyMemory(pTns8uffer->ClIentMachineName, pAdapter->LocalCOmputerName, MAX-COMPUTER NAME S
-2 IZE);

433 if (NT SUCCESS(Status)) ( 939 PLIST ENTRY wrkrRequest;
935 PREQUEST DATA pWrkrRequestData;
436 LARGE_INTEGER queuewait;

9 38 %:l:
439 '~~$ea~~;~e estackeL"toy ~..~_..-~.._w....~.._.~.:~ ....~._~.._.~..r...
940 ~l:
441 TNSSendPackets(pAdapter->LOwerMPHandle, 6MyPacket, 1);

9 9 9 /this .~~=~a ~ze~ '°~operat~'on so ire ~expec~ ~ ~ respoase 445 ~~Block,~a~ti~r ~otie sespvsase,-f~caa ythe~ta, 446 t/y 447 queueWait.QuadPart = -(HelloRetryCount~1000~1000);

449 Status = KeWaitForSingle0bject( 450 (PVOID) 6pAdapter->ClientWOrkerResponseSemaphore, 451 Executive, 452 KernelMode, 453 FALSE, 459 fiqueueWait);

956 if (Status == STATUS_TIMEOUT) ( 958 /,;l~sa~agy.,.useful,. yL3'jre ~yac ~'~.a~t°;

461 } else ( 962 ~~ _ 4 63 '' ~Psz~9S~''~a?

466 clientRequest = ExInterlockedRemoveHeadList( 467 6serverContext->ClientWorkerListEntry, 468 6serverContext->ClientWOrkerListSpinLock):

470 MyAssert(clientRequest != NULL):

472 pClientRequestData = CONTAINING RECORD(clientRequest, 473 REQUEST DATA, 474 Linkage);

476 MyAssert(pClientRequestData != NULL);

478 if (pClientRequestData->requestOpcode != TNS HELLO REPLY) ( 479 MyASSert(0):
980 ) else ( 981 D((0, ~We got a hello reply\n~));
482 HelloReceivedReply = TRUE;
483 ) 985 JI _ 486 ~1~,~~CkE ~ e. ierciliyect ~,Y..._. ~r~ .....<.... ... _..
4 87 ~~I
488 ExInterlockedInsertTailList(6serverContext->WOrkerListEntryPool, 989 6pC11entRequestData->Linkage, 990 6serverContext->ListEntryPoolLock);
" 9:03 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 7 of 39 492 ) 493 }
494 ) 496 while (1) 497 KeDelayExecutionThread( 498 KernelMOde, 499 FALSE, 500 6queueWaitl:

502 TnsGetNICStats(pAdapter, 6pAdapter->mpStats):
503 ) 504 ) 508 PsTerminateSystemThread(STATUS SUCCESS):
509 ) 514 TNSServerWOrkerThread( 515 PVOID Context 516 ) 517 ( 518 NTSTATUS waitStatus:
519 LARGE INTEGER queueWait:
520 PADAPTER serverContext = (PADAPTER)Context:
521 PADAPTER pP.dapter = (PADAPTER)Context;
522 PLIST_ENTRY serverRequest;
523 PREQUEST DATA pServerRequestData:
524 NTSTATUS Status:

526 queueWait.QuadPart = -(3~1000~10000):

528 D((0, ~TNSServerWOrkerThread\n~)):

530 if (TNSSharedMemoryNodeEmulation) ( 532 pAdapter->TNSSharedMemoryPtr = NULL:
533 pAdapter->TNSSharedMemorySize = 0;

535 %~'3~<~iL~3 536 pAdapter->TNSMemoryType = VIRTUAL MEMORY;
537 pAdapter->TNSMemoryType = NONPAGED MEMORY:

539 if (pAdapter->TNSMemoryType == VIRTUAL_MEMORY) ( 59 0 ~;/;
541 ~l:~;1~.~~mgg,'3:0 ~star~ with s42 ~~, 599 pAdapter->TNSSharedMemorySize = 1024~1024~4;

546 Status = zwAllocateVirtualMemory( 547 (HANDLE) NtCurrentProcess(), 548 (PVOID *) spAdapter->TNSSharedMemoryPtr, 549 (ULONG) 0, 550 (PULONG) &pAdapter->TNSSharedMemorySize, 551 (ULONG) MEM COMMIT, 552 (ULONG) PAGE_READWRITE):

559 if (Status != STATUS SUCCESS) ( 555 D((0, ~Virtual memory allocation failed\n")):
556 asm int 3 557 ) else 558 D((0, "Virtual memory allocation succeeded\n~)):
559 RtlZeroMemory(pAdapter->TNSSharedMemoryPtr, pAdapter->TNSSharedMemorySize):
560 ) 561 }
562 if (pAdapter->TNSMemoryType == NONPAGED_MEMORY) ( 564 ~~~~~~at~g: ta~~rC#i .~, _.~.~A_..._~__ ~;....... _. ... ", 565 jFa, 566 pAdapter->TNSSharedMemorySize = 1024'1024~1;

568 pAdapter->TNSSharedMemoryPtr =

569 ExAllocatePool( 570 NonPagedPool, 571 pAdapter->TNSSharedMemorySize):

P,,,xw br ~sP.,a.z-~= 9:03 am Thursday, 30 September t 999 Flle: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 8 of 39 573 if (pAdapter->TNSSharedMemoryPtr == NULL) ( 574 D((0, "NonPagedPOOl memory allocation failed\n"));
575 asm int 3 576 ) else ( 577 D((0, ~NonPagedPOOl memory allocation succeeded\n~)):
578 RtlZeroMemory(pAdapter->TNSSharedMemoryPtr, pAdapter->TNSSharedMemorySize):
579 ) 581 ) 583 }
584 KeSetPriorityThread(KeGetCurrentThread(), LOW REALTIME PRIORITY+7);

586 do ( 587 waitStatus = KeWaitFOrSingle0bject( 588 (PVOID) 6serverContext->ServerWorkerRequestSemaphore, 589 Executive, 590 KernelMode, 591 FALSE, 592 squeueWait);

595 ;J/
596 J%,'~Gheck,far,timeout, if'r~e do,,;then,:'do something 597 ~~%,' 598 if (waitStatus == STATUS_TIMEOUT) ( 599 7!
600 J!x""Z~ Status as tinieout; x3ke'theoppartnni~y~to~.r3o something=usef~il' 601 /l~:,a~ collect some atatistiCal daCa 602 %~: ... .... . .
603 TnsGetNICStats(pAdapter, ~pAdapter->mpStats);

605 continue;
606 ) 608 %~15( (Xt,"~~~',_'""INSServerWorkaz'lhxead := ~equeued anraobject~n") ~~;
609 MyASSert(waitStatus == STATUS SUCCESS ):

611 while (serverRequest = ExInterlockedRemoveHeadList( 612 6serverContext->ServerWorkerListEntry, 613 6serverContext->ServerWorkerListSpinLOCk)) {

615 pServerRequestData = CONTAINING RECORD(serverRequest, 616 REQUEST DATA, 617 Linkage):

619 MyAssert(pServerRequestData):

621 switch (pServerRequestData->requestOpcode) ( 622 case TNS_READ REQUEST: {
623 PNDIS_PACKET MyPacket;
624 ULONG PacketLength:
625 PTNSPacketReadReply pTnsHuffer;
626 NTSTATUS Status;
627 PUCHAR vHuffer:

629 vBuffer = pAdapter->TNSSharedMemoryPtr;

631 ~7~Dia~. , :Pirocess~ngserve~~xeac~i'~eeques't~a~) 9 632 PacketLength = TNS PACKET SI2E(TNSPacketFteadReply):

639 Status = TNSInitializeCllentNOdeSendPacket(pAdapter, 635 6MyPacket, 636 6pTnsHuffer, 637 PacketLength):

639 RtlCopyMemory(pTnsBuffer, &((PTNSPacketReadRequestllpServerRequestData->TnsPacket))->
-2 MACSrcAddress, 6);
640 %7 641 J/~;~'i~lc in~re3av~tzt;~paGkex 3,n~r~ia~3:on,$~ete~ . ;..
642 11;
643 pTnsBuffer->TNSCommandReply = wswap(TNS READ_REPLY):

645 pTnsBuffer->RequestTag = ((PTNSPacketReadRequest)(pServerRequestData->TnsPacket))->Re -2 questTag:
646 pTnsHuffer->RequestStartTSC = ((PTNSPacketReadRequest)(pServerRequestData->TnsPacket) -2 )->RequestStartTSC;
697 vBuffer =
(PUCHAR)((ULONG)vBuffer+(ULONG)dwswap(((PTNSPacketReadRequest)(pServerReque -2 stData->TnsPacket))->RequestOffset)):

649 if Idwswap( ((PTNSPacketReadRequest)(pServerRequestData->TnsPacket))->RequestOffset) -2 <= pAdapter->TNSSharedMemorySize ) ( ~n,w.a~.cwsPre.z.,. 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapf.c Page 9 of 39 650 pTnsBuffer->dwData = '((PULONG)vBuffer):
651 ) else ( 652 _asm int 3 653 ) 655 TNSSendPackets(pAdapter->LowerMPHandle, ~MyPacket, 1):

657 break:

659 case TNS_WRITE_REQUEST: ( 660 PNDIS_PACKET MyPacket:
661 ULONG PacketLength;
662 NTSTATUS Status:
663 PUCHAR vBuffer;

665 lJ,~~;'(D~" "Processiag sesuer Nrite :request\a"'~,) 667 vHuffer = pAdapter->TNSSharedMemoryPtr:

669 vHuffer = (PUCHAR)((ULONG)vHuffer+(ULONG)dwswap( ((PTNSPacketWriteRequest)(pServerReq -2 uestData->TnsPacket))->RequestOffset)):

671 if (dwswap(((PTNSPacketWriteRequest)(pServerRequestData->TnsPacket))->RequestOffset) -2 <= pAdapter->TNSSharedMemorySize ) ( 672 '((PULONG)vHuffer) _ ((PTNSPacketWriteRequest)(pServerRequestData->TnsPacket))->d -2 wData:
673 ) else ( 674 _asm int 3 675 ) 677 break;
678 ) 679 case TNS HELLO REPLY:
680 MyAssert(TNSSharedMemoryNodeEmulation):
681 !:l 682 %leifcllieTlii~-repTy 6 8 3 %'/
689 D((0, "Processing server hello reply\n")):

686 TNSSendPackets(pAdapter->LowerMPHandle, 6pServerRequestData->pNdisPacket, 1):

688 break;
689 default:
690 MyAssert(0);
691 break:
692 ) 693 %=I
694 JI'3teCyale ~khe"gueue .object 695 %I
696 ExInterlockedInsertTailListl6serverCOntext->WOrkerListEntryPool, 697 6pServerRequestData->Linkage, 698 fiserverContext->ListEntryPoolLock):
699 ) 700 ) while (TRUE);

702 PsTerminateSystemThread(STATUS SUCCESS);
703 f 706 TNSEmulSetPacketHeader( 707 PADAPTER pAdapter, 708 PVOID pTnsPacket, 709 UINT PacketLength) 710 ( 711 UINT i:
712 ULONG 'pulData;

714 pulData = (PULONG) pTnsPacket:

716 %'/
717 JX,~Ze=cqirteinoryy,~take~this.out~'3a~erl;
71 a l1 ~ _.. _ 719 RtlZeroMemory(pTnsPacket, PacketLength):

721 1;1:
722 //fPuL a recognxzab'~e ~aC,ie"rn,yto paa7ceC~';buffer 723 f;~, ... ._..
729 for (,i=0: i<PacketLength/9; i++) 725 'pulData++ = Oxcafebabe:

726 ) 728 %!
w~rrt~a ey cwsP.,e.z.~. 9:03 am Thursday, 30 September 1 999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page y0 of 39 729 // ~Set,~ the' dest3nation"ancf, source addresses ',foi;,the; packet;
7 3 0 !.!, 731 for (i=0: i<HARDWARE ADDRESS LENGTH; i++) 732 ((PTNSPacketHeader)pTnsPacketl->MACDstAddress(i] = pAdapter->SMNMacAddress(i]:
733 ((PTNSPacketHeader)pTnsPacket)->MACSrcAddress[i] = pAdapter->LowerMPMacAddress[i];
734 ) 735 /7:
736 I/ 'Set, khe etfi~!rtype to. our ettieitype 737 Ll:
738 ((PTNSPacketHeader)pTnsPacket)->MACEtherType = wswap(TNS_EMULATION
ETHERTYPE);

740 ) 742 %!.
793 %! Initialized':ao ~ -incremented ,by 1.~eactuaime vre.'~pee'3Y:~: 'We 'use:T:
749 %ythis:to help,upy:keep track; of.outstand3ag.;eque~ts to.;the,SNE~i;, 745 ~:
746 unsigned long gRequestTag = 0;
747 unsigned long 748 TNSGetRequestTag(void) 750 return gRequestTag++;
751 }

754 J%:
755 %Y Initialized,.to 0 : incremented by 1, each time. we~:use .ft:: tote use::.
756 /J thia;:.te help,up:keep.traek;;of,outs~anding requests~to.Lhe.;ft~l,.;
757 /:J, . .....
758 unsigned long gSharedMemoryNodeNodeID = 0;
759 unsigned long 760 TNSGetSharedMemoryNodeNodeID( 761 PADAPTER pAdapter, 762 unsigned char ~pHeader) 763 {
764 ULONG i:
765 ULONG NextFreeSpace=Oxffffffff;
766 ULONG NewTeamNodeID;
767 PTNSPacketHelloBroadcast pTnsPacket = (PTNSPacketHelloBroadcast) pHeader:

769 for (i=0; i<MAX_TEAM_NODES: i++) {
770 if (pAdapter->TeamNodeTable[i].LocationSet) 771 if ( RtlCompareMemory(SpHeader(6], pAdapter->TeamNOdeTable[i].TNMacAddress, 6) _= 6) [
772 return pAdapter->TeamNodeTable[i].TNNOdeID;
773 ) 774 } else 775 if (NextFreeSpace == Oxffffffff) [
776 NextFreeSpace = i;
777 ) 778 }
779 ) 781 '/%
782 /1 =~f ire ~~airle. i~t this' far; we °'c113 not>' find an~~en~:
783 !I .S~t, an;-~ntry incur ;tabhe ~or_ xhis mac addzesa.
7 a 4 !/. . _.
785 NewTeamNodeID = gSharedMemoryNodeNOdeID++;
786 RtlCopyMemory(pAdapter->TeamNodeTable[NextFreeSpace].TNMacAddress, 6pHeader[6], 6);
787 RtlCopyMemory(pAdapter->TeamNOdeTable[NextFreeSpace].TNComputerName, pTnsPacket->ClientMachineName, -2 AX_COMPUTER_NAME_SIZE);
788 pAdapter->TeamNodeTable[NextFreeSpace].LOCationSet = TRUE;
789 pAdapter->TeamNodeTable[NextFreeSpace].TNNOdeID = NewTeamNodeID:

791 return NewTeamNodeID;
792 ) 795 LARGE_INTEGER diffTime;

798 TNSInitializeClientNodeSendPacket( 799 IN PADAPTER pAdapter, 800 IN OUT PNDIS PACKET ~ppNdisPacket, 801 IN OUT PVOID ~ppTnsHuffer, 802 IN ULONG PacketLength) 803 {
804 NTSTATUS Status=STATUS_SUCCESS:
805 PTNS_PACKET CONTEXT PktCOntext:
806 PNDIS_PACKET MyPacket:

807 PNDIS_BUFFER MyNdisBuffer;
808 PVOID vBuffer;
809 NDIS PHYSICAL ADDRESS HighAddress = NDIS PHYSICAL ADDRESS CONST( -1. -1 ):
'~ 9:03 am Thursday, 30 September 1999 Flle: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 1 y of 39 B10 PVOID pTnsPacket:
811 LARGE_INTEGER startTime, endTime:
812 ' 813 '/,'/:
814 '71'Allocate a.~pac'ket~°f:rom:rinr-:aqai. ay'YeMpacket~poQl,;' 815 %;1 check.; status, . remit. the:,packet:_~azzø~ge~t~e' 816 %/t conteaL":context area 817 %-(: ... . _ ,...
818 startTime = rdtsc():
B19 NdisAllocatePacket(6Status, &MyPacket, pAdapter->PacketPoolHandle);
820 endTime = rdtsc();

822 diffTime.QuadPart = endTime.QuadPart - startTime.QuadPart:

824 if (diffTime.LowPart > 0x400) ( 825 J~D~°(I,x~..:"NdisAllocatePacket_,Time;
su$x~ln","~°,"~pfTime -IawEart);~_ 829 %7 'hack=vtiack, ,walk on; error fiauiili~g 830 //:
831 if (Status != STATUS_SUCCESS) ( 832 asm int 3 833 return Status:
839 ) 835 NdisReinitializePacket(MyPacket);

837 PktContext = PACKET_CONTEXT_FROM_PACKET(MyPacket):

839 PktContext->OriginalPacket = NULL;
840 PktContext->LookaheadBuffer = NULL;
841 PktContext->SMNEmulationPacket = TRUE:

843 /~
899 /,! Nod,.: aTTo~s~e Ta'mEnffer ~ay;cha3n,~~to .khe~.~?aclcet e9s ~~" , 846 Status = NdisAllocateMemory(avBuffer, PacketLength, 0, HighAddress):

848 !l 849 lJ?~hao~ ~~iaCk~,~r~ork ~a $r~°hand~ing eso /j 851 if (Status != NDIS STATUS SUCCESS) ( 852 NdisFreePacket(MyPacket);
853 return Status:
B54 ) 856 NdisAllocateBuffer(6Status, 857 6MyNdisHuffer, 858 pAdapter->LookaheadPOOlHandle, 859 vHuffer, 860 PacketLength):

863 ~~,,,'ha~k~iar~k y!c~k op~4exrar haadlinq 869 %%
B65 if (Status != NDIS_STATUS_SUCCESS) 866 asm int 3 867 NdisFreePacket(MyPacket):
868 NdisFreeMemory(vBuffer, PacketLength, 0):
869 return Status;
870 ) 872 pTnsPacket = (PTNSPacketHelloBroadcast) vBuffer:

874 ~!~.
875 %:IH'~et -.~'t~e ~ ac~3Ee~~~nac dest,;;sourCe, and aethes~y!ge ~P._ t? ~.._ ...
876 %~

878 TNSEmulSetPacketHeader(pAdapter, pTnsPacket, PacketLength):

66o Tl B a l ?/,~'-Set;~~hoe",ack6t~~ength 882 l/:
883 NdisAdjustBufferLength(MyNdisBuffer, PacketLength):

885 %%
886 %I,Qiain~aurx~uf~e~,r°trfthis~abket::~t2eiGYiNre BB7 !j_-888 NdisChainBufferAtFront(MyPacket, MyNdisBuffer):
889 NdisRecalculatePacketCounts(MyPacket):

891 ~ppNdisPacket = MyPacket:
9:03 am Thursday. 30 September 1999 Flle: D:\nt4DDK\src\tlmesn\tnsdrvr\tnsapi.c Page 12 of 39 892 'ppTnsHuffer = pTnsPacket:

894 return Status:
895 ) 898 TNSFIushReadReplyQueue( 899 PADAPTER pAdapter) 901 LARGE INTEGER queueWait:
902 NTSTATUS Status:
903 PLIST_ENTRY clientRequest:
904 PREQUEST_DATA pClientRequestData:

906 do ( 907 queuewait.QuadPart = -(0):

909 Status = KeWaitForSingle0bject( 910 (PVOID) 6pAdapter->ClientWOrkerRequestSemaphore, 911 Executive, 912 KernelMOde, 913 FALSE, 919 6queuewait):

916 if (Status == STATUS_SUCCESS) ( 918 clientRequest = ExInterlockedRemoveHeadList( 919 spAdapter->ClientWOrkerListEntry, 920 epAdapter->ClientWOrkerListSpinLOCk);

922 MyAssert(clientRequest != NULL);

924 pClientRequestData = CONTAINING RECORD(clientRequest, 925 REQUEST_DATA, 926 Linkage):

928 MyASSert(pClientRequestData):

930 TnsIncrementStat(pAdapter, spAdapter->MyStats.numDiscardedTnsRecvs);

933 ~/e~~°daefaqueae-: ~je~t 939 ~~.
935 ExInterlockedInsertTailList(spAdaptez->WOrkerListEntryPOOl, 936 6pClientRequestData->Linkage, 937 6pAdapter->ListEntryPOOlLock):
938 ) 939 } while (Status == STATUS SUCCESS) 949 ,~J _ 99 5 ~~~~i~~~~ .aM~ '~53r~ ..EI_tt7CY .Polnt$

948 Ndefine MAX REQUEST RESPONSE RETRIES 50 950 ~f~''*'~+~"«~~*'~.w'~'~"~rssa:~a,;nib;wy~:arar*.ierhraszt*~t-rx~~i-!~a~ry':,4,v~tx.*~at*,~i~*~+:
~~,x as~~,.~ezrasm..r..,_;n~rs~:.axasar-a..._.~...-.:~..:w:~:~._~ee,:i...z~m,..~estxr:.._:~utzars.:x ~
~.._..:ez~:a.w_~..~~.:~z~K.r_~s.;u:;.
951 )(,, 952 UhONG
953 DECLSPEC_EXPORT
959 _TNS_READ_REGISTER_ULONG( 955 IN PVOID DeviceHandle, 956 IN PULONG Register) 957 L~I
958 ~C7=sC7C"~,~oa:
959 ~7:

966 ( 967 ULONG RegisterData=OxbaddcOde:
968 PADAPTER pAdapter = (PADAPTER) DeviceHandle:
969 NTSTATUS Status;

970 KIRQL OldIrql:
971 PNDIS PACKET MyPacket:
972 ULONG PacketLength;
973 PTNSPacketReadRequest pTnsHuffer:
~~~~~~sP~z-~~ 9:03 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 13 of 39 979 PLIST ENTRY clientRequest:
975 PREQUEST DATA pCllentRequestData:
976 ULONG requestTag:
977 ULONG retries=0:
978 int noreply = TRUE:
979 ULONG returnRequestTag:
980 LARGE_INTEGER startTime, endTime, diffTime:

982 :/r1 983 ;/l~.hadk~hack''"We xea3ly :wanna use the device;contest gi~ren-up 994 l:b ~ttie~caller.:: ~~ ~' ... _m..-......
. ~ a,~~.. -985 %L:
986 pAdapter = CONTAINING RECORD(AdapterList.Flink, ADAPTER, Linkage):

988 !J
989 !/'I~ai~e'~RQL to preve:it,jtas3c..swage;~.ag~,Whiz:e~aHercomplatesprocess'"3.r 990 /'J"°fox ;this packed, .-:: . ..
9 91 '/'f w 992 ICeRaiseIrql(DISPATCH LEVEL, 601dIrq1):

995 /-% flake, asure txfr3~rer ha's been ,'3~ntLal3zed.~properly (~Ct~s ,is 996 I%_-an;.assertioa_iw thi~.-case_ahould~;never :happen)~~.
997 '/%-998 'll 999 ~/%"haz;~ shack ~orlc~.on terror :handling 1000 ~,~. .. . _.....
1001 if (!pAdapter->TNSDriverInitialized) ( 1002 BreakPoint();
1003 KeLowerIrql(OldIrql):
1004 return 0:
1005 }

1007 TnsIncrementStat(pAdapter, spAdapter->MyStats.numReadRequests):

1009 J~" compu'~e.pac7ce~""7.ength, based on sequest,~aad 1010 !l ~set.dttie va~i,able accordingly (t3~e~-packet ~struCture~.le~G3 1011 /sr~aw3~13;a'geL sets d~cordlng.,toE=th~.5~ua~able~
1012 ' ~ . . _:

1014 PacketLength = TNS-PACKET SIZE(TNSPacketReadRequest):

1016 requestTag = TNSGetRequestTag();

1018 while (noreply 66 (retries++ < MAX REQUEST RESPONSE RETRIES) ) 1020 Status = TNSInitializeClientNodeSendPacket(pAdapter, 1021 6MyPacket, 1022 &pTnsBUffer, 1023 PacketLength);

1025 ~7:
1026 J~~~~.~4via';~'6~.av~at packets 3n~zm~xign,,~~ere., ...

1028 pTnsBuffer->TNSCommandReply = wswap(TNS READ-REQUEST);

1030 pTnsBuffer->RequestTag = dwswap(requestTag):
1031 pTnsBuffer->RequestWidth = dwswap(4):
1032 pTnsHuffer->RequestLength = dwswap(1):
1033 pTnsHuffer->RequestOffset = dwswap((unsigned long)Register):
1034 pTnsBuffer->RequestStartTSC = rdtsc():

1036 if (NT SUCCESS(Status)) {
1037 PLIST ENTRY wrkrRequest;
1038 PREQUEST DATA pwrkrRequestData;
1039 LARGE INTEGER queueWait;
1040 int timeout = FALSE;
1041 int ltimeout = FALSE;
1042 int timeoutcount = 0;

1049 TNSFIushReadReplyqueue(pAdapter):

1051 startTime = rdtsc();

1052 %!
1053 vll.Sen~,xsgue~t;,packexyto ~f~1 1055 TNSSendPackets(pAdapter->LowerMPHandle, sMyPacket, 1);
PrinbCbyCRI8PvB2.t~ 9:03 am Thursday. 30 September X999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 14 of 39 1057 ~/l 1058 //-Thig--'is::aieadaope=ation,yso we:.expect a'respansey 1059 7/~SSock waiting ~os~the,Fresponse;,fzom the;,.SMN:-1060 /"~~ ..:
1061 %/amthisyis:"-lOtim.BeCS::
1062 !/

1064 queueWait.QuadPart = -(1000000):

1066 Status = KeWaitForSingle0bject( 1067 (PVOID) 6pAdapter->ClientWOrkerRequestSemaphore, 1068 Executive, 1069 KernelMOde, 1070 FALSE, 1071 6queueWait);

1073 if (Status != STATUS TIMEOUT) 1074 PTNSPacketReadReply pTnsPacketReadReply:

1076 clientRequest = ExInterlockedRemoveHeadList( 1077 6pAdapter->ClientWOrkerListEntry, 1078 6pAdapter->ClientWOrkerListSpinLock):

1080 MyASSertIclientRequest != NULL);

1082 pClientRequestData = CONTAINING RECORD(clientRequest, 1083 REQUEST DATA, 1084 Linkage);

1086 MyASSert(pCllentRequestData != NULL);
1087 pTnsPacketReadReply = (PTNSPacketReadReply) 6pClientRequestData->TnsPacket:

1089 RegisterData - pTnsPacketReadReply->dwData;
1090 returnRequestTag = dwswap(pTnsPacketReadReply->RequestTag):

1092 F/'~i.~yAssert'~retgtiiRequest2ag ....,~~quest~ag~.~

1094 if (returnRequestTag == requestTag) 1095 noreply = FALSE;
1096 endTime = rdtsc():
1097 ) 1099 'l7 1100 J.l~'only~ma3ataiayatats ;if we ~clid, aot~retry the: operation 1101 %~. ~ -. _..
1102 i~f ( (retries == 1) 6s (noreply==FALSE) ) 1103 diffTime.QuadPart = endTime.QuadPart - startTime.QuadPart:
1104 if (pAdapter->MyStats.maxKeadTimeSingle.QuadPart == 0) ( 1105 _ pAdapter->MyStats.maxReadTimeSingle.QuadPart = diffTime.QuadPart;
1106 ) else 1107 if (diffTime.QuadPart > pAdapter->MyStats.maxReadTimeSingle.QuadPart) 1108 pAdapter->MyStats.maxReadTimeSingle.QuadPart = diffTime.QuadPart;
1109 ) 1110 ) 1111 if (pAdapter->MyStats.minReadTimeSingle.QuadPart == 0) [
1112 pAdapter->MyStats.minReadTimeSingle.QuadPart = diffTime.QuadPart:
1113 ) else ( 1119 if (diffTime.QuadPart < pAdapter->MyStats.minReadTimeSingle.QuadPart) [
1115 pAdapter->MyStats.minReadTimeSingle.QuadPart = diffTime.QuadPart;
1116 ) 1117 ) 1118 if (pAdapter->MyStats.numReadTimeSingleSamples.QuadPart < 30000) 1119 pAdapter->MyStats.cumReadTimeSingle.QuadPart += diffTime.QuadPart:
1120 TnsIncrementStat(pAdapter, 6pAdapter->MyStats.numReadTimeSingleSamples):
1121 ) else 1122 pAdapter->MyStats.cumReadTimeSingle.QuadPart = diffTime.QuadPart:
1123 pAdapter->MyStats.numReadTimeSingleSamples.QuadPart = 1:
1124 ) 1125 ) 1128 //;ReCyC7e~the'queue objeC~
1129 %!:
1130 ExInterlockedInsertTailList(6pAdapter->WOrkerListEntryPool, 1131 6pClientRequestData->Linkage, 1132 ~pAdapter->ListEntryPOOlLock);
1133 ) else 1134 TnsIncrementStat(pAdapter, 6pAdapter->MyStats.numReadRequestTimeouts);

1135 ) 1136 ) 1137 ) PrirtW byCHi9PV6.2.1~ 9:03 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 15 of 39 1139 KehowerIrql(OldIrql):

1141 if (retries > 1) ( 1192 TnsAddStatsUlong(pAdapter, spAdapter->MyStats.numWriteRequestRetries, retries-1):
1193 ) 1145 if (noreply == TRUE) ( 1146 RegisterData = OxFFFFFFFF:

1148 TnsIncrementStat(pAdapter, spAdapter->MyStats.numReadRequestNOReplies);
1199 J/:
1150 J/::Tliiow an:eaception~to; our client ,.,.
1151 ,/'/: .., _ 1152 /I~,TODO

1155 return RegisterData:
1156 ) P *w+y-*-ri~r*::,tv***~rd..rt-+~.**r:~*y*:*Yir~i:** * :~.**+y*yi:y **y.i"v,i**y*~4irrl~+y;*** '*' +~s~
1160 !/ _.:_..-_,zu..~.~ _ .::._ .R .~,:,~._.-...,-,." ~.;:.:-, . _ .::, ,.;,". __,,:-;.... -,"...:<..- .......

1163 DECLSPEC_EXPORT
1169 _TNS_WRITE_REGISTER_ULONG( 1165 IN PVOID DeviceHandle, 1166 IN PULONG Register, 1167 IN ULONG RegisterData) 1178 PADAPTER pAdapter = (PADAPTER) DeviceHandle:
1179 NTSTATUS Status;
1180 KIRQL OldIrql:
1181 PNDIS_PACKET MyPacket;
1182 ULONG PacketLength:
1183 PTNSPacketWriteRequest pTnsBUffer;
1184 ULONG requestTag:
1185 ULONG retries=0:
1186 int noreply = TRUE;
1187 PLIST_ENTRY clientRequest;
1188 PREQUEST_DATA pClientRequestData;
1189 ULONG returnRequestTag;
1190 LARGE_INTEGER startTime, endTime, diffTime;

1193 /l:Di(0. !cTNS=WEtTfi~ REGZSTER't7LONG\a°)'),.

1195 l%
1196 JL. hack~fiaak° Wereally~wanna .iise the. deuiee: contest:' ginen.up 1197 l./; by._the,:caller:: _.. .. .. .._ .... .

1199 pAdapter = CONTAINING RECORD(AdapterList.Flink, ADAPTER, Linkage);

1201 '/!
1202 '/I: ~Raiye'TRpL to.,~prevent~,task, Wapping whileywe coiuplete piocessyg 1203 %-T for-this packet :-1204 /.% - .
1205 KeRaiseIrql(DISPATCH LEVEL, 601dIrq1);

1208 %% -T4ake =sure .diiver'shas;-been°'in'Balize~ ,properly- (.this is .=.
1209 /~;an.-assertyn, ~this;case,ahould ne~erhappen)..
1210 ,/:/.
1211 %J:
1212 Il::fiack;tiack work on error hand7aacj 1213 l J, . . ....
1219 if (!pAdapter->TNSDriverInitialized) {
1215 HreakPoint();

1216 KeLowerIrql(OldIrql);
1217 return;
1218 ) vri.u~a~.cwsP.,s.z.,. 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\tlmesn\tnsdrvr\tnsapi.c Page 16 of 39 1220 TnsIncrementStat(pAdapter, 6pAdapter->MyStats.numWriteRequests);

1222 /r 1223 /~pcompute packed rleagth, baser! ~oa,-~equest, ~"aad 1224 /,j set the~wariable~accordingl:~~'tthe gackat -stractvre"rlenijt~i a 1225 !,=l~il4.,x9et, set~ra~COri3i-ug ~o,tttxi~s vax~.able) 1226 a.-~~."~ -- .: ...

1228 PacketLength = TNS PACKET_SIZE(TNSPacketWriteRequest):
1229 requestTag = TNSGetRequestTag();

1231 while (noreply a6 (retries++ < MAX REQUEST RESPONSE RETRIES) ) ( 1233 Status = TNSInitializeClientNodeSendPacket(pAdapter, 1239 6MyPacket, 1235 6pTnsHuffer, 1236 PacketLength);

1238 J/' 1239 l'/-''~'il,'i,;la;;se"7.aarea~.'gacket~Zin~nrma~3.oa :.hexes;: ~~, ~..~,. ' . .... . ., 1240 i/
1241 pTnsBuffer->TNSCommandReply = wswap(TNS WRITE REQUEST);

1293 pTnsHuffer->RequestTag = dwswap(requestTag):
1294 pTnsHuffer->RequestWidth = dwswap(9):
1295 pTnsBuffer->RequestLength = dwswap(1):
1246 pTnsBuffer->RequestOffset = dwswap((unsigned long)Register);
1297 pTnsHuffer->dwData = RegisterData:
1298 pTnsBuffer->RequestStartTSC = rdtsc();

1250 if (NT SUCCESS(Status)) ( 1251 PLIST_ENTRY wrkrRequest:
1252 PREQUEST_DATA pWrkrRequestData:
1253 LARGE_INTEGER queueWait:

1255 TNSFIushReadReplyQueue(pAdapter):

1257 startTime = rdtsc():

1259 ~f~-'~end.~~eguest:°packei~tc.-to ft~e~-<ass~~~<zea~iaA3e de'~i°vs?~Yl 1261 TNSSendPackets(pAdapter->LowerMPHandle, 6MyPacket, 1);

1263 queueWait.QuadPart = -(1000000);

1265 Status = KeWaitForSingle0bject( 1266 (PVOID) 6pAdapter->ClientWOrkerRequestSemaphore, 1267 Executive, 1268 KernelMode, 1269 FALSE, 1270 6quBUeWait)) 1272 if (Status != STATUS_TIMEOUT) ( 1273 PTNSPacketWriteReply pTnsWriteReplyPacket;

1275 clientRequest = ExInterlockedRemoveHeadList( 1276 6pAdapter->ClientWOrkerListEntry, 1277 spAdapter->ClientworkerListSpinLOCk):

1279 MyAssert(cllentRequest != NULL):

1281 pClientRequestData = CONTAINING RECORD(clientRequest, 1282 REQUEST DATA, 1283 Linkage):

1285 MyAssert(pClientRequestData != NULL):

1287 pTnsWriteReplyPacket = (PTNSPacketWriteReply)6pClientRequestData->TnsPacket:

1289 returnRequestTag = dwswap(pTnsWriteReplyPacket->RequestTag);

1291 llse~rtare~utnlTequestTag.X!~~~~Tag~e:

1293 if (returnRequestTag == requestTag) {
1294 noreply = FALSE:
1295 endTime = rdtsc();
1296 ) 1298 if ( (retries == 1) 6d (noreply==FALSE) ) 1299 diffTime.QuadPart = endTime.QuadPart - startTime.QuadPart;
1300 if (pAdapter->MyStats.maxWriteTimeSingle.QuadPart == 0) 1301 pAdapter->MyStats.maxWriteTimeSingle.QuadPart = diffTime.QuadPart;
Alr~hdbyCRiSPv6.2.7s 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 17 of 39 1302 ) else ( 1303 if (diffTime.QuadPart > pAdapter->MyStats.maxWriteTimeSingle.QuadPart) 1304 pAdapter->MyStats.maxWriteTimeSingle.QuadPart = diffTime.QuadPart;
1305 ) 1306 ) 1307 if (pAdapter->MyStats.minWriteTimeSingle.QuadPart == 0) {
1308 pAdapter->MyStats.minWriteTimeSingle.QuadPart = diffTime.QuadPart;
1309 ) else ( 1310 if (diffTime.QuadPart < pAdapter->MyStats.minWriteTimeSingle.QuadPart) f 1311 pAdapter->MyStats.minWriteTimeSingle.QuadPart = diffTime.QuadPart;
1312 ) 1313 ) 1315 if (pAdapter->MyStats.numWriteTimeSingleSamples.QuadPart < 30000) ( 1316 pAdapter->MyStats.cumWriteTimeSingle.QuadPart += diffTime.QuadPart;
1317 TnsIncrementStat(pAdapter, 6pAdapter->MyStats.numWriteTimeSingleSamples);
1318 ) else 1319 pAdapter->MyStats.cumWriteTimeSingle.QuadPart = diffTime.QuadPart;
1320 pAdapter->MyStats.numWriteTimeSingleSamples.QuadPart = 1:
1321 ) 1322 ) 1325 //:~;Recycle:-Ghe qiieue:otije.ct 1326 1/:
1327 ExInterlockedInsertTailList(6pAdapter->WorkerListEntryPool, 1328 ~pCllentRequestData->Linkage, 1329 6pAdapter->ListEntryPoolLock);

1331 ) else [

1333 TnsIncrementStat(pAdapter, spAdapter->MyStats.numWriteRequestTimeouts);

1335 ) 1336 ) 1337 ) 1339 if (retries > 1) ( 1340 TnsAddStatsUlong(pAdapter, ~pAdapter->MyStats.numWriteRequestRetries, retries-1);
1391 ) 1399 if (noreply == TRUE) {
1395 Yl~
1346 !!~,-;'~hrow, an"eaCeption td: ouz cheat f.~DDD
1347 %'/-1350 TnsIncrementStat(pAdapter, &pAdapter->MyStats.numWriteRequestNoReplies);
1351 ) 1353 KeLOwerIrql(OldIrql);

1355 return;
1356 ) :~* *a.* *sr~i:'r**-L*rt-rrTsx*-riaa:*s ~ *-:*rt *:*~* *s*at:**~***-i:~ry.,r*
** ew*;i x* **-**,a~*++r~t* a * *y~i.* *.r*
. . ... . .. . .._ . . ." . ~ . ~.. ... .. _-.
1358 //_. ,. w..z.~..,a....,. .-. . ..-N.. ~,~.a_,... ,2 .._. ,.~ _ ,. .<e .._.~. ~. r .."...~..,. __ 1359 ~//;-, 1361 DECLSPEC_EXPORT
1362 _TNS_READ_REGISTER_USHORT( 1363 IN PVOID DeviceHandle, 1369 IN PUSHORT Register) 1375 USHORT RegisterData=Oxbadd;

1377 return RegisterData:
1378 ) 1380 , 'i~t.rs~
~r:**r*.ri*.:***~rrxx*~.*w:e**r:****:cr*s*r+,r;e***van:~***~rr,u~+tw~~*i~r~ra*e *:a** xv~
~j, . .:;..--~ ' " ".,.. r . ., ,:.;... ,. ~.r ,.cW, .,.- .. .
s."~...,.._"..":,.r.. " ..._,.- :..x-. .._ , ~. ~..» d._..,....~.~'.:, .,. ~.,-.-.-_......, -.:.. : r,~.z"..:
1381 °!v1.=

~ra.a~.cAisP.,s.z.,. 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 18 of 39 1384 _TNS_WRITE_REGISTER_USHORT( 1385 IN PVOID DeviceHandle, 1386 IN PUSHORT Register, 1387 IN USHORT RegisterData) 1398 ) I/*~"'r*visa.r~.+wav.sr+r*rs*4:**sy.rr~s*+.i+i++***rai~+n,r*t**rimpartiall stay,+.+**r~rrl:*
.,..~,u.,.,.b....,.WO,..sm.,....n.;....<.._,....,_....:oa.,...
..,....,.,.~n..."~~.<,.,.,...d.,.__~.,...,..x.... ,.,..._.,~
..,.",..._o,._.._._.._..,..,..""._.~ _->-.z:,..;,r.:
19 O 1 '/'/.-t.

1903 DECLSPEC_EXPORT
1904 _TNS READ REGISTER UCHAR( 1405 IN PVOID DeviceHandle, 1406 IN PUCHAR Register) 1916 ( 1417 UCHAR RegisterData=Oxba:

1419 return RegisterData:
1420 ) 1922 '.~'*~+.*!v:'.*.v-*~r*s**a~i~**.6:+iv~*r~.**.i.y+*+*.i.r.+.iir*i.*e:*y.r*L:*i**~**.w~yr:.**
.*ws~r +**y*-L.+~r~~*~.
1923 l~ ""° ~'"'.-'~. "a_.~s. ~ ~6 ua,.,e ,,...~~" ~ _.~ .. . .
w...,>,yz , ,z<,., . ,.~. _~ _ , _ _ ~ ,__.~ . ..._ ..__ . .....,._, 1426 _TNS WRITE REGISTER UCHAR( 1427 IN PVOID DeviceHandle, 1428 IN PUCHAR Register, 1929 IN UCHAR RegisterData) 14 30 5"1~:
1431 %'I::DYe~Cti t~bn»:
~,-,M.._, 1432 /:I:'0.
1433 ~T;~~En?isso'ninent~

1440 ) ~.t.,i *.*r*'a.t*r.rvr w* ***.tserr a** y~rr**.+* r*r~*+**.*xwy~'x=i:» **i~.i~-Irrx+: y~r*.*y.~e s: **+* * t ~:x s:+Yr,e 14 9 9 // - ., x _x..,a,4,"~..~,a,...~",....~aa..,.:, "..,...,.,._._._,:._..:y..~~as~:_,w..._ .........-.s,m°s..., ......" .-_u.~.a3=...: ,._.__"_...
_"....>..,.x_.......,..
1445 %;/~~., 1496 VOrID
1997 DECLSPEC_EXPORT
1948 _TNS READ_REGISTER HUFFER_ULONG( 1449 IN PVOID DeviceHandle, 1450 IN PULONG Register, 1451 IN PULONG pulHuffer, 1452 IN ULONG Count) 1953 '//
1459 ~/l'~°Aescxi: ~'oii:
1455 :1~ - _...._.
1956 ;/-I'-=Epvi:roninentr:
1457 :/y. . ,.. _ ...., .._ 1458 J%~Aetjirti~Valiie:.

1459 Il ';,.... ,._....
14 60 %'1,.~ ~
- i.Yy,**rr.s.*r**~*x»+~*x**e*y"****~+x;i -:AEI..**~s +*e..
.'vrr*r*.**.*sr,n.*ri~**ew.+i*~r*.ey,r~,.rs*:rh.
1961 // _ ~ , ..,....,., ".a... .... ""... ..... _....,..~.~,...ua ..
~H.w...._.:.~.~..:_..,.... ...,_.,._ ..._.. A_ .,_.~.r...~....--a..~.u..._m..~
,.W..,..,.,..~r _A_.. __ 1963 ) I/*!'t******i:*+*+r*y.**+*,~.;~sa*r+*sw**.*va.rw***+r.+v~.***+~w.+**~***rr:***d :pss*****~~.r.ia*
Priru~abyCRi9Pv6.2.ta 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page y9 of 39 1966 J%=f 1469 _TNS WRITE REGISTER_BUFFER_ULONG( 1470 IN PVOID DeviceHandle, 1971 IN PULONG Register, 1472 IN PULONG pul8uffer, 1473 IN ULONG Count) 1484 ) 1486 %~.;*'s.*i*s+a*.*.Crt**.rd.'*i.r~issi***.*.*"v***y.is.**~.+**+t**,*~s~-L;i:**ii~i**'i*fi*~»;*s*~.~3**ai.*
!l_. <»_ . - ..,~ ,.,...,..,.,..",~.".",. . m..w...,w ....v .,.~.. .x o-,- ,.
~~.... ._..~ ,.. .. . . .. . ._..:_," 1 N _ .... .. - . ..a».~~, a...,.d".....b_ .>
1487 ~:7-~ »

1989 DECLSPEC_EXPORT
1990 _TNS READ REGISTER BUFFER USHORT( 1491 IN PVOID DeviceHandle, 1992 IN PUSHORT Register, 1493 IN PUSHORT pus8uffer, 1494 IN ULONG Count) 1505 ) 1 07 . ~*~irt*,rr*.*~*~***:*.i*x****:ui~:rr*r~*:*:*~*-****itaa*r*fr**~a.**~t*,4.***~rrt~l*.**.*~rr~i~**i***-*a::*
5 !! v ~, ~. ~, .. ~ ~ . _~_:.:.a~ae.:u;:.s~ «_ ,....." "», _. . ,. _ ... _. ... ,_. _.,. . .
:.:., s~ ._.,......>:..,.~x........,.~,.,~;».. .:z... .....: ,~ : ".._,., »..
__....... ...
1508 !./-+

1510 DECLSPEC_EXPORT
1511 _TNS WRITE REGISTER_BUFFER_USHORT( 1512 IN PVOID DeviceHandle, 1513 IN PUSHORT Register, 1519 IN PUSHORT pus8uffer, 1515 IN ULONG Count) 1516 %'1 1517 %/=/ ;DesctipL~iaii 1518 ~J j;
1519 Tl ~ri~i~roament_ 1520 ll:
1521 J=/iteLiirn:Yalue :';,.;,,==,X=y- . .... _....
1522 l!....,..
1523 %/
*t:,*~*t**~*~x*rtr***r*i~-*r**ir** * e-xy-t*f x-tyr** t* **~rt:*~r,r**':~e-i:*i*~r~iw.~r;4~. *x**~*t~***air**.,.
1524 /!..
..__ ".. .~._,.<..<..~..:~:.s..~-. ..__,.... .... _._-,... -r ..r.~..~-<-.: ~.-v~u":~ =:~. _.__~_:_..,. .._..:...n._>.....-._ - .__~..:.._s._t~-1525 ( 1526 ) 1530 ~Y

J~;;****Hi~i***i*Aie~~ti*i~f**f1**it**~**if*Ai~d~****~iM*****N~r*<*.1i*t*fr*~ii fAiiY*ri' .,c"",. ....,.<.. . . , s.... <.._ s., ... ... . . . .."..,k ,. .: ~c... ..,<.
..,.v. ..v , .. ,H- e.~x a., r~ n n~r . . ....
1532 7%:=ty 1534 DECLSPEC_EXPORT
1535 _TNS_READ_REGISTER HUFFER_UCHAR( 1536 IN PVOID DeviceHandle, 1537 IN PUCHAR Register, 1538 IN PUCHAR pucBuffer, 1539 IN ULONG Count) 1590 -/!
1591 !!.°~D~sc=iptioi~.:?
1542 lY'°............. ....... ..
1593 /lEnviioa~eiit::
1549 !!.,.. .. .. -..~~__.
1545 /.YAexu=a.yaloe:
1546 7.7.~..~.,;
1597 ! j__°....
PNnt~dbyCRi8PvB21~ 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 20 of 39 *sir'*,**ar.i:.r,e*.a~a*:*,G.r*~r*a',ir.+*ay;:*tai**.*.s.*:*i~*,*das:*'~ir*a**~
s**irtia~',+aa*ris;i:**a*;*aii.:+
1548 /r ~. " ,~ . ~. ..._.. . ~ , .. ". < H _ ,..".
,°...w _.a..,.".:"."",._~. ,.., _w_ A, .,.. ~,.:X"":"_.mc. ....._..,..
,.., . ,w..,....". _ ,",.. .. ,. , .. . ..~,... , , 15 4 9 ~( 1550 ) 1552 ° ~ *'~s3*~*+ss%i:xrw**'ii's*i*,iaaliy,ns*s.:.s**.i-v' ;~a,~t*.*s.r*~iss*sfsi***wi*i* dr,~w~y~i~i.atri:~
~~__,r";n..m...;.is...~-w,:~;....-....r . . ... >... .
",....,..........u~.~::.e.. ..,."..,n,. ..,., ~,-.~~ .,.,.~...., .".._...u...._.,.~..,~._.._..__.w.

1555 DECLSPEC_EXPORT
1556 _TNS WRITE REGISTER_BUFFER_UCHAR( 1557 IN PVOID DeviceHandle, 1558 IN PUCHAR Register, 1559 IN PUCHAR pucHuffer, 1560 IN ULONG Count) 15 6 9 'r'!' 1571 ) 7 -.*~r*y:****:rr**r***r*~w-**~*>*y~vrt*~-r~;r-.k-r**;*:rw**~.*rx;c**r*sst*****r*+~***~*t*~-***~a*f~*
15 3 I/. . .. . , , . ,. .,_.:_,...,..""x..~.z_ .__ ..:...: .., ....:. ~ .m .. ....:
,....~,:.,.A,~:...._.... . .:. ...... ._ ..... ,... ..... .. ~:.....:x.... _ ..~..........:.....
157 4 '/:I:-t.

1576 DECLSPEC_EXPORT
1577 TNSAcquireLOCkP( 1578 IN PVOID DeviceHandle, 1579 IN PLOCKID pLOCkID) 1590 return TNS_STATUS_NOT_IMPLEMENTED;
1591 ) -sYrii*a*#vr::yi:ih**:'**~~r'*;i:'ia*sr*~**xsa*r~e.'~r~wr*-r~eik*~**, -~*rx**~*v~***rwr*. ***,r~r*:~r**r** ~ »,rYaa~
1593 Ll !! ~u'x~w~,~,...>daea:w:~. ..:..:a~_s~~..w.za,~a,~e.u,a,,~.,z..o, ...~"w.~:aa'.~ a~r~,~,>.~".~.... .,_~.~..:..w":...,,...,»rtw.~uw 1594 , .K

1597 _TNSReleaseLockP( 1598 IN PVOID DeviceHandle, 1599 IN PLOCKID pLockID) 1601 II Dascr~p~~on,-1603 J%?Eiivi~so~iment:.

1610 return TNS_STATUS_NOT_IMPLEMENTED:
1611 ) ylI**'~*****'~~'~'**waa*f»+*.a.ti+r*a.*a~~aaa*:~..r*****tr~*.***dr~+~***~ft**s*
w*i***~.*s*s~i .,. ' . :., ,..: . ,.: , .:.: _ _ --; - ~ , . _,: '. f :.:
aaa._..:,re.;.~,ha,e.., ... ~.. ....,..r,. -o- -->... ., .. ..-. ... .. .-. , -.. H_.e-. . -.,-.. >... . . _ ~:.a...r,~-e. s. . >. . _.,.
1619 - _ 1615 TNS_STATUS
1616 DECLSPEC_EXPORT
1617 TNSQueryLockP( 1618 - IN PVOID DeviceHandle, 1619 OUT PLOCKSTATUS pLockStatus) 1620 j%:
1621 %%y:Deacr3.piion::
1622 ~1'1..... .. _ ..
1623 II Envixoa~erit 1629 %I:
1625 %=l'~~te~urn' ~Yal'sie:
1626 ;/J,~~' .re_ ' ...__......
1627 %'r'~-'M' 1628 /~*~"******'*******a*aaaa*a*:-wa***a***
a:*~s*+**ra******t*ias***a******a*******x~*a 1629 '(-,.~~~.~.' °wa_: :. .... . ...:... ... ._ ~: . ... ... .. , . .
__. ...._......... : ,. .:...__ . .:. . .... -Pf11K1a try CR16P v6.2.1v 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 2y of 39 1630 return TNS_STATUS_NOT_IMPLEMENTED:
1631 ) **i.*a.,'i,*t~l.xt-****~r~**.st**s:i'***x*xx~*w**k+i f**r*. *.'**.******* ~.*+
* **.fr;r~irx*****rs;i 163$ ;7l , , a "~
1636 ~./_+N~~ .~'u~-~~ "'' _, _=::>~~..-... .,._,.... . ~__.;....._. :~.
_~.... .:_.:_T -:. _ :_, ...~.~,_.-~__, __ -, ~-1637 TNSySTATUS

1639 _TNSAllocateLockP( 1640 IN PVOID DeviceHandle, 1641 IN TNSKEY Key, 1692 OUT PLOCKID ~pLockID) 164$

16$0 16$1 .* *.'i*.* +***-**i*&**.'~ *****~i~i.;e.
16$2 16$3 return TNS_STATUS_NOT_IMPLEMENTED;
16$4 ) 16$5 1656 /j***a"r**,t*-x*+-r*>*****-r*i~~xx**x****x**-rx***.x*~r********.t,****x**t**r*********xx**,*
16$7 ~ j ,~.>. ~ , 16$9 DECLSPEC_EXPORT
1660 _TNSFreeLockP( 1661 IN PVOID DeviceHandle, 1662 IN TNSKEY Key, 1663 IN PLOCKID pLOCkID) 1679 return TNS_STATUS_NOT_IMPLEMENTED;
1675 }

*~;:4is:*s***y:ri:***x*:as**~rrs~a*nr*+*xa*sa**:r*ts*****:***:x*s*xyx,4**f,****
arx~**x~x3**~*"i.
1677 /I ~ ~" s ~ ", ..........,_.."N ~,.~. ....,y.,.~
~.~~:::~K,~ ._..~. ri_..._.._._.....~.b"."._._._.._. .~_,__...-W..._.. .._._ _ _ .__.
1678 /j .t.~4 1679 TNS~STATUS

1681 _TNSNOtifyCPU( 1682 IN PVOID DeviceHandle, 1683 IN TNSCPUID CpuID, 1689 IN PVOID pMessageHUffer, 1685 IN ULONG MessageLength) 169$
1696 return TNS_STATUS_NOT_IMPLEMENTED:
1697 ) * *.a.isi.**,**a:,~i;+*** s:~i*~r*ia-si*aiiia:i.°i"* s~.* * ~.r.r* *.~
s * ~:i ** ~:r~* ~ i:*.i. *s,i.i.* **+* *~-~r* **~, a * *;~:
1699 j/ " .r~__~,..x. .. ..~_. _~-_ ._._...... _.. _ . .__. _._.._ _.,~~,~...
,_._._. , . .._..
1700 JI ~ ..

1702 DECLSPEC_EXPORT
1703 _TNSNotifyCPUSync( 1709 IN PVOID DeviceHandle, 170$ IN TNSCPUID CpuID, 1706 IN PVOID pMessageBuffer, 1707 IN ULONG MessageLength, 1708 IN PVOID pCallback, 1709 IN PVOID pContext) 1710 %/
1711 Yl Description:
vn.M.eeycwsP.,e-2.~~ 9:03 am Thursday, 30 September X999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 22 of 39 1720 return TNS_STATUS_NOT_IMPLEMENTED;
1721 ) '. -*hiii,f**asf~ie.,i**ef~:sr:*s*s~*i.,vx.**~ii~:,i~r*ri*'r*:ew*~y*r*~*sv.yr*'*rr*
i:x***.~=f.xsiw*t*w*i:ia 1724 /l ~ . ~, .. .,.._.....~, .__..,-.~,_, ".
~~k' 1 . _.,~-::_.-:__-.~Ø1d...p"xe.a.. ......:.w..".'<i.~.:..t.::ali:6;..:.
5:.....~e.," . ,.,.. ..,.... .. ".,~"".,5 ._.u..""._ ._ , ,...,...
.;.._,»7....:"..'.,' .
17 2 5 /,.1~.
1726 TNS~STATUS

1728 _TNSQueryNotifyStatus( 1729 IN PVOID DeviceHandle, 1730 IN TNSCPUID CpuID, 1731 IN OUT PTNSNOTIFYSTATUS pCpuNOtifyInfo) 1741 ( 1792 return TNS_STATUS_NOT_IMPLEMENTED;
1793 ) 1751 IN PVOID DeviceHandle, 1752 IN PVOID pCallBack, 1753 IN PVOID SysParml, 1754 IN PVOID SysParm2, 1755 IN PVOID SysParm3) 1766 return TNS_STATUS_NOT_IMPLEMENTED;
1767 ) 77 .. r**.*~t**~~rs****i*~-i**~***~i~t**..rx~a-c**'*s:r***i*yrf~x*ir**~*+.**rt*~+:+:r*~*.x*~*~***~c**arx 1 ~ I'r ~ xe.,.._.._.,~....=av~:.aass:v..~ .x~,...~.-,~.,. ,.aa.'_m_.a, e, _ ~.~_.,: _~?..s',. . 5c.., _r,-.-.~...w_.__s....._.. x . ..,_.....x ..._-, ._.,. __._ 1771 %f-,"a 1772 TN~S STATUS

1779 _TNSRegisterNotificationCallback( 1775 IN PVOID DeviceHandle, 1776 IN PVOID pCallHack, 1777 IN PVOID SysParml, 1778 IN PVOID SysParm2, 1779 IN PVOID SysParm3) 1781 Jl~Des~x~'piion;
17 8 2 s"/.~%
1783 ~%pvisaiaii~at<
1789 ~"%:
1785 a%sRei-ui~cY~Sia7:lae~
1786 ,I! .pat _."........
1787 /%.~y.

:s!*:yi:~,*411*'*;;:itw*w~lii,dYrr.'~*~tf~1i''!?l~f~*ar**rA~Ywr~rr*Yrs*H***f-*~:.~i*'Irf**~isrit*l.;ii:**slryredlfl~*.efY~?*ir~ftliv 1788 //.,:,~»,~aa,~'...,..ro..,..,_~,.,.;,.a,.e:_ ..,.-_._,~~..a.__,uc..~.,.,a_~-..;_.. ,._.....m.._.:e,~,r~aarsrex;a;.ae..~-.m,~..,a.,a .~~r..i""..,:,:._.__...._,.
1789 ( 1790 return TNS_STATUS_NOT_IMPLEMENTED;
1791 ) ~.x.ebycwsv*e.z.i. 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 23 of 39 1794 ~/~/-*.iiw.i****y4~.,r*w*.*yt*.t~.;,*****t*a:i'***a.a*~_*a*a.i~aaaaa air'a..r**as.w+ai-a*a~a*»:****a~as 1795 /y~+~~p "..°°.~~e_...,.>...~.,.e~...~~:ww. ...._..~_ ..v~s~
_.,..~..."_..,: v,........~ .._._.....~............,. ~......,."....., 1796 TNS~ STATUS

1798 _TNSDeRegisterNotificationCallback( 1799 IN PVOID DeviceHandle, 1800 IN PVOID pCallHack) 1809 to*;ity~~:~:~y;ra 1811 return TNS_STATUS_NOT_IMPLEMENTED:
1812 ) 1815 **ftaiy.rr~~ii..r:f.rr*t~w~.*f*a~******+a**.r**r~ai*i+*s*a*a~~aiaX.*sr~:-,r***~f*+o*ai. a**
... ..". . ,: , ._ 1816 ~// ; .-..,_. __..>.. . .-~,.... x_~.~_.~~:.. _...,._,.._" _._x_~_ .,. ..
.. .. .., ~..",.... . .. .... . ....,. ...... .......

1818 DECLSPEC_EXPORT
1819 _TNSWhoAmI( 1820 IN PVOID DeviceHandle) 1831 return 0:
1832 ) . ,** ~iy.rtxts*:wa.*Hrxa~.+*.,r*dr w * *si-r* *rtr* **-tsf x~c*:era**.rr* t s *'a *x'r*:r*~~sr*rr ~i~.t*~*ar * iH.;"sr*' 1834 JJ,~..:.-:~a«,. a_~..,~.....»..,,...,.~,..,~...,e:~..2tM;..,t ..
,m,:..~rao->;.".~.~..__.f_._dr_....rr..<....."...>,ra~se~~a~-'-' _~..,.,.,....e..~.~e..x~..x:.~.:
1835 %:/,'~

1837 DECLSPEC_EXPORT
1838 _TNSReadOrdinalCounter( 1839 IN PVOID DeviceHandle) 18 4 0 %:%
1841 %.%c=ipti;oa:
18 4 2 %'/:
18 4 3 '/;~l~Eavi="oiimen~:, 1845 °l:/*itetiizu=?YaTtas:
. . ..., .. .:...-:.....:...::. ....
18 4 6 ~'/?:i ~~ ~-;' "-:
1847 !7%/::.>.
1848 , fia*is*awt**i.**a~.******,i*:~t,x*.rnx*i.*axwse-is*aw+yii* ~,~atw**+
:r*+ tf.~ *aaev. ~.ra ~/,x=,~ ..:... -_~..a~r.>-,~.~...--.___. ~a:~xa>.,.r< >,.,_ -~w> >-_r,. __ _.._.<_....,.. .. .__~.<,..._ .-_,.r _ ......._ "...,~,.~~.,....

1850 return 0;
1851 ) *r~iw:"s..rr.r.ry:*,Fwr a~r~::~ rvw *,~.rw* *x ** * w9.*** * v~ ***x ryas***x**bir*x axx~sixxx r-ti~~r**yxyr.*x *.i:x 1859 .r l, .."...,_...,.c,m..."",...,.ro.,......,", ._..a.,.,.;
,.,...""..,....,._.....", . ,,.,-x".........,._.- "....,... ......_., .:.,~'e..<.um~.;4.;~n 1855 JJ '+~
1856 TNS~STATUS

1858 _TNSAllocateSharedMemory( 1859 IN PVOID DeviceHandle, 1860 IN TNSKEY Key, 1861 IN TNSMEMFT.AGS Flags, 1862 IN TNSMEMSIZE Size, 1863 IN OUT PVOID 'ppBuffer) 1864 ~/;j 1865 ll,Descxiption' 1866 J%' 18 67 :/>/:':?ErivironinenC

..........M_............_.,.~,.,._,.
1868 %'/
1869 -!%''Ftetuia~:value=
.":'..;:;: ...:..:...... .......,:..:
1870 /!.. ~.".,_,_.
1871 %'/~-a*ai*****ia**s****~.r*,*r-*.y,ty*
:**nir*xswi~*xs*.t.i.i'*ara*a**:wa*tra>y:~~.*s '***- :vr~>a.*a.*~~.
1872 // a a ! ~,.~
........._ .._ _...~... ....:~..,.. <........:...".s..,....~, u..~ .._..
_..~..__..._ a ..,.:...a::....a,a."..~ -__. . ... , .,.._..,_.....c..ae~...".,.......~.
1873 {' -. - ~. ,-1874 return TNS_STATUS_NOT_IMPLEMENTED;
1875 ) 9:03 am Thursday, 30 September ~ 999 File: D:\nt4DDK\src\tfmesn\tnsdrvr\tnsapf.c Page 24 of 39 1877 E//*-a~+~r**..ti*as.i,+i*+****~~r+r**r*w*.r;,*+****i.;*,~****~aa*art**+t.i~******a**
***;*:*-r~i.~i r. ..~,., .. .. , ...~. ~",.,~.:-<..r.:9:~ ...r., .. a,..... . . ..".x,-aa.,..
n...,. a.Y.....u. , . - ..,. . ..,,...y ..<. a.... .... ..
1878 %s/y~~
1879 TNS_STATUS

1881 TNSFreeSharedMemory( 1882 IN PVOID DeviceHandle, 1883 IN TNSKEY Key, 1889 IN PVOID Ptr, 1885 IN TNSMEMSIZE Size) 1896 return TNS_STATUS_NOT_IMPLEMENTED:
1897 ) 1899 t**,v**xs~t**,r.rst*t*~r*+~.iri-n**s.** y***~-:~~r*at*~ri.*-r#**yi:rr*~irfi.~*t*i~r+sr*s~~.*,r~*~
'// , .mss.. _ .. r... . , ..,>,. ~".,.,_,wa. ,*. ". .. o . ,.-r_ ."._ .,.".--, _ ..,_... _ , ..N o , .. .,r , ...,..., 1900 ~!/ ,+
1901 TNS_STATUS

1903 TNSReadSharedMemory( 1904 IN PVOID DeviceHandle, 1905 IN PVOID pSharedMemoryAddress, 1906 IN ULONG Length, 1907 IN PVOID pHuffer) 1918 return TNS_STATUS_NOT_IMPLEMENTED:
1919 ) t,N*tt~Jatf,~!~l.lni***~lilii9i'sf'**~13'Yf!!!~*~**'~*~*s!W Yltit3!*llHlFl4rW
~~~l~f.r.i*:*- !~a*~f*~!**f.l:l1 1922 l! ;"~ ~ ._ ...98»n#,.,..,..-.:'r.C..6c~ <-."a,. w~ x=,',aGS~.a:
,a.d..,."ana.ava2dvs~iGe.:.,......,u..,z..a,:.....C:; ........,...", .w4-~7~Tx~a..3~..>am-Au hzx cSzLfF".
1923 /,/~ Y
1924 TNS_STATUS

1926 TNSWriteSharedMemory( 1927 - IN PVOID DeviceHandle, 1928 IN PVOID pSharedMemoryAddress, 1929 IN ULONG Length, 1930 IN PVOID pBUffer) 1939 rs~s+**,***r+**~,*#****t* rr:***x***ar*.ty .....,".» a-,..x,.,~._ _ri... ~..._..__~ ,_,<...~.~""_ ..~

1941 return TNS_STATUS_NOT_IMPLEMENTED:
1942 ) J/*~,'r.i.~la+.t*r**.i,ixw.***i*s*.e:*+***.'ef~a,s..*,rr.ri:++.aa*.i.ir*.r.i,vw ***s.,:fis~***,i.,t'*i*;a.*:.ir,y.t.+i 1995 ~/ .E:~"'.,... .,~., . .....,_. ..~ ~.u.~,... w..<. , ~~ ,..~..."..~;.", . ...... _ : ,., n......
1996 TNS_~STATUS

1948 _TNSDmaReadSharedMemory( 1999 IN PVOID DeviceHandle, 1950 IN PVOID pSharedMemoryAddress, 1951 IN ULONG Length, 1952 IN PVOID pBUffer, 1953 IN PVOID pCallback, 1959 IN PVOID DMAReadCompleteComtextl, 1955 IN PVOID DMAReadCompleteComtext2) 1956 %Y:
1957 !.'!s.°DescFiptiqri:;
Prindd by CRISP v6.2.1~
9:03 am Thursday, 30 September ~ 999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 2S of 39 1958 '!.%:
1959 J/~Enviromnent 1966 return TNS_STATUS_NOT_IMPLEMENTED;
1967 }

vssi*'w*w~~:e.y;*~ * s:*~r.My,~r+.+* *:*i *+tHi.>~w.r* w *~ *~*~ w * *~ivi..x *w *ywy: ** ** er* *-r*a *-t *w~t* ** ** x *;-e»:*
1969 ay.,: ~,,:m :.:. _.. .,~ ~.:.~~:,;~._..... ..:.: " ~:~. .> : .:: .
.u...:. :. ......: :... ... ..: .. .:. ~ >... :.::..;,:
197 0 %J:,-1971 TNS_STATUS

1973 _TNSDmaWriteSharedMemory( 1979 IN PVOID DeviceHandle, 1975 IN PVOID pSharedMemoryAddress, 1976 IN ULONG Length, 1977 IN PVOID pBUffer, 1978 IN PVOID pCallback, 1979 IN PVOID DMAWriteCompleteComtextl, 1980 IN PVOID DMAWriteCompleteComtext2) 1991 return TNS_STATUS_NOT_IMPLEMENTED;
1992 }

1994 *+*i'~"w**wr*.r.,~t,ci*af*i*n~#rw~r*t~id.w*+,r**ii.*w~~w~r,rw**,r is*.~.**e,i**N~~.*w * *-~*.~~r:i /~ _.. .,.,....~ ...M.k~. . ,.""~.,..~.~.a...r.. >. ,. . .~ ., ._~ ....
..e..,....-..-.>_.."...>.."...., .,w.. ..,>a.~>...,.,.>. <..,.n.",,,..,~..,x., 1995 ,Il-~: ~i 1996 TNS~ STATUS

1998 _TNSAllocateWorkQueue( 1999 IN PVOID DeviceHandle, 2000 IN TNSKEY Key, 2001 IN PULONG pQueueLength, 2002 IN OUT PTNSQUEUE 'ppTNSQueue) 2013 return TNS_STATUS_NOT_IMPLEMENTED;
2014 }

v ;' ;7i:* s,'t;**a-t~t:x:*r*yri~;iy* ~w~r:ii s;r~ w~~v:* *~~,i~* * w r~ w~t w le~:~i:iv** **is~4.nr,'t-f t* f:~+f-t:~t* t*rt~~x*a:r:: rar.
2017 // ...m. ____.w.,... a.,s... .. ..>.,~."-.:. v...." .., . .i.",.,_,...
,.... ....:,.. .~. _.c ._.... ...s: ,.,:,~.a....., :.:...., _,.,. .., ,."»,.,"
~:;..n..;r~..r c:._~~.>
2018 ~/. jH~~.. .

2021 _TNSFreeWOrkQueue( 2022 IN PVOID DeviceHandle, 2023 IN TNSKEY Key, 2024 IN PTNSQUEUE pTNSQueue) 2025 ~J7 2035 return TNS_STATUS_NOT_IMPLEMENTED;
2036 ]

//*w*******wi*.*******w*a*r******i**wa*>*********~*********e*w*r~*x~*******w*at ~>tr 2039 //-.t-:,..._- ,_.»,.. ..,_.._ . . ........... ..... ~ . . w.- ,..a... .
.....,.>
P''"°'d°ycwBP"wz~~ 9:03 am Thursday, 30 September 1999 Flle: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 26 of 39 2091 DECLSPEC_EXPORT
2092 TNSInterlockedEnqueueTODOP( 2043 IN PVOID DeviceHandle, 2099 IN PTNSQUEUE pTNSQueue, 2045 IN PVOID pItem, 2046 IN ULONG Length) 2055 ~t~s*'~ t*x+#y*.*r* a~~~ aura ratss,t*a*ay_ir* r*-a y,*.*ie.~rt ,..,w.,.... >_...._..,". .e"_>.."": .,...,....: _., ,...>... r ;,:,.H..,.
>....,.

2057 return TNS_STATUS_NOT_IMPLEMENTED:
2058 ) 2061 ~//'~'*:'"**.**i*.d.aaa~isf.a+*****-w.a.w*k*L,~i.+~ a-+.i..f* ~i-**~.r-.a~s*.i..;,.f;.~.airtrt*s',,t:****+i:**aa*~.r*t+* ' ~. ..._.....:. _ " . _:,m: ..,~.v-~:~. ._ ~.: a., ..~_ ~_t._. .... - ,.,.,~.-.
_<,.. ,__ .° ,.,... . .:~..
2062 /!

2064 DECLSPEC_EXPORT
2065 _TNSInterlockedDequeueToDoP( 2066 IN PVOID DeviceHandle, 2067 IN PTNSQUEUE pTNSQueue, 2068 IN PVOID pItem, 2069 IN PULONG pLength) 2079 i 2080 return TNS_STATUS_NOT_IMPLEMENTED:
2081 }

-irrss:Y~rtf**,tt**,Max~~r*~-*~*,,t xy+*iyvryari.*°,ta*~,t*+~"4*vr~**xwws*rvs~*~**s******a*+.ir**+**
2083 ~lI -~ ", ..,.%..,. .,.'.,.'.f3..t.~.i~~...a>,.,Cw.S~,vL.t"..m...:.,... _ .,....YG,. r ___ ~_..r.~_:".i~t3'.1_fi:n W .,...,..n .... Y.. >:f2.:.fLY c.L..,... .... .
2089 JL~_ m . __..._~.__ ,.,.
2085 TNS_STATUS

2087 _TNSQueryQLengthP( 2088 IN PVOID DeviceHandle, 2089 IN PTNSQUEUE pTNSQueue, 2090 IN PULONG pLength) 2099 *i~tr°t*°t*a~+.s* *-r****tie*rrt **yr* r~.rf rxa.'i - .. x ..,..
2100 ..::. ... . . ~s.:_... .._ _.. .: ». . ,.,.., . ... ...:.,.,_ ., _ ...
2101 return TNS_STATUS_NOT_IMPLEMENTED:
2102 ) 21 O5 I ~!r~'y'*~''" * a *.i.a*+** satra.aart:+.* *w *;r a~ a+* a a+;i:* * a r**:e:r"+a.aa **~a~:++:~r,a a ~+i+~** as ~f yr.as'i .,~,...r~r~.~.,.:,..,. .,.,...,.::...~,~. . , .. , .-..... ..... .>..,.. ".,~
~ . .. .. ,. ... ... .... .. .. . x ,s,<. , . < _. >.,r.~.,_ ....
2106 ~!;~

2109 _TNSQueueHeadP( 2110 IN PVOID DeviceHandle, 2111 IN PTNSQUEUE pTNSQueue, 2112 IN OUT PTNSQUEUE 'ppTNSQueue) 2113 '//:
2114 //'Description' 2115 jJ'._....__..
2116 ~IIWne~,i~oilmen~'~.
. ..._..m..._..,._ ... _._............_: _.
2117 ~%:
2118 '/!''.3tettua value.;:
a~_..;,:... -..., 2119 %.l:°;;~.'~,A:;
2120 %!
~!-aIr*.*+* <Y* Jr!* * ai:l.f as aA**** ** i:aai *t**.+-a.iii.**yr.,~.i.t.
atala *,i:~'a at+.i ~irArAr a* *+1i ~ s*** *.!~?~s4* *
2121 /l . ", ~: _;, - .r -~.. , _ w.. .. . ~ <. . , . ...... ~;,..;~ ,.- . . . A v .. ,A
_~, P""~'°°~'~B°"°w~' 9:03 am Thursday. 30 September 1999 File: D:\nt4DDiC\src\timasn\tnsdrvr\tnsapi.c Page 27 of 39 2122 l 2123 return TNS STATUS NOT IMPLEMENTED;
2129 } _ _ _ 2127 /x.t*i.**i.,~.**~'.i*a*.a***+*s + **********'~. ,f ***:i.~*s°**i.,wws.**,t-irk.*~*3.** .'-'i'.:.r*i:+*~i,v.t::
l .._ _c,.e~.,a.sna.~,.,_.~.xF, ,.,'. . _.m.. a ..a, us,:.: ,..."~.......e .,_; 2s~~ a~"x_..xr.~e~.,.~. a" ,...,. ",_ ... .. "~.,..s.:, ,:.:..-~.,.T~.
2128 j/-~' 2129 TNS_STATUS
2130 DECLSPEC_EXPORT
2131 _TNSQueueTailP( 2132 IN PVOID DeviceHandle, 2133 IN PTNSQUEUE pTNSQueue, 2139 IN OUT PTNSQUEUE *ppTNSQueue) 2135 ~l 2136 Jl:'Desu3 io3x-.:
.. . Pt<.._~.~..

2138 %r/::Euviiiomaent~,;
2139 Jv/
2140 J'1:.':Retusgvlta"lusz 2141 !% , ~ ..

214 3 ./'** i~* *i~ ~* ~°'.*~w-*,y**:w**d.* tie-.r* *r*a,ryr *4*.*~
**+* f ~.r,w.~,e.*.r?~***r~nni.* * x:*~ *i.i: ~ts.**i.*~*~:' ! .a:._._..,m.K"a,,r~s...-~...:a:~.~.:_,,:... ~ _~~E._-s,r...,x._..~...:w-~-...c,..~.~.-.,~~.~:::.,z,n...~. -~__-e.. _nw._,_,_._..,...
....r,s...~.,...~,~.. ,r_.._..
2149 ( 2195 return TNS STATUS NOT IMPLEMENTED:
2196}

2149//*is'****+**fvrr*x+**~~-***-rfryrwey,wwxri ,:acre:~.::s:ar..,.a~z"..,...:
.~.<.znw:ae>
rug.
:-z,~
:::
x:
::re r ~
:~

. .
2150. ...
Y/.- ...
~ .
:.
.
...
.
:
.

2151TNS_ STATUS

2152DECLSPEC_EXPORT

2153TNSQueuePayloadP( -2159IN PVOID DeviceHandle, 2155IN PTNSQUEUE pTNSQueue, 2156IN PVOID pItem, 2157IN PULONG pLength) 215JT ~~esC"p~~q;

2160Y:7.

~..a~
J/::_i zii ~'.~_.._ .

2167( 2168STATUS_ NOT_IMPLEMENTED:
return TNS

2169_ ) 2172 //*~~aa';~r*,~r'~x,t.~r.*.sa tia*.***s,*+**x,~.*t,*.**,.*;r***+***aa*.*s*r*+**,r.a.*i**'a.**a<ai*.~:
.~. _ , _....
.<P.,<:.~:a~:.a;."-:,u.:: . .>....."-..., ,.".».._...-..,.~.,. K ,.~-..-,.~.b.."?v.".-., ., ",".,..~, < ..r..,....~.,~...sm>,.""..,...

..:_..

2176 _TNSQueueNextP( 2177 IN PVOID DeviceHandle, 2178 IN PTNSQUEUE pTNSQueue, 2179 IN OUT PTNSQUEUE *ppTNSQueue) 2180 l!.
2181 ~I".DgHC~°~""'~'it3 2182 yJ....
2183 ~/:-3;tiv3eaiw 2185 YY.: ~tefnia--.V;alue:!
.....,.. ,....-._.4..~._..
2186 /!~:-~:,~-~-",.
2187 %'J~~

//*t*~r*.~x~~+x,wa.,~:**.+*a*"t,.a:;*s**v.lia.*s*a~+.***s.a,it*,*.*~**+r*wia.,r .~r;t.*rs**x.s.+~*~'i.;.,t.s>*
.. .~. a.~.>'~m...'Lav.:,.,~ .a...,.v.. , .~ _...a...~,.,ke.R,.."..w,v. "~, ,be..,..:d.~ , ... ~ .~-."..:u"m..~'.'-xdu~a.s..vr..a.,.,~.,.. ,s"..e.~ ._ .,gym. u~,wT,.a,>.,. .. ..
2189 ( 2190 return TNS_STATUS_NOT_IMPLEMENTED;
2191 ) 2193 //"."~'~"'~'t*;k~~;F".a~**snF'*.~,.*ay;y:******,xi*-*s**.*~rt*~*~i.s~fr*+ss~a.*:*et'~°r"~:A~*.4**~xy~lr**~~:ri~ti.'.
~~cY%.MW k.tEds.,wd~.a_trH2a-.5a~ s..-.:.;=t-z,.,ean,~.cl~-_a~a,Y.o."_..,m,a,.. ..p. .,vsa.,ro,_..e."_~ro.".m....
a._~e~.et.ara~swn~f::~ab:.

2196 DECLSPEC_EXPORT
2197 _TNSInterlockedInsertQueueItemP( 2198 IN PVOID DeviceHandle, 2199 IN PTNSQUEUE pTNSQueue, 2200 IN PTNSQUEUE pTNSQueueInsert) 2201 Jl.
2202 Y/'"Desctip't3on Rlra~byCRISPvE2.tx 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 28 of 39 2209 '//~yEnvatoniuerit-2205 '/°%
2206 %:%yFtetiizii:yYalu'e 2207 17~:a~-a~;:;, 2208 ~/:(~>_ >
2209 ~/"~.*i********* **********H:**** r a ***archery****** *~+***i.***x*a*a ****r*****:i;~
_ ._. . _.._ .. ..x , .~..: .. ,. ... ., .'.. ., .. "., . . . ....
2210 ( . "' . ... .~ :. ..., - __. .. . ,. _ u>., . s..,... .
2211 return TNS_STATUS_NOT_IMPLEMENTED:
2212 }

2215 J/*'**+**** .4*******e**~** y~*****-x*:***.***y**~r.**~*ry**i*~r.*:***»**~*.*,***.*** n.x*~-***.*;*
2216 ~J,~*~'r -....<_. ..,...,:.. "..A.:, <..... .. ~.:.- .,.:..~~, . ..
..,~.,: _-~:,: ." .,.,.,.:. .<..:..,:....:~:.:.::

2219 _TNSInterlockedDeleteQueueItemP( 2220 IN PVOID DeviceHandle, 2221 IN PTNSQUEUE pTNSQueue, 2222 IN PTNSQUEUE pTNSQueueDelete) 2223 Jy:
2224 !(~°Desc=iptiqn':
2225 ~// "..
2226 'IJEnvirpninent::
2227 //:

2231 ~.~*

2233 return TNS_STATUS_NOT_IMPLEMENTED;
2234 }

2236 '//'~n~*~***s*i*****»:i;i;o-.*ta*a*i***vi.s****a*sa..t*ti*c-i***ai*"**+i.iiayia****,**x;v:*a**+*
2237 / f.''°°".~.a"~ ~:~.......~:.,_-.>,"" .._:~
.~,vw....,..:.;M";<.,:._ .:..,....,~ ..-.....~. ......._:~ ..y..... .,.-=r..._...:.....,..
2238 TNS_STATUS
2239 DECLSPEC_EXPORT
2290 _TNSQueueItemInfoP( 2241 IN PVOID DeviceHandle, 2242 IN PTNSQUEUE pTNSQueue, 2243 IN PTNSQUEUEINFO pTNSQueueInfo) 2259 return TNS_STATUS_NOT_IMPLEMENTED;
2255 ) 2258 al's**.***** **-*****.*****+********I'm'~** *
****r******~+********:r***;n*.1*s*.*,*****.*
...a _~._ , . x ,. ~~".:yr ._.,, ,.,~ ,;.... . ., . . - . ~ ..
2259 /I_ ~ . . _..>A....>.~_ _ . .:. ., .:...... :,...

2262 _TNSGetFirstDeviceInstance( 2263 PVOID *ppDeviceInstance) 2264 %~!:
2265 '/%!'~'Desc=i ion:
Pt 2266 :~:y,.'_.: ~.__....
2267 /! Dsav.isronmeat,:
2268 yf 2269 %!.-=l;etriruy9alue~_ 227o fJ/~ ,;~ .., zz71 J~.°-~.

r/I**Mni****3a;r,..**r*~*x*.**sr*.#*****j..,::i*,:~i**slr.**:*.*.~.i.»*:i:~:r:.
**a*ai,r*~.*~r*~i*:i4_~**".~*~i~iya.~i 2273 {-.."..., , w..__ .,..w. .*. . . - .,. _ ... n -~ ., - , - ., "...,.. >
.... . -.. .>.~,. . ." - ., 2274 return TNS_STATUS_NOT_IMPLEMENTED:
2275 ) 2277 ~~***a,****~***s*r**~*****x.r*:*~***-***;Mi.***.rs.**w**.r .**********r*****i.****iri:*********:i.
.:_,~ ............ :...ate ..,.,..~...,. ..n.. ~.m, ...,>..".".,c.. .. , ~!:e.. , ~_ ,~,_ .~,.. . ...~..,.........
2278 !1-~-r 2279 TNS_STATUS
2280 DECLSPEC_EXPORT
2281 _TNSGetNextDeviceInstance( 2282 PVOID pDeviceInstance.
2283 PVOID *ppDeviceInstance) 2289 %%
2285 //.Descript3os:
Rlnt~d by CRISP V6.2.i~ 9:03 am Thursday, 3O September 1 999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 29 of 39 2293 ( 2294 return TNS_STATUS_NOT_IMPLEMENTED;
2295 ) .~yr~~.rxe:ir:.rw.ryw~.rrlrr:ry,s~+s,r:*~,rxr.x~i~:~s. t ~~'t~~
t,rxrie::r~re~cwx. x.ry. *yi:FS.:~~~~a:riiw~~
2299 Jl.,....
. . ,..
2300 /,r,y - °~,°~..yE...~...,:.sir-,."":;,s'".;:s,..~.".:as:.,:.~,a:~,n__,<_~:cyuc:rtc.,>w .....,..,~,..~-.~~,~....~x.,~.._Q......
y 2302 DECLSPEC_EXPORT
2303 _TNS GET_SMN STATISTICS( 2304 IN PVOID DeviceHandle, 2305 IN OUT PSTATISTICS pStatistics, 2306 IN OUT PULONG pStatsStructSize, 2307 IN OUT pMPSTATS pMpStats, 2308 IN OUT PULONG pMpStatsSize) 2319 PADAPTER pAdapter = (PADAPTER) DeviceHandle;
2320 NTSTATUS Status;
2321 KIRQL OldIrql;
2322 PNDIS PACKET MyPacket;
2323 ULONG PacketLength;
2324 PTNSPacketQueryStats pTnsHuffer;
2325 PLIST_ENTRY clientRequest;
2326 PREQUEST DATA pClientRequestData;
2327 ULONG requestTag;
2328 ULONG retries=0;
2329 int noreply = TRUE;
2330 ULONG returnRequestTag;

2332 I~1 2333 J'Ta~ack;ha'~k -WeF~eaf7.y~waana use"t'he~device contex~~',?g~"vea-up 2 3 3 4 I~~the ~call~er 2335 !°/
2336 pAdapter = CONTAINING RECORD(AdapterList.Flink, ADAPTER, Linkage);

2339 /%~'Raise"-I~R~ o,~,recent_xas~c~°swappingzwhile''sre aoa~~ete~processiiig.
2340 '/%s~Q7C~i~gipaCket,,w.; -- _,.
2341 J:1 2342 KeRaiseIrql(DISPATCH LEVEL, sOldIrql):

2344 %J
2345 /% Make~su~~vez fias?beetia'C3'3lized'~prop2r'~lyr -tt7.;iS.
2346 J1,~,;an ~ssarticn., i3sis;case ~ha~u>:d neuer~happea,?~
2 3 4 7 %'~; . _...
2 3 4 8 %'/:
2349 %~l~~hack h~c3c~ vark~~n: a=ro~a ttaaFil~iig 2350 -X:f:
2351 if (!pAdapter->TNSDriverInitialized) ( 2352 HreakPoint();
2353 KeLowerIrql(OldIrql);
2354 return 0;
2355 ) 2357 J"J
2358 !%~C"~ompute hpacket ~lengih,'~ased -nn requeax, ansl 2359 !% set the variable~accordirnJly (t3ie:packet stxucture'~iengtti-2360 %-/. wi.llz,ggt set~~ordiag to.;thls s!ariab2e) :.
2361 /.lp. . ..

2363 PacketLength = TNS PACKET SIZE(TNSPacketQueryStats);

2365 requestTag = TNSGetRequestTag();

2367 while (noreply 6& (retries++ < MAX REQUEST RESPONSE RETRIES) ) ( r~~"°~'c~sP"gz." 9:03 am Thursday, 30 September 1999 Protocol Layer j Transport Protocol Layer j Transport APi API
I I
Shim I Shim I

System o System 1 Standard System 2 Network Switch System n-1 Dedicated Shared .Memory Node Device 1 1 1 ' - ~' ' System 0 I J System 1 , I System 3 I ~~~ l System (n-1) File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 30 of 39 2369 Status = TNSInitializeClientNOdeSendPacket(pAdapter, 2370 &Mypacket, 2371 spTnsHUffer, 2372 PacketLength):

2374 %'7:
2375 '!/.~yfil in =relavent ,pactcet. fiifoimation khere 2376 t!/. . - . ~ . ..._..
2377 pTnsBuffer->TNSCommandReply = wswap(TNS QUERY STATS):

2379 pTnsBuffer->RequestTag = dwswap(requestTag):
2380 pTnsBuffer->RequestStartTSC = rdtsc();

2382 if (NT SUCCESS(Status)) 2383 PLIST ENTRY wrkrRequest:
2384 PREQUEST DATA pWrkrRequestData:
2385 LARGE INTEGER queueWait;
2386 int timeout = FALSE:
2387 int ltimeout = FALSE:
2388 int timeoutcount = 0;

2390 !I
2391 %/ flush the mead ~eply;.9ueue .In ~case a vdifferent-:-xeqtiest aimed-out';
2392 ~%/ and it'~ctuallyshows.up,.y~!e need foyfTiish the,:;queue,;fior 2393 llxsutesequent yrequests.::
2399 % J: . <
2395 TNSFIushReadReplyQueue(pAdapter);

2397 %/
2398 l~Seaei.se est atliet to'.-1 ~? .._..;.'F._......_.,.<.~,~.<..,<..~
2399 %I
2900 TNSSendPackets(pAdapter->LowerMPHandle, 6MyPacket, 1);

2903 %j~f~ys"is a lead ~peiation,.so we.~xpect:a respoiise4 2405 l~~~l°ck waiting,fqr..~rhe_freapanae~"Erom;Lhe.x~l::
2406 %T~~~,'fli3s~sn~fDQm, ~,secs ~._,. ~._.
2907 ft:
2908 queueWait.QuadPart = -(1000000);

2910 Status = KeWaitForSingle0bject( 2411 (PVOID) 6pAdapter->ClientWorkerRequestSemaphore, 2412 Executive, 2913 KernelMode, 2414 FALSE, 2415 6queueWait):

2917 if (Status != STATUS_TIMEOUT) ( 2418 PTNSPacketQueryStatsReply pTnsPacketQueryStatsReply;

2420 clientRequest = ExInterlockedRemoveHeadList( 2421 6pAdapter->ClientWOrkerListEntry, 2422 6pP.dapter->ClientWOrkerListSpinLock);

2429 MyASSert(clientRequest != NULL):

2426 pClientRequestData = CONTAINING RECORD(clientRequest, 2427 REQUEST DATA, 2428 Linkage):

2430 MyAssert(pClientRequestData != NULL):

2432 pTnsPacketQueryStatsReply = (PTNSPacketQueryStatsReply) 6pClientRequestData->TnsPacke 2439 returnRequestTag = dwswap(pTnsPacketQueryStatsReply->RequestTag);
2435 MyAssert(returnRequestTag == requestTag);

2437 if (returnRequestTag == requestTag) ( 2938 noreply = FALSE;
2939 RtlCOpyMemory(pStatistics, 6pTnsPacketQueryStatsReply->TnsNodeStatistics, sizeof(;
-2 ISTICS) ):
2440 RtlCopyMemory(pMpStats, 6pTnsPacketQueryStatsReply->MpStats, sizeof(MPSTATS) );
2441 ) 2 4 9 3 !l :R~cyclie-.tise °c~ueue., cb j a 2949 %l 2445 ExInterlockedInsertTailList(~pAdapter->WorkerListEntryPool, 2446 &pClientRequestData->Linkage, 2997 6pAdapter->ListEntryPoolLOCk):
2498 ) else ( v.i=e.e ~ o~sP.~s.z.,. 9:03 am Thursday, 30 September ~ 999 File: D:\~t4DDK\src\timesn\tnsdrvr\tnsapi.c Page 3y of 39 2999 %'/
2450 %-/;sd'o''~soiiiethy :vuaeful':?:
2451 /,~ ..:.. ...... : . ..
2452 ]
2453 }
2454 ]

2456 KeLOwerIrql(OldIrql);

2458 if (noreply == TRUE) 2459 'l7 2460 /l~ThrowAan,exception~to:our client . ...
2461 ~/l'. . . . ..
2462 %J,~'On0 2463 ~ __ 2465 return 0;
2466 ]

2470 IIr**'ar**f***,.***f.ii.~f***.~..~~ * *w+.i.*+r:*** * *** * * s *w**.**+*+*a f,r~**w* * **i:.
2971 +-~"" . ~ °~. ~<_-,_,~ -. _ . . _ _.~._ . .-, ,-.. ., ".... .:-~r.
. ...::_. ~ :..;.. . ..: ..,-. ....__ .-...w~..
//.. ..

2973 DECLSPEC_EXPORT
2979 _TNS GET_SMN STATISTICS BY NODEID( 2475 IN PVOID DeviceHandle, 2476 IN ULONG NodeID, 2977 IN OUT PSTATISTICS pStatistics, 2978 IN OUT PULONG pStatsStructSize, 2979 IN OUT pMPSTATS pMpStats, 2480 IN OUT PULONG pMpStatsSize) 2491 PADAPTER pAdapter = (PADAPTER) DeviceHandle:
2992 NTSTATUS Status;
2493 KIRQL OldIrql;
2494 PNDIS PACKET MyPacket;
2495 ULONG PacketLength;
2496 PTNSPacketQueryStats pTnsHuffer;
2997 PLIST_ENTRY clientRequest;
2498 PREQUEST DATA pClientRequestData;
2499 ULONG requestTag;
2500 ULONG retries=0;
2501 int noreply = TRUE;
2502 ULONG returnRequestTag;
2503 ULONG retValue = 0;

2505 v!
2506 /'/.hack hank ~7e~;eally wanna-yuse the-device canteat givieri~.:up 2 5 D7 l! -~y~, the ~allez:; .. _ .. . _... _ 2508 Yc~Y: ~ ...
2509 pAdapter = CONTAINING RECORD(AdapterList.Flink, ADAPTER, Linkage);

2511 if (TNSSharedMemoryNodeEmulation) 2513 %;l 2514 /'.:'Find iri$ex ihtb'8MN node , info =table,;, iaake sure 2515 /I,-.it's valid- . _. . : _ 2516 %J
2517 if (NOdeID < MAX TEAM_NODES) 2518 if (pAdapter->TeamNOdeTable[NodeID].LocationSet == 0) 2519 return 0;
2520 ) 2521 ] else 2522 return 0;
2523 ]

2525 %"/:
2526 /!"~taise'~IitQL toprevent';,Lask;,swapping;<,irhile :ve: comp7.ete processing 2527 /! 'for this-Packet:;: . . . - .
2528 /l:
2529 KeRaiseIrql(DISPATCH_LEVEL, 601dIrq1);

~~o.ae~rcR~sP~o.z.,~ 9:03 am Thursday, 30 September 7999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 32 of 39 2531 '/v/
2532 //Make suie tlriver~has :been 3at~a'S°ized°prope=iy "(,this, 3s%:
2533 /Jean asseitiaa~;,thi9~case shouldynever~happen);:
2539 %,/. ' .. ..:
2535 %;%
2536 /%a~iack'haFk wor~',ron ;erroi;,bancl~i~g 2537 %1' ~ ".v 2538 if (!pAdapter->TNSDriverInitialized) ( 2539 Breakpoint():
2590 KeLOwerIrql(OldIrql);
2541 return 0:
2542 }

2544 /l:
2595 /I~.compnte ~paaket ~.engtfi, based oa reguest and 2546 /./nsei the uaxiable accorctmglyE:(the packet ~sixuc"~upelenqtki 2597 /x:iri'll _ge~~set~c:~ording to'p;~t173;~,~wa=iablej~_ 2548 /~';=:
2549 ::
2550 PacketLength = TNS PACKET SIZE(TNSPacketQueryStats):

2552 requestTag = TNSGetRequestTag():

2559 while (noreply 66 (retries++ < MAX REQUEST RESPONSE RETRIES) ) ( 2556 Status = TNSInitializeClientNOdeSendPacket(pAdapter, 2557 6MyPacket, 2558 6pTnsBuffer, 2559 PacketLength):

2561 I?
2562 ll"wS_ef;~d3xec~ed ack~t~asld=e'sszby~node~3a 2563 %Y:
2564 RtlCopyMemory( 2565 pTnsBuffer->MACDstAddress, 2566 pAdapter->TeamNOdeTable[NodeID].TNMacAddress, 2567 ETH_ADDRESS_LEN):

2570 1~~~,~~~~'pat,~"~~ n~pr_~atioa' ~3vere~,::

2572 pTnsHuffer->TNSCommandReply = wswap(TNS QUERY STATS);

2574 pTnsHuffer->RequestTag = dwswap(requestTag):
2575 pTnsHuffer->RequestStartTSC = rdtsc():

2577 if (NT SUCCESS(Status)) ( 2578 PLIST ENTRY wrkrRequest:
2579 PREQUEST_DATA pWrkrRequestData:
2580 LARGE INTEGER queueWait;
2581 int timeout = FALSE;
2582 int ltimeout = FALSE:
2583 int timeoutcount = 0:

2593 /~s!'et~~i esi"~ aakef>:t$

l 2595 TNSSendPackets(pAdapter->LowerMPHandle, 6MyPacket, 1):

2597 %j 2598 /I'~s'~,"'xead ~pezat'~onso-swe-~expectza,.~esponaev:' 2 5 9 9 l /~~k ~;ra~t~.~~rxy~a ~'e~t~!$~ ~'~rorg~,t1'te~t~t,, 2600 l~' 2601 fJ.~.~~ .~m~seca 2602 l~:
2603 queueWait.QuadPart = -(1000000);

2605 Status = KeWaitForSingle0bject( 2606 (PVOID) 6pAdapter->ClientworkerRequestSemaphore, 2607 Executive, 2608 KernelMOde, 2609 FALSE, 2610 squeueWait);

2612 if (Status != STATUS TIMEOUT) ( v.;rm.e by CR19P V621~ 9:03 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrv~\tnsapi.c Page 33 of 39 2613 PTNSPacketQueryStatsReply pTnsPacketQueryStatsReply:

2615 clientRequest = ExInterlockedRemoveHeadList( 2616 &pAdapter->ClientWOrkerListEntry, 2617 6pAdapter->ClientWorkerListSpinLOCk);

2619 MyASSert(clientRequest != NULL):

2621 pClientRequestData = CONTAINING RECORD(clientRequest, 2622 REQUEST DATA, 2623 Linkage):

2625 MyASSert(pClientRequestData != NULL):

2627 pTnsPacketQueryStatsReply = (PTNSPacketQueryStatsReply) 6pClientRequestData->TnsPacke -2 t:

2629 returnRequestTag = dwswap(pTnsPacketQueryStatsReply->RequestTag);
2630 J,IMyAssert-(retnsii&equestTag .,..._ raquesxTag!)~F.
2631 . .
2632 if (returnRequestTag == requestTag) 2633 noreply = FALSE:
2634 RtlCopyMemory(pStatistics, 6pTnsPacketQueryStatsReply->TnsNOdeStatistics, sizeof( -2 STATISTICS) ):
2635 RtlCopyMemory(pMpStats, 6pTnsPacketQueryStatsReply->MpStats, sizeof(MPSTATS) );
2636 retValue = 1:
2637 ) 2638 /!
2639 /l_.'RecyClE hequeue;,objeet 2641 ExInterlockedInsertTailList(&pAdapter->WOrkerListEntryPool, 2642 6pClientRequestData->Linkage, 2643 spAdapter->ListEntryPoolLock):
2644 ) else ( 2645 %:/
2646 !/_-do samie~h3ngyuseful=2:' 2647 /;/- .-:
2698 }
2649 ) 2650 ) 2652 KeLowerIrql(OldIrql):

2654 if (noreply == TRUE) 2655 %%
2656 // ~hrow:aa e~ceptionSto_cur5clieat ."_ 2657 /;1._ ., 2 6 5 8 l I~~ODC7 2660 ) else {
2661 ) 2663 return 0:
2669 ) 2666 ".-I*stsw~w~~aryr.ti.ys,rxy+~rxxr+w~riyr~xi.~i~~.oa *yty.w~t*w~xv:.~,s,at~r~r+~.rs~ay,+.rs.sr,..r,i ... ~_....._..._.. , ri: _..~:rm.~ :.. f .._.-na., , >.~ ,........_,~ ~~....
.~..,.._.~.,~ . r-. .. . .-~... .. ::.~z- , ... . , 2667 //~-f 2670 _TNS GET_SMN INFORMATION( 2671 IN PVOID DeviceHandle, 2672 IN OUT unsigned char ~pMacAddress, 2673 IN OUT unsigned char ~pNodeName, 2679 IN OUT unsigned long ~pSharedMemorySize) 2689 {
2685 PADAPTER pAdapter = (PADAPTER) DeviceHandle:
2686 pAdapter = CONTAINING RECORD(AdapterList.Flink, ADAPTER, Linkage);

2688 RtlCopyMemory(pMacAddress, spAdapter->SMNMacAddress, HARDWARE_ADDRESS_LENGTH):

2689 RtlCopyMemory(pNOdeName, 6pAdapter->SMNMachineName, 16):
2690 ~pSharedMemorySize = pAdapter->TNSSharedMemorySize:
2691 return 0;
2692 ) Prt/uwes~.CRI8Pv0.2.1~ 9:03 am Thursday. 30 September 1999 Flle: D:\nt4DDK\src\timesn\tnsdrvr\tnsapl.c Page 34 of 39 *~*i.'ia***:.ie;i****~.**t*.**,~******ts~r~*****'*»:r*~.**~'w**ass'*':a**+*~+:+
*w~+.,rsii:r.a~**aa~~,~f 2699 // , ,~ . ~ . ~ r.. x M , ~~x . ....~,., .. < ".,..
2695 /J",+:.x: "' ~.....y ~c.~,-.:~,.. .. ., ~_. ... .,.~ . , f ~.. . ., ,. , ..._. ... , ..

2698 _TNS_GET_NODE_INFORMATION( 2699 IN PVOID DeviceHandle, 2700 IN OUT unsigned char ~pMacAddress, 2701 IN OUT unsigned char *pNOdeName, 2702 IN OUT unsigned int *pNOdeID) 2713 PADAPTER pAdapter = (PADAPTER) DeviceHandle:
2714 pAdapter = CONTAINING RECORD(AdapterList.Flink, ADAPTER, Linkage):

2716 RtlCopyMemory(pMacAddress, &pAdapter->LowerMPMacAddress, HARDWARE_ADDRESS
LENGTH);
2717 RtlCopyMemory(pNOdeName, spAdapter->LocalComputerName, 16):
2718 ~pNOdeID = pAdapter->TNSClientNodeID:
2719 return 0;
2720 ) *t.x*.***sw.t~lw*aiwt~~S'**-r~**yr**x,*x*xr***.***w**;irx*:*****.*:r'"****xfx****~r**'r.*w**x****vr:w'-2722 JJ ~, ~ , E ~.~.............~...... ~.....~._ . . ... ~,..._.. ~.. ~. ,... ~..~ ....q, ... , ~ ~. .~~ . ._ ...~..
2723 ~/~ r 2725 DECLSPEC_EXPORT
2726 _TNS_CLEAR_NODE_STATISTICS( 2727 IN PVOID DeviceHandle) 2738 PADAPTER pAdapter = (PADAPTER) DeviceHandle;
2739 pAdapter = CONTAINING RECORD(AdapterList.Flink, ADAPTER, Linkage);

2791 RtlZeroMemory(&pAdapter->MyStats, sizeof(STATISTICS));
2742 RtlZeroMemory(6pAdapter->mpStats, sizeof(MPSTATS)):
2743 GetProcessorSpeed(pAdapter);
2744 return 0:
2795 ) J/*ki~*x**.rt*wTr*i~'***'Nr**xrs******~r*xyt*.t*s***st.r*si***t~x*~.**~xr*y.,r*
.r**»s.*.waa :. ,. s_..--~.~.~a~s:~.rra.ee..~.v,.",.. _,~.~.: .~., . _.ieen.~. x..~e ... .
W..~~.x .uri.,b, .x., s~-_x...-..." .._u .; re=..."-- ., m,: ~e.~ .,.,K n ,.
_... _ .. ,..
2750 ~1;~:~

2753 _TNS GET_SMN TAHLE_INFO( 2759 IN PVOID DeviceHandle, 2755 IN OUT pSMNTableInfo pSt~lInfo) 2765 f 2766 PADAPTER pAdapter = (PADAPTER) DeviceHandle:
2767 ULONG retValue=0;

2768 int i,j:

2770 pAdapter = CONTAINING_RECORD(AdapterList.Flink, ADAPTER, Linkage);

2772 if (TNSSharedMemoryNodeEmulation) t 2779 l return true ~.i~ are are van.=St~1 ~.uw by CRl9P VE.21~ 9:03 am Thursday, 30 September 1 999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 35 of 39 277 s %.r:
2776 retValue = 1;
2777 for (i=0: i<MAX TEAM_NODES; i++) ( 2778 pSMNInfo->LocationSet = pAdapter->TeamNodeTable[i].LocationSet;
2779 for (j=0; j<6; j+.+) ( 2780 pSMNInfo->MacAddress[j] = pAdapter->TeamNOdeTable[i].TNMacAddress[j];
z7e1 ) 2782 for (j=0; j<MAX COMPUTER NAME_SIZE: j++) {
2783 pSMNInfo->ComputerName[j] = pAdapter->TeamNodeTable[i].TNComputerName[j];
2784 ) 2785 pSMNInfo->NodeID = pAdapter->TeamNodeTable[i].TNNOdeID;
2786 pSMNInfo++;
2787 ]
2788 ) 2790 return retValue;
2791 ) 2793 //*x~***w*+****rv**i******~.**iai** *i:*a***,.***++*.*~i .t++
***w*+*r**a~*+***aa.****
2799 // +':'~ °"~ ..... . ,...,.... . . ~ ,~,.....~.. .r .... ~~...
,~». .. ~.. ., ...

2796 DECLSPEC_EXPORT
2797 _TNS_CLEAR_SMN_STATISTICS( 2798 IN PVOID DeviceHandle) 2799 !/
2800 /%.v:Descripi5on=::::
2801 /./:-.................
2802 I'!-'~Ertdirok~ieri~v ......._.....~ .......~.....,......., 2803 //:
2804 %.'lRe~ii=ii,Va3ue W .~....~_.._...__...
.,.., 2805 /-/..:qz::.--_.~__ 2806 /7v-.~

//*~f~*;*°t~*r****a+s**s,w*sew..rfsaw***+isvr*~wa.»i:r**s*y*wta~+*~*:r*r **,*is*i*s*~*.ri*
., . : . _ .. ., ..,».n,.b, _.".,., ..,~:, .~ ,,"._ <..w. .,.... ...._.. .~..,...,.,..
,_..~.:.... ». _ ..:....,. _4s~ ~. . .~~, ~..--,. .......» , .M "..,.., . ._~.
2808 {
2809 PADAPTER pAdapter = (PADAPTER) DeviceHandle;
2810 NTSTATUS Status;
2811 KIRQL OldIrql;
2812 PNDIS_PACKET MyPacket:
2813 ULONG PacketLength;
2814 PTNSPacketClearStats pTnsBuffer;
2815 PLIST_ENTRY clientRequest;
2816 PREQUEST_DATA pClientRequestData;
2817 ULONG requestTag;
2818 ULONG retries=0;
2819 int noreply = TRUE;
2820 ULONG returnRequestTag:

2822 e/~l 2823 lyactc liaek. 3~e °xea~ly"wanna:~se the'deq~ce,rcontext"given=-iip 2824 r%lr~yF,the~al7:er~:

2826 pAdapter = CONTAINING RECORD(AdapterList.Flink, ADAPTER, Linkage);

2828 ~/'%
2829 %% Raise f~EQI. to prevent, task,s~ppiiig while: We complete ,prose~si~g 2830 l7 ~~sr.,thls,pa~cket. =;:
2831 '/%:
2832 KeRaiseIrql(DISPATCH LEVEL, 601dIrq1):

2834 Jl 2835 %! ~9d~e' sure t3~3ver~zlias bees untid"T~zec7 piop'erly'~,T,~his,~i~s,:
2836 %:! an ~ssertian,, th~s~~ase :should ;never, happen),::
2837 %!
2838 /'I
2839 %:d'9sac'k ;back yworfc on error handli:rig 2890 '/%.
2841 iP (!pAdapter->TNSDriverInitialized) ( 2842 HreakPoint();
2843 KeLowerIrql(OldIrql);
2894 return 0;

2 8 4 7 '/x)-2848 %!-ccmpuGe packet lenijth, based on request,;~and 2899 l! aet the'uariable:accordingly (the~~packet.atruciure leagtti 2850 %1f11, get set acearx33ng to mthis variable);;.' 2851 /Ipy . . ..

2853 Packethength = TNS-PACKET SIZE(TNSPacketClearStats);

28ss requestTag = TNSGetRequestTag();

9:03 am Thursday, 30 September 1999 File: D:\nt4DDIC\src\timesn\tnsdrvr\tnsapi.c Page 36 of 39 2857 while (noreply 66 (retries++ < MAX_REQUEST_RESPONSE_RETRIES) ) ( 2859 Status = TNSInitializeClientNodeSendPacket(pAdapter, 2860 sMyPacket, 2861 6pTnsBuffer, 2862 PacketLength):

2865 /1;.~i3'S,f~~s-el~vgn~txpacke~G.~ia~fa~matian;here ..~~.~
2866 JY;
2867 pTnsBuffer->TNSCommandReply = wswap(TNS CLEAR STATS):

2869 pTnsBuffer->RequestTag = dwswap(requestTag):
2870 pTnsBUffer->RequestStartTSC a rdtsc():

2872 if (NT SUCCESS(Status)) ( 2873 PLIST ENTRY wrkrRequest:
2874 PREQUEST DATA pWrkrRequestData;
2875 LARGE INTEGER queueWait:
2876 int timeout = FALSE;
2877 int ltimeout = FALSE:
2878 int timeoutcount = 0:

2es1 Yl~ea~i~~equest~packet~o°s~ua zaez !-!:
2883 TNSSendPackets(pAdapter->LowerMPHandle, 6MyPacket. 1):
2884 ) 2885 ) 2886 KeLowerIrql(OldIrql):

2888 return 0:
2889 ) 2893 r<~''~~s'~'~"l.,tw.,.i.~rw.,c'.i-i-a,i~+i~si-i.~"s~~a.iii'ia.rnw~i.~.#~.te~.:l~rac~i.iFa~l.~aaaf~.a:drnLirs.y~.
G-.'".a~..s.#'#,wn~:&ie~a~evi~t~.:.P~'iioaaiwrw rm~es3.a.w.~w..~..G.38au1s~-.,.addr-.~.ar.a..,a~ 'M.ar.~R..:-re ...v~A_.YV ...a..vvx,a~rav 2 a 94 y~;,,~~~
2895 iJLONG

2897 _TNS GET_NODE STATISTICS( 2898 IN PVOID DeviceHandle, 2899 IN OUT PSTATISTICS pStatistics, 2900 IN OUT PULONG pStatsStructSize, 2901 IN OUT pMPSTATS pMpStats, 2902 IN OUT PULONG pMpStatsSize) 2913 PADAPTER pAdapter = (PADAPTER) DeviceHandle:
2914 NDIS STATUS NdisStatus:
2915 ~"
2 916 IJG~~,_~iaak:' ~w~e~y~,~llg,~~s~"'~~'yia~;~CO~,'~zeni;
2917 ,/J;_,*1~11~~.
2918 '%
2919 pAdapter = CONTAINING RECORD(AdapterList.Flink, ADAPTER, Linkage);

2921 MyAssert(pStatsStructSize);
2922 MyASSert(pMpStatsSize);

2924 if ( ('pStatsStructSize >= sizeof (STATISTICS)) ss (pStatistics) ) ( 2925 RtlCopyMemory(pStatistics, &pAdapter->MyStats. sizeof(STATISTICS) );
2926 ) else 2927 ~pStatsStructSize = sizeof (STATISTICS):
2928 return 0;
2929 ) 2930 if( (~pMpStatsSize >= sizeof (MPSTATS)) bb (pMpStats) ) ( 2931 TnsGetNICStats(pAdapter, pMpStats):
2932 ) else ( 2933 ~pMpStatsSize = sizeof (MPSTATS) ;
2934 return 0;

2935 ) 2937 return 1;
2938 ) 9:03 am Thursday, 30 September 1999 Flle: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 37 of 39 2993 unsigned char zerobuffer[6] _ ( 0, 0, 0, 0, 0, 0 ]:

2946 TNSSendPackets( 2997 IN NDIS_HANDLE NdisBindingHandle, 2948 IN PPNDIS_PACKET PacketArray, 2949 IN UINT NumberOfPackets) 2950 {
2951 UINT PhysBufferCount, BufferCount, PacketLength;
2952 PNDIS HUFFER FirstHUffer, NextBuffer:
2953 PUCHAR va:
2954 UINT bufferLength:
2955 unsigned short 'pEtherType:
2956 unsigned int 1,j:
2957 NDIS STATUS Status:
2958 int Found:

2961 for (i=0: i<NumberOfPackets; i++) 2963 #ifdef DHG
2969 NdisOueryPacket(PacketArray[i], SPhysBufferCount, 6HufferCount, 6FirstBuffer, 6PacketLength):

2966 NextHuffer = FirstBuffer;
2967 for (j=0: NextBuffer!= NULL; j++) 2968 NdisQuery8uffer(NextHuffer, sva, 6bufferLength):

2970 if (j==0) {
2971 MyASSert(bufferLength != 0);
2972 if (bufferLength >= 19) 2973 pEtherType = (unsigned short *)&va[12]:
2974 MyAssert (wswap(*pEtherType) _= TNS EMULATION_ETHERTYPE):
2975 MyAssert (RtlCompareMemory(va, zerobuffer, 6) != 6):
2976 MyASSert (RtlCompareMemory(sva[6], zerobuffer, 6) != 6);
2977 ) 2978 ) 2979 NdisGetNextHuffer(NextHuffer, &NextBUffer);
2980 ]
2981 #endif 2982 NdisSend(fiStatus, NdisBindingHandle, PacketArray[i]):

2984 #ifdef DBG
2985 switch (Status) ( 2986 case NDIS STATUS_SUCCESS:
2987 break;
2988 case NDIS STATUS_PENDING:
2989 break;
2990 case NDIS STATUS_INVALID_PACKET:
2991 MyAssert(0);
2992 break:
2993 case NDIS_STATUS_CLOSING:
2999 MyASSert(0):
2995 break:
2996 case NDIS STATUS_RESET_IN_PROGRESS:
2997 MyASSert(0):
2998 break;
2999 case NDIS_STATUS_FAILURE:
3000 MyAssert(0):
3001 break:
3002 default:
3003 MyASSert(0):
3004 D((0, "Status => %x, %s\n~, Status, GetNDISStatusString(Status, 6Found) ));
3005 break:
3006 ) 3007 #endif 3009 ) 3010 l/~ldySeadPae&atst~ldlaaind3xaqHandle; Paeke~Array,.FNumb~rOfPaa*ets~.

3014 TnsGetNICStats( 3015 PADAPTER pAdapter, 3016 pMPSTATS pMpStats) 3017 ( 3018 NDIS_STATUS NdisStatus;

3020 NdisStatus = MakeLocalNdisRequest( ~r,e.a by cwsP.,sz.~w 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsepl.c Page 38 of 39 3021 pAdapter, 3022 OID GEN XMIT OK, 3023 6pMpStats->XmitOK, 3024 sizeof(ULONG));
3025 if (NdisStatus != NDIS STATUS_SUCCESS) /
3026 ~~~s~atusc;
3027 _asm int 3 3028 ) 3030 NdisStatus ~ MakeLOCalNdisRequest( 3031 pAdapter, 3032 OID GEN RCV OK, 3033 6pMpStats->RCVOK, 3034 sizeof(ULONG)):
3035 if (NdisStatus !~ NDIS STATUS SUCCESS) I
3036 asm int 3 3037 ,~.~S~at~s:

3040 NdisStatus ~ MakeLocalNdisRequest( 3041 pAdapter, 3042 OID GEN XMIT ERROR, 3043 spMpStats->XmitError, 3044 sizeof(ULONG)):
3045 if (NdisStatus != NDIS_STATUS_SUCCESS) 3046 asm int 3 3047 ~/' ;~ix93:

3050 NdisStatus = MakeLOCalNdisRequest( 3051 pAdapter, 3052 OID GEN ACV ERROR, 3053 6pMpStats->RCVError, 3054 sizeof(ULONG));
3055 if (NdisStatus != NDIS STATUS SUCCESS) 3056 asm int 3 3057 ~asa'-~"~'~' 3058 ) 3060 NdisStatus - MakeLocalNdisRequest( 3061 pAdapter, 3062 OID GEN RCV NO BUFFER, 3063 6pMpStats->RcvNOHUffer, 3064 sizeof(ULONG)):
3065 if (NdisStatus !- NDIS_STATUS_SUCCESS) ( 3066 asm int 3 3os7 f~,"~~:
3068 ) 3070 NdisStatus - MakeLocalNdisRequest( 3071 pAdapter, 30,72 OID GEN_RCV CRC ERROR, 3073 6pMpStats->RCVCrcError, 3074 sizeof(ULONG));
3075 if (NdisStatus !~ NDIS STATUS SUCCESS) 3076 asm int 3 3077 ~$~;:
3078 ) ' 3081 return NDIS_STATUS_SUCCESS:
3082 ) 3086 TnsAddStatsUlong( 3087 PADAPTER pAdapter, 3088 PLARGE INTEGER pLi, 3089 ULONG Addend) 3091 LARGE_INTEGER AddendPart:

3093 AddendPart.HighPart = 0:
3094 AddendPart.LowPart = Addend:

3096 (void)ExInterlockedAddLargeInteger(pLi, AddendPart, 6pAdapter->MyStatsLOCk);
3097 ) 3100 TnsIncrementStat( 3101 PADAPTER pAdapter, 3102 PLARGE_INTEGER pLi) meal ey ~.~e.Q.,.
9:03 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsapi.c Page 39 of 39 3103 ( 3104 LARGE_INTEGER Addend:

3106 Addend.QuadPart - 1:

3108 (void)ExInterlockedAddLargeInteger(pLi, Addend, 6pAdapter->MyStatsLock):
3109 ) 3111 unsigned long _fltused:

3113 void 3114 GetProcessorSpeed( 3115 PADAPTER pAdapter) 3117 LARGE INTEGER qPerfCounterl, qPerfCounter2, qPerfDiff, qPerfFreq;
3118 ~puti3"4~

3120 LARGE INTEGER qPerfInc a (65536, 0):
3121 LARGE_INTEGER qrdtscl, qrdtsc2, qrdtscdiff:

3123 qPerfCounterl = KeQueryPerfozmanceCounter(6qPerfFreq);

3125 qPerfCounter2.QuadPart ~ qPerfCounterl.QuadPart + qPerfInc.QuadPart:

3127 qrdtscl ~ rdtsc():
3128 do 3129 qPerfCounterl = KeQueryPerformanceCounter(NULL):
3130 qrdtsc2 = rdtsc():
3131 ) while (qPerfCounterl.QuadPart < qPerfCounter2.QuadPart) 3133 qPerfDiff.QuadPart = qPerfCounterl.QuadPart - (qPerfCounter2.QuadPart -qPerfInc.QuadPart):
3134 qrdtscdiff.QuadPart - qrdtsc2.QuadPart - qrdtscl.QuadPart;

3136 ~; o~3e ~-~qF,'"~~ is f vv ~~''c~'anxb a PPS, ionr~art~~'.Ql~.'ei~rq~.~~°a.~:
~'"~'. ,......~ .. ~ %....~ .~~. ..:

3138 pAdapter->MyStats.rdtscDiff = qrdtscdiff.LOwPart:
3139 pAdapter->MyStats.perfFreq = qPerfFreq.LowPart:
3140 pAdaptez->MyStats.perfDiff ~ qPerfDiff.LowPart:

3142 D((0, ~qrdtscdiff.LowPart => 8x\n", qrdtscdiff.LowPart )):
3143 D((0, "qPerfFreq.LowPart => 8x\n", qPerfFreq.LowPart )):
3144 D((0, "qPerfDiff.LowPart => 8x\n~, qPerfDiff.LOwPart )):
3145 ) ~~br~b-Z-~~ 9:03 am Thursday, 30 September 1999 File: D:\nt4DDK\src\tfmesn\tnsdrvr\tnsemul.c Page 7 of 20 z 33 9include ~tns.h"
34 Uinclude "tnsdebug.h"
36 PADAPTER CurrentAdapter:
37 ULONG TNSSharedMemoryNOdeEmulation = FALSE:

39 NDIS_PHYSICAL_ADDRESS HighP.ddress = NDIS PHYSICAL_ADDRESS CONST( -1, -1 ):
41 LIST ENTRY AdapterList:
42 NDIS_SPIN_LOCK AdapterListLock:

44 NDIS_HANDLE ClientProtocolHandle;
46 NDIS_HANDLE MPWrapperHandle:

48 NDIS_HANDLE LMDriverHandle;

PDRIVER OBJECT IMDriverObject:
51 PDEVICE_OBJECT IMDevice0bject:

53 CONFIG_DATA ConfigData:

NDIS STRING IMSymbolicName = NDIS_STRING CONST(~\\DosDevices\\Im~):
56 NDIS STRING IMDziverName ~ NDIS STRING_CONST("\\Device\\Im" ):
57 NDIS_STRING IMMPName ~ NDIS STRING CONST(~\\Device\\Im~ ):

59 DECLARE_STRING( PacketPOOlSize ):
DECLARE_STRING( DebugLevel ):
61 DECLARE_STRING( DebugMask ):
62 DECLARE_STRING( TNSSMNEmulationMOde ):

64' NTSTATUS
71 DriverEntry( 72 IN PDRIVER OBJECT DriverObject, 73 IN PUNICODE_STRING RegistryPath):

STATIC NDIS STATUS
76 GetAdapterRegistryData( 77 PNDIS_STRING IMParamsKey, 78 - PADAPTER pAdapterl;

STATIC VOID
B1 ProcessLowerMPOpenAdapter( 82 IN PADAPTER pAdapter, ~nne.deyoweP..e.~.~~ 9:02 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsomul.c Page 2 of 20 83 IN NDIS_STATUS Statusl:

86 AllocatePacketPOO1( 87 , PADAPTER pAdapter):

90 AllocateReceiveBufferPOOls( 91 PADAPTER pAdapter):

94 ReadSingleParameter( 95 IN NDIS_HANDLE ParametersHandle, 96 IN PWCHAR ValueName, 97 IN ULONG DefaultValue, 98 IN NDIS PARAMETER TYPE ParamType):
99 - _ 101 WriteSingleParameter( 102 IN NDIS_HANDLE ParametersHandle, 103 IN PWCHAR ValueName, 104 IN ULONG ValueData, 105 IN NDIS PARAMETER TYPE ParamType):

113 $ifdef ALLOC PRAGMA
114 /pragma alloc text(INIT, ConfigureDriver) 115 Upragma alloc text(INIT, ReadSingleParameter) 116 4pragnu3 alloc text(INIT, Write5ingleParameter) 117 9endif 119 M"s~~, ...~~, ~y 120 ;

122 ipragma NDIS INIT FUNCTION(DriverEntry) 130 DriverEntryl 131 IN PDRIVER OBJECT DriverObject, 132 IN PUNICODE_STRING RegistryPath) 133 ( 134 NDIS_STATUS Status:
135 NDIS_PROTOCOL CHARACTERISTICS ProtocolChars:
136 NDIS MINIPORT CHARACTERISTICS MiniportChars:
137 NDIS STRING It~iame - NDIS STRING CONST( "IM"):
138 ULONG InitShutdovnMask:
139 PWCHAR EventLogString ~ IMDriverName.Buffer:
140 PVOID DumpData:

142 9lfdef DBG
143 TNSMakeBeep(l:
144 4endif 145 . D((0, "TNSE7mu1 DriverEntry\n~)):
146 D((0, ~TNSEMUL, Built Bs at 1s\n~, DATE- TIME-)):

149 IMDriverObject = DriverObject:

152 InitializeListHead( 6AdapterList ):
153 NdisAllocateSpinLock( sAdapterListLOCk );

155 NdisMInitializeWrapperl 6MPWrapperHandle, DriverObject, RegistryPath, NULL
):

157 InitShutdownMask ~ SHUTDOWN TERMINATE WRAPPER:

159 Status ~ ConfigureDriver( RegistryPath, 6ConfigData ):

161 if ( !NT SUCCESS( Status )) ( 162 D((0, "ConfigureDriver - Status: Ox8x\n", Status )):
163 goto DriverEntryErrort 164 ) vN~e.a br owsP Ve.n.~~ 9:02 am Thursday, 30 September 1999 File: D:\nt4DDiC\s~c\timesn\tnsdrv~\tnsemul.c Pegs 3 of 20 167 Ndis2eroMemory(6ProtocolChars, sizeof(NDIS PROTOCOL CHARACTERISTICS)):
168 ProtocolChars.Name.Length = IMName.Length:
169 ProtocolChars.Name.HUffer = (PVOID)IMName.Buffer:

171 ProtocolChars.MajorNdisVersion = 9:
172 ProtocolChars.MinorNdisVersion = 0;

174 ProtocolChars.OpenAdapterCompleteHandler °
LowerMPOpenAdapterComplete:
175 ProtocolChars.CloseAdapterCompleteHandler = LowerMPCloseAdapterComplete:
176 ProtocolChars.SendCompleteHandler = CLSendComplete:
177 ProtocolChars.TransferDataCompleteHandler = CLTransferDataCOmplete:
178 ProtocolChars.ResetCompleteHandler = CLResetComplete:
179 ProtocolChars.RequestCompleteHandler ° CLRequestComplete:
180 ProtocolChars.ReceiveHandler = CLReceiveIndication:
181 ProtocolChars.ReceiveCompleteHandler = CLReceiveCOmplete;
182 ProtocolChars.StatusHandler - CLStatusIndication:
183 ProtocolChars.StatusCompleteHandler ° CLStatusIndicationComplete:
184 I'~~~tc~col~ass ~tepg~~e~~agkg~~ad7~r<.,;, sCLRec~SwePaclce~:
185 ProtocolCtiars.ReceivePacketHandler =NULL:
186 ProtocolChars.BindAdapterHandler = BindTOLowerMP:
187 ProtocolChars.UnbindAdapterHandler ° UnbindFromLOwerMP:
188 ProtocolChars.UnloadHandler = CLUnloadProtocol:

190 NdisRegisterProtocol(6Status, 191 6C11entProtocolHandle, 192 sProtocolChars, 193 sizeof(NDIS PROTOCOL CHARACTERISTICS) + ProtocolChars.Name.Length):

195 if ( !NT SUCCESS( Status )) 196 D((0, "DOProtocolInit: couldn't register client handlers 808X\n", Status )):
197 ) 200 if ( !Nf_SUCCESS( Status )) {

202 D((0, "DoProtocolInit Failed! Status: Ox8x\n", Status)):

204 DumpData ° sStatus:
205 NdisWriteErrorLogEntry(IMDriverObject, 206 EVENT TRANSPORT_REGISTER_FAILED, 207 TNS_ERROR_PROTOCOL_INIT, 208 1, 209 ~EventLOgString, 210 sizeof( Status ), 211 DumpData):

213 goto DriverEntryError:
z14 ) 216 InitShutdownMask I° SHUTDOWN_DEREGISTER_PROTOCOL:

218 NdisZeroMemory(6MiniportChars, sizeof(NDIS_MINIPORT~CHARACTERISTICS)):
219 MiniportChars.MajorNdisVersion = 4:
220 MiniportChars.MinorNdisVersion ° 0:

222 MlniportChars.Reserved = 0:
223 MiniportChars.HaltHandler = MPHalt:
224 MiniportChars.InitializeHandler = MPInitiaiize:
225 MiniportChars.QueryInformationHandler = MPQueryInfozmation:
226 MiniportChars.ResetHandler ° MPReset:
227 MiniportChars.SetInformationHandler ° MPSetInformation:
228 MiniportChars.TransferDataHandler ~ MPTransferData:

230 MiniportChars.ReconfigureHandler = NULL;
231 MiniportChars.DisableInterruptHandler - NULL:
232 MlniportChars.EnableInterruptHandler = NULL:
233 MiniportChars.HandleInterruptHandler = NULL:
234 MiniportChars.ISRHandler ° NULL:
235 MiniportChars.CheckFOrHangHandler = NULL:

238 MiniportChars.ReturnPacketHandler ° MPReturnPacket:
239 MiniportChars.SendPacketsHandler ° MPSendPackets:
240 MiniportChars.AllocateCOmpleteHandler = NULL:
241 MiniportChars.SendHandler ° NULL:

243 Status = NdisIMRegisterLayeredMiniport(MPWrapperHandle, 244 ~MinipartChars, 245 sizeof(MiniportChars), 246 ~LMDriverHandle):
9:02 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsemul.c Page 4 of 20 248 if ( !NT SUCCESS( Status )) 250 D((0, "DoMiniportInit Failed! Status: OxBx\n~, Status)):

252 DumpData ~ 6Status:
253 NdisWriteErrorLagEntry(IMDriverObject, 254 (ULONG)TNS EVENT MINIPORT REGISTER_FAILED, 255 O.
256 1, 257 6EventLogString, 258 sizeof( Status ), 259 DumpData):

261 goto DriverBntryError;
262 ) 264 Status ~ WDMInitialize( DriverObject, 6InitShutdownMask ):

266 if ( !NT SUCCESS( Status )) ( 268 D((0, "WDMInitialize Failed! Status: OxBx\n", Status)):

270 goto DriverEntryError:
271 }

274 return (STATUS SUCCESS):

277 DriverEntryError:

279 if ( InitShutdownMask 6 SHUTDOWN DEREGISTER PROTOCOL ) 280 if ( ClientProtocolHandle 281 NdisDeregisterProtocol( 6Status, ClientProtocolHandle ):
282 if ( Status -- NDIS STATUS PENDING ) ( 283 D((0, "Client DeregProto failed - 808X\n~, Status)):
284 ) zes ) 286 }

288 if ( InitShutdownMask 6 SHUTDOWN TERMINATE_WRAPPER ) ( 289 NdisTerminateWrapper( MPWrapperHandle, NULL ):
290 ) 292 WDMCleanup( InitShutdownMask ):

294 NdisPreeSpinLOCk( 6AdapterListLock ):
295 NdisFreeSpinLock( SPSAListLock ):

297 return (STATUS UNSUCCESSFUL):

299 ) ~,'r~

302 CLResetComplete( 303 IN NDIS_HANDLE ProtocolBindingContext, 304 IN NDIS_STATUS Status) 305 ( 306 pADAPTER pAdapter a (PADAPTER)ProtocolBindingContext:
307 D((0, "(808X) CLResetComplete: Status - 808x\n", pAdapter, Status)):
308 ) 311 CLStatusIndication( 312 IN NDIS HANDLE ProtocolBindingContext, 313 IN NDIS STATUS GeneralStatus, 314 IN PVOID StatusBuffer, 315 IN UINT StatusBUfferSize) 316 ( 317 PADAPTER pAdapter ~ (PADAPTER)ProtocolBindingContext:

319 D((0, "(808X) CLStatuslndication: Status %08X\n~, pAdapter, GeneralStatus)):
320 ill:
w---"-~~.~. .-321 ~'il~T~!~.~-323 if (pAdapter->TNSDriverInitialized) ( 324 NdisMIndicateStatus( pAdapter->TNSNdisHandle, GeneralStatus, StatusBuffer, StatusBUfferSize ) 325 ) 327 1 ~a8in ~.ww~ewen.,e.a.,. 9:02 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsemul.c Page 5 of 20 330 CLStatusIndicatlonCOmplete( 331 IN NDIS_HANDLE ProtocolBindingContext) 332 ( 333 PADAPTER pAdapter = (PADAPTER)ProtocolBindingContext:
334 D((0, "(i08X) CLStatusIndicationComplete\n", pAdapter));

336 if (pAdapter->TNSDriverInitialized) ( 337 NdisMIndicateStatusComplete(pAdapter->TNSNdisHandle):
338 }
339 } ~;~at 344 ConfigureDriver 345 IN PUNICODE STRING RegistryPath, 346 IN PCONFIG DATA ConfigurationInfo) 347 ( _ 348 NDIS_HANDLE ConfigHandle:
349 NDIS STATUS Status:
350 NDIS STRING TnsBlahBlah ' NDIS STRING CONST("BlahBlah~):
351 PNDIS CONFIGURATION PARAMETER pCOnfigParameter:

353 NdisOpenProtocolConfiguration( sStatus, sConfigHandle, RegistryPath ):

356 ConfigurationInfo->PacketPoolSize = 200:

359 °'~" '°'~'a~~i x~"'a'f~ea~ea'°'~ 'tie °'~~t:
;.r...~~r.......~ -_~....~-............_............, 362 ConfigurationInfo->DebugLevel ~ 10;
363 ConfigurationInfo->DebugMask ~ Oxffffffff:

365 if ( Nf_SUCCESS( Status )) ( 367 READ HIDDEN CONFIG ( PacketPoolSize, NdisParameterInteger ):
368 NdisCloseConfiguration( ConfigHandle ):
369 ) 371' return STATUS SUCCESS:
372 ) 375 ReadSingleParameter( 376 IN HANDLE ConfigHandle, 377 IN PWCHAR ValueName, 378 IN ULONG DefaultValue, 379 IN NDIS_PARAMETER_TYPE NdisParamType) 380 ( 381 UNICODE STRING ValueKeyName:
382 ULONG ReturnValue:
383 NDIS STATUS Status:
384 PNDIS_CONFIGURATION_PARAMETER ConfigParam:

386 MyASSert( NdisParamType =~ NdisParameterInteger II NdisParamType s-NdisParameterHexInteger ):

388 NdisInitUnicodeString( 6ValueKeyName, ValueName ):

390 NdisReadCOnfiguration(6Status, 391 6COnfigParam, 392 ConfigHandle, 393 iValueKeyName, 394 NdisParamType):

396 if ( NT SUCCESS( Status )) ( 397 ReturnValue ~ ConfigParam->ParameterData.IntegerData:
398 } else ( 399 ReturnValue = DefaultValue:
400 ) 402 return ReturnValue:
403 ) tll~~:!'!~

406 BindToLowerMP( 407 OUT PNDIS_STATUS Status, 408 IN NDIS_HANDLE BindContext, 409 IN PNDIS STRING MPDeviceName, 410 IN PVOID SystemSpecificl, v.~.xwbr~~-~~ 9:02 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsemul.c Page 6 of 20 411 IN PVOID SystemSpecific2) 412 ( 413 PADAPTER pAdapter;
414 int 1;
415 NDIS STATUS OpenAdapterStatus:
416 NDIS STATUS OpenErrorStatus;
417 NDIS STATUS LocalStatus;
418 NDIS MEDIUM MediumArray[] _ ( 419 NdisMediumFddi, 420 NdisMedium802 5, 921 NdisMedium802 3, 422 NdisMediumWan ):

424 UINT MediumArraySize = sizeof( MediumArray ) / sizeof( NDIS_MEDIUM );
425 UINT MediaIndex:
426 ULONG AdapterStructSize;
427 ULONG NdisPacketTypes:
428 int j;

430 D((0, "BindTOLoverMP: 9s\n", MPDeviceName->Huffer )):

941 AdapterStructSize = sizeof( ADAPTER ) + MPDeviceName->Length fJ'I~~pace.~bi~~~t11~?d~~eoice~~iam qq2 + MPDevi_ceName->Length + ~'4!~cg;:poi.'~<.~he.;;,~-''sr3~a3~.-ada~~e 443 4 ~ sizeof( UNICODE_NULL ):

445 'Status ~ NdisAllocateMemory(6pAdapter. AdapterStructSize, 0, HighAddress);

497 if ( pAdapter ~- NULL ) [
448 PWCHAR StringData[2];

450 StringData[0] - IMDriverName.Huffer:
451 StringData[1] = L~Adapter~:
452 NdisWriteErrorLogEntry(IMDriverObject, 453 ' (ULONG)EVENT TRANSPORT RESOURCE POOL, 454 0, 455 2.
456 6StringData, 457 0, 958 NULL):

460 Status ~ NDIS_STATUS_RESOURCES:
461 return:
462 ]

464 NdisZeroMemory(pAdapter, AdapterStructSize):

466 GetProcessorSpeed(pAdapter);

469 'dame 471 ( 472 HANDLE ParamHandle;
473 UNICODE STRING KeyNameU;
974 HANDLE ConfigHandle;
475 ULONG Disposition:
476 OBJECT ATTRIBUTES TmpObjectAttributes:
477 Char nameBuf[256]:
478 STRING ntNameString;
479 PKEY VALUE FULL INFORMATION pKeyInfo;
480 unsigned char keyBuffer[128]:
481 ULONG ResultLength;
982 unsigned short 'pvString:
483 UNICODE_STRING ValueNameU:
489 NTSTATUS Status;

486 (VOID)sprintf(nameBuf, "\\Registry\\Machine\\System\\CurrentControlSet\\Control\\ComputerName -2 tiveComputerName"):
487 RtlInitString(6ntNameString, nameBuf);

489 Status ~ RtlAnsiStringToUnicodeString( 490 6KeyNameU, ~.x.aer~P~.s-~~ 9:02 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timasn\tnsdrvr\tnsemui.c Page 7 of 20 991 6ntNameString, 492 TRUE):

494 if (Status ~= STATUS SUCCESS) ( 496 (VOID)sprlntf(nameBuf, ~ComputerName"):
497 RtlInitString(&ntNameString, nameHuf):

499 Status - RtlAnsiStringToUnicodeString( 500 6ValueNameU, 501 6ntNameString, 502 TRUE):

509 InitializeObjectAttributes( 505 6TmpObjectAttributes, 506 6KeyNameU, 507 OBJ_CASE-INSENSITIVE.
508 NULL.
509 NULL):

511 Status = ZwCreateKey( 512 6COnfigHandle, 513 KEY READ.
514 6TmpObjectAttributes.
515 0.
516 NULL, 517 0.
518 6Disposition):

520 Status = ZwQueryValueKey( 521 ConfigHandle, 522 3ValueNameU, 523 KeyValueFullInfoxmation, 52q 6keyHuffer, 525 sizeof(keyBUffer), 526 6ResultLength):

528 if (Status ~ STATUS SUCCESS) ( 529 int i:
530 pKeyInfo a (PKEY VALUE FULL-INFORMATION) keyBUffer:

532 p ~ ..i .~ .r ~~~~

534 3~f'Na~.

536 pwString = (unsigned short ~)pKeyInfo:
537 (~ ~~.T . -~.'~~°P.~
538 pwString = lunsigned short ~)((ULONG)pwString + pKeyInfo->DataOffset);
539 x,.,: g" .y ..

541 i-0:
5q2 while (~pwString 66 (i<MAX COMPUTER NAME SIZE) ) (_ 543 ~'.~~. ~r.~~!'.l'~~~'~~.fF~~'i, 549 pAdapter->LocalComputerName(i++] ~ (unsigned char) ~pwString:
545 pwString++;
546 ) 548 D((0, "Machine Name => 8s\n~, pAdapter->LocalComputerName)1:
599 ) 550 ]

552 ~~~'i's~
553 i 554 RtlFreeUnicodeString(6KeyNameU):
555 RtlFreeUnicodeString(6ValueNameU):
556 ) 558 , 560 ~~'L~.jt ~'s~~g9( 562 for (i=0: i<HARDWARE ADDRESS LENGTH: i++) ( 563 pAdapter->SMNMacAddress[i) ~ Oxff:
564 ]

567 '' . ~- , 569 for (1~0: i<MA)C TEAM NODES; 1++) ( 570 for (j=0: j<HARDWARE ADDRESS LENGTH: j++) ( 571 pAdapter->TeamNOdeTable(i].~'NMacAddress(j] = 0x00:
572 ) ~r,e.eeyew~ePvez.,. 9:02 am Thursday. 30 September 1999 Pile: D:\nt4DDIC~src\timesn\tnsdrvr\tnsemul.c Pege 8 of 20 573 pAdapter->TeamNodeTable[i].TNNodeID - Oxffffffff;
574 ) 577 ~t~"~', p~8~~atxi~a~~~o~srae~~n"o~"Sa"~;_:~~~e'~o-~~'"ge 578 ~/~.~'dL~",~,~xhg"~r,,~g~~ge'~,~~
579 ~J
580 pAdapter->AdapterStructSize = AdapterStructSize;

583 ~.%~'hey'u"~dres,~~",~$~'~n~~~'~-~","~'~t~f""~!~rei 584 ~~'~rjsx~~
Ses ~~:

587 InitializeListHeadl6pAdapter->CllentWorkerListEntry);
588 InitializeListHeadl6pAdapter->ServerworkerListEntry):
589 InitializeListHead(6pAdapter->WOrkerListEntryPool):

591 KeInitializeSemaphore(6pAdapter->CllentWOrkerRequestSemaphore, 592 0, 593 MAXLONG);
594 KeInitializeSemaphore(6pAdapter->ClientWorkerResponseSemaphore, 595 0, 596 MAXLONG);
597 KeinitializeSemaphore(6pAdapter->ServerworkerRequestSemaphore, 598 0, 599 MAXLONG):
600 KeInitializeSpinLock(spAdapter->CllentWOrkerListSpinLock);
601 KeInltializeSpinLock(6pAdapter->ServerWOrkerListSpinLock);
602 KeInitializeSpinLock(6pAdapter->ListEntryPoolLock);

604 KeInltializeSpinLock(6pAdapter->MyStatsLock);

606 pAdapter->ListEntryItems = 50;

608 for (1~0; i<(int)pAdapter->ListEntryItems; i++) 609 PREQUEST DATA pRqstData;

611 pRqstData = (PREQUEST DATA) ExAllocatePool(NonPagedPool, sizeof(REOUEST
DATA) );

613 if (pRqstData != NULL) 614 ExInterlockedInsertTailList(6pAdapter->WOrkerListEntryPool, 615 apRqstData->Linkage, 616 3pAdapter->ListEntryPoolLock);

618 ) else 1 619 D((0, "Cannot allocate worker queue pool\n"));
620 _asm int 3 621 ) 622 ) 632 pAdapter->TNSDeviceName.MaximumLength ~ MPDeviceName->MaximumLenqth + 3 ' sizeof( UNICODE NULL );;

633 pAdapter->TNSDeviceName.Length a pAdapter->TNSDeviceName.MaximumLength;
634 pAdapter->TNSDeviceName.Buffer a (PWSTR)( pAdapter + 1 );

636 pAdapter->MPDeviceName.MaximumLength ~ MPDeviceName->Length;
637 pAdapter->MPDeviceName.Length ~ pAdapter->MPDeviceName.MaximumLength:
638 pAdapter->MPDeviceName.Buffer = (PWSTR)((PCHAR)pAdapter->TNSDeviceName.Buffer +
639 pAdapter->TNSDeviceName.MaximumLength +
640 sizeof( UNICODE_NULL )):

642 _ ' ~~~~ ., . ., 644 RtlCopyMemory(pAdapter->TNSDeviceName.Huffer, L"\\Device\\IM_", sizeof(L~\\Device\\IM ")):

646 ~r..~,~ ~l~,~fl~l.~s : ~'' ~~,"~'..~~~.~..~f '°'".'~
64 7 ~~~'a'~

649 RtlCopyMemory(6(pAdapter->TNSDeviceName.Buffer[sizeof("\\Device\\IM")]).
650 6(MPDeviceName->Buffer[sizeof(~\\Device~)]), 651 MPDeviceName->Length - sizeof(L"\\Device"));

~.,ewer~.,e.z.~~ 9:02 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsemul.c Page 9 of 20 65 a ~ : ~..~~.~:;:G"e~'T~da'.,~erpe'"ist""..Rata it . NDIS:STRING):S""~....~.
e~'.'aP~ez;: =:
~~~ _,.....,-,~..._.... ,.._P~,y. ...3~",u?~'..,~...."t.-:.~.~ ...~...' _ -.....~Ys..,....P. ,.."".. .. . ...... :fir:
656 ,.
657 if (0) 658 D((0, "(%08X) HindToLowerMP: Couldn't get registry data %08X (%s)\n~, 659 pAdapter, LocalStatus, MPDeviceName->BUffer )); ' 661 ~Status - NDIS STATUS FAILURE:
662 NdisFreeMemory(pAdapter, (sizeof(ADAPTER)+MPDeviceName->Length+MPDeviceName->Length+4~sizeof(UNIC
-2 ODE_NULL)) , 0):
663 return;
664 ]

666 7?
667 ~eue'~i or~~ acqe~'we.~ar~a ~i.'~n~"~ iie'~~~i~sa a~...,.,...._.......,...-,........,~..:~.__.~.-v...-..=
668 y"a 669 ~'-~s~emesobes~st font'~o-~e,7caa"'"'~.e'~eF~2~A~a~'"'~'"~'ei;,3 670 ~~~.: .. ,.r 671 NdisInitializeEvent(SpAdapter >BlockingEvent) 672 lJ~~t~s"I.#~al~zelrren~,fi~aptef~l;ece~,'veh~~~:a°E~vn~a~"~Ce, ,I~~~'~a~t~:
673 pAdapter->BindContext = BindContext:

676 ~.:'~u~~~~s°
677 NdisOpenAdapter(60penAdapterStatus, 678 60penErrorStatus, 679 6(pAdapter->LowerMPHandle), 680 sMediaIndex, 681 MediumArray, 682 MediumArraySize, 683 CllentProtocolHandle, 684 pAdapter, 685 MPDeviceName, 686 0, 687 NULL):

690 if ( OpenAdapterStatus ~~ NDIS STATUS PENDING ) I
691 NdiswaitEvent( 6pAdapter->BlockingEvent, 0 ):
692 NdisResetEvent( 6pAdapter->BlockingEvent ):
693 ) else ( 694 pAdapter->FSnalStatus = OpenAdapterStatus:
695 ) 697 if ( NT_SUCCESS( pAdapter->FinalStatus )) ( 699 pAdapter->MediaType - MediumArray[ MediaIndex ];

701 if (pAdapter->MediaType = NdisMediumwan) 702 pAdapter->MediaType a NdisMedium802 3:
703 ) 704 ProcessLowerMPOpenAdapter( pAdapter, pAdapter->FinalStatus ):
705 pAdapter->TNSClientNOdeID = Oxffffffff:

707 if (TNSSharedMemoryNodeEmulation ~ FALSE) ( 708 if (PSCreateSystemThread( 709 6pAdapter->ClientWorkerThreadHandle, 710 (ACCESS MASK) 0, 711 (POBJECT ATTRIBUTES) NULL, 712 (HANDLE) NULL, 713 (PCLIENT ID) NULL, 714 TNSCIIentWOrkerThread, 715' (PVOID) pAdapter) !m STATUS SUCCESS) ( 717 D((0, ~Could not create client thread\n")):
718 _asm int 3 720 ) else ( 721 if (PsCreate5ystemThread( 722 6pAdapter->ServerworkerThreadHandle, 723 (ACCESS MASK) 0, 724 (POBJECf ATTRIBUTES) NULL, 725 (HANDLE) NULL, 726 (PCLIENT ID) NULL, 727 TNSServerworkerThread, 728 (PVOID) pAdapter) != STATUS SUCCESS) 730 D((0, ~Could not Server worker thread\n")):
731 asm int 3 Pn..e.aer~eP.,a-z-~~ 9:02 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsemul.c Pege 10 of 20 735 ~Status = pAdapter->FinalStatus:

737 ~ ~.~tIMO"~GawA
] 1~,~~... . "'ws.."~..

740 GetAdapterRegistryData( 741 PNDIS_STRING IMParamsKey, 742 PADAPTER pAdapter) 743 ( 744 NDIS STATUS Status:
745 NDIS_HANDLE ConfigHandle:
746 NDIS STRING IMInstanceNUmberKey = NDIS STRING CONST( "InstanceNumber" ):
747 PNDIS CONFIGURATION PARAMETER ConfigParam:

749 NdisOpenProtocolConfiguration( 6Status, 6ConfigHandle, IMParamsKey ):

751 if ( !NT SUCCESS( Status )) 752 D((0,' "(808X) GetAdapterRegistryData: can't open key 8s (808X)\n", pAdapter, IMParamsKey->Huffer, -2 Status ));
753 HreakPoint():
754 return Status:
755 ]

758 ~.~i~~et,,..~el;?~ievrce .,3xieiance,~ua~r :an'~ xEui~ ~h~e ~e~ri~ce T.instance..~ti3:iig zs9 x,~.~', . . ._ 760 NdisReadConfiguration(6Status, 761 6COnfigParam, 762 ConfigHandle, 763 6IMInstanceNumberKey, 764 NdisParameterInteger):

767 if ( !NT SUCCESS( Status )) ( 768 D((0, "(808X) GetAdapterRegistryData: Missing InstanceNumber key\n~, pAdapter)):

770 Status = NDIS STATUS FAILURE:
771 goto CloseConfig:
772 ]

774 pAdapter->DevInstance - (USHORT)ConfigParam->ParameterData.IntegerData:

776 NdisMoveMemory(pAdapter->TNSDeviceName.BUffer, IMMPName.Huffer, IMMPName.Length);

778 pAdapter->TNSDeviceName.Buffer( IMMPName.Length / sizeof( WCHAR ) ] = L'0' + pAdapter->DevInstance;

781 CloseConfig:
782 NdisCloseConfigurationl ConfigHandle ):

784 return Status.
785 _ 786 ]

789 ProcessLOVerMPOpenAdapter( 790 IN PADAPTER pAdapter, 791 IN NDIS STATUS Status) 793 NTSTATUS EventStatus:
794 NDIS HARDWARE STATUS HWStatus:
795 NDIS MEDIA STATE MediaState = OxFFFFFFFF:
796 NDIS STRING IMDevName:
797 ULONG MacOptions:
798 ULONG ErrorLogData[2]:
799 PWCHAR StringData(2]:
800 PVOID DumpData:

802 D((0, "(808X) ProcessLoWerHPOpenAdapter\n~, pAdapter)):

807 if ( !NT SUCCESS( Status )) ( 808 D((0, "(808X] ProcessLorrerMPOpenAdapter: binding failed 808X\n~, pAdapter, Status)):
809 if ( Status ~ NDIS STATUS ADAPTER NOT FOUND ) ( 810 EventStatus = EVENT_TRANSPORT ADAPTER NOT FOUND:

811 ] else 812 EventStatus = EVENT TRANSPORT BINDING FAILED:

Prsne.d ey ccoer.~ez.~~ 9:02 am Thursday, 30 September 1999 Ffle: D:\nt4DDlC\src\timesn\tnsdrvr\tnsemul.c Pege 11 of 20 815 StringData(0] = pAdapter->TNSDeviceName.Buffer;
816 StringData(1] = pAdapter->MPDeviceName.Buffer;
817 DumpData = 6Status;

819 NdisWriteErrorLogEntry(IMDriverObject, 820 EventStatus, 821 0, 822 2, 823 6StringData, 824 sizeof( Status ), 825 DumpData);

827 NdisFreeMemory(pAdapter, pAdapter->AdapterStructSize, 0):
828 return;

831 D((0, ~(%08X) =1 Adapter\n", pAdapter ));
832 InitializehistHead( 6pAdapter->ClientList );
833 pAdapter->ShutdownMask = 0;

836 NdisInterlockedInsertTailList(6AdapterList, 6pAdapter->Linkage, 6AdapterListLock);

838 Status ~ MakeLOCalNdisRequest(pAdapter, 839 OID_GEN_HARDWARE_STATUS, 840 6HWStatUB, 841 sizeof(HWStatus));

893 if ( Status a= NDIS STATUS INVALID OID II HWStatus ==
NdisHardwareStatusReady ) ( 845 Status = MakeLocalNdisRequest(pAdapter, 846 OID GEN-MEDIA CONNECT_STATUS.
647 6MediaState, 848 sizeof( MediaState )):

850 if ( Status == NDIS STATUS_INVALID OID II MediaState ==
NdisMediaStateConnected ) ( 852 Status = MakeLocalNdisRequest(pAdapter, 853 OID GEN LINK SPEED, 854 6pAdapter->LinkSpeed, 855 sizeof( pAdapter->LinkSpeed ));

857 if ( !t9T_SUCCESS( Status )) ( 859 D((0, "(%08X) ProcessLOwerMPOpenAdapter: Can't get link speed - Status %08X\n", pAdapter, -2 Status));

861 ErrorLogData( 0 ] = TNS ERROR MISSING OID;
862 ErrorLogData( 1 ] = OID GEN LINK SPEED;

869 NdisWriteErrorLogEntrylpAdapter->LowerMPHandle, 865 NDIS ERROR CODE MISSING CONFIGURATION PARAMETER, 866 2.
867 ErrorLogData);

869 return;
870 ) 872 } else ( 874 D((0, "(808X) ProcessLOwerMPOpenAdapter: Media not connected\n", pP.dapter ));
875 ) 876 ) else ( 877 ' 878 D((0, "(%08X) ProcessLOwerMPOpenAdapter: HW Status not ready (%d)\n", HWStatus)):
879 ) 881 Status = MakeLocalNdisRequest( 882 pAdapter, 883 OID_802 3 CURRENT ADDRESS, 884 6pAdapter->LowerMPMacAddress, 885 HARDWARE ADDRESS LENGTH);

887 if ( NT_SUCCESS( Status )) ( 888 D((0, ~ProcessLowerMPOpenAdapter: got hardware address => %02x %02x %02x %02x %02x 802x \n", .
889 pAdapter->LowerMPMacAddress(0], 890 pAdapter->LowerMPMacAddress(1], 891 pAdapter->LowerMPMacAddress(2], 892 pAdapter->LowerMPMacAddress[3], 893 pAdapter->LowerMPMacAddress(4], 894 pAdapter->LowerMPMacAddress(5])):
895 } else ~r~.eer~.~e.Q.i~ 9:02 am Thursday. 3Ca September 1999 Fils: D:\nt4DDiC\src\timesn\tnsdrvr\tnsemul.c Page 72 of 20 896 D((0, "ProcessLowerMPOpenAdapter: can't get hardware address \n~ )):
897 ) 899 Status = MakeLocalNdisRequest(pAdapter, 900 OID GEN MAC OPTIONS, 901 sMacOptions, 902 sizeof(MacOptions)):

904 if ( NT SUCCESS( Status )) ( 905 pAdapter->CopyLookaheadData = (HOOLEAN)(MacOptions 6 NDIS MAC OPTION COPY
LOOKAHEAD_DATA):
906 ) 908 Status = AllocatePacketPool(pAdapter):

910 if (!NT SUCCESS(Status)) ( 911 return;
912 ) 914 Status ° AllocateReceiveHufferPools(pAdapter):

916 if (!NT SUCCESSIStatus)) 917 return:
918 ) 920 NdisInitUnicodeString( 6IMDevName, 6pAdaptez->TNSDeviceName.Buffer[8] ):

923 CurrentAdapter ° pAdapter:

925 D((0, "Calling NdisIMinitializeDeviceInstance\n")):
926 Status = NdisIMInitializeDeviceInstance(LMDriverHandle, 6IMDevName):

928 if ( !NT SUCCESS( Status )) ( 930 D((0, "(808X) ProcessLowerMPOpenAdapter: can't init IM device 8s (808X)\n~, 931 pAdapter, IMDevName.Huffer, Status)):

933 ErrorLogData[ 0 ) = TNS ERROR CANT-INITIALI2E_IMSAMP DEVICE:
939 ErrorLOgData[ 1 ) - Status:

936 NdisWriteErrorLOgEntry(pAdapter->LOwerMPHandle, 937 NDIS ERROR CODE DRIVER FAILURE, 938 2~ _ _ _ _ 939 ErrorLogData):

991 return:
942 ) 944 pAdapter->ShutdownMask I° SHUTDOYIN-DEINIT DEV_INSTANCE:

946 return:
947 _ 948 ) 951 LowerMPOpenAdapterComplete( 952 IN PADAPTER pAdapter, 953 IN NDIS STATUS Status, 954 IN NDIS STATUS OpenErrorStatus) 955 ( 956 NDIS_MEDIA_STATE MediaState = OxFFFFFFFF:

958 D((0, "(808X) LowerMPOpenAdapterComplete\n", pAdapter)):

960 pAdapter->FinalStatus = Status:
961 NdisSetEvent( spAdapter->HlockingEvent ):

963 ) "" _~zt.,~~~.~.~~.

966 AllocatePacketPool( 967 PADAPTER pAdapter) 968 ( 969 NDIS STATUS Status:
970 ULONG ProtoReservedSize:

972 -, "_,_ ",..

975 ProtoAeservedSize = sizeof(TNS PACKET CONTEXT);
976 - _ 977 NdisAllocatePacketPool(6Status, 9:02 am Thursday, 30 Septeimber 1999 File: D:\nt4DDK\s~c\tfmesn\tnsdrvr\tnsemul.c Page y3 of 20 978 6pAdapter->PacketPoolHandle, 979 ConfigData.PacketPOOlSize, 980 ProtoReservedSize):

982 return Status:

984 1 ~~~~~' 987 AllocateReceiveBufferPools( 988 PADAPTER pAdapter) 989 ( 990 NDIS STATUS Status:

991 ULONG HeaderSize;

992 ULONG FrameSize: ,~.'~'~."'"he"'~4bgei 993 NDIS ERROR CODE ErrorCode:

994 ULONG ErrorLOgData(2]:

997 ~t~ao"~~"'a~l~e?33A~..:r~

999 Status ~ MakeLocalNdisRequest(pAdapter, 1000OID GEN MAXIMUM_FRAME_SIZE, 1001aFrameSize, 1002sizeof(FrameSize)):

1004if ( !NT SUCCESS( Status )) 1006D((0, "(808X) AllocateReceiveHufferPOOl:frame size - Status 808X\n", Can't get pAdapter, Status) -2 ):

1008ErrorCode = NDIS_ERROR CODE MISSING
CONFIGURATION PARAMETER:

1009ErrorLOgData( 0 ] m TNS ERROR MISSING
OID:

1010ErrorLogData( 1 ] ~ OID GEN_MAXIMUM-FRAME_SIZE:

1011goto ErrorExit:

1012) 1015p~$i 1016~
x 1018Status ~ MakeLocalNdisRequest(pAdapter, 1019OID GEN MAXIMUM TOTAL_SIZE, 10206pAdapter->TotalSize, 1021sizeof(pAdapter->TotalSize));

1023if ( !N1'_SUCCESS( Status )) ( 1025D((0, "(808X) AllocateReceiveHufferPool:total size - Status %08X\n~, Can't get pAdapter, Status) -2 ):

1027ErrorCode - NDIS ERROR CODE MISSINGPARAMETER:
CONFIGURATION

1028ErrorLogData[ 0 ) - TNS ERROR MISSING
OID:

1029ErrorLogData( 1 ) - OID GEN_MAXIMUM
TOTAL_SIZE;

1031goto ErrorExit:

1032) 1034a~.-1035~:r;~'.
_~..._._____-..~__._..__-_ 1037HeaderSize ~ pAdapter->TotalSize - FrameSize:

1038D((0, "FrameSize ~> %d, HeaderSize 8d\n", FrameSize, HeaderSize, ~> 8d, TotalSize -> pAdapter->TotalS

-2 izel):

1040Status = MakeLocalNdisRequest(pAdapter, 1041OID GEN MAXIMUM_LOOKAHEAD, 1042spAdapter->LookaheadBufferSize, 1043sizeof(pAdapter->LookaheadHufferSize)):

1045if ( !NT SUCCESS( Status )) 1047D((0, "(808X) AllocateReceiveBufferPool:lookahead size - Status 808X\n", Can't get pAdapter, Sta -2 tus)):

1049ErrorCode a NDIS_ERROR_CODE MISSING_CONFIGURATIONPARAMETER:

1050ErrorLOgData( 0 ] ~ TNS ERROR MISSING_OID:

1051ErrorLogData( 1 ] ~ OID GEN-MAXIMUM_LOOKAHEAD:

1052goto ErrorExit;

1053) 1055pAdapter->LookaheadBufferSize +-HeaderSize:

r,snewdy~vez~. 9:02 am Thursday, 30 September 1999 Flle: D:\nt4DDK\src\timesn\tnsdrvr\tnsemul.c Pege y4 of 20 1058 ~~ °ewk~eai~~u o03' :~. ... ~~.,,,..
1059 ~I
1060 NdisAllocateBufferPOO1(6Status, 6pAdapter->LookaheadPOOlHandle.
ConfigData.PacketPoolSize):

1062 return Status:

1064 ErrorExit:

1066 NdisWriteErrorhogEntry( 1067 pAdapter->LowerMPHandle, 1068 ErrorCode, 1069 2, 1070 ErrorLOgData ):

1072 return Status:

1074 ) ca,"~~,eRec~~i'ui=fe 1078 MPInitialize( 1079 OUT PNDIS_STATUS OpenErrorStatus.
1080 OUT PUINT SelectedMediumIndex, 1081 IN PNDIS_MEDIUM MediumArray, 1082 IN DINT MediumArraySize, 1083 IN NDIS HANDLE MiniportAdapterHandle, 1084 IN NDIS_HANDLE wrapperConfigurationContext) 1085 ,( 1086 NDIS STRING LowerAdapterKey = NDIS STRING CONST( ~LOwerAdapter" ):
1087 PADAPTER pAdapterInList:
1088 ULONG ErrorLogData[2]:
1089 PNDIS MINIPORT BLOCK Mp = (PNDIS MINIPORT BLOCK)MiniportAdapterHandle:
1090 NDIS_STATUS Status:
1091 NDIS HANDLE ConfigHandle:
1092 PNDIS CONFIGURATION PARAMETER pConfigParameter:
1093 NDIS STRING TnsSmnMOdeString ~ NDIS STRING CONST(~TNSSMNEmulationMOde"):

1096 D((0, "MPInitialize: Enter\n")):
1097 D((0, "MlniportInitialize Miniport->HaseName ~ 8ws\n",Mp->MiniportName.Huffer y):

1099 pAdapterInList - FindAdapterHyName(Mp->MiniportName.Buffer);

1102 NdisOpenConfiguration( 1103 6Status.
1104 6ConfigHandle, 1105 WrapperConfigurationContext):

1107 if (Status !- STATUS SUCCESS) ( 1108 D((0, "Cannot open miniport config data\n")):
1109 ) else 1 1110 NdisReadConfigurationl 1111 6Status, 1112 6pConfigParameter, 1113 ConfigHandle, 1114 6TnsSmnMOdeString, 1115 NdisParameterHexInteger):

1117 if (Status !~ STATUS SUCCESS) 1118 D((0, "Can't read reg, Status ~> 8x\n". Status));
1119 ) else ( 1120 D((0, "read reg. value ~> 8x\n", pConfigParameter->ParameterData.IntegerData)):
1121 TNSShazedMemoryNOdeEmulation - pConfigParameter->ParameterData.IntegerData;
1122 ) 1126 _ 1128 if ( !pAdapterInList ) ( 1130 D((0, "Can't find adapter for MP dev $ 9ws\n",Mp->MiniportName.Huffer)):

1132 ErrorLOgData[ 0 ] a TNS ERROR HAD_REGISTRY_DATA:
1133 ErrorLogData[ 1 ] ° TNS ERROR_INVALID_IMSAMP MP INSTANCE:

1135 NdisHriteErrorLogEntry(MiniportAdapterHandle, 1136 NDIS ERROR CODE_MISSING CONFIGURATION PARAMETER, , 1137 2, r~.e.ac~.~.,e.Q.,~ 9:02 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timssn\tnsdrvr\tnsemul.c Page 15 of 20 1138 ErrorLogData):

1140 HreakPOint();
1141 return NDIS_STATUS_FAILURE:
1142 ) 1144 ~~. _ _ 1145 ~iT~"~'.~~a.~='~~g~~~~~n~~~"me~Y:
1146 ~;~%i 1147 for (--MediumArraySize : MediumArraySize > 0; ) ( 1198 if ( MediumArray[ MediumArraySize ) =m pAdapterInList->MediaType ) 1149 break:
1150 ) 1151 i~f ( MediumArraySize ~ 0 ) 1152 break;
1153 ) 1154 --MediumArraySize:
1155 ) 1157 if ( MediumArraySize -- 0 66 MediumArray[ 0 ] != pAdapterInList->MediaType ) f 1158 HreakPOint();
1159 return NDIS STATUS UNSUPPORTED MEDIA:

1162 *SelectedMediumIndex = MediumArraySize:

1164 ;,'~~

1167 pAdapterInList->TNSNdisHandle ~ MiniportAdapterHandle;

1169 DM((DEBUG-INFO, DEBUG MASKEN_INIT, "AdapterInList->TNSNdisHandle =>
8x\n", pAdapterInList->TNSNdisHan -2 d1e)):
1170 (J:
1171 ~ ' ",~ . , _"".. ....... , M_~".,. ~,a.."

1173 NdisMSetAttributesEx(MiniportAdapterHandle.
1174 pAdapterInList, 1175 0, 1178 NDIS ATTRIBUTE_IGNORE_REQUEST TIMEOUT I
1179 NDIS_ATTRIBUTE-INTERMEDIATE DRIVER , 1180 0);

1185 pAdapterInList->TNSDriverlnitialized a TRUE;

1187 return NDIS_STATUS_SUCCESS:

1189 ) f 1192 FindAdapterHyName( 1193 PWCHAR AdapterName) 1195 PLIST_ENTRY NextAdapter;
1196 PADAPTER pAdapterInList:
1197 ULONG NameLength = 0:
1198 PWCHAR prr ~ AdapterName:

1200 While ( *pw++ !~ 0 6~ NameLength < 64 ) 1201 ++NameLength:
1202 ) 1204 NameLength *= sizeof( WCHAR ):

1206 NdisAcquireSpinLock( 6AdapterListLock ):

1208 NextAdapter a AdapterList.Flink;
1209 while ( NextAdapter != sAdapterList ) 1211 pAdapterInList - CONTAINING RECORD( NextAdapter, ADAPTER, Linkage );
1212 _ 1213 ~~~..-v 1215 if ( pAdapterInList->TNSDeviceName.Length =_ (NameLength+2) ) [
1216 if ( NdisEqualMemory(pAdapterInList->TNSDeviceName.BUffer, AdapterName, NameLength)) 1217 break:
1218 ) ~"ewer~weP.~a-s-,~ 9:02 am Thursday, 30 September 1999 Flle: D:\nt4DDIC~s~c\tlmesn\tnsdrv~\tnsemul.c Page 16 of 20 1219 }

1221 NextAdapter = NextAdapter->Flink;
l2zz }' 1224 if ( NextAdapter != 6AdapterList ) ( 1225 } else 1226 pAdapterInList ~ NULL;
1227 ) 1229 NdisReleaseSpinLack( 6AdapterListLock );

1231 return pAdapterInList:
1232 ) 1235 UnbindFromLowerMP( 1236 OUT PNDIS STATUS Status, 1237 IN NDIS HANDLE ProtocolBindingContext, 1238 IN NDIS_HANDLE UnbindContext) 1240 PADAPTER pAdapter = (PADAPTER)ProtocolBindingContext;
1241 NDIS_STATUS LocalStatus:

1243 D((0, "(%08X) UnbindFromLOwerMP\n", pAdapter));

1245 if ( pAdapter->ShutdownMask 6 SHUTDOWN_DEINIT DEV_INSTANCE

1247 LocalStatus = NdisIMDeInitializeDeviceInstance(pAdapter->TNSNdisHandle);
1248 MyASSert(NT_SUCCESS (LocalStatus));

1250 pAdapter->ShutdownMask 6= -SHUTDOwN_DEINIT DEV INSTANCE:
1251 f 1253 pAdapter->HindCOntext - UnbindContext:

1255 ~Status = NDIS_STATUS_PENDING;

1257 }

1260 LowerMPCloseAdapterComplete( 1261 IN NDIS HANDLE ProtocolBindingContext, 1262 IN NDIS_STATUS Status) 1263 ( 1264 PADAPTER pAdapter = (PADAPTEA)ProtocolBindingContext:

1266 D((0, ~(%08X) LowerMPCloseAdapterComplete\n", pAdapter)):

1268 MyASSert( NT_SUCCESS( Status ));

1270 if ( pAdapter->HindContext ) ( 1271 NdisCompleteUnbindAdapter( pAdapter->HindContext, Status 1:
1272 }

1274 NdisAcquireSpinLock( 6AdapterListLock );
1275 RemoveEntryListl 6pAdapter->Linkage );
1276 NdiaReleaseSpinLock( 6AdapterListLock ):

1278 if ( pAdapter->ShutdownMask ~ SHUTDOwN_DEALLOC PACKET-POOL ) ( 1280 NdisFreePacketPOOl( pAdapter->PacketPoolHandle ):
1281 ) 1283 fi 1287 if ( pAdapter->ShutdownMask 6 SHUTDOWN_DEALLOC LOOKAHEAD_POOL ) ( 1289 NdisFreeHufferPool( pAdapter->LookaheadPoolHandle ):
1290 }

1293 NdisFreeSpinLock( 6pAdapter->Lock );

1295 NdisFreeMemory(pAdapter, pAdapter->AdapterStructSize, 0):

1297 ) 1300 CLUnloadProtocol( 9:02 am Thursday, 30 September 1999 Ftle: D:\nt4DDK\src\timesn\tnsdrvr\tnsemul.c Page 17 of 20 1301 VOID) 1303 Breakpoint():
1304 ) ~(, ;~n'hia3Eirotocol 1308 MPHalt( 1309 IN NDIS_HANDLE MlniportAdapterContext) 1311 PADAPTER pAdapter = (PADAPTER)MiniportAdapterContext:

1313 D((0, "(%08X) MPHalt\n~, pAdapter)):
1314 pAdapter->ShutdownMask 6= -SHUTDOWN DEINIT DEV INSTANCE:
1315 Breakpoint():
1316 } ~~A~i 1319 MPReset( 1320 OUT PBOOLEAN AddressingReset, 1321 IN NDIS_HANDLE MiniportAdapterContext) 1323 PADAPTER pAdapter a (PADAPTER)MiniportAdapterContext:
1324 D((0, ~(%08X) MPReset\n", pAdapter)):
1325 ~AddressingReset = FALSE:
1326 return NDIS STATUS SUCCESS:
1327 1 'y>~~;aet.

1338 NDIS_STATUS
1339 MakeLocalNdisRequest( 1340 PADAPTER pAdapter, 1341 NDIS OID 01d, 1342 PVOID Buffer, 1343 ULONG BufferSize) 1394 ( 1345 NDIS STATUS Status;
1396 ULONG HytesNeeded, HytesWritten;

1348 pAdapter->Request.RequestType = NdisRequestQueryInformation:
1399 pAdapter->Request.DATA.QUERY INFORMATION.Oid - Oid:
1350 pAdapter->Request.DATA.QUERY INFORMATION.InformationBuffer = Buffer:
1351 pAdapter->Request.DATA.QUERY INFORMATION.InformationBufferLength =
HufferSize:
1352 pAdapter->BytesNeeded - 6BytesNeeded:
1353 pAdapter->HytesReadOrWritten = 6BytesWritten:
1359 pAdapter->LocalRequest ~ TRUE:

1356 NdisResetEvent( 6pAdapter->BlockingEvent ):

1358 NdisRequest(~Status, pAdapter->LowerMPHandle, 6pAdapter->Request):

136 !s~:.~'''diie'f_3~~R..;
1362 ~' 1363 if (Status =- NDIS STATUS PENDING) ( 1365 NdisWaitEventl 6pAdapier->BlockingEvent, 0 ):
1366 NdisResetEvent( 6pAdapter->BlockingEvent ):
1367 Status = pAdapter->FinalStatus;
1368 ) 1370 ~ _ 1371 ~.~80.e."~ti~ iC~ n "-'-1373 if ( Status == STATUS NOT SUPPORTED ) 1374 Status ~ NDIS STATUS INVALID OID;

1377 return Status;
1378 ) "~l:;~i~M

PrlnE~d by GRIBP ve27~ 9:02 am Thursday, 30 September 7 999 Pile: D:\nt4DDK\src\timesn\tnsdrvr\tnsemul.c Page y8 of 20 1389 MakeLocalNdisRequestSet( 1385 PADAPTER pAdapter, 1386 NDIS OID Oid, 1387 PVOID Buffer, 1388 ULONG HufferSize) 1389 ( 1390 NDIS STATUS Status:
1391 ULONG BytesNeeded, BytesWritten;

1393 pAdaptez->Request.RequestType = NdisRequestSetInformation;
1394 pAdapter->Request.DATA.QUERY INFORMATION.Oid a Oid:
1395 pAdapter->Request.DATA.QUERY INFORMATION.InformationBuffer = Buffer:
1396 pAdapter->Request.DATA.QUERY INFORMATION.InformationBUfferLength =
BufferSize:
1397 pAdapter->BytesNeeded = bBytesNeeded:
1398 pAdapter->BytesReadOrWritten = b8ytesWritten:
1399 pAdapter->LocalRequest = TRUE:

1901 NdisResetEvent( bpAdapter->HlockingEvent ):

1403 NdisRequest(bStatus, pAdapter->LowerMPHandle, bpAdapter->Request):

1406 ~l~~al~~~'~~e~~P ,pen~~Clu~~~5es 1407 ~//:
1408 if (Status =- NDIS STATUS PENDING) ( 1410 NdisWaitEvent( bpAdapter->HlockingEvent, 0 ):
1411 NdisResetEvent( bpAdapter->BlockingEvent ):
1412 Status = pAdapter->FinalStatus:
1413 ) 1915 if ( Status -- STATUS NOT_SUPPORTED ) ( 1416 Status = NDIS_STATUS_INVALID_OID;
1417 ) 1419 D((0, "MakeLocalNdisRequestSet Status -> 8x\n", Status)):
1920 return Status: _ 14 21 1 ~'~~.~d~søt~

1424 NDIS STATUS ' 1425 MPSetInformation( 1926 IN NDIS HANDLE MiniportAdapterContext, 1427 IN NDIS OID Oid, 1428 IN PVOID InformatlonHuffer, 1429 IN ULONG InformationBUfferLength, 1430 OUT PULONG HytesRead, 1431 OUT PULONG HytesNeeded) 1432 ( 1433 PADAPTER pAdapter a (PADAPTER)MiniportAdapterContext:
1934 NDIS STATUS Status:
1435 ULONG FoundFlag:

1437 Status = NDIS_STATUS_FAILURE:

1439 D((0, "MPSetInforsiation, Context => 8x, (8x) NDIS OID => 8s\n", pAdapter, Oid, GetNDISOidString(Oid, -2 bFoundFlag) ));

14 41 ~ ti 1"i~ t~°
14 4 2 (T~<
1493 pAdapter->Request.RequestType - NdisRequestSetInformation:
1494 pAdapter->Request.DATA.SET INFORMATION.Oid ~ Oid:
1445 pAdapter->Request.DATA.SET INFORMATION.InformationBuffer =
InformationHuffer:
1446 pAdapter->Request.DATA.SET INFORMATION.InformatlonHUfferLength =
InformationBufferLength:
1447 pAdapter->HytesNeeded ~ BytesNeeded:
1448 pAdapter->HytesReadOrWritten = BytesRead:

1450 NdisRequest(b5tatus, pP.dapter->LowerMPHandle, bpAdapter->Request):

1452 if (Status ~ NDIS STATUS SUCCESS) ( 1453 'HytesRead = pP.dapter->Request.DATA.SET INFORMATION.BytesRead:
1454 'BytesNeeded = pAdapter->Request.DATA.SET INFORMATION.HytesNeeded:
1455 ) 1457 return (Statusl:
1458 ) ~;E,"~fh 1461 NDIS_STATUS
1462 MPQueryInformation( 1463 IN NDIS HANDLE . MiniportAdapterCOntext, F'~~d°°~'~"°g" 9:02 am Thursday, 30 September 1999 File: D:\nt4DDiC\src\tlmesn\tnsdrvr\tnsemul.c Page 19 of 20 1464 IN NDIS OID Oid, 1465 IN PVOID InformationBuffer, 1466 IN ULONG InformationBufferLength, 1467 OUT PULONG BytesWritten, 1468 OUT PULONG HytesNeeded) 1470 PADAPTER pAdapter a (PADAPTER)MiniportAdapterContext:
1471 NDIS STATUS Status = NDIS_STATUS_FAILURE:
1472 ULONG FoundFlag;

1474 D((0, "MPQueryInformation, Context => %x, (%x) NDIS OID -> %s\n", pAdapter, Oid, GetNDISOidString(Oid -2 , 6FoundFlag) )):

1476 pAdapter->Request.RequestType m NdisRequestQueryInfozmation:
1477 pAdapter->Request.DATA.QUERY INFORMATION.Oid ~ Oid:
1478 pAdapter->Request.DATA.QUERY INFORMATION.InformationHUffer ~
InformationHuffer:
1479 pAdapter->Request.DATA.QUERY INFORMATION.InformationBufferLength ~
InformationBufferLength:
1480 pAdapter->HytesNeeded = BytesNeeded:
1481 pAdapter->BytesReadOrWritten ~ BytesWritten:

1483 ~ _ _ 1484 ~l~"'~~'e,~~~.~'~ t~9!~~ .:.~'~T! "e.~?.~.8~~~'~~'~~i~~-t~~.

1486 NdisRequest(6Status, pAdapter->LowerMPHandle ,6pAdapter->Request);

1488 Sue, 14a9 d~t~,'~3.~~~gss,~.1?~~sJ~l~;~~esu9~~'tee"3eat3~tiat:e~~e..reguest 1490 ~/~ ..
1491 if (Status =° NDIS_STATUS SUCCESS) ( 1492 'HytesWritten = pAdapter->Request.DATA.QUERY INFORMATION.BytesWritten:
1493 'BytesNeeded a pAdapter->Request.DATA.QUERY INFORMATION.HytesNeeded:
1494 ) 1496 return(Status):

1501 CLRequestComplete( 1502 IN NDIS_HANDLE ProtocolBindingContext, 1503 IN PNDIS REQUEST NdisRequest, 1504 IN NDIS STATUS Status) lsos ( -1506 PADAPTER pAdapter - (PADAPTER) ProtocolBindingContext:
1507 NDIS OID Oid = pAdapter->Request.DATA.SET INFORMATION.Oid:
1508 ULONG FoundFlag:

- ~s ~ ~ ~~.~~8.i,~ev 1511 .,. . ,... ~ ' . a..
_.._ ~u:-~!i~...-- ~-' ~°

1513 if (pAdapter->LocalRequest) ( 1514 pAdapter->LOCalRequest ~ FALSE:
1515 NdisSetEvent(spAdapter->HlockingEvent):
1516 ) else ( 1517 switch(NdisRequest->RequestType) 1518 case NdisRequestQueryInformation:

1520 'pAdapter->HytesReadOrWritten ~ NdisRequest->DATA.QUERY
INFORMATION.BytesWritten:

1522 'pAdapter->HytesNeeded - NdisRequest->DATA.QUERY INFORMATION.HytesNeeded:

1524 D((0, ~CLRequest Complete, TNSNdisHandle ~> 8x, Status => %x, (%x) Oid ~>
%s\n", 1525 pAdapter->TNSNdisHandle, 1526 Status, 1527 Oid, 1528 GetNDISOidString(Oid, sFOUndFlag)));

1530 NdisMQueryInformationComplete(pAdapter->TNSNdisHandle, Status):

1532 break; , 1534 case NdisRequestSetInformation:

1536 'pAdapter->BytesReadOrWritten = NdisRequest->DATA.SET
INFORMATION.HytesRead:
1537 'pAdapter->HytesNeeded ~ NdisRequest->DATA.SET_INFORMATION.BytesNeeded:

1539 NdisMSetInformationCOmplete(pAdapter->TNSNdisHandle, Status):

1540 break:

1542 default:
1543 ASSERT(0):
1544 break:
~,ewbr~~.a-~~ 9:02 am Thursday. 30 September '1999 File: D:\nt4DDK\src\timesn\tnsdrvr\tnsemul.c Page 20 of 20 1545 }
1546 }
1547 ) ~ye9 '7:ek~:
r._.....,~..

~.~e.dbYGRISPbZ~~~ 9:02 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\recv.c Page 1 of 12 35$include "tns.h"

36$include "tnsdebug.h"

37$include ~x86.
h~

40MPReturnPacket( 41IN NDIS HANDLEMiniportAdapterContext, 42IN PNDIS_PACKETPacket):

45CLReceiveIndication( 46IN NDIS HANDLEProtocolBindingCOntext, 47IN NDIS HANDLEMacReceiveContext,, 48IN PVOID HeaderBuffer, 49IN UINT HeaderBufferSize, 50IN PVOID LookAheadBuffer, 51IN UINT LookaheadHufferSize, 52IN UINT ' PacketSize):

55CLReceiveComplete( 56IN NDIS_HANDLEProtocolHindingContext);

58NDIS_STATUS

59MPTransferData( 60OUT PNDIS PACKETPacket, 61OUT PUINT HytesTransferred, 62IN NDIS HANDLEMiniportAdapterContext, 63IN NDIS HANDLEMiniportReceiveContext, 64.' IN UINT HyteOffset, 65IN UINT HytesToTransferl:

68CLTransferDateCOmplete( 69IN NDIS HANDLEProtocolBindingContext, 70IN PNDIS PACKETpNdisPacket, 71IN NDIS STATUSStatus, 72IN UINT HytesTransferred):

76MPReturnPacket( 77IN NDIS HANDLEMiniportAdapterContext, 78IN PNDIS_PACKETPacket) 80PADAPTER pAdapter(PADAPTER)MiniportAdapterContext:
=

81PTNS_PACKET_CONTEXTPktContext:

82PNDiS PACKET
MPPacket:

9:05 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\recv.c Pegs 2 of 12 83 PNDIS BUFFER NdisBuffer:
84 PBUFFER CONTEXT HufContext:
85 DINT Length;
86 PUCHAR MediaArea;
87 UINT Size:

89 DM((DEBUG VERBOSE, DEBUG MASKEN-ENTRYEXIT, ~MPReturnPackets =>\n"));
91 ~T
92 ,~~ , eie _ ''Sri ea ~ket°'1."'~'~'at es'~~at~l.'~'",~elesag ..~.,...
9 3 f ~~.aFa :.~omecneM.be ~tLS~and..~etn~a .it wba i~_....._.,:,....»...,~....._~....~_...-.

96 PktContext ~ PACKET CONTEXT FROM PACKET( Packet );
97 - _ _ 98 MPPacket = PktContext->OriginalPacket:

100 DM((DEBUG_VERBOSE, DEBUG MASKEN-RECV, "(%08X) MPReturnPacket: IM Packet %OBX\n", pAdapter, Packet)):

102 if ( MPPacket ) ( 104 D((0, ~(%08X) MPAeturnPacket: Returning MP Packet %08X\n", pAdapter, Packet)):

106 NdisReturnPackets( 6MPPacket, 1 );

108 ) else ( 110 P,~ _ 112 ~~~ae'~'s~::~C"iF~a~'.~C2~~~ee;~~oi~_ 113 NDIS_GET_PACKET_MEDIA_SPECIFIC_INFO( Packet, 6MediaArea, 6Size );

115 NdisUnchainHufferAtFront( Packet, aNdisHuffer );

117 MyAssert( NdisHuffer !e NULL ):

119 NdisQueryBuffer(.NdisHuffer, 6BUfContext, bLength );

121 NdisFreeBuffer(NdisHuffer):
122 NdisFreeMemory(BufCOntext, Length, 0):

124 NdisUnchainBufferAtFront( Packet, 6NdisHuffer );

126 if ( NdisBuffer ) ( 127 Breakpoint();
128 ) 129 ) 131 NdisReinitializePacket( Packet ):
132 NdisFreePacket(Packet);

134 DM((DEHUG VERBOSE, DEBUG MASKEN_ENTRYEXIT, "MPReturnPackets <=\n~)):

137 unsigned char BroadcastAddress(] - (Oxff, Oxff, Oxff, Oxff, Oxff, Oxff):

139 int 140 TnsCheckAddressEtherType( 141 PADAPTER pAdapter, 142 unsigned char ~pHeaderBuffer, 143 ULONG HeaderBufferSize) 144 ( 145 , int beast - FALSE;
146 int ucast ~ FALSE:
147 unsigned short 'pEtherType:

152 if (memcmp(pHeaderBuffer, BroadcastAddress, 6) ~- 0) 153 beast = TRUE:

155 , s~'~Gfhi~x~.
156 ~$.~H..~"~~i~a~GtE~.,~~~~:~

158 if (memcaap(6pHeaderBuffer[6], pAdapter->LorrerMPMacAddress. 6) ~ 0) ( 159 return FALSE;

160 ) 161 ) ~~.eeycwaPVe.Z.~~ 9:OS am Thursday. 30 September 1999 Flle: D:\nt4DDK\src\timesn\tnsdrvr\recv.c Page 3 of 12 165 pEtherType = (unsigned short ~)bpHeaderHuffer[12]:

167 ~s1 168 ~.";a~s't~ ,a~i~:
y 170 if ( TNS_EMULATION ETHERTYPE== wswap(~pEtherType) ) 171 return TRUE;
172 ) 175 ~~~~~'s"
~lr~.~.~~...,..

177 return FALSE.
178 ) 182 CLReceiveIndication( 183 IN NDIS_HANDLE ProtocolBindingContext, 184 IN NDIS HANDLE MacReceiveContext, 185 IN PVOID HeaderHUffer, 186 IN UINT HeaderBufferSize, 187 IN PVOID LookaheadBuffer, 188 IN UINT LookaheadBufferSize, 189 IN UINT Packei5lze) 190 ( 191 PADAPTER pAdapter = (PADAPTER)ProtocolHindingContext;
192 PSINGLE LIST ENTRY ResidualEntry a NULL;
193 PTNS_PACKET CONTEXT PktContext;
194 PNDIS_HUFFER LookaheadNdisHuffer:
195 PNDIS PACKET OurPacket:
196 NDIS_STATUS Status:
197 NDIS STATUS OurPacketStatus~NDIS STATUS SUCCESS;
198 PVOID vHuffer:
199 NDIS PHYSICAL ADDRESS HighAddress ~ NDIS PHYSICAL ADDRESS CONST( -1, -1 );
200 int i;

202 DM((DEBUG_VERHOSE, DEBUG MASKEN ENTRYEXIT, ~CLReceiveIndication ~>\n~)):

205 if (!pAdapter->TNSDriverInitialized) 207 -cR':.- tr~3t"~~~'~
.,:~~~:._...

209 HreakPoint():
210 return NDIS STATUS NOT ACCEPTED:

215 "::~.r,:,~'~~5-~a"~'-~a~~°F

217 if (HeaderHufferSize >a 14) 218 if (TnsCheckAddressEtherType(pP.dapter, HeaderBUffer, HeaderHUfferSize)) ( 219 unsigned short ~pEtherType:
220 PVOID pTnsPacket = NULL:
221 PTNSPacketHeader pTnsPacketHeader ~ NULL:
222 unsigned short TNSCocmnand;

224 _.....:~,.

228 ' ' ':'-~ . ~ ~~._.

230 , 232 if (HeaderBufferSize a= PacketSize) 233 pTnsPacket - HeaderHuffer;
234 ) 235 if ((pTnsPacket == NULL) b (HeaderBufferSize < PacketSize) ) [
236 if (HeaderHufferSize ~~ 14) ( 237 pTnsPacket = b((unsigned char ~)Lookahead8uffer)(-14]:
238 i 239 ) 2 4 0 i . _.,.,........~_..... ..~,...._ . ... ~..'~~ :~r..:.».
x -2 ._ ,- ; ~°~r~ ' 242 MyASSerL(pTnsPacket !e NULL):

244 ~~ .~ ~': ._._r.~. .. .. ... ... _ Y-__ ' ' ' vnne.aM~aP.~e.a.~~ 9:05 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\recv.c Page 4 of 12 246 TNSCommand = wswap(((PTNSPacketNeader)pTnsPacket)->TNSCommandReply):

248 switch (TNSCommand) 299 case TNS HELLO BROADCAST:
250 D((0, "TNS HELLO BROADCAST\n~)):
251 if (TNSSharedMemoryNOdeEmulation) 252 F ~e"~''~~e~'3th~~~mn~ r ~' ~~, s~
254 TnsIncrementStat(pAdapter, spAdapter->MyStats.numSrvHelloBroadcasts):

256 6!~l 257 ~. ~ '~'~'~h'~. "'~~ ~ ~iaiAedo ~"' ~",~ias;~.
'.:..~1'rtx:__..rr, u.,.,_..~_~,.._..__~ ~'::,. .. ..
258 91 ~~tEd:~

260 if ( (pAdapter->TNSSharedMemoryPtr) 66 (pAdapter->TNSSharedMemorySize) ) ( 261 TNSBuildBroadcastReplyAndSend(pAdapter, pTnsPacket, HeaderBUffer):

263 ) else 1 265 4 ~ t""i's"~r'~~"~,~,adca~s 266 a]io~pe,~q3c.;
267 ) 268 break:
269 case TNS HELLO REPLY:
270 D((0, "TNS HELLO_REPLY\n")):
271 if (TNSSharedMemoryNodeEmulation) 273 ~-~~~~ . ;i 279 3' 276 MyASSert(0):
277 ) else 1 278 PLIST ENTRY pRequestObj:
279 PREQUEST DATA pRqstData:
280 unsigned char ~pHuffer:
281 _ _ ~~ uFa>: w s_a}
2 8 3 ~i .: a ~'~r 285 pAdapter->TNSCIIentNOdeID = ((PTNSPacketHelloReply)pTnsPacket)->TNSClientNodeID:
286 D((0, ~Server Hello reply, Client NodeID => %d\n~, pAdapter->TNSClfentNodeID)):
287 pAdapter->TNSSharedMemorySize = dwswap(((PTNSPacketHelloReply)pTnsPacket)->TNSSha -2 redMemorySize):

289 D((0, "TNSSharedMemorySize ~> %x\n~, pAdapter->TNSSharedMemorySize)):

291 for (i=0: i<6; i++) 292 pAdapter->SMNMacAddress[i] _ ((PTNSPacketHelloReply)pTnsPacket)->St~lServerMac -2 Address[i]:
293 ) 294 RtlCopyMemory(6pAdapter->SMNMachineName, ((PTNSPacketHelloReply)pTnsPacket)->SMNM
-2 achineName, 16):
295 ~ _ _ 296 ;' e~~:J ~.~~ ..

298 pRequestObj = ExInterlockedRemoveHeadI,ist( 299 6pAdapter->WOrkerListEntryPool, 300 6pAdapter->ListEntryPoolLock):

302 pRqstData = CONTAINING RECORD(pRequestObj, 303 REQUEST DATA, 304 Linkagej;

309 pRqstData->pNdisPacket = NULL:
310 pRqstData->requestOpcode = TNS HELLO REPLY:

313 ._..._ .. _.

315 ExInterlockedInsertTailList( 316 bpAdapter->ClIentWOrkerListEntry, 317 6pRqstData->Linkage, 318 6pAdapter->CllentWOrkerListSpinLock):

323 KeReleaseSemaphore( 324 spAdapter->CllentWOrkerResponseSemaphore, ~~~~~bz-~~ 9:05 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\recv.c Page 5 of 12 325 (KPRIORITY) 0, 326 (LONG) 1, 327 FALSE);

329 yi~~.~.~~!e~o,*~~.~9.~99'~.~.

332 ) 333 break:

334 READ REQUEST:
case TNS

335 _ ~S]'iSTS.1~1~;

336 if (TNSSharedMemoryNodeEmulation) [

337 PLIST ENTRY pRequestObj:

338 PREQUEST DATA pRqstData;

339 unsigned char p8uffer:

341 TnsIncrementStat(pAdapter, 6pAdapter->MyStats.numSrvReadRequests);

343 if (pAdapter->TNSMemoryType == VIRTUAL MEMORY) ( 395 ~~

_ 34 6 ~l~'e.~[)~.~~7~..~! r~
~'a -. ~3.~~
.

347 .
.
._ 399 ~~

_ 350 ~~q~e~2e ~~~~xb~~ue:

3 51 Y:

352 pRequestObj = ExInterlockedRemoveHeadList( 353 6pAdapter->workerListEntryPool, 354 6pAdapter->ListEntryPOOlLock):

356 MyAssert(pRequestObj):

358 pRqstData = CONTAINING RECORD(pRequestObj, 359 REQUEST DATA, 360 Linkagej:

362 MyASSert(pRqstData);

365 . ~.~~ o 367 pRqstData->pNdisPacket = NULL:

368 pRqstData->requestOpcode = TNS READ REQUEST:

369 pBuffer = (unsigned char )apRqstData->TnsPacket:

370 RtlCopyMemory(pBuffer, HeaderBUffer, HeaderBufferSize):

371 RtlCopyMemory(spBuffer[NeaderHufferSize], LookaheadBuffer, Lookahead8ufferSiz -2 e):

373 ~' _ 37 4 ."~,~,~~....~.~.~.~,.'D~~~~,.',...et~e:

376 ExInterlockedInsertTailList( 377 spAdapter->ServerWOrkerListEntry, 378 6pRqstData->Linkage, 379 apAdapter->ServerWOrkerListSpinLock);

3 8 2 ., ~ ~'~~. ~a.~~..

389 KeReleaseSemaphore( 385 6pAdapter->ServerWorkerRequestSemaphore, 386 (KPRIORITY) 0, 387 (LONG) 1, 388 FALSE):

389 ) 391 if (pAdapter->TNSHemoryType == NONPAGED MEMORY) [

392 PNDIS PACKET MyPacket:

393 ULONG PacketLength:

394 PVOID pTnsBuffer:

395 NTSTATUS Status:

396 PUCHAR veuffer:

398 vBuffer = pAdapter->TNSSharedMemoryPtr:

400 PacketLength = TNS PACtCET_SI2E(TNSPacketReadReply):

402 Status = TNSInitializeCllentNOdeSendPacket(pAdapter, 403 6MyPacket, 404 6pTnsBuffer, 905 PacketLength):

9:05 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\recv.c Page 6 of 12 q07 RtlCopyMemory(pTnsBuffer, 6((PTNSPacketHeader)pTnsPacket) ->MACSrcAddress, 6):

408 /~ _ 409 ~ket~~~orne~i~a.~g~ .' ~Y~FB~~P

.

ql~ ~PTNSPacketHeader)pTnsBUffer)->TNSCommandReply =
wswap(TNS READ_REPLY):

413 ((PTNSPacketReadReply)pTnsHuffer)->RequestTag =
((PTNSPacketReadRequest -2 )pTnsPacket)->RequestTag:
uestStartTSC m ((PTNSPacketReadRequest ffer)->Re T
B
dR
k l qlq q u ns etRea ep y)p ((PTNSPac -2 )pTnsPacketl->RequestStartTSC:

415 vHUffer =
(PUCHAR)((ULONG)vBuffer+(ULONG)dwswap(((PTNSPacketReadRequest)pTnsP

-2 acket)->RequestOffset)):

q17 if (dwswap(((PTNSPacketReadRequest)pTnsPacket)->Request0ffset) <= pAdapter->T

-2 NSSharedMemorySize) ( 418 ((PTNSPacketReadReply)pTnsHuffer)->dwData =
'((PULONG)vBuffer):

qlg } else ( q20 asm int 3 q22 TNSSendPackets(pAdapter->LowerMPHandle, 6MyPacket, 1);

423 ) q25 } else ( 426 MyAssert(0):

427 ) 428 break;

q29 cas e TNS READ REPLY:

4 30 ~''~.'".~.~

q31 if (TNSSharedMemoryNodeESnulation) ( 432 , 433 .a ...''-~~~?.R

434 .

435 MyAssert(0);

436 } else ( q37 PLIST ENTRY pRequestObj:

q3g PREQUEST DATA pRqstData:

q39 unsigned char 'pBuffer:

440 _ 4 41 .~~~..'.., 4 4 5 ..M. ......:.-. -~~~.c.~. ~'ss :.:.~~

qq7 pKequestObj = ExInterlockedRemoveHeadList( 448 6pAdapter->WOrkerListEntryPOOl, qqg _ 6pAdapter->ListEntryPoolLock):

451 pRqstData = CONTAINING RECORD(pRequestObj, q52 REQUEST DATA, 453 Linkagej:

458 pRqstData->pNdisPacket a NULL:

459 pRqstData->requestOpcode - TNS READ REPLY:

460 pBUffer = (unsigned char ')6pRqstData->TnsPacket:

461 RtlCopyMemory(pBuffer, HeaderBuffer, HeaderBufferSize):

462 RtlCopyMemory(6pHUffer[HeaderBufferSize], LookaheadHuffer, LookaheadBufferSize):

464.
T

4 65 .._ ~, . ~

4 6.6 q67 ExInterlockedInsertTailList( 468 6pAdapter->CllentWOrkerListEntry, q6g 6pRqstData->Linkage, q70 6pAdapter->CllentWOrkerListSpinLOCk):

4 7 3 . ... ..

q75 KeReleaseSemaphore( 476 6pAdapter->CllentWOrkerRequestSemaphore, 477 (KPRIORITY) 0, 478 (LONG) 1, q79 FALSE):

483 ) varreeycwsPVe.z,. 9:05 am Thursday, 30 September 1999 Flle: D:\nt4DDK\src\timesn\tnsdrvr\recv.c Page 7 of 12 484 break:
485 case TNS WRITE REQUEST:
w.
4 8 6 ~~i'~:..~,.~-i-. :.~~:ii.' 488 if (TNSSharedMemoryNodeEmulation) ( 490 TnsIncrementStat(pAdapter, 6pAdapter->MyStats.numSrvWriteRequests):

492 if (pUAdapter->TNSMemoryfype =- VIRTUAL_MEMORY) S~ry 496 PLIST ENTRY pRequestObj:
q97 PREQUEST DATA pRqstData:
498 ' unsigned char ~pBuffer:
499 ;
500 _ .....~~'~$~.~~

b 504 ,' .-.....:' >,.e.. ,.: . . ....,..... ' ~'~. .~~ .. ~~~29u.~~e.~4 506 pRequestObj w ExinterlockedRemoveHeadList( 507 6pAdapter->WOrkerListEntryPOOl, 508 6pAdapter->ListEntryPOOlLOCk):

510 pRqstData w CONTAINING RECORD(pRequestObj, 511 REQUEST DATA, 512 Linkage);

515 r 517 pRqstData->pNdisPacket = NULL:
518 pRqstData->requestOpcode w TNS WRITE REQUEST:
519 pBuffer - (unsigned char ~)~pRqstData->TnsPacket:
520 RtlCopyMemory(pHuffer, HeaderBuffer, HeaderHufferSize):
521 RtlCopyMemory(spHuffer[HeaderHufferSize], LookaheadBuffer, LookaheadBufferSiz -2 e):

523 ' 524 _,~ .. , 526 ExInterlockedInsertTallList( 527 6pAdapter->ServerWOrkerListEntry, 528 6pRqstData->Linkage, 529 6pAdapter->ServerWOrkerListSpinLock):

532 ..

534 KeReleaseSemaphore( 535 6pAdapter->ServerWorkerRequestSemaphore, 536 (KPRIORITY) 0, 537 (LONG) 1, 538 FALSE):
539 ) 541 if (pAdapter->TNSMemoryType ~ NONPAGED MEMORY) 543 PNDIS PACKET MyPacket:
544 ULONG PacketLength:
545 PVOID pTnsHuffer;
546 ' NTSTATUS Status:
547 PUCNAR vBuffer:

54 9 . ..,. , 551 vBuffer = pAdapter->TNSSharedMemoryPtr:

553 vBuffer = (PUCHAR)((ULONG)vHUffer+(ULONG)dwswap( ((PTNSPacketWriteRequest)pTn -2 sPacket)->RequestOffset));

555 if (dwswap( ((PTNSPacketWriteRequest)pTnsPacket)->RequestOffset) <w pAdapter--2 >TNSSharedMemorySize ) 556 ~((PULONG)vHuffer) _ ((PTNSPacketWriteRequest)pTnsPacket)->dwData:
557 ) else ( 558 asm int 3 r~s..ewercweP.~e-e.,~ 9:05 am 'rh~Bday, 30 Ssptermber 1999 File: D:\nt4DDtC\src\timesn\tnsdrvr\recv.c Pege 8 of 12 565 PacketLength = TNS PACKET SI2E(TNSPacketWriteReply):
566 Status = TNSInitializeClientNodeSendPacket(pAdapter, 567 6MyPacket, 568 6pTnsBUffer, 569 PacketLength):

571 RtlCopyMemory(pTnsBuffer, 6((PTNSPacketWriteRequest)pTnsPacket)->MACSrcAddres -2 s. 6):
572 ~.
73 J ~='t""n~.:+ 2169 ~c'~u'r~'., .,_-_-.: .-_,-~~.«~..;~ ~~ ................,.~.__..........
5 7 4 yf<
575 ((PTNSPacketWriteReply)pTnsHuffer)->TNSCommandReply = wswap(TNS WRITE
ACK):
576 ((PTNSPacketwriteReply)pTnsBuffer)->RequestTag = ((PTNSPacketWriteReques -2 t)pTnsPacket)->RequestTag:
577 ((PTNSPacketWriteReply)pTnsBUffer)->RequestStartTSC =
.((PTNSPacketWriteReques -2 t)pTnsPacket)->RequestStartTSC:
578 ' 579 TNSSendPackets(pAdapter->LOwerMPHandle, 6MyPacket, 1);
580 ) 582 ) else ( 584 ~ " ... w 585 ~~' 586 MyASSert(0):
587 ) 588 break;

590 case TNS WRITE ACK:

592 if (TNSSharedMemoryNodeEmulation) 5 94 au~~~~

596 MyASSert(0):
597 ) else ( 598 PLIST_ENTRY pRequestObj:
599 PREQUEST DATA pRqstData:
600 unsigned char ~pBuffer:

602 ,'~' .."K.

608 pRequestObj = ExInterlockedRemoveHeadList( 609 6pAdapter->WOrkerListEntryPool, 610 spAdapter->ListEntryPoolLock):

612 pRqstData ~ CONTAINING RECORD(pRequestObj, 613 REQUEST DATA, 614 Linkagej:

619 pRqstData->pNdisPacket ~ NULL:
620 pRqstData->requestOpcode ~ TNS WRITE ACK:
621 pBuffer - (unsigned char ')6pRqstData->TnsPacket:
622. RtlCopyMemory(pBuffer, HeaderBuffer, Header8ufferSize):
623 RtlCopyMemory(apBuffer[HeaderBUfferSize), LookaheadBUffer, LookaheadBufferSize):

625 _ 626 ~~~'a'T.g~,.'~ _'~ - .

628 ExInterlockedInsertTailList( 629 6pAdapter->CllentWorkerListEntry, 630 spRqstData->Linkage, 631 6pAdapter->ClientWorkerListSpinLOCk):

636 KeReleaseSemaphore( 637 6pAdapter->ClientWorkerRequestSemaphore, 638 (KPRIORITY) 0, 639 (LONG) 1, 640 FALSE):

Pn.,ew ey ~ b.s.,~ 9:05 am Thursday. 30 September 1999 Flle:
D:\nt4DDK\src\timesn\tnsdrvr\recv.c Page 9 of 642 ~.~a~rae ~~.o "'ess~'-~~~,~~s~a"'~e 644 ) 645 break:

646 case TNS QUERY STATS:

a;
4 7 1.
~a'..'.'.,~~.~<

648 PLIST ENTRY pRequestObj;

649 PREQUEST DATA pRqstData;

650 unsigned char pHuffer;

652 PNDIS PACKET MyPacket;

653 ULONG PacketLength;

654 PTNSPacketQueryStatsReply pTnsHuffer;

655 NTSTATUS Status;

656 NDIS STATUS NdisStatus;

657 PUCHAR vBuffer;

659 TnsIncrementStat(pAdapter, 6pAdapter->MyStats.numSrvQueryStats):

661 vBUffer a pAdaptez->TNSSharedMemoryPtr:

663 PacketLength = TNS PACKET SIZE(TNSPacketQueryStatsReply);

665 Status ~ TNSInitializeClientNodeSendPacket(pAdapter, 666 6MyPacket, 667 6pTnsHuffer, 668 PacketLength);

670 RtlCopyMemory(pTnsHuffer, a((PTNSPacketHeader)pTnsPacket)->MACSrcAddress, 6);

672 ~~.a~a..~.

674 _ _ -pTnsHUffer->TNSCommandReply ~ wswap(TNS QUERY STATS
REPLY);

676 pTnsBuffer->RequestTag - ((PTNSPacketQueryStats)pTnsPacket)->RequestTag:

677 pTnsBuffer->RequestStartTSC = ((PTNSPacketQueryStats)pTnsPacket)->RequestStartTSC

-2 ;

67g RtlCopyMemory(6pTnsHuffer->TnsNodeStatistics, 6pAdapter->MyStats, sizeof(STATISTI

-2 CS) ); RtlCopyMemory(6pTnsHUffer->MpStats, spAdapter->mpStats, 680 sizeof(MPSTATS) );

682 pTnsBuffer->NdisStatus - STATUS SUCCESS:

684 TNSSendPackets(pAdapter->LowerMPHandle, 6MyPacket, 1);

686 ) 687 break;

689 CLEAR_STATS:
case TNS

690 _ ~ ' . ..''.:.

692 Rtl2eroMemory(6pAdapter->MyStats, sizeof(STATISTICS) ):

693 RtlZeroMemory(6pAdapter->mpStats, sizeof(MPSTATS) ):

695 break;

6g7 case TNS QUERY $TAT$ REPLY: ( ..

698 ~~.
..~~'Ya 699 PLIST_ENTRY pRequestObj:

700 PREQUEST DATA pRqstData;

701 unsigned char pHuffer;

703 ,~k ._ 706 . , 707 ~,.~~', ~, ._..,..~.. . .._ 70g pRequestObj ~ ExInterlockedRemoveHeadList( 710 6pAdapter->WorkerListEntryPool, 711 6pAdapter->ListEntryPOOlLock);

713 pRqstData = CONTAINING RECORD(pRequestObj, 71q REQUEST DATA, 715 Linkagej:

~
~
~

718 ~..o.
~ ~~i' ~ .....

720 pRqstData->pNdisFacket ~ NULL;

721 pRqstData->requestOpcode ~ TNS QUERY STATS REPLY;

~nneweycweP.~e-s.~~ 9:08 am ThW sday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\recv.c Page 10 of y2 722 pBuffer = (unsigned char ~)apRqstData->TnsPacket:
723 RtlCopyMemory(pBuffer, HeaderBuffer, HeaderBufferSize):
724 RtlCopyMemory(6p8uffer[HeaderHufferSize), LookaheadBuffer, LookaheadBufferSize):

726 7!~: _ 727 ~' p'..:..,.1~...~ '~E~~'~~~:.tits~a~r~:
728 ~~.
729 ExInterlockedInsertTailList( 730 6pAdapter->ClientWorkerListEntry, 731 6pRqstData->Linkage, 732 6pAdapter->CllentWOrkerListSpinLock):

734 ~j:
i'~fir83ti 7 35 ~~~"....~~........>._.........

737 KeReleaseSemaphore( 738 6pAdapter->ClientWOrkerRequestSemaphore, 739 (KPRIORITY) 0, 740 (LONG) 1, 741 FALSE):
7 4 2 ,~'-, _ 7 4 4 ili~
745 ) ..._..
746 break;

748 case TNS STRING WRITE REQUEST:
749 D((0, "TNS STRING_WRITE_REQUEST\n~)):
750 MyAssert(0);
751 if (TNSSharedMemoryNodeEmulation) 752 ) else ( 753 ) 754 break:
755 case TNS STRING_READ REQUEST:
756 D((0, ~TNS STRING_READ_REQUEST\n")):
757 MyASSert(Oj:
758 if (TNSSharedMemoryNOdeEmulation) ( 759 ) else ( 760 ) 761 break:
762 case TNS STRING READ REPLY:
763 D((0, "TNS STRING_READ_REPLY\n~)):
764 MyAssert(Oj:
765 if (TNSSharedMemoryNOdeF7nulation) ( 766 ) else ( 767 ) 768 break:
769 default:
770 D((0, "Unrecognized command ~> %x\n", TNSCommand)):
771 D((0, "HeaderBuffer => 8x, HdrBufferSize => 8x\n~, HeaderBuffer, HeaderBUfferSize)) 772 D((0, "LookahedHuffer ~> 8x, LAHufferSize => %x\n", LookaheadBuffer, LookaheadBUffer -2 Size1):
773 MyASSert(0):
774 break;
775 ) 777 ) 779 ) else 780 D((0, "HeaderHufferSize not equal to or gt than 14, HeaderBufferSize ~>
%d\n~, Heade=BufferSize)) 781 _asm int 3 782 ) 784 DM((DEBUG VERBOSE, DEBUG MASKEti-RECV, "HeaderBuffer a> %x, HeaderBufferSize => %x, LookaheadBuffer =>
-2 %x, LookaheadBufferSize -> 8x\n", 785 HeaderBuffer, 786 HeaderBufferSize, 787 LookaheadBuffer, 78B LookaheadBufferSize));

790 NdisAllocatePacket(6Status, 60urPacket, pAdapter->PacketPOOlHandle);

792 NdisReinitializePacket(OurPacket):

794 DM((DEBUG VERBOSE, DEBUG MASIDrN-RECV, ~CLReceiveIndication: OurPacket =>
%x\n", OurPacket)):

796 MyAssert(OurPacket->Private.Head ~~ NULL):

798 NDIS SET PACKET STATUS(OurPacket, OurPacketStatus):
799 - _ _ 9:05 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\recv.c Page y ~ of 12 800 Status - NdisAllocateMemory(6vBuffer, 2000, 0, HighAddressl:

802 if (Status !~ NDIS_STATUS_SUCCESS) ( 803 HreakPoint():
804 }

806 NdisAllocateBuffer(6Status, 807 sLookaheadNdisBuffer, 808 pAdapter->LookaheadPOOlHandle, 809 vBuffer, 810 2000);

812 if (Status != NDIS_STATUS_SUCCESS) 813 HreakPoint():
814 }

816 DM((DEHUG_VERBOSE, DEHUG_MASKEN_RECV, "CLReceiveIndlcation:
LookaheadNdisBuffer => %x\n~, LookaheadNd -2 isBuffer))t 818 PktContext ~ PACKET_CONTEXT_FROM_PACKET(OurPacket):

820 DM((DEHUG VERBOSE, DEBUG MASKEN RECV, "(%08X) CLReceiveIndication: Packet %08X Packetsize %d 8s\n", 821 pAdapter, OurPacket, PacketSize, 822 (PacketSize != LookaheadBufferSize Z "(RD)~ . ~~))):

824 PktContext->OriginalPacket = NULL:

826 if (pP.dapter->COpyLookaheadData) ( 827 NdisMoveMemory(vBUffer, Headereuffer, HeaderBUfferSize):
828 NdisMoveMemory((CHAR ~)vHuffer+HeaderHufferSize, LookaheadHuffer, LookaheadHufferSize):
829 } else ( 830 TdiCopyLookaheadData(vBuffer, HeaderBuffer, HeaderBufferSize, 0):
831 TdiCopyLookaheadData(ICHAR ~)vBuffer+HeaderBufferSize, LookaheadHuffer, LookaheadHUfferSize, 0):
832 }

834 NdisAdjustBufferLength(LookaheadNdisBuffer, HeaderBuffersize+LookaheadBUfferSize):
835 NDIS SET PACKET HEADER SIZE(OurPacket, HeaderBufferSize):
836 NdisChainBUffezAtFront(OurPacket, LookaheadNdisBuffer):

838 DUMP_PACKET(OurPacket):

840 DM((DEBUG_VERBOSE, DEBUG MASKEN_RECV, ~Adapter->TNSNdisHandle -> 8x, OurPacket => %x\n", pAdapter->TN
-2 SNdisHandle, OurPacket)):
841 NDIS SET PACKET STATUS(OurPacket, NDIS STATUS RESOURCES):
842 - _ _ _ 843 NdisMIndicateReceivePacket(pAdapter->TNSNdisHandle, 60urPacket, 1):

845 if ( NDIS GET PACKET_STATUS(OurPacket) !~ NDIS STATUS_PENDING) ( 846 MPReturnPacket( (NDIS HANDLE)pAdapter, OurPacket ):

849 DM((DEHUG VERBOSE, DEBUG MASIDrN_ENTRYEXIT, ~"CLReceiveIndication <=\n")):
850 return NDIS_STATUS_SUCCESS:

852 ) 856 CLReceiveComplete( B57 IN NDIS HANDLE ProtocolBindingContext) ese ( -859 PADAPTER pAdapter~= (PADAPTER)ProtocolHindingCOntext:

861 . DM((DEBUG_VERBOSE, DEBUG MASKEN ENTRYEXIT, ~CLReceiveComplete ~>\n")):

863 if (pAdapter->TNSDriverInitialized) ( 865 switch( pAdapter->MediaType ) 866 case NdisMedium802 3:
867 DM((DEBUG VERBOSE, DEBUG MASKEN RECV, ~(%08X) CLReceiveComplete: 802 3\n", pAdapter)):
86B NdisMEthIndicateReceiveComplete( pAdapter->TNSNdisHandle ):
869 break:

871 case NdisMedium802 5:
872 D((0, ~(%08X) CLReceiveComplete: 802 5\n", pAdapter)):
873 HreakPOint():
874 NdisMTrIndicateReceiveComplete( pAdapter->TNSNdisHandle ):
875 break;

877 case NdisMediumFddi:
878 D((0, "(%08X) CLReceiveComplete: FDDI\n", pAdapter)):
879 Breakpoint():
'~ 9:05 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\recv.c Page 12 of y2 880 NdisMFddiIndicateReceiveComplete( pAdapter->TNSNdisHandle ):
881 break:

883 default:
884 MyAssert( FALSE ):
885 ) 886 ) else 887 BreakPOint():
88~ ) 890 DM((DEHUG_VERBOSE, DEBUG MASID;N_ENTRYEXIT, ~CLReceiveComplete <~\n"));
8 91 ) Q~'E3 893 NDIS_STATUS
894 MPTransferData( 895 OUT PNDIS PACKET Packet, 896 OUT PUINT BytesTransferred, 897 IN NDIS_HANDLE MiniportAdapterContext, 898 IN NDIS HANDLE MiniportReceiveCOntext, 899 IN UINT HyteOffset, 900 IN UINT HytesToTransfer) 902 PADAPTER Adapter = (PADAPTER)MiniportAdapterContext:

904 D((0, ~(%08X) MPTransferData:\n", Adapter)):
905 HreakPOint():
906 return NDIS STATUS_FAILURE:
907 ) (~,~

910 CLTransferDataComplete( 911 IN NDIS HANDLE ProtocolHindingContext, 912 IN PNDIS PACKET Packet, 913 IN NDIS STATUS Status, 914 IN DINT BytesTransferred) 916 PADAPTER pAdapter a (PADAPTER)ProtocolHindingContext:
917 PTNS PACKET_CONTEXT PktContext:

919 DM((DEBUG VERBOSE, DEBUG MASKEN_ENTRYEXIT, "CLTransferComplete ~>\n")):
920 D((0, "(%08X) CLTransferDataComplete: Packet %08X Status %08X Bytes xfer'ed %d\n~, 921 pAdapter, Packet, Status, BytesTransferred)):

923 PktContext a PACKET CONTE7CT_FROM-PACKET( Packet ):

925 NdiaChainBUfferAtFront(Packet, PktContext->LOOkaheadBUffer):

927 NdisMIndicateReceivePacket(pAdapter->TNSNdisHandle, 6Packet, 1):

929 if ( NDIS GET PACKET STATUS(Packet) !e NDIS STATUS_PENDING) [
930 MPReturnPacket((NDIS HANDLE)pAdapter, Packet):
931 ) 933 DM((DEHUG VERBOSE, DEHUG_MASKEN ENTRYEXIT, "CLTransferComplete <-\n")):
934 1 . ~~_ P",.ew"y~re.z.,. 9:05 am Thursde~y, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\send.c Page 1 of 3 33 6lnclude "tns.h"
34 iinclude "tnsdebug.h"
iinclude "x86. h"

37 9define MAX_LOCAL_PACKE'1'_ARRAY 10 MPSendPackets( 41 IN NDIS HANDLE MiniportAdapterContext, 42 IN PPNDIS_PACKET PacketArray, 93 IN UINT NumberOfPackets 44 ):

48 CLSendComplete( 49 IN NDIS_HANDLE ProtocolHindingContext, IN PNDIS PACKET Packet, 51 IN NDIS_STATUS Status 52 ):

MPSendPackets( 56- IN NDIS HANDLE MiniportAdapterContext, 57 IN PPNDIS_PACKET PacketArray, 58 IN UINT NumberOfPackets) s9 ( PADAPTER pAdaptere(PADAPTER)MiniportAdapterContext:
61 PNDIS PACKET Packet:
62 PNDIS PACKET MyPacket:
63 PNDIS PACKET MyPacketArray[MAX LOCAL_PACIdrT_ARRAY]:

PSINGLE LIST ENTRY PacketEntry ~ NULL:
66 PTNS PACKET CONTEXT PktContext:
67 PNDIS_BUFFER FirstBuffer:
68 PNDIS_PACKET OOH DATA My00HData;
69 PNDIS_PACKET_OOH DATA OOHData:
ULONG PacketLength, 1:
71 ULONG NumMyPackets=0:
72 NDIS_STATUS Status:

74 DM((DEBUG_VERBOSE, DEBUG MASKEN ENTRYEXIT, "MPSendPackets s>\n")):
DM((DEBUG_VERHOSE, DEHUG_MASICE61_SEND, ~(:08X) MPSendPackets: 9d XPORT
packets\n~, pAdapter, Numt -2 ackets)):

77 if (pAdapter) ( 78 if (!pAdapter->TNSDriverInitialized) ( 79 .i .. ...
~nre.aey~va.z.,. 9:05 am Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\send.c Page 2 of 3 62 HreakPoint():
83 ) 84 ) 86 for (i~0; i<NumberOfPackets: ++i) [ s8,""", "~~z~:~a 87 _ 88 ~0~,~'~'.~°~~zs"°"adl'~rai~'~' 90 Packet = PacketArray[i]:

92 DUMP PACKET(Packet):
94 tt'!~u~~~',~~tt~""~
.:.u -eov~t.~~ ~r js~ .
96 _...
97 NdisAllocatePacket(6Status, sMyPacket, pAdapter->PacketPOOlHandle);

100 .",., ,,".....,...

102 MyASSert(MyPacket->Private.Head ~= NULL);

104 PktContext ~ PACKET CONTEXT_FROM PACKET(MyPacket);

106 DM((DEHUG VERBOSE, DEBUG MASKEN SEND, ~MPSendPackets: MyPacket -> 8x\n~, PacketEntry)):

108 .
109 NdisQueryPacket(Packet, NULL, NULL, 6FirstBuffer, 6PacketLength);

111 NdisChainHufferAtFront(MyPacket, FirstHuffer):

113 NdisSetPacketFlags(MyPacket, NdisGetPacketFlags(Packetl):

115 OOBData - NDIS OOH_DATA FROM PACKET(Packet);
116 My00BData a NDIS_OOB DATA FROM PACKET(MyPacket);
117 NdisMoveMemory(My00BData, OOHData, sizeof(NDIS PACKET_OOH DATA)):

122 NDIS SET PACKET STATUS(Packet, NDIS STATUS PENDING);

1z4 125 y , .. ...~"~.Y'.vr~ .......
126 ' 128 PktContext->OriginalPacket ~ Packet:
129 PktContext->SMNEmulationPacket a FALSE;

131 _ 132 ~~~:~ ..,... ..~.

134 DUMP PACKET(MyPacket);
135 MyPacketArray[NumMyPackets++) - MyPacket;
136 ) 138 if (NumMyPackets) {
139 int FoundFlag:
140 for (i-0; i<NumMyPackets; i++) {
141 DM((DEBUG_VERBOSE, DEBUG MASKEN_SEND, "MPSendPackets, Packet Status ~> 8x, 8s\n", 1q2 NDIS GET PACKET STATUS(MyPacketArray[i]), 143 GetNDISStatusString(NDIS_GET PACKET STATUS(MyPacketArray[i]). 6FoundFlag) )):
144 ) 145 NdisSendPackets(pAdapter->LoxerMPHandle, 6MyPacketArray[0], NumMyPackets):
146 ) 148 DM((DEBUG VERBOSE, DEBUG MASKEN_ENTRYEXIT, "MPSendPackets <~\n"));
149 ) ..

151 int printbuftime ~ 1:

154 CLSendComplete( 155 IN NDIS_HANDLE ProtocolBindingContext, 156 IN PNDIS_PACKET Packet, 157 IN NDIS STATUS Status)' 158 [
159 PADAPTEA pAdapter = (PADAPTER)ProtocolBindingContext:
160 PTNS PACKET CONTEXT PktContext;
161 int FoundFlag;
162 int SMNEmulationPacket;
163 PNDIS BUFFER MyBuffer;

Pn""eeyawe~Vez.i. 9:05 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsdrvr\send.c Page 3 of 3 169 PTNSPacketReadRequest BufContext:
165 UINT Length:

167 DM((DEHUG_VERBOSE, DEBUG MASKEN ENTRYEXIT, "CLSendComplete ~>\n~));

169 DM((DEBUG VERBOSE, DEBUG MASKEN SEND, ~CLSendComplete, Packet Status =>
%x, %s\n~, 170 NDIS GET PACKET_STATUS(Packet), 171 GetNDISStatusString(NDIS GET PACKET STATUS(Packet), sFoundFlag) I):

173 PktContext ~ PACKET CONTEXT FROM PACKET(Packet):
174 SMNEmulatlonPacket ~ PktContext->SMNEmulationPacket:

176 DUMP PACKET(Packet):
177 if (PktContext->OriginalPacket) 178 DUMP PACKET(PktContext->OriginalPacket):
179 DM((DEHUG VERBOSE, DEBUG MASKEN SEND, ~CLSendComplete, Packet Status ->
%x, %s\n~, 180 NDIS GET_PACKET_STATUS(PktContext->OriginalPacket), 1B1 GetNDISStatusString(NDIS GET PACID;T_STATUS(PktContext->OriginalPacket), 6FoundFlag) )):
182 ) 184 if (SMNEmulationPacket) 185 NdisUnchainHufferAtFront(Packet, 6MyHUffer):
186 NdisQueryBuffer(Myeuffer, 6HUfCOntext; 6Length);
187 NdisFreeBuffer(MyHuffer):
188 NdisPreeMemory(BufContext, Length, 0):
189 ) 191 ',~' ~~,~'b' ~$i.~ aT-'t»'e'L~t~Fi;'Gn~";
,..,au.~ ~. ~c.»» .. ....;-c~z.,:v..,~~,~
192 NdisReinitializePacket(Packet) 193 NdisFreePacket(Packet);
194 ~.~'~:.z~~r 195 ~f 197 if (SMNEmulationPacket ~ FALSE) ( 198 NdisMSendComplete(pAdapter->TNSNdisHandle, PktContext->OriginalPacket, Status):
199 ) 201 DM((DEBUG VERBOSE, DEBUG MASKEN ~NTRYEXIT, ~CLSendComplete <=\n~)):
202 ) vN.e.a ey cw~sP.'ex,. 9:05 am Thursday, 30 September 1999 Fil~: D:\nt4DDIC\src\timesn\tnsclien\tnsclien.h Page y of 2 z idefine FILE_DEVICE_TNSCLIENT 0x00008300 /define TNSCLI~NT-IOCTL-INDEX 0x830 Idefine IOCTL_TNSCLIENT_HELLO CTL_CODE(FILE_DEVICE_TNSCLIENT, \
56 TNSCLIENT_IOCTL_INDEX, \
57 METHOD_HUFFERED, \
58 FILE ANY ACCESS) /define IOCTL_TNSCLIENT_GET_LOCAL_STATS CTL_CODE(FILE DEVICE TNSCLIENT, \
61 TNSCLIENT IOCTL INDEX+1, \
62 METHOD BUFFERED, \
63 FILE ANY ACCESS) idefine IOCTL_TNSCLIENT_GET_SI~1_STATS CTL_CODE(FILE DEVICE TNSCLIENT, \
66 TNSCLIENT IOCTL INDEX+2, \
67 METHOD BUFFERED, \
68 FILE ANY ACCESS) 71 ~define IOCTL TNSCLIENT_GET_SMN_INFO CTL_CODE(FILE DEVICE TNSCLIENT, \
72 TNSCLIENT IOCTL INDEX+3, \
73 METHOD BUFFERED, '\
7q FILE ANY ACCESS) 76 9define IOCTL TNSCLIENT_GET_LOCAL_INFO CTL_CODE(FILE DEVICE TNSCLIENT, \
77 TNSCLIENT IOCTL INDEX+4, \
7g METHOD BUFFERED, \
7g FILE ANY ACCESS) 82 ~define IOCTL TNSCLIENT_DOTEST CTL_CODE(FILE DEVICE TNSCLIENT, \
Rsa.aer~.~e.Q-,~ 8:58 am Thursday, 30 September 1999 File: D:\nt4DDIC\src\timesn\tnsclien\tnsclien.h Page 2 of 2 g3 TNSCLIENT_IOCTL INDEX+5, \

gq METHOD_BUFFERED, \

85 FILE ANY ACCESS) CLEAR CODE(FILE_DEVICE_TNSCLIENT, TNSCLIENT \
STATS CTL
87 Ndefine IOCTL

_ _ _ TNSCLIENT IOCTL_INDEX+6, _ \

g9 METHOD BUFFERED, \

9p FILE ANY ACCESS) INFO CfL_CODE(FILE_DEVICE
TNSCLIENT, TNSCLIENT
GET
SMN
TABLE
93 Adefine IOCTL

_ TNSCLIENT IOCTL INDEX+7, _ \
_ _ _ 9q g5 METHOD BUFFERED, \

g6 FILE ANY ACCESS) 98 9define IOCTL_TNSCLIENTCTL CODE(FILE DEVICE
GET_NODE_INFO TNSCLIENT, \

9g TNSCLIENT IOCTL INDEX+8, \

100 METHOD BUFFERED, \

101 FILE ANY_ACCESS) 10q 107 Ndefine ETHERNET ADDRESS

108 9define MAX COMPUTER
NAME_LEN 16 109 [./~;

110 'i~i~SL
w.~s~ u...... ' .,... .

112 typedef struct IODRIVER
PACKET ( 113 int MaxNumWrites:

11q int MaxNumReads:

115 int MaxNUmReadWrites:

117 STATISTICS Stets:

118 MPSTATS MpStats:

120 unsigned char MacAddress[ETHERNET
ADDRESS LEN]:

121 unsigned char ComputerName[MAX
COMPUTER NAME LEN]:

122 unsigned long TeamNOdeID:

123 unsigned long TNSSharedMemorySize:

12q 125 unsigned long TestStatus:

127 unsigned long DebugPrintFlag:

128 unsigned long DebugPrintMask:

130 SMNTableInfo SMNInfo[MAX_TEAM
NODES]:

132 ) IO DRIVER PACKET, 'pI0 DRIVER PACKET:

vN.x.e ey cweP.~.,~ B:SB am Thursday, 30 September ~ 999 File: D:\nt4DDK\s~c\timesn\tnsclien\tnsclien.c Page 1 of 9 31 9include <ntddk.h>
32 !include <stdarg.h>
33 iinclude <stdio.h>
34 9lnclude "tnsstats.h"
tinclude "tnsclien.h"
36 !include "xH6.h"

39 ~~~~P~T3snk~~'~~.;r~~~$E
9 0 i~ "~~.

43 typedef struct DEVICE EXTENSION
44 ULONG StateVariable:
) DEVICE EXTENSION, ~PDEVICE EXTENSION;

48 VOID GetSidt(PVOID):

51 ULONG GTestFlag~l0;
52 ULONG gPrintStats = 0:

extern unsigned char ~MyTrapOE:

59 TNSClientDrvDispatch( IN PDEVICE OBJECT Device0bject, 61 IN PIRP Irp 62 ):

TNSClientDrvUnload/
66 IN PDRIVER_OHJECT DriverObject 67 ):

69 ULONG PFPrintFlag - FALSE:
71 idefine TESTTIMES 1000 ~'~..::'"°~T~- ;",.,.~..:,.~.
~,,~,-.M.,~-x.. -"d."..,.~:u~:3;-.v:;::a~:a:::~ama-,~:~:~s:
82 ~~".~rn.~-apse~oian~o~s~u~bes' vn.x.adyowePve.z~. 8:58 am Thursday. 30 September 1999 File: D:\nt4DDIC\src\tlmesn\tnsclfen\tnsclfen.c Page 2 of 9 88 .~yr.~'ae,A''x~~Tic~? ~'"~,'ai~krrM~.~iaFir».~x;?~urv.e~er ~
irr~r~r~pli~~ire.x~yartt~iwv.i.a#~~,s~Yt~i-i..~t~~a~a 89 ~~"' ~,~~"~:,~ . «.z~,eri~._xs ...-~,~,.e ~rY..~=t_..~..~. ~-~-~~~x:n.~.~~.= r=. ,-:~.,r~~e..,.-~.<,a...~. ,.... ...~.~.Y".,.
-91 unsigned 100 seed ~ seed'Ox015a4e35L + 1:
101 return (seed»16)60x7fff:
102 }

104 ~'~~'~"'5~','~'i'.~.~ y~"r.~~~si~~!'.~'.~, .~"'~t:3~i.,.i,i°s°f'iZ~..r.ii~~i?r.i~r',~-i~
~~.,r~.,w-_.~..~:aa-x.~,w.a,~x~...~~~:....._~a.x_.e~.-.,.a:~.-~ssr.~:5.~.
"..,.,.._eG., x ..:.aadr ,..--=;..~x ....s..r.~~.~~rt_..,.a-.>.s.,~._ 105 ~I,/5 106 unsigned long 115 unsigned long n:
116 n a myrand():
117 n ~ n « 16:
118 n I° myrand():
119 return n:
120 ) t'~~~~~a'~ . 3?a~''.~.iaNFi~ aY~f~~t~r.7r3~~w?3~ ~:eWr~~li,~r~i~.i#~:~' ~e~a"s~#,r~s':
122 ;~,.,~ -~-"s~ . ~ -r~"x.e.r.. .~:a~~a ~,Ya~~~.~r~ ..i,.,~" r, 123 ~s 124 unsigned long 133 unsigned long n:
134 n ~ myrand():
135 n ~ n « 16:
136 n I- myrand():

138 if (clipvalue ~ 0) 139 return 1:

141 return (n 8 clipvalue):
142 }

145 ~~~~~x~~s,~~s~~w.~raau~i~s~r4cak~~~v~~:s~,~"~e,iu a~;e ud~~~ s:~.K::~:..~..:~~tc;..,aw:~;e.res~uu~ . ~smar:cses.-~8~s?.H~z~,~:a:~rr:a. ~rz-~..assF.~:

147 unsigned 148 myrandn( 149 unsigned n) ~~.~iumbei.

157 if (n ~- 0) 158 return 1:

160 return (myrand() 6 n):
161 }

163 ... .~~~-.m."..~~~~,.~~~..~.....a ~n~y:LSS~w'~'..,~.~..w~..rw~:u~.::z~::;::a~~:c~.au;a:~~c:~xr"-'"-r~---r-r~
164 [1,:7 ~~br~~bz.~~ , 8:58 nm Thursday, 30 September 1999 File: D:\nt4DDK\src\timesn\tnscllen\tnsclien.c Page 3 of 9 165 -fa ze,~,_al5cwe~~3~.aeas ~anqruenpsen~cragdDs~
~aVmber:~enesacn~_:

166 [G!

167 ~/~~ ;""ya,::....~,r~".,..,..
....:.~~~...A~-H,:~;:..r...~~, ...M.,a.:~...~,.-.
~..,z.y,~,a:z:::

~~ r.~~. ~~.~':'~s~qTi~s:~~', . ,t,~ .;~'~'~cxaa~:.
170 ~ .";;"",a~;~,~,..r...z:~x..~t=.~..,.-~-._..r.~--:~'u?.,~!:.ae~::m~e~!u-w_ . -i:.~ r~s5.~ -~.~.~ .-.s~

171 yr=~:

172 void 173 mysrand( 174 unsigned newseed) 181 seed ~ newseed:

182 }

"

184 dF'~'.!~'~
'~"~ca~~ca~~u~.ay ' "
s'.:w~:,tcs~u ,xaW.:.;.::,s.a,~.:~."~-.wash.
a,.:~: . ~;.~~..~,.,:~.,.~...,., ~ .~:::..~~;a...M
..,~,:_.",.~-.~;~.,~.:~:;~i..:;:~>

.
18 5 ~/rJ'!~t.

186 unsigned 194 return seed:

195 }

200 DriverEntry( 201 IN PDRIVER_OBJECTDriverObject, 202 IN PUNICODE_STRING
RegistryPath 226 PDEVICE_OBJECTdevice0bject - NULL:

227 NTSTATUS ntStatus:

228 wCHAR deviceNameBuffer[] = L"\\Device\\TNSCLIEN":

229 UNICODE deviceNameUnicodeString:
STRING

EXTENSION deviceExtension:

_ deviceLinkHuffer[] = L"\\DosDevices\\TNSCLIEN":
231 wCNAR

232 UNICODE_STRINGdeviceLinkUnicodeString:

234 IDTRRegisterContents IDTRContents:

235 PIDTREntry pIdtrEntry:

236 int i:

237 ULONG NevAddress:

238 LARGE_INTEGERtscl, tsc2, tscdiff;

239 PHYSICAL pAddr:
ADDRESS

240 PVOID pBuffer:

241 PVOID pMapBUffer:

2 4 6 ~,:~.'~ ~.a ~~~." .~. .~~~

~.,aww~~~a.~.~~ 8:58 am Thursday, 30 September 1999 Flle: D:\nt4DDK\src\timasn\tnsclien\tnsclien.c Page 4 of 9 248 1~~~t~emt"°~"~ooc~ .de~~' t~,zt zsuppvirs 249 J7'~K.:~e've'aaaimed~.anr z~es'ouraes z3''3iaund~our .nso~rea~E, 250 ~~< ~":~deg~i ,ad~ajs~~.,~#eff~x.; . . .

253 RtlInitUnicodeString(6deviceNameUnicodeString, 254 deviceNameBuffer);

259 C~V$3pF~~~v~~ s~4 0 _~ n~~~d~ '~3fie ~~ ~'A~~
..~E~__a~. ~~,...,._..~......~:~%._,__.,_ 260 'j"~~~ea 263 ntStatus - IoCreateDeviee (DriverObject, 264 sizeof (DEVICE EXTENSION), 265 6deviceNameUnicodeString, 266 FILE DEVICE TNSCLIENT, 267 0, 268 TRUE, 269 6device0bject 270 ):

272 if (NT SUCCESS(ntStatus)) 273 deviceExtension ~ (PDEVICE EXTENSION) device0bject->DeviceExtension:

284 ~ i~ea""'~e,~ ~3~~~ , ~''1~~?8~~;~~°~_' ie s ~~' ze7 288 RtlInitUnicodeString (6deviceLinkUnicodeString, deviceLinkHUffer):

290 ntStatus ~ IoCreateSymbolicLink (adeviceLinkUnicodeString, 6deviceNameUnicodeString);

293 if (!NT SUCCESS(ntStatus)) ( 294 _asm int 3 295 !

300 ,. ~., ' _ ..~_ . . _.,..

303 DriverObject->MajorElinction[IRP MJ CREATE] a 304 DriverObject->MajorFlinction[IRP MJ CLOSE]
305 DriverObject->MajorFl~nction[IRP MJ DEVICE CONTROL] ~
TNSClientDrvDispatch:
306 DriverObject->DriverUnload - TNSCIIentDrvUnload:
307 ) 310 if (!NT SUCCESS(ntStatus)) 312 ~'~t"..._.. . ., . " ...~ __,.,..,.. ..

315 if (deviceObject) 316 IoDeleteDevice (device0bject):
317 ) 319 return ntStatus;
320 ) 324 _declspecldllimport) 325 _TNS READ_REGISTER ULONG( 326 PVOID DeviceContext, 327 PULONG Register);

~"°'°~'~"°z" 6:bB am Thursda , 30 Se y ptember 7 999 File: D:\nt4DDK\src\timesn\tnsclien\tnsclien.c Page 6 of 9 331 _declspec(dllimportl 332 _TNS WRITE_REGISTER_ULONG( 333 PVOID DeviceCOntext, 334 PULONG Register, 335 ULONG RegisterData):

339 declspec(dllimport) 340 _TNS GET_SMN STATISTICS( 341 IN PVOID DeviceHandle, 392 IN OUT PSTATISTICS pStatistics, 343 IN OUT PULONG pStatsStructSize, 344 IN OUT pMPSTATS pMpStats, 345 IN OUT PULONG pMpStatsSize):

348 declspec(dllimport) 399 _TNS GET_NODE_STATISTICS( 350 IN PVOID DeviceHandle, 351 IN OUT PSTATISTICS pStatistics, 352 IN OUT PULONG pStatsStructSize, 353 IN OUT pMPSTATS pMpStats, 354 IN OUT PULONG pMpStatsSize):

359 declspec(dllimport) 360 TNS CLEAR_NODE STATISTICS( 361 IN- PVOID DeviceHandle);

364 _declspec(dllimport) 365 _TNS CLEAR_SMN STATISTICS( 366 IN PVOID DeviceHandle):

369 _declspec(dllimport) 370 _TNS GET_SMN INFORMATION( 371 IN PVOID peviceHandle, 372 IN OUT unsigned char ~pMacAddress, 373 IN OUT unsigned char ~pNodeName, 379 IN OUT unsigned long ~pSharedMemorySize) 377 _declspec(dllimport) 378 _TNS GET_SMN TAHLE_INPO( 379 IN PVOID DeviceHandle, 380 IN OUT pSt~lTableInfo pSMNInfo);

383 _declspec(dllimport) 389 _TNS GET_SMN STATISTICS HY NODEID( 385 IN PVOID DeviceHandle, 3H6 IN ULONG NodeID, 3H7 IN OUT PSTATISTICS pStatistics, 388 IN OUT PULONG pStatsStructSize, 389 IN OUT pMPSTATS pHpStats, 390 IN OUT PULONG pMpStatsSize):

393 _declspec(d113mport) 394 _TNS GET_NODE_INFORMATION( 395 IN PVOID DeviceHandle, 396 IN OUT unsigned char ~pMacAddress, 397 IN OUT unsigned char ~pNodeName, 39H IN OUT unsigned int ~pNOdeID):

401 TNSCIIentDrvDispatch( 402 IN PDEVICE OBJECT DeviceObject, 403 IN PIRP Irp 404 ) 8:58 am Thursday. 30 Septambar 1999 File: D:\nt4DDIC\src\timesn\tnsclfen\tnsclien.c Page 6 of 9 423 PIO STACK LOCATION irpStack;
424 PDEVICE EXTENSION deviceExtension;
425 pI0 DRIVER PACId;T ioHuffer;
426 ULONG inputHufferLength;
927 ULONG outputHufferLength;
928 ULONG ioControlCode;
429 NTSTATUS ntStatus:
430 int 1:

432 ULONG ReturnCode:

435 Irp->IoStatus.Status = STATUS SUCCESS:
436 Irp->IoStatus.Information - 0:

440 ~~~~~~Z~~i'~L~-Cl~rz3BEt~'~. ~'.~~,s 9 41 ' '98a~~ 'z"8~e'a~,:eH

944 irpStack m IoGetCurrentIrpStackLocation (Irp);

452 deviceExtension - Device0bject->DeviceExtension;

457 . ,~

460 ioBUffer = (pI0 DRIVER PACKET)Irp->Assoclatedlrp.SystemHuffer;
461 inputeufferLength = irpStack->Parameters.DeviceloControl.InputBufferLength:
462 outputHufferLength a irpStack->Parameters.DeviceIoControl.OUtputBufferLength;

466 switch (irpStack->MajorFunction) ( 467 case IRP MJ CREATE:

469 break:

471 case IRP MJ CLOSE:

473 break:

475 case IRP MJ DEVICE CONTROL:
476 ' 477 ioCOntrolCode ~ IrpStack->Parameters.DeviceIOControl.IOControlCode:

979 switch (IoControlCode) ( 981 case IOCTL TNSCLIENT GET NODE INfO:
482 ULONG StatsLen, mpStatsLen;

484 mpStatsLen = sizeof(MPSTATS);
485 StatsLen ~ sizeof(STATISTICS);

487 TNS_GET SMII_STATISTICS BY,-NODEID( 488 NULL.
q89 IoHUffer->TeamNOdeID, q90 6ioBUffer->Stats, qgl 6StatsLen, 492 6ioBuffer->MpStats, ~~~~~-s.~~ 8:58 am Thursday. 30 September 1999 .

Ffle: D:\nt4DDK\src\timesn\tnsclien\tnsclfen.c Pege 7 of 9 493 6mpStatsLen):

495 Irp->IOStatus.Information = sizeof(IO DRIVER PACKET);
496 break;
4 97 ) 499 case IOCTL_TNSCLIENT GET SMN TABLE_INfO: ( 500 _TNS_GET_SMN_TAHLE_INFO( 501 NULL, 502 loBuffer->SlB4Info);

504 Irp->IOStatus.Information = sizeof(IO DRIVER_PACKET);
505 break;
506 ) 507 case IOCTL_TNSCLIENT GET_SMN INFO: ( 508 _TNS GET SMN INFORMATION( 509 ~~,_ _ 510 loBuffer->MacAddress, 511 loHUffer->ComputerName, 512 6ioHUffer->TNSSharedMemorySize);

514 Irp->IoStatus.Information ~ sizeof(IO DRIVER PACKET):
515 break;
516 ) 518 case IOCTL_TNSCLIENT CLEAR STATS: ( 519 _TNS CLEAR_NODE STATISTICS( 520 NULL); _ 521 _TNS_CLEAR_SMN_STATISTICS( 522 NULL):
523 Irp->IOStatus.Information a sizeof(IO DRIVER PACKET):
524 break;
525 ) 527 case IOCTL TNSCLIENT GET LOCAL INFO: ( 528 TNS GET NODE INFORMATION( 529 - ~~_ _ 530 loBuffer->MacAddress, 531 loBuffer->ComputerName, 532 6ioBuffer->TeamNodeID);
533 Irp->IoStatus.Information = sizeof(IO_DRIVER PACKET);
534 break;
535 ) 537 case IOCTL_TNSCLIENT_DOTEST: ( 538 int 1;
539 unsigned long randdata:
540 unsigned long randaddress;
541 unsigned long returndata;

543 if (io8uffer->MaxNumWrites) 544 for (i=0; i<laBuffer->MaxNUmWrites: i++) ( 595 randdata = myrand32():
546 randaddress - myrand32n(loHuffer->TNSSharedMemorySize);
547 _TNS_WRITE_REGISTER_ULONG(NULL, (PULONG)randaddress, randdata):
548 ) 549 ) 551 if (ioBUffer->MaxNumReads) 552 for (i-0; i<loHuffer->MaxNumReads: i++) ( 553 randaddress = myrand32n(loHuffer->TNSSharedMemorySize);
554 returndata = _TNS_READ_REGISTER_ULONG(NULL, (PULONG) randaddress);
555 ) 556 ' ) 558 if (foHuffer->MaxNumReadWrites) 559 for (1~0; i<ioBuffer->MaxNumReadWrites: i++) ( 560 randdata = myrand32();
561 randaddress a myrand32n(ioBuffer->TNSSharedMemorySize):

563 TNS WRITE REGISTER ULONG(NULL, (PULONG)randaddress, randdata):
564 returndata ~ TNS READ REGISTER_ULONG(NULL, (PULONG)randaddress):
565 if (randdata !- returndata) ( 566 DbgPrint("randdata !- returndata, randdata ~> tx, returndata => 9x\n", ra -2 nddata, returndata):
567 break;
56A ) 569 ) 570 ) 572 Irp->IOStatus.Information ~ sizeof(IO_DRIVER_PACKET):
573 break:
P~~~°°~'~°~"°s-~~ 8:58 am Thursday. 30 September 1999 File: D:\nt4DDlC\src\timesn\tnscifen\tnsclien.c Page 8 of 9 574 ) 576 case IOCTL TNSCLIENT_GET_LOCAL STATS: ( 577 ULONG StatsI,en, mpStatsLen:

579 mpStatsLen = sizeof(MPSTATS):
580 StatsLen = sizeof(STATISTICS);

582 _TNS_GET_NODE_STATISTICS( 583 NULL, 584 6ioHuffer->Stats, 585 ~StatsLen, 586 sioBuffer->MpStats, 587 6mpStatsLen);

589 Irp->IOStatus.Information = sizeof(IO_DRIVER_PACKET):
5g0 break:
591 ) 593 case IOCTL TNSCLIENT GET SMN STATS: ( 594 ULONG StatsLen, mpStatsLen:

596 mpStatsLen = sizeof(MPSTATS):
597 StatsLen = sizeof(STATISTICS1:

599 _TNS_GET_SMN_STATISTICS( 600 NULL.
601 6io8uffer->Stats, 602 6StatsLen, 603 6loHuffer->MpStats, 604 ~mpStatsLen):

606 Irp->IOStatus.Infoxmation = sizeof(IO DRIVER PACKET);
607 break:
608 ) 610 default:

612 Irp->IOStatus.Status = STATUS_INVALID PARAMETER:

614 break:

616 ) 617 break;
618 ) 623 ~t'bedl.r~"t°19o.he~'a~~'st~~ia~" szas ...." . x e. as ; .x w.~F~~.-.~..,~
624 , ~'"s~.~~-627 ntStatus = Irp->IoStatus.Status:

629 IoCompleteRequest (Irp, 630 IO_NO_INCREMENT
631 I:

634 ~i 635 ~~ . ._. w,.. _,..a.., 638 return ntStatus:
639 ) 644 TNSCISentDrvUnload( 645 IN PDRIVER_OBJECT DriverObject 646 ) Atne~e ey cfusP ve.zi w 8:58 am Thursday. 30 September 1999 File: D:\nt4DDK\src\timesn\tnsclien\tnsclien.c Page 9 of 9 662 wCHAR deviceLinkHuffer[] - L~\\DosDevices\\TNSCLIEN~;
663 UNICODE_STRING deviceLinkUnicodeString;
664 IDTRRegisterContents IDTRContents;
665 PIDTREntry pIdtrEntry;

667 ~dJ
668 ?%~.,~I3elete~the;5yn11~o13~cw;liff'k 669 %J_ 671 RtlInitUnicodeString (4deviceLinkUnicodeString, deviceLinkBuffer);

673 IoDeleteSymbolicLink (&deviceLinkUnicodeString);

675 %
67 6 l°l~c:lie~:s~e;the' ~devic~~vb~ect 679 IoDeleteDevice (DriverObject->DeviceObject):
680 ) Prirri~dbyCRI8Pv6.2.~~ 8:58 am Thursday, 30 September 1999

Claims (41)

What is claimed is:
1. A method, comprising:
passing a set of interconnect fabric data through a shim layer that is interposed between an interconnect fabric interface layer and a protocol layer including:
receiving said set of interconnect fabric data with said shim layer, classifying said set of interconnect fabric data with said shim layer, and handling said set of interconnect fabric data with said shim layer as a function of a transport application program interface with which said set of interconnect fabric data is associated.
2. The method of claim 1, wherein said set of interconnect fabric data includes a packet.
3. The method of claim 1, wherein classifying said set of interconnect fabric data includes classifying said set of interconnect fabric data as a function of said transport application program interface.
4. The method of claim 1, wherein said set of interconnect fabric data is received and then classified and then passed.
5. The method of claim 1, wherein passing includes transforming said set of interconnect fabric data.
6. The method of claim 1, further comprising monitoring passage of said set of interconnect fabric data with a heartbeat function to expedite recovery in the event of an error.
7. The method of claim 1, further comprising monitoring passage of said set of interconnect fabric data with sense interrupt indications to expidite recovery in the event of an error.
8. A method, comprising:
passing a set of network data through a shim layer that is interposed between a network interface layer and a protocol layer including:
receiving said set of network data with said shim layer, classifying said set of network data with said shim layer, and handling said set of network data with said shim layer as a function of a transport application program interface with which said set of network data is associated.
9. The method of claim 8, wherein said set of network data includes a packet.
10. The method of claim 8, wherein classifying said set of network data includes classifying said set of network data as a function of said transport application program interface.
11. The method of claim 8, wherein said set of network data is received and then classified and then handled.
12. The method of claim 8, wherein passing includes transforming said said of network data.
13. The method of claim 8, further comprising monitoring passage of said set of network data with a heartbeat function to expedite recovery in the event of an error.
14. The method of claim 8, further comprising monitoring passage of said set of network data with sense interrupt indications to expedite recovery in the event of an error.
15. The method of claim 8, wherein said shim hosts network middleware to handle at least one function selected from the group consisting of transmitting packets, obtaining information on local and remote multi-computer nodes, setting up packet receive sinks and controlling a protocol.
16. An apparatus, comprising:
a shared memory unit;
a first system coupled to said shared memory unit; and a second system coupled to said shared memory unit, wherein a data set transfered between said shared memory unit and at least one member selected from the group consisiting of said first system and said second system is received by a shim that is interposed between either i) a network device/driver and a protocol layer or ii) an interconnect fabric interface and said protocol layer, classified by said shim and handled by said shim as a function of a transport application program interface with which said data set is associated.
17. A computer system comprising the apparatus of claim 16.
18. The apparatus of claim 16, wherein the shim is interposed between said network device/driver and said protocol layer, and said at least one member includes a network interface card.
19. The apparatus of claim 18, wherein the network interface card provides a heartbeat function to facilitate error recovery.
20. The apparatus of claim 18, wherein the network interface card provides programable packet type identification.
21. The apparatus of claim 18, wherein the network interface card provides media sense interrupt indications to facilitate error recovery.
22. The apparatus of claim 16, wherein the shim is interposed between said interconnect fabric interface and said protocol layer.
23. The apparatus of claim 22, wherein said at least one member provides a heartbeat function to facilitate error recovery.
24. The apparatus of claim 22, wherein said at least one member provides programable packet type identification.
25. The apparatus of claim 22, wherein said at least one member provides media sense interrupt indications to facilitate error recovery.
26. An apparatus, comprising:
a switch;
a first system coupled to said switch; and a second system node coupled to said switch, wherein a data set transfered from said first system to said second system through said switch is received by a shim that is interposed between either i) a network device/driver and a protocol layer or ii) an interconnect fabric interface and said protocol layer, classified by said shim and handled by said shim as a function of a transport application program interface with which said data set is associated.
27. A computer system comprising the apparatus of claim 26.
28. The apparatus of claim 26, wherein the shim is interposed between said network device/driver and said protocol layer, and said at least one member includes a network interface card.
29. The apparatus of claim 28, wherein the network interface card provides a heartbeat function to facilitate error recovery.
30. The apparatus of claim 28, wherein the network interface card provides programable packet type identification.
31. The apparatus of claim 28, wherein the network interface card provides media sense interrupt indications to facilitate error recovery.
32. The apparatus of claim 26, wherein the shim is interposed between said interconnect fabric interface and said protocol layer.
33. The apparatus of claim 32, wherein said at least one member provides a heartbeat function to facilitate error recovery.
34. The apparatus of claim 32, wherein said at least one member provides programable packet type identification.
35. The apparatus of claim 32, wherein said at least one member provides media sense interrupt indications to facilitate error recovery.
36. An electronic media, comprising: a computer program adapted to pass a set of interconnect fabric data through a shim layer that is interposed between an interconnect fabric interface layer and a protocol layer including:
receiving said set of interconnect fabric data with said shim layer, classifying said set of interconnect fabric data with said shim layer, and handling said set of interconnect fabric data with said shim layer as a function of a transport application program interface with which said set of interconnect fabric data is associated.
37. A computer program comprising computer program means adapted to perform the steps of passing a set of interconnect fabric data through a shim layer that is interposed between an interconnect fabric interface layer and a protocol layer including:

receiving said set of interconnect fabric data with said shim layer, classifying said set of interconnect fabric data with said shim layer, and handling said set of interconnect fabric data with said shim layer as a function of a transport application program interface with which said set of interconnect fabric data is associated when said computer program is run on a computer.
38. A computer program as claimed in claim 37, embodied on a computer-readable medium.
39. An electronic media, comprising: a computer program adapted to pass a set of network data through a shim layer that is interposed between a network interface layer and a protocol layer including:
receiving said set of network data with said shim layer, classifying said set of network data with said shim layer, and handling said set of network data with said shim layer as a function of a transport application program interface with which said set of network data is associated.
40. A computer program comprising computer program means adapted to perform the steps of passing a set of network data through a shim layer that is interposed between a network interface layer and a protocol layer including:
receiving said set of network data with said shim layer, classifying said set of network data with said shim layer, and handling said set of network data with said shim layer as a function of a transport application program interface with which said set of network data is associated when said computer program is run on a computer.
41. A computer program as claimed in claim 40, embodied on a computer-readable medium.
CA002382836A 1999-10-13 2000-09-29 Low latency, high bandwidth multi-computer system interconnect Abandoned CA2382836A1 (en)

Applications Claiming Priority (5)

Application Number Priority Date Filing Date Title
US15908699P 1999-10-13 1999-10-13
US60/159,086 1999-10-13
US67290900A 2000-09-28 2000-09-28
US09/672,909 2000-09-28
PCT/US2000/026728 WO2001027781A2 (en) 1999-10-13 2000-09-29 Low latency, high bandwidth multi-computer system interconnect

Publications (1)

Publication Number Publication Date
CA2382836A1 true CA2382836A1 (en) 2001-04-19

Family

ID=26855641

Family Applications (1)

Application Number Title Priority Date Filing Date
CA002382836A Abandoned CA2382836A1 (en) 1999-10-13 2000-09-29 Low latency, high bandwidth multi-computer system interconnect

Country Status (4)

Country Link
EP (1) EP1224560A2 (en)
AU (1) AU7621500A (en)
CA (1) CA2382836A1 (en)
WO (1) WO2001027781A2 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6999998B2 (en) 2001-10-04 2006-02-14 Hewlett-Packard Development Company, L.P. Shared memory coupling of network infrastructure devices
US6920485B2 (en) 2001-10-04 2005-07-19 Hewlett-Packard Development Company, L.P. Packet processing in shared memory multi-computer systems
US9351250B2 (en) * 2013-01-31 2016-05-24 Qualcomm Incorporated Methods and apparatus for low power wake up signal and operations for WLAN

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5515508A (en) * 1993-12-17 1996-05-07 Taligent, Inc. Client server system and method of operation including a dynamically configurable protocol stack
US5606666A (en) * 1994-07-19 1997-02-25 International Business Machines Corporation Method and apparatus for distributing control messages between interconnected processing elements by mapping control messages of a shared memory addressable by the receiving processing element
US5742607A (en) * 1995-12-20 1998-04-21 Intel Corporation Method and apparatus for controlling two way communication via disparate physical media
US5996021A (en) * 1997-05-20 1999-11-30 At&T Corp Internet protocol relay network for directly routing datagram from ingress router to egress router
US6061796A (en) * 1997-08-26 2000-05-09 V-One Corporation Multi-access virtual private network
US6295571B1 (en) * 1999-03-19 2001-09-25 Times N Systems, Inc. Shared memory apparatus and method for multiprocessor systems

Also Published As

Publication number Publication date
WO2001027781A3 (en) 2001-11-29
EP1224560A2 (en) 2002-07-24
AU7621500A (en) 2001-04-23
WO2001027781A9 (en) 2002-09-26
WO2001027781A2 (en) 2001-04-19

Similar Documents

Publication Publication Date Title
US7274706B1 (en) Methods and systems for processing network data
TW546929B (en) Method and apparatus for allowing proprietary forwarding elements to interoperate with standard control elements in an open architecture for network devices
CN105357266B (en) It is suitble to the SOCKET communication and management of process general-purpose platform and method of several scenes
US5894557A (en) Flexible point-to-point protocol framework
US7246178B2 (en) Methods and systems for changing a topology of a network
US9015822B2 (en) Automatic invocation of DTN bundle protocol
US7117280B2 (en) Network based intra-system communications architecture
US7626938B1 (en) Local area network switch using control plane packet mirroring to support multiple network traffic analysis devices
EP4047904A1 (en) Methods and systems for implementing communications between a management controller and a network controller via an nc-si that utilizes ip connectivity
CN104699489A (en) Multiple operating systems based embedded software platform
WO2019190859A1 (en) Efficient and reliable message channel between a host system and an integrated circuit acceleration system
CA2382836A1 (en) Low latency, high bandwidth multi-computer system interconnect
US6975632B2 (en) Multi-service architecture with any port any service (APAS) hardware platform
JP3988475B2 (en) Transmitting apparatus, receiving apparatus and methods thereof
US10237353B2 (en) Method and system for discovering the topology of the communications between applications of a computer network
CN109451362A (en) RapidIO network interface under VxWorks and implementation method
CN110502418B (en) Method for realizing remote debugging
WO2017202272A1 (en) System and method of software defined switches between light weight virtual machines using host kernel resources
Dinda The minet tcp/ip stack
CN106936927A (en) A kind of socket communication means based on pc client
JP2004518310A (en) How to analyze transmitted protocol data units
CN109257264B (en) System and method for opening Ethernet virtual private network service
CN100375464C (en) Method for data communication of every terminal when network interconnecting
CN112612735A (en) Unity-based multi-platform multi-form VR hardware interface management system
CN105591723B (en) A kind of VNF stacking method and device

Legal Events

Date Code Title Description
FZDE Discontinued