TRANSPARENT SUPPORT OF PROTOCOL AND DATA COMPRESSION FEATURES FOR DATA COMMUNICATION

Abstract: A proxy engine (50) enables network protocols that are supported by both network endpoint application (30) and local endpoint application (20). The proxy engine (50) determines network control protocols and enables data compression techniques (54) that are supported by the network endpoint application (20) and the proxy engine. It transmits data between the local endpoint application (20) and the network endpoint application (30). The proxy engine (50) also opens multiple communication channels for transmitting data simultaneously between the local endpoint application and the network endpoint application.

Description: TRANSPARENT SUPPORT OF PROTOCOL AND DATA COMPRESSION FEATURES FOR DATA COMMUNICATION NOTICE RE: COPYRIGHT A portion of the disclosure of this patent document contains matter subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent disclosure, as it appears in the Patent and Trademark Office files and records, but otherwise retains all copyright rights whatsoever. BACKGROUND OF THE INVENTION A. Field of the Invention This invention relates generally to the field of telecommunication and the processes by which digital data is transmitted between computer systems over a network or communications link. The invention is particularly suitable for use in devices that support Integrated Service Digital Network (ISDN) digital telephone services or the like, in which the digital data is transmitted via the ISDN or other digital line to a data terminal equipment (DTE), such as a computer. B. Description of Related Art In order for digital data to be transmitted from the source of the data (such as a computer) to a destination (such as another computer) over a network or telecommunication line, the data must be formated and presented to the transmission medium and the destination in a form that is compatible to the elements of the system. For example, if the source of the data wishes to compress the data using a particular data compression technique, the source and the) destination must support both the chosen data compression algorithms. It is a well known fact of life that the various computers in a network of computers may not have compatible data transmission and formatting software, due to the differences in technology available when the computers were purchased, the different options and features that may have been built into the computers subsequent to their purchase, or the fact that the owners of the computers on the network (such as the Internet) do not know or care about what features other computers on the network may support. When transmission of data in this situation is attempted, the lowest common denominator in terms of the communications protocols is determined during the call connect process. If the source of the data runs communications software that supports only basic communication protocols, but the destination runs backwardly compatible advanced protocols and compression functions, the call will typically proceed, but only in accordance with the basic communications protocols supported by the source. The present invention addresses this problem by determining, in the call connect process, the communication protocols and compression techniques that are supported at both ends of the network, and by supporting multiple compression protocols and compression algorithms, so as to facilitate communication between the elements of the system. The invention does this automatically, and in a manner that is transparent to the user. Further, if the telecommunication line between the source and destination supports multiple communication channels (such as an ISDN line), the invention automatically enables the data to be transmitted through multiple communication channels. This has the effect of increasing data throughput, and significantly shortening the call connect time. In order to better understand these and other advantages and features of the invention, a brief exposition of data communication technology and the Point-To- Point Protocol is set forth here. The Open Systems Interconnect Reference Model is the standard model for describing the layers of functions and protocols necessary for data communications between computers. This well-known model consists of a hierarchy of seven layers of protocols which control the transmission of data from a source of the data to a destination via a network. The lowest layer in the model is the physical layer, which manages the physical connection of network elements. The next two higher layers are the link layer and the network layer, respectively. The link layer, also known as the data link layer, manages the flow of data between the user and the network, or between a DTE and Data Communications Equipment (DCE). This layer's responsibility is to assure reliable and efficient data transfer, data formatting, the detection, correction and recovery of errors, data transparency, and some forms of addressing. The network layer manages the details of transmitting data across the physical network between network elements, as well as between networks. The network layer also has the responsibility to define data call establishment procedures for packet and cell switched networks, and manage the segmentation and assembly of data across the network. The application layer is the top layer of the model, and manages the program or device that generates the data that is to be sent from the source through the network to the intended destination. The Point-to-Point Protocol (PPP) provides a standard method of encapsulating network layer protocol information over point-to-point links. The PPP also defines an extensible Link Control Protocol (LCP), and proposes a family of Network Control Protocols (NCPs) for establishing and configuring different network-layer protocols. The PPP is described in detail in a series of documents that are available on-line. Persons of skill in the art are familiar with these documents, known as the Request For Comments. The Request For Comments (RFC) 1661, which is incorporated by reference herein, gives an informative overview of the PPP. The initial deployment of the PPP has been over short local lines, leased lines, and plain-old-telephone-service (POTS) using modems. As new packet services and higher speed lines are introduced, PPP is easily deployed in these environments as well. As noted above, the PPP has three main components: A procedure for encapsulating datagrams over serial links; 2. A Link Control Protocol (LCP) for establishing, configuring, and testing the data-link connection; and 3. A family of Network Control Protocols (NCPs) for establishing and configuring different network-layer protocols. In order to establish communications over a point-to-point link, each end of the PPP link must first send LCP packets to configure the data link during the Link Establishment phase. After the link has been established, PPP provides for an optional Authentication phase before proceeding to the Network-Layer Protocol phase. By default, authentication (i.e., password identification) is not mandatory. If authentication of the link is desired, an implementation must specify the Authentication-Protocol Configuration Option during Link Establishment phase. These authentication protocols are intended for use primarily by hosts and routers that connect to a PPP network server via switched circuits or dial-up lines, but might be applied to dedicated links as well. The server can use the identification of the connecting host or router in the selection of options for network layer negotiations. PPP encapsulation of data communications is possible when the data is transmitted over digital communication lines, such as ISDN lines. ISDN lines comprise two data channels (referred to as bearer channels or "B" channels), and a control channel known as the "D" channel. The ISDN D-channel can also be used for sending PPP packets when suitably framed, but is limited in bandwidth and often restricts communication links to a local switch. Since the ISDN B-channel is by definition a point-to-point link, PPP is well suited to use over ISDN lines. The ISDN Primary Rate Interface may support many concurrent B-channel links. The PPP Link Control Protocol and Network Control Protocol mechanisms are particularly useful in this situation in reducing or eliminating hand configuration, and facilitating ease of communication between diverse implementations. In order to accommodate ISDN data links over multiple channels simultaneously, a protocol known as PPPML or PPP MultiLink is used. The PPP MultiLink protocol is described in the Request For Comments 1717, which is incorporated by reference herein. In our invention, an element of communication equipment we have called a proxy engine is used in establishing a connection between the local endpoint application (i.e., the application running at the source of the data) and the application located at the far end of the network (i.e. , the application running at the destination for the data). The application located at the destination is referred to herein as the "network endpoint application". The proxy engine, which in the preferred form constitutes a communication software structure, may be installed at the source, at the destination, or at both the source and destination. The term "proxy" is meant to indicate that the proxy engine is supplying the protocol feature or data compression on behalf of the local endpoint application. The term "engine" stems from the fact that the proxy engine actively provides or supports these protocol and/or compression features in real time during the call connection and data transfer process. In our invention, the proxy engine conducts simultaneous communications sessions with the local endpoint application and the network endpoint application to determine what protocol features are supported by the endpoint applications. Additionally, the proxy engine supports or enables multiple advanced features available with the Point-To-Point Protocol, such as PPP MultiLink, various data compression techniques over PPP or PPP MultiLink, Challenge Handshake Application Protocol (CHAP) MD5, and any Link Control Protocol extensions that are implemented in the proxy engine, such as Link Control Protocol ECHO_REQUEST, ECHO_REPLIES, call back, endpoint identification, etc. Because these features are supported in the proxy engine, the user does not have to independently develop these features. The invention allows an application running above the proxy engine to "leverage", or take advantage of, all the advanced set of features described in the PPP Request For Comments, without supplementing any part of the PPP but the most basic feature of the set described in Request for Comments 1661, and possibly the Password Authentication Protocol and at least one Network Control Protocol. Computers that implement the present invention will essentially level the playing field for all the endpoint applications, because the proxy engine makes up for and supports the data compression, multiple link, and authenticaion features that are lacking in the local endpoint application. The benefit to the user of the invention is thus increased throughput and data capacity over their existing equipment, because the proxy engine will provide the necessary protocol or compression features that may be lacking in the endpoint application. In accordance with the present invention, the proxy engine learns each of the endpoint' s particular configuration parameters, such as security information, network addressing, error correction routines and data compression technique, during communication sessions at the outset of the call connect process. To the user and the local endpoint application, it appears as though the local endpoint application is communicating directly with the network endpoint application, but in reality the local endpoint application is interfacing with the proxy engine. Similarly, the network endpoint application appears to be communicating directly with the local endpoint application, but is actually interfacing with the proxy engine. All of this is done in a manner that is transparent to the user at the local endpoint application, i.e, the user does not need to initiate any special configurations or take special action, as it occurs automatically. Thus, the invention provides for "spoofing" for quick determination and implementation of PPP network control protocols over one or more channels, and for data compression techniques, during the call connection process. SUMMARY OF THE INVENTION The present invention is implemented in a system comprising a source of data, a receiver of data and a communication channel linking the source and the receiver. In one aspect, the invention is a method for setting up a data transmission session between a local endpoint application at the source and a network endpoint application at the destination with a proxy engine in a transparent manner. The method comprises the steps of: placing the proxy engine in simultaneous communication sessions with the local endpoint application and the network endpoint application; determining with the proxy engine at least one of the following: (a) security protocols, (b) multiple channel capabilities, (d) data compression techniques, and/or (d) network control protocols, that are supported by the network endpoint application, determining with the proxy engine the security protocols and/or network control protocols that are supported by the local endpoint application; enabling the security protocols, multiple channel capabilities, data compression techniques and network protocols that are supported by both (1) the network endpoint application, and (2) the combination of the proxy engine and the local endpoint application, and transmitting data between the local endpoint application and the network endpoint application, whereby data may be transmitted from the source of the data to the receiver of the data over the communication channel. In this manner, to the extent that the network endpoint application requests multiple channel capabilities or data compression techniques that are not supported by the local endpoint application, these features are provided by the proxy engine. Additionally, the proxy engine enables the security protocols and network control protocols that are supported by the local endpoint application. In general, the local endpoint application communication session ("the local session") may be negotiated as a single link with no data compression. Conversely, the network endpoint application communication session ("the network session") will be negotiated with multiple links and with data compression. In accordance with the preferred form of the present invention, in order for the network session and the local session to gain each other's configuration information, the two sessions are preferably brought up (or "enabled") in a specific order. Inherently, PPP requires that multiple control layers be established before a session may be brought into service. Where the proxy engine supports multiple links over the PPP, the preferred embodiment of the invention provides for opening up a second communication channel or multiple communication channels for transmission of the data between the source and the receiver of the data, and transmitting the data over all of the opended channels simultaneously from the source to the receiver. If more than two channels are available (as in ISDN Primary Rate service), then the proxy engine may open up more than two channels and pipe the data to the endpoint application down however many channels may be opened. This feature permits a significant reduction in the overall call connection time and a significant increase in call throughput. BRIEF DESCRIPTION OF THE DRAWINGS Presently preferred embodiments of the invention are depicted in the drawings, wherein like reference numerals refer to like elements in the various views, and wherein: FIG. 1A is an illustration of a prior art local endpoint application that communicates with a network endpoint application via a single channel communication line connected to a network; FIG. IB is an illustration of a prior art local endpoint application that communicates with a network endpoint application via a multiple channel communication line connected to a network; FIG. 2 is an illustration of the interrelationship between a local endpoint application, a proxy engine and a network endpoint application according to a preferred form of the invention; FIG. 3 is a hardware and software diagram of the local endpoint, showing the local endpoint application, proxy engine and communications hardware, in conjunction with the communication channel leading to the network and network endpoint equipment; FIG. 4 is an illustration of the sequence of the flow of information between the local endpoint application, the proxy engine, and the network endpoint application of FIGS. 2 and 3, when the data transmission session is established according to a preferred embodiment of the invention; and FIG. 5 is a schematic diagram of a source of data which implements the invention in communication with a variety of possible different network endpoint destinations over a network, wherein the proxy engine of FIGS. 2-4 may be implemented in one or more of the network endpoint destinations in addition to the source. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENT FIG. 1 shows a prior art data communication system wherein a local endpoint application 20 is in communication with a network endpoint application 30 via a network 40. The local endpoint application 20 is the source of data to be transmitted to the network endpoint application 30. The local endpoint application is linked via communications hardware (not shown) to a communication channel 22 A (such as a B-channel of an ISDN line), which is turn routed through the network or communication system 40 to a second ISDN channel 22B. Channel 22B is connected via conventional hardware (not shown) to the computer running the network endpoint application 30. Typically, the channel 22A supports the Point- To-Point Protocol (PPP) with or without the implementation of data compression techniques. In order for advanced PPP protocols to be used by both the local 20 and endpoint 30 applications, both would have to be supported by the respective applications. FIG. IB shows a similar prior art arrangement of the local and network endpoint applications 20 and 30 respectively, except that a multiple channel line 24A links the local endpoint application 20 to the network 40. Similarly, a multiple channel line 24B links the network 40 to the network endpoint application 30. The capabilities of the local and network endpoint applications is the lowest common denominator of protocol and compression suites that may be supported by the local and network endpoint applications. Referring now to FIG. 2, the presently preferred embodiment of the invention uses a proxy engine 50 to facilitate the communication between the local endpoint application 20 and the network endpoint application 30. The proxy engine 50 consists of a software structure that is typically implemented at the source computer (not shown in FIG. 2) running the local endpoint application 20, such as at the ISDN driver for the source computer. The proxy engine 50 consists of a set of routines 52 that communicate with the local endpoint application in a local endpoint application communication session 26, and a set of routines 54 that communicate with the network endpoint application 30 in a network endpoint application communication session 28. The routines 52 consist of PPP, single channel, no data compression routines that are described in detail below in conjunction with FIG. 4 and set forth in the appended software listing. The routines 54 consists of multiple channel PPPML routines, with compressed data, and are also described below in conjunction with FIG. 4 and set forth in the appended software listing. The double arrow 53 indicates that the local endpoint application routines 52 pass information learned about the local endpoint application 20 to the routines 54 that communicate with the network endpoint application 30, and vice versa. FIG. 3 is a hardware and software diagram of a source of data or local endpoint 32, showing the local endpoint application 20 (in software), proxy engine 50 (also in software), in their relationship to the communication hardware 56 that connects the source 32 to the communication channel 24. The communications hardware 56 is, for example, an ISDN basic rate adapter which is installed in a personal computer, and corresponds to the physical layer of the OSIRM model. The communication hardware 56 is controlled by the software 34 that runs at the source 32. The proxy engine 50 is in communication via the line 24A, network 40, and line 24B with the destination or network endpoint 38, which has its own communications hardware 56 controlled by its own application software 30. The local endpoint application 20 will typically support the Point-to-Point protocol and perhaps some limited subset of the advanced PPP features, and may or may not support particular data compression algorithms. The session 26 negotiates the PPP protocol down to single channel and no data compression. The proxy engine 50 supports single channel non-compressed PPP protocol to the local endpoint application 20 from the routines 52. The proxy engine 50 supports multiple compressed PPP channels to the network endpoint application 30 (which supports PPP or PPPML) and possibly compression of the data packets from routines 54. The network endpoint or destination 38 contains a network endpoint application 30 which supports PPP or PPPML and possibly compression of data packets. If the network endpoint application 30 supports a particular data compression algorithm, but the local endpoint application 20 does not, the proxy engine 50 provides for the local endpoint application 20 the necessary data compression feature, provided that the proxy engine supports this particular compression feature. It will be apparent that to optimize the usefulness of the proxy engine with a large and diverse set of potential network endpoints, it is preferable to support as large a number of protocol features (such as PPPML, security requirements such PAP) and data compression techniques as possible. It will also be appreciated that the present invention may be used with just support for PPP features such as PPPML or PAP and no data compression, or data compression but no protocol features, or with both protocol features and data compression, the idea being that the proxy engine supplies the missing authentication protocol (i.e., CHAP in the present embodiment), data compression technique, or multiple link protocol that happens to not be implemented at the local endpoint application. The data transmission session establishment process is preferably performed in a sequence of steps. In particular, FIG. 4 illustrates the session establishment flow between the network endpoint application 30 and the local endpoint application 20, with the reference numerals 1-10 corresponding to the steps described below. The arrows in FIG. 4 represent the flow of requests and information between the proxy engine 50, the local endpoint application 20 and the network endpoint application 30. As noted in FIG. 4, the proxy engine is placed in simultaneous communication sessions 26, 28 between the proxy network endpoint application 30 and the local endpoint application 20. The routines 52 and 54 (FIG.3) which are performed in the proxy engine 50 are described in conjuction with the ten steps set forth below. Step 1: Bring up the physical layer of the network session 28. The process begins by the source DTE 32 placing a call over a communication link (such as an ISDN D-channel) to a remote DTE 38 on the network or communication system 40, thereby allocating an end-to-end circuit through the communication network 40. Step 2: Bring up the network endpoint application 30 LCP layer. The proxy engine 50 establishes the link-control-protocol (LCP) layer of the network session 28 prior to responding to any messages from the local endpoint application 20. This step involves a series of handshaking routines (such as configure-request or CFG_REQ messages) to determine that the user at source 32 has called up a PPP entity 38 over the network 40. The Internet Standard for PPP is used for the LCP layer. Two of the items of information that is learned when the LCP layer in brought up in step 2 are (1) whether or not password authentication needs to take place, and (2) whether MultiLink (or PPPML) is supported by the network endpoint application 30. Step 3: Bring up the local endpoint application 20 LCP layer. Once the network endpoint application 30 LCP is established, the local endpoint application 20 LCP session is brought up. In the configure-request message, the Password Authentication Protocol (PAP) Authentication is specified if the network endpoint application 30 requires any kind of authentication. PAP is used so that the user name/password is obtained transparently from the local endpoint application 20 without requiring user intervention. Step 4: Bring up the local endpoint application 20 Authentication Layer (if applicable) If the network session 28 at step 2 specified that the local endpoint application 20 must authenticate passwords before bringing up the network control protocols (NCP's), the user name/password combination must be obtained from the local endpoint application 20. By requesting to the local endpoint application 20 during the link control protocol negotiations that the local endpoint application 20 must authenticate with the proxy engine 50 (the proxy engine 50 being the Authenticator and the local endpoint application 20 being the Peer), we now bring up the PAP Authentication control protocol with the application session as per the Internet Standard for PPP Authentication Protocols. Step 5: Bring up the network endpoint application 30 Authentication Layer. Once the local endpoint application 20 authentication control protocol is open, the network endpoint application 30 's authentication control protocol is brought up, with the network endpoint application 30 being the Authenticator and the proxy engine 50 being the Peer. In the preferred embodiment, the proxy engine 50 can support both PAP or CHAP (Challenge Handshake Authentication Protocol). Also, the proxy engine 50 will only be the Peer on the network endpoint side and the Authenticator on the local endpoint side. Step 6a: Determine which Network Control Protocols (NCP's) the local endpoint application 20 wants to bring up. At this point, the proxy engine 50 needs to determine which of the network control protocols the local endpoint application 20 supports and wishes to open. In order to determine this, the proxy engine 50 will wait to receive the CFG_REQ message from the local endpoint application 20 for the NCP's that the network endpoint application 20 wishes to open and communicate over. Upon receiving a CFG-REQ message, the proxy engine 50 will first learn any information that is necessary for successful proxy operations. The learned information for each supported network control protocol is as follows: (i) BCP (Bridging Control Protocol): None. (ii) IPCP (Internet Protocol Control Protocol): The local endpoint application 20' s internet protocol address, including whether the local endpoint application 20 is asking for an internet protocol address to be assigned from the network endpoint application 30. (iii) IPXCP (Internet Packet Exchange Control Protocol): a) The local endpoint application 20's internet packet exchange network address, including whether the local endpoint application 20 is asking for the IPX network address from the network endpoint application 30; and b) The local endpoint application 20 's IPX Node Address, including whether the application 20 is asking for an IPX Node Address to be assigned from the network endpoint application 30. If the local endpoint application 20 is asking for one to be assigned, the proxy engine 50 will return the proxy engine's Media Access Control Address as the assigned Node Address (which is stored in an EEPROM memory, not shown) instead of asking the network endpoint application 30 for one. c) NBFCP (NetBEUI control protocol): The local endpoint application 20' s name in the IBM Network Basic Input/Output System Extended User Interface (NetBEUI) protocol. Since multiple network control protocols can be opened over a single PPP session, each network control protocol state machine can operate autonomously. Step 6b: Determine which (if any) Compression Protocols the network endpoint application 30 is trying to bring up. If it is one that the proxy engine supports, bring it up. Once all of the LCP and Authentication Layers are opened, the network endpoint application 30 is allowed to attempt compression control protocol (CCP) negotiations, that is, opening up a compression session between the proxy engine 50 and the network endpoint application 30. The proxy engine 50 listens for any CCP CFG_REQ messages from the network endpoint application 30. Upon receiving one, the proxy engine 50 determines what compression scheme the network endpoint application 30 is trying to negotiate. Specificallly, the compression algorithm that the network endpoint application 30 is attempting to negotiate is determined in two steps. The first step is to look at the CCP Option Type Field in the CCP Configuration Request (CFG_REQ) message. If the CCP Option Value indicates Microsoft PPC Compression, the proxy engine does not need to proceed further with the interrogation. If the CCP Option Value indicates STAC Electronics LZS, the proxy engine 50 needs to determine whether it is STAC LZS ™ or Ascend ™'s version of STAC LZS. Th difference between these two is that the length of the STAC Electronics Configuration Request Message is five (5) bytes long whereas Ascend 's length is six (6) bytes long (Ascend has an additional byte for negotiating the dictionary reset mode). If none of the three compression techniques were detected, no compression will be allowed. Persons of skill in the art will of course appreciate that the above identification technique for presently popular data compression techniques can be readily adapted to other types of data compression techniques that may be developed in the future. If the compression techniques that the network endpoint application 30 is a compression scheme that is supported by the proxy engine 50, the proxy engine 50 will open the compression layer control protocol with the network endpoint application 30. If it is not one that the proxy engine 50 supports, the proxy engine 50 will reject the request to negotiate the compression layer with a PROTO_REJECT message, thereby disallowing compressed data packets over the network session 28. Thus, even if the local endpoint application does not support the data compression algorithm requested by the network endpoint application 30, the proxy engine 50 provides it for the local endpoint application 20, allowing the data compression technique to be used in the transmission of data from the source to the destination. Preferably, the proxy engine 50 supports a wide variety of known compression protocols, such as STAC LZS ™, Microsoft PPC ™, and Ascend ™ version of STAC LZS™. Licenses from the proprietors of the compression techniques should be obtained in order for the proxy engine 50 to implement proprietary compression techniques. Step 7: For each NCP that the local endpoint application 20 has specified (via step 6 (a)), bring up the respective network endpoint application 30 NCP. After learning the local endpoint application 20 NCP information in step 6(a), the proxy engine 50 will use this information in bringing up the respective network endpoint application 30 NCP's. If any information was dynamically assigned by the network endpoint application 30 (as dictated by the local endpoint application 20) the proxy engine 50 will store the learned information for later use. Step 8: Once the Network endpoint application 30 NCP are opened, bring up the respective application NCP. After the network endpoint application 30 NCP is opened, the proxy engine 50 will bring up the respective local endpoint application 20 NCP (passing back to it any dynamically assigned information from either the network endpoint application 30 or the proxy engine 50). Once this step is complete, data packets may flow over the proxy engine 50 logical interface. Step 9: Once the local endpoint application 20 NCP is open, the proxy engine will now allow data packets to flow through it. As the proxy engine 50 receives data packets from the local endpoint application 20, it will: (1) try to compress the packet (if applicable); (2) split the packet (original or compressed) into multiple fragments; and (3) transmit the fragments over one or more open data channels to the network endpoint application 30. As the proxy engine 50 receives data fragments from the network endpoint application 30, it will: (1) collect all the fragments which constitute a complete data packet; (2) reassemble the fragments into one contiguous data packet; (3) uncompress the reassembled data packet (if applicable); and (4) transmit the uncompressed reassembled data packet to the local endpoint application 20. Step 10: If the network allows MultiLink to be brought up. bring up a second data channel. Once the first NCP is opened on the local endpoint application 20 side, the proxy engine 50 will preferably attempt to bring up a second data channel (such as the second B-channel in ISDN basic rate service) over the network session 28. Unlike the first link, the local session 26 is not aware of the second B-channel activity. Once the second B-channel comes up, the data packets are transmitted over both the multiple active B-channels to the network endpoint application 30 running at the destination DTE 38, thereby increasing call throughput and reducing the overall call connect time. The present invention may be implemented in a variety of situations. Referring to FIG. 5, the source DTE 32 is shown connected via channel 24 A to a network 40 (the details of which are not important). The network 40 may supply a line 24B to a bridge 60 connected to a second network 61, a line 24C connected to a router 62 connected to another network 63, a line 24D connected to computer 64, or a line 24E connected to a computer 70. In FIG. 5, source 32 is shown as having a proxy engine in communication with communication hardware 56 (such as an ISDN basic rate adapter), and running an application software comprising the local endpoint application 20. The source 32 may attempt to transfer data to the bridge 60, which runs its own application and thus is considered herein as a network endpoint application. The same holds true for router 62. Note that computer 64 has its own proxy engine 50 and application 20. The combination of the proxy engine 50 and the local endpoint application 20 running in the computer 64 constitutes in effect a network endpoint application 65 that may be called by the source 32. The computer 70 is shown connected to a line 24E via an ISDN terminal adapter 72. The computer 70 does not have a proxy engine of its own. However, the source 32 may transmit data to the computer 70 using its own proxy engine in the manner described above. The combination of the computer 70 running its own application and ISDN TA 72 could also be considered a network endpoint application as that term is used herein. In all of the above representative examples of FIG. 5, it will be appreciated that the proxy engine 50 in the source 32 facilitates the communication with whatever network endpoint application it may happen to call to transmit data. The description above in conjunction with FIGS. 2-4 would apply to any of these data transmission sessions. The appended computer software listing sets forth the source code for a presently preferred embodiment of the invention. The source code is preferably incorporated into the ISDN driver, and runs on the motherboard of a host personal computer. The reader is directed to the Notice Re: Copyright set forth above. It will be appreciated from the forgoing description of a presently preferred embodiment of the invention that some variation in the above procedure is envisioned depending on the particular features of the data transmission medium, the capabilities of the local and network endpoint applications, and the protocol features that may be supported by the proxy engine. Such variations will apparent to those of skill in the art and are intended to be within the spirit and scope of the invention. As additional protocols are developed (such as authentication protocols and multiple link protocols, some modification to the operation of the proxy engine may be necessary in order to implement the invention, and such modifications are considered to be within the capabilities of persons of ordinary skill in this art. This true spirit and scope is defined by the appended claims, to be interpreted in light of the foregoing specification. typedef enua I PPP STATE UNDEFINED, /' PPP elt conn is undefined - f PPP~STΛTE~CONN UP. /* PPP ekt conn is up V PPP~STΛTE~NCP OP, /• PPP NCP's are up •/ PPP__STΛTE~HΛX~ /* Maximum state value •/ I PPP states ϊ; /* PPP Connection Events typedef enu PPP_EVENT_START. / « Start PPP connection PPP~EVENT~LINK UP, / ' Linn is up PPP~EVENT " LINK~DN, /« Link is down PPP~EVENT~PACKET TX, / « Application level packet to tx PPP~EVENT~FRAM£ RX. / « IPC data frame received PPP~EVENT~TIMER7 /* Timer timeout APPP_EVENT TIMER. /« App Timer timeout NPPP_EVENT~TIMER, /> Net Timer timeout PPP_EVENT_MAX PPP events t; PPP Deflnitiona typedef enum PPP gβt_pld code e typedef enum PPP layer e ( LCP LAYER - 0, PAP~LAYER. CHAP LAYER, BRCP ' lAYER. IPCP~LAYER, IPXCP LAYER, NBFCP~LAYER, CCP LAYER, NUM~PPP_LAYERS ) PPP_layβr_ ; typedef enum CP_states_e C?_INITIAL - 0, CP_STARTING, C? CLOSED, C?~5TOPPED, :?~CLOSING, C?~5TOPPING, C?~REQ_SENT, C? ACK~RCVD, CP~ACK _ SENT, CP~OPEN CP states t; typedef enum £M_states e i EM INITIAL - 0, EM~LISTENING, EM~NETCP_STARTED, EM NETCP OPEN, EM k.PPCPJ.PEN } EH states t; / • PPP Control Protocol control block */ typeoβf struct s_cpctl ( CP states_- cpstate; / • Control Protocol state •/ ua~ lastid; / • ID of last REQ we sent •/ ul6 ack_retry; /* sβnd_rβq ACK retry " counter */ Tιmβr_t cιmβr_ιdl; / • Identifier of timer 1 • ' Timer t timer ιd2; /* Identifier of timer 2 */ } S. CPCTL? /** Compression control block •/ typedef struct _comprβssιon state 1 BOOL inited; /* Compression session inited '/ BOOL compressing; /* TRUE if we are compressing •/ DWORD algorithm; /* which algorithm we are using •/ uiό mode; /* N:N or 1:1 mode for the connection •/ -16 per ormance_mode; /* LZS performance parameter •/ -16 performance; /* LZS performance parameter V ul6 flags; /• LZS compression ONLY flags •/ ul6 cut_o _sιze; / • Won't compress less tnan this size */ ul6 tl_*.o_large; /* Ctr for TI timer: pkts to large •/ ul6 *.l_pιct_count; /* Ctr for TI timer: pkts compressed •/ I Comprβss_t; •define PPP TIMER1 •define PPP~TIMER2 •define PPP TIMER3 •define SZ_IPX NOOENUM 6 .define SZ NBFJ-LUTTER 6 •define SZ_.NBF_PEERNAME 33 •define MPP_WINDOW_SIZE 16 •define NUM~PPP INTERNAL BUFS 8 •define MAX~QUEUED PPP DATA PKTS 4 •define MAX -ALL_RETRIES ~ 5 •define PPP RESTART TIMEOUT • 3 •define PPP~MAX TERM COUNTER . •define PPP~MAXJCFG COUNTER 10 •define PPP~MAX_FAIL COUNTER 10 •define PPP~CHECKB TIMEOUT 45 •define M PPP NCP PROTS (PPP PROT CCP I PPP_PROT_NBF I PPP PROT IPX I \ ?PP_?ROT Z ? : ?PP_PROT_BR I PPP_PROT CHAP I \ PPP PROT~PAP) /* PPP channel control DIOCK. typeoef struct S PPP I * Protos supported (BRIDGE. IPI */ * Circuit Connection State ♦/ /* Last event processed •/ / * LCP: 1"Attempt MRU negotiation •/ * LCP: Max RX Unit value (Outgoing) •/ * LCP: Max RX Unit value (Incoming) */ 1 * LCP: RX Addr/Ctrl compression •/ * LCP: RX Protocol compression •/ * LCP: TX Addr/Ctrl compression */ / • LCP: TX Protocol compression */ - LCP: Send Endpt ID •/ * LCP: Authentication Flags •/ ul6 auth compl_flags; / ♦ LCP: Auth Complete Flags •define AF CHAPJWJTH APPROVED 0x1 •define AF~CHAP_PEER~APPROVED 0x2 •define AF~PAP_AUTHJΛPPROVED 0x4 •define AF~PAP PEER APPROVED Oxβ u32 challengβ_val; /* CHAP: Current Challenge Value •/ ul6 neg_ιp_addrs; /* IPCP: 1-aend a CfgReq w/ιp addrs */ BOOL ρee _negotιated_ p_addr u32 my_ιp_addr; /* » IPCP: My IP address •/ u32 peer_ιp_addr; /* IPCP: IP address of remote peer */ ul6 neg_ιpx_nβtwork; /* IPXCP: 1-sβnd CfgReq w/ipχ net I •/ BOOL ρeer_negotιated_ιpxnet_addr; u32 my_ιpx_nβtwork; /* IPXCP: my IPX network, address •/ u32 pββr_ιpx_nβtwork; /* IPXCP: peer IPX network address •/ ulβ nβg_ipx_nod«; /* IPXCP: 1-ββnd CfgReq w/IPX node f ' BOOL pββ7 negotiated ipxnodβ addr; uβ my lpx nodβlSZ IPX NODENUM); uθ peer ipx nodβfSZ IPX NODENUM]; ulβ lpx framing; IPX frame type (as it goes up) •define PPP_IPX_FRAME ETHER II 0 •define PPP_IPX_FRAME~ETHER__802 2 1 •define PPP IPX_FRAME ETHER_802~3 2 •define PPP_IPX_FRAME~ETHERJ3NAP 3 ul6 neg_namβ_pro. ; / NBFCP: 1-send CfgReq w/Name Pro. BOOL peer_negotiated_nβnamβ; ulβ neg_peer_mfo; /' NBFCP: 1-send CfgReq w/Peer Info '/ uie nb mac_rβq; / NBFCP: MAC address required flag */ uβ nb~pββr clutter(SZ NBF CLUTTERI ; /* NBFCP: Peer Class,Ver */ β nb~peer~name(SZ NBF PEERNAME]; / ♦ NBFCP: Peer Name •/ uθ ccp rβq_.βn; CCP: CCP Cfg Req options length */ •define CCP STACKER REQ~LEN 5 •define CCP~MICROSOFT REQ LEN 6 •define CCP~ASCENO_REQJ_XN β uβ ccp nun hists; /• CCP: CCP Number of histories •define CCP CV NONE ~ 0 •define CCP~CV~LC8 1 •define CCP_CV~CRC 2 •define CCP_CV_SEQNUM 3 uβ stac_cnβck_val; /• CCP: STAC Cheek Value type •/ uβ stac_dβcomp_pausβd_ιd; /* > STAC: Decompress Pause ID V /* (non-0 means we are paused) •/ ulβ mopc_rx_conβrency; / ♦ MPPC: RX conβrβncy ctr (12 bits) */ ulβ mppc tx coherency; /* MPPC: TX coherency ctr (12 bits) */ •define CCP_A_FLUSHED ~ ~ OxβOOO •define CCP~B~HISTBEG 0x4000 •define CCP~C~PKTCOMPRESSED 0x2000 •define CCP~D~PKTENCRYPTED 0x1000 •define CCPj:OHERENCY_BITS OxOfff uβ ascend reset mode; /* CCP: ASCEND Reset Mode •define ASCEND_RESET SING1 HISTORY 0x1 •define ASCEND RESET~MULTI HISTORY 0x2 •define ASCEND~RESET~HISTORY GEN 0x3 /* Ascend CCP request - extra byte value Idefine ASCEND MAGIC BYTE uβ pppic; ' • Counter for PPP id field */ u3 mpp_seqnum; /* MPP: Running sequence number •/ u32 mpp seq_state; •define MPP_SEQ STATEJΛESYNC 0 »dβfιnβ MPP_SEQ~STATE_SYNC 1 / • " Compression Control Block vars. **/ Data Control Bloc* variables. ♦« Link expansion timer , / Last link data was sent out */ Data activity flag ♦ / • of application packets tx •/ • of IPE packets tx */ Numcer of bytes tx •/ Number of bytes tx per poll */ • of application packets rx */ • of IPE packets rx */ • of bytes rx */ • of bytes rx per poll •/ Lower edge of rx window •/ Upper edqe of rx window ♦ l •/ Call retry counter */ ; / • Rx buffers •/ 1; /* Rx buffer map •/ Tx pkt queue •/ Number of Tx pkts on the que •/ / • APPP channel control block. •/ typedef struct S APPP ( / • Protos supported (BRIDGE, IP) •/ / « Circuit Connection State */ / - Last event processed -I / « LCP: 1-Attempt MRU negotiation •/ / - LCP: Max RX Unit value (Outgoing) */ / • LCP: Max RX Unit value (Incoming) •/ / « LCP: RX Addr/Ctrl compression •/ l - LCP: RX Protocol compression •/ I ' LCP: TX Addr/Ctrl compression */ I ' LCP: TX Protocol compression */ I ' LCP: Send Endpt ID •/ / ' LCP: Authentication Flags •/ 0 LCP: Auth Complete Flags u32 challβngβ_val; / • CHAP: Current Challenge alue */ ulβ nβg_ιp_addrs; /* IPCP: 1-send a CfgReq w/ p addrs */ BOOL peer_negotiated_lp_addr; u32 my__p_addr; / • IPCP: My IP address */ u32 peβr_Ip_addr; / • IPCP: IP address of remo e peer */ ulβ neg_ιpx_nβtwork; /* IPXCP 1-sβnd CfgReq w/IPX net » • / BOOL pβer_nβgqtιated_ιpxnβt_addr; u32 my_ιpx_nβtwork; /* IPXCP my IPX network address */ u32 pββr_ιpx_network; / • IPXCP peer IPX network address •/ ulβ neg_ϊpx_nodβ; / • IPXCP .-■end CfgReq w/IPX node t */ BOOL peer nβgotιated_ιpxnodβ_addr uθ my_ιpx_nodβ(SZ IpX_NODENUMl ; uβ pββr_ιpx_nodβ|SZ_IPX_NO0ENUM 1; ulβ lpxjirammg; /* IPX frame type { a* it goes up) •define PPPJIPX FRAME ETHER II 0 •define PPP_IPX~FRAME~ETHER 802_2 1 Idefinβ PPP IPX FRAME ETHER 802 3 2 •define PPP~IPX~FRAME~ETHER~SNA? 3 ulδ neg_name_pro-|; / • NBFCP: 1-sβnd CfgReq w/Naraβ Pro: BOOL, peer_negotιated_noname; ul6 neg_peβr_ nfo; ~ " NBFCP: 1-send CfgReq w/Peer Info */ ulβ no mac req; f NBFCP: MAC address required flag •/ uβ nD~peer_clutter|S2_NBF_C UTTERI /* NBFCP: Peer Class,Ver •' u8 nb_pββr name(SZ_NBFJ?EERNAMEl; /• NBFCP: Peer Name •/ u8 pp id; /* Counter for PPP d field / " Data Control Block variables. ** u32 tx_packβts; /* I of application packets tx */ u32 tx_bytβs; //• NumBβr of bytes tx •/ u32 rx_paekets; / f of application packets rx •/ u32 rx bytes; / I of bytes rx */ 3_CPCT a_cpctl(NUM_PPP_LAYERS, ; EM states a_emstatea(NUM_PPPJ ^ AYERS1 ; /• Emulation state •/ APPP~CB_t; typedef struct _callInfo DWORD num links; /* num active links for this call •/ ιnk_C8 t l mk (MAX_LINKS ] ; APPP CB~t appp; /* PPP Emulation State Machine. */ PPP CB_t PPP; /• PPP State Machine. •/ ISCCALLSPECI ICDATA IscCallOata; / ♦ ISC Call Info paramo •/ CA INFO, 'PCA INFO; ###### * I « I MMMI » I HMIMf MMMI IMMM opyngnc ISDN Systems Corp., 1992-1995. All Rignts Reserved. Filename: appp.c Description: This module contains the Application side for tne PPP Emulation state machine processes. Modification Log: Date Authors Notes/Description of Change 02-10-93 Jomama Genesis •include "pppdefs.h" /* • em_ppp_undβfinβd_proc - Process UNDEFINED events void em_ppp_undβfinβd_proe( PPP_βvβnts_t event, PCALI.INFO IpCall, void *p_auxl, void *p aux2, void • p_aux3> I APPP_CB_t *p_acb - *lpCall->appp; /• APPP CB •/ PPP_CB_t *p~ncb - SlpCall->ppp; /• NPPP CB •/ LinkJTB_t -p link - (Lmk_CB_t • )p_auxl; /* Link CB •/ /* p_auxl is tne ptr to tne l nk control block (where appl.) •/ / • p_aux2 is the address of the user αata (wnere applicable) */ p_acD->last_event » event; p_ncD->last_evβnt • event; switch(eventl 1 case PPPJΪVENTJ_INKJJP: if (lpCall->num links -• 1] ( aρpp_ιnltcDl IpCall) ; nppp ' initcbl IpCall, p link); p acb->ekt_state - PPP STATE CONNJJP; p~ncβ->ckt_statβ - PPP~STATEJ.ONNJJP; /• Establishing PPP connection • / /* beam me up scotty... Net s de (STEP 1) */ nppp startllpCall, p link, LCP LAYER, CPJCLOSEO) ; ) /' else this an expanded l nk - impossible •/ Dreak; case PPP 2VENTJ_.INKJ_W: /• ignore */ break; case PPPJ5VENT _-RAMEJAX: ppp_rls_pkt (p_aux2. 0); / ♦ drop it */ oreax; -32- case PPP_EVENTJ»ACKXT_TX: ppp_rls_pκt ιp_aux2, 0); / • we don't queue TX pkts, drop i •/ break; case APPP VENT_TI ER: clr_appp_tιmer(lpCall, (PPPJlayer_ ιp_aux3, ( u32)p_aux2 ! ; break; case NPPPJiVENTJTIMER: clr_nppp_tιmer (IpCall, p link, ( PPPJιayer_ )p_aux3, (u32)p_aux2! ; oreak; /* Event is unrecognized */ default: break; /« em_ppp_ckt_conn_up - Process CONNJJP events void em_ppp_ckt_conn_up_proc( PPP_evβnts_t event, PCALLINFO IpCall, void *p_auxl, void "p aux2, void *p aux3) I APPP_CB_t *p_aco » t ( lpCall->app l ; /* APPP CS ♦ / PPPJCB_t *P_hcb » -lpCall->ppp; / • NPPP CB • / Link_C8_t -p~link - (Lιnk_CB_t • )p_auxl; /* Link CB • / PPPJlayβr_t layer; /* p_auxl is the ptr to the link control block (where appl.) ♦ / /* p~aux2 s tne address of the user data (where applicable) • / /* ~ or the Timer Index • / /* p_aux3 is tne PPPJiayβr (for Timer Events) • / p_acβ->last_βvβnt " event; p_nco->last_βvβnt » event; switch(eventI case PPPJiVENT LINKJJN: / • Connection is down */ if (ϊpCall->num links — 0) I p acb->ckt state - PPPJSTATEJNOEF-NED; p~nco->ckt~statβ - PPP~STATE~UNDEFINED; appp_clβanup juβuβs(IpCall) ; nppp_cleanup_quβuβs(IpCall) ; appp_ιmtcb( IpCall) ; nρpp_ιnιtcβ( IpCall, p lmki; /* PPP connection down • / ) else 1 / • Expanded PPP link down •/ ) break; case PPPJϊVXNTJ/RAMEJΛX: / ♦ pkt from Net level • / nppp_rxjfr »β( IpCall, p Unk, p_aux2); break; case PPPJiVENTJ?ACKXT_TX: /• pkt from Application level • / appp_rx .ramβ( IpCall, p_aux2); break; case APPPJϊVENTJTIMER: layer » ( PPP_layβr_.)p_aux3; clr_appp_tιmer( IpCall, layer, ;u32)p_aux2) ; if (layer -- PAPJ.AYER) appp_auth_tιmeout (IpCall, layer, ( u32 ) p_aux2 ) ; else ppp_ timeout : IpCall, -ayer, ιι_32)p aux2!; case NPPPJϊVENT riMER: layer * I PP?_layer_t ιp_aux3; clr_nppp_-.ιmeri ipCal., p .ink, layer, (u32 )p_aux2) ; if I (u32)p_aux2 -- PPPJTIMER3) i / • tne Bandwidth timer */ nppp cneck_ow(lpCali: ; ) else '* a CP timer */ I if ((layer — • CHAPJ-AYER) l l (layer •- PAPJ_AYER) ) .-ιppp_autn_tιmeout (IpCall, p_lmk, layer, ιu32)p_aux2) ; else ~ nppp_tιmeout!IpCall, p linn, layer, (u32)p aux2); I creak; case PPPJΪVENT .INKJJP: / • This is only valid for an expanded link */ if ( IpCall->num links ~ 2) < /* beam me up scotty... */ nppp_start( IpCall, p link, LCPJ-AYER, CP CLOSED); i ~ ~ oreak; /* Unrecognized Event */ default: break; /• em_ppp_rβlβasβ_conn - Stop all links for th s connection •/ ~ ~ em_ppp_release_conn( PCALLINFO IpCall ) i APPP CB t -p acβ - i(lpCall->appp); /• APPP CB */ PPP_CB_t -p~nco - 4lpCall->ppp; /• NPPP CB V p acβ->ckt state - PPP STATE UNDEFINED; p~ncβ->ckt~statβ - PPP~STATE~UNDEFINED; appp_cleanup_queuβs(IpCall ) ; nppp_cleanup_queues ( IpCall ) ; appp_ιnιt_all iayβrsIIpCall. CPJINITIAL); /* It s Highly Recommended to oring down the Primary Link LAST !! */ if (IsPrlmaryLinkdpCall, .lpCall->lmk[01 ) I I nppp_rβlβaββ ιink(IpCall, .IpCall->1ink(1] ) ; nppp~release~lιnk( IpCall, 41pCall->lιnkI01 ); ) else I nppp_rβlβasβ ink (IpCall, tlρCall->llnkfO) ); nppp~rβlβase Link (IpCall, .ipCaU-> nk(l| ) ; I appp_send_pkt - Transmit a frame. appp_sβnd j 3it ( PCALLINFO IpCall. GCAPAC ET *p_pkt. ul β pid) / • APPP CB •/ /* ad ust the prim buffer pkt offset • / /* (put in the PPP neader) • / PUTJJATA_OFF(p_pkt, [GET_DATAJJFF(p_pkt> - PPPJHDRLEN) ) ; p_pppndr » (SJ?PPHDR * ) GETJ3ATAJ?TR(p_pkt 1 ; p_ppphdr->addr - HDLCJ-J.LJ-UDOR; p_pppndr->control • HDLCJJI; p_pppndr->pιd » swaplβlpid) ; p_pkt->uLβngth •>« PPPJHDRLEN; /* now handle AC and/or Proto Compress •/ if (pid •- PPP LCP PID) { ad ustjfwd » 0; / ♦ if AC comp. Dump up the ptrs and decrement the ctrs '/ if (p_aco->tx_ac_comp) adjust_fwd ♦» 2; / • if PROTO comp. Dump up the ptrs and decrement the ctrs •/ if ( id ( (pid t OxffOO) ••» 0)) switch (adjust fwd) ( case 1: /* Protocol Compression •/ /* adjust the prim buffer pkt offset •/ /• (take out the AC fields) ♦ / PUTJJATAJOFF(p_pk , (GETJJJATAJOFF(p_pk ) ♦ 11); p_pkt->u ength — 1; / • move Addr/Ctrl up •/ p_βytβ - ιu8 -IGET DATAJ*TR(p pkt); • pjoytβ - HDLCJ ,L~AODR; HDLCJJI; rea ; case 2: /" AC Compression •/ /• adjust tne prim buffer pkt offset */ /* (take out the AC fields) */ PUTJ3ATΛJ)FF(p_pkt, IGE J3ATAJJFF(p_pkt ) ♦ 2)); p_pkt->uLβngth — 2; break; case 3: /" AC and Protocol Compression */ /* adjust tne prim Duffer pkt offset */ /* (taxe out tne AC fields) • / PtπjDATA_OFF(p_pkt, (GETJ3ATAj3FF(p_pkt ) ♦ 3)1; p_pkt->uLβngtn -« 3; break; ) ) /• • * Now we have the pkt fully encapsulated, ship it • / / • bump stats */ p_acb->tx_packβts*- : p_acb->tx~βytβs ♦«■ p_pkt->uLβngth; / ♦ Enqueue the frame to tne rx (App) data queue '/ L4J?lacePackβtOnRιng( IpCall, (void • )GETJ3ATAJ?TR(p_pkt ) , p_pkt->uLength) ; ppp_rTs_pk ιp_pkt, 2); return 0; appp_rx_ rame - Receive a frame irom a link void appp_rx_frame( PCALLINFO IpCall, 3CAPACKET *p_ rame) APPP_CB_t *P_3=D * t (lpCall->appp) ; /* APPP CB SJPPPHDR -p j pppndr; J8 -p_Dyte; int adιust_Dack; p_ppphdr - (SJ?PPHDR • I (GETJ3ATAJ?TR(p_ frame) ) ; /• pump stats */ p_acb->rx_oytes ♦- p_frame->uLength; p_acb->rx_ρackets*>*>; / • if necessary, rebuild the received pkt PPP header. Influencing •/ /* parameters can oe ACJZompression ano ProtocolJZompression. */ p_βyte - iu8 *!p_ppphdr; ad 3 ustJoaek » 0; /* adjust for AC Compression */ f (Cp_βyte —■ H0LC_AL-,_AD0R) it ( ♦ !p_oyte»l I -- HDLCJJI)) p_Dytβ ♦- 2; / * Dump past the aoor/ctrl fields */ else adjust_βack »- 2; /* adjust for Proto Compression */ PUT_DATA_OFF(p_framβ, (GETJ_ATAJ3FF(p_framβ) - adjust_back) ) ; ρ_framβ->uLβngth »• adjust_back; p_bytβ « (u8 *)p_ppphdr; P-JPPpr- r " <SJ?PPHDR "l lpjaytβ - adjust jack) ; • at this point, we know how far Dack to go, so do it.... */ switch (adjust back) ( case 2: /' AC Compression */ p_ppphdr->addr - HDLCJ\LLJ\D0R; P_PPpndr->eontrol « HDLCJJI; break; case 1: /• Protocol Compression •/ case 3: /• AC and Protocol Compression • / p_ppphdr->addr - HD C -U. _ADOR; p_ppphdr->control - HDLCJJI; p oytβ • (uβ * ) 4p_pppndr->pιd; -pjoytβ - 0; break; Now we have a PPP packet. Hake sure: */ 1) packet is not too snort */ 2) make sure that ADDR-Oxff •/ 3) make sure tnat CTRL«3 • / 4) make sure tnat PROT is odd */ ( (p_framβ->uLβngth <■ PPPJ DRLEN) I I lp_ppph r->addr '• HDLC_ALL_A00R) n (p_pppndr->control '• • HDLCJJI) I I ( (swapl6(ρ_pppnor->pιd) & I) »- 0)) ppp_rls_pkt(p_framβ, 0); return; appp_rx_pkt ( IpCall, p_frameι; appp_rx_pκ - Process a received oaocet void appp_rx_pkt( PCALLINFO IpCall, GCAPACKE? • p_pkt) APPPJTB_t *P_a=o * * ! lpCali->appp) ; / • APPP CB */ PPPjTS T *p_nco • 4(ipCali->pppι ; /• NPPP C3 • / ιni_cl_ *p_lιnk; 5_CPCTL~ -p acp - SlpCall->appp.a_cpctl ' LCP AYER] ; 3J2PCTL *p_ιpacp, *p_ pncp; ~ S_CPCTL *p_ιpxacp, » p_ pxnep; 3JTPCT -p_oracp, -p_orncp; SJTPCTL -p_nofacp, *o_--.Dfncp; S~PPPHDR *p_pppnor; GCAPACKET -p~PR_pkt; uβ -p_from; uβ *p_to; u!6 i; ulβ pid; si 6 numoytes; p_l nk - GetPrimaryLink ( IpCall ) ; p_ppphdr - (SJ?PPHDR * ) ( GET J3ATA J?TR (p_pkt ) ) ; **' Here we nave a contiguous PPP put, process it as such. •/ switch (swapl6(p_ppphdr->pιd) ) i case PPP BR PID: / * Bridge Data Packet */ case PPP~BPDUJ?ID: / • BPDU • / pjoracp » 41pCall->appp.a_cpctl [BRCPJ ^ AYERl ; pjorncp - *ρ_lιnk->a_cpctT[BRCPJ«AYER) ; pid - swapl6(p_ppphdr->pιd) ; if (p bracp->cpstate '- CP OPEN) I ppp_rls_pkt lp_pkt, 1); break; I f (p brncp->cpstatβ '- CP OPEN) ( ppp_rls_pkt (pjskt. 1); break; ) /* Strip off the PPP header •/ PUTJ3ATAj3FF(p_pkt, (GE J3ATAjDFF(p_pkt ) *PPP_HDRLEN) I ; p_pict->uLβngtn — PPP_HDRLEN;~ /* Paaa it to NPPP and let him handle it (and release the buffer) • nppp_sβnd_pkt ( IpCall. NULL. p_pkt, pid); break; ~ case PPPJIP_PID: /* IP Data Packet */ p_ιpacp~- SlpCall->appp.a_cpeti CPCPJ-AYERI ; p_ιpncp • J .p_lιnκ->a_cpctl[ IPCPJ_AYER1 ; if (p ιpacp->cpstate •- CP OPEN) ( - ~ ppp_rls_pktlp_pkt, 3); preak; if ip ιpncp->cpstate '- CP OPEN) I ppp_rls_pkt (p_pkt, ι; break; /* Strip off the PPP header •/ PUTJ2ATA_OFF(p_pκt, (GETJ2ATA OFF:p_pκ ) *PPPJ^RLEN) ) ; p_pkt->uLength~— PPP_HDRLEN;~ /* Pass it to NPPP and let mm nanαie it land release tne ouffer: • ' nppp_sβnd_pktilpCali, NULL, p_pκ , PPP_IPJ?ID); break; case PPP_IPXJ?ID: / • IPX Data Paciet '' p_ιpxacp - 4lpCall->appp.a_cpcti ! IPXCPJAYER] ; p_ιpxncp - ip_i nk->a_cpctl I IPXCP -AYER1 ; if (p ιpxacp->cpstate '-» CP_OPEN) I ppp_rls_pkt ιp_pkt, 3); break; I if (p_ pxncp->cpstate !- CP_OPEN) ( ppp_rls_pkt (p_pkt, 3); break; I /* Strip off tne PPP header * ' PUTJ3ATAJ3FF(p_pkt. (GET_0ATAJ3FF(p_pkt ) +PPP_HDRLEN) ) ; p_pkt->uLβngth--- PPP_HDRLEN; /' Pass it to NPPP and let him handle it land release the buffer) '/ πppp_send_pkt( IpCall, NULL, p_pkt, PPP IPX PID); break; case PPP NBFJ?ID: / • Nβtbios Data Packet •/ p_nbfaep - 4lpCall->appp.a_cpctl (NBFCPJAYER1 ; p_nβfnep - *p_lmk->a_cpctl [NBFCPJ-AYERI ; if (p_nbfacp->cpstatβ !- CP OPEN) i ppp_rls_pkt (p_pkt, 1 ) ; break; if (p_nDfncp->cpstate !- CP OPEN) ( ρpp_rls_pkt (p_pkt, 1); break; / ♦ Strip off the PPP header • / PUTJ3ATA_OFF(p_pfct. (GET JATAJOFFI p_pkt ) +PPPJ-IDRLE ) I ; p_pkt->uLengtn — PPPJHDRLEN;- /' Pass it to NPPP and let mm handle it (and release tne ouffer) nppp_sβnd_pkt 1 IpCall, NULL, p_pkt, PPP_NBFJ?ID) ; break; case PPPJ-CP ?ID: /* Link Control Protocol • / / • subtract PPP Header from packet length (total bytes in pkt) • / p_pkt->uLβngth — PPP_HDRLEN; appp_proc(IpCall, LCPJ-AYER, p_pkt); break; case PPPJ?APJ?ID: / ♦ Password Autnβnt cation Protocol • / if !p_lacp->cpstatβ I" CP OPEN) ! ppp_rls_pkt (p_pkt, 1 ) ; break; /• subtract PPP Header from packet lβngtn (total bytes in put) • / p_pkt->uLβngtn -- PPP_HDRLEN; appp_pap_proc( IpCall, PAP -AYER, p_pκt); break; case PPPJ3RCPJ?ID: ' • Bridge Control Protocol •/ * do not act on tins packet unless tne App LCP is Open. •/ if ιp lacp->cpstate '» CP OPEN) ( ppp_rls_pkt(p_pkt, 7); break.* I /* if we are not configured to support Bridging, but we get a •/ /• request from tne App, set it. */ if (! (p acb->protocols 4 PPP PROTJ3R) ) ( p_acβ->protocols i » pppj?ROTJ3R; p ncb->protoeols ι» PPP PROT BR; ) /• Before we respond to this request, the stat of the combined •/ /* state machines must nave advanced to the point that this NCP */ / ♦ is at least LISTENING. • / if (p aco->a_βmstates(BRCP LAYER] < EM LISTENING) ( ppp_rls_pkt(p_pkt, 7) ; break; t / ♦ subtract PPP Header from packet length (total bytes in pkt) •/ p_pκt->uLβngtn — PPPJ-IDRLEN; appp_proe( IpCall. BRCPJJAYER, p_pkt); break; case PPP_IPCPJ?ID: / • IP Control Protocol ♦ / /• do not act on this packet unless the App LCP is Open. **/ if (p lacp->cpstatβ !- CP OPEN) ( pρp_rls_pfct(p_pkt, 7); break; I /* if we are not configured to support IP, but we get a * » / /* request from the App, set it. */ if (' lp acβ->protocols 4 PPP PROT IP)) I p_acb->protocols l- PPPJ?ROT_IP; p nco->protoeols ι» PPP PROT IP; I / • Before we respond to this request, the stat of the combined */ /* state machines must tiav advanced to tne point tnat this NCP •/ / • is at least LISTENING. • / if (p acto->a ematates(IPCP LAYER) < EH LISTENING) 1 ppp_rls_pkt(p_pkt, 7); break.- 1 / • subtract PPP Header from packet length (total bytes in pkt) •/ p_pkt->uLβngth — PPPJ-IDRLEN; appp_proc( IpCall. IPCPJ ^ AYER. p_pkt); break; case PPP_IPXCPJ?ID: / ♦ IPX Control Protocol V /* do not act on this packet unless the App LCP is Open. V if (p lacp->cpstate ' - CP OPEN) ppp_rls_pkt (p_pkt, 7); break; I '* if we are not configured to support IPX, but we get a */ /* request from tne App, set it. */ if (!(p acc->protocois 4 ?PPJ?ROT_IPX) : ( ρ_acb->protocoιs i- ?PPJ?ROT_IPX; p ncβ->protocois I- PPP PROT_IPX; 1 / • Before we respond to this request, tne stat of tne combined */ /* state macmnes must nave advanced to the point tnat tnis NCP »/ / • s at least LISTENING. */ if (p_acD->a_emstates[IPXC?J-AYER| < EMJ ^ ISTENING) i ppp_rls_pκ ip_pkt, ",; break; i • suBtract PPP Header from packet length (total bytes in pkt) */ p_pkt->uLengtn — PPPJ-IDRLEN; appp_proc<IpCall, IPXCPJ-AYER, p_pkt); break; case PPP_NBFCPJ?ID: /* NetBios Control Protocol */ / • do not act on this packet unless tne App LCP is Open. */ if !p_lacp->cpstate '« CPJ3PEN) ppp_rls_pkt (p_pkt, 7); break; I /* if we are not configured to support NetBeui, but we get a */ /• request from the App, set it. • / if ( ! (p_acD->protocols 4 PPPJ?ROT NBF)) I p_acb->protocols I- PPPJ?ROTJ*IBF; p ncb->protocols i- PPPJ?ROTJ.BF; ) /• Before we respond to t s request, the stat of the combined •/ /* state macninβs must have advanced to tne point tnat tnis NCP •/ / ♦ is at least LISTENING. • / if (p_acD->a emstateslNBFCPJ-AYERl < -^LISTENING) I ppp_rls_pkt [p_pkt, 7); break; I /* subtract PPP Header from packet length (total bytes in pkt) */ p_pkt->uLength -- PPPJ-IDRLEN; appp_proc( IpCall, NBFCPJ-AYER. p_pktl; break; default: rx_sβnd_proto_re*) : /* only send back a PROTOJ-iEJ if LCP is open • / if (p lacp->cpstate —■ CP OPEN) I / * suotract PPP Header ! rom pactcet lengtn ( total bytes in pkt ) * / p_pkt->uLengtn -- PPPJ-IDRLEN; / • Get pacxet for tne sending of a PROTOCOL REJECT to peer • / i f ( ( pJ?R_pk*; - ppp_get_pkt i ) ) «» NULL) break; / • need to copy info f ield f rom RX pkt into PROTOJΛEJ pkt • / / • make sure it doesn ' t exceed max negotiated length * / p lrαm » ( l uβ * ) p_pppndr ) ♦ PPP_HORLEN; p~to • l l uθ • ) GETJ3ATAJ?T ι pJ?R_pkt I I ♦ PPP HDRLEN ♦ CNF HDRLEN? if (p_pkt->uLengtr* < p_acD-> remjnru I numoytes - p pκt->uLengtn; else numβytes - p_acβ-> remjnru; / • insert rejected-protocol after CNFJ-IDR •/ *p_to»* ■ i swapl6ι jpppnor->pιd) ) >> 9; *p_to*» « swaplβ !pjppphdr->pιd) ; pJ?Rjpkt->uLengtn •» 2; /* copy info field ♦ / for l " 0; i < numoytes; ι«->) *ρ_to*» » 'p from**; pJ?R_pkt->uLengtn »« numoytes; appp_sendreply( IpCall, LCPJ_AYER, pJ?R_pkt, PROTO_REJ. 0); ppp_rlS_pkt (p_pκt, 7|; Dreak; appp_get_pιd_code - Determine PID code from NCP states and * pacKβt type (from eft). •/ PPP_get_pιd_code_t appp gβt_pιd code! PCALLINFO IpCall. GCAPACKET *p pkt, ulβ •pjoid) ( APPPJCBJ: *P_»cb - t(lpCall->appp); /* APPP CB ■ .ιnk-C8 t • p_lιnk; ETHE J-1DRJTYPE • p ' ethndr; p_link » GetPπmaryLink ( IpCall ) ; /• Check to see if it is an IP Packet •/ if (p_acb->protocols i PPPJ?ROTJIP) p athhdr - ( ETHER J-IDRJTYPE • ) <GETJ3ATAJ?TR(p_pkt ) ) ; I tatβ -- CP OPEN) else I /* if we are using ONLY IP, que the packet, */ /* otherwise we must drop it Because we don't */ /• know which CP tnis IP pkt will eventually • / /• go out (IPCP might get negotiated away from • / / • the peer) . •/ if ( (p aco->protocols - M PPP NCP PROTS) -- PPP PROT IP) I / • we need to queue it until IPCP is up • / *p p d ■ ?PPJIPJ?ID; return) PPP GET PID QUEUE); else / • drop it */ return I PPP GET PID NULL), /• Check to see if it is an IPX P cket p_acD->protocoιs . ?ppj?ROT_:?X' BOOL noveli_pκ ; novell_pkt - FALSE; p_etnhdr - (ETHER_HDR_TYPE • 3ET 3ATAJ?TR(p_pkt ) ! ; /* are we dealing witn an Ethernet or 802.3 packet 1 •' if iswaplβl !ul6tp_etnndr->e_typeι > 1500) i if ( (p_ethhdr->e_type -« Ulβ IFTJIOVELL) > , (p_ethhdr->e type -» Ulβ EFT~NOVΕLL2) l ( p_acD->ιpx_f rammg - PPP_IPXJJ"RAMEjϊTHER_::; novel. Dit • TRUE; ulβ *p noveli_ιd; SNAPHDRJ? « p_snap; p_novell_ι! - (uiό • ) 'p_etnncr » 1); /* check for 802.2 and 802.3 Novell pkt types ♦ / if (*p_novell_id -- NOVEL J302J2) I p_acβ->ιpx_fraπung - PPP_I?XJTRAMEJITHERJ302_2; novell pxt - TRUE; ~ _ I else f Cp novell_ιd « NOVELL -02_3) I p_aco->ιpx_framιng - PPP_IPXJTRAME_ETHERJ302_3; noveil_pkt « TRUE; ~ ~ ; ~ /* cheek for SNAP Novell pkt types •/ else if (*p novβil_ d -- SNAP SNAP) ( p_snap - (SNAPHDRJ? • ) p_novell_ιd; if ( (p_snap->Typβ(01 »- (EFT_NOVELL >> 8)) -i (p~snap->Typβ(ll -- (EFTJIOVELL . Oxff 1 ) ) ETHERNET SNAP (Use frame type field.) Destination Address i i I I i ι_ Source Address ι '. i . ι_ Frame engtn i i i DSAP IAAI 33AP lAAl Control Byte ι03l Vendor Code I 00100) 00 I Frame Type I 81137 I p_acb->ιpx framιng - PPP PXjrRAMEJITHERJiNAP.- novell akt - TRUE; if (novell_pkt) I /• Is IPXCP up? •/ if (p_lιnk->a cpctl 1 IPXCPJ-A.'ES] . cσstate —» CP OPEN) I • p_p O • PPP_IPXJ?ID; return i PPP GET PΪD SEND); 1 else ( / ♦ if we are using ONLY IPX, que tne packet, •/ /* otherwise we must drop .-. oecausβ we don't • / /• know wnicn CP this PX a ill eventually •/ /• go out 'IPXCP ignt get -*!gotιated away from •/ / • the peer) . • / if ( (p_acD->protoco.s i M ?PPJICPJ?ROTS) — ?PPJ?ROT_.PX) I / • we need to queue it until IPCP s up •/ • p_pιd - PPP IPX PID; returnI PPP GET PΪD QUEUE); else /• drop it • / returnI PPP GET PID NULL); / ♦ Check to see if it is an NBF Packet • / if (p acβ->protocols 4 PPP PROT_NBF) ! uθ ♦ p_sap; BOOL netbιos_pkt; netbιos_pkt - FALSE; p_βthhdr - <ETHERJtDRJTYPE • I (GET_DATAJ?TR(p_pk ) ) ; p~sap - (uβ • )(p_ethhdr * 1) ; ~ if ( » p_sap -- SNAP_NETBIOS) nβtβlos_pkt » TRUE; if (nβtbιos_pkt) ( /• Is NBFCP up? ♦ / if (p link->a_cpctl(NBFCPJ-AYERl .cpstatβ — • CP OPENI ( •p_pιd - PPP NBF PID; return(PPP GET PΪD SEND); I else ( /• if we are using ONLY NetBIOS, gue the packet, */ /• otherwise we must drop it because we don't •/ / • know wnich CP this NetB os pkt will eventually •/ / • go out (NBFCP might get negotiated away from •/ /• the peer) . •/ f ((p acβ->protocols - M PPP NCP PROTS) -- PPPJ?ROT NBF) ( / • we need to gueue it until NBFCP is up •/ *p_pιd • PPP_NBF PID; return(PPP GETJ?ΪDJ2UEUE) ; I else f / • drop it • / return(PPP GET PID NULL); /• Cheek to see if it is a BRIDGED Packet • / if (p acβ->ρrotocols 4 PPP PROT BR) I / • Is BRCP up? • / if (p lmk->a cpctllBRCP LAYERI .cpstate -- CP OPEN) • p pid - PPP BR PID; return(PPP GET PID SEND); 1 else ( / • if we are using ONLY BR, que tne packet, •/ / • otherwise we must drop it oecause we don't •/ /• know wnich CP tnis BR pkt will eventually ♦ / /• go out IBRCP might get negotiated away from •/ -43- / • the peer ) . • / i f ! l p aCD->protocc is . J?PP C? PROTS ) — PPPJ?ROTJ3R I I / " we need to queue i t -.nti i 3RCP is up • / • p_pid - PPPJ3RJ?:D; return ( PPP GET PI D QUEUE ) ; else / • drop it */ returni PPP GET PID NUL1 else ( /• No protocol specified, rop it return(PPP GET PID NULL); appp_ιnιtco - Initialize tne PPP control dock void - i (lpCall->appp); /• APPP CB p_aeb->ιpx_framιng - PPP_IPXJTRAMEJITHER_II; /* Return port to inited stage (this resets •/ /• ctl blk vars and kills outstanding timers). •/ appp_ιnι _all_layers( IpCall, CP_ NITIAL) ; ' • init the data control block associated with this PPP_cb •/ p_acD->tx_packets » ; ρ_acb->tx_Dytes « O; p_acβ->rx_ρackβts - 0; ρ_acβ->rx_βytβs » 0; p_acb->pppιd » 0; 1 * appp_clβanup_queuβs - Stop all links for this connection •/ void appp_cleanup_queuβs (PCALLINFO IpCall ! / • what remains is a stub.... eventually remove all calls to tnis func. I /* appp_inιt_all_layβrs — Initialize ail layers for the specified port. ' / ~ void a ( ppp init all layers!PCALLINFO IpCall, CP states t cpstate) appp_rβsβt(IpCall, LCPJ VYER. cpstate, TRUE); appp~reset( IpCall, PAP~LAYER, cpstate, TRUE); appp~rβse IIpCall, CHAPJIAYER, cpstate, TRUE); appp_res*t( IpCall, 9RCPJ-AYER, cpstate, TRUE); appp~reset( IpCall, IPCP-LAYER, opstate, TRUE); appp_resβt( IpCall, IPXCPJ-ftYER, cpstate, TRUE); appp~reset (IpCall, NBFC?~LAYER, opstate, TRUE); '• Even tnough we don't use tnis NCP at tne app side, in t it •/ /• to a down state. " appp_resβt( IpCall, CCPJ-AYER, cpstate, TRUE); /• appp_rβset — Reset tne configuration options for initial request • for tne specified port. •/ void appp_reset( PCALLINFO ioCall, PPP_layer_t layer, CP states t cpstate, BOOL reset emstate) I APPP_CB_t *p_acb » - i lpCall->appp) ; / » APPP CB •/ S_CPCTL~ "p_acp - *lpCall->appp.a_cpctl [layer1 ; p_acp->cpstate » cpstate; p~acp->ack_retry * 0; if (p_acp->tιmer_ιdl.active) / • K ll any existing CP timer •/ clr_appp_tιmer( IpCall, layer, PPPJTIMER1); if (p_acp->tιmer_ιd2.active) / • Kill any existing CP timer •> cTr_appp_tιmer( IpCall, layer, PPPJTIMER2); if lreset_emstate) /• initialize tne emulation states for each NCP •/ p_acD->a emstatesl layer) - EMJINITIAL; ) switcn (layer) 1 case LCPJ-AYER: / • Reset our config request params to our preferred values */ p_acb->nβg_mru - 1; / • always try to negotiate MRU •/ p_acb->tx_ac_comp » 0; p_acβ->txjDroto_comp ■ 0; p_aco->rx_ac_comp » TRUE; ρ~acβ->rxjproto_comp ■ TRUE; ρ_acβ->send_endpt » 0; / •• 0YN_CFG: We will fill this in as we learn it from Net ••/ p_acβ->auth_flaga - 0; p_aeo->autn_compl_flags - 0; / ♦♦ DYNJCFG: We will fill this in as we learn them from App ••/ ρ_acb->protocols ■ 0; p_acβ->remjnru - DEFJ-IRU; p_acβ->lcl_mru « DEF_MRU; p_acβ->send_endpt ■ FALSE; break; ease CHAPJJ-.YER : break! case PAPJ ^ AYER: break; case BRCPJJWER: break; case I PCPJ-AYER : / ♦ Set up for I P addr exchange • / p_acb->nβg_ιp_addrs « _ • p_acβ->p«βr_nβgotιatβd_ιp_addr » FALSE; break; case IPXCPJ-AYER: / • Set up for IPX network and node nu oer exchange; •/ p_«cb->nβg_ιpx_nβtwork • 1 ; p_acb->neg_ιpx_node » 0; p_acb->ρeer_negot ιated_ιpxnet_addr ■ FALSE; p acb->peβr_negotιateo_ pxnode_acdr » FALSE; / ♦♦ DYNJCFG: We will fiil tnis in as e learn tnem ••/ p_ac β ->my_ιpx_network » 0; p_acD->peer_ιpx_network - 0; memsβt (p_acD->my_ιpx_node, 0, S * "_I?X_NODENUM) ; memset lp_acD->peer_ιpx_nooe, C, 3:_I?XJ^ODENUM) ; orβak; case NBFCPJ ^ AYER: p_aco->neg_name_pro: • 1; p_acD->neg_peer_ιnfo » l; p_aco->peer_negotιated_r.oname « FALSE; ρ_aco->no_peer_name ( 0 | » 0; memset ι p_acD->nD_peer_clutter, 0 , SZ IBFJTLUTTER ) ; oreak; appp_restart — Reinitialize layer state machine for config exchange for the specified port. */ void appp_restart (PCALLINFO IpCall, PPP_layer_ layer) A?PPJCB_t 'p_acβ - *(lpCall->appp); /• APPP CB •/ 5JCPCTL *p_acp - 41pCali->appp.a_cpctl ( layβrl ; ' • Something went wrong; restart negotiations •/ switch (layer) I case LCPJ-AYER: / • Reset CP state machine for con iguration negotiation */ appp reset(IpCall, LCP LAYER, CP CLOSED, TRUE); appp reset!IpCall. BRCP LAYER, CP CLOSED. TRUE); appp_resβt(IpCall, IPCP~LAYER, CP~CLOSED, TRUE); appp reset I IpCall, IPXCP LAYER, CP CLOSED, TRUE); appp_rβset I IpCall. NBFCP~LAYER, CP~CLOSED. TRUE); / • Even thougn we don't use this NCP at the app side, mit it */ / • to a down state. • / appp_rβsβt( IpCall, CCP AYER. CPJCLOSED, TRUE); Break; case BRCP AYER: /• Reset CP state machine for configuration negotiation •/ appp_rβsβt(IpCall, BRCPJ-AYER. CPJ.LOSED. TRUE); break; case IPCPJAYER: /• Reset CP state machine for configuration negotiation */ appp_rβsβt( IpCall, IPCPJ-AYER, CP_CLOSED, TRUE); break; case IPXCPJAYER: /• Reset CP state machine for configuration negotiation •/ appp_rβββ IIpCall. IPXCPJ-AYER, CPJCLOSED, TRUE); break; case NBFCPJ-AYER: /• Reset CP state machine for configuration negotiation */ appp_rβββt( IpCall, NBFCPJ-AYER, CPJCLOSED, TRUE); break; 1 / • Unexpected APPP Connection Down, Restarting Connection. I /• appp_start — Initialize layer state machine for config excnange for tne specified port. ir.t appp_sta rt ( PCALLINFO IpCa l l , PPPJ ayer l ayer, CP_statβs_t cpstate ) \ ~ - - - APPP_CB_t *P_acb - 4 ( IpCall-tappp) ; / ♦ APPP CB • / PPP_CB_t 'p~ncp « 4(lpCai.->pppι ; / • NPPP CB • / SJΞPCTL 'p_acp » 4ipCall->apρp.a_cpctl [ layβrl ; switch (layer; case PAPJ-AYER: if (p aco->autn flags 4 AF_?A?_AU7HENTICAT0R) ( / ♦ Start timer against wait for reception of the PAP REQUEST "/ set appp timer ( ' PPP ^ RESTART TIMEOUT • PPP MAX CFG COUNTER;, " ipCall, 1-22) layer, PPPJTIMER2); - - - j ~ Dreak; default: if :p acp->cpstatβ ™ c? STOPPED) ( >* Stopped; wait until remote attempts connect •/ / • fall tnu to "return 0" • / I else ( f (layer -- LCP LAYER) ( '* set autn flags according to wnac Net requested. */ if (p_ncD->auth_flags) p~acb->auth flags • AF PAP AUTHENTICATOR; ! /• set new CP state • / p_acp->cpstate » CPJAEQ_SENT; / • state should • CLOSED, begin CP configuration negotiation •/ returni ppp sendreqtIpCall, layer)); I Dreak; I return 0; 1 /• appp_opβn — Transition to OPEN state. •/ void appp open(PCALLINFO IpCall, PPP layer t layer) I APPPjCBj: *P_«eb ■ twlpCall->apppι ; / ♦ APPP CB •/ PPP_CB_t 'p~ncβ • 4lpCall->ppp; /• NPPP CB •/ BRI AQAPTER -p~adaptβr; LinkJTB : 'p ink; cnac " ~ βufl β OI; p_adaptβr • gβt_adaptβr( (ulβ) lpCall->βoard_nun«oerl ; switch (layer) I case LCPJ-AYER: /* LCP is open; switch to next pnase, */ /• Startup CP negotiations • / / • If Authentication is required, start the appcopciate CP •/ if (p acb->auth flags 4 AF PAP AUTHENTICATOR) appp stacttlpCall, PAP~LAYER. CP CLOSED); else ( • 1) No sense checking whether or not to start the Net AUTH * since we would not be tnis fac if tne Net required AUTH out the App didn't. * 2) Launcn tne beginnings of (step 3), wnich will listen for • wnicn NCPs tne App wants to start (NCP CFG_REQ) . Hold tight until tr.er,. ••••/ p_aco->β_βmstates(BRCPJ-AYER • ^LISTENI G; p_aco->a_emstates(IPCP LAYER! - EMJ_ISTENING; p_acD->a_emstates(IPXCPJ-AYER| • EMJ.I3TΞNING; p_acD->a_emstates[*4BFCP2LAYE*?! « ΪM ' .STENING; p_aco->a_emstates(CCPJ-AYER' - £MJ_I5TENING; / • Now we ran start listening fir CCP •/ p ncd->protocols i » PPP PROT CCP; I Break; rase PAPJ-AYER: ' • APPP - Authentication Ccmplete. •/ /•••• • Before t*e NCPs can come up. Authentication needs to OPEN on tne Net side l if applicaole). ρ_lιnk - jβtPrimaryLmkl IpCall) ; if (p_ncp->autn_flags 4 AF_CHAPJ?EER) 1 nppp start (IpCall, p ink, CHAP LAYER. CP CLOSED); I else if (p_-ιcb->autn_flags 4 AFJ?APJ?EER) I nppp_start (IpCall, p_lιnk, PAPJJYER, CPJCLOSED) ; else I * This scenario snould not happen, but we must carry on.... Launch the beginnings of (step 3), wnich will listen for wnicn NCPs tne App wants to start (NCP CFGJ-iEQ) . Hold tight until tnβn. p_acb->a_βmstatβs(BRCPJAYER| - EM LISTENING; p~acb->a~emstatβs(IPCP~LAYERl - ErfLISTENING; p~aeβ->a~βmstatβs(IPXCPJ-AYER| • EM LISTENING; p~acβ->a~βmstatβs(NBFCP~LAYER| • EM~LISTENING; p acb->a~βmstatββ(CCPJ-AYERI - EMJ.ΪSTENING; / • Now we can start listening for CCP •/ p_ncD->protocols i » PPPJ?ROT :CP; I oreak; case ΘRCPJ-AYER: / ♦ APPP - Bridging Link UP. •/ • (Step 6 - UP) . • Now tnat tne App NCP is up, unload all tne data queues and go • into full service. p_acB->a_βmstatβs(layβrl - EMJ PPCPJOPEN; p_acb->ckt_statβ - PPPJSTATEJ4CPJJP; p_ncβ->ckt_state • PPPJSTATE ICP .?; /• try to bring up tne second .nannβi • / nppp_chβck_ow ( IpCall ) ; break; case IPCP LAYER: /• APPP - I? Link UP. */ /• set the learned IP address in the CallOata structure • / /• for reporting reasons. */ lpCall->IscCallData.ιpAddrβss » p_acb->peβr_ip_addr; /•••• • (Step 6 - up) . • NOW tnat tne App NCP is up, .niiad all the data queues and go • into full service. ••••/ p_acb->a_emstates I layer i • £HJ * K?PC?_OPEN; p_acβ->ckt_state - ?PPJ3TATE_MCPJJP; p~ncβ->Ckt_state » PPP STATE iCPJJP; /* try to bring up tne seccnc -"rannei • / ιppp_cnecι*._ow( ipC . ; c eak; case :?XCP LAYER: /' APP? - !?X Lir.k .?. • • ♦ (Step 6 - UP! . • Now that tne App NCP is up, unioao all the data queues and go ♦ into full service. .... / p_acβ->a_βmstatβs(layβrl - EMJ«.PPC?_OPEN; p_acb->ekt_statβ - PPPJSTATEJICPJ P; ρ~ncβ->ckt~state - PPP~STATE~NCP P; /* try to bring up tne second cnannel •/ *ιpρp_enβe»*_βw( ipCal ; ; break; zasu NBFCP JJ.YER: /• APPP - NetBEUI Link UP. • ' ♦ (Step 6 - UP). • Now that the App NCP is up, unload all the data queues and go * into full service. *•••/ p_acβ->a_βmstatβa[ layβrl - EM_APPCPJ3PCN; p aeβ->ckt_statβ - PPP STATEJtCPJJP; p *cβ->ekt~statβ - PPPjSTATEJtCPJJP; / • try to bring up tne second cnannβl */ nppp_cnβck_ow( IpCall ) ; oreaic; appp_closβ — Close the specified layers interface from the local side for tne specified port. •/ appp_cloββ(PCALLINrθ IpCall, PPP_layβr_t layer. CP states t cpstate, CP states t ui cpstate) 1 AfPf_CB_t *P_*cb - *(lpCall->appp); / • APPP CB S CPCTL- *P~*cp • *lpCall->appp.a cpctll layer] ; GCAFACKZT *PJ>kt; Int re ode • 0; /*> if Layer »- LCP LAYER, need to down upper layers */ if (lay-ar — LCP YER) appp_rβ«et l IpCall, BRCP LAYER. „i_cpstatβ, TRUE); appp^resetlIpCall, I?CP~LAYER, αi~cpstatβ. TRUE); appp~rβsβtl IpCall. IPXCSJLAYER, ul_cpstatβ, TRUE); appp^resetf IpCall. NBFCP~LAYER, ui~cpstate, TRUE); appp~rββet(lpCaii. CCPJ_AYER, ui_ pstatβ, TRUE); if (p_acp->cpstatβ •» CP_OPEN) ! / • APPP Connection Down. • / ) / • state - INITIAL, STARTING. CLOSED, STOPPED •/ if ιp_acp->cpstate <- C?_3T0PPING) / ♦ in a state wnicn doesn't aiiow TERM REQ to D β sent, •/ if (cpstate —• CPJ3T0PPING) appp_reset( IpCall, layer, C? STOPPED, TRUE); else appp_resβt( ipCall, layer, CPJTLOSED, TRUE); returnl-l); i /* as* remote nost to snutαown */ p_acp->cpstatβ • -restate; p_acp->acκ_retry • 0; if ιp_aco->tιmer_ιd .activβi c.r_appp_tι.*nβr; IpCall, layer, PPPJTIMER1); if (p_acp->t mβr_ d2.actιvβl lr_appp_tιmβr( IpCall, layer, PPPJTIMER2I; /* Set a timer against our request to shutdown •/ sβt_appp_t mβr(PPPJ<.ESTART_TIMEOUT, IpCall. !u32)layβr, PPPJTIMERi); /* Get packet for TERMINATE_REQ •/ if 1 ιp_pkt • ppp get pktll) •- NULL) { if (cpstate ~ CPJTTOPPING) appp_resβt I IpCall. layer, P_5TOPPED. TRUE); else appp_rβsβt( IpCall, layer, CPJCLOSED, TRUE); rβtcoαe « -1; I else 1 if (appp sendreplytIpCall, layer, p_pkt, TERMINATE REQ. 0) '- 0) ( if (cpstate •»- CPJ3TOPPING) appp resetlIpCall, layer, CP STOPPED, TRUE); else appp_rβsβtIIpCall, layer, CPJCLOSED. TRUE); rβtcode - -1; I I return i etcooβi ; appp_senoreg — Build and send CFGJΛEQ packet. int appp sβndrβq(PCALLINFO IpCall, PPP layer t layer) I Aj?PP_Cl_t *P_»cb - * ( lpCall->apppl ; / • APPP CB S CPCT - *P~*βp • « lpCall->appp. a cpctU layer ) ; GCAPACKtT *P_j*t; uβ *p_cfgopts; / ♦ Get packet for configuration request •/ if (lp_pkt » ppp_gβt_pktI ) ) — NULL) return! -1 ) ; p_cfgopts - (luβ -)GETJ3ATAJ?TR(p_pkt) ) ♦ PPPJ-IDRLEN * CNfJ-IORLEN; /* load config params ir.t. buf (return size of options */ /• field) PPP_HDRLEN and CNFJDRLEN will ββ added to • / / • data_lβngtή as it as it gets closer to being snipped. • / p_pkt->uLβngtn > appp_makerβqιIpCall, layer, p_cfgopts); /• Start timec against wait for reply to ouc config request */ set_appp_timer(PPP_RESTART_TIMEOUT. ipCall, (u32) layer. PPPJTIMERI); /• Send CP configuration request to remote host */ rβturnιappp_3βn<3rβply : IpCall, layer, p_pkt. CONFTG REQ, 0)i; I /• • appp_maιtβrβq -- Do actual ouiia of "GJ-tEQ options field. •/ ~ , int app nakereql PCALLINFO IpCall, P?P_layer_t layer, uβ •p_opt_ouf) p_adapter • get_adapter( (ulβ) ipCali->Doard_number) ; switch (layer) ( case LCP -AYER: /* Maximum Receive Unit */ i (p_acD->neg_mruι • cp«-> - MAX_RCV_UNIT; *ep*- • 4; • cp»-> • p_aco->lcl_mru >> 9; *cp*>-> • p_acb->lcl_mru Oκff; Opt Cnt »« 4; I /• AC Compression •/ if (p aco->rx ae comp) I ~ *ep->-> - ACJCCMPRESS; *cp** • 2; opt cnt *- 2; ) /* Protocol Compression */ if (p_acβ->rx_proto_eomp) i *cp*4. ■ PROTJCCMPRESS; *cp->- « 2; opt_cnt 4.- 2: /' This is our mecnan s for getting tne App to give us his */ / • usernane, password for NET PAP or CHAP. This will only •/ /* get turned off if the App REJECTED our initial request -/ /* for it (indicating tnat ne nas no usernane,passwor ) . */ if (p acb->autn flags 4 AF PAP AUTHENTICATOR) I " *cp*>* - AUTn nrPE; •cp«"> • «• *ep*-> - PPP PAP PID » 9; • Cpt-> - PPP~PAP~PID 4 Oxff; opt cnt ♦■ «; 1 break; case BRCP LAYER: /* MAC Type •/ • cp** - BR_MAC_TYPE; - • cp->* " 3;~ • cp-- - BRD_MACJ3023; opt_cnt *a 3; break; case IPCPJ-AYER: /* Try to snare IP_addr info with Peer ?? • / if (p_acb->neg_ιp_addrs 44 p_ace->peer_negotiated_ip_addr 44 p_ncD->pβer_nβgotιated_ιp_aααr ) i • cp— > - :?J3 > ODRSJιEW; • cp"- • β; '• nave ; 3 30 -n s in mars or else fields get */ /• overwritten wnβn tney ali n * / "cp»- - i _acD->my_;p_aααr >> 34); • = p»« • ιp_acD->my_ιp_addr >> 16); • cp--> - :p_aco->my_ιp_addr >> 8); ' p** - p_aco->my_ιp_aβdr; opt cnt •»« 6; 1 break; case Nβt_addr info with Peer ?? */ rk 44 p_acβ->peβr_nβgotlatβo_ιpxnβt_addr 44 ed ipxnet addr) ' • nave to ao tnis in chars or else fields get */ / • overwritten wnβn tney align •/ • cp»* • (p_acβ->my_ιpx_nβtwork >> 24); - C p«. . ιp_acD->my_ιpx_nβtwork >> 161; • cp-*— - (p_acβ->my_ιpx_nβtwork >> 8); *cp-- - p_acβ->my_ιpx_nβt*tJork; opt cnt •>■ 6; I / • Try to snare Net IPXjodβ_addr info with Peer ?? • / if (p_acβ->nβg_ιpx_nodβ 44 p_aco->peβr_nβgotiatβd_lpxnodβ_addr 44 p ncβ->peer negotiated lpxnode addr) I mβmcpyMuβ *icp, p_aco->my_ιpx_nodβ, S2 _I PXJTOOENUM ) ; opt cnt •■ β; 1 break; case NBFCP J-AYER: if (p acb->neg name_proj ) ( * project 0 NetBios names to remote peer */ ♦ cp-4* - NBP_NAMEJ?ROJ; • cp*- » 2; opt cnt *■ 2; 1 /* Try to snare Net NBF Name info with Peer ?? -I if (p acD->nβg_peβr info 44 p nes->peer negotιated_nbnane) I •ep*>* - NBrj?EER_INfO; p_lβn • cp; / • rβmβmeβr wnere the lengtn is */ • ep*>* « β; mββepylcp, p ncβ->nb_peβr clutter. SZ NBF CLUTTER); cp ♦- SZJ*.BF~CLUTTER; opt_cnt ♦« θ; nD_nam _l en » strlen(p_n e->ne_peer_naeie) ; if mβ name len) string and include in count • / oreak; returntoot cnt); appp_sβndpaprβsp — Build and send PAP AUTH -.CK/NAK packet. '/ appp_sendpapresp( PCALLINFO IpCall, ud coαe. uθ id) APPP CB_t • D_aco » 4 ( lpCal.->appp) ; /• APPP CB GCAPACKET 'pZ K ; JS -p_rfgopts; /• Get packet for PAP AUTHJ-.CK/NAK • / if i(p_pxt • ppp_get_pkt , , i ■ • » NULL) returnl-l i ; p_cfgopts - l (uθ • )GETJJATAJJTR(p_pkt) ) ♦ PPPJ4DRLEN * CNFJiDRLEN; /* Indicate tnat there is no message to oe sent back. */ •p_cfgopts»-» • 0; /* The msg len iset to 0) needs to oe reflected in tne pkt s ze •/ ρ_pκt->uLβngth « 1; /• Send PAP AUTH WTK/ NAK to autnβnticator ♦ / rβturn(appp_sβndrβplyllpCall, PAPJAYER, p_ρkt. code, id)); appp_sendreply — Send a PPP Control packet to the peer » / int appp_sendreply( PCALLINFO IpCall. PPP_layβr_t layer, GCAPACKET *p_pkt, u8 code, uβ id! ( APPP_CB_t *P_acb - 4(lpCall->apppι; /• APPP CB S CPCΓL" • p_acp ■ 41pCali->appp.a cpctl [ layer 1 ; 3JCNFHDR • p rnfhdr; u32 'pjnagicnum; u32 pid; p_cnfhdr - (SJCNFHOR "l IKuβ • ) GET J3ATA J?TR ( p_pkt ) I * PPPJ-IORLEN) ; pjnagicnum - 7u32 « Η((u8 *ιp_cnfhdrι -~CNF_HDRLE I ; /* Load CP header values */ p_cnfhdr->code « code; switch(code) I case COHΠG REQ: /* AXA: CHAP CHALLENGE 4 PAP REQUEST •/ case TEIIMNATEJΛEQ. /• Save 0 field for match against replies from renote nost •/ p_acp->lastιd • p_aeβ->pppid; p~cn£hdr->id • ρ_aco->pppid**; break; case ECHO REQ: if (layer '- LCPJ-AYER) goto rβply_dβfault; / * Save ID field for .match against replies from remote host */ p_aep->lastιd • ρ_aco->pppιd; p_cnfhdr->id ■ p_aco->pppια»«>; •p_magιcnum • 0; /• no need to swap32(0) */; p_pkt->uLβngth «•- sizβof (u32) ; / * add magicnua to pktlen */ break; case PROTO REJ: f (layer '• LCPJ^YER) goto reply_default; p_enfhdr->ιd » p_ac β ->pppιd»*»; oreak; case 0ISCAR0_REQ: p_cnfhdr->ιa « p aco->pppιa»-; orβak; case CONFIG ACK: / • AKA CHAP_RES?ONSE i ?A?_AC ♦ / case CONFIG~NAK: " AKA -Λ?_S ' "ZS3 i ?A?_NAK • / case CONFIG~REJ: " AKA 'riAf FAIL- E ' ' case TERMINATE ACK: case CODE_REJ:~ p_cnfhdr->ιd - id; oreak; rase ECHO REPLΪ: if (layer ' - LCP -AYER" goto rβpl _ae auit; p_cnfhdr->ια ■ 13; *p_-nagιcnum ■ ); > • -- se-3 ;: swap32 (01 */ ; p_pkt->uLβngtr*. •» sizeof;»J2 ' • aαa magicnu to pitlen • ' orβak; default: repiy_αβfault: ' • Shouldn't happen ■ / ppp_rls_pκt ιp_pκt, . ' 2 ) : return(-1 ) ; protocol V ppp_rls_pk tp_pkt, 14); rβturnl-1) ; j ' • framβsizβ ■ length of options field */ p_cnfhdr->lβn » swaplβl (ul6) !CNF_HDRLEN • p_pkt->uLβngth) ) ; /* update buffer Frame Size itotal bytes in pkt) */ p_pkt->uLβngtn ♦» CNFJ-IORLEN: ' • Adjust the packet sffsets so -.nit tney are aligned witn •/ /* all the other metnods of jetting a packet to appp_sβnd_pkt . '* Specif cally, set tne app αata ptr to start of CNFHDR • >/ PUT DATA OFF(p_pkt, (GET DATA OFFΪp Okt)»PPP HDRLENI); returnIappp_send_pkt 1 IpCall, p_ρkt. (ulβipidl) -.ppp_senαt*rmacι- -- ie'O a TΞRMI'-ATϊ * -.-. tne peer void appp_sβndtermack( PCALLINFO IpCall, P?P_.ayer_t .ayer. CP_states_t cpstate I -V?PPjT3_t 'p_acD - 4< loCall->appp) ; /• APPP C3 -ι S CPCTL- 't3_acp » 41pCall->appp.a_cpctl(layβr| ; G APACKET -p_tx_pkt; /* Get packet for terminate ack • / if ((p_tx_pkt - ppp get_pktll) ' - NULL) ( /- try to send out TERMINATE CK pkt " appp sendreply! IpCall, .ayer, p_tx_pκt, TERMINATE ACK, ;,. I ρ_acp->cpstate » cpstate; return; ppp_sβndcodβre-| — Send a CODE REJECT to tne peer -/ void appp_sendcodere 3 (PCALLINFO IpCall, PPP_layβr_t layer, GCAPACKET *p pkt, CP states t cpstate) ( APPP_CB_t *P_»Cβ 4 ( IpCall->appp) ; /• APPP CB •/ S_CPCTL~ *P_acp • 4lpCall->βppp.a_cpctl[layβr|; S~PPPHDR • p_pppndr; GCAPACKET -e_CR_pkt; uβ "p_from; uθ -p~to; u32 ι;~ s32 numoytes; p_pppndr - (SJ?PPHDR * ) ( GET J3ATA JTTR I p_pk ) ) ; /* Get packet for code reject */ if ((p_CR_pkt - ppp_gβt_pk 1 ) ) '- NULL) i ~ / ♦ need to copy info field from RX pkt into PROTOJEJ pkt */ /• make sure it doesn't exceed max negotiated lengtn •/ p_from - (((uβ *lp_pppndr) ♦ PPPJiORLENl; p~to - (((uβ 'IGET DATA PTRI CR pktli ♦ PPPJ-IDRLEN ♦ CN IORLEN); .f (p_pkt->uLength < p_acβ--»rem_mruι numoytes • p ρr.t->uLβh5*:r; else numbytes • p_acb->rβm_mru; /* insert rβ 3 βctβd-protocol after CNFJ40R •/ * > p_to*-> • p_pppndr->p d >> 8; •p~to-* • p_ρpprtdr->ρid 4 Oxff; ρ_CR_pkt->uLβngtn ♦• 2; /• copy info field ♦ / for (i •» 0; l < numoytes; ι*>*) •p_to->*> - 'p rom; pJCR_pkt->uLengtn ♦• numoytes; appp sendreply', IpCall, layer, p CR pkt, CODE REJ, 0); I ~ p_acp->cpstatβ • cpstate; return; • appp_tιmβout — Timeout while waiting for reply from peer. •/ ~ void appp_tιmeout( PCALLINFO IpCall, PPP_layer . .ayer, .22 timer ιαxl APPPjC8_t -D_aco » . : oC-l.->apppι ; / ♦ APPP CS •/ 5JCPCTL 'p_aco ■ 41pCaι.->appp.a_rpcti J ayer! ; 3CAPACKET * p_tx_pκt; / • Attempt to get things going again •/ switch ιp_acp->cpstatβ) case CP INITIAL: > ' Unexpected event • / case CP~STARTING: case CP~CLOSED: case CP~STOPPE0: case CPJOPEN: oreak; case CPJCLOSING: / • Timeout waiting for terminate ACK; send another request •/ if C»p_acp->ack_rβtry > PPP MAX TERM COUNTER) ( / • No response to our request; give it up •/ appp resetI IpCall, layer, CP CLOSED, TRUE); 1 else I / • Request remote host to close data link •/ set appp_tιmβrιPPP RESTART TIMEOUT, IpCall. (u32) layer, PPPJTIMER1); / • Get packet for Terminate Request */ if (Ip tx_pkt » ppp gβt_pkt<)> •- NULL) appp_reset(lpCaIl. layer. CPJCLOSED, TRUE); else i / • try to send out anotner TERMINATEJIEQ pkt • / appp sendreply! IpCall, layer, p tx_pkt, TERMINATE_REQ, 01; i ! break; casø CPJ3TOPPING: / • Timeout waiting for terminate ACK; send anotner request • / if (->->p acp->ack retry > PPP MAX TERM COUNTER) 1 /• No response to our request; give it up */ appp resetIIpCall. layer, CP STOPPED, TRUE); 1 else ( /• Request remote host to stop data link */ set appp timerI PPP RESTART TIMEOUT, " ipCall. (u32) layer. PPPJTIMERl); / • Get packet for Terminate Request */ f lip tx pkt - ppp gβt_pkt(! ) -« NULL) appp reset(IpCall. layer, CP STOPPED, TRUE); else I / • try to send out anotner TERMINATEJIEQ pkt • / appp sendreply!IpCall, layer, p tx_pict, TERMINATE REQ. 3); ) ! oreak; case CP REQ SENT: case CP ACK RCVD: zaf CP ».CK~SENT: / • Timeout waiting for ACK to :.r request, • / /• :r timeout waiting f:r request trim remote host • / i f 1 *- > p_acp->ack_re- ry > PPP_ M AX_CrύjrθUNTER ) i — ~ / • Connection EstaDlisn Timeout, PPP Connection αown. •' /• terminate connection •/ em_ppp_reiease_conn( IpCall) ; else /* Try to get things going by sending new request •/ appp_sendreq(lpCali, layer); if !p_acp->epstatβ !- CPJVCK SENT) p~acp->cpstatβ • CPjTEQjTεNT; oreak; aefauit: / • ignore oreak; return; I appp_autn_t meout -- Timeout while waiting for Authentication. '/ appp_autn_tιmβout( PCALLINFO IpCall, PPP_layβr_t layer, u32 tlmβr_ιdx) i APPP_C3_t -p_acβ - * (IpCall->appp); / • APPP CB 3_CPCTL~ *P_acp « 41pCall->appp.a_cpctl(layerI ; /• Attempt to get things going aqain • / if (layer — PΛPJAΪER) ; ~ /• if Autn Request timer nas gone off blow off the connection •/ if (timer idx — PPP TIMER2) ( / • Peer has not requested Auth, PPP Connection down. •/ /• terminate connection •/ em_ppp_relβasβ_conn(IpCall) ; appp_proc -- Process the incoming CP packet •/ void appp_proc ( PCALLINFO IpCall. PPP layer t layer. GCAPACKET *p_pkt l I APPP CB t *p ace - « llpCall->appp) ; /* APPP CS • / S_CNFHDΪ 'p^cnfhdr; GCAPACKET • p~tx_pkt; p_cnfhdr - ( SJTNFHDR * ) ( ( ( u8 • ) GET JOATA J?T ( p_pkt 1 I ♦ PPP_HDRLEN ) ; ' • Process CP packet data * / swi ten i p cnf hdr->code ι I case CO FIGJ-tEQ: ι * Request of remote host *■ / appp_rcvreq( IpCall, layer, p_pkt); break; case CONFIGJ^CX: / • Remote accepted our req, */ appp_rcvack(IpCall, layer, p_pktj; break; case CONFIGJtAK: /• Remote ad-justed our req •/ appp_rcvnak( IpCall, layer, p_pktι; break; case CONFIGJ«XJ : / • Remote rβ-j ectβd our req • / appp_rcvre-* ( IpCall, -ayer, p_pκti ; Dreaic; cas β ' • τemote request to close " appp_rcvtermrβq( IpCall. layer); oreak; case TERMINATE ^C : / * Remote closed on request •/ appp_rcvtermack( IpCail, layer;; oreak; case CODE_R£J: appp_rcvcoαere-| ( IpCall, layer, p_pkt); oreax; case PROTCJ-tE : 3ppp_rcvprotcre IpCa .. .ayer, p_pκt); breax; case ECHO REQ: if (layer -- LCP JWER) i ' * Get oacxβt for configuration request *-7 if ! :p_tx_pκt - ppp_gβt_pκt ( ) ) '« NULL) I ' • try to send out ECHO_REPLY pkt •/ appp_s β ndrβply ( IpCall, LCPJJWER. p_tx_pkt, ECHO_REPLY, p cnfhdr->ιd); ~ ~ ) I break; case ECHOJ^EPLY: breax; RFC. Simply crop this pkt •/ oreak; default: appp_rcvunknown( IpCall, layer, p_pkt); brβak; i ppρ_rls_pk (p_pκt, 15); return; ( /• apρp_pap_proc — Process the incoming PAP packet •/ void *p_pkt) APPP CB •/ I ; p_cnfhdr - (SJ-WfΗDR • )K(uβ • )GETJ3ATAJ?TR(p_pkt) ) * PPPJ4DRLEN); p~cfgopta » (~(uβ • )p_enfhdπ ♦ CNFjiORLEN); / • Process PAP packet data '/ switchlp cnfhdr->code) ( case PAP REQUEST : /* Request Message */ if ip acβ->auth flags t AF PAP AUTHENTICATO I I /* Stop timer against wa t for valid PAP REQ • / if (p_acp->tιmer_ιd2.activeI clr_appp_tιmerI IpCall. layer. PPPJTIMER2); / ♦ get length of APP usernane • / len a t ,p_cfgopts*>*>; /• is the usβrnamβ too long 1 ' I if (len > (MAXSLUSERNAMESIIE-l) ) goto pap_proc_txnak,* / • * »• Nao tne App ϋsername ••• • for 11 « 0; i < .en; ι--> lpCall->IscCaj.i3ata. username, l , « -p^fgopts**; lpCali->IscCaliData.usernameι i ! » 0; /• get lengtn of APP oassvora • ' len » • p_cfgopts** > : /• is tne passwora too long ? • if den > (MAXSLPASSWDSI2E-1) ) oap_proc_txnaκ: ' • APPP Auth railed, PAP Mismatcn. PPP Connection αown. appp_senopaprβsp( IpCall, PAP_NAK, ρ_cnfhdr->ιd) ; /• terminate connection •/ em_ppp_relβasβ_conn( ipCall I ; break; /••• Nab tne App 'Jserna β • > • */ for (i - 0; i < len; i•> • * ■ ) lpCall->IscCallData.password! il » ♦ p_efgopts»»: lpCall->IscCallData.password! il • 3; p_acβ->auth_compl_flags i- AFJ?APJUTH_APPROVED; appp_sβndpaprβsp(IpCall, PAPJ\CK, p_cnfhdr->ιd) ; /• are we all the way up ? *"/ if i acβ->auth flags •- p acβ->autn coapl flags) I p_aeβ->auth_flags l - AF_COMPLETED; p_acβ->auth_compi_flagβ ι» AFJCOMPLETEO; p_acp->cpstatβ ■ CPJ3PEN; /* all authentication complete • / appp ooenIIpCall. layer) ; ) I Break; aefault: /* Bogus pkt. ignore it. */ break; I ppp_rls_pkt ιp_pkt, I'M; return; 1 /• appp_rcvreq — Process tne received CFGJΛEQ from tne peer. •/ void appp rcvreqlPCALLINFO IpCall, PPP layer t layer, GCAPACKET *p_pkt) { APPPjCB : *P_*Cβ - 4 ( lpCall->appp l ; / • APPP CB • / SJCPCTL *P_*cp " * lpCal l->aρpp. a_cpctl ( layer l ; LΪnkJCBj- 'p ink ; switch ( _acp->cpstate i case CP INITIAL: " Unexpected event • / i f T l layer • ■ CCP LAYER ) 4 i p acD->a βmstatβa l layer I « EM LISTENING ) ) I * ( Step <J ) . * For tne NCPs, we are awaiting tne CFGJ- Q from the App side * to fire up tne Net siaβ. Mane sure tne Net side supports ■ - this NCP oefore responding ;- ne App. appp_learnfromreq! IpCail. -ayer, p_p t:; p_acβ->»_emstates, .ayer: - EM_ ETC?_3TARTED; p_lmk - GβtPrimaryLinki IpCail) ; r.ppp start l IpCail, p link, .ayer, C? CLOSED); ) break; case CPJ3TARTING: /• unexpected event •/ oreax; case CPJCLOSED: appp_sβndtermack 1 IpCall, layer, CPJCLOSED); oreak; case CPJ3TOPPED: / * Send our configuration request • / appp_sandreq( IpCail. layer) ; /* Evaluate configuration request from remote host * ' appp_chkreq( IpCall, layer, p_pκt, CP_ACKJSENT, CP_REQJSENT) ; orβak; ~ ~ case CPJCLOSING: /• We are attempting to close connection; wait */ /* for timeout to reseno a Terminate Request •/ orβak; case CPJ3TOPPING: /• We are attempting to stop connection; wait */ ' • for timeout to resend a Terminate Request •/ oreak; case CP REQ SENT: case CP~ACK~SENT: /* Evaluate configuration request from remote host */ appp_Chkrβq( IpCall. layer. p_pkt, CP_ACK_SENT. CP_REQ_SENT) ; break; case CPJ«:κ_RCVu: /" Stop timer aqainst wait for config request */ if ip_aep->cιtiMr_idl.active) clr_appp_tιmβr<IpCall. layer. PPP riMERl); /* Evaluate con iguration request from remote host • / appp_chkrβq< IpCall. layer, ρ_pkt, CPJ3PEN, CP_ACK_RCVD) ; break; zasø CP_OPEN: /* Unexpected event • ' '• Something went wrong; restart negotiations */ appp_restart I IpCall, layer) ; /* Send our configuration request • / appp_sendreql IpCall, layer) ; /* Evaluate con iguration request fro* remote host • / appp_cnkreq(IpCail. layer. p_pkt. CP_ACXJSENT, CP_REQJ3ENT) ; break; default: /• ignore */ break; I return; i /• appp_chkreq — Cheek link control options requested by the peer. •/ appp_chkrβq< PCALLINFO IpCall, PPP_iayβr_t layer. GCAPACKET "p_pkt. ulβ ack_cpstate, lβ nak_ pstatβ) APPPjCBj; *p_aco - 4 ( lpCaii->apppι ; /• APPP CB •/ 3JCPCTL- "P~.acp » iipCai ->appp.a_tpcti I layer 1 ; 3JCNFHDR -p~cnfhdr; SJ3PTHDR *p~optndr; uβ *p optdata; GCAPACKET • p~ACK_pkt; uβ "p~ACKj5uf; slβ i, lien; sl6 alloptslβn; sl6 cptdatalen; sβ 3pt_accept; /• Per option reply •/ sβ cnf_accβpt • CONFIGJ-iCK; / • Overall reply to req •/ slβ minoptlen; p_cnfhdr - (SJCNFHDR * *)(((uθ ♦ )GETJ3ATAJ?TR(p_pkt) I * PPPJiDRLEN) ; p~optnor • (SJ3PTHDR *)((luβ ")p_cnfhαrT ♦ CNF_HDRLEN); /• Get CF5_ACK packet */ if (lp_ACK~_pkt - ppp_gβt_pkt ( ) ) — NULL) return; /* Set ptr to CFG ACK buffers option field • / p_ACK_βuf - ((uβ • )GET_DATAJ?TRtp_ACK_pkt) ) ♦ PPPJ-IDRLEN ♦ CNF_HDRLEN; /•* Make sure length in CP config header is realistic if ιp_pκt->uLβngtn < ! DWORD) swaplβ ( p_cnfhdr->lβn ) ) ρ_cnfhdr->lβn • swaplβ ( (ulβ) p_pkt->uLβngtn > ; alloptslβn - swaplβ(p_cnfhdr->lβn) - CNFJHORLEN; if (layer ~» CCP -AYE I minoptlen • 5; else if (layer -- IPCFJJWER) minoptlen a 4; else minoptlen » 2; I- Process options requested by reeiote host V for (; alloptslβn >• minoptlen; alloptslβn —» p_opthdr->lβn, p optndr - (S OPTHDR ")((uβ *)p opthdr ♦ p optήdr->len) I I optdatalen « ρ_optndr->len - 2; /• Get curr opts data len */ /* Set ptr to option data */ p_optdata • l (uβ -)p_opthdr) ♦ 2; opt_a:=ept - CONFIGJVCK; /** Assume will accept option •/ if (layer ~ LCP LAYER) I ulβ 116; switenip opthdr->type) I case MAX_RCVJJNIT: /• Max Receive Unit is a lβbit field • / lien - 2; if (optdatalen < lien) ( /** Short option data; reject packet */ opt_accβpt • CONFIGJΛEJ; break; I /* Get proposed value from packet */ ιl6 - Cp_optd«ta « β) i • lp_optdata*>l ) ; / • Check if new value is appropriate */ if (llβ < MIN MRU) I /* Too small, ask for minimum instead */ opt_aceept « CONFIGJ4AK; *p όptoata • MINJ-iRU >> 8; •ιρ optaata » * ,, " - MIN_MRU t Oxff; llβ~" MIN MRU; else i '* Value is acreo ao.e */ :pt accept • ror.3 ACK; p_acD->rem_*nru » :1a; oreak; :ase ASYNC_ T * ._MAP: ' • Async Control Map •' /• Async centre, map is a 3ϋbιt field •/ if loptdatalen < leni '* Short option data; reject packet */ opt_accept ■ CONFIG_REJ; orβak; /* OTHERWISE, BLINDLY ACCEPT BECAUSE WE WILL NOT • / ' • OO ANY MAPPING, BUT WE NEED TO ack THEIR OPTION •/ / • REQUEST • / opt_aceβpt • CONFIG_ACK; break; rase AUTH_TYPE: /* Get proposed value from packet */ ιl6 - (*p_optoata << 8) I * (p_optdata*l) ; / • Cheek to see if CHAP or PAP is requested •/ if (116 -- PPP CHAP PID) / • blindly smack mta down, we w ll not be an Auth Peer */ opt accept • CONFIG REJ; I else if (116 -- PPP PAP PID) /* blindly smack mm down, we w ll not be an Auth Peer */ opt accept • CONFIG REJ; 1 else I /•-- THIS OPTION IS NOT NEGOTIABLE. REJECT —•/ opt accept ■ CONFIG REJ; I oreak; case MAGIC_NUMBER: > ♦ Haqic Number • / /* Magic Numeer is a 32bit field */ if loptdatalen < ileni t / • Short option data; reject packet • / opt_accβpt • CONFIG_REJ; oreak; I /• OTHERWISE, BLΣNOLY ACCEPT BECAUSE WE WILL NOT • / /• OO ANY MAPPING, BUT WE NEED TO ack THEIR OPTION • / / • REQUEST ♦ / opt_accβpt - CO FIG_ACK; break; case PROT -CMPRESS: /• snould oe 0 opt data bytes left */ ilen - optdataien; if (ileni I -jpt_accβpt • ONFI5_REJ; } else I p ace->tx_proti_comp ■ -RUE; opt_accβpt - CONΓ:G_ACK; i break; case AC_CCHPRESS: ' * snoulα βe 0 apt cata oytes left • / lien - ptdatalen; : i ilieni I opt accept » CONFIG REJ; I else 1 p_aco->tx_ae_comp « TRUE; spt accept • CONFIG ACK; I break; case FCS 32: /* 32-bit FCS not implemented •/ /... τHI g OPTION IS NOT NEGOTIABLE, REJECT •••/ pt_accβpt - CONFIG_REJ; Dreak; casβ MPP MRRU: / • MPP MRRU ♦ / lien-- 2; spt_accβpt • CONFIG_REJ; break; case MPP_SHORTSEONUM: / * MPP Short Sequence Numbers •/ / •• • THIS OPTION IS NOT NEGOTIABLE, REJECT •••/ opt_aceβpt « CONFIG_REJ; break; case PP_ENOPOINT_IO: / • MPP Endpoint ID •/ ' • " •♦" since β~don't support MPP, rβfβct it •"•"• ilen ■ optdatalen; opt_accept » CO FIG_REJ; oreak; default: /• Unknown option • / opt_accept - CO riG_REJ; /* protect from βoqus packet or buffer overrun */ if I (p opthdr->lβn <- 01 i t (allopcslen < p opthdr->lβn) ) 1 p_opthdr->lβn » alloptslβn; ilen - alloptslen-2; 1 else ( ilen » optdatalen; ) break; I I else if (layer — IPCP LAYER) ( u32 rβqpββr_ιp; switcn tp optndr->type ) I case IP_A00ftS_NCM: /• IP address •/ / ♦ IP Addr is a 32bιt field •/ ilen ■ 4; if (optdatalen < ileni I / • Short option data; re ect packet ♦ / opt_accept • C0NFIG_REJ; break; I / • Get proposed value fro-a packet *» / rβqpββr_ιp ■ reqptaβr~ιp - « 8) I *Mp_optdata * 1) rβqpββr~ιp « « 8) I p_optd«ta ♦ 2) rβqp«βr~ip • ( rβqpeer^ip « β) I *(p_optdata ♦ 3) / ♦ If the App side is requesting an IP Addr and the Net */ /* side qave us one, relay it back to tne App. •/ if (reqpeer ip '- p acβ->pββr ip addr) I opt_acceot » CONFIG_NAX; • p_sptaata - ;p_aco->peβr_ιp_addr >> 24); "'p_optαata - 1, ■ p_acβ->pββr_ p_aadr >> 16ι; * :p_optdata • Z . • iD_acβ->peβr_.p_addr >> 8 ) ; "p_ ptoata - 31 - ; o_aco->peer_.p addr • Oxffi, '- Siir.dly accept oecause tne Net side didn't " / • engage i.-. :? Aaαr .negotiation (for whatever reason). •/ pt_accep » TONF:3_ACK; break; case IP COMPR TϊPE: / ♦ IP neader compression •/ /* • * THIS~OPTION IS NOT NEGOTIABLE, REJECT •• •/ lien » 2; opt_accβpt • CONFIG_REJ; break; default: /* Unknown option •/ opt_accβpt - CONFIG_REJ; '* protect from bogus packet or buffer overrun •/ if ι ;p_optπαr->ien <• 0, lalloptsiβn < p_opthdr->lβn) ) i ~ — p_-3pthαr->L-!- - ιll;ptslβn; ilen • a..optsiβn-2; else i ilβn - optdatalen; I break; ) ) else if (layer — IPXCP_LAYER) ! - u32 reqpeer ipxnet; u8 rβqpββr~ιpxnooβ(52_.?X_NO0ENUM| ; switch(p optndr->typeι ( case IPX_NET_NUM: /• IPX Network Number • / /• IPX Network Addr is a 32bιt field • / f (optdatalen < ilen) I / •» Short option data; rβ-jβct packet V opt_accept - C0NFIG_REJ; break; /* Get proposed value from packet • / • *p_oρtaata; » ι rβqpββr_ιpxnβt << 8) l * p_optdata • 1); reqpeer_ιpxnet • ( rβqpββr_ pxnβt << β) l *ιp_optdata * 2); reqpeer_ipxnet » ι rβqpββr_:pxnet << 8) l *(p_pptdata ♦ 3 ); /• If the App side is requesting an IPX Net Addr and the Net */ /*> side gave us one, relay it oack to the App. */ if (reqpeer ipxnet ' ■ p acβ->peer ipx network) ( opt_accβpt - CONFIG_NAK; **p_optdata » ιp_acβ->pββr_ιpx_nβtwβrk >> 24); •lp_optdata ♦ iT • (p_aeβ->p«βr_ιpx_nβt*t4ork >> lβ); •lp~optdata * 2) » (p~aeβ->pββr_ipx_nβtwβrk >> 81; •fp^optdata ♦ 3) ■ (p_acβ->peβr_ιpx_nβtwork * Oxff); else I f alindly accept because tne Net side didn't • / ' * engage :.-. '. ? Aβar negotiation (for wnatever reasoni , rpt_ac βpt • CONF.3_ACX; break; casβ IPX_NODE_NUM: " IPX Node Number •/ /• IPX Node Addr is a MAC Address •/ ilen • SZ_I?X_NODENUM; if :optdataιen < i.eni I / • Short oot icn aata; rej ect pacicβt * / opt_accept - CONFIG_REJ; sreax; /* Get proposed value from packet • / maccpyi reqpβer_ιpxnodβ, p_optdata) ; ι * If the App side is requesting an IPX Node Addr and tne •/ / • Net side gave us one, relay it oaex to tne App. •' if ( !maccmp( rβqpββr_ιpxnoaβ, (u8 *)p_acβ->pββr_ px_nooeι .• i opt_accβpt • CONFIG_NAK; macepylp optdata, p acβ->peer ipx node); I else I /* • Blindly accept because the Net side didn't *' /' engage in I? Addr negotiation (for wnatever reason). •/ opt accept « CONFIG ACK; I break.* case IPX_CFG_COMPLETE: / • IPX Configuration Complete •/ ιlβn~- optdatalen; / • BLINDLY ACCEPT BECAUSE WE WILL NOT DO ANYTHING V /* WITH THIS AT THIS TIME • / opt_accβpt • CONFIG_ACKj break; default: / • Unknown option */ opt_accapt - CONFIG_REJ; /* protect from bogus packet or buffer overrun */ if I (p opthar->len <- 0) ι ι (alloptslβn < p opthdr->lβn) ) ( p_optndr->len • alloptslβn; ilen - alloptslen-2; } else 1 ilen - optdatalen; ) oreak; I ) else if I layer —» NBFCP LAYER) ( switch(p opthdr->typβ) { case NBF_NAME_PROJ: / • NβtBxos Name Projection • / lien • optdatalen; / • BLINDLY ACCEPT BECAUSE WE WILL NOT 00 ANYTHING • / / • WITH THIS AT THIS TIME • / opt_accβpt - C0NFIG_ACK; break; case Nβr_PEER_INFO: / • NetBios Peer Information V ilen-- optdatalen; / • Oon't need to record the IP address since it was • / /* picked off in tne iearnfromreq function. */ / • BLINDLY ACCEPT BECAUSE WE WILL NOT 00 ANYTHING •/ / ♦ WITH THIS AT THIS TIME • / opt_accβpt » CONFIG_ACK; break; case NβF_MU ICAST: ' " NetBios Multicast • / ilen - optdatalen; /* BLINDLY ACCEPT BECAUSE WE WILL NOT DO ANYTHING */ i - WITH THIS AT THIS TIME •' opt_accβpt » CON IG_ACK; orβak; case NBF_MAC_REQUIRED: / • NetBios MAC Required • / ilen » optdatalen; / ♦•• THIS OPTION IS NOT NEGOTIABLE, REJECT • ■»♦ ' opt_accβpt • CO IG_REJ; Break; default: /* Unknown option */ opc_accβpt ■ CONFIG_REJ; '* rote t frcm ooqus packet or Duffer overrun • ' if ( :p_optndr->lβn <■ 0) ι : (alioptsien < p_optndr->lβn) ) ρ_opthdr->lβn ■ alloptslen; len « alloptslβn-2; 1 else ( ilen • optdatalen; ) orβak; I I else ' • assumed to oe BRCP_LAYER •/ I switcnip optndr->typβ) / • MAC Type •/ f (optdatalen < lien) ( /* Short option data; reject packet V opt_aceept « CO FIG_REJ; Break; . if Cp_optdata '•» BRD_MAC_8023) opt accept - CONFΪG REJ; else opt_accβpt » C0«FIG_ACK; /• Value is acceptable •/ Dreak; case 9R_REM_RING_ID: /* Remote Ring ID • / /* 302.3 does not use tnis option, it is Doqus.. •/ op-:_accβpt » CONFIG_REJ; Dreak; case BR_LINE_I0: /* Line ID • / /* 802.3 does not use th s option, it is boqus.. */ opt_accept • CONFIG_REJ; Break; ease BR TINY COMPR: /* Tinyqraa Compression •/ / ••• THIS OPTION IS NOT NEGOTIABLE. REJECT • ••/ lien a 1; opt_accβpt » CONFIG_REJ; Break; case BR LAN 10: " LAN ID */ / • « • THIS OPTION IS NOT NEGOTIABLE. REJECT • • • / opt_accept • CONFIG_REJ; orβak; default: /"* Unknown option * ■ / opt_accβpt « COMFIG_REJ; /* proteet from boqus packet or buffer overrun */ if !(p opthdr->len <• 0) I I (alloptslβn < p optndr->lβn) ) ( p_opthdr->lβn • alloptslen; ilen » alloptslen-2; I else 1 len - optdatalen; I oreak; 1 if ((opt accept »« CONFIG ACK) .£- (cnf accept ' - CONFIG ACK) ( ' • This option was good, out a previous -/ i" option was not. Return only those options */ ' • wnicn are oeing nackβd/ rejected. • / continue; if (opt accept —• CONFIG NAK) ( if (cnf accept — CONFIG REJ) /** Return only tnosβ options •/ i' whicn are Dβing rejected. */ continue; if (cnf accept -- CONFIG ACK) ( ' • Discard current list of good options */ /* Rest ouffer oytecount * ■ / p_ACK_pkt->uLengtn ■ 0; /* Remit ptr to CFG_ACK buffers option field */ p_ACK βuf - ((uβ *)GET DATA PTRIp ACK_pktt) f PPPJ-IDRLEN ♦ CNF_H01UEltj» /* Send a list of necked options */ cnf_accβpt - CONFIG_NΛK; if (opt accept — CONFIG REJ) I if (cnf accept '•» CONFIG REJ) I >' Discard current list of good options */ / • Rest buffer bytecount • / p_ACK_pkt->uLβnqtn ■ 0; / • Remit ptr to CFG ACK buffers option field */ p ACK βuf ((uβ •)GET_OATA_PTrlip ACK_pkt) ) ♦ PPP_HDIUXN ♦ CNF_HWIAOi; /" Send a list of rejected options • / cnf accept - CONFIG REJ; I I /* Add option response to tne return list */ *p_ACK_bu ♦♦ a p op ndr-> type; •p~ACK~buff - άβn ♦ OPT_HDRLEN; for li " 0; i < ilen; ι»») ( *p ACK buff-> • *p optdata*>->; ) / ♦ Bump buffer bytecount by size of REPLY option */ p ACK_pkt->uLengtn •• l en ♦ OPT HDRLEN; 1 / • Send ACK/NAK/REJ to remote host • / if (cnf accept -- CONFIG ACK) ( /• Accept conf iquration requested sy remote host *» / appp_sβndrβply( IpCail, ..ayer, c_AC>-_pkt, CONFIG_ACK, p_cnfhdr->tdl i p_acp->cpstate » acx:_cpstate ; / * i f we j ust tiransitioneβ to OPEN state * / f ( p_acp->cpstate «» C?_OPEN I I appp open) ipCall, layer); '• CP link now open •/ I '• NAK/RE config request made Dy remote nost •/ appp_sβncrepi ! ipCall, layer, p_ACK_pkt, cnf_accept, p_cn hdr->ιd) ; p_acp-> ps-;ate - nak_cpstatβ; return; appp_lβarnfromrβq — Grab any Juicy info from tne App CFG_REQ '/ vo d appp lβarnfromrβq(PCALLINFO IpCall, PPP_layβr t layer, GCAPACKET *p_pkt) ( APPP_CB_t "P_»cβ - *(lpCall->appp); / ♦ APPP CB •/ ?PP_CB_ϊ "p_ncβ - 4(lpCall->ppp) ; /• NPPP CB ♦/ S CPCTL *P_acp • tlpCall->appp.a_cpctlIlayerI ; S~CNFHDR "p_cnfhdr; SJ3PTHDR -p Dpthdr; uβ *p_optdata; slβ .. l ien; slβ alloptslen; slβ optdatalen; 116 minoptlen; p enfhdr - (S CNFHDR • )(((uβ *)GET DATA_PTR(p_pkt) ) ♦ PPP HDALENI; p^optndr - (S_OPTHDR -)(((uβ **)p_cnfhβrϊ ♦ CNF_HDRLEN) ; /• Make sura lenqtn in CP config header is realistic */ if (p_pkι->uLβngth < (DWORD)swapl6(p_cnfhdr->lβn> ) ρ_cnfhdr->lβn ■ s aplβl (ulβ)p_pkt->uLβngth) ; alloptslβn • swapl6tp_cnfhdr->lβn) - CNF_HDRLEN; if (layer -•> IPCP_LAYER) minoptlen » 4; else minoptlen • 2; > ' Process options requested by rβaotβ host */ for (; alloptslen >- minoptlen; alloptslβn — p_opthdr->lβn, p opthdr - IS OPTHDR *)(lu8 *)p opthdr * p opthdr->lβn) ) t " optdatalen ■ p_opthdr->lβn • 2; /* Get curr opts data len •/ ~ /• Set ptr to option data • / ρ_optdata - i( U β • )p_optnαr> * 2; if (layer ~ IPCP LAYER) t if ip optndr->type •• IP AOCRS NEW) /* IP address • / I u22 app_ιp; / • IP Addr is a J2bιt field */ if (optdatalen '. » « ) continue; /' Wrong size, lqnore */ / • Get proposed value from packet */ app_ιp • *p_optdata; *PP_iP " (app_ιp << βl i "tp_optdata ♦ 1); *PP_.iP * (app^ip « 8) i *lp~optdata ♦ 2) ; »PP_iP " l»PpZιp << 8) i "ip optdata ♦ 3 ) ; -f *.sι App is requesting an IP Address to De assignee to rum, we need to indicate to the Net side to request an I? Address. If one nas oeen assigned, we need to reflect tnat as well. p_acβ->pββr_nβgotιatβd_ιp_addr « TRUE; p_aco->pββr_ιp_addr » app_ιp; ' • set tnis for tne Net side negotiations p_.-,cD->my_.p_addr » app_ιp; i ~ " " ~ I else i f .' . ayer •>- I PXCP_LAYER) i f ( p optndr->typβ IPX NET NUM) IPX Nβtwcrr. Numoer ( u-12 app_ιpxnet; /• IPX Net Addr is a 32bit field •/ if (optdatalen !- 4) continue; / ** Wrong size, ignore •/ /* Get proposed value from packet • / app_ιpxnβt « -p_optdata; app_ιpxnβt « ιapp_ιpxnβt << 8) I •lp_optdata ♦ _) ; app_ιpxneτ • ιapp_ιpxnet << 8) I *(p_optdata » 2); app_ιpxnβt - ιapp_ιpxnβt << 8) I * p_optdata . 3); * If the App is requesting an IPX Net Address to.oe assiqned * to mm, we need to indicate to the Net side to request * tne IPX Net Address. If one nas been assigned, we need to * reflect tnat as well. p_acb->pββr_nβgotlatβd_ιpxnβt_addr ■ TRUE; p_acb->peβr_ιpx_nβtwork - app_ιpxnβt; /* set tnis for the Net side negotiations */ p_ncβ->my_ιpx_nβtwβrk ■ app_ιpxnβt; else if (p opthdr->typβ •- IPX NODE NUM) IPX Node Number • / / • IPX Net Addr is a i∑β t field •/ if (optdatalen '•> MΛCADDRESSSIZE) continue; /' Wrong size, ignore */ * If tne App is requesting an IPX Node Address to be assigned * to him, we need to indicate to tne Net side to request ' the IPX Net Address. If one has been assigned, we need to * reflect that as well. p_acb->peβr_negotιaιed_ipxnodβ_addr « TRUE; /' Get proposed value from packet '/ maccpyιp_acβ->peβr_ιpx_nodβ, p_optdata) ; / • set tnis for the Net side negotiations * -/ maccpytp ncβ->my ipx node, p optdatal; I 1 else if (layer — NBFCP LAYER) I i f ( p_optndr->type — NBF_PEER_INFO| / • NetBIOS Peer Info • / I / * copy all the clutter ( Class and version ) */ mβracpy l i uβ • ! p_acβ->nD_pββr clutter, ( u8 " i p optdata . SΣ NBF~CLUTTER) ; / * i f tne far end nas suppned a Peer Nas tuck it away . £ loptdatalen > 8) • The App siaβ is giving us nis NBF Name. Tuck it away • so tnat we can reflect i oack to the Net. p_acD->pββr_nβgotιatβd_nβnamβ - TRUE; mβmcpyl lu8 * ) _aco->nD_pββr_namβ, ( luβ * )p_optdata*SZ_NBF_CLUTTER) , (optdataiβn - 81); p_acβ->nβ_pββr_namβ(optdatalen - 81 - 0; I 1 else / • assumed to Dβ BRCP_LAYER */ I Notning to oe learn here... ♦ / I return; I appp_rcvack — Process the received ACK from the peer. void appp revack(PCALLINFO IpCall, PPP layer t layer. GCAPACKET *p_pkt) ( APPP_CB_t *P_»cb - l lpCai l->appp) ; / • APPP CB V S_CPCTL~ *pZ«cp - 41pCall->appp. a_epctl ( laytarl ; if (p_acp->tιmβr_idl.active) Tr_appp_tιmβr( IpCall, layer, PPP_TIMER1); switcnip acp->cpstate) I case CP_INITIAL: /* » Unexpected event */ case CP~STARTING: /* Unexpected event • / break; case CP_CLOSED: appp_sβndtβraaek<IpCall, layer. CP_CL03ED); break; case CP_STOPPEO: appp_sandtβrmack(IpCall, layer. CP_STOPPED); break; case CP_CLOSING: /* We are attempting to close connection; wait */ /* for timeout to resend a Terminate Request */ oreak; ease CP_STOPPING: /• We are attempting to stop connection; wait • / /* for timeout to resend a Terminate Request */ break; case C»_REQ_3EHT: / • Make sure ACK is proper • / if (appp_chkack(IpCall. layer. p_pkt) '- -1) p_acp->cρstatβ • CP_ACK_RCVD; / • Reeotβ host accepted our req •/ /• Still need to settle request from renote host • / set_appp_timer(PPP_RESTART_TIMEOUT, IpCall. Iu32)layer, PPP_TIMER1 ) ; break; case CP_ACK_RCVD: appp_sβndrβql IpCall, layer); p_acp->cpβtatβ • CP_REQ_SENT; break; case CP ACK SENT: / • Make sure ACK is proper • ' if (appp_cnkackilpCali, .ayer, p_pkt) « -L) ( /• εrror in ACK from remote nost */ /* ait for anotner ACK, tnβn send anotner request •/ sβt_appp_tιmβr( PPP_RESTART_T:MEOUT, " ipCaϊi, l J2ilayer. ?PP_T-MER1 ) ; 1 else I p_acp->cpstate • CP_OPEN; /• CP negotiation eompiβtβ */ appp openi IpCail, layer); ! oreak; case CP_OPEN: /* Somet ng went wrong; restart negotiations */ appp_rβstartl IpCall, layer); /• Send our configuration request */ appp_sβndrβq(IpCall, layer); p_acp->epβtatβ • CP_REQ_SENT; break; default: / • ignore • / break; / • * appp_ehkack -- Cheek the received ACK from the peer. •/ APPP CB (3 CNFHD* •lllluβ *)GET DATA PTR(p_pktl) «■ PPP HDΛLEN); (s~OPTM0* •iniuβ •ιρ_ACK_cn?hdrι ♦ CNF_HOΛLEHT; / • CP 10 field auat match last requeat we sent */ if (p_ΛCX_cnfhβr->id !• ρ_acp->laatid) return -I; /• Get packet for REQ to ACK comparison check • / it (lp_RE0_pkt • ppp_gβt_pkt( I I -• NULL) return!-1); /* Sat ptr to REQ option header •/ p REQ opthdr - I S OPTHOR * Η < ( uβ " I GET DATA PTKlp REQ_pk l ) » PPP_H0ΛLEN •> CNF_H0RLEHT; / • Get a copy of last request we sent • ' p_REQ_pkt->uL β nqtn ■ appp nak β re ( IpCall, layer, luβ • )p_REQ_opthdr> ; / • Get sire of REQ and ACK options field •/ ACK_optslβn - swapl6(p_ACK_cnfhdr->ιβnι - CNF_HDRLEN; REQ_optalβn » p_REQ_pkt->uLβnqtn; ~ /* Overall buffer lenqtn snould aten •/ if (ACK_optslβn '» REQ_optslβnl acierr • 1; » if (layer -- .PCP_LAYER) minoptlen • 4; else minoptlen • 2; * ACK must ecno all options we requested in the order requested "/ for t; (REQ_optslβn >- minoptlen) t« (tackβrπ; REQ_optslβn -« p_REQ_optndr->lβn. p_REQ_optndr » (S_δPTHDR • ) ( (u8~" lp~REQ_optndr » p~ Eθ βPt dr->lβn) , ACK_optslβn -•» p_ACK_optndr->lβn, p_ACK_optndr • (S OPTHDR •) ( iu8~')p~ACK opthdr ♦ p~ACK~optndr->len) ) ( /* Must nave as many acked options as requested •/ i (ACK_optsiβn < minoptlen) ackβrr » 1; ocean; I / • Set ptr to current REQ option data field */ p_REQ_optdβta » ( (uβ * )p_REQ_optndrI ♦• 2: /* Set ptr to current ACK option data field */ ρ_ACK_optdata - ((uβ *ιp_ACK_opt5dr) ♦ 2; /* Confiq option headers must match *>/ if ( ιp_ΛCK_optndr->typβ !- ρ_REC;_optndr->typβ) ii (p~ACK~optnar->lβn !« p REQ oρtnβr->lβn) I ( ackerr « ι ; break; I if (layer ••> LCP LAYER) ( /* Confiq option values must match '/ s tenip REQ optndr->typeι I case MAX_RCV_UNIT: / • Maxiraua Receive Unit •/ ackiϊβ ■~(*p_ACK_optdata << 81 I • ιp_ACX_optdata*l) ; rβqilβ - < *p~REQ~optdata << 8) I • (p~REQ~optdata*>l) ; if (ackllβ •• reqilβ) ackerr » 1; break; case AJUTH_TTPC: /• Autn Protocol Type •/ ackllϊ - (•p_ACX_optdata << 8) I • (p_ACK_optdata->l) ; reqlle - (*p~REQ~oρtdata << 8) i • (p~REQ optdata*l) ; if (ackllβ •- rβqilβ) ackβrr * ,; Break; case PROT COMPRESS: /* Protocol Compression */ case AC_COMPRE33: /* Addr/Control Coaprβaslon •/ / •» its now okay */ break; default: / • Sheuldnt happen « 7 ackβrr « I; break; I I else if (layer -- IPCP LAYER) I /* Confiq option values must match • / swttcnip EQ optnqr->cypβ) ( ~ " case i?_ADORS_NEW: /• :? a dd ress •/ I Echoed values must matcn our request - I reqmy_ιp ■ *o_SEQ_3ptβata--; reqmy_ιρ » ιrβqmy_ιp << 3) ι •p_R£Q_optdata« reqmy_ιp • ιreqmy_ιp << 3 ) , • p~SEc l - , P t --- ( * t -** reqmy_ιρ » (reqmy_ιp << 8) i -p^REQ^optdata * ackmy_ιp » 'p_ACK_optdata * *; ack y~ιp • ιack»y_ιp << 8) i *p_ACK_optdata-> ackmy~ιp ■ (acι y_ιp << 8) I *p~ACK~optdata- ackmy~ιp » (ackmy_ιp << 8) I *p_ACK~_optdata-* if (ackmy_ip '» rβqmy_ιp) aekβrr » 1; break; case IP_COMPR_TYPE: /• IP nβadβr eompr •/ • Ecnoed values must matcn our request •/ rβq iβ « •p_REQ_aptαataf-; reqilβ « ireqilβ << 9) ι -p_REQ_optdata; ackllβ » •p_ACK_3ptdata«»: ~ ~ ackilβ • (ackill << 8) i *p_ACK_optdata; if (reqilβ '• ackllβ) acxerr • 1; break; default: / • Shouldnt happen •/ ackβrr " 1; oreak; else if (layer — IPXCP_LAYER) i /*> Confiq option values must match •/ s itcnip REQ optnαr->cypβl I case acklpx_net ■ •p_ACX_optdata*-»; ackιpx~net - (ackipx_nβt << 81 I *p_ACX_oρtdata**ι ackιpx~net • (aekipx~nβt << 8) I • p~ACκ~optdata**>,* ackιpx~nβt - laekipx ' net << 8) I •p~ACK~optdata*->; if (ackιpx_nβt !• reqιpx_net) ackβrr •» . ; oreak; caae IPX_NO0E_NUN: /• IPX Node Nueβer •/ for Ti - 0; 1 < SZ IPX NOOENUM; l*->) I if Cp ACK optdata ** '- *p REQ optdata**) ( acker - 1; break; I 7 break; default: /' Me didn't send ANY CTO OPTIONS for IPX •/ ackerr - 1; break; I ) else if Ilayer -- NBFCP LAYER) ( / • Confiq option values must match •/ switcnip REQ optndr->typ«ι ( case NBF_NAME_PROJ: /• Empty Na*aβ Prelection •/ / • assume its okay •/ break; cas β NBF_?£ER_INFO: / • Nβtβios Peer Information •/ I * assume its okay • / break; default: / • We z'. r. ' : send any otner NBF "G OPTIONS "' ackβrr » 1; orβait; I I else /' assumed to Dβ ΘRCP_LAYER V i / • Confiq option values must matcn •/ swιtcnιp_REQ_optnor->typβ) I case 3R_MAC_TYPE: / ♦ MAC Type •/ / • MAC Types MUST match */ if ( *p_ACK_optdata ' » *p_REQ_optdata) ackβrr ■ l; ~ oreak; default: ackβrr » 1; oreax; I I ) ppp_rls_pktlp_REQ_pkt, 18); if (ackβrr) return -1; / • ACK matches last requeat we made */ return 0; appp_rcvnak -- Process the received NAX from the peer. void appp rcvnakl PCALLINFO IpCall, PPP layer t layer, GCAPACKET *p_pkt) I APPP_CB_t 'P_«eβ • « UpCal l->appp> ; / ♦ APPP CB • / S_CP TL~ 'P_acp - t lpCal l ->appp. a_cpetl ( layβr | ; if (p_acp->tιmer_ιdl.active) cTr_appp_timertIpCall. layer, PPP_TIMER1); switch(p acp->cpstate) I case CP_INITIAL: /• Unexpected event */ case CP~STARTING: /• Unexpected event */ break; case CP_CLOSED: appp_βendtβrβack( IpCall, layer, CP_CLOSED); brβakj case CP_STOPPtO: appρ_βendtβr«ack(IpCall, layer. CP_STOPPEO) ; βreakj case CP.CLOStNβ: /* ι*e are atteeaptmq to close connection; wait */ /* for timeout to resend a Terminate Requeat •/ break; caaa CP_STOPPING: /* Ha are attemptlnq to stop connection; wait V / ♦ for timeout to resend a Terminate Requeat */ break; case CP REQ SENT: case CP~ACK~SENT: /* Update our confiq request to reflect NAKed options •/ if (appp_cnknak(ipCall. layer. p_pktι — -1) I / • Bad NAK packet • / / • ait for anotner; resend request on timeout »/ sβt_appp_tiUiβrlPPP_RESTART TIMEOUT, IpCail. TuJ2) layer, ??P_TIMER1 ) ; } else ( ' • Send updated con ic request */ appp_jβndrβqι ipCa.i, * ayerι; oreak; case CP_ACK_RCVD: /• lend our confiquration request '/ appp_sendrβq( IpCall, layer); p_acp->epstatβ » CP_REQ_SENT; break; case CP_OPEN: /• Soraβtnmq went wronq; restart neqotiatlons •/ appp_rβstart( IpCall, layer); /• Send our confiquration request • / jppp_sβnorβq( IpCiil, .ayβπ; p_acp->cpstatβ • CP_REQ_SENT; Dreai ; default: oreak; /• iqnore •/ ) return; I /• appρ_chknak — Check tne received NAK from the peer. •/ ~ mt appp_cnknak ( PCALLINFO IpCall , PPP_layβr_t layer. GCAPACKET *p_pkt ) >appp); /• APPP CB •/ appp.a cpetl ( layerI ; p slen; p_NAX_enfhdr • (S_CNrHOR "(llluβ • )GET_OATA_PTRIp_pktI ) ♦ PPP_HORLEN) ; p^NAK ' optftdr " (S~OPTHO* *)l((uβ • )p_NAK_cnfhdr) ♦ CNΓ_HC*LENΪ; /* CP ID field must match last request we sent •/ If ιp_NAK_cnfhdr->id !■ ρ_aep->laatid) return -1; ~ /• Gat packet for REQ to NAK comparison check •/ if (ip_REQ_pkt - ppp_gβtJpk ( ) ) «■ NU L) return(-1); /* Sat ptr to REQ option header •/ p REQ optndr • (S OPTHDR "iniuβ "ISET DATA PTRlp REQ_pkt)i • PPP_HCΛL£N " - CN?_HDW H> ; / * Get a copy of last request we sent • / p_REQ_pkt ->uLβnqtn • appp_makβre ( IpCal l . layer, ( uβ • ) p_REQ_opthdr ) ; /• Get size of REQ and NAK options field •/ NAK_optslβn - swaplβ(p_NAK_cnfhdr->lenι - .-MΓ ^ UΠBTΓM. _ _ REQ_optslβn « p_REQ_pkt->uEenqtτ.; ' • * Check overall suffer lenqtn •' if (NAK_optSlen > REQ_optslβnι naitβrr ■ L; ..' : layer « -pc?_LAτΕR) -ninopt-en • «; minoptlen » 2; / ' NAKed options must Dβ same order as our original request */ for i; ιNAK_optslβn >■ minoptiβn) it l 'na*tβrr) ; REQ_optsiβn — ρ_REQ_optnor->lβn, p_REQ_opthdr • S_OPTHDR • ) ( ( u8~" )p~REQ_optndr ♦ p REQ~optndr->len) , MAK_optslβn —• p_NAK_optndr->lβn, p~NAK~optndr • S 3PTH0R • ) ( lu8~' ιp~NAK_optndr ♦ p~NAK~opthdr->lβn) ) ( /* Must find matcn to each NAKed opt.on •/ :f (REQ_optslβn < minoptlen) nakβrr - 1; oreak; ' ♦ Mayoβ not all options were NAKed; look ' I /* for matcn nq option in our request •/ niiβ ip REQ optnor->typβ ' • » p NAK optndr->typel ( ' • This option not NAKed; eat rest */ /• of option from the request packet */ EQ_optslβn —• p_REQ_opthdr->iβn; p_REQ_optndr - (S_OPTH0R *)((uβ *)p_REQ_opthdr ♦ p_REQ_opthdr->lβnι; /• Must find matcn to eaen NAKed option "/ if (REQ_optalβn < minoptlen) ( D_REQ_optndr->typβ • nakβrr • 1; break; I /• Confiq option headers must match •/ if ( ιp_NAK_optndr->typβ '• p_REQ_optndr->type> il (p NAK~optndr->lβn •• p REQ optndr->1en) ) f nakβrr ■ 1; orβak; I /* Set ptr to current NAK option field to compare */ p_NAK_optdata « ((uβ • )p_NΛK_opthdr) * 2; if (layer — LCP LAYER) I /* Reaete noat replaced our request witn new suggestion */ switcnip REQ optrvdr->typ«ι I case HAX_RCV_UNIT: /• Maximum Receive Unit • / / • Get suggested MRU • / nakilβ « ( « p_NAK_optdata << 8) I • (p_NAK_optdata*l) ; /' Save new request value */ p_acβ->lel_mru • nakilβ.* break; caae AUTH TYPE: /* Autnβntieatlon Protocol Type) •/ /• ne~are requesting AUTH because the Nat la requesting */ /• Authentication. We cannot allow the App to negotiate • / / • it away, so IGNORE IT. • / nakβrr • *, ; break; default: i ' Shoulαnt nappβn ' ' nanerr ■ 1; break; I 1 else if (layer — I?CP_LAYER| > • demote nose replaced our request witn new suqgestion •/ s it r. !p_REQ_aptndr->typei case IP_ADDRS_NEW: /• IP address •' ' • App NOT allowed to give mβ MY Z? Address '! •/ ιaκβrr • i; Dreax; αefaul*;: / ' Shoulαnt nappen •/ nakerr - 1; Dreak; 1 else i f ( layer — IPXCP LAYER) I /• Confiq option values must matcn "/ swι entp_REQ_optndr->typβt I case IPX_NET_NUH: / ♦ IPX Network Number •/ / • App NOT allowed to give me MY IPX Net Address !! •/ nakβrr ■ 1; oreak; case :PX_NO0E_NUM: /* IPX Node Nus-Ber •/ i - App NOT allowed to give me Y IPX Node Address '. '. •/ nakβrr ■ l; break; defaul t : / • Me didn ' t send ANY CFG OPTIONS for IPX */ nakβrr - 1; break; ! ! else if (layer — NBFCP LAYER) ( /• Renote host replaced our request with new suqgestion, •/ /• Except tnat we didn't send ANY NetBIOS CFGs THAT CAN BE NAKed •/ sw tcn(p_REQ_opthdr->typβι I default: nakerr - 1; break; } 1 else / • assumed to be BRCP LAYER • / ( /• Remote noat replaced our requeat with new suqgestion •/ switcnip REQ optndr->type) < default: nakerr - i, βrβakj I ) I ppp_rlβ_pkt(p_REQ_pkt. 19); if (nakarr) return -1; /* NAK matcnβs last request we made '/ return 0; I /• • appp_rcvrβ — Process tne received REJECT from the peer. •/ vo d appp revr β i ( PCALLINFO ipCall, PPP layer : layer. iCAPACKET "p_pktj I APPP_CB_t • p_acβ - 4 ( ipCali->apppι ; '• APPP CS S_CPCTL *P_a=P - *lpCa..->appp.a_cpcti [ layer! ; if (p_acp->tιmβr_ιαl. ctive) cIr_appp_timer(lpCall, -ayer, ???_?:.VER1J ; swιc nι _acρ->cps a β) .aaβ CP_:NI7:AL: / • 'Jnexoectβα event • / case CP_5TARTING: ' • unexpected event •/ oreak; case CP_CLOSEO: appp_sβndtermacκ( IpCail, layer. P_".LOSEO); break; case CP_STOPPED: appp_sβndtβrmack( IpCall, layer, CP_STOPPED) ; oreaic; case CPJ-. CSING: /• we are attempting to close connection; wait •/ ι * for timeout to resend a Terminate Request •/ break; case CP_STOPPING: / • e are attempting to stop connection; wait *7 / • for timeout to resend a Terminate Requeat */ oreak; case CP REQ_SENT: case CP~ACK " SENT: /* Update our config request to reflect NAKed optiona •/ if (appp chkre*) I IpCall, layer, p_pkt) •- -1) ( /• θad reject packet */ /* Wait for anotner; resend request on timeout • / set appp timerlPPP RESTART TIMEOUT, IpCall. Tu32)layβr7 PPP_TIMER1); I else I /* Send updated confiq request */ appp sendrβqlIpCall, layer) ; ) break; case CP_ACK_RCVD: /* Send our confiquration request */ appp_senαreq(IpCall, layer); p_acp->epstatβ ■ CP_REQ_SENT; break; case Ct OfBi: /* Soβethinq went wrong; restart negotiations */ appp_rββtart(IpCall. layer); /* Sand pur configuration request • / appp_sβndrβq(IpCall, layer); p_acp->epatatβ » CP_REQ_SENT; break; default: / • iqnera • / break; return; 1 • appp_ehkrβ-) — Cheeic tne received REJECT from tne peer. int appp_cnkrβ 3 (PCALLINFO IpCall. PPP_layβr_t layer, GCAPACKET *p_pkt) j ~ ipCall->apppι; / • APPP CB »/ pCali->appp.a_cpcti|layβr) ; dr; dr; ar; , REQ_optslβn; slβ minoptlen; p REJ enfhdr - !S "^JFHDR -M((u8 • )GET QATA PTR(p_pktl) * PPP HDRLEN); ~ Ej aptndr - (S~OPTHDR "Mlluβ • )p_REJ_en hdr) •> CNF_HDRLENT; /* CP 0 field must match last request we sent •/ if (p_REJ_cnfhdr->ld !- ρ_acp->lastid) return -1; /* Get packet for REQ to REJ comparison cneek */ if ( (p_REQ_pkt « ppp_gβt_pkt( ) ) •• NULL) return! -1 ) ; /*- Set ptr to REQ option nβadβr • / p REQ optndr • (S OPTHOR -l(((uβ 'IGET QATA PTRlp REQ_pkt)l ♦- PPP_HORLEN ♦ CNΓ_HORLENI; /* Get a copy of last request we sent '/ p_REQ_pkt->uLenqtπ • appp_makβreq(IpCall. layer, (uβ * )p_REQ_opthdr) ; /• Get size of REQ and REJ options field •/ REJ_optslβn - swapl6(p_REJ_cnfhdr->lβnι - CNF iDRLEN; REQ sptslen ■ ρ_REQ_pkt->uLβnqth; / • Check overall buffer lenqtn • / if (REJ_optslβn > REQ_optsiβn) re}err » 1; if (layer — IPCP_LAYER) minoptlen • 4; else minoptlen • 2; /* Rejected options must oe same order as our oriqinal request */ for (; (REJ_opt lβπ >- minoptleni 4 (!re)crr); REQ_optslen -" p_REQ_optndr->lβn, p_REQ_optndr « (S_OPTHC* • ) ( <uβ~ , )p~REQ_optndr ♦ p~REQ~oρtndr->lβnι , REJ_optslen — p_R£J_optndr->len. p^REJ^opthdr • (S δpTMDR •) ( (uβ~ » )p~REJ optndr •> p~REJ~oρtnβr->lβn) > ( tcn tβ each Rejected option •/ < aunoptiβn) breaa; I / • Maybe not all options were Rejected; look • / /* for mateninq option in our request • / while ip REQ opthdr->type '• p REJ opthdr->type) I /• This option not RE ed; eat rest */ / • of option fron tne request packet • / REQ_optslβn -■ ρ_REQ_opthdr->lβn; ρ_REQ_optndr « (S_OPTHDΛ * Ηlua ♦ )p_R£Q_opthdr ♦ p_RCQ_optftdr->lβnι ; / • Must find maten to eacn REJβd option • / if (REQ optslen < minoptlen) ( r->t: pe « 0; oreak; ! 1 /• Config option headers must matcn •/ if ( (p_REJ_optnβr->typβ '« ρ_REQ_optnβr->cypβι I I (p_REJ_optndr->lβn '■ p_REQ_optndr->iβn) ) reiβrr » L oreaic; . : (layer —• LC?_LAYER ) ' • Remote lost wont negotiate tnis option •/ zaaø AUTH_TYPE: / • Autnentication Protocol Type ' I / • Me are requesting AUTH oecause tne Net is requestinq */ /* Autnentication. We cannot allow the App to neqotiate */ / • it away, so IGNORE IT. • / orβak; default: /• Shouldnt happen •/ oreak; ) ) else if (layer -- IPCP LAYER) ( /• Remote host won't negotiate tnis option */ switcnip REQ optndr->typeι I casø IP_ADDRS_NEW: / • IP address •/ /• Abandon attempt to negotiate IP addrs •/ p_acD->neq_ιp_a<3drs • 0; /* Reflect that link is being establisned */ /• w tn NO IP ADDRS assigned •/ break; default: /• Shouldnt happen •/ break; ) I else if ( layer — I PXCP LAYER ) I / • Restate host won ' t negot iate tnis option * / switcn ip REQ optrvdr->type ι I case IPX_NET_NUM: /• IPX Network number •/ /• Abandon attempt to negotiate IPX Network nuaabβr **/ p_acD->nβg_ιpx_nβtwork • 0; / • Refleet tnat link is being establisned • / /• with NO IPX Network number assigned */ break; case IPX_NOOE_NUM: / • IPX Node numβer •/ /* Abandon attempt to negotiate IPX Node nustber •/ p_acβ->nβg_ιpx_nodβ • 0; oreak; def ault : / • We di dn ' t jβnd ANY CFG OPTIONS for I PX • / break; I else if ! layer -- NBFC? 1AYER) ( / • Remote host replaced our request with new suggestion, •/ / • Except tnat we didn't send ANY Nβtβioa CFGs THAT CAN SE NAKed •/ switcnip_REQ_oρtndr-> ypβi case NθF_NAME_PROJ: / • Abandon attempt to indicate to far end any name projection */ p_aco-»nβg_naιnβ_pro-> • 0; break; case NBF_PEER_INFO: ' • Abandon attempt to indicate to far end our peer info •/ p_acD->nβg_pββr_ιr.fo • 0; break; default: reiβrr • χ oreax; i else /* assumed to oe BRCP LAYER */ ( / • Remote host replaced our request with new suggestion V switcnip REQ optndr->typβι ( default: break; ppp_rls_pkt(p_REQ_pkt, 20); return -1; /* Reject matenes last request we made •/ return 0; ) /• appp_rcvtβrtnrβq -- Process the received TERMINATE REQUEST from tne peer. •/ appp rcvtermrβql CALLINFO IpCall, PPP layer t layer) ( APPP_C8_t *P_acβ • 4j(lpCall->apppl; / ♦ APPP CB •/ 3_CPCTL *p_acp • *lpCall->appp.a_cpetl tlayerl ; switcnip acp->cpatatβ) ( caaa CF_IHITIAL: / • Unexpected event •/ caaa CP ' STAKTINβ: /* Unexpected event •/ break) UpCail, layer, ρ_acp->cpβtatβl; :aaø CP ACK RCVO: case CP ' ACK^SENT: appp_sβndtβrmac i IpCal l. layer, CP_REO_SENT) ; break; case CP_OPEN: /* iometnmg went wrong; reatart negotiations */ appp_r β start ιipCall, layβπ; / • Send terminate ack • / appp_sendt β rmac i IpCall, layer, C?_STOPPED) ; break; default: /• ignore • / break; appp_rcvtermacιt — Process tne received TERMINATE ACK from the peer. oid appp rcvtβrmae ( PCALLINFO IpCall, ?P? layer t layer) ( APPP_CB_t ♦ p_acβ • * I lpCall->apppl; /• APPP CB S_CPCTL *p_acp • 4ipCall->appp.a_cpctl [layerI ; switcn (ρ_acp->cpstatβι I case CP_INITIAL: / • Unexpected event •/ case CP~STARTING: / ♦ Unexpected event •/ break; case CP CLOSED: case CP " STOPPEO: casø CP ' REQ SENT: case CP Ka*TsENT: /* stay in same state */ break; case CP_CLOSINβ: /* completes transition to down state, indicate this fact */ appρ_rβstart I IpCall, layer) ; break; case CP_STOPPING: /* completes transition to down state, indicate tnis fact */ appp_rβatart (IpCall, layer); break; case CP_ACK_RCV0: p_aep->cpstatβ « CP_REQ_SENT; break; case CP .PEN: /• Something went wrong; restart negotiations •/ appρ_rβatartlIpCall. layer); /* Sand our configuration request •/ appcι_sendreq(IpCall, layer); p_aeta->cpatatβ « CP_REQ_SENT; break; default: /• ignore • / break; I return; I /• * appp_rcvcoββrβ} — Process tne received CODE REJ from the peer. void appp_rcvcodβrβl ( PCALLINFO IpCall, PPP_layβr_t layer, GCAPACKET 'p_pktl i APPP_C8_t 'p_aco - i I IpCal * ->aoppι ; /• APPP CB • / S_CPCTL *p_acρ • i.pCa..->apop.a_cpct: : layer) ; /• catastrophic code error • / swιtcnιp_acp->cpstatβι I case CP_INITIAL: / * Unexpected event •/ case C?_STAΛTING: / ♦ Unexpected event •/ oreak; ctsø C? CLCSE3: casø CP~CLOSING: ρ_acp->epstate • r?_rLOSEO; break; case CP STOPPED: case CP~STOPPING: case CP~REQ SENT: caaa CP~ACK~RCVO: caaø CP~ACK~SENT: p_acp->cpstatβ » CP_5TOPPED; break; case CP OPEN: appp_ciosβ(IpCall, layer, CP_STOPPING. CP .LOSED); orβak; default: /* ignore • / break; ) return; / « appp_rcvprotorβj — Process tne received PROTO REJ froa tne peer. void appp_rcvprotorβι ( PCALLINFO IpCal l , PPP_layβr_t layer. GCAPACKET *-p_pkt ) I APPP_CB_t *P_acβ - t(ipCall->appp); /• APPP CB •/ S_CPCTL~ "P_.»cp • tlpCall->appp.a cpctl (layβrl ; S_CNFHOR • ρ_cnfhdr; ul β rβJ_proto; p_enfhdr - (S_CNrHO* • )({(uβ •iβtT DATA PTR(p_pkt)l ♦ PPP HDΛLEN); rβi_proto - "Tulβ • ) (((uθ *> )p_cnfr4dr> *~CN _Hua.Lrji); / • eneek tna proto tne renote cnocked on •/ if lrβ*)_proto —• swaplβ(PPP LCP PID)) I / • catastrophic coda error • / switcnip acp->cpatatβι ! caaa CP_INITIAL: / • unexpected event */ caaa CP~STARTINC: / • unexpected event */ breaki caaa CP CLOSED: caaa CP -LOSING: p_acp->cpatatβ • CP_CLOSED; break; caaa CP STOPPED: caaa CP~STOPPING: caaa CP~REQ SENT: case CP " ACK " RCV0*. caaa CP~AθTsεNT: p_acp->cpatatβ • CP_STOPPED; break; caaa CP OPEN: appp_closβ( IpCall, layer, CP_3T0PPING, CP CLOSED); break; default: /* ignore •/ oreak; ) β»sβ .f !!r»-;_proto •- ?PP_3RCP_?ID) ■ ■ (re*|_proto —• ?PP_9R_?ID) ) / • turn aown attempting to D mg up BRCP •/ p_aco->protocols *• -?PP_PROT_BR; appp_rβsβt( IpCall. BRCP_LAYER7 CP_INITIAL. TRUE); / • Peer APPP Does NOT support Bridging, DISABLING. •/ βisβ if (lrβ-j_proto »•> swaplβl PPP_IPCP_PID) ) I I (rβj_proto «« swaplβl PPP_I?_?ID) ) ) " turn down attempting to oring up IPCP •/ p aco->protocols t« -PPP PROT_IP: appp_rβsβt i IpCall. :?CP_ AϊΕR7 CP_rNITIAL, TRUE); /* Peer APPP Does NOT jupport IP. DISABLING. •/ else if l(re*t_proto «• swaplβl PPP_:PXCP_PID) ) II (rβ-|_proto ■» swaplβl PPP_I?X_?ID) ) )~ /* turn down attempting to bring up IPXCP •/ p aeβ->protocols *- -ppp PROT IPX; appp_rβsβt(IpCall. :?XCP~LAYER. CP_ΣNITIΛL. TRUE); / • Peer APPP Does NOT support IPX. DISABLING. •/ I else if ((re:_proto »» swaplβl PPP_NBFCP_PID) I II ιrβ}_proto -" swaplβlPPP_NΘF_PID) I )~ I ~ "" / • turn down attempting to bring up NBFCP •/ p_acβ->protocols *• -PPP PROT_NBF; appp_resβt( IpCall, NBFCP~LAYER. P_ΣNITIAL. TRUE); / • Peer APPP Does NOT support NetBEUI. OISABLΣNG. •/ I return; appp_rcvunknown -- Process tne received pkt with an UNKNOWN CODE from the peer. void appp rcvunknβw i PCALLINFO IpCall. PPP layer t layer, GCAPACKET *>p_pkt) I APPP_Cl_t *P_acβ • (lpCall->apppl; /• APPP CB •/ S_CPCTL~ *PI«CP • *lpCall->appp.a_cpetl(laye l; switcnip acp->cpβtatβ) ( caaa CP_INITlAL: / ♦ Unexpected event •/ caaa CP~STAλTING: /* Unexpected event •/ break; case CP CLOSED: case CP~STOPPEO: case CP ' CLOSING: case CP " STOPPING: case CP~REQ SENT: zaaa CP~ACK~RCVD: case CP~ACK~_SENT: appp_sβndcodβrβι ( IpCall, layer, p_pkt. p_acp->cpatateι; break; case CP OPEN: / ♦ Before declaring down, send out coββ rβ-jβct pkt •/ appp_sβndcodβrβ-( (IpCall, -ayer, p_pκt, C?_ LOSED) ; /* Somβtning went wrong; restart negotiations •/ appp_rβstart ;ipCaii. layeri ; /* Send our configuration request • >/ appp_sβndrβgιIpCall. layer) ; p_acp->cpstatβ » CP_REQ_SENT; oreak; default: /* ignore */ oreak; ; return; IIMIM •lltltl •mil I • I a • •••IIII ) • a Capyπgnt ISDN Systems Corp., 1992-1995. All Rights Reserved. Filename: nppp.e Description: This module contains tne Network side for tne PPP Emulation state macninβ processes. Modification Log: Date Autnors Notes/Description of Change ::-10-93 Jo ama 5enβsιs •include "pppdβfs.h" 300L SplitPkts - TRUE; /' By default, always spilt pkts */ — NOTE: declaration of MS Oata variables goes nβrβ. Since the • "* Microsoft Compression scneme is not intellectual property of USR, ** we cannot reveal it in tnis patent application. ••••/ " . . . INSERT MICROSOFT COMPRESSION DATA DECLARATIONS HERE ... • / / • nppp_sβnd_pkt - Transmit a frame. •/ ~ int npρp_sβnd_pkt ( PCALUNfO IpCall , Lmk_CB_t *p_linfc, GCAPACKET *p_pkt. ulβ pid ) I i f ( P_P« m NULL) return -1; if { (pid — PPP BR PID) I I (p d -« PPP BPDU PIDI ) ! /• • • Make aure tne packet is tne min mum Ether Pkt size ( 60 bytesI •/ if (p_pkt->uLβngth < 60) p_pkt->uLβngth ■ βO; 1 / * let tMa function do tne compressing, splitting, and spittlnq '/ nρpp_ββnd_fra-*βa i IpCall , p_lιnk, p_pκt. pid) ; return 0; ~ I /• nppp_sβnd_fraββa - Split tna data packet to be sent over PPP into multiple PPP frsaaaa. • / void nppp_sβnd_frames( PCALLINFO IpCall. Lιnk_CB_t • p_lιnk, GCAPACKET *p_pkt. ulβ pid) j PPP_CB_t -p_ncβ • t(lpCali->pppι; / • NPPP CB * Set up default packet lβngtn */ pkt_lβn • orιgιnal_pkt_lβn ■ p_pkt->uLβngth; / • Point to past end of pkt */ CopyPtr - ( ( uβ )GET_DATA_PTR(p_pkt) ) ♦ pkt_lβnj *" > Compreaa the data if capable. •/ /* If (connection haa negotiated compression) and (PIO is a datagram) •/ if (p_ncp->compreaa on.coaprβaaιng ti ((pid f OxffOO) — 0)) /* ' • Before we compreaa, we must prepend the PID to tne packet. •/ switcnip ncβ->coαpressιon.algorithm) [ ease CCWPRESS_STAC: p_snβrtpid - (uβ • ) GET_OΛTA_PT Ip_pkt) ; p_snortpid—; / •> back up getting ready for prepend •/ •p_βnortpld • pid t Oxff; spec saya to ALKAY3 coavpress PID •/ p_paekat a p_ahβrtpid; p_coβapData - coβjprβssβd_data; NOTE: call function to compreaa pkt for STAC Coβprβssion algorithm. Since tne STAC Compression scπetae is not intellectual property of USR, we cannot reveal information pertaining to it in this patent application. ... INSERT FUNCTION CALL HERE ... V (stac_cap_rβturn - compreaa packet with STAC Compression) •/ * if (wa compressed tne packet) */ f (stae_cap_rβturn — C0H RESS_OKAY) pkt_lβn • eompreβsedLengtn; CopyPtr - compressβd_data • pkt_lβn; /• end of pkt • / pid - PPP_C_PI0; reflect tnat tnis is a compressed pkt *-/ -87 - i else ( / • * • i f we did not cc-mpress , copyptr is already initialize d . " * and iβn is uncnangβd . */ i break; case COMPRESS_MICR0S0FT: p_iongpιd • (ui6 • I GET_3ATA_PTR(p_pkt) ; _iongpιd—; / • back up getting ready for prepend •/ *p_longpιd - swaplβ(pιd); p_packβt » luβ ')p_longpid; long_pkt_len • pkt_lβn * sizβo ( lβ) ; /• add pid to compress size •/ /..« • . •• NOTE: call function to compress pkt for Microsoft Compression ** algorithm, since tne Microsoft Compression scne-aa is not — intellectual property of USR, we cannot reveal information ** pertaining to it n this patent application. ..../ / • ... INSERT FUNCTION CALL HERE ... ♦ / / • <ms_cmp_rβturn » compress packet with Microsoft Compression) •/ / • if Iwe compressed the packetI •/ if <ιmβ cmp return . PACKET COMPRESSED) — PACKET COMPRESSED) I /* ad-Just tne prim buffer pkt offset */ /* (put in tne PPP neader) •/ PUT_DΛTA_OFF(p_pkt, (GET_OATA_θrr(p_pktI - Slzeof(ulβ) ) I ; pkt_lβn • long_pkt_lβn; CopyPtr » p_packβt * pκt_lβn; / ♦ end of pkt -I pid « PPP C PID; / • reflect tnat tnis is a compressed pkt •/ I else ( / • •• if we did not compress, copyptr is already initialized. •* and len is unenanged. */ I break; case COMPRESS_ASCEND* p_paekβt ■ l uβ * ) GET_OATA_PTR ( p_pkt) ; p_eo*apθata • co«aprββsβα_αaca; /* before we eoaapreas tnis packet, we need to calculate the */ /* 2-byte LCS. • / for ( i - 0, pkt_lcft 4 Oxf f f f , p_oytβ - p_packβt; 1 < p_pkt->uLβngtft; i** ) ~ ( p*t leto *a up byte**; ) . f •••* •* NOTE: call function to compreaa pkt for STAC Compression **> algorithm. Since the STAC Compression scneae is not •• intellectual property of USR, we cannot reveal information — pertaining to it in tnis patent application. ••••/ /• ... INSERT FUNCTION CALL HERE ... • / /• (stac_cmρ_rβturn • compress packet witn STAC Coaaprβsβion) •/ /* if (we compressed tne packet) • / if istae cmp return — COMPRESS OKAY) I /• stuff in tne 2-oyte LC3 at tne end of the compressed pkt */ -83- - .omprβssβdLβngtni ; pkt_.en » romoressedLeπgtn; CopyPtr " csmpressβd_data • pκt_len; / • end st pkt •/ pid • PPP C PID; / • reflect tnat this is a compressed pkt •/ I else ( • * if wβ did not compress, copyptr is already initialized. •* and len is unchanged. •/ I orβak; i /* if (connection is using compression) */ /• • • At tnis point, we have a data pkt tnat is ready to be split up •* into multiple fragments, be framed, tnen snipped. •* "" Set up tne default number of links, tnen make the various cheeks •* tnat mignt override this default. •/ if !lpCall->num_lιnks «— 0) num_lιnus » 1; else num_llnks ■ ipCall->num_links; /' Is tnis a Control Protocol? If so, do not split it. •/ if I (pid * OxffOO) • • 0) num_lιnka « 1; / • Not allowed to split packets •/ /• Haa tne user explicitly said no pkt splitting? */ if ϋSplitPktsi I num links " 1; /* > Not allowed to split packets • >/ I reaaion, see how many linka wa can •/ num_ltnks—.* ) n / num_ rames ; rame len - i pkt len % num fraawa i ; rame len > pkt len; /* Loop through tne fragments, building tne individual frames • / for (idx ■ num frastes, npp seqnu • p ncβ-x-app aeqnua * Idx - 1; ldxj ldx~) ( /• On tne first fragment Hast sent), re-uaa the original buffer •/ if IIdX -a 1) ( / • point to the original buffer */ p_tx_pκt • p_pkt; length • equal frame len; I else / • not the last fragment •/ I /* if this is tne last frame i irst to send) •/ if ((idx ■- num_framesι '* (iast_framβ len !» 0)) lβngtn « last frame len; else Iβngtn • βgual_framβ_lβn; /• get ASI header •/ p_tx_pkt ■ ppp_gβt_pkt( ) ; / • dropping this fragment •/ /* if this was going over MPP, we need to bump tne •/ / * sequence nu eer so tnat tne far end will see a •/ / • hole in tne sequencing ( representing this dropped pkt) */ if l (lpCall->lscCallOata.dw£ncapaulatlon — PPPML EMULATION) a iipid 4 OxffOO) -- Oil ~ I p_neβ->mpp_ββqnum»*; mpp_sβqnum«; ) continue; /• Fill in or update this frames vitals •/ p_data - (cnar • )GET_OΛTA_PT (p_tx_pk I ; /* Ad*)ust ptr of where to copy from •/ CopyPtr — length; /• Copy m tne data •/ meαcpyιp_data, CopyPtr, lβngtnI; /* Set or update the length field for this frame p_tx_pkt->uLβngtn - lβngtn; / • before we encapaulate w th MPP or PPP header, we need to •/ /* compensate for any additional compreaaion header stuffing. •/ if (lldx « 1) it (pid — PPP C PID) I ( switcnip ncβ->eoaaprβsslon.algorithm) ( case offaat */ slzeof ( ut) ) ) ; p_histnum - l uβ • ) GET_DATA_PTR (p_tx_pltt ) ; ^ *p_nia«nuβ) • ρ_ncβ->ecp_nu«_nιstβj p tx_pkt->uLβngth »• ιιzeof ( uβ) ; I break; caaa COMPRESS_MICROS0rT: / * ad)ust~thβ prim buf fer pkt offaat •/ / * (put in the PPP header ) */ PUT_QATA_orr < p_tx_pkt . " (GET_DATA_δrrip_tx_pkt) - sizβo (ulβ))); p_eohereney ( U lβ •)GET_DATA_PTR(p_tx_plt j; /' build tne MS_COMP Bit field (A:B:C:0) and conβrβncy num •/ *p_eohβrβnr-y -> swaplβl (ulβ) (( (ulβ)ms_cmp_rβturn « β) I / • Increment the 12-oιt counter and account for wrap •/ /* NOTE: tnis also clears any FLUSH indicators tnat may ♦/ /* navø oeen set from nppp_rsvrβsβtrβqι ) . */ p_ncB->mppc_-:x_conβrβncy ■ -p_ncD->mppc_tx_conerency * 1) t Oxttt; p_tx_pkt->uLenqtn •« sizeoflulβ); oreak; case COMPRESS_ASCEN0: • just tne prim buffer pkt offset •/ /* iput m tne PPP nβadβπ •/ PUT_OATA_OFFip_tx_pkt. ~(GET~CATA_OFF(p_tx_pkt) - sιzeof(ulβ) - sizβof(ulβ) ) ) ; p_ul6 - l lβ • )GET_DATA_PTR(p_tx_pkt); *p_ul6--> « swaplβ(orιoιnal_pid) ; • p_ulβ • swaplβ(orιtjιnal_pkt_lβn) ; p_tx_pkt->uLβngtn -- sizeoflulβ) •> sιzeof(ulβ); break; /* snould we send tnis packet out over MPP or just PPP ? */ if i (lpCall->IscCallOata.dwencapsulatιon — PPPML_EMU ATION) ti ( (pid * OxffOO) — 0) ) / • Build the flags field for MPP */ flags ti 0; if I idx *••> num frames) flags i- MPP_EN0_PKT; if (idx « 1) flaqs i- MPP_BCCIN_PKTJ / • now tnat wβ know it is MPP, is this the first •/ /* witnin tne packet? If so. prepend a MPP and PPP header •>/ / ♦ to it. else 3 ust prepend a MPP header to it. */ if (flaqs t MPP BEGIN PKT) ( / • adjust tne prim buffer pkt offset */ /* (put in tne MPP neader) •/ PUT DATA orrip tχ_pxt. ~ ( GET~0ATA OFF( p tx_pkt l - MPP_HORLCN - ( PPP_HOMXN - 3 ) 1 ) ; p_mpphdr - ( S_MPPHDR • ) GET_OATA_PTR ( p_tx_pkt ) ; p_mpphdr->addr - HDIC_ALL_ADC5*.J p~mppndr->control - HO CjjI; p~rappndr->pιd • swaplβ(PPP_MPP_PID) ; p_mpphdr->flaqs ■ flaqs; ρ_nppndr->se-qnι • (u8) (*npρ_sβqnuβ >> 16); p~mppndr->ββqlo ■ swaplβl (ulβ) (napp_sβqnuaι « Oxffff)); / ♦ no need to modulo this since nigh byte is no care */ /• trust tae. it will take care of itself */ p_-neβ->mpp_seqnumt"f; *app_seqnua--; t* Note: wa are βackinq up 1 byte to overlay the PPP • / /* neader into tne MPP header. The 1 byte ♦ / /*- is due to tne fact tnat tne PPP framing •/ / • is NOT included in tna PPP header • / p_snortpid • (uβ • I (p_mppndr ♦ 1); • p_snβrtpιd - pid i Oxff; p tx_pkt->u βngtn «■- MPP HOR CN ♦ (ppp HDaχtN-3); I elaa i / • adjuat the prim Duffer pkt offset */ /• iput in tne MPP neader) • / PUT_aATA_OFF( p_tx -kt , ; GET_3ATA_OFF( p_;x_pk ) - MPP_ H DRLEN ) I ; p_ * nppndr • ( S_MPPHDR • ) 3ετ_0ATA_PT lp_tx_pkt) ; p_mppndr->aodr ■ HDLC_ALL_ADDR; p_rnppndr->eontroi • HDLCJJI; p_ ppndr->ρid • swapl β i PPP_MPP_?IDl ; p_mppndr->flags • flags; p_mpphdr->seqnι • (u8) ιmpp_seqnum » 16); p_ ppndr->seqlo ■ swaplβ( (ulβ) Impp_sβqnum 4 Oxffff)); /' no need to modulo this since hign byxe is no care '/ '* trust me, it will take care of itself */ p_nco->mpp_sβqnu*rvt**; -npp_sβqnum—; p_cx_pκt->uLβngtn ♦- MPP HORLEN; I I else ( / • ad-gust the prim buffer pkt offset */ / • (put in tne PPP header) •/ PUT_OATA_OFF(p_tx_pkt. (GET_DATA_OFF(p_tx_pktI - PPP_HDRLEN) ) ; ρ_pppnβr - <s_PPPHOR • ) GET_OATA_PTR<p_tx_pkt) ; p_pppndr->addr - HDLC_ALL_ADOR; P_pppndr->eontrol • HDLC_UI; p_pppndr->pιd • swaplβIpid); p tx_pkt->uLβngtn •>• ppp HORLEN; ) / • > now handle AC and/or Proto Costpresa */ if (pid !- PPP LCP PIO) I ad)ust_fwd > 0; / • if AC comp, Bump up tne ptrs and deereaant the ctrs V if tp_ncp->tx_ac_coaapι ad*)ust_fwd ♦• 2; / • i PROTO comp, buaap up tne ptrs and decrement tne etra */ if ( (p_ncB->tx_protβ_coap) «t ((pid - OxffOO) — 0)) adt)uat_fwd**; ~ switch!adjust fwd) I case 1: / •» Protocol Compreaaion '/ / • ad * )uat tna pria buffer pkt offset •/ /• (take out tna AC fields) ♦ / pιrr_QATA_orr ι p_tx_pkt . ι GET_DATA_OIT i p_tx_p*t ι ♦ 11 1 ; p_tx_pkt->uLength -• I; p_tx_pkt->uLβngth -■ 2; break; caaa 3: / • AC and Protocol Coapreaalon **/ /* adiuat the pria buffer pkt offset */ /• (take out the AC fields) '/ PυT_QATA_OFF(p_tx_pkt, lGET_DATA_OrF(p_tx_pkt) ♦ 3)1; p_tx_pkt->uLβngth -• 3; /• • • > ow we nave the iragraert ;.:.y encapsulated, snip it •/ / • " Dump DC stats • / p_nco->tx_framβa*»; p_nco-»εx_Dytβs •- D_tx_pkt->uLβngtn; p_nco->tx_dβlta_oytβs «•» p_cx_pkt->uLβngtn; /* if it is NULL nerβ, wβ a αata packet */ if (p_lmk -« NULL) p^lmk - nppp_gβt_nβxt_link( IpCall. TRUE); / • if it still is NULL, wβ eβ screwed... •/ if (p link »» NULL) ( /* get rid of the pof data pkt since it is not going out */ ppp_rls_pκtιp_tx_pkt. 5> ; 1 else ( '' • get out of my yard you miserable dog... •/ Ll_TransmιtPaekβt(p_tx_pκt, ipCall. p_lιnk->usβr_sββs_ιd) ; /* This will cause us to cycle tnru to the next active link */ p_lmk - NULL; ) nppp_rx_frame - Receive a frame from a link */ void k, GCAPACKET *p frame) /• NPPP CB ♦ / p_pppndr - (S_PPPHW • ) (GET_OATA_PTR(p_frame) ); •/ /* ad*)uat for AC Compression •/ If ( (•p_βyta«*aa HOLC_ALL_ADrA) «4 C(p_βytβ«*l) — H0LC_UD) p byte ♦■ 2; ~ 7 » bump past tne addr/Ctrl fields */ elaa ~ ad1uat_back ♦• 2; /* ad-Just for Proto Com ression */ - ad*»uat_βaek) ) ; p_βytβ « (uβ ♦ ιp_pppndr; p_pppndr ■ ιS_PPPHDR •)(p_βytβ - adiust_oaeki ; /• at this point, we know now far oack to go, so d o it. switen lad-just back) 1 case 2: /" AC Compression •/ p_ppphdr->addr « •DLC_ALL_ASDR; p_pppndr->control » HDLCJJI; oreak; rase 1: '* Protocol Compression •/ rase 2 : /" AC ana Protoco. Compression •/ p_pppnar->aaar - *ι0LC_ALL_AD0R; ntrol • HOLCJJI; • iϋp_pppndr->pιd; Dreak; I /• Now we have a PPP packet. Make sure: / • 1) packet is not too snort /* 2 ) make sure tnat ADDR-Oxff /" 3) mane sure tnat CTRL"! /* 4) make sure tnat PROT is odd if ( (p_frame->uLβngtn <- PPP_HORLEN) I I .p_pppnαr->addr '■ MDLC_ALL_ADDR) I I !p_pppndr->control '• HDLCJJI) I I ( (swaplβ(p_pppnαr->ριd) . I) ■« 0) ) ( ppp_rls_pκtιp_fra β, 0); return; *• Processing is dependent upon MPP or PPP framing if (swaplβ(ρ_ppphdr->pld) — PPP_MPP_PIDI nppp_cx_mpp_framβ(IpCall, p_Imk, p_frame); else nppp_rx_pkt(IpCall, p_lmk, p_frame); nppp_cx_pkt - Process a received packet void -ιppp_rx_pkt(PCALLINFO IpCall. Lιnk_CB_t -p_llnk. GCAPACKET ' ^kt) NPPP CB p_ppphdr • ( S_PPPHDR * I ( GET_2ATA_?TR ( p_pkt I ) ; / ' *• Do we need to decompressing tne pacxet? •/ if (swaplβ(p_ppphdr->pιd) -• PPP_C_PID) ( /• ■ * if (connection nas negotiated compression) •/ i (p_ncb->eompression.compressing) I swi cnip neo->compressιon.algorιtnffl) ! case COMPRESS_STAC: /• If we are paused for a RESET_ACK, send a new RESET_REQ •/ /• w th the saved 10 and drop tne rx'd pkt •/ ~ if (p neβ->stac aβcotftp_pausβd id) I nppp_sβndrβsβtrβg<lpCali, P_J-ink. CCP_LAΪE ); ppp_rls_pkt(p_pkt. 1); return; I /• • - Initialize tne decompression variables */ p dβcompβuf fβr • decompression buffer; dβstCount • MAX FRAME LENGTH; lβngtn_of_data • MAX_F \AME_UNGTH» •- we now need to determine wnere the cβapreaaad data starts •/ p_comp0ata - (uβ •)(p_ρppndr * -.,; pkt_lβn • p_pkt->uLβngtn - PPPJHORLEN; if (p ncβ->ccp num hists) ( /* gosh, if we are supporting 1:1 compreaaion, tna •/ / • history value really anouid be 1. •/ if Cp compOata !• p nco->ccp num mats) I ppp_rls_pktlρ_pkt, 1); return; •• NOTE: call function to decompress pkt for STAC • • Oacoapreβslon algoritnm. Since tne STAC ** Decompression schema is not intellectual property •• of USR, we cannot reveal information pertaining to • * it in this patent application. / •» decompress. acket witn STAC Decompression •/ /* (stac_cmp_rβturn » decompress pkt with STAC Compression) •/ / ♦ * *> If wa are nβrβ, we are either going to uaa a new sat •* • of Duffers or we ara going to release tna received pkt • • Duffers. Do it here in a eotaaon place. •/ PPP_cls_pkt(p_ρkt, 1); if (stac_cmp_rβturn !• C0MPRESS_OKAY) ( nppp_sβnorβsβtrβq(ipCall, p_lιnk, CCP_LAϊER) ; return; ~ I /• • * Copy tne decompressed info out of the dβcomp Duffer • " so cπat we can massage it then pass it up to tne user. •/ / •• TAKE HEED: Wβ are aoout to reuse p_pkt •*/ /" Get packet for copying out the decompressed data into */ if ;;p_pkt « ppp_ςet_pkt( I ) »- NULL) return; p_pkt->uLβngth ■ iβngth_of_data; p_data ■ (cnar • )GET_OATA_PTR(p_pkt) ; memepyι p_data, deeempresslonjpuf βr, length_of_data > ; /* •• Determine now many Dytes we need to back up before prependlng • * tne PPP Header. •/ / • we know at a minimum tnat we need to prepend the address •/ / • and control bytes to tne PPP header •/ ad*)ust_back • 2; /• •• Prepend framing portion of PPP Header to pkt (back to front). •• Take into account tnat tne PIO aignt be compressed (snort). •/ last octact in PIO *7 / ♦ make this look exactly like a PPP pkt */ p_ppphdr • (S_PPPH0R ')(p_data - edjuatjoack) ; p_ρpphdr->addr » HOLC_ALL~AOOΛ; p_pppndr->control ■ HDLCJJI; p_αa a » luβ • > (4p_ρppndr->pld) ; • p_aa a ■ 0; / • tnis doesn't hurt in either ease •/ PUT_OATA_OFr<p_pkt. (GET_0ATA_OΓF(p_pk ) - βd-justjoacfc)); p_pkt->uLβngtn ♦• ad")ustjaack7 / • Reset PPP Header Ptr • / p_pppndr - (S_PPPHOR • ) (GET_DΛTA_PTR(p_pkt) 1 i break; ~ ~ caaa COMPRESS MICROSOFT: / • •• Ma now need to extract tne cornereney information from •• tna start of tna packet. • / p eo pOata - (uβ • ) Ip_pppr*ar ♦ 1) ; pϊt_lβn - p_pkt->uLβngtn - PPP_H>RLENj ( (ulβ • )p_compOata) ) j /* if the dictionary was flushed, blindly accept tna */ /• TX conarency count, flush the dictionary, ana) decoaapreea •/ if (conarency 4 CCP A FLUSHED) ( /• bump tne next expected RXJCohβrβney cnt */ p nce->mppc rx conarency • Iconβrβήcy " » 1) 4 CCP_CC-HERENC1f BITS; I else /• the RX and TX conerency counts muat match •/ I if ;p_rico->mppe_rx_conβrβncy '• <conerency 4 CCP COHERENCY BITS)) ! / • Peiease tne received pkt Duffers. •/ ppp_ris_pkt:p_pkt, 1); * send out CCPJAβsβtRβς •/ nppp_sβndrβsβtrβq I IpCall . p_lιnk, CCP_LAYER) ; return; I else I / • bump the next expected RX_Cohβrβncy cnt •/ p_nco->mppc_rx_conβrβncy ■ i nco->mppe_rx eonβrβncy * 1) 4 CCP COHERENCE BITS; I - • since we currently don't supported encrypted pkts, we ** must crop it if we get one. •/ -f iconβrβncy 4 CCP 0 PKTENCRYPTEO) I / > Release tne received pkt buffers. •/ ppp_ris_pktιp_pkt, li; return; /• •• Now mane sure tnat tne compress bits indicate that tne *- packet nas βeen compressed (this is the seat flexible * • way to code it) . • */ if (coherency 4 CCP C PKTCCHPftESSED) ( ρ_deeo*apβuffβr - decoetpresaionjouffer: '" NOTE: call function to decompress pkt for Microsoft ** Dβconprββaion algontna. Since the Microsoft " Oβcomprβssion scheme is not Intellectual property • * of USR, we cannot reveal inforaation pertaining to "* it in tn s patent application. •••»•/ /• decompress packet with Microsoft Decompression •/ /• ... INSERT FUNCTION CALL HERE ... ♦ / /• ••» If we aeø nere. we are eitner going to use a new aet • " » of buffers or we are going to releaae tne received pkt *"• buffers. Do it nare in a coaaaon placa. • / P P_rla_pktιp_pkt. li; /•• TAKE HEED: Ha are about to reuse p_pkt •• / ^- / • Get packet for copying out the dβcoββprβasβd data into */ if (ip_pkt a ppρ_gβt_pktI ) ) •- MU L) return; p_pkt->uLβngtn > iβngtn_of_data; p_data • (cnar ♦ )GET_QATA_PTR(p_pfct); meraepyi p data, p dβco pβuf ar, lβngth_of data ) ; I elaa I / • • "" for some reason, this packet came in under the CCP *• PIO but neitner tne compreaa or encrypted bit waa •♦ set. Set tne vaπaDiββ tnat will be used βy tne • * common coeβ oβiow. * • For common processing, set tne current app ptr * • to point past tne ??P nor and Conβrβncy cntr and ** adjust tne data lenqtn as well. •/ ?UT_3ATA_OΓFIp_pkt, .jE?_-A7A_3F"i _pict ) ♦ (p_pkt->ui.βngt.-ι - pkt_iβnιl); p_pkt->uLβngtn • ριct_:βn; p_aaca - ;cnar • iGtT_uATA_PTR(p_pkti ; i ~ - /• •• Oetβrmine now many bytes we need to back up before • * prependlng tne PPP Header. / • we know at a minimum tnat we need to prepend the •/ /* address and control oytβs to tne PPP header •/ /• •• Prepend framinq portion of PPP Header to pkt (Back to * "" front i. Take into account tnat tήβ PIO m gnt oe ** compressed lsnorti. / • SBit is set if last oetβct in PIO •/ /• make this look exactly like a PPP pkt */ p_pppndr ■ (S_PPPHO ')(p_data - ad)uat_beck); p_pppndr->addr - HD C_A _AOOΛ; p_ppphdr->control • HOLCJJI; p_data • luβ • ) ( J,p_pppnαr->pιd) ; • p_data « 0; / • tnis doasn't hurt in either caaø •/ PUT_QATA DfF(p_pkt, (G£T_3ATA_θrrtp_pkt) - ad-justjoack) I ; p_pkt->uLβngth ♦• ad 3 ust_oack7 / • Reset PPP Header Ptr • / p_pppndr ■ (S_PPPHDR • I (GET_OATA_PTR(p_pkt) ) ; break; case COMPRESS ASCEND: / • '*> Initialize the decompression variables V p dβcoaapβtuffβr « decompression buffer; dβatCount • MAX FRAME LENGTH; lβngtn_of_data - MAX_FRAME_ ENGTH; /• *"* Ma now need to determine wnere tne compressed data starts •/ p_co«ρOata • luβ •)tp_ppphdr » 1 ) ; pitt_len • p_pkt->uLβngth - PPP_HDRLEN; /• get tnen bump paasad the pkt PIO */ orιginal_pιό • swaplβ ( • ( luiβ • ιp_eoβpθata) ) ; p_compOata ♦« sizeof (ulβ) ; pitt_lβn — sizeof (ulβ); /* gac than Dump paasad tna uneoapreaaed packet length •/ orιgιnal_pkt_len • swaplβl* I (ul* • > p_coaapOata > ) ; p_compOa a •>• sizeof (ulβ) ; pkt_len — sizeoflulβl; * 9βforβ wβ αβcomoresβ cnβ put. we need to extract tne LCB * from tne end of tne received put. In addition, wβ need * to adjust tne pkt_len so that tne LCB bytes liast 2-oytβsι * are not treated a compressed data. β! » ! (ulβ • ) ιo_compData * pιt_ien - sizeof(ulβ) I . —4 sizeof(ulβ); * NOTE: call function to decompress pkt for STAC Decompression * algoπtnm. Since tne STAC Decompression scnetnβ .s not * intellectual property of USR, wβ cannot reveal .nicrmat on * pertaining to it in tnis patent application. /• ... INSERT FUNCTION CALL HERE ... •/ /* !stac_cmp_return • decompress pkt witn STAC Compression) •/ '• tf we are nβre, wβ are either going to use a new set •• of buffers or we are going to release tne received pxt " • ouffers. Do it nere in a eotnαon place. ppp_rls_pktιp_pkt, 1!; if lstac_cmp_rβturn '» COMPRESSJ3KAY) return; ~ •• make sure the pkt len passed in front of the compressed " packet matches tne decompressed length. if (lβngth_of_data !• orιginal_pkt_lβn) return; " Now calculate and compare the LCB to make sure tnat we matcn. for li » o, caic_leβ - Oxffff, p_βytβ • decompression_ou fβr; i < iβngtn_of_data; ι*>->) calc_lcb * ■ *p_βytβf Copy tne decompressed info out of tne decotap buffer so tnat we can massage it tnen paaa it up to tne user. /•* TAKE HEEO: we are about to reuse p_pkt •**/ /* Gat packet for copying out tne dβcoaaprββββd data into */ i f l ( p_pkt a ppp_ςβt_pkt l ) I •> NULL) return; p_pkt->uLβngtn ■ lβngth_of_data; p_data • (char •)GET_OATA_PTR(p_pkt).* maιaepy(p_data. dβco prβssionjouffβr, lβngth_of_data); Determine now many bytes we need to back up before prependlng tne PPP Header. /• we knew tnat wβ need to prepend the PPP header • / adjuβt_βack • PPPJrtDRLEN; /• •• Prepend framing porti.n z t PPP Header to pkt (back to front) ■• Take into account nac tne PID ignt Oβ compresse d I snort ; / • -nake tnis iooi exact.'/ .ixβ a PPP p<t •/ p_pppnor » 5_PPPHDR • : , p_aata - aα}ust_oac)cι ; p_pppndr->addr - HDLC_ALL_AOOR; p_pppndr--»controi - HDLCJJI; p_pppndr->pid ■ swapl6(oπg nai_pιd) ; PUT_DATA_orrtp_pkt, (GET_3ATA orr(p_pkt) - adlust_Dack) ! , p__pkt->uLβngth ♦« 'ad")ust_Dack7 ~ /• Reset PPP Header Ptr • / p_pppndr - (S_?PPHDR • ) (GET_DATA_PTRlp_pkt ) ) ; •• -...-.illy, wβ are down to a contiguous, non-compressed PPP pkt, '* process it as sucn. switch (swapl6(p_pppl*tdr->pld) ) ! case PPP BR PID: / • Bridge Data Packet '/ case PPPJBPOUJPIO: / • BPDU • / p_βrήcp » *" *p_link->a_epctl'βRCPJLAYER| .* pjoracp - .lpCall->appp.a_epctlΪBRCP_LAYER| ; if (p_brnep->cpstatβ '» CPJOPEN) I ppp_rls_pkt(p_pkt, 11, break; if l _βracp->epatatβ !- CPJ3PEN) ( ppp_rls_pkt(p_pkt, 1), oreak; > /* since tne App side is guaranteed to be only talking PPP V /* (not PPPML), the packet is ready for delivery. Isn't it */ / • nice tnat we don't nave any sequence nuaiβers in tne pkt */ / • to contend with! Me are merely a conduit here. */ /- Enqueue tne fraaw to the rx data queue •/ L4_PlacβPaekβtOnRlng( ipCall, (void • )GET_OATA_PTR(p_pkt) . p_pkt->uLβngtn) .* ppp_rls_pkt lp_pkt. Σ); break; case PPP_IP_PI0: / • IP Data Packet • / p lpnep-- «p_llnβ->a_cpcti ( IPCP LAYERI; p_ipacp - *lpCall->appp.a_epctlTlPCP_LAXER|; if (p_lpnep->epatate !• CPjOPEN) ppp τla_pkt(p_pkt, 3); break; f (p_ιpaep->epatatβ !« CPjOPEN) ppp_rla_pktιp_pkt. 3); break; • since the App side is guaranteed to be only talking PPP */ * mot PPPML), tna packet is ready for delivery. Isn't it */ /* nice tnat we don't nave any sequence nuaββrs in tna pkt • / /* to contend with! He are merely a conduit here. •/ /* Enqueue tne frame to tne rx data queue '/ L4_PlaeePacketOnRιng( IpCall, i oid "iGET DATA PTR(p_pkt), p_pkt->uLβngthl ; ppp_rla_pκt ιp_pkt, 21; oreak; case PPP_IPX_PID: / • IPX Data Packet v p_ιpxncp~*. *p_lιnk->a_cpctltIPXCP_LAYER! ; p~ιpxacp • 4lpCall->appp.a_cpctl(ΪPXCP_LAYER] ; : i ,p_ιpxncp->cpstate '• CPJOPEN) ppp_rls_pkt(p_pkt, 31; orβax; I if (p ιpxaep->cpstate !- cp OPEN) I ρpp_rls_pkt (p_pkt, 3); ocean; 1 /• since the App side is guaranteed to be only talking PPP •/ / • tnot PPPML), tne packet is ready for delivery. Isn't it V /* nice tnat we don't nave any sequence nuaeers in tne pkt •/ /' to contend with! Me are merely a conduit nara. */ /* Enqueue tne frame to tne rx data queue */ L4_PiaeβPackβtOnRιng(lpCaU, (void *)GET_DATA_PTR(p_pfct) , p_pkt->uLβngtni ; ~ - ρpρ_rls_pkt ιp_pkt, 2); Dreak; caaa PPP NBF PID: / • Natbios Data Packet V p nβlncp " - ip link->a cpctl(NBFCP LAYER); pjnβfacp - 4IpCall->appp-*_cpctl(NβFCP_IATERl. • if Ip nβfnep->cpstatβ !• CP OPEN) I ppp_rls_pkt lp_pkt, 1); oreax; 1 if ip nbfacp->cpstate !• CP OPEN) ( ppp_rls_pkt(p_pkt, 1); orβak; I /* since tne App side is guaranteed to be only talkinq PPP •/ / • mot PPPML), tne packet ia ready for delivery. Isn't it *>/ / • nice that we don't have any sequence nuaabers in the pkt */ / * * to contend with* Ha are merely a conduit here. •/ / • Enqueue the fraaa to tna rx data queue */ L4_PlacβPackβtOnRlng(lpCall. (void • )GET_DATA_PTR(p_pkt) , ~ p_pkt->uLβngtni ; ~ ~ ρpp_rla_pktιp_pkt, 2); break; caaa PPP_LCEj.HO: / • Link Control Protocpl •/ /* suotract PPP Header frota packet length (total bytaa in pkt) • / p_pfct->utβngtn — PPPJHORLENj nppp_proc( IpCall, p_link. LCP_LAYER, p_pkt); break; " ".. ~ caaa PPP_CHAP_PID: /• Challenge Handshake Authentication Protocol */ if (p lncp->cpstate !" CP OPEN) ( ppp_rls_pkt(p_pkt. 6); Dreak; I / • subtract PPP Header from packet length (total bytaa in pkt) */ p_pkt->uLβngtn —» PPPJHDRLEN; nppp_cnap_proc( IpCall, p_..-*>-, CHAP_LAYER, p_pkt I ; orβak; case PPP_PAP_PID ; / • Passwora Autr.enticaticn Protocol •/ if lp_lncp->cpstate '- CP OPENi ( ppp_ris_pkt:ρ_pιct, " J ; Drean; ' • suDtract PPP Header from pacicβt length itotal bytes in pkt) •/ p_pkt->uLβngtn -« PPPJ-IDRLEN; nppp_pap_procl ipCall, p_iιnk, PAPJLAYER, p_pkt); oreax; case PPPJ3RCP_PID: • Bridge Control Protocol •/ ' • ao not act n tnis packet unless tne Net LCP is Open. */ if (p lncp->cpstatβ '« p OPEN) ( pρp_ris_pkt ιp_pkt. "> ) ; oreaκ; /• if wβ are not configured to support Bridging, drop the pkt V if (!(p ncβ->protocois 4 PPP PROT BR) ) ( ppp_rls_pkt lp_pkt, " ; break; ) p_acβ • 4(lpCali->appp); / • APPP CB •/ /* Before we respond to tnis request, tne state of tne coaabmed */ / • state machines must hava advanced to tne point tnat tnis NCP •/ / • is at least NCP STARTEO. • / if (p acβ->a emstatesIBRCP LAYERI < EM NETCP STARTEO) ! ppp_rls_pkt lp_pkt. "> ) ; break; I /* subtract PPP Header from packet lenqth (total bytes in pkt) */ p_pkt->uLβngtn — PPPJrfDRLEN; nppp_proc(lpCall. p_link. BRCPJLAYER, p_pkt); break; case PPP_IPCP_PI0: /• IP Control Protocol • / /* do not act on this packet unless tne Net LCP is Open. */ if (p lncp->cpatatβ !- CP OPEN) I ppp_rls_pkt(p_pkt. i ; break; 1 / * if weware not configured to support I P, drop the pkt * / if ( ! (p ncβ- protocols a PPP PROT IP) ) I ppp_rls_pkt (p_pkt, " >); break; 1 p_acβ » 4(lpCall->apρpι; / • APPP C8 */ /* Before we respond to tnis request, tne state of tne combined • / / * state machines must nave advanced to tne point tnat tnis NCP */ /• is at least NCP STARTEO. • / if (p aco->a βmβtatβsdPCP LAYER) < EM NETCPJSTAΛTEO) i ppp_rls_pkt (p_pkt. "> ) ; / • subtract PPP Header from oackβt lengtn (total Dytβs in pkt) •/ p_pkt->uLβngth — ?PP_HDRLEN; nppp_proci IpCall, p_link, IPCPJLAYER, p_pkt); oreak; case PPP_IPXCP_PID: / • IPX Control Protocol */ /- do not act on tnis packet unless tne Net LCP is Open. •/ if (p lncp->epstatβ • ■ CPJOPEN) ( PPP_rlS_pkt (p_pkt, 7); oreax; 1 /*> if wβ are not configured to support IPX, drop tne pkt •/ if (! (p ncβ->protocoιs 4 ?PP_PROT_IPX) I ( ppp_rls_pkt(p_pkt. 7, ; oreak; ) p_acβ - 4(ipCall->apppl; / ♦ APPP C8 ♦/ /• Before we respond to cms request, tne state of tne coe ned •/ /** state maenines must nave advanced to the point tnat tnis NCP */ /• is at least NCP STARTEO. • / if (p acβ->a βmatatβalIPXCP LAYER! < EH NETCP STARTEO) i ρpp_rls_pkt (p_ρkt, 7); Dreak; I / • subtract PPP Header from packet lengtn (total bytaa in pkt) */ p_pkt->uLengtn — PPP_HORLEN» nppp_procUpCall. p_lιnk, IPXCP_LAYER. p_pkt)j break; case PPP_N8FCP_PID: / • NβtBioa Control Protocol « / / • do not act on this packet unless the Net LCP is Open. */ if (p lncp--»epstatβ '« CP OPEN) { ppp_rla_pkt(p_pkt, 7); break; / ♦ if wa are not configured to support NaT, drop the pkt •/ if IMP nco->protocole 4 PPP PROT NBD ) ( ppp_r1a_pkt1 _pkt, 7 ) ; break; I p_acβ 4(lpCall->appp); / ♦ APPP CB •/ /* Bator* wa respond to tnis request, tna state of the coaβined • / /• state maenines must nave advanced to tna point tnat tnis NCP •/ /• is at laaat NCP STARTEO. */ if (p acβ->a β*aβtatβs(NBFCP LAYER! < EM NETCP STARTED) ! ρpp_rls 5kt(ρ_pk ' t, ); break; ) /* subtract PPP Header from packet length (total bytaa in pkt) */ p_p*t->uLβnςtn -• 999_HOΛl£Ms nppp_procI IpCall. ρ_link, NβFCP_LAYER. p_pkt); break; ease PPPJCCP_PID: / • Compression Control Protocol */ / • do not act on tn s packet unless tne Net LCP is Open. »/ if (p_lncp->cpstatβ '- CPjOPEN) I ppp_rls_pκt ιp_pιtt, 9); breai; 1 p_aco » 4 ; ;pCaii->appp) ; /• APPP C8 '/ ι- Sefore wβ respond to tnis request, tne state of tne CC? •/ / • emulation state machine must nave advanced to tne point •/ / • tnat CCP is at least LISTENING. • / if :p aco->a ematatβs(CCP LAYERI < EM LISTENING) ( ppp_rls_pkt ip_ρfct, ); break; I /• if wβ are not configured to support Compression, PROTO REJECT •/ if I ■ (p_-ιeD->oretocols 4 PPPJPROTJCP) ) goto rx_sβnd_proto_rβ] ; ' • subtract PPP Header f c packet length (total oytes in pkt! •/ p_pιct->uLβngtn — PPP_HDRLEN; nppp_proc! IpCail, p_ nk, CCPJLAΪER. p_pkt); oreak; default: rx_sβnd_proto_rβ-) : /• only send back a PROTOJAEJ if LCP is open •/ if I inep->epatatβ •« CP~OPEN) I ' • suotract PPP Header from packet lengtn (total bytes in pkt) "/ p_pkt->uLβngtn — • PPPjrIORLENj / • Get packet for tne sending of a PROTOCOL REJECT to peer */ if l(pjPR_pkt « ppp_gβt_pkt ( l i -■ NULL) break; /** need to copy info field from RX pkt into PROTOJΛEJ pkt */ / • make sure it doesn't exceed max negotiated lengtn • / p_froβ - ( (uβ •lp_pppndrι » PPPJrfORLEN; p~to - ((u β 'ISET Q ATA PTRIp PR_j * »*«- * > ♦ PPP_H0*LEN ♦ CNf JKDRLEN; if (p_pkt->uLβngth < p_neb->rβ» ιru) nuαabytee « p_pkt->uLβngth; else nuαaβytes • p_ncβ->rβm_mru; /• insert rβ-fβetβd-protocol after CNΓ_HDR • / • p_to*>*> « (swapl6(p_ppρndr->pιd) ) >> 5; • ^ o** • s * 4 j apl6(p_pppndr->pid) ; p_PR_pkt->uLβngtn ♦■ 2; /• eejpy info field • / for (i ■ 0; t < numβytβs; ι«->) • pjto** ■ *p_f ro*a->*; p_PR_pitt->uLβngtn »• nuaβytas; nppp sendreply I IpCall, p link, LCP LAYER, p PR_pkt, PROTO REJ. 0); I ppp_rls_pkt(p_pkt, 10); break; npρp_rx_mpp_frame - Process an incoming MPP frame frosi a link void • nppp rx mpp framβ( PCALLINfO IpCall, * ... *■ x C9 t • D_lιnk. 3CAPACKET 'p frame) I ιii->ppp); /• NPPP ca •/ p_mppndr - (S_MPPHDR *) (GET_"lA.TA_PTR(p_frame) ) ; /* make sure we are capable of receiving MPP packets */ if (lpCall->IscCallOata.dwεncapauιatιon '- PPPML EMULATION) ( ppp_rls_pkt lp_framβ, 11; return(NUL I ,*~ ) ' update most recently received packet for tnis link. p_link-> rr_sβqnum - ( ( (u32)p_mpphdr->sβqnι) << 16) I ( (u32)swaplβ(p_tapphdr->ββqlo) ) ; ' If we arø resynenronizing, don't accept anything but a packet begin if (p neo->mpp seq state •— MPP SEQ STATE RESYNC) ( if (p mppnβr->flags 4 MPP BEGIN PKT) ( p_ncβ->ι»pp_sβq_statβ « MPPjSEQjSTATEjSYNCj » p_link->mrr_seqnua; ua ♦ MPPjaiNOQt SIZE) 4 MPP MAXSEQj I else ( ppp_riβ_pkt(p_fraa4e. 1); return(NULL); I /•••• * Put packet in the receive window if it'll fit rla_βntry TRUEj if ( (ppp_iajβatweβn(p_ncβ->fra β_βxpectβd. p_lιnk->«rr_sβgnuja, t MPP_MINOCM_SIZE] ) ) /* if it could fit in the window, stick it in... • / offset p_lιnk-> rr_sβqnusι » MPP_NTNOOW_SIZEi p_neo->arrIved(offset| • TRUE; p_ncβ->Inβuf(offsetI - p_frame; // Save whole message rls_βntry FALSE; ~ // Don't ralaaaa it P MINOON SIZElli / • Release tnis pretender.. ppp_πs_pκtιp_tmp_framβ, 1); p_neβ->Inβuf[of sβtl » NULL; p_ncβ->arr ved(offsetI - FALSE; p_neo-> ramβ_expβetβd » MPP_SEQJINCR(p_ncβ->framβ_βxpβctβd) , p_nco->too_far - MPPJSEQ_INCR(p_-ιcD->too_farI ; perforfi M -pdate. * •* « mm(all most recently rcvd sβqnums) .- . - :, • M*JO _:NVAL:2SEQ; ι < ..pCali->num_lιnks; ι*—l :τplιnx - 41pCall->lιnk( ι| ; !p_tmplιnx->statβ •■ LK_STATE_UP) if IM — MPP_INVALIDSEQ) *-ι • p_cmplιnk->mrr_aβqnum; else if (Tp_cmplink->mrr_sβqnum * M) t 0x800000) ( /• wrap case • / if (M < p_t.*nplink->mrr_sβqnum) M » p_c*nplιnκ.->mrr_sβqnum; else normal case •/ ,p_ mpiιnk->mrr_sβqnum < M) M • p_tmplιnk->mrr_seqnua; /* perform M cleanup •/ if (M '- MPP INVALIOSEQ) I • A lost fragment is detected wnβn M advances PAST the ' sequence number of a fragment bearing an Ending bit • of a packet wnicn naa not been completely reaaseaeled (i.e., • not all tna sequence numeers between the fragment bearing ' tne Beginning oit and tne fragment bearing tne Ending bit • nave oeβn received). This is because of the increasing • sequence number ruiβ over tne bundle. for ii - 0, offset - p neβ->frame expected I MPP WINDOW SIZE; i < MPP WIN0OH SIZE; ι->) ( if (!p nco->arrιvβd(offsetI ) ( offset • (offset «• 1) » MPPJ*IN00 _SIZE; continue; p_tβp_frame • p_ncβ->[nβufloffsβ I ; p~tap~mppnor • Ts iPPHOΛ ♦ lGET_QATA_PTι ι jt»βp_framβ) ; offstjt - (offset * i) t MPPJ INOON_SIZE; if (p t p mppndr->flags 4 MPP END PKT) I tmp_seqnum • ( I (u32)p_tmpjιappndr->sβqlU) << lβ) l ( (u327swaplβ(p_tsap_a-ppMr->seqlo) ); /• M > tnp_seqnua of first pkt with Ending lit? •/ if (mpp is greater tnaniM, tap seqnua)) ( • Remove all packets from tne window up to M. * If M doesn't nave its Begin bit on, iscard all packets until BEG found. xoffset • p_ncD->framβ expected I MPP WIN00M_SI2E; for (-. • C;~- < MPP_WINDOW_5I2E; 7 * ->l~ if !'p nco->arrιved[xof fsβtl ) ( xcffsat « i xoffset - 1) 1 MPP_wiN∞W_stzε. p_ncs->f ramβ_expβctβd » ~ MPP_SEQ_ΪNCR l _ncβ->f ramβ_βxpβcted ) ; ρ_r.co->too_far ■ MPP_SEQ_INCRTp_nco->too_far ] ; continue; I p_t.*πp_f ramβ - p_ncb->Inβuf (xoffset I ; p^tmp nppndr » 7s_MPPHDR ♦ )βET_DATA_PTR(p_tnp_fran»β) ; trap_sβςnum ■ ( ( ( 32)ρ_tmp_nppndr->sβghl ) << 16) l ( ( u32~swaplβ (p_top_rr4ppndr->seqlo ) ) ; if (mpp_ιs_grβatβr_tnan(M, t*np_segnua) ) ! ~ ~ ~ ~ / • Release buffer at xoffset •/ ppp_rls_pkt(p_tmp_framβ, II; p_neβ->InβufI offsetI " NULL; p_nco->arrιvβdlxoffsβtl - PALSE; p_ncb->framβ_βxpβctβd « MPP_SEQ_ΪNCR(p_ncβ->framβ_βxpecte ); p_neβ->too_far « MPP SEQ INC*7p ncp->too farl; I else break; // found packet containing M xoffset - (xoffset * i) • HPP NZNOON SIZE; 1 f««« ' • ' * Starting at M, releaaa any non-ΘEβ* until BEG found * (xoffset and j are set by previous loop). for (; 3 < MPP WINDOW SIZE; )♦♦) ( if ( !p_ncb->arrιvβd(xoffsat| ) break; // don't know wnat to do hare p tap frame • p ncβ->Inb f(xoffaat1 ; p~t*ap~ι»-ppftdr - TsjIPPHC* • )GCT_OATA_PTΛ(p_tap_fraa»β); tmp_saqnua - ( I (u32)p_tmp_»appr4dr->eeghl) << lβ) I ( lu32lswapl«lp_ts«>_tappr»dr->ββ-lo) ) ; if (p_t*ap_mppndr->flaga 4 MPP_βEOIM_PKT) braax; // BEG found, gat out of hare... elaa ( /* Releaaa buffer at xoffset */ PPP_rls_pkt (p_taap_f raaaβ, 1); p_neβ- > I nbu f( offse I • NULL; ρ_ncβ->arrιved( offset I « ΓA SEJ p_ncβ-> ramβ_βxpectβd ■ MPP_SEQ_ΪNθ ( p_ncβ->f ramβ_βxpectβd ) ; p_neo->too_far ■ MPP SEQ INC Ip ncβ->too far); I - xoffaat - (xoffaat ♦ 1) I MPP WINOCN SZZC; > * Stt scat* to ACSYNC if wt couldn't find * Bβqin p-iCKtt in tn« wi dow. lf !} -• MPP_WINDOW_SIZE) p_-.CD- > mpp_seq_statβ « MPP_SEQ_STATE_RESYNC; oreax; I I 1 /• Get rid of it if it doesn't oβlong in window •/ if !ris_βntry) ppp_rls_px (p_£ramβ, 0!; return iNUL l ; • Chβcl for compi βtβ f rames : ' We nave a complete frame i wβ maren from frame expected and * find an END pactcet witnout any missing fragmenta. for li - O, offset - p nco->framβ expected % MPP WINDOW SIZE; l < MPP WINDOH~S:ZE; i•»•») " ( if ( !p_ncβ->arrlvβd[sffsβt] ) Dreak; p_tmp_frame « p_nco->Inβuf'offsetI ; p~tmp2*nppndr - ~S_MPPH0R • ) GET_-ATA_PTR<p_tmp_ rame) ; offset • (offset - il l MPP_WINDOH_SI∑E; if Ip t p mppndr->flags i MPP END PKT) ( / • give it up • / xoffset « p_neβ->frame_βxpeetβd % MPP_WINDCH_SIZE; wniiβ (xoffset '- offset) ( if 1 !nppp_aasβmelβ_mpp_pkt( IpCall, p_lmk, p ncβ->Inβuf[xόffsβtl ) I ( ppp rls_p(et(p_ncb->Inbuf[xoffset], 1); ) p_ncβ->Inbuf(xoffsetI ■ NULL; p_ncβ->arrιved(xoffset) • FALSE; p_ncβ->(ramβ_βxpβcted » MPP_SEQ_YNCR(p_ncβ->frame_βxpectedl ; ρ_ncβ->too_7ar • MPP_SEQ_INCR(p_neo->too_far) ; xoffset • (xoffset - li t MPP WI DOM S ZE; I /> if we got here, wa didn't reassemble any pkts return(NUU.) ; nppp_aaaeaB>le_rapp_pkt - Reassemble tne received MPP packet BOOL nppp assemble m*pp_pkt ( PCALLINFO IpCall, Link CB t *p link, GCAPACKET *p frame) I PPP CB t -*p_ncβ - -llpCaH->pppl; NPPP CB statιc _ GCAPACKET •p_aβs_pkt • 0; static ulβ nppp_ass_iengtn; S PPPHM •p_ppphdr; S~MPPHD* • ρ_mρpftdr; uβ •p_nβwdata; uβ •p_.*nsgda a; uβ •p_snortpιd; β flags; p_mppndr - (S_MPPHDR •) oET_3ATA_PTR:p_framβi ; flags » p_mppnor->fiags; /• check for NULL fragment < no payioad pxt used for sync purposes ! - 1 if (((flags i (MPP 3EGIN PKT : «PP END PKT)) -« (MPP_BEGIN_PKT~! MPP~END_?KT) )~44 ι _framβ->uLβngtn -•» MPP_HDRLEN) ! returnl FALSE) ; : ! ! flags 4 MPP_9EU:N_?KT) •• Strip off tne MPP header tnen prepend tne PPP neader to tne put p_snortpιd « (uθ • ) ( _-nppndr - ! ) ; /• LSBlt is set if last oetect in PID */ if cp snortpid - 1) ( PUT_3ATA_OFF ( p_framβ. IGET_0ATA_OFF(p_framβ)♦MPP_HDRLEN-3) I ; p_framβ->uLβngth -- ιMPP_HDRLEN-3) ; */ ) ; else /* long pid format '/ ( PUT DATA OFFlp frame, (GET QATA_OFF(p frame>*MPP HD LE -2)); p_framβ- uLβngtn — (MPP_HDRL£N-2) ; /* make this look exactly Ilka a PPP pkt */ p_pppndr • (S_PPPHDR • ) ( *p_mppήdr->sβglβ); p_pppndr->addr - H0LC_ALL_AOOR; p_pppndr->eontrol ■ HDLC_UI; / I else / • ri ust strip of f MPP header • / PUT_CATA_OFF( p_f ramβ, ( GET_0ATA_OFF( p_ rame ) *MPP_HDRLEN ) I ; p f rame->uLβngtn — MPP HORLEN; ~ I /* copy data pkt into nppp ass_pbuf */ if I I flags 4 (MPP BEGIN PKT I MPP END PKT)) ~ (MPP BEGIN PKT I MPP END PKT)7 ( /* let the PPP pkt processing handle (and release) tnis pkt "/ nppp_rx_pkt(IpCall, p_iιnk, p_frame); return!TRUE); I else I if (!p_a#a_pkt) i if (! (flags 4 MPP BEGIN PKT) > I /* don't start assembling a new packet if it la */ /* not tne beginning of tne wnole packet */ return(FALSE); 1 / • Get packet for tne sending of a PROTOCOL REJECT to peer •/ if (ip_aβa_pkt - ppp_get_pktt i ) «- NULL) return(FALSE); p_aβs_pkt->uLβngth « p_framβ->uLength; P_msgdata • icnar • )GET_2ATA_PTR(p_fra βi ; p_nβwβata • icnar • : E ^A A^PTR<p_ass_p*t) ; m β mcpyιp_nβwoata, p_.i>sgdata, p_ ramβ->uLβngtn) ; nppp_ass_iβngtn • p_Jramβ->uLβngtn; else I p_msgdata - icnar * )GET_3ATA_PTR(p_framβ) ; p_nβwβata » icnar • )GET_DATA_PTR(p_ass_pktI ; mβ cpyl ιp_nβwdata ♦ nppp_ass_iβngth) , p_msgdata, p_framβ->uLβngtnι ; •>ppp_ass_lβngtn ♦- p_framβ->uLβngtn; p_ass_pxt->uLβngth ■ nppp_ass_iβngth; if I iags 4 MPP_END_PKT) i / • let tne PPP pkt processing nandlβ (and release) this pkt •/ nppp_rx_pxtUpCali, p_iιnκ, p_aββ_pkt); /' reset global ptr so tnat a new pbf is allocated next time •/ p_ass_pxt « NULL; 1 1 1 return! FALSE); I nppp_ιmtcβ - Initialize tne PPP control bloek void . Link CB t *p link) - 4(lpCall->ρpp); /* NPPP α •/ p_ncb->mpp_sβqnuβ a 0; p~ncβ->mpp-sβ4-j_statβ - MPP SEQ STATE SYNC; p_ncβ->ipx2fraaung - PPP_IPX_FRAME_ETHER_II; / ♦ Return port to inited stage ( tnis resets •/ / • ctl blk vars and kills outstanding timers ) . •/ nppp_ιnlt_all_layβrs < lpCaU , p_l ιnk. CP_ΣNITIAL) ; / * init tne data control block associated witn this PPP_eb ' / SI2E; for Udx - 0; idx < MPP WINDOW SIZE; ιdx**> ) ( p_neβ->t nbuf 1 ldx l • NULL; p_ncβ->arrιve l ιdx | • FALSE; i ~ InltlallzaListHeadl p_neb->txql ; p_ncβ->num_tx_pkts_on_q • O; p_nco->comprβssιon. inited • FALSE; p~ncB->compressιon. ompressing ■ FALSE; /•• 0YN_CFG: We will fill this in as we iβarn it *•/ p πcB->comprβssιon.aigorιt.-tm « 3; nppp_gβt_nβxt_iιnk - Get tne next l nk for tx data • .ιnιc_CB_t *nppp_gβt_nβxt_iιnk l PCALLINFO IpCall, BOOL ιncr_flag) { ~ ~ ~ PPP_CB_t *P_ncβ - 4(lpCall->ppp); /• NPPP CB Lmk_C8_t *p_lιnk; uJ2 ~ ~ num_lιnks; u32 Lmic_no; iιnκ_no • ρ_nco->last_tx_l nκ; for (num links » lpCail->num_lιnks; num_links; num_iinks--) i iιnk_no*>-* ; Unk^no »• lpCall->num_lιnks; p link - 4ipCal l-> lιnk [ lιnk no| ; I f I p lιnk->statβ — LK STATE UP) I i f ( ιncr_f lag) p_ncβ->last_tx_l mk • l mk_no; return i p_lιnk ) ; /• No link is up. Links are transitloning to down, return NULL */ return(NULL); nppp_cleanup_queues - Stop all links for this connection void nppp cleanup queues(PCALLINFO IpCall) ( PPP CB t 'p ncβ - 4(lpCail->pppι; /• NPPP CB GCAPACKET *PJ>kt; for (ι • 0; 1 < MPP MINOON SIZE; l**> ( if (p ncβ~>Inbuf|i! '- NULL) ( p*pp_rlβ_pfct(p_neø->tnβuf(11, 0); p_neβ->Inβtjf111 - 0; 1 nppp_init_all_layβrs — Initialize all layers for tne specified port. void nppp_ιnit_all_layβrsIPCALLINFO IpCall. Lmk_CB_t 'p^lnk. CP_statβa_t cpatate) PPP ca t •p_neβ • llpCall->pppl; PPP Cl nppp_raaat(IpCall, p_llnk, LCP_LAYER, cpatate); nppp_rβsβ (IpCall, p ' link, PAP^LAYER, cpstate); nppp~rβsβt( IpCall, p~lιnk, CKAP_LAYER. cpstate); nppp_rβsβt( IpCall, p ' link, BRCP~LAYER, cpstate); npppZcβββttIpCall. P^lmk, IPCP~LAYER. cpstate); nppp_r β a β t ( IpCall. p_lιnk, IPXCP LAYER, cpstate); nppp_rβs β t(IpCall, p_link. NBFCP~LAYER, cpstate); nppp_rβsβt( IpCail, p_lιnk, CCP LAYER, cpstatβl; I • nppp_rβsβt — Reset the con iguration options for initial request for tne specified port. •/ /013 nppp_cβsβt i PCALLINFO IpCall, -,ιn-._CB_t *p_lιnk, ?PP_layβr_ layer, P_statβs_t cpstate) PPP CB t *P_ncβ - 4(lpCaii->ppp> : / • NPPP CB • APPP_CB_t 'place - 4(lpCall->apppι ; / • APPP CB •/ 3_CPCTL -p_ncp « 4p_lιnk->a_cpcti ! layer1 ; p_ncp->cpatatβ • cpstate; p^ncp->ack_retry « 0; if (p_ncp->tιmβr_ιdl.active) / • Kill any existing CP timer •/ clr_nppp_tιmert IpCail. p_lιnκ, layer, PPP_TIMER1 I ; .f (p_nep->tιmβr_ιa2.active) /* Kill any existing CP timer •/ c~r_r*ppp_ ιmβrI IpCail, p_lιnk, layer, PPP_TIMER2I ; switen (layer) case LC?_LAYER: /• Reset our config request params to our preferred values •/ p_ncβ->nβg_mru - 1; /* always try to negotiate MRU •/ p_neβ**>tx_ac_eoπ»p • 0; p_ncβ->tx_prόto_eoβ** « 0; p_ncβ->rx_ac_co*ap ■ TRUE; p_ncβ->rx_prό ' to_comp « TRUE; p_neb->ββnd_βndpt • FALSE; /•• DYN_CFG: We will fill this m aa we learn it from Net ••/ p_ncβ->auth_ lags • 0; ρ_neβ->autn~compl_flags » 0; /•• DYN_CFG: Wβ will fill this in as wβ learn it from App •• >/ p_acb->protoeols • 0; p_ncβ->rβm_mru » DEF_MRU; p ncβ->lcl~mru « 0EI"_MRU; / « set incoming and outgoing MRU max to MAX_FRAME_LENGTN ♦ / /* plus aitner PPP header • / if (lpCall->IscCallData.dvCncapβulatlon — PPPML_EHULATION) p ncβ->send endpt • TRUE; else ~ p_ncβ->ββnd_βndpt - FALSE; break? ~ caaa CHAP_LAYER: braak? case PAP_LAY*R: break; caaa BRCP_LAYER: break! caaa IPCP_LAYER: / * Sat up for I P addr exchange * / p_ncb->nβg_ip_addrs ■ I ; p ncB->peer_negotiated_lp_addr • FALSE; / •• DYN_crC: Wβ wil l fil l this m aa we learn it f rββ) App • • / p_ncb->my_ιp_addr « 0; p_ncβ->pβer_ιp_addr • 0; oreak; case IPXCP_LAYER: / • Set up for IPX ne work and node r-.umoer excnangβ; ' i p_ncβ->nβg_ιpx_nβtwor>* » I; p~nco->nβg_ιpx_ncoe « 1; p~ncp->pβ β r_negotiated_ιoxnβt_aodr « FALSE; p~ncβ->pe β r_nβgotιated_ιpxnodβ_addr • FALSE; /•• 0YN_CFG: Me will fill tnis in as wβ learn tnβm •*/ p_ncβ->my_ιpx_nβtwork • 0; p~nco->pβer_ιpx_nβtwork • 0; mβmsβt(p_neb->my_ιpx_nodβ, 0, SZ_IPX_NO0ENUM) ; mβmsβt(p~ncβ->peβr_ιpx_nodβ, 0, 52_IPX_NODENUM) ; break; zaaø NBFCP_LAYER: p_neβ->nβg_namβ_pro*| » 1; p2nco->nβg_pββr_ιnfo • 1; p_ncβ->pββr_nβgotiated_noname FALSE; p_ncβ->nβ_pβer_name(0l - 0; mβmββt ιp_ncβ->nβ_pββr_ciuttβr, 0. SZ NBF CLUTTERI J oreak; " case CCP_LAYER: /*• 0YN_CFG: Wβ will fill tnis in as we learn all of these ••/ p_neβ->eep_rβq_lβn ■ 0; p_neβ->ccp_num_hlsts » 0; p_ncb->βtae_chβck_val » Oj p_neβ->t»ppc_rx_eonβrβney ■ 0; p ncβ->mppc_tx_cohβrβney » 0; p~ncβ->stac_decoιβp_pauβed_ιd •> 0; p ncβ->aacβnd_rβsβt_modβ » 0; break; I nppp_cβstart -- Reinitialize layer state machine for config exchange for tne specified port. void nppp_rββtart(PCALLINFO IpCall. Link_C8_t • p_link, PPP_layβr_t layer) PPP CB t *p_neb - 4<lpCall->ppp); /< NPPP CB • / S CPCTL *p~ncp - 4p_link->a_epctltlayβrl; /• Something want wrong; restart negotiationa switcn (layar) ( case LCP_LΛYER: / • Roaac CP state macnine for configuration negotiation •/ nppp_rβaβt(IpCall. p_lιnk. LCP_LAYER. CP_CLOSED) ; nppp_rβββtIIpCall, p_link, BRCP LAYER, CP CLOSED) ; nppp_rβaβt(IpCall, p~llnk, I PCP~LAYER. CP " CLOSED) J nppp_rβaβt<IpCall, p~lιnk, I PXCP LAYER, CP CLOSED) ; npρ-p_rβaβt(IpCall. p^link, NBFCP " LAYER. CP~CLOSEDU np*pp_raaat(IpCall. p_lιnk, CCP_LAYER, CP_CLO«D)j breakj caaa mCTJXt A: /* Raaat CP ataea mac ine for configuration negotiation •/ nppp_rβaβ IIpCall, p_llnk. BRCP.LAYER. P_CLOSE0); break; case IPCP_LAYER: /* Raaat CP state maemne for configuration negotiation •/ nppp_rβββt IIpCall. p_l nk. IPCP_LΛYER. CP_CLO3E0l; breakj caaa IPXCP_LAYER: /* Raaat CP state macnine for configuration negotiation •/ nppp_rβaβt IIpCall. p_lιnk, IPXCP_LAYER. CP_CLOSEO) ; break; case NβrCP_LAYER: /* Raaat CP state macnine for con iguration negotiation */ nppp_rβaβt IIpCall. p_Unk. NBFCP_LAYER. CP_CLOSEDIJ orβak; case CCP_LAYER: / • Reset CP state macnine for configuration negotiation •/ nppp_r β s β t! ipCall, p_.ini-., CP_CLOSEO) : Dreak; ) /» Unexpected NPPP Link Down, Restarting Link •/ •*ppp_start — -r.itiaiizβ layer state macnine for config βxcnangβ for tne * specified port. •/ int nppp_start ( PCALLINFO IpCall , Lιnk_CB_t -p_i nk, PPP layer - .ayer, CP states t cpstatβ l ( PPP_C8_t "P_neβ - 1 lpCall->ppp) ; / • NPPP CB ■ / S_CPC L *p_ncp • 4p_imk->a_cpctl [ layβrl ; switcn I layer ) ( case CHAP_LAYER: if (p~nep->autn_flags « AF_CHAP PEER) ( / • Start timer against wait for reply to our config request V set nppp timer( ~(PPP~RESTAAT TIMEOUT • PPP MAX CF5 COUNTER). IpCall. p link, (u32)layer7 PPP TIMER2I ) break; case PAP_LΛYER: if (p neo->autn flags 4 AF PAP PEER) I / • set new CP state • / p_ncp->cpstatβ « CP_REQ_SENT; returnInppp sendpapreql IpCall, p link)); I break; default: if lp_ncp->cpβtatβ « CP STOPPEDI ( /* Stopped; wait until resaota attaaapta connect •/ /* fall thu to "return 0" • / 1 else ( / » sat new CP state •/ p_ncp->cpβtatβ ■ CP_RE0_SEWT; /* state should « CLOSED, begin CP configuration negotiation •/ return(nppp aendreqiIpCall, p link, layer)); I break; return 0; > nppp_opβn — Transition to OPEN state. void nppp open(PCALLINFO IpCall, Link CB t 'p link, PPP layar t layar) ( PPP CB t *p ncβ • *(lpCaU->pppl; / ♦ NPPP CB • / APPP_d_t "place • » UpCaU->apppl; / • APPP CB • / cnar " ~ ouϊlβOI; switen (layer) ( case LCP_LAYER: / • if tnis is an expanded link, worry oniy aβout the Net side •/ if I (lpCall->IscCallData.dw£ncapsu;ation — ?PPML_EMULATION) 4 4 (IsPπmaryLinkl IpCali, p_:mki » - FALSE) ) ( /* LCP is open; s it h to *ιext pnasβ, •/ / • Startup CP negotiations • / / • If Autnentication is required, start tne appropriate CP •/ if :p ncβ->autn flags 4 AF CKAP_PEER) nppp_start;IpCall, p_ιlπι , CHAP_LAYER, CP_CLOSEDI ; if (p ncβ->autn flags 4 AF PAP PEER) nppp_start [IpCall, p_lϊnk,~PAP_LAYER, CP_CLOSE0) ; /* If autnentication is not required •/ if (!p neβ->autn_flags) ( /* reset the call retry counter so subsequent expanded */ /* calls can be placed. */ ρ_ncβ->call_rβtry_cnt • 0; if !p nco->protoeols 4 PPP PROT BR) I /• NPPP - Expanded Bridging Link UP •/ p lιnκ->a cpetlORCP LAYER! .cpstate - CP OPEN; I if (p ncβ->protocols 4 PPP PROT IP) I /• NPPP - Expanded IP Link UP •/ p link->a cpctlCIPCP LAYER) .cpatate - CP OPEN; ) if (p neb->protocola a PPP PROT IPX) ( /• NPPP - Expanded IPX Link •/ p link->a cpctllIPXCP LAYER! .cpatate CP OPEN; ! if (p neβ->ρrotocols 4 PPP PROT Nβf) ( /. NPPP - Expanded NetBEUI Link UP • / p iιnk->a cpctllNBFCP LAYER! .cpatate • CP OPEN; I if (p ncβ->protocols 4 PPP PROT CCP) I " / * NPPP - Expanded Compression Link UP */ p llnk->a epctl lCCP LAYER! . cpatate - CP OPEN; I 1 ) else /* This is tne first link, bring up the App LCP ♦ / ( / • start tna App side LCP now tnat we are up (STEP 2): */ appp start(IpCall. LCP LAYER. CP CLOSED); ! break] caaa CHAT LAYER: caaa PAP_LAYER: /* At tnia ia a auppleaiental MPP enannel, do not • / /• bring up the NCP's for this link; go straignt to OPEN • / if ((lpC#ll->IβeCaHOata.dwtncapβulation — PPPML EMUIATION) at (IaPrls ryLlnklIpCall, p link) « FALSE)) ( /* NPPP • Expanded Autnentication Coaaplete */ if (p ncβ->protocols 4 PPP PROT BR) I - /• NPPP - Expanded Bridging Link UP */ p_link->a cpctllBRCP LAYER) .cpatate - CP OPEH; ) if (p ncβ->protocols 4 PPP PROT IP) I / • NPPP - Expanded !P Link UP */ p_link->a_cpcti(IPCP_LAYER| .cpstate ■ CPJDPEN; /• AC Compression •/ ; / • Protocol Compression •/ i f i ncβ->rx_proto coeap) ( • cp*. * a PR0T_C0MPRE3S» •cp— « 2; opt cnt ♦• 2 1 break; case BRCP LAYER: / • MAC Typa • / •cp— - BR_MAC_TYPE; •CP— " 3; ♦ ep— - BRD_MAC_β023; oρt_cnt *" 3; break; case IPCP_LAYER: /* If the Nat ia allowing us to exchange IP Addra and the App gave • / /* ue an IP or requeated one. go for it. • / if (p ncb->nβg ip addra 44 p acβ->peβr negotiated ip addr) ( •cp** - IP_A00M_MOI> •cp*-* - •; " ~ /• have to do tnis in enars or else fields gat • / /* overwritten whan tney align •/ •cp— « (p_neβ- «y_ip_βddr » 24 ) ; •cp** - ( p~neto-:»*a*y2-ple '3 r >> 16) ; •ep— ( ncb->mr ~l.p~aθΛ' » β ) ; •cp— " p_nco->β"γ_ϊp_addr; opt cnt ♦■ 6; ) break; case IPXCP_LAYER: /• If the Nat is allowing us to exchange IPX Net Addra and the */ /• App gave ua an IPX Net Addr or requested one. go for it. • / if lp_neβ->neg_lpx_nβtwork 4 p_aeβ->peβr_nβgotlatβd_lpxnβt_eddr> 1 •cp— - IPX NTT_NUX; •cp*- - 6; / • nave to ao tnis in cnars or else fiβiβs get **/ / • overwritten wnen tney aiiαn • ' • cp— - (p_ncβ->my_ιpx_nβtwor»; >> 241; •cp— ■ (p~ncβ-> y_ιpx_netvorκ >> 16); •cp** i tp~ncβ->my_ιox_nβtworκ >> 81; -> y_ιpx_netvork; / » If the Net is allowing us to excnangβ IPX Node Addrs and tne •/ • App gave us an IPX Node Addr or requested one, go for it. •/ if 'p_ncD->nβg_ιpx_nodβ 44 p_acD->pββr_nβgotιatβd_ pxnooβ_addr) I • cp*- - IPX_NODE_NUM; • cp— ■ 8; ■ nβmcoy ( l u8 • I cp, p_ncD- >my_ιpx_nodβ, S2_I PX_NODENUM) ; apt_cnt *« 9 ; I break ; zasø NBFCP_LAYEA: i f ( p_nco->nβg_namβ_pro") ) ( /• project 0 NetBIOS names to remote peer •/ •cp— - NBF NAME PROJ; •cp * * - 2; opt cnt ♦■ 2; 1 /• If tne Net is allowing us to exenange NBΓ Names and tne App gave •/ /• us a NBF Name, go for it. •/ if (p nco->nβg_pββr info (4 p aeb->peer negotiated nbna-aβl ( •cp— « NBΓ_PEER_INΓO.* p_lβn " ep;~ ~ /• remember wnere the lβngtn is •/ •cp— • 8; mβ cpylcp, p acβ->nb_pββr clutter, SZ NBF CLUTTER); cp — S2_NBF cLU τER; opt_cnt * " ■ 87 nb_namβ_lβn ■ strlβn(p_acβ->nβ_pββr_namβ); ; tne string and nclude in count •/ •p_lβn « p_lβn * nβ_namβ_iβn ♦ I; opt cnt ♦•» nβ_namβ len ♦ I; I I break; caaa CCP_LAYER: / * Coaapraaalon Type •/ switcn i ncβ->co«prβββlon . algorithm I ( caaa COMPRESS STAC: • cp** • CCP_STAC_CCMP; •cp** « p_neβ->cep_rβq_lβn; • cp** » ( p_neβ->ccp_nuβ_nιsts >> 8 ) ; • cp** » p_neβ->ccp_nusι_nιsts 4 Oxf f ; •cp* * • p_ncβ->βtac_cnβck_val; break; ~ case COMPRESS MICROSOFT: •cp * * - CCP_HS_CCMP; •cp** ■ p_ncβ->eep_rβq_Lβn; • cp * * • o~ ♦ CP— • 0; • CP— • 0. • cp** - PPc_ME ioτiAτε_r' iP; Drβax; case 3', Oxff; β: spt_cnt •« p_-iCD->ccp_req_len; Dreax; return(opt_cnti , ) /• nppp_sβndcnapresρ — 3uιlt and send CHAP RESPONSE packet. •/ int nppp_sendcnaprβsp(PCALLINFO .pCali. -•nn_:B_: *p_iιnfc, uβ 'resp val, -B idi ~ ( NPPP CB /• Get packet for CHAP AUTH_ACK/NAK •/ if (lp_pxt - ppp_gβt_pkt!) )~~ NULL) return(-1); p_cfgβasβ • ρ_cfgopts • ((uβ •lGET_-jATA_PTR(p_pkt) 1 * PPP_HDRLEN ♦ CNF_HDRLEN; /• load Auth Request params into βuf •/ • p_cfgopts»* » S2_MD5_2IGEST; /• size of value βmcpylp_cfgopts, cβsp_vai. SZ_1D5_-!IGEST); /• value •/ ρ_cfgopts * - S2_MD5_OIGEST; strepy(p_efgopts. lpCall->tβcCallOata.usβrnaaa>; /• nas p_cfgop a * • strlβn(lpCall->IacCallData.uaβrnaβ>e); /• detemlne number of bytes for options data •/ p_pkt->uLβngtn « p_cfgopta - p_cfgβasβ; /• Send CHAP RESPONSE to autnenticator • / rβturn(nppp_sβnorβplyιlpCaH. p ιιnκ, CHAP LAYER, p_pkt. CHAP_RESPONSE. ιd));~ I /* p_sendpapreq — Build and send PAP AUTH_REQ packet. int k) /• NPPP CB •/ PAP LAYER); /• Get packet for PAP AUTH_REQ •/ if ιιp_pkt « ppp_gβt_pkt()T ■- NULLi rβtumi -I i ; p cfgoasβ - p_cfgoots - I luβ • IGET_2ATA_?TR(p_pktl ' • ?PP_uCRLEN • CNF_HDRLEN; /• load Autn Request params into o f • / peer_ιd_ien - str.en: -cCal.->IscCaliCaca.userπameι ; •s_sfgopts— " peer_.a_len; strcpyιp_cf5opts. .pCaTl->IscCaiiData.jsβrnamβ) ; p_.f-jopts -* oeer_:3_.βn; opp_αβcrypt_p d(npρp_pn-d, ipCall->IscCallData. assword) ; pva_len • strlenιnppp_pwd); • s_cf-jopt3— » owo_ιβn; str pyιρ_-*fgopts, .- > ppp_pwd); p_cfgopts *■ pwo_iβn; /• aetβrmine number of oytβs for ODtions data •/ p_pιct->uLβngtn » p_cfgopts - p_efgoasβ; / • Start timer against wait for reply to our config request •/ sec nppp timerlPPP RESTART TIMEOUT, LpCali, p link, (u32lPAP LAYER. PPP TIMER1); /• Send PAP AUTH_REQ to authenticator •/ return(nppp_sβnorβply( IpCall, p_ιιnx, PAP_LAYER. p_pkt, PAP_REQUEST. 0)); nppp_sβndrβply — Send a PPP Control packet to the peer •/ int nppp_sβnorβpiy( PCALLINFO ipCall, Lιnk_CB_t •p_lιnk, PPP_layβr_t layer, GCAPACKET *p_pkt. β cooβ, uβ ιd)~ ( ?PP_CB_t -p_ncb »(lpCall->ppp)j / • NPPP CB 3 PCTL "p ncp - ip i mk->a cpctl ( layer I ; S TNFHDR • p ' cnfhdr; -ι 3 2 ♦ pjnagicnum; .22 pid; ρ_cnfhdr » (S_CNFHDR -Miluθ • )GET_OATA_PTR(p_pkt) ) * PPP_HORLEN); c ' mag cnu • 7u32 ')(((uβ 'Ip^nfhdr) ♦~CNF_HDRLEN); ' • Load CP header values •/ p_cnfhdr->codβ • code; switcnicodβ) I case CONFIG REQ: / • AKA: CHAP CHALLENGE i PAP REQUEST • / case TERMNATE_REQ: / • Save 10 field for matcn against replies from remote nost */ p_nep->laatld • p_ncβ->pppld; p~cnffιdr->id " p_nco->ρppid—; break; caaa ECHO REQ: if (layer !- LCP_LAYER) goto rβply_dβfault; /* Save 10 field for natch against replies froa remote host • / p_ncp->lastid « ρ_ncb->pppld; p_cnfhdr->ld • p_ncβ->pppιd* * ; •pjnagicnum ■ 0; / • no need to svap32 ( 0 ) * / ; p_pkt->uLengtn ♦« sizeof ( u32 ) ; / • add magi enum to pktlβn •/ oreak; case PROTO REJ: i f I layer • - LCP_LAYER I goto rβpl y Sβfault ; p_cnfhdr->ιd ■ p *ιcβ- >pppιd— ; oreak; case OISCAROJXEQ: p_cn fhdr-> ιd « p ιco->pppιd— ; oreak; case ZZ? RESET_REQ: if (layer ■ • CCP_LAYER> goto repiy aβ fault; / • if tnis is tne first in tne series, savt oft the RεsεT REQ 13 •/ if ip nco->stae 3βcomp paused id « 0) ~ ( if ιp ιcD->pppid ■■ 0) p jιco->pppιd*» ; pj-ιcD->stac a β comp ausβd ιd » p ;nfhdr->ια ■ p nco->ppp d; pj-ιco->pppιd»-; ρ .nfhαr->ιd • pjιco->stacj3βeompjauaed id; orβai ; ~ case CONFIG ACK: / • AKA: CHAP RESPONSE . PAP ACK ♦/ case CONFIG NAK: / • AKA: CHAP SUCCESS - PAP NAK •/ case CONriG~REJ: / • AKA: CKAP~FAILURE •/ case TERMINATE ACK: case CODE_REJ:~ pjrnfhdr->ιd « id; break; case ECHO REPLY: if l 1 ayer ' - LCP_LAYE l goto rβpl _defaul ; p :nfhdr->ιd • id; • pjnagicnum • 0; / • no need to swap32(0) •/; p pκt->uLength *- sizeof I u32); /• add agicnua to pktlen •/ srβak.* case CCP RεsεT ACK: if (layer " ■ CCP_LAY8R) goto rβplyjaefault; p :nfhdr->ιd ■ ia; break; default: reply j aefault: protocol • / ppp_rla_pkt(p_pkt. 14); retur (-1) ; I /• fra βslzβ - length of options field */ pj,nfhdr->lβn • swaplβl (αl6) (CNr_HDRLEN * pjjkt->uLength) ) ; /• update buffer frame Size (total bytes in pkt) •/ p_pkt->uLβngtn *« C F HORLENj /• Adjust tna packet offsets so that tney are aligned with • / /• all the other metnods of getting a packet to npp J end jkt. •/ /• Specifically, set tne ap jaatajtr to start of C ?H0R •/ PUT DATA OFF(p_pkt, (GET_OATA OFFΪp pkt I 'PPP HORLEN)); return ι nppρ_sβndj-.t : ipCall, p_ιιnκ, p j Dkt, , -iδlpld) ] ; I /. -.ppp j sendtermaci* -- Send a TERMINATE A.CX to .-.β peer • / * r.ppo j 5βnd:er*nack( PCALLINFO ipCall, ' ..rκ_Z3_z • o_.ιr.k. ??P_.ayer - -ayer, TPj-xatβs i cpstate; rPP TB t -pjlCβ " 4 I lpCali->ppp] ; /• NPPP 3 •/ S CPCTL 'p cp ■ *p_-ink->a rpetl ! layer! ; 3CAPACKET '0_tx_pkt; " Get packet for terminate ack • / if (ι _tx_pkt - ppp jβtjKtI ) ) ' - NULL) /• try to send out TERMINATE λCK pkt ♦ / nppp j jenoreplyl IpCall, p_lιnι , layer, p txjpkt, TERMINATEJ-.CK, 0); p j -ιcp->cpsta β cpstate; return; ιppp * βnocodβre 3 — Send a CODE REJECT to the peer npppj-βndcooβrβ-j I PCALLINFO IpCall. Lιnκj".8 - • p_lιnk, PPP layer t layer, GCAPACKET *p kt. CP states t cpstate) I ?PP_C8_t *P_ncb • *llpCall->pppl; /• NPPP C8 S TPCTL *pjιcp • tp_iιnk->aj:pctl ( layer! ; 5~PPPH0R ' jppnd ; GCAPACKET 'pj-Rjpkt; u8 • p from; u9 » p to; .22 ι;~ sJ2 numeytea; pjppndr - (S PPPHDR • ) (GET_OATA_PTR(p_pkt) ) ; / • Get packet for coda rβ*)βct • / -f ( (p_CR_pkt - ppp_gβt_pkt ( ) ) ' - NULL) / • need to copy info field from RX pkt into PROTOJXEJ pkt • / / • make sure it doesn't exceed max negotiated lengtn •/ p_from « (lluβ • >p_pppftdrl ♦ PPP_HDRLEN); p to - (((uβ '1GET DATA PTRIp CR j kt)) * PPP_HORLEN ♦ CNF_HORLEN); if (p_pkt->uLβngth < p ιcβ-> remjnru) numoytes • p_pkt-> Lβnqtn; else numoytes • pj*ιcθ->rea j *ru; / • insert, rejected-protocol after CNF JOR •/ • p_to*>* - p_ppphdr->pid >> 8; •p^to** - pjpρftdr->pid t Oxff; p_CRjkt->uLβngtn ♦■ 2; / • copy info field • / for i i ■ 0; i < numoytes; -♦*) • p eo** • • pjfrom; p_CRjkt->uLβngtή ♦■ numoytes; nppp sendreply! ipCall, p link, layer, p CR_pkt, COOE ^EJ. 01; I ρj"ιcρ->cpstate ■ cpstate; return; t * nppp -βndresβtreq — send a CC? -*ESET REQ to tne peer void nppp jβndrβsβtreq I PCALLINFO IpCall, ink TB e *'p_llnk, ?PP_layβr : .ayer) = ?? _---_- 'SJJS » 4 ( * pCal.->ppp) , / • NPPP C3 GCAPACKET -o tx pkt; αl6 • pjiistnum; ' • Get oacite*; far reset req • / .; ■ p -.xj κt • ppp_cβtjpkt ! ) i '- NULL) - • -lβed • : i... --ι cata area witn history numpβr •/ p iistn m - * lό 'IGET 0A7A PTRlp tx pktl) ♦ ?PP_-<DRLEN »~CNF_HDRLENT; ' • insert -istory numper tnat wβ are resetting * • / • p ustnum-— • swaplβ i p ιco->ccpjumjMatS) j p tx j pkt->uLenςtn -■ sizeof I ulδi ; /• try to send out CCPJ^ESET ^EQ pkt •/ •> ppp_sβnαr β pιy ( IpCall, p_lιnk. layer, p_tx_p*t, CCP_RESET_REQ, 0); nppp sβndresβtacK -- Send a CCP RESET ACK to tne peer •/ void nppp aβndrβsβtackl PCALLINFO IpCall, LinkjCBjt *p_Unk, PPP layer t layer. GCAPACKET 'pjkt)- ( ?PP_C8_t *P_ n <-» " *<lpCall->ppp); /• NPPP C8 */ GCAPACKET -p cx jjkt; uβ -p_from; uβ *p to; .22 i.* " s32 numoytes; ' • Get packet for reset ack • / -f l lpjix pkt - ppp jβt j kt ( ) ) '• NULL) i i" Copy the data field from the RESET ^EQ pkt • / p from • ((luβ "IGET 3ATA PTRip j pkt I ) " ♦ PPP iORLEN * CNFJ-ID LEN); p_to - I (luβ -IGET DATA PTRlp txj kt)) ♦ PPP_HDULEN ♦ CNF ΪDRLENI If ( (p kt->uLβnqth - CNf ^lDRLEN) < pjιeβ->rβtajar l nuaβytβa • p_pkt->uLβnqtn - CNF HORLEN; nuaaoytββ ■ p jιcb*>>rea nru; /• copy data field •/ for (1 0; l < nuaeytea; ι*>*l • p to**- ■ -p froa; p txjkt->uLβnqtn »• numoy es; /• try to send out CCPjrESETjsvCK pkt • / nppp sendreply ( IpCall " , p link, layer, pjtxjkt. CCP ESET KCX, 0); I return; nppp eimβout — Timeout while waiting for reply from peer. vαid nppp j cimβout l PCALLINFO ipCall . Lmic Ca : • p_. i,-ϊ<, PPP layer * ayer, uJ2 timer ιαx > ! ?PPJ.B_t *P_ncB - * ( lpCai : - >ppp ι ; / • NPPP C3 • / ϊ CPCTL 'pjicp • *p_. mk ->a j-pet. ; layer I ; GCAPACKET -p~tx_pkt; • Attempt to get tnmgs going again • ' 3 tςnιpjep->cps atβ) case C?_.NIT:AL: " Unexpected event • / case CP STARTING: case CP~CLCSED: zaaw C?~STOPPED: case CPJOPEN: Dreak; zasm CP CLCSING: /• Timeout waiting for terminate ACK; send another request */ if I —p ncp->acκ retry > PPP MAXJTERM COUNTER) I /" No response to our request; give it up •/ nppp reset( IpCall. p linrt, .ayer, CP CLOSED); I else / • Request remote nost s close data link •/ set ippp - mβrt PPP_RESTART TIMEOUT, " .pCali. p_lιnκ7 luJ2) layer, PPPjTIMERl); /• Get packet for Terminate Request */ if lipjtxjpkt - pppjjβtjktt ) ) •- NULL) nppp reset(IpCall, p link, layer. CP CLOSED); else ( / • try to send out another TERMINATEJ^EQ pkt •/ nppp sendreply!IpCall, p link, layer7 p txjpkt. TERMINATE REQ, 0); I I orβak; case CP_STOPPING: / *■ Timeout waiting for terminate ACK; send anotner request V if (<->p ncp->ack retry > PPP MAX TERM COUNTER) ( /' No response to our request; give it up */ nppp resetIIpCall. p link, layer, CP STOPPED); ) else i / • Request reeete host to stop data link V ββt ippp ti*eer<PPP RESTART TIMEOUT, IpCall. p_llnk7 (u.32) layer, PPPjTIMERl); /* Gat packet for Terminate Request */ f l(p_tx_pkt • ppp gβtjpktin ■■ NULL) nppp rβeβtdpCaϊl, p link, layer. CP STOPPED); alee. ( /• try to sand out another TERMlNATEJtEQ pkt •/ nppp sendreplyllpCall. p link. layerT p txjpkt, TERMINATE REQ. 0); 1 I break; case CP REQ SENT: case CP~ACK"RCV0: caaa CP ACK SENT: /• Timeout waiting for ACK to our request. • / /" or tuneout waiting for request from remote nost */ If ( 44-p_nep->ack_retry > PPP_MAX_CF3_COUNTER) / • Connection Estaolisn Timeout, NPPP link down •/ / • terminate lin */ nppp_relβasβ_lι.-.ι , ipCall, c_- * .-.ιci ; else ( / • Try to -jet t.iings ςoi.-.g oy sβndlnς new request • / nppp jβnareq l IpCall , p_. mk , . ayeπ ; i f : pj".ep->cpstate ' « CPJXCKJSENT ) pjιcp->cpstate « CPj-(EQ SENT; oreak; default: /• ignore •/ ϋreax; ) return; nppp_autn -imeout — Timeout wni.e waiting for Autnentication. •/ nppp auth t mβou ! PCALLINFO IpCal l , inkjTSj. *p_iιnk, PPP_layβr c layar, u32 tιmβr_ιαx ι ( PPPjCBji *P_nep - 4 1 lpCal l ->ppp ) ; / ♦ Nppp CB •/ SjTPCTL "PJicp - *p_linκ->aj:pβtl ( layer] ; / * Attempt to get things going again ♦ / i f ( layer -- PAP LAYER ) ( /* if Autn Response timer naa gone off. cneck for re-x it */ f (tιmβr_iαx -•> PPPjTIMERl) 1 /* Timeout waiting for ACK to our request, •/ / • or timeout waiting for request from remote host */ if (f-p ncp->ack retry > PPP MAX ere COUNTER) ( / • Autnentleator has not replied, NPPP link down •/ / • terminate link • / nppp release linkllpCall. p link); I else I / • Try to get things going βy sending new request */ nppp aenβpepreql IpCall, p link); I I else / • timer Idx -- 2 • / I /* Since we are NOT a PAP Authenticator. tnis Drancn is no */ /• longer valid WHOLLY IGNORE THIS • / ) I else /• CHAP • / I /* if Autn Response timer naa gone off. cneck for re-xmlt • / if I timer idx « PPP TIMER1) I /• Since wβ are NOT a CHAP Autnentleator, thla Branch s no •/ /• longer valid WHOLLY IGNORE THIS •/ ) else / • timer idx — 2 • / I /• CHAP CHALLENGE Timeout, NPPP link down •/ /• terminate link * • / nppp_r β ι β asβ_iιnκι IpCail. p_ii-iki ; / • -pppjproc -- Process tne incoming CP packet • / -ppp j proc i PCALLINFO IpCail, L * .nk_CS_t *p_:ιnk, ??P_.ayerj; -ayer, GCAPACKET -pjpkt) PPPJT3JΪ "PJ-ICB • i I * pCal * ->pppι ; /• NPPP CB */ 3_-"NFHDR -pjrnfhαr; 3CAPACKET "pjixjpkt; p enfhβr - ,S_CNFHOR *) <(lu β • IGETJOATAJPTR( jpkt) ) ♦ PPP_HORLENI, '• Process CP packet data */ sw ten(p_cnfhdr->codβ) case CONFIGJ*.EQ: /* Request of remote host •/ nppp_rcvrβq(IpCall, ρ_lmk, layer, pjpkt); Break; case CONFIG XCK: / • Remote accepted our req •/ nppp_rcvack( IpCall, p_lmk, .ayer, p j pkt); Break; case CONFIGJ-IAK: / • Remote ad-justed our req •/ nppp_rcvna i IpCall, p_lmk, layer, p j pkt); orβak; ase CONFIG _RtJ : /* Remote rβ 3 βeted our req •/ nppp_rcvre") ( IpCall, p_lmκ, layer, p j pktl; orβak; case TERMINATE r Q: / • Remote request to close •/ nppp rcvtermrβqIIpCall. p_lmk, layer).- oreak; case TERMINATEjλCK; /' Remote closed on request */ nppp_rcvtβrmack(IpCall. p_lmκ.. layer) ; Break; case CODE_REJ: nppp_rcvcodβrβj (IpCall, p_lιnk, layer, pjpkt); Break; rase PROTO ^EJ: nppp_revproto re j ( IpCal l , p_l ιnfc, layer, pjpkt l ; oreak; case ECHO REQ: .f (layer -- LCP LAYER) I / * Get packet for conf iguration request * / i f ( i p txjpkt « ppp gβtjpkt o i ' • NULL) ( / ♦ t ry to send out ECHOj^EPLY pkt • / nppp_sβndrβpiy( IpCall . p_link. LCPjLAYER, p txjpkt. ECHO_REPLY, p cnfhdr->id) ; ) » break; caaa ECHOJCPLY: Break? caaa OISCARD.REQ: /* Aa par tna RFC. Simply drop tnis pkt */ Break; ease CCP RESET REQ: if (layer -- CCP LAYER) nppp_rcvrβββtrβq(IpCall, p_lιnk, layer, pjpkt); Break; case CCP RESET ACX: i (Tayβr -- CCP LAYER) nppp_rcvrβsβtack( IpCall. p_lιnk, layer, pjpkt); Break; default: nppp_rcvunknown( IpCall, p_imk, layer, pjpkt); Break; ppp_risjpkt ip pkt, I5i; return; I /* • nppp cnapjproc — Process tne ι.-ιcomιr.g CHAP packet » / nppp :napjroc l PCALLINFO IpCall, Link j CBjs •p_lιnk, ??P_layβr - layer, GCAPACKET -p j pxti PPP TB c -pj-ico - i l ipCali->pppι ; /• NPPP C8 •/ 3JTPCTL -p icp; s ' NFHDR • p~enfhdr; -ιβ "p rfgopεs; -i6 v.i len, .en; -ιβ βufTl20l; unsigned char aιgβst[S2 MDS DIGEST); θ nppp_pwd(MAXSL?ASSWOSirεi; pjsnfhdr - ' 3__"NFH0R -Ml'uβ ♦ lGET_3ATA_PTR(pjpkt I ) - PPP_HDRLEN); p ' cfgopts • ;7ιu8 'ip j rnfndπ ♦ CNF -IORLEN) ; ~ pjicp • *p_lιnk->aj:pctl ; layer I ; pppjaβcryptjpw lnpppjpwd, lpCall->IscCallOata. password) ; ' • Process CHAP packet data • / switen ( pjrnf hdr->codβ ι ease CHAP CHALLENGE: / » Challenge Message •/ / * make sure we nava a secret string */ i Inppp j tfd(01 -. oi Break; enallβngβ value •/ val_lβn • •pj=fgopts; tne packet tnan overrun our stack Buf[] */ /' concatenate tne pkt ID, tne "secret", and tne Challenge value •/ Bu lO) • pjrnfhdr->ιd; len • 1; strcpyllcnar • )4Buftll, npppjpwql; len ♦- strlβn (npppjpwdl ; memepyl icnar * > ) 4Buf (lβn| , (p_cfgopts»l ) , val_lβn); / • wβ now nave tne octet string to nasn, MOS it.. •/ MOS -iasniBuf, digest, lβni; /• Build and send tne CHAP Response pkt */ nppp aβndcnaprββpl IpCall. p_lιnk. digest. ρ j :nfhdr->id) ; Break; caaa CHAP_R£3P0NSE: / • Response Message •/ /* Since.I aa not a CHAP AUTHENTICATOR. ignαra tnis caaa V break; case CHAPjSUCCESS: / • Success Message • / / • Stop timer against wait for CHAP RESULT COOC */ if (pjicp->timer_ia2.active) clrj-ippp -imβπ IpCall. p_lmk, layer. PPP_TIMER2) ; pjιcp->autn_cofBpl_flags I- AF_CHAP ?EER_APPROVE0; i- are wβ all tne way up ? • / if (p ncB->autn flags ••> p nco->autn eααpl flags) ( pjιcB->autn_ flags ι • AF COMPLETED; pj*ιeD">βutn j .ompl_flags ι • AF TCMPLETEO; p -ιcp->cosεac« • PJ3PEN; / • ai. a tnentieatior eompiete •/ npppj-pen i .pCaii, p_..r.κ, -ayer); oreak; case CHAP FAI U E: / • Failure Message •/ / • Stop timer against wait for CHAP RESULT CODE •/ :i :p j ιcp->tιmβr_ α2. ctive) elr_nppp_tιaιβr(IpCall, p_lmk, layer, PPPJTIMER2); /• NPPP Autn Failed, CHAP Mismatcn. NPPP link down •/ /» terminate link */ nppp_reιeasβ_iιnι I IpCall, p_iιnki ; oreak; aefaul*. : / • 9ogus pkt, ignore it. • / orβak; ppp_rlsjpkt( pjpkt. 16); return; nppp j pap j proc — Process tne meoming PAP packet void , / ♦ NPPP CB ; pjenfhdr • (S CNFHDR ♦ )(((uβ • ) GET_OATA ?T ( pjpkt ) ) f PPP_HORLEN ) ; p_cfgopts - (Tluβ "(p rnfhdr) ♦ CNF^DRLEN ) ; pjicp - tρ_lιnk->ajϊpetl (layβrl ; /* Process PAP packet data */ swi ten i p j ;n f hdr- >coαβ ) case PΛPJTEQUEST : '* Request Message • / / • since I an not a PAP AUTHENTICATOR, ignore tnis ease */ Break; ease PAP ACK: / • ACK Message •/ / • Stop timer against wait for PAP auth response */ it (p_ncp->tlιaer_idl.active) cTr_nppp_tι«βr(IpCall. p_link. layer. PPPjTIMERl); p_nc&->authjeo** l_ laga I- AF_PAP_PEER_APPROVXDj /* are we all tne way up ? '/ if ip nco->autn flags «- p ncB->autn eompl flags) ( " p_ncβ->auth_flags ι- AF TOMPLETED: pj-ιcB->autn rompl_f lags i • AFJCOMPLETEDJ pjιcp->cpstatβ t CPJ3PEN; /* all authentication complete */ npppjapβnl IpCall, p_lιnκ, layerI ; I oreak; ease PAP_NAJ<: /• NAK Message •/ / • Stop timer against wait for PA? autn response •/ if (pjιcp->tιmer_ι-:i .active' clrjnppp timerl .pCaii, p_l r.>-, layer, PPPjTIMERl); / ♦ NPPP Autn Fai.ed, PAP "ismatr- sppp ;.,-..< a 0 wn •/ /• terminate linn •/ * , ppp_rβleasβ_. * nk( IpCall, p_.:*ικι, oreak; aefaulε: /• Bogus pkt, -gnorβ it. • / oreak; ppp_rls j pkt (pjpkt, I ' M; return; ippp_rcvreq -- Process tne received CFβ -tEQ from the peer. •/ void nppp_revrβq I PCALLINFO IpCall, LinkjTSjt •p_lιnk, PPP layer z layer. GCAPACKET -p pkt) ! PPPJ.8J- "pjicp - *(lpCall->pppι; /• NPPP CB * / APPP rSj *PJ»CP - li (lpCall->apppl; /• APPP C8 • / S_CPCTL "P_ncp • *p_lιnκ->a_cpctl ( layer! ,* switcnip ncp- epstateι I ease CP_INITIAL: / • Unexpected event • / ease CP~STARTING: /• Unexpected event •/ if Tllayβr »• CCPjLAYER) it (p acB->a βastatβsllayβrl ■« ■ EM LISTENING)) ( • For the CCP. we are awaiting the CF6JXEQ from the Net side * to learn wnat compression (if any) it is trying to start up. ••"*•/ nppp_lβarnf romreql IpCall, p_lmk, layer, p j pkt); if ip ncp->eompressιon.algorιtnm ' - CCHPRESS NONE) ( p_acb->ajaβιβtatβs(layer| - EMj-lETCPjSTARTEDj nppp start! IpCall, p link, layer, CP CLOSED); I I Break; ease CPJCLOSED: npppjaenβteraackl IpCall, p_lιnk. layer, CP TLOSEO) ; break; caaa CPjSTOPKD: / • Sand our configuration request '/ nppp j aendreq l IpCall. ρ_lmk, layer); /• Evaluate configuration request from remote host •/ nppp shkreql IpCall. p_link. layer, pjpkt. CP_ACX_SENT. CP_REQ j SENT ) ; Breakj case CPjCLOSINβ: /* Me are attempting to close connection; wait */ /* for timeout tβ resend a Terminate Request • / Break; ease CP STOPPING: /• We are ttempting to stop connection; wait */ /* for timeout to resend a Terminate Request */ Break; ease CP REQ SENT: caaa CPJ" *fSENT: / * Evaluate configuration request !::«ι remote nost • / nppp_cnkr β q| IpCall, p_lιnk, .ayer, pjpkt. P CK SENT, CP_R£Q SENT); Break; ~ ~ caaa CP_ACK_RCVD: / ♦ Stop timer against wa t iz: config request •/ if (pjιcp->tιmβr_ιal. ctive) clr_npppj.ιmβrI IpCail, p_iιnk, layer, PPPjTIMERl); '' Evaluate configurat sn request frsm remote nost •/ -.pppj-.-.k eqi IpCall. p_l nk, -ayer, pjpkt. CPjOPEN, CP_ACκj*CVD) ; oreak; .ase CPjOPEN: ' • Unexpected svent • ' ' • Something went wrong; restart negotiations •/ .nppp_restart : IpCail. p_lmκ, ..ytri; '* Send our configuration request • / npppjjβnoreqi IpCall, p_ * ιr.k, layer); ' • Evaluate configuration request from remote nost */ nopp -.nkreqi IpCall, p_:ιn , .ayer, pjpkt, CPj-VCKjaENT, CP ^EQjsENT) ; Break; ~ ~ ~ default: / • ignore • / oreak; 1 /• nppp_ehkrβq -- Cheek link control optiona requested by tne peer. vo d npppjehkrβql PCALLINFO IpCall. LinkjCBjt • p_llnk. PPP_layer_t layer, GCAPACKET *pjpkt, ulβ ack cpstate. ulβ nak cpstate) ~ ( NPPP CB / • Per option reply '/ Overall reply to req •/ p rnfhdr • (SjCNFHD* •)<(luβ • ) GET JOATAJPTR ( pjpkt I ) ♦ PPP <DRLEN); pj-tptftdr - (SjOPTHC* •)(((uβ • )p_cnfhdrT • CNF_HDRLEN); / • Gat crO ACX packet •/ if (lp_ACXjkt • ppp_qβt pkt ( I ) — NULL) return; .- ~ / ♦ Set ptr to CFS ACX buffers option field •/ p_ACX_ouf - (luβ •)GET_OATA ?TR(p_ACK pkt) ) ♦ ppP 40ftL£N ♦ CNF_HORLXN; / • Make sure length in CP confiq neader is realistic */ if lp_pkt->uLβngth < (0 OR0)βwaplβ(p_cnfhdr->lβnl ) pjenfhdr->lβn « swaplβl (ulβ)pjpkt->uLβnqth) ,* alloptslen • swaplβ(p_cnfhdr->lβnl - CNF_HORLENj if (layer -- CCPjAϊER) minoptlen - 5,. else if (layer -- IPCPjAYER) minoptlen » 4; else minoptlen - 2; /• Process options reαuβsteα sy remote nost •/ for ,; aiioptsien >« -ninop * en; a * -QDts * en -■ D j .s;.-.αr->.er., o optnαr » .3 3PTHDR *ι -3 • p -ctr.αr - c 5ptήdr->.en) ■ I cptaataleπ « pj=ptndr->len - 2. /• Set eurr opts sata -en •' / • Set ptr to option αata •/ p j - tdata » ' ' * 3 *)pjsptndr) * 2: opt_aecept » CONF.S 'iCK; / • Assume will accept option •' •f (layer «- LCPjΛYERI -16 1 6; switcnιpj-.ptnαr->typβl ease MAX_RCVJJNIT: / • Max Receive Unit is a 16bιt field •/ .f loptdatalen < u«nι / • Short option data; rβ-iβct packet •/ ept_aecβpe » CONFIG ^EJ; oreai ; 1 /* Set proposed value from packet •/ l6 ■ ( ♦ pjoptαata << 8) i • (ρj * ptdata»l) ; /* Check if new value is appropriate •/ .1 : l6 < MIN j tRU! ( / • Too small, ask for minimum instead •/ opt_accβpt - CONfIGJ«AK; •p j όptdata - IN IRU >> β; • !p optdata • 1) " - MIN MRU . Okff; ιl6~- MIN MRU; I else ( /• alue is acceptaple •/ opt accept • CONFIG ACK; 1 p -ιCB->remjnru • 16; oreak; /• Async Control Map •/ map is a 32bιt field • / if (optdatalen < ilen) t / • Short option data; rβiβct packet • / opt_accept ■ CONFIGJ^EJ; oreak; ) / ♦ OTHERWISE. BLINOLY ACCEPT BECAUSE WE WILL NOT • / /• DO ANY MAPPING. BUT WE NEED TO ack THEIR OPTION • / f REQUEST • / opt_ae βpt • CC*.FIG_ACK; oreak; case AUTHJTYPE: /• Get proposed value from packet •/ ιl6 ft cpj-ptaata << 8) i • ip j sptdata*!) ; pppjaeeryptjpwαinpppjpwd. lpCall->IscCallOata. password) ; /• Check to see if CHAP or PAP is requested */ if (116 — - PPPjCHAP PID) if (optdatalen • • ileni ( / • wronq ootion aata Iβncjtn; rej ect pac«βt • • optjaceeot - CONF. jj-lEJ; oreak; I ' • make sure tney ao M05 •/ if !*(p optaata*2) '» CHAP ALS MD5) ( / • D5 net supported, ask far PAP •/ ' • NOTE: This .s mainly far Microsoft since tney •/ / • never converge on different CHAP aiqs. •/ Oxf f ) ; else ( / • Value s acceptaPle • / optj»ccβpt • CONFIGjλCK; pjιcp->authjf laqs ι - AFjCHAPjPEER; i I else i f 1 116 — • PPPJPAPJPI O I i i len - 2 ; if loptdatalen ' - Ileni 1 / • wronq option data lenqtn; reject packet •/ optjaccβpt - CO FIG IEJ; Break; ~ 1 / • we w ll assume tnat if tney are askinq for auth •/ / • tnat tne App w ll eventually supply uβ witn tna •/ / • oooty. Otnerv se. we will end up tearinq down •/ / • tne call. Oh woe is m EOJ • DRAIN BRAMAGE... •/ optjaceβpt « CONFIGjACK; pjιcp->autn flaqs i • AF PAP PEER; I else / • - • THIS OPTION IS NOT NEGOTIABLE. REJECT •••/ opt accept • CONFIG REJ; ) break; case MASIC_NUMBER: / • Magic Nuaber • / / • Magic Nuaoer is a 32bιt field •/ if (optdatalen < ilen) ( /* Short option data; reject packet • / opt_accβpt ■ CONFIG_REJ; break; I /• OTHERMISE. BLINDLY ACCEPT BECAUSE ME MILL NOT •/ jf 00 ANY MAPPING. BUT ME NEED TO ack THEIR OPTION •/ / • REQUEST •/ opt_accβpt - CONFIGjXCX; orβak; caaa PROT_COMPRES3: / • should be 0 opt data Bytes left • / ilen • optdatalen; if (lien) I opt accept - CONFIG REJ; I else t pjιep->txjproto j :emp • TRUE; opt_accβpt • CO IG jACK; l break; caaa AC_COMPRESS: /* snould oe 0 opt sata oytes left •/ i.en ■ optdatalen; :! 'ileni opt_accept - CONFIGJREJ; •>.se ρj-.CD->tx ejre.*np ■ TRUE; opt_aceept » CONFIG V * K; oreak; case FCS_32: / • 32-bit FCS not implemented •/ / •♦• THIS OPTION IS NOT NEGOTIABLE. REJECT •••/ ease LATION) opt_accept • ONFIGj^EJ; break; 1 else f " MPP Mak Receive Unit s a lβblt field •/ lien • 2; f (optdatalen < ilen) i / • Short option data; rβiβct packet */ optjaecβpt • CONΓIGJΛEJJ break; 1 / • Get proposed value from packet •/ ιl6 • cpjoptdata << 91 I * lpj3ptdata*l) ; " Check if new value s appropriate • / f 1116 < MIN MRU) I / ♦ Too small, ask for minlsuai instead •/ opt_accβpt • CO IG MAK; • p j sptdata » MIN_MRU » β; •ip optdata - l)~- MIN MRU 4 Oxff; 116~- MIN MRU; I else ( /• Value is acceptable •/ opt accept • CONFIG ACX; I break: ease-MPP SHORTSEONUM: /• MPP Short Sequence Nuaβera •/ / • •• THIS OPTION IS NOT NEGOTIABLE. REJECT • • •/ ilan ■ 0; optjaccapt - CONFIGjEJ; break; ~ ease MPPjΣNDPOIKt IO: / • MPP Endpoint ID •/ lien ■ optdatalen; / • BLINDLY ACCEPT BECAUSE WE MILL NOT 00 ANYTHING • / / • WITH THIS AT THIS TIME */ opt_accβpt - C0wriG_ACK; break; default: /• Unknown option • / opt_accβpt • CONFIGj^EJ; i ' protect from oocus pac<βt or suffer overrun •/ f I ιp_optner-J t ι β n <- o, ...optsiβn < p j -ptnαr->ιβn) ι pj * ptndr->len ■ al.cptslβn; ι * en - aj.iopts-en-2. else ..en - optdatalen; oreak; βise if , -ayer »- .PCPjLAYER) I * 32 *:eqpββr_ p; swi en(pjoptndr->typβ) zaaa IP_AODRS_ EH: / • IP address •/ /• t? Addr is a 32bit field •/ if loptdatalen < ilen) ( / • Short option αata; reieet packet •/ opt_accβpt • CONFIG »EJ; oreak; -' • Gee proposed value from packet •/ rβqpββr_ιp ■ 'pjsptdata; rβdpββr_ιp - ιrβqpββr_ p « θ) i *(p_optdata ♦ 1); rβdPββr_ιp - lrβqpβer_ιp << 8) i p~optdata • 2); rβqpβer_ p - I rβqpββr_ιp « 3) ι *(ρ~optdata ♦ 3); / • if tne Net is asking for an IP address. Re) it •/ f (reqpeer p — 0) ( optjaceept • CONFIGJΛEJ; break; I / • save Net IP addr • / Djιcβ->pββrjιβqotιated_ιp_addr - TRUE; pjιcβ->peer_ιp_addr • rβqpββr_ιp; 3pt_accβpt » CONFIG_ACK; break; case IP_COMPR_TYPE: / • IP header eoraprβssion •/ / ••• THIS~OPTION IS NOT NEGOTIABLE, REJECT •••/ ilen • 2; opt_accβpt • CONFIG EJ; break; default: /* Unknown option •/ opt_accβpt - CONfIG_REJ; / • protect from bequs packet or puffer overrun •/ it up optndr ->. en <■ 0) ι ι .alloptslen < p optndr->lenι ) ( p j oρtMdr->len - alloptslen; ilen ti alloptslen-2; I else ( lien • optdatalen; I break; I I else f (layer « IPXCP LAYER) I u32 reqpeer ipxnet; sw tsnip_3ptnαr->":ypeι i case IPXJ.E? NUM: ■• :?X Network Numoβr " / • IPX Net Addr is a 22=:: field " lien • 4; if loptdatalen < neni ( " Snort eptisn sata; reject pacitet •/ zpz_iccepz « CONFIG ^EJ; Dreait; ' • Get proposed value irem oackβt • / reqpeerj.pxnet ■ 'sjjptdata; reqpββr_ιpxnβε - ι reqpββr_ιpxnβt << 8) i *ιp j ptdata • li; reqpββr_ιpxnec - , reqpeβr_ιpxnβt << 8) ι •ip j sptdata » 2) ; reqpββr_ιpxnβt ■ , eqpeer_ pxnβt << 8) I » !p_optdata - ); / • if tne Net s asκιnq for an IPX Net address. Re} it •/ l βqpββr_ pxnβt Oi opt_aceβpt » CONFIG ^EJ; Break; I / • save Net IPX Net addr */ p -.c p ->oβerjιeqotιated_ιpxnβt_addr ■ TRUE; p_nep->peβrjιpxj*ιβtwork « reqpββr_ιpxnβt; opt_accβpt ■ CONFIGjλCK; break; case I PX jMOOE _NUM : /• px Node Number v / • IPX Node Addr is a MAC addr • / lien - SZ_IPX <ODENUM; if loptdatalen < ilen) I / • Short option data; reject packet •/ opt_accβpt • CONFIGJ3EJ; break; / • Get proposed value from packet • / -naccpy(pjiee->peer_ipxjiode. pjsptdatai j i f I IaMaeEmpty:p j ien->peer_ipxjiodel ) I opt_aceβpt • CONFIG_REJ; break; /• indicate that Peer IPX Node was aupplied • / pj-ιcP->pββr_nβqotιated_ιpxnodβ_addr • TRUE; opt_aceept - CONFIG_ACK; break; caaa IPX_CFC - * OMPLETE: / • IPX Confiquration Complete •/ ilen » optdatalen; /• BLINOLY ACCEPT BECAUSE WE WILL NOT 00 ANYTHING • / <•• WITH THIS AT THIS TIME • / opt_acββpt • C0NFIG_ACK; break; default: /• Unknown option •/ opt_accβpt " CONFIGJEJ; /* protect from ooqus packet or buffer overrun • / if lip optndr->len <« Oi ι ι lalloptslen < p optndr->lenι ) ( p sρtndr->lβn ■ alloptslβn; lien • alloptslen-2; else ( ilen • σptαacalen; i area*.; else if i -ayer « NBFC?_-AYE ) switen i p * otndr->typeι ease BF τ " AMEj?ROJ: ' • NetBios Name Proiβctie- " ..en - eptdatalβn; " BLINDLY ACCEPT BECAUSE WE WILL NOT 30 ANYTHING •' ' • WITH TWI3 AT THIS TIME • / -pt_aceept • CONFIGj-CK; oreak; case NΘFj?EER_INFO: ' • NetBIOS Peer -format e-i •/ ' • copy all tne cutter 'Class and version) •' -nemcpyi J3 • ' pjιeβ->nDjpββr jJluttβr. ' 3 • ιp_3ptaata, Si * _ BF~CLUTTER) ; /* f tie far end nas supplied a Peer Name, tuck t away •/ .1 toptαataiβn > 3) I • The Net side s qivmq us nis NΘF Name. Tuck it away • so tnat wβ can reflect it oack to tne App. ••••»•/ pjιcβ->pββrj-ιβqotιatβdjιβnamβ » TRUE; • nemcpyi ( β • ) pjτeo->nβjββrjιaa»β, l(u8 • !p_optaatβ»SZj*BF ; * TTER). loptdatalen - 8)); pjιcβ->nβjpββrj-ιamβ(optdataιβn - θ| • o ; ilen - optdatalen; opt j accβpt • CONFIGjλCK; oreak; case NBF_MULTICAST: / • NetBIOS Multicast • / len • optdatalen; / • BLINDLY ACCEPT BECAUSE WE WILL NOT 00 ANYTHING •/ / • WITH THIS AT THIS TIME ♦ / opt_accβpt ■ CONFΣG λCK; oreak; case NBF_MAC_REQUIRED: / • NetBIOS MAC Required •/ len~t> optdatalen; / • •• THIS OPTION IS NOT NEGOTIABLE. REJECT •••/ -pt_accβpt - CONflGJΛEJ; orβak; default: / • unknown option •/ opt_accβpt - CONFIG_REJ; / • protect from βoqus packet or buffer overrun */ if lip optndr->len <- 0) u (alioptslβn < p optndr->lβnl ) ( pj3pthdr->lβn • alloptslen; lien -a alloptslβn-2; ) else ♦ lien - optdatalen; I break; I I else if (layer " CCP LAYER) t ulβ 116; switcnip optndr->typeι I case CCPjSTACjCOMP: /• Stac Compression •/ if ιp j τcP->comprβssιon.a.-*orιtnm »» COMPRESS JSTAC) ' • until determined otherwise, default to oκay •/ opt_accβpt - CONFIG_ACK; nen « optαataien; f (optdatalen ' ■ :"?jSTACKER_REQ_ EN - 2; : I ' • mismatcn option aata lenqtn; rβiee packet •/ ot_accept - CONFIGJUEJ; oreak; / • 3e: proposed history value • / i ό » "pjjptcata << 9l ι • (pj * ptdata*>l ) ; ' • If t is non-tero, NAK it. • / if die '» pj-.co- >cep j-ium justs i ' • see if he accepts our nistory nurrtoβr •/ opt_accβpt - CONFIGJ-IAK; • p_optdata ■ ipj-ιCD->ccpjτu*nJιists >> 8); '.p_optoata ♦ 1 ) - pjτco->cepj-ιumjιιsts i Oxff; / • mane sure Cheek Type is somβthinq wβ can nandlβ •/ if (*:p optdata*2) '- p ncp->βtac cneck val) ( /- see if ne accepts our cneck value •/ opt_accβpt - CONFIGjtlΛK; • ιρ_αptdata*2) • pjτcd->stac_enβek j val; 1 else /• ASCEND •/ ( / • until determined otnerwise, default to okay •/ opt_aceβρt • cONFIβ CX; ilβn optdatalen; /.... •• NOTE: check ASCEND parameters of the STAC Compression. •• Since the ASCEND version of the STAC Compression is not •• intellectual property of USR, we cannot reveal • * information pertaininq to it in tnis patent application. ••••/ / • if biq mismatcn, REJ tne request. • / / • else if parameters are different but can be •/ /• negotiated, NAK tne msq, else ACK it. •/ I break; ease CCPj*tSj * "CKP* /* Microsoft Compression •/ / • until determined otnerwise, default to oκay • / opt_aceept - CONFIG_ACK; lien - optdatalen; If loptdatalen '- (CCP MICROSOFT REQ LEN - 2)) ( /* ntisaaten option data lenqtn; relect packet • / opt_aeeept • CO IGJ*EJ; βraak; 1 /* Get proposed compression and encryption values */ msjempjanc • • (pjsptdata ) ; / • If it is non-zero. NAK it. •/ If llfflt cap βnc 4 MPPC NEGOTIATE COMP) !- MPPC NEGOTIATE COMP) I /• see if ne accepts our history nuaaβer • / opt accept • CONΓIG NAK; •(p~optdata ♦ 3) • MPPC NEGOTIATE COMP; 1 break; aefault: '• 'J nun own option •/ ept_aceept • CONtZ~_ ZJ; ' • protect from pegus oaciet or ouffer overrun •< *f ( ,pj3ptndr->ιen <• 0) .a.ioptsien < pj-ptndr->lenι i ojjotndr->ιβn » ..lopcslβn; : * en ■ al.eptsιen-2; ilen - optαataiβn; steak; else /* assumed to oe BRCPj"_AYER •/ switsnιp_optnor->typβι ease 3R_MAC_7YPE: / ♦ MAC Type •/ .en » 1; .; loptdatalen < ilβn) / • Short option data; rβiβet packet •»/ opt_aceept » CONFIGjrEJ; oreaκ; if :*p_optdata ' - ΘRO_MAC_Θ023) opt_accβpt • CON ΪG XEJ; else -pt_acr β pt « CONfIG -\CK; / • Value is seeeptaple •/ Dreak; ease BR REMjXING ID: / • Remote Ring ID •/ eaae BR~LINE_ID:~ / • Line ID •/ / • 302.3 does not use tnis option, it is boqus.. •/ opt_aceβpt ■ CONFIGJ-IEJ; break; caaa BR TINY COM PR: / • Tinygrata Compression •/ caaa BR~LAN Ϊ0; /' LAM 10 ♦ / /- •• THIS OPTION IS NOT NEGOTIABLE, REJECT •*•/ ilen » 1.* opt_accβpt » C0NFIGJ*EJ; break; default: /• Unknown option •/ opt_accβpt » CONFIGJTEJ; / • protect from bogus packet or buffer overrun •/ if ( (p optndr->len <- 0) ι ι lalloptslen < p optndr->len) ) ( ρj3pthdr->lβn • alloptslen; lien - alloptsiβn-2; ) else I lien • optdatalen; orβak; » if ((opt accept « CONFIG ACK) ti (cnf accept '• CONTIG ACX)) ( / • This option was good, out a previous • / / • option was not. Return only tnosβ options • / / • wnicn are being nackβd/ rejected. •/ continue; ( if lopt accept « CONFIG NAK) I if lent accept — CONFIG REJ) " Return only those actions •/ / * wnicn are oeiπg rejectee. •/ continue; I if (en _accept « C0NF.3 -.CKi / • Discard current ..sc of good options •/ ' • Rest ouffer bytecount •/ e_AC pκt->uLβngtn » 0; / • Remit ptr -.-) CF3_ACK buffers option field •/ p_ACX_βuf - ( .uβ • lGET_2ATA_?TR(p_ACK_pktl I * PPPj*iORΪEN ♦ CNF_HDRLEN; ' • Send a l st of -ackβd options •/ c-ι._aeeept » CONFIG iAK; if (opt_accβpt « CONFTβ_REJ) I if (cnf accept '» CONFIG REJ) ( / • Discard current list of good options •/ /• Rest buffer bytecount •/ / • Remit ptr to CFGjXCK buffers option field •/ p ACK buf - ((uβ *)GET DATA PTRlp ACK j kt I ) ♦ PPP_HORLEN ♦ C FJDΛLEN; / • Send a list of cβiβctβd options •/ cnf_accβpt - CONFIGJrEJ; 1 /• Ardd option response to tne return list */ •pjHO buf*» - pjaptndr->typβ; • p~ACKJ9uff- - lien ♦ OPT_H0RLEN; for (1 - 0; i < lien; l»->) ( • p ACK buf** » *p optdata**; ) /* Bump buffer bytecount by size of REPLY option */ p -VCK_pkt->uLβngth ♦- ilen ♦ OPTJDRLEN; / • Send ACK/NAK/REJ to remote nost • / . f (cnf accept -- CONFIG ACK) ( /• Accept configuration requested by remote nost •/ nppp sendreply! IpCall, p link, layer, p ACX j kt, C«ΠG_ACX, p_cnfhdr->ι lj pjιcp->cpetatβ - ack j pstatβ; /* If wa just tranaitioned tβ OPEN state •/ If (p ncp->cpatatβ — CP OPEN) ( nppp open(IpCall, p link, layer); / • CP link now open •/ ) ) else I /• NAK/REJ config request made by remote nost •/ nppp »βndrβply( IpCall, p_lιnk, layer, pjACXjkt. enf_accβpt, pjϊnfhdr->ιd) ; p τcp->epβtatβ « nakjepstatβ; 1 return; ) / • nppp_lβarn romreq -- Grab t-.e "? algoπt.lm frsm tne Net CFG ^EQ •/ -,ppp_iβarnf romrβq ( PCALLINFO IcCaii, inkjCBjc • p_i nk, ?PP_.ayβrj: -ayer, GCAPACKET • pjpitt PPP CB t *p -.eβ « S(.pCal.->pppι; /• NPPP C3 •/ 3 CNFHDR • oj.nf.-.dr; 3~OPTHOR 'p ' optner; slβ optdatalen; o enfhdr - '3 CNFHDR *! i((uβ 'IGET DATA PTR(p_pkt) i - PPP ORLEN I; ρ~optndr » (SJ3PTHDR 'i lϋjβ 'ipjcr-fhαrT - CNF_HDRLEN); '• Make sure Length in C? config reader is realistic •/ if (p_pkt- uLβngtn < ( OWORDl swaplδ i p_cnjhdr->lβn) ) p_cnfhdr->len » swaplβl ι ul 61 pjpkt ->uLβngtnι ; / • Process options requested oy remote nost • / cptoatalβn • ρ 3pthdr->lβn - 2: '• Get surr opts data len •/ if :p_optndr->typβ «• C PjSTACjCOMP) i ~ ~ ~ p j -ιeβ->comprβssιon.algorithm • COMPRESSJ-IONE; /• since we will never reacn tne open stage, reflect */ /• tne fact tnat tnerβ will be no compression. •/ lpCaU->IscCallOata.compression • COMPRESS NONE; 1 I else if ιp_optnβr->typβ •- CCP_MS_COMP) i ~ ~ ~ / • Microsoft Coβjprβssion •/ ρ_nes->eempreaaien. algorithm • COMPRESS J ICROSOFT; p2ncβ->ccp_req_lβn - CCP_MICROSOFT_REQjLEN; pjflCB-Jtccpjiumjhista • 1; / " see now this goes • / p~ncβ->βtac cneck val • CCP CV NONE; 1 else ( p_nco->coaapresslon.algorithm • COMPRESS_NONE; /* since wa win never reacn tna open stage, reflect */ /• tne fact tnat tnare will βe no compression. • / lpCall->IscCallOata.compression • COMPRESS NONE; 1 pjιcD->mppc_rxjϊonβrβncy • 0; ρjιcp->mppc~txjϊonβrβncy « 0; pj*,cβ->stae ββcompjpausβd id « 0; pjιcp->aβcβnd_rβββtjaoββ • ASCENDj^ESETj3INGLE_HISTORY; return; I /• nppp_rcvack "" Process tne received ACK Jrom :nβ peer. •/ vo d -pρp_rsvack( PCALLINFO .pCali. • ..-.k_;3_t -p .;.*<, ?PP_layβrjt .ayer, GCAPACKET 'p_pκz, ?PPj_8jC 'PJ CP » 4 ( lpCai:->pppι ; /• NPPP rs •/ 3_r?CTL 'Pjicp - 4p_.ιnk->ajepcti ! layer! ; -J i pjιcp->tιmer jidl . active l :7r_nppp_tιmβr I IpCall, p_iιnk. layer, PPPjTIMERl i ; switch l pjicp->epstate I :-sβ CP_INITIAL: / • Unβkpβeted event •/ ease CPJ3TARTING: / • Unexpected event */ break; case CP_CLOSED: nppp aendtermackl IpCall, p_ιιnk, layer, CPJCLOSED) ; orβak; ~ case CP_STOPPED: npppjjβndtβrmackl IpCall. p_lιnιt. layer. CPJSTOPPED); Dreak; ease CPJ.LOSING: /• We are attempting to close connection; wait ♦/ /• for timeout to resend a Terminate Request •/ break; ease CP_STOPPING: /• Me are attempting to stop connection; wa t •/ / • for timeout to resend a Terminate Request •/ break; zaaa CP_REQ_SENT: / ♦ Make sure ACK s proper •/ if Inppp_cnkack(IpCall. p_lιnk, layer. p_pkt) • • -1) pjicp-j>cpstatβ - CPjλCKJΛCVD; /• Remote nost accepted our cβq / • Still need to settle request from remote nost •/ set nppp timerlPPP RESTART TIMEOUT, IpCall, p_lιnfc, (u32)layβr7 PPP_TIMER1); break; case CP_ACK_RCVD: npppjendreq I IpCall, p_link, layer) ; pjιcp->cpβtatβ ■ CPj^EQjSENT; orβak; ease CP_ACKj3ENT: /• Make sura ACX la proper */ f (nppp cnkackfIpCall, p l nk, layer, pjkt) -- -1) ( /* Error in ACX from remote host •/ /* Malt for another ACX, tnen send anotner request •/ aβt_nppp_tlsaβrlPPP RESTART TIMEOUT. -PCaϊl. p Iιnk7 1U-.2) layer, PPP IMER1); ) else I pjCp->cpstate « CPjOPENj /• CP negotiation complete • / nppp open! pCall. p link, layer); I Break; ease CP 3PEN: /• Somβtnmg went wrong; restart negotiations •/ nppp_rβstar iIpCall. p_lιnκ. layeri ; /• Send our con iguration request •/ nppp jaβndrβqi IpCall, ρ_lιnκ, layer); pjιcp->cpstatβ - CPJ^EQjϊENT; orβak; default: /• ignore ♦ / break; nppp_cnkack -- Check tne received ACK from tne peer. */ mt nppp cnkackI PCALLINFO IpCall, Lιnk_CΘ_t 'p_lιnk, PPP layer t layer. GCAPACKET 'pjpkt) ( PPP_CB_t 'PJ.CP • t(lpCall->pppι; /• NPPP C8 S CPCTL *P~ncρ * 4p_lιnk->a_cpctl(layβrl ; S~CNιTHDR - ' ACK enfhdr; S~OPTHDR 'p~ACK~optndr; GCAPACKET -p~REQjkt; S_OPTHDR *p~REQ_optndr; sϊβ ACKjjptslen. REQjaptslβn; uβ 'pjVCKjsptdata; u8 • pjEQjsptdata; sl6 ackβrr " 0; ulβ reqilβ, ackllβ; uβ rβq β. aeklβ; u32 rβqmy ip, ackmyjp; u32 reqlpxjret, ackipxjret; slβ minoptlen; int i; p_ACX_enfhdr - ISJΓNΓHOR 'iiiiuβ • )GETj3ATA_PTR(p_pkt ) ) * PPP_HDΛLENl; ' ACK^eptndr - ISJOPTHDR 'iπi β ')p_ACK_cn hdrι ♦ CNΓ_HDRLENT; / • CP ID field must match last request we sent • / if lpjCKjenfhdr-> d !- p ιep->lastιd) return -1; / • Get packet for REQ to ACK comparison cneck •/ ( ιp *ιEQ_pkt ■ pppjjβtjkt ( ) ) — NULL) return! -I); ~ / • Set ptr to REQ option neader • / p REQ optndr • ( S OPTHD* * I ( I I uβ • ) GET DATA PTR I p REQ_pkt ) ) ♦ PPPjiORLEN ♦ CNf_HORLENT; /• Get a copy of last request we sent • / pJlEQ_pkt->uLβngth • ~ npppjaakβreql IpCall, p_llnk, layer, luβ • ) p_REQ_optnd ) ; / • Gat βlxβ of REQ and ACX options field • / ACXjaptalβn - βvapl6(p_ΛCXj-nfhdr->lenι - CNΓ_HORLEMJ REQjoptelβn - p_REQ_pκt->uLβnqtn; / • Overall buffer lenqtn snculd match • / if (ACK_optslβn !- REQjjptalβnl ackβrr • 1; if (layer « CCPjLAYERI minoptlen s ; else if (layer « IPCPjLATER) minoptlen • <; else minoptlen ■ 2; / • ACX must ecno all options we requested in tne order requested • / for l; (REQjsptslen >- minoptlen) it I'ackβrrl; 119 REQjaptslβn — pj*EQj * ptncr->len, p ^EQ optn d r • (SjSPTHDΛ • I ( lu8 _, !p~REQ_optndr • PJ*EQ j 3pthdr->lβn) , ACKjsptslβn -• pjKCKj3ptiϊdr->ιen, p - * .CK~optndr • (S_OPTHDR •l iiu β *sp~ACK ipt.-.cr * p ACK optndr->lβnl > ( / • Must nave as many ackβd options as requested •/ if IACK optsiβn < minoptlen) ( ackerr » 1; oreak; I / ♦ Set ptr to current REQ option data field •/ - I i -.8 • !pjEQ j sptndr) ♦ 2; ' • Set ptr to current ACK option data field •/ p_ACK j 3ptdata ■ I (uβ • ip_ACKj-ptnpr) * 2; / • Config option nβaoβrs must matcn • / f l (pj-.CKj * ptndr->typβ ' - pj*EQj«ptndr->typel i l (p~ACK~opthdr->lβn '- p REQ όptndr->lβn> ) ( aekβrr • 1; Dreak; I i ; ackβrr - 1; I break; case AUTH TYPE: / • Autn Protocol Type not imclemβntβd '/ ackiiβ - :'p_ACKj3ptβata << 9) i • (p j ACK_oρtdata*l ) ; reqilβ - ι 'p~REQ~optdata << 8) I • (p~REQ~optdata*l) ; i lackiiβ '• req lβ) ~ ~ ( ackerr • 1; 1 if I reqilβ — PPP CHAP PΣO) I /• make sure tne algorlt is wnat we requested • / if C(p_ACXjsptdataf2) '- • ιρ_RXQ_optdata*2) ) ackβrr - 1; I break; ackerr ι ; I break; MPP Endpoint ID •/ ackiβ ♦ pjACX j sptdata**; rβqiβ • • p~REQj3ptdata*>*; if (ackiS ~- rβqiβ) ( ackβrr ■ 1; break; β rβak; casβ PROT COMPRESS: - • ?zzzzc: Compression •/ case ACjCMPRESS: Addr/Con: roi Compression > i * its now okay orβak; default: Shouldnt nappen aexerr oreak; i else if ; ayer —■ I?CP_1AYER) '• Confiq option values must matcn •/ switcnip REQ optndr->typβ) ( case IP ADDRSJ-)EW: / • IP address •/ ' • Ecnoed values must matcn our request •/ rβqmy_ιp « •pjEQjaptdata*"*; reqmy_ιp « trβqmy_ιp << 8) I 'pJlEQ j sptdata** reqmy_ιp - lrβqmy_ιp << 8) i • pj 5 .EQ_optoata»-» reqmy_ιp - ( rβqmy_ιp << 8) I • pj"tEQ j optdata*-> ackmy_ιp • 'pjACKjsptdataf*; acκmy_ιp • ιackmy_ιp << 8) I • pjACK j aptdata**; ackmy_ιp • (ackmyjip << 8) I *pj».CX j 3ptdata**; ackmy_ιp - (ackay_ιp << 8) I • pjACX j aptdata**; if (ackmyjip !■ rβqmy_ιp> ackβrr - 1; Break; case IPjCOMPR TTPE: / • IP header eoβpr • / / • Eenoeα~values must matcn our request */ reqilβ « p «:EQ j 3ptdata*-; rβqilβ » I rβqilβ « β ) I • p_REQ_optdata; ackllβ » •p *.CK j 3ptdata*«»; ~ ackllβ - (ackilβ « 8) I *p_ACX_optdata; if (reqilβ ackllβ) ackerr oreak; default: Shouldnt nappen ackerr 1; oreak; I ) else if (layar IPXCP LAYER) ( /• Confiq option values must match •/ switcnip REQ optndr-> ype) { caaa IPXJτCT_NUH: / • IPX Network Nuassar •/ / • Ecnead valuβa muat match our request •/ reqipjcjret » *pj-tEQ j* ptdaca->->; reqιpx~nβt (rβqipxjiβt << 8) i reqlpx_nβt • < reqipx j net << 8) I rβqipx -iβt irβqlpxjrβt << 8) i acklpxjnβt ■ *p «\CXj3ptdata->*; acklpxjret « lacklpx j -iβt << 8) • p jVCX j-iptda t a ♦ * J acklpx iβt • (acklpxj-iet << 8) • pjVCXjsptdata** ; ackipx -iβt lackipx iet << 8) • pj»»CX 3ptdata«"> ; if (ackipxj-iβt !• rβqipxj-iβt) ackerr » 1; break; case IPX_NOOCJΛJM: /• IPX Node Nuβaoer •/ fβr Ti - 0; i < S2 IPX NODENUM: ι**l If (*p_ΛCX_oρtdata*>* '• • p_REQ_optdata*>*) ackerr • 1; break; i I oreak; default: /• We diαn'; send ANY ZT" OPTIONS for IPX •/ ackβrr « i; Dreak; ) I eise if ! layer -- WBFC?_ AYERl ' • Confiq option values must matcn •/ swι cnιp ΛEQj3ptndr->typβι case NBFJWIEjPROJ: /• Empty Name Prelection •/ '• assume its okay •/ oreak; ease NBF ?E£R_INFO: " NetBIOS Peer Information •/ / • Ecnoed values must matcn our request •/ f ( CpJ*EQj-ptdata • » • p_ACK j* ptdataι 11 ( * :pJ*EQj-ptoata ♦ - ) ' - ~(p \CK j sptdata • 11) 1 acKβrr » 1; ~ Dreak; default: / • Wβ didn't send any otnβr NBF CFG OPTIONS •/ ackβrr • L; orβaic; ( else if (layer — CCP LAYER) ( /• Confiq option values must matcn •/ switcnip REQ optnor->typβ) ( case CCPjSTACjCOMP: /• stac Compression •/ /* Ecnoed values must matcn our request •/ f (p nco->compressιon.alqor tna —* COMPRESS STAC) 1 / • Echoed values must matcn our request •/ if :ρ nco->ccp req len « CCP STACKER REQ LEN) ( f ( ( • pj-iEQj-ptdata !« 'pjACXjsptdatai u ( * Ipj^EQjsptdata ♦ 1) '• • (p XCX j sptdata ' 111 , ι C!p REQ~optdata - 2) '• • (p~ACX~optdata < ■ 2))) ( ackerr « I; ) } else < ackerr ■ 1; ) ) else /• ASCENO •/ I /* Ecnoed values must matcn our request */ i (p nep->cep req len « CCP ASCEND REQ LEN) i if ( ( • pjrEQj-ptdata '• 'p VCXjaptdata) I I ( • (p_REQ >ptdata ♦ 1) " '- p_ΛCXjjptdata * ill I I ( ♦ (pJτ£Q~optdata ♦ 2) '- • (pjACXjsptdata ♦ 2)) : ι ( • (p~REQ~optdata ♦ 3) '• • tp~ACX~optdata ♦ 3)1) ( ackerr • 1; 1 I else I ackerr - 1; I I orβak; ease CCP_MS_CCMP: /• Microsoft Coaapress on • / /• Ecnoed values must maten our request • / if l p j *cp->eep_rβq_.βn •- CCP_MICROSOfTjΛEQjEN) ( if ( (*p *EQ apteata '• 'p_ACKj3ptdata) I I ■• ipj^E Q jsotdata - 1 ) ' » • ιp -«.K_optαata - . • i - 2 ) '" * 'P~ACK~optdata * 2: * - 2 ) ' - • ιp~ACK~optda a * 3) ackerr » 1. else oreak; default: / • Wβ didn't send any otnβr CCP CFG OPTIONS aexarr • 1; oreak; else /' assumed to Dβ BRCP LAYER • / I /• Confiq option values must matcn •/ switer. : p ^EQ j 3ptncr->typβ casa SR_MAC_TYPE: '* "AC Type •/ /• MAC Types MUST match • / if cp ACKjjptdata ' • -pj^EQjaptdata) ackβrr ■ I; orβak; default: ackβrr ■ 1; break; ppp_rlsjkt!p *.EQ_pkt, 181; f (ackerr) return -1; /• ACK matches last request we made •/ return 0; nppp_revnak — Process tne received NAK from the pear. vo d nppp_rcvnak(PCALLINFO IpCall, LinK_α»_t 'p ^ llnk. PPP layer t layer, GCAPACKET 'p_pkt) ~" I PPP_C8_t *P_neβ - * ( lpCall->pppl ; /• NPPP CB SjCPCTL 'P icp *p_iιnk->a_cpctll layer); if (pjιcp->tl»βr_idl. active) clr_nppρ_tιmβ I IpCall. p_lmk. layer. PPPjTIMERl); switcnip ncp->cpβtatβι ( caaa CP_INITIAJ-: / • Unexpected event •/ case CP~STAΛ*πNG: /• Unexpected event •/ Brea j caaa PjTLCSED* npppjβndtβrmac l IpCall, p_lιnk, layer, CPjCLOSED); Break; ease CPjSTOPPEO: nppp_sβndtβrmack( IpCall. p_llnk, layer. CPjSTOPPCO); break; ~ caaa CPjCLOSING: /• Sβ are attββ tmq to close connection; wait • / / • for timeout to resend a Terminate Request • / oreak; ease CPjSTOPPING: /* **a are attβmptinq to stop connection; wait •/ / • for timeout to resend a Terminate Request •/ Break; case CP REQ SENT: ease CPJ*.CK~SENT: / • Update our eonfiq request to reflect NAKed options •/ :i ! .pppj:nιnaκ; .pCaii, ;_.;,*κ, .ayer, p j t> «• -.) I /• Sad NAK packet •/ /• Wait for anotner; resend request on timeout •/ set nppp timeriPPP RESTART TIMEOUT, ipCall. p link, Tu3 2 )layβr7 PPP TIMER1); 1 else 1 /• Send updated confiq request •/ nppp sendreqIIpCall, p lιnκ, layer); I break; oreak; ease CPJ3PEN: / • Sometn nq went wronq; restart negotiations */ nppp_rβstart I IpCall, p_lιnk, layer); /• Send our conf Iquration request •/ nppp_aβndrβq I IpCall, p_lιnk, layer); p_ncp->cpstatβ • CPJ^EQ SENT; break; ~ " default: oreak; /• ignore •/ I return; I npppj-hknak —> Check tne received MAK froa the pear. tnt npppjehknak(PCALI.INro IpCall. lnk C*_t *p_llnfc, PPP_layβr_t layer, CJCAJPACKET •pjpkt) PPP CS t • p_neβ ■ 4(lpCall->ρpp); /• NPPP CB S CPCTΪ • p^ncp - 4p_lιnk->aj.pctl(layβ l; S~CNFHC* • p~MAK_enfhdr; S " OPTHO« • p tAK jsp nd r ; acAPAOrr • p~"EQjkt; S OPTHM • pjSEQjsptnd r ; sit MAKjsptslβn. REQjsptslβn; uβ • p_MAK_optdata; slβ nakerr « 0; ul* nakilβ; u32 na*cay_lp; u32 nak j ipxjiβtnuia; slβ minoptlen; uβ majsap βnc; p_MAK_cnfhdr - (SJ34IH0* •)(((u β • ; p~NAK~opehdr (S_OPTHD* ")(((uβ • /• CP 10 field must matcn last request we sent • / if (p tAKjcnfhdr->id !• pjιcp->iastιd) return -1; /• Get packet for REQ to NAK eemoaπson check •/ if lip_REQj^kt » pppjjβt _pκz : ) ' »- NUΓ.-, return ( -1); /• Set ptr to REQ option neader • / p REQ optndr - ιS_OPTHDR • ) ( ( -8 "iGE -ATA PTRlp REQ_pkt ) I • ?PP_HDRI.EN " * CN?_H0RLEN|; " Get a rooy of last request we sent • ' ppp jriakβrβ i p a , ρ_-i.-ικ, * ayβr, I uβ • ipjXEQ sptneri ; ι" Get size NAKj-pts βn REQjjptsiβn /* Check overall buffer lenqtn •/ if (NAKjaptslen > REQj-ptslβ i naxerr - 1; if (layer — CCPjLAYER) minoptlen • 5; else f (layer — IPCP AYER) minoptlen • 4; else minoptlen • 2; /' NAKed options must Pe same order as our oriqinal request •/ , ) nakerr • 1; orβak; 1 / • Maybe not all options were NAKed; look ♦ / / • for matcnmq option in our request • / while (p REQ optndr->typβ '■ p NAK optndr->type> [ / • This option not NAKed; eat rest •/ / • of option from tne request packet •/ REQjsptslβn — pj*EQj3ptndr->lβn; p_REQjoptndr - (SjDPTHDR 'i iiuβ •>p_R£Qjapthdr ♦ pj*EQj3ptndr->lβnl ; ~ ~ / • Muat find matcn to each NAKed option •/ if (REQ optslen < minoptiβni { p_REQj»pthdr->typβ ■ 0; nakβrr • 1; Break; ) ) /* Confiq option headers must matcn •/ If ( (p_NAK_optndr->typβ ' « p_REQj3ptnβr->typβ) I I Ip NΛK~optndr->lβn '» p REQ όptndr->lβn) i ( nakerr ■ 1; Break; ) / • Sat ptr to current NAK option field to coapare */ p_NΛKj9pcdata i ι β • >p_NAK_optndri ♦ 2; if (layer — LCP LAYER) I /• Remote nost replaced our request witn new suggestion • / svitemp REQ optndr->eypβ i I case MAX_RCV_UNIT: " aximum Receive Unit •/ ' • Set suqqβstβd MRU • / nakilβ • > ! • p ' i AKjsptdata << 8) • 'p *IAK_optaata*>l ) ; / • Save new request value •/ pj-ιCD->lcljnru • r.akllβ; sreak; ease MPp_MRRU: / * MPP MRRU • / ' • 3et su gested MRU • ' nakilδ » ! << 3 I • 'pJtΑKj-ιptdata»l ι ; if ( iπakilδ < INj-lRUi ι tnakilβ > pj*,cB->lei mrul ) "lamiβ • pj-ιC0->.ei jnru; ~ ~ ' • Save new request /aluβ • / pjιeo->lcljnru • nakilβ; oreak; case MPP_ENOPOINT_ID: / • MPP Endpoint ID •/ pj-ιCD->sβnojandpt • FALSE; oreak; default: /* Shouldnt nappen •/ nakβrr • 1; orβak; I I else if (layer -- IPCP LAYER) ( / • Remote nost replaced our request witn new suqqestion •/ switcnip REQ optndr->typβ) I case IP_AODRS_NEW: / ♦ IP address •/ / • Set replacement value froa NAK packet •/ nakmy_ιp ■ •pJ-IAKjaptdata**; nakβy_ιp - inakmyjip << 8) I • p iAKjsptdata**; nakayjip • ιnak»y_ip « 8) l *p~NAK~optdata»*; nakmyjip « (nakmyjip << 8) I • pjiAKjoptdata**; /• Check My IP address •/ if ( 'pjιcp->my_ιp_addr it nakmyjip) pjιcB->my_ιp_addr « nakmy_ιp; / • sava my_ιpjaddr •/ Dreak; default: / • Shouldnt nappen •/ nakerr " 1; Dreak; ! ) else if (layer —> IPXCP LAYER) I /• Confiq option values must matcn •/ switcnip RCQ optnβr->type) I caaa :PX_N£T_NUH: / • IPX Network Nujapβr • / /• Gat replacement value from NAK packet • / nak_lpx ιβtnu» • • pj-lAKjaptdata**; nak_ιpx~nβtnusι ι nak_ιpxjιβtnuβ << 8) I • p lAKj3ptdata**; oak_ιpxj-ιβtnusι « makjipxjiβtnuβ << 8) l 'p <ΛKj3ptdata»->; nakjlpxjiβtnum • (nakjipxjiβtnuai << 8) l *pj<AK 3ptdata*»; /• Update My IPX Network Numββr ? • / if (! pjicp- >my_ιρxjιβtwork ti, nakjipxjΛβtnuai) pjτcp->my_ιpxjτβtwork • nak_ιpxjιβtnuβ; Break" caaa IPX_NO0C_NUM: /• IPX Node NuaaBβr • / /• Updatβ~My IPX Node Nu eer ? •/ if (IsMac£a4pty<p ιcB->my_ιpxjτodβ> ti ! ! IsMacjjaptyTp NAK optdata ) ) ) ( maccpy<pjιcB->my_jpx node. pj^AK optdata) ; I Break; dβfault: / • Wβ didn't send ANY CFG OPTIONS for IPX • / nakβrr » l; Break; ) 1 else If (layer — N8FC?_ * AYER) i / • Remote nost replaced our request witn new suggestion, •/ i ' Excβot tnat wβ didn't send ANY NetBios CFGs THAT CAN 8E NAKed default: naxβrr • 1; Dreax; ) else if (layer -- CC? LAYER) I ulβ histjsuf ; uθ enacK j nodβ. reset jnodβ; / • Confiq option values must matcn • / switcn i p REQ optndr->typβ) ( ease CCPjSTACjCOHP: / • Stac Compression • / i f ( pjTCD->eompression . algoritnm •- COM PRESS JJTAC) i f ( p ncB->ccp req len — CCP STACKER REQ LEN ) ( / • Get tne NAKed values from tne NAK pkt •/ nistjsuf • 'pJtAKjsptdata**; nistjsuf - (nlstjauf << 8) l *pj*lAKj3ptdata->->; cheek mode • » p NAK optdata**; I else ( nakerr • 1; Break; I /• Check to see if num nists nas cnanqed •/ if ip nep->ccp num nists ' • nist Duf) I if ( (h St Buf aa 0) I I (hlStJSUf at. 1) ) I pjιcB->eepjιumJ*ιιsts • nistjsuf; else nakerr - 1; Break; I /• Cheek to see if tne cneck val naa cnanqed • / if (p ncB->stac cneck val '• cneck mode) ( If (check mode ~ CCP CV NONE) I p ncB*>>stae cneck val • cneck mode; 1 else ( nakerr ■ 1; Break.- I ) \ else /• ASCEND • / I •• NOTE: check ASCEND parameters of tne STAC Conpression. •• information pertaininq to it m tnis patent application. / • maxβ sure tnat tne values of tne Dara βters tne far " ' • end is are vaiuβs we support iβise laicβrr it). •/ oreax; ease CCP_MS CCMP: ' • Microsoft Compression •/ :1 ;p_neo->ecp_req_lβn « CCP_MICROSOrr_REQ_LEN) '* Get proposed compression and encryption values • ■' • nsjempjenc » * i pj^AKj * ptdata- 3 ) ; ' • Z.' it is non-zero, NAK it. •/ if (ims j empjenc i MPPC ^EGOTIATEjCOMPI « 0) ( / • turn down attβmptinq to Bπnq up CCP •/ pjιeβ->orotoeols *- -PPP PROT CCP; nppp_rβsβt!IpCall. p_liniτ, CCPjAYER. CP_INITUU.l; / • Peer NPPP Does NOT have Compression enaBlβd, •/ /• DISABLING compression. •/ ) ) else nakerr « 1; Break; default: / • Wβ didn't send any otnβr CCP CFG OPTIONS •/ nakβrr « 1; Break; I I else / • assumed to Be BRCP AYER • / I / • Remote nost replaced our request with new suqqestion •/ switcnip REQ opthdr->type) ( default: nakβrr • 1; Break; ) ) ) ppp_r Is jkt I p_REQjkt , 19); if inakβrr) return -I; /• NAK matches last request we made */ return 0; I /• nppp_rcvrβ — Proeess tna received REJECT from the peer. void nppp rtrvrβ-) ( PCA LINΓO IpCall. Link CB t *p link, PPP layar t layer, SCAPACXXT 'pjpk ) 99tJΛ t *P_«eb - * ( ipCall->ppp) ; / • NPPP CB SjCPCπ. • pjicp ip_iιnk->ajepctl[layβr| ; if lpjτcp->tιmerjιdl.actιvβl clrjipppjtimarilpCalrl. p_lιnk. layer. PPPjTIMERl) ; switcnip ncp*»>cpstate> ( case CP_INITIA : / • Unexpected event • / case CP~STARTING: /• Unexpected event •/ oreak; ease CPJCLOSED: nppp j jJβndtβrmac l IpCall. p_lιnκ, .ayer. CPJCLOSED); oreak; ease CPjSTOPPED: npppj β ndt β rmae l lpCal., p_- * .-ικ, .ayer, C?j3TOPPED) ; Break; ease CPjLOSING: /• Sβ are attβmptmq to close connection; wait •/ /* for timeout to resend a Terminate Request •/ Break; zaaa CP_STOPPINC: /• Wβ are attβ ptinq to stop connection; wait •/ /• for timeout to resend a Terminate Request •/ oreak; ease CP REQ SENT: ease CP~ACK~SENT: '• Update our confiq request to reflect NAKed options •/ if inppp cnkrβi l IpCall. p .inn, layer. p_pkt) »■ -1) ( /• Bad reject packet •/ /• Wait for anotner: resend request on timeout •/ set nppp timerlPPP RESTART TIMEOUT, IpCall. p l nk, Tu32)iayβr7 PPPjTIMERl); ) else ( /• Send updated confiq request */ nppp sendreqi IpCall, p link, layer); I Break; caaa CP_ACK_RCVD: /• Send our conf iquration request • / npppjendreq I IpCa . p_link. layer I. - pj*ιep->epatatβ - CP tEQjSENT; Break; caaa CPjOPEN: / • Somathlnq went wronq; restart nβqotiations •/ nppp_rβstartl IpCall, p_lιnk, layer) ; /• Send our conf iquration request • / nppp_jβndrβq( IpCall, p_lιnk, layer); pj-ιep->epstatβ - CP EQjSENT; Break; ~ default: /• lqnore •/ Break; I return; ) /• * npppjenfcrβ — Check the received REJECT froa tne peer. */ int nppp_chkrβ-| ( PCA .INΓO IpCall. Lιnk_C8_t 'p_lmk. PPP_layβr_t layer, GCAPACKET • pjpkt) PPf_CB_t • P.ncb - llpCall->ppp); /• 9tt C8 S CPCTL » p ncp t p nnk->a cpctl ( layar) ; S CNrHDIl « p REJ enfhdr; s ai-THO* - ' EjOpt βrj GCAPACKET *p REQjpkt; SJ3PTHDH • p~REQ 3ptft r; slβ REJjsptslβn, REQ j sptslβn; slβ rβiβrr " 0; sl β minoptlen; p_AEJ_cnf β r - ( S TNFHDR • I I ( ; 3 'IGET CATA PTRIp pkt) ) - PPP HORLEN I; p_REJ_optndr - ( S_OPTHDR • i i ( : -3 • ιp_aEJ_cnfhdrι - CNΓ_HORLENT; /• CP ID fieid must naten last request wβ sent •/ if (pj«XJjϊnfhαr->ιd ' • pjιcp->ιastidi return -1; /• Get packet for REQ to REJ comparison cneck •/ :f ; ,p_REQjpkt • pppjjβt jpkt ( ) i »- NULL) return i -1 : ; " Set ptr '.o REQ option neader • / p REQ optndr - :S OPTHOR "J iuβ *)GET QATA PTR(p REQ j pktl l * PPP_HDRL£N ♦ CNFJTDRLENI . * / • Get a copy of last request wβ sent • / p_REQjpkt->uLβnqtn • npppjnakβre i IpCall, p_lιnκ, layer, (uβ • I p J*EQ_optnβ ) ; / • Get size of REQ and REJ options field •/ REJj-ptaiβn - swaplβ tp *lEJ_cnfhdr->lβn I - CNFJ4DRLEN.* REQ j aptslen ■ pJ*EQj kt->uLβnqtn; ~ /• Check overall ouffer lenqtn •/ if iREJj-ptsiβn > REQjJptslenl • Remote cant REJ more options tnan we requested •/ rejβrr ■ i; 1 if (layer — CCPj-AYER) minoptlen - 5; else if (layer -- IPCPjAYERI minoptlen • 4; else minoptlen • 2; /• Rejected options must Be same order aa our oriqinal request •/ /• Maybe not all options were Rejected; look •/ /• for mateninq option m our requeat •/ while (p REQ opthdr->typβ '- p REJ optndr->type) ( / ♦ This option not REJed; eat rest • / /* of option froa the request packet •/ RCQjsptalen — pj * tEQj-pthdr->lβn; p_AEQjjpthdr • (SjOPΪHOR » )(luβ • )p_REQjspthdr • p !EQ_opthdr->len) ; /* Muat find match to eaen REJed option • / if (REQ optslen < minoptlen) ( pjEQj3ptndr->type a 0; rβfβrr « 1; oreak; I I /• Confiq option neadβrs must matcn • / if ( (pjREJ j* ρtndr->typβ '• pj*.EQj3ptndr->typβ) I I (p REJ όptndr->lβn ' • p REQj-ptndr->lβnι l I r β lβrr ■ 1; orβan; if (layer «- LC? LAYER) ( / • Remote nost wont negotiate tnis " option •/ switcn ιpj*EQj-ptndr->typβι ! ~ ~ case MAX_RCV_UNIT: ' • Maximum Receive Unit •/ ' • Dont attempt to neqotiate MRU •/ pj*.CB->neςjτιru ■ 0; p~ncB->Lcijnru - MAX_FRAME_LENGTH ♦ sizeof (SjPPPHDR) ; oreak; case MPP_MRRU: / • MPP MRRU • / / • Don't attempt to negotiate MPP, use PPP ♦ / if ( :pCall->IscCallOata.dwEncapaulation «- PPPML iMULATION) lpCall->IseCaliData.owEncapsulatιon • PPPJΣMULATION; default: / • Shouldnt nappen •/ Break; I I else if (layer —■ IPCP LAYER) I / • Remote nost won't neqotiate this option V switcnip REQ optndr->typβ) ( caaa IPJXDORSJTXH: / • IP address •/ / • Abandon attempt to neqotiate IP addrs •/ p j *ιcβ->neg_tp j »ddrs • 0; / • Reflect tnat link is Bemq established •/ / • with NO IP AOORS aaaiςnβd •/ Break; default: /• Shouldnt nappen •/ re-)err • 1; oreak; I I else if (layer — IPXCP LAYER) { /* Raaaate host won't neqotiate this option •/ switcnip REQ_opthdr->typβ) ( caaa tfX tVrjαmi / • IPX Network nuββer ♦ / /* Abandon attempt to neqotiate IPX Network nuaaser • / pjιcβ->neq_lpx j -ιβtwork ■ 0; /• Reflect tnat link is Bβinq established */ / • witn NO IPX Network numβer assiqned •/ Break; ease IPX_NO0C_NUM: /• IPX Node nuaaser • / / • Abandon attempt to neqotiate IPX Node nuafeer • / ρjΛCβ->nβq_ιpxjΛodβ • 0; Break; default: / • We didn't send ANY CFG OPTIONS for IPX • / ret) err • 1; Break; 1 I else if (layer — NBFCP LAYER) ( / • Remote nost replaced our request witn new suqqestion, •/ / ♦ Except tnat wβ didn't send ANY NetBios CFGs THAT CAN 9E NAKe d •/ switcnip REQ optnor->cypβ) ( ease NBF tAME j PROJ: / • ABandon attempt to indicate to Jar and any name proj ection • / p_ncβ->nβq j Λamβj ro"f • 0; Break; ~ ease NβF j ?EER_INFO: / • ABanoon attempt to indicate to far end our peer info • / pj-ιCθ->nβq_pββr_ιnfo » 0; orβak; default: Dreak; I I else if (layer — CCP LAYER) ( /• Confiq option values must matcn •/ switcnip REQ optndr->typeι I ease CCPjSTACJTCMP: / ♦ Stac and Ascend Compression •/ ease CCP 4SJ".OP1P: / • Microsoft Compression •/ / • If wβ qot rejected for anytninq in tnis option, tnen •/ / • -use forqet compression altoqetner •/ /• turn down attβmptlnq to Drinq up CCP •/ pjCB->protocols *■ -PPPjPROT ICP; nppp_rβββt(IpCall, p_lιnk, CCPjLAYER. CP_INITIAL) ; / • Peer NPPP Does NOT support conpression, DISABLING.\r\n". Break; default: Break; 1 ) else /• assumed to Be SRCP LAYER •/ ( /• Remote nost replaced our request witn new suqqestion •/ switcnip REQ optndr->type> I default: Break; } 1 ) ppp_rlsjpkt lpj*EQj kt, 20) ; if (rβiβrr) return -1; /• Rβ-|ec*t Batches last request we made • / return 0; ) /• nppp_revter rβq — Process the received TERMINATE REQUEST froa the peer. void nppp revtβr»req ( PCALLIN.rθ IpCall. Link CB t *p link, PPP layerjt layer) ( PPP_C8_t *P_ncβ - 4 ( lpCal l->ppp) ; /• NPPt CB V SjIPCTL "pjΛcp tρ_ι ink->ajepctl ( layer) ; switcn i p ncp->cpatatβ ) ( caam CP_INITIAL: / • Unexpected event • / caaa CPjSTAR lNG : / * Unexpected event ' ' Break; 132 case CP CLOSED: case CP~STOPPED: case CP~CLOSING: ease CP~STOPPING: ease CP~REQ_SENT: npppjiβndtermack ( ipCall, p_.ini., .ayer, p j ιco->cpstatβι ; orβak; ease ? ACK RCVO: ease CPJ-vO-TsENT- -ιpppjj*βndtermack( LpCali, p_lιnk, -ayer, CPj"(EQJSENT: ; orβak; caaa CPJ3PEN: /• Sometmnq went wronq; restart neqotiatlons */ nppp_rβstart ( IpCall, p_lιnk, layerI; /• Send terminate ack •/ npppjJβndtβrmac i IpCall, p_lιnx, layer, CPjsTOPPED] ; Break; ~ default: /• ignore • / Drβax; I return; /• nppp_revtβrmack -- Process tne received TERMINATE ACK from the peer. void n Ippp revtermackI PCALLINFO IpCall. Link _CB_t *p_link, PPP_layar_t layer) PPP_CB_t « 4 ( lpCal l ->pppl ; / • NPPP CB S_CPCTL • *p_l ιnk->ajepctl ( layβr l ; switcnip ncp->cpstatβ) ( case CP_INITIAL: / • Unexpected event • / ease CP~STARTING: / ♦ Unexpected event • / Break; ease CP_CLOSEO: case CP STOPPED: caaa CP~REQ SENT: caaa CP ' ACK^SENT: / • stay~m saaae state •/ Break; case CPJ.LOSING: /* eoapletea transition to down state, indicate tnis fact •/ npρp_rββtar (IpCall, p_lιnk, .ayart; Braakj caaa CFjSTOrPING: /* eoapletea transition to down state, indicate tnis fact •/ nppρ_rββ«art(IpCall, p_link. layer); break; case CP_ACK_RCVO: pjιcp->cpβtatβ CP ^EQ SENT; Break; ~ ~ caaa CPjOPEN: / • Sostβtninq went wronq; restart neqotiatlons •/ nppp_rβstart( IpCall, p_Unk, layer),* / • Sand our con iquration request • / nppp_sβndrβq( IpCall, p_lmk, layer); p_ncp->cp«tatβ ■ CP_REQj3ENT; Braak; default: /• lqnorβ Break; nppp_revcodere} ~ Process tne received CODE REJ from tne peer. •/ void nppp_rcveodβrβ-| (PCALLINFO IpCall. Hnkj__J- *p_lιnk, PPP layer t layer, GCAPACKET *p_pkt) ~ ~ ( PPP_CB_t *P_ne_ - .(lpCall->pppl; /• NPPP CB SjTPCTL ' ^ncp - tp_lιnk->a_cpctl[layβrl ; /• eatastropnie code error •/ switcnip ncp->cρstatβ) ( ease CP_INITIAL: / • Unexpected event •/ case CP~STARTING: / • Unexpected event •/ Break; case CP CLOSED: ease CPJ-L03ING: pj-ιcp->cpstatβ • CPJCLOSED; orβak; ease CP STOPPED: caaa CP STOPPING: caaa CP~REQ SENT: caaa CP ACK~RCVD: caae CP_ACK~SENT: p_ncp->cpatatβ - CP STOPPED; Break; case CPJOPEN: nppp_cloββiIpCall. p_link. layer, CPjSTOPPING. CPJCLOSED) ; Break; "" ~ default: /• iqnore •/ Break; 1 return; nppp_rcvprotorβj — Process tna received PROTO REJ froa the peer. void nppp_rcvprotorβ 7 ( PCALLINΓO IpCall, Link CB t *p link, PPP layar t layar, GCAPACKET » p_pkt7 PPP_C»_t *>p_neJ» *(lpcall->pppi; /• NPPP CB SJCPCTL *p~ncp imk->a cpctl (layarl ; S _NI * HD* •p j snfhdr; ulβ re*) proto; pjenfhdr (S_CNΓHD* •Ml ' luβ ♦ )GE j_ATA PTR I p j pkt) I ♦ PPP_HD»L_N) ; rβ-)_proto - "(ulβ '((due •ip snfhβ i *~CNr τOIU-_ll» ; /* cneck the proto the reaote cnocked on •/ if (rβ _proto — swaplCIPPP LCP PID)) I /• catastrophic code error V swιten(p_ncp->epatatβι caaa CP_INITIAL: / • 'Jnβxpβcteo event */ case CPjSTARTING: / • Unexpected event •/ Break; case CPjCLOSED: caaa CP CLOSING: pjιcp->cpsta e - CPj LOSED; Break.* ease CP STOPPED: caaa CP ' όTOPPING : ease CP~REQ_SENT : case CP _ ACK~RCVO: ease CP~ACKJ3ENT : pj-ιcp->cpstatβ - CPjSTOPPED; oreak; ease CPJ3PEN: npppjelosβlIpCall. p_lιnk. layer. CPjSTOPPING, CPJCLOSED); Break; ~ ~ default: /• iqnorβ •/ Break; I I else if (lrβi_proto • » PPPJ3RCP_PID) I I (rβ-j_proto ■_ PPPJ3R_PID) ) i ~ ~ /* turn down attβmpt nq to Bπnq up BRCP •/ pjιco->protocols 4" -PPPj?ROTJ3R; nppp_rβsβtllpCall, p_lιnic, ΘRCP_LAYER, CP_INITΣΛL); / ♦ Peer NPPP Does NOT support βrldqinq, DISABLING. •/ I else if ((rβj_proto — swaplβ<PPP_IPCP_PIO) ) II (rβ _proto . swaplβlPPP IP PΪD)))~ { /* turn down attemptlnq to βrinq up IPCP */ p ncB->protOCOls 4- -PPP PROT IP; nppp_rβaβ (IpCall, p_lιnk. IPCP_LAYER. CP_INITIΛ1); / • Peer NPPP Does NOT support IP, DISABLING. •/ I else if i(re-j_proto - swaplβl PPP_IPXCP PID)) II (rβι_proto -• swaplβlPPP IPX PIO) ) )~ I / • turn down attβmptinq to Brmq up IPXCP •/ p ncp->ρrotocols -ppp PROT IPX; nppp_rβaβt(IpCall, p_lιnk, IPXCPjLAYER, CP_INITΣAL) ; /• Peer NPPP Does NOT support IPX. DISABLING. •/ ) else If t ( rβ1_proto — swaplβl PPPjτβFCP_PIO) ) I I ( rβ*)_proeo . βwapl i PPP Nβr PID) ) ) ~ I / * turn down attβaptlnq to βrinq up NBFCP •/ p -ιdβ->protocols 4 -ppp PROT NBf; nppp_rβaβ I IpCall. p_Unk. NBFCP jLAYER. CP_INITIΛL> ; / • Paar NPPP Ooaa NOT support NetBEUI. DISABLING. •/ ) else If ( l rβ * )_proto « swaplβ I PPPjCCPjPIO) I I I < rβj_proto a βwaplβ ( PPP_C_PID) ) ) ~ ( /* turn down attaaptinq to drinq up CCP */ p ncβ->protocois -ppp PROT CCP; nppp raaat(IpCall. p_lιnk, CCP LAYER. CP INITIAL); Paar NPPP Ooaa NOT support Compreaaion, DISABLING. return; nppp_rcvrea β tr β q ~ Process tne received CCP RESET REOVEST froa tne peer. void nppp_revrβββtrβq < PCALLINFO IpCall, inkjCB t 'p linie, PPP layer t layer, GCAPACKET • pj ktT ( PPPjCBjt 'pjieo ■ *(lpCall->ppp) ; /• NPPP CS •/ SjCPCTL • pjicp • *ρ_iιnk-.>ajepctl (layer) ; if (p ncρ->epstatβ « CP OPEN) ( nppp j.oιr»p_rβsβt (IpCall) ; / • reset compression dictionary */ if (pjτeb->compressιon.alqontnat ~ COM PRESS JSTAC) nppp_aβndrβββtaek< IpCall. p_lmk, layer, " pjpkt ) ; else if lpjιcβ->comprβasιon. lgorithm — C_MPRXSS_MTCROSOFT) p ncB->mppc txjronβrβncy I - CCP A FLUSHED; ~ else ~ ( / ♦ COMPRESS ASCEND - do notnmq •/ I 1 return; 1 /• nppp_revrβsβtack — Process the received CCP RESET ACK froa tna paar. • / void nppp_rcvrβsβtack(PCALLINFO IpCall. Link_CB_t ♦ p_link, PPP_layβr_t layer, GCAPACKET •pjpkt " ~ I PPP_CB_t "P.ncβ - 4(lpCall->pppl; /• NPPP CB •/ SJCPCTL * lnep 4p_l nk->ajzpetl I layer) ; If (p ncp->cpβtatβ «- CP OPEN) I πpppjeoap_rβββt(IpCall); / • raaat coaprβsβlon dictionary •/ p ncB->βtaej3βcoap_pausβd Id • 0; / • elaar the oecoa paused ID •/ I return; I /• nppp_rcvunknown — Procoaa the received pkt with an UNKNONN COOC the paar. •/ void nppp revunknow (PCALLINro IpCall. Link CB t *p link, PPP layar t layar. GCAfACKTT 'pjpkt) I ppr_q_t •p. »--> - *<ipc*ιι->pppi; /• NPPP CB 3_CfCTfc * _. n β " 4p_link->a_cpctl(layar|; swltehlp ncp->cp*tatel < caaa C*_INIT_AL: /• Unexpected event •/ caaa cr'STAMTINOi /• Unexpected event •/ Break; caaa CP CLOSED: caaa CP~STO»ftθs caaa CP~C_C_INO: caaa CP ' STOPPINβ: caaa CP~RCς SENT: caaa CP~ACK~RCVO: caaa CPJJVCK JENT: npppjaβfidcodβrβ (IpCall, p_llnk, layar, pjpkt. p_ncp->epβtatβι Break; caaa CP OPEN: /• Before dβelaπnq down, send out code rβiβct pkt •/ nppp_s β n β coαβrβ-j (IpCall, p_lιnk. layer, p_pkt. CPJCLOSED) ; /• Soββthinq went wronq; restart neqotiatlons •/ nppp_rβstar IIpCall, ρ_lιnκ, layeri; /• Send our confiquration request •/ npppj»βndreq( IpCall, p_lmk, layer); p_ncp->cpstatβ - oreak.* default: /• iqnorβ • / Break; ) return; /• nppp_comp_ιnlt — Initialize tne compression seaalon. • / void nppp eoap mit ( PCALLINFO IpCall, Link CB t *p link) ( PPPJCBJΪ "Pjvsb ■ 4 ( lpCall->pppl ; / * NPPP CB unsigned short stae .mp_rβturn • 0; ulβ local switcnip neB->compreasion.alqorltha) ( caaa CCHPRESS STAC: caaa CCHPRESS^ASCENO: If Ip ncB->coaprββslon.alqorltna a CCHPRESS ASC NO) local mode • COMPRESS MO0C N TO N; else 1 if (p ncb->eep nua hlsts) local node-- COMPRESS MODE 1 TO 1; else local mode • COMPRESS MODE N TO N; 1 •• NOTE: call function to initialize tne htseoriaa (contexts) for •• STAC Compression alqorltna. Since tha STAC Coβprβaβlon •*> scneste is not intellectual property of USR, w cannot reveal •• lnforaacton pertaininq to it in tnis patent application. ••>»• I /• . . . INSERT FUNCTION CALL HERE . . . •/ /* (atac_cap_ratum - initialize tha STAC hiβtoriβa ) •/ 12 (acae cap return — CCHPRESS OKAY) ( /* finally. Indicate that sandjfraaws can eoapraaa outqoinq pkts • / p ιwA--4ooapraaβlon. coapreβsιnq~t> TRUE; ) a aa - " [ /• NPPP - Coaprβsβion Link OONN •/ ) Break; ease CCMPR£SS_MICROSOrT: /•••• •• NOTt: call function co initialize the hlβtorlaa (contexts) for "~ Microsoft Coβprβsslon alqorltna. Since tne Microsoft Coβprβaβlon ** βchβaβ la not intellectual property of USR, wa cannot reveal •• lnforaatlon pertaininq to it In tnis patent application. •••»• /• ... INSERT FUNCTION CALL HERE ... •/ / • finally. Indicate tnat sendjframβs can compress outqoinq puts •/ p_ncB->comprβssιon.compressing « TRUE; oreak; ) / « npppjeompjslosβ -- Close tne compression session. •/ vo id -ιpppjeompj.iosβ I PCALLINFO ipCall ) * • NOTE: call function to close tne nistorles (contexts) far " STAC Compression alqoπtnm. Since tne STAC Compression •• scnβ e is not intellectual property of USR, wβ cannot reveal •• information pertaininq to it in tnis patent application. ••-•/ / • ... INSERT FUNCTION CALL HERE ... • / npppjeo pjresβt — Reset Iclear) tne compression histories. void nppp comp reset ( PCALLINFO IpCall) ( PPP_CB_t *p_neB 4(lpCall->ppp); /• NPPP CB i f I p_nee->cotaprasslon . alqorltna — CCMPRtSS_MICROSOFT) • * NOTE: call function to raaat tna Mlcroaoft Coapraβslon •• TX context. Since the Microsoft Coaprβββion seheae is not •• intellectual property of USR, wa cannot reveal it in thlβ •* patent application. /• ... INSERT FUNCTION CALL HERE ... •/ else • NOTE: call function to reβet tne STAC Compression • TX context. Since tne STAC Coaprβββion scneete is not * intellectual property of USR. we cannot reveal it in tnis * patent application. INSERT FUNCTION CALL HERE nppp_rβlβaaβ_link - Stop the specified link void nppp release link!PCALLINFO IpCall, Link CB t -p link) I int 1; nppp_inlt_all_layerstIpCall. p_link, CP_ΣNITΣAL); /• Now tnat PPP haa settled down its activity for this link, brlnq •/ /• the link down. • / fsa Ik executeILK EVENT STOP, IpCall. (void *) p link, 0); ) /• • nppp check ow • Should tha Bandwidtn Be adjusted •/ void nppp enβck_Pw( PCALLINFO IpCall) I PPP_CB_t *P_nco - -lpCall->ppp; /• PPP CB •/ _ιnk_C8_t • p_Iιnk; u32 ~ ~ seconds y_link; p_link - GβtPrimaryLlnklIpCall); /• Oo not expand a call if MultiLink is not enapled */ /• In fact, do not restart tne timer to cneck. • / if (lpCall->IseCaiiOata.dwEncapaulation •• PPPML_EHULATION) return; /• Oo not expand a call unless we originated it */ / • and tnat we nave not exnausted or retry count •/ / ' In fact, βo not restart tne timer to enβek. •/ if ( I (IpCall-XϊwOriςin -a LINECALLORIGIN EXTERNAL) I I (IpCall-x-JwOriςin - * .INECA_LORIβIN_ΪNβOUNO) I II (p ncp->eall_rβtry_ent — MAX_CAL__RETMES) ) return; /• Restart tna timer before carrying on. This will βnausa tnat we •/ /* will return to enβek tnis. •/ sβt_nppp_tιmβr(PPP_CHECKBH_TIMEOUT. IpCall. NUU.. 0. PPP_TIMER3); / • Oo not expand a call if tnere are NO available channels •/ / • If no cnannels are available, restart tiswr and check again •/ /• on tne next timer expiration • / If (lpCali->num_ nks > 1) return; if (GetPrimaryLinkldxlIpCall, p link)) { secondary link 0; I else ( secondary link ι ; I ρ_neb->call_rβtry_cnf>fj / • bump the retry count •/ / ♦ kick off the second call •/ fsm_lk_βxβcute ι U«;_EVXNT__TAΛT, IpCall. " ( void • ) 41pCΪll->llnk ( ββcondary_l lnk l . ( void • ) 4JlpCall->Unk( sβcondary2link| .dlstant_addr) ; *Λpp_lβ_grβatβr_tnan - find out which value is greater, return BOOL. •/ BOOL app la greater than(u_2 a. u_2 b) ( If (a -a b) return l-O-SE; if I (a * b) t OxβOOOOO) ( /• wrap case */ if la < b) return TRUE; else return FALSE; I else I if (a < b) return FALSE; else rβturn TRUE; ! I /• * ppp_ιs_betweβn - Compare sequence numbers •/ BOOL ppp_ιs_bβtwββn(u32 a. 22 b, u32 c) if ll(a < β) ii (0 < e) ) I I (le < a) ii la <•» e) ) π l(b < e) 4« lc < a)l) return(TRUE) ; else return(FALSE) ; I

Claims: WE CLAIM: 1. In a system comprising a source of data, a receiver of data and a communication channel linking the source and the receiver, a method for setting up a data transmission session between an local endpoint application at said source and a network endpoint application at said receiver with a proxy engine in a transparent manner, comprising the steps of: conducting simultaneous communication sessions with the proxy engine with the local endpoint application and the network endpoint application, said proxy engine: (1) determining at least one of the following: (a) security protocols, (b) multiple channel capabilities, (c) data compression techniques, or (d) network control protocols, that are supported by the network endpoint application, (2) determining at least one of the following: (a) security protocols or (b) network control protocols, that are supported by the local endpoint application; and (3) enabling at least one of the following: (a) the security protocols, (b) multiple channel capabilities, (c) data compression techniques, or (4) network protocols that are supported by both (i) the network endpoint application, and (ii) the combination of the proxy engine and the local endpoint application, and thereafter transmitting data between the local endpoint application and the network endpoint application, whereby data may be transmitted from the source of the data to the receiver of the data over the communication channel. 2. The method of claim 1, wherein said communication channel supports a plurality of communication channels, and wherein the method further comprises the step of: opening up multiple communication channels for transmission of said data between the source and the receiver of said data, and transmitting said data over said multiple channels simultaneously from the proxy engine to the receiver. 3. The method of claim 1, wherein said communication channel comprises a digital telephone line. 4. The method of claim 3, wherein said communication channel comprises an ISDN B-channel. 5. The method of claim 2, wherein said multiple communication channels comprise ISDN B-channels. 6. The method of claim 1 , further comprising the steps of: determining whether the network endpoint application specifies a password authentication with the local endpoint application, and if the password authentication is specified, enabling a password authentication control protocol with the local endpoint application. 7. In a system comprising a source of digital data, a receiver of said data and a communication line connecting the source with the receiver, a method for setting up a data transmission session between a local endpoint application and a network endpoint application with a proxy engine, the proxy engine conducting a communication session with the local endpoint application and network endpoint application simultaneously in a manner transparent to a user of the system, comprising the steps of: (a) placing a call between the source and the receiver over the communication line; (b) enabling the link-control-protocol (LCP) layer of the network endpoint application; (c) enabling the LCP layer of the local endpoint application; (d) determining which network control protocols are supported by the local endpoint application; (e) for each network control protocol determined in step (d), enabling the respective network control protocol in said network endpoint application; (f) enabling the respective local endpoint application network control protocols supported by the local endpoint application; and (g) transferring data between said local endpoint application and said network endpoint application. 8. The method of claim 7, wherein the steps (a)-(g) are performed in consecutive, sequential order. 9. The method of claim 7, further comprising the steps of: (h) determining which data compression protocols the network endpoint application is attempting to establish, and (i) implementing said data compression protocols in said proxy engine if said data compression protocols are supported by said proxy engine. 10. The method of claim 7, wherein said communication line comprises a plurality of communication channels, said data transmission occupying a first channel of said plurality of communication channels, and wherein the method further comprises the step of: establishing multiple communication channels between said network endpoint application and said local endpoint application and transmitting said data through more than one of said plurality of communication channels. 11. The method of claim 7 wherein said communication line comprises an ISDN line. 12. The method of claim 7, further comprising the steps of: determining whether said network endpoint application specifies a password authentication prior to establishing the network control protocols, and if said password authentication is specified, initiating a password authentication control protocol with the local endpoint application. 13. The method of claim 1 , wherein said proxy engine further performs the steps of: determining the data compression protocols the network endpoint application is attempting to establish, and implementing said data compression protocols in said proxy engine if said data compression protocols are supported by the proxy engine. 14. Apparatus for linking an application running at a source of digital data with an application running at a receiver of said digital data over a communication channel, comprising, in combination: a proxy engine means for conducting simultaneous communication sessions between said source and said receiver, said proxy engine comprising (a) means for enabling at least one compression algorithm or at least one multiple channel protocol, (b) means for determining the compression algorithm and multiple channel protocols supported by said application running at said receiver of said digital data; (c) means for implementing said at least one compression r algorithm or said at least one multiple channel protocol if said J compresion algorithm or multiple channel protocol is supported by said application running at said recevier; and 5 communication hardware means interfacing with said communication channel for placing said data from said application running at said source onto said communication channel from transmission to said receiver. 15. The apparatus of claim 14, wherein said proxy engine further comprises: (d) means for enabling at least one network control protocol. 16. The apparatus of claim 14, wherein said communication channel comprises a digital telephone line. 17. The apparatus of claim 16, wherein said communication channel comprises an ISDN line. 18. The apparatus of claim 17, wherein said communication channel comprises an ISDN B-channel. 19. The apparatus of claim 14, wherein said multiple channel protocol comprises PPPML. 20. Apparatus for linking an application running at a source of digital data with an application running at a receiver of said digital data over a communication channel, comprising, in combination: a proxy engine means for conducting simultaneous communication sessions between said source and said receiver, said proxy engine comprising (a) means for enabling at least a first authentication protocol, (b) means for determining the authentication protocol specified by said application running at said receiver of said digital data; (c) means for implementing said first authentication protocol if said receiver application -specified protocol corresponds to said first authentication protocol; and communication hardware means interfacing with said communication channel for placing said data from said application running at said source onto said communication channel from transmission to said receiver. 21. The apparatus of claim 20, wherein said first authentication protocol comprises PAP. 22. The apparatus of claim 20, wherein said first authentication protocol comprises CHAP.

Inventors: KRALOWETZ JOSEPH D, ORTEGA DOUGLAS F, KRALOWETZ, JOSEPH, D., ORTEGA, DOUGLAS, F.
Applicants: U S ROBOTICS CORP, U.S. ROBOTICS CORPORATION
Application year: 1996
Main classification: G06F9
IPC codes: H04L29, H04Q11