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