Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages   Examples  

PPPif.h

00001 #ifndef _DEV_PPPif_H_
00002 #define _DEV_PPPif_H_
00003 
00004 /*
00005  * Copyright (C) 2002 by Call Direct Cellular Solutions Pty. Ltd. All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions
00009  * are met:
00010  *
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in the
00015  *    documentation and/or other materials provided with the distribution.
00016  * 3. All advertising materials mentioning features or use of this
00017  *    software must display the following acknowledgement:
00018  *
00019  *    This product includes software developed by Call Direct Cellular Solutions Pty. Ltd
00020  *    and its contributors.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY CALL DIRECT CELLULAR SOLUTIONS AND CONTRIBUTORS
00023  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CALL DIRECT
00026  * CELLULAR SOLUTIONS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00029  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00030  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00031  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00032  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00033  * SUCH DAMAGE.
00034  *
00035  * For additional information see http://www.calldirect.com.au/
00036  *
00037  * -
00038  * Portions Copyright (C) 2001 by egnite Software GmbH. All rights reserved.
00039  *
00040  * Redistribution and use in source and binary forms, with or without
00041  * modification, are permitted provided that the following conditions
00042  * are met:
00043  *
00044  * 1. Redistributions of source code must retain the above copyright
00045  *    notice, this list of conditions and the following disclaimer.
00046  * 2. Redistributions in binary form must reproduce the above copyright
00047  *    notice, this list of conditions and the following disclaimer in the
00048  *    documentation and/or other materials provided with the distribution.
00049  * 3. All advertising materials mentioning features or use of this
00050  *    software must display the following acknowledgement:
00051  *
00052  *    This product includes software developed by egnite Software GmbH
00053  *    and its contributors.
00054  *
00055  * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
00056  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00057  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00058  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
00059  * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00060  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00061  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00062  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00063  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00064  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00065  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00066  * SUCH DAMAGE.
00067  *
00068  * For additional information see http://www.ethernut.de/
00069  *
00070  * -
00071  * Portions Copyright (C) 2000 David J. Hudson <dave@humbug.demon.co.uk>
00072  *
00073  * This file is distributed in the hope that it will be useful, but WITHOUT
00074  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00075  * FITNESS FOR A PARTICULAR PURPOSE.
00076  *
00077  * You can redistribute this file and/or modify it under the terms of the GNU
00078  * General Public License (GPL) as published by the Free Software Foundation;
00079  * either version 2 of the License, or (at your discretion) any later version.
00080  * See the accompanying file "copying-gpl.txt" for more details.
00081  *
00082  * As a special exception to the GPL, permission is granted for additional
00083  * uses of the text contained in this file.  See the accompanying file
00084  * "copying-liquorice.txt" for details.
00085  */
00086 
00087 /*
00088  * $Log: PPPif.h,v $
00089  * Revision 1.2  2003/01/24 12:01:09  przemko
00090  * Obciecie dosowych znakow konca lini
00091  *
00092  * Revision 1.1.1.1  2002/12/07 07:16:52  marwi
00093  *
00094  *
00095  * Revision 1.1  2002/11/02 15:17:42  harald
00096  * First check in
00097  *
00098  *
00099  * Revision 1.0  2002/03/28 MJC CDCS
00100  * New device structure implemented
00101  *
00102  */
00103 
00104 #include <dev/netbuf.h>
00105 #include <net/if_var.h>
00106 
00115 //typedef struct _PPPINFO PPPINFO;
00116 
00121 typedef struct _PPPINFO {
00122 //    volatile u_char ppp_rx_cnt;               /*!< # of packets in NIC buffer. */
00123     //u_char ppp_tx_bsy;                                        /*!< PPP transmitter busy flags. */
00124 //    HANDLE ppp_rx_rdy;                                /*!< Receiver event queue. */
00125 //    HANDLE ppp_tx_rdy;                                /*!< Transmitter event queue. */
00126         HANDLE ppp_state_chg;                           
00127     HANDLE ppp_tx_asy;                                  
00128     NETBUF * volatile ppp_tx_nbq;               
00129     u_long ppp_rx_packets;                              
00130     u_long ppp_tx_packets;                              
00131 //    u_long ppp_interrupts;                    /*!< Number of interrupts. */
00132 //    u_long ppp_overruns;                              /*!< Number of packet overruns. */
00133 //    u_long ppp_rx_frame_errors;               /*!< Number of frame errors. */
00134     u_long ppp_rx_crc_errors;                   
00135 //    u_long ppp_rx_missed_errors;              /*!< Number of missed packets. */
00136         u_char  ppp_lcp_id;
00137         u_short ppp_mru;                                        
00138         u_long  ppp_accm;
00139         u_char  ppp_usePFC;
00140         u_char  ppp_useACFC;
00141         u_short ppp_auth;
00142         u_long  ppp_magic;
00143         u_char  ppp_state;
00144         u_char  ppp_retry;
00145         HANDLE  ppp_tx_thread;
00146         HANDLE  ppp_rx_thread;
00147 
00148 } PPPINFO;
00149 
00150 // ppp_state bits all 0's = DEAD
00151 #define DEAD    0
00152 #define LINK_UP 1
00153 #define LCP_UP  2
00154 #define AUTH_UP 4
00155 #define IPCP_UP 8
00156 #define PPP_UP  0x0F            
00157 
00158 typedef struct ppp_header {
00159         u_char  address;                                
00160         u_char  control;                                
00161         u_short prot_type;                              
00162 } PPPHDR;
00163 
00164 typedef struct lcphdr 
00165 {
00166     u_char      code;                                   
00167     u_char      id;                                             
00168     u_short     len;                                    
00169 } LCPHDR;
00170 
00171 typedef struct lcpopt 
00172 {
00173     u_char      type;                                   
00174     u_char      len;                                    
00175     u_char  *data;                                      
00176 } LCPOPT;
00177 
00178 /*
00179  * Definitions
00180  */
00181 #define PPP_MRU                 1500
00182 
00183 #define PROT_PAP            0xC023
00184 #define PROT_LCP            0xC021
00185 #define PROT_IPCP       0x8021
00186 #define PROT_IP         0x0021
00187 
00188 //#define ICMP            0x01
00189 //#define TCP             0x06
00190 
00191 #define DEFAULT_TTL     64
00192 
00193 #define HDLC_FLAG       0x7E
00194 #define HDLC_ESCAPE     0x7D
00195 
00196 #define FCS_GOOD                0xF0B8
00197 
00198 //#define PPP_Offset      5           // Number of bytes preceeding the PPP payload
00199 
00200 //#define XCP_BadOpt      128         // Location in buffer to copy bad options to
00201 
00202 #define XCP_CODE        0
00203 #define XCP_ID          1
00204 #define XCP_LEN_H       2
00205 #define XCP_LEN_L       3
00206 #define XCP_FIRST_OP    4
00207 
00208 #define XCP_CR          1           // LCP/IPCP Configure-Request Code
00209 #define XCP_CA          2           // LCP/IPCP Configure-Ack Code
00210 #define XCP_CN          3           // LCP/IPCP Configure-Nack Code
00211 #define XCP_CRJ         4           // LCP/IPCP Configure-Reject Code
00212 #define XCP_TR          5           // LCP/IPCP Terminate-Request Code
00213 #define XCP_TA          6           // LCP/IPCP Terminate-Ack Code
00214 #define XCP_CDRJ        7           // LCP/IPCP Code-Reject Code
00215 #define LCP_PRJ         8           // LCP Protocol-Reject Code
00216 #define LCP_ERQ         9           // LCP Echo-Request Code
00217 #define LCP_ERP         10          // LCP Echo-Response Code
00218 #define LCP_DRQ         11          // LCP Discard-Request Code
00219 
00220 #define LCP_MRU         1           // LCP MRU Option
00221 #define LCP_ACCM        2           // LCP Async Control Map Option
00222 #define LCP_AUTH        3           // LCP Authentication Protocol Option
00223 #define LCP_QUAL        4           // LCP Quality Protocol Option
00224 #define LCP_MAGIC       5           // LCP Magic Number Option
00225 #define LCP_PFC         7           // LCP Protocol field compression Option
00226 #define LCP_ACFC        8           // LCP Address/Control field compression Option
00227 
00228 #define IPCP_ADDRESSES  1           // IPCP Ip Addresses Option (deprecated)
00229 #define IPCP_COMPRESS   2           // IPCP Compression Option
00230 #define IPCP_ADDRESS    3           // IPCP Ip Address Option
00231 #define IPCP_PRI_DNS    0x81        // IPCP Primary DNS Address
00232 #define IPCP_SEC_DNS    0x83        // IPCP Secondary DNS Address
00233 
00234 #define PAP_REQ         1           // PAP Authenticate request
00235 #define PAP_ACK         2           // PAP Accept
00236 #define PAP_NACK        3           // PAP Reject
00237 
00238 
00239 /*
00240  * Available drivers.
00241  */
00242 extern NUTDEVICE devPPP0;
00243 extern NUTDEVICE devPPP1;
00244 
00245 
00246 /*
00247  * Driver routines.
00248  */
00249 extern int PPPInit(NUTDEVICE *dev);
00250 extern int PPPOutput(NUTDEVICE *dev, NETBUF *nb);
00251 extern void PPPInput(NUTDEVICE *dev, NETBUF *nb);
00252 extern int NutPPPOutput(NUTDEVICE *dev, u_short type, NETBUF *nb);
00253 extern u_char PPPGetState (NUTDEVICE *dev);
00254 //extern void PPPSetState (NUTDEVICE *dev, u_char state);
00255 extern void PPPTerminateSesion (NUTDEVICE *dev);
00256 extern void PPPLCPRequestOptions(NUTDEVICE *dev);
00257 extern int CDNetPPPConnect (NUTDEVICE *dev, CONST char *scriptin);
00258 #endif

Generated on Thu Jan 30 22:30:51 2003 for EduNet by doxygen1.2.18