pppout.c

Go to the documentation of this file.
00001 
00066 /*
00067  * $Log: pppout.c,v $
00068  * Revision 1.7  2005/04/30 16:42:42  chaac
00069  * Fixed bug in handling of NUTDEBUG. Added include for cfg/os.h. If NUTDEBUG
00070  * is defined in NutConf, it will make effect where it is used.
00071  *
00072  * Revision 1.6  2005/04/08 15:20:51  olereinhardt
00073  * added <sys/types.h> (__APPLE__) and <netinet/in.h> (__linux__)
00074  * for htons and simmilar.
00075  *
00076  * Revision 1.5  2004/03/16 16:48:45  haraldkipp
00077  * Added Jan Dubiec's H8/300 port.
00078  *
00079  * Revision 1.4  2004/03/08 11:28:23  haraldkipp
00080  * HDLC functions moved to async HDLC driver.
00081  *
00082  * Revision 1.3  2003/08/14 15:15:28  haraldkipp
00083  * Unsuccessful try to fix ICCAVR bug
00084  *
00085  * Revision 1.2  2003/07/13 19:09:59  haraldkipp
00086  * Debug output fixed.
00087  *
00088  * Revision 1.1.1.1  2003/05/09 14:41:37  haraldkipp
00089  * Initial using 3.2.1
00090  *
00091  * Revision 1.2  2003/05/06 18:17:58  harald
00092  * PPP hack for simple UART support
00093  *
00094  * Revision 1.1  2003/03/31 14:53:28  harald
00095  * Prepare release 3.1
00096  *
00097  */
00098 
00099 #include <cfg/os.h>
00100 #include <string.h>
00101 
00102 #include <dev/ppp.h>
00103 #include <dev/ahdlc.h>
00104 #include <netinet/in.h>
00105 #include <netinet/if_ppp.h>
00106 #include <net/ppp.h>
00107 #include <sys/types.h>
00108 #include <sys/timer.h>
00109 
00110 #ifdef NUTDEBUG
00111 #include <net/netdebug.h>
00112 #endif
00113 
00118 
00119 
00135 int NutPppOutput(NUTDEVICE * dev, u_short type, u_char * ha, NETBUF * nb)
00136 {
00137     PPPHDR *ph;
00138     IFNET *nif = dev->dev_icb;
00139     PPPDCB *dcb = dev->dev_dcb;
00140 
00141     /*
00142      * Allocate and set the HDLC header.
00143      */
00144     if (NutNetBufAlloc(nb, NBAF_DATALINK, sizeof(PPPHDR)) == 0)
00145         return -1;
00146 
00147     ph = (PPPHDR *) nb->nb_dl.vp;
00148     ph->address = AHDLC_ALLSTATIONS;
00149     ph->control = AHDLC_UI;
00150     ph->prot_type = htons(type);
00151 
00152 #ifdef NUTDEBUG
00153     if (__ppp_trf) {
00154         fputs("\nPPP<", __ppp_trs);
00155         NutDumpPpp(__ppp_trs, nb);
00156     }
00157 #elif defined(__IMAGECRAFT__)
00158     /*
00159      * No idea what this is, but ICCAVR fails if this call isn't there.
00160      */
00161     NutSleep(100);
00162 #endif
00163 
00164     /*
00165      * Call the physical device output routine.
00166      */
00167     if (nif->if_send && (*nif->if_send) ((((NUTFILE *) (uptr_t) (dcb->dcb_fd)))->nf_dev, nb) == 0) {
00168         return 0;
00169     }
00170     NutNetBufFree(nb);
00171     return -1;
00172 }
00173 
00174 

© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/