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