124#ifndef PPP_INPROC_MULTITHREADED 
  125#define PPP_INPROC_MULTITHREADED (NO_SYS==0) 
  131#ifndef PPP_INPROC_OWNTHREAD 
  132#define PPP_INPROC_OWNTHREAD      PPP_INPROC_MULTITHREADED 
  135#if PPP_INPROC_OWNTHREAD && !PPP_INPROC_MULTITHREADED 
  136  #error "PPP_INPROC_OWNTHREAD needs PPP_INPROC_MULTITHREADED==1" 
  142#define PPP_ADDRESS(p)  (((u_char *)(p))[0]) 
  143#define PPP_CONTROL(p)  (((u_char *)(p))[1]) 
  144#define PPP_PROTOCOL(p) ((((u_char *)(p))[2] << 8) + ((u_char *)(p))[3]) 
  158#define ESCAPE_P(accm, c) ((accm)[(c) >> 3] & pppACCMMask[c & 0x07]) 
  165#ifndef PPPOS_RX_BUFSIZE 
  166#define PPPOS_RX_BUFSIZE    (PPP_MRU + PPP_HDRLEN) 
  169typedef struct PPPControlRx_s {
 
  175#if PPP_INPROC_OWNTHREAD 
  176  u_char rxbuf[PPPOS_RX_BUFSIZE];
 
  180  struct pbuf *inHead, *inTail;
 
  186  PPPDevStates inState;         
 
  194typedef struct PPPControl_s {
 
  199  struct pppoe_softc *pppoe_sc;
 
  211#if PPPOS_SUPPORT && VJ_SUPPORT 
  218  struct ppp_addrs addrs;
 
  220  void (*linkStatusCB)(
void *ctx, 
int errCode, 
void *arg);
 
  241#if PPP_INPROC_OWNTHREAD 
  242static void pppInputThread(
void *arg);
 
  244static void pppDrop(PPPControlRx *pcrx);
 
  245static void pppInProc(PPPControlRx *pcrx, u_char *s, 
int l);
 
  246static void pppFreeCurrentInputPacket(PPPControlRx *pcrx);
 
  255static PPPControl pppControl[NUM_PPP]; 
 
  262struct protent *ppp_protocols[] = {
 
  285u_char outpacket_buf[NUM_PPP][PPP_MRU+PPP_HDRLEN];
 
  297static const u_short fcstab[256] = {
 
  298  0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
 
  299  0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
 
  300  0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
 
  301  0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
 
  302  0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
 
  303  0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
 
  304  0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
 
  305  0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
 
  306  0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
 
  307  0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
 
  308  0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
 
  309  0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
 
  310  0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
 
  311  0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
 
  312  0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
 
  313  0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
 
  314  0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
 
  315  0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
 
  316  0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
 
  317  0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
 
  318  0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
 
  319  0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
 
  320  0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
 
  321  0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
 
  322  0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
 
  323  0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
 
  324  0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
 
  325  0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
 
  326  0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
 
  327  0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
 
  328  0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
 
  329  0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
 
  334static u_char pppACCMMask[] = {
 
  345#if PPP_INPROC_OWNTHREAD 
  351  if (pppControl[pd].openFlag != 0) {
 
  359pppLinkTerminated(
int pd)
 
  364  if (pppControl[pd].ethif) {
 
  365    pppoe_disconnect(pppControl[pd].pppoe_sc);
 
  371#if PPP_INPROC_OWNTHREAD 
  374    pc = &pppControl[pd];
 
  376    PPPDEBUG(
LOG_DEBUG, (
"pppLinkTerminated: unit %d: linkStatusCB=%p errCode=%d\n", pd, pc->linkStatusCB, pc->errCode));
 
  377    if (pc->linkStatusCB) {
 
  378      pc->linkStatusCB(pc->linkStatusCtx, pc->errCode ? pc->errCode : PPPERR_PROTOCOL, 
NULL);
 
  393  if (pppControl[pd].ethif) {
 
  394    pppoe_disconnect(pppControl[pd].pppoe_sc);
 
  398#if PPPOS_SUPPORT && PPP_INPROC_OWNTHREAD 
  436struct ppp_settings ppp_settings;
 
  441  struct protent *protp;
 
  444  memset(&ppp_settings, 0, 
sizeof(ppp_settings));
 
  445  ppp_settings.usepeerdns = 1;
 
  446  pppSetAuth(PPPAUTHTYPE_NONE, 
NULL, 
NULL);
 
  450  subnetMask = 
PP_HTONL(0xffffff00UL);
 
  452  for (i = 0; i < NUM_PPP; i++) {
 
  454    for (
j = 0; (protp = ppp_protocols[
j]) != 
NULL; ++
j) {
 
  461pppSetAuth(
enum pppAuthType authType, 
const char *user, 
const char *passwd)
 
  464    case PPPAUTHTYPE_NONE:
 
  466#ifdef LWIP_PPP_STRICT_PAP_REJECT 
  467      ppp_settings.refuse_pap = 1;
 
  470      ppp_settings.refuse_pap = 0;
 
  472      ppp_settings.refuse_chap = 1;
 
  475    case PPPAUTHTYPE_ANY:
 
  495      ppp_settings.refuse_pap = 0;
 
  496      ppp_settings.refuse_chap = 0;
 
  499    case PPPAUTHTYPE_PAP:
 
  500      ppp_settings.refuse_pap = 0;
 
  501      ppp_settings.refuse_chap = 1;
 
  504    case PPPAUTHTYPE_CHAP:
 
  505      ppp_settings.refuse_pap = 1;
 
  506      ppp_settings.refuse_chap = 0;
 
  511    strncpy(ppp_settings.user, user, 
sizeof(ppp_settings.user)-1);
 
  512    ppp_settings.user[
sizeof(ppp_settings.user)-1] = 
'\0';
 
  514    ppp_settings.user[0] = 
'\0';
 
  518    strncpy(ppp_settings.passwd, passwd, 
sizeof(ppp_settings.passwd)-1);
 
  519    ppp_settings.passwd[
sizeof(ppp_settings.passwd)-1] = 
'\0';
 
  521    ppp_settings.passwd[0] = 
'\0';
 
  537pppOverSerialOpen(
sio_fd_t fd, pppLinkStatusCB_fn linkStatusCB, 
void *linkStatusCtx)
 
  542  if (linkStatusCB == 
NULL) {
 
  549  for (pd = 0; pd < NUM_PPP && pppControl[pd].openFlag != 0; pd++);
 
  554    pc = &pppControl[pd];
 
  556    pppFreeCurrentInputPacket(&pc->rx);
 
  558    memset(pc, 0, 
sizeof(PPPControl));
 
  573    pc->rx.inACCM[15] = 0x60; 
 
  574    pc->outACCM[15] = 0x60;
 
  576    pc->linkStatusCB = linkStatusCB;
 
  577    pc->linkStatusCtx = linkStatusCtx;
 
  584#if PPP_INPROC_OWNTHREAD 
  594static void pppOverEthernetLinkStatusCB(
int pd, 
int up);
 
  597pppOverEthernetClose(
int pd)
 
  599  PPPControl* pc = &pppControl[pd];
 
  604  pppoe_destroy(&pc->netif);
 
  607int pppOverEthernetOpen(
struct netif *ethif, 
const char *service_name, 
const char *concentrator_name,
 
  608                        pppLinkStatusCB_fn linkStatusCB, 
void *linkStatusCtx)
 
  616  if (linkStatusCB == 
NULL) {
 
  623  for (pd = 0; pd < NUM_PPP && pppControl[pd].openFlag != 0; pd++);
 
  627    pc = &pppControl[pd];
 
  628    memset(pc, 0, 
sizeof(PPPControl));
 
  632    pc->linkStatusCB  = linkStatusCB;
 
  633    pc->linkStatusCtx = linkStatusCtx;
 
  645    if(pppoe_create(ethif, pd, pppOverEthernetLinkStatusCB, &pc->pppoe_sc) != 
ERR_OK) {
 
  650    pppoe_connect(pc->pppoe_sc);
 
  664  PPPControl *pc = &pppControl[pd];
 
  673    pc->errCode = PPPERR_USER;
 
  681    pc->errCode = PPPERR_USER;
 
  684#if PPP_INPROC_OWNTHREAD 
  703nPut(PPPControl *pc, 
struct pbuf *nb)
 
  708  for(b = nb; b != 
NULL; b = b->
next) {
 
  711               (
"PPP nPut: incomplete sio_write(fd:%"SZT_F", len:%d, c: 0x%"X8_F") c = %d\n", (
size_t)pc->fd, b->
len, 
c, 
c));
 
  733pppAppend(u_char 
c, 
struct pbuf *nb, ext_accm *outACCM)
 
  735  struct pbuf *tb = nb;
 
  752    if (outACCM && ESCAPE_P(*outACCM, 
c)) {
 
  753      *((u_char*)nb->
payload + nb->
len++) = PPP_ESCAPE;
 
  754      *((u_char*)nb->
payload + nb->
len++) = 
c ^ PPP_TRANS;
 
  766pppifOutputOverEthernet(
int pd, 
struct pbuf *p)
 
  768  PPPControl *pc = &pppControl[pd];
 
  770  u_short protocol = PPP_IP;
 
  787  if (!pc->pcomp || protocol > 0xFF) {
 
  788    *((u_char*)pb->
payload + i++) = (protocol >> 8) & 0xFF;
 
  790  *((u_char*)pb->
payload + i) = protocol & 0xFF;
 
  795  if(pppoe_xmit(pc->pppoe_sc, pb) != 
ERR_OK) {
 
  798    return PPPERR_DEVICE;
 
  813  PPPControl *pc = &pppControl[pd];
 
  815  u_short protocol = PPP_IP;
 
  816  u_int fcsOut = PPP_INITFCS;
 
  826  if (pd < 0 || pd >= NUM_PPP || !pc->openFlag || !pb) {
 
  846    return pppifOutputOverEthernet(pd, pb);
 
  853  if (headMB == 
NULL) {
 
  866  if (protocol == PPP_IP && pc->vjEnabled) {
 
  873        protocol = PPP_VJC_COMP;
 
  876        protocol = PPP_VJC_UNCOMP;
 
  892  if ((
sys_jiffies() - pc->lastXMit) >= PPP_MAXIDLEFLAG) {
 
  893    tailMB = pppAppend(PPP_FLAG, tailMB, 
NULL);
 
  898    fcsOut = PPP_FCS(fcsOut, PPP_ALLSTATIONS);
 
  899    tailMB = pppAppend(PPP_ALLSTATIONS, tailMB, &pc->outACCM);
 
  900    fcsOut = PPP_FCS(fcsOut, PPP_UI);
 
  901    tailMB = pppAppend(PPP_UI, tailMB, &pc->outACCM);
 
  903  if (!pc->pcomp || protocol > 0xFF) {
 
  904    c = (protocol >> 8) & 0xFF;
 
  905    fcsOut = PPP_FCS(fcsOut, 
c);
 
  906    tailMB = pppAppend(
c, tailMB, &pc->outACCM);
 
  909  fcsOut = PPP_FCS(fcsOut, 
c);
 
  910  tailMB = pppAppend(
c, tailMB, &pc->outACCM);
 
  913  for(p = pb; p; p = p->next) {
 
  917    sPtr = (u_char*)p->payload;
 
  923      fcsOut = PPP_FCS(fcsOut, 
c);
 
  926      tailMB = pppAppend(
c, tailMB, &pc->outACCM);
 
  932  tailMB = pppAppend(
c, tailMB, &pc->outACCM);
 
  933  c = (~fcsOut >> 8) & 0xFF;
 
  934  tailMB = pppAppend(
c, tailMB, &pc->outACCM);
 
  935  tailMB = pppAppend(PPP_FLAG, tailMB, 
NULL);
 
  940             (
"pppifOutput[%d]: Alloc err - dropping proto=%d\n", 
 
  961pppIOCtl(
int pd, 
int cmd, 
void *arg)
 
  963  PPPControl *pc = &pppControl[pd];
 
  966  if (pd < 0 || pd >= NUM_PPP) {
 
  970    case PPPCTLG_UPSTATUS:      
 
  972        *(
int *)arg = (
int)(pc->if_up);
 
  977    case PPPCTLS_ERRCODE:       
 
  979        pc->errCode = *(
int *)arg;
 
  984    case PPPCTLG_ERRCODE:       
 
  986        *(
int *)arg = (
int)(pc->errCode);
 
 1015  PPPControl *pc = &pppControl[pd];
 
 1019  if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) {
 
 1030pppWriteOverEthernet(
int pd, 
const u_char *s, 
int n)
 
 1032  PPPControl *pc = &pppControl[pd];
 
 1039  LWIP_ASSERT(
"PPPOE_HDRLEN + n <= 0xffff", PPPOE_HDRLEN + n <= 0xffff);
 
 1045    return PPPERR_ALLOC;
 
 1054  if(pppoe_xmit(pc->pppoe_sc, pb) != 
ERR_OK) {
 
 1057    return PPPERR_DEVICE;
 
 1073pppWrite(
int pd, 
const u_char *s, 
int n)
 
 1075  PPPControl *pc = &pppControl[pd];
 
 1079  struct pbuf *headMB, *tailMB;
 
 1084    return pppWriteOverEthernet(pd, s, n);
 
 1090  if (headMB == 
NULL) {
 
 1094    return PPPERR_ALLOC;
 
 1101  if ((
sys_jiffies() - pc->lastXMit) >= PPP_MAXIDLEFLAG) {
 
 1102    tailMB = pppAppend(PPP_FLAG, tailMB, 
NULL);
 
 1106  fcsOut = PPP_INITFCS;
 
 1112    fcsOut = PPP_FCS(fcsOut, 
c);
 
 1115    tailMB = pppAppend(
c, tailMB, &pc->outACCM);
 
 1120  tailMB = pppAppend(
c, tailMB, &pc->outACCM);
 
 1121  c = (~fcsOut >> 8) & 0xFF;
 
 1122  tailMB = pppAppend(
c, tailMB, &pc->outACCM);
 
 1123  tailMB = pppAppend(PPP_FLAG, tailMB, 
NULL);
 
 1129             (
"pppWrite[%d]: Alloc err - dropping pbuf len=%d\n", pd, headMB->
len));
 
 1135    return PPPERR_ALLOC;
 
 1151ppp_send_config( 
int unit, 
u16_t mtu, 
u32_t asyncmap, 
int pcomp, 
int accomp)
 
 1153  PPPControl *pc = &pppControl[unit];
 
 1158  pc->accomp = accomp;
 
 1161  for (i = 0; i < 32/8; i++) {
 
 1162    pc->outACCM[i] = (u_char)((asyncmap >> (8 * i)) & 0xFF);
 
 1166            pc->outACCM[0], pc->outACCM[1], pc->outACCM[2], pc->outACCM[3]));
 
 1174ppp_set_xaccm(
int unit, ext_accm *accm)
 
 1176  SMEMCPY(pppControl[unit].outACCM, accm, 
sizeof(ext_accm));
 
 1179            pppControl[unit].outACCM[0],
 
 1180            pppControl[unit].outACCM[1],
 
 1181            pppControl[unit].outACCM[2],
 
 1182            pppControl[unit].outACCM[3]));
 
 1191ppp_recv_config( 
int unit, 
int mru, 
u32_t asyncmap, 
int pcomp, 
int accomp)
 
 1193  PPPControl *pc = &pppControl[unit];
 
 1203  for (i = 0; i < 32 / 8; i++) {
 
 1205    pc->rx.inACCM[i] = (u_char)(asyncmap >> (i * 8));
 
 1210            pc->rx.inACCM[0], pc->rx.inACCM[1], pc->rx.inACCM[2], pc->rx.inACCM[3]));
 
 1221ccp_test( 
int unit, 
int opt_len,  
int for_transmit, u_char *opt_ptr)
 
 1230ccp_flags_set(
int unit, 
int isopen, 
int isup)
 
 1241ccp_fatal_error(
int unit)
 
 1252get_idle_time(
int u, 
struct ppp_idle *
ip)
 
 1285  mask = subnetMask | 
htonl(nmask);
 
 1299sifvjcomp(
int pd, 
int vjcomp, 
u8_t cidcomp, 
u8_t maxcid)
 
 1301#if PPPOS_SUPPORT && VJ_SUPPORT 
 1302  PPPControl *pc = &pppControl[pd];
 
 1304  pc->vjEnabled = vjcomp;
 
 1305  pc->vjComp.compressSlot = cidcomp;
 
 1306  pc->vjComp.maxSlotIndex = maxcid;
 
 1307  PPPDEBUG(
LOG_INFO, (
"sifvjcomp: VJ compress enable=%d slot=%d max slot=%d\n",
 
 1308            vjcomp, cidcomp, maxcid));
 
 1330#if LWIP_NETIF_HOSTNAME 
 1344  PPPControl *pc = &pppControl[pd];
 
 1347  if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) {
 
 1352    if (
netif_add(&pc->netif, &pc->addrs.our_ipaddr, &pc->addrs.netmask,
 
 1353                  &pc->addrs.his_ipaddr, (
void *)(
size_t)pd, pppifNetifInit, 
ip_input)) {
 
 1356      pc->errCode = PPPERR_NONE;
 
 1358      PPPDEBUG(
LOG_DEBUG, (
"sifup: unit %d: linkStatusCB=%p errCode=%d\n", pd, pc->linkStatusCB, pc->errCode));
 
 1359      if (pc->linkStatusCB) {
 
 1360        pc->linkStatusCB(pc->linkStatusCtx, pc->errCode, &pc->addrs);
 
 1375sifnpmode(
int u, 
int proto, 
enum NPmode mode)
 
 1389  PPPControl *pc = &pppControl[pd];
 
 1392  if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) {
 
 1400    PPPDEBUG(
LOG_DEBUG, (
"sifdown: unit %d: linkStatusCB=%p errCode=%d\n", pd, pc->linkStatusCB, pc->errCode));
 
 1401    if (pc->linkStatusCB) {
 
 1402      pc->linkStatusCB(pc->linkStatusCtx, PPPERR_CONNECT, 
NULL);
 
 1420  PPPControl *pc = &pppControl[pd];
 
 1423  if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) {
 
 1427    SMEMCPY(&pc->addrs.our_ipaddr, &o, 
sizeof(o));
 
 1428    SMEMCPY(&pc->addrs.his_ipaddr, &h, 
sizeof(h));
 
 1429    SMEMCPY(&pc->addrs.netmask, &
m, 
sizeof(
m));
 
 1430    SMEMCPY(&pc->addrs.dns1, &ns1, 
sizeof(ns1));
 
 1431    SMEMCPY(&pc->addrs.dns2, &ns2, 
sizeof(ns2));
 
 1446  PPPControl *pc = &pppControl[pd];
 
 1451  if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) {
 
 1455    IP4_ADDR(&pc->addrs.our_ipaddr, 0,0,0,0);
 
 1456    IP4_ADDR(&pc->addrs.his_ipaddr, 0,0,0,0);
 
 1457    IP4_ADDR(&pc->addrs.netmask, 255,255,255,0);
 
 1458    IP4_ADDR(&pc->addrs.dns1, 0,0,0,0);
 
 1459    IP4_ADDR(&pc->addrs.dns2, 0,0,0,0);
 
 1470  PPPControl *pc = &pppControl[pd];
 
 1476  if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) {
 
 1494  PPPControl *pc = &pppControl[pd];
 
 1500  if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) {
 
 1514#if PPPOS_SUPPORT && PPP_INPROC_OWNTHREAD 
 1518pppInputThread(
void *arg)
 
 1521  PPPControlRx *pcrx = arg;
 
 1524    count = 
sio_read(pcrx->fd, pcrx->rxbuf, PPPOS_RX_BUFSIZE);
 
 1526      pppInProc(pcrx, pcrx->rxbuf, count);
 
 1538pppOverEthernetInitFailed(
int pd)
 
 1545  pc = &pppControl[pd];
 
 1546  pppoe_destroy(&pc->netif);
 
 1549  if(pc->linkStatusCB) {
 
 1550    pc->linkStatusCB(pc->linkStatusCtx, pc->errCode ? pc->errCode : PPPERR_PROTOCOL, 
NULL);
 
 1555pppOverEthernetLinkStatusCB(
int pd, 
int up)
 
 1558    PPPDEBUG(
LOG_INFO, (
"pppOverEthernetLinkStatusCB: unit %d: Connecting\n", pd));
 
 1561    pppOverEthernetInitFailed(pd);
 
 1567pppSingleBuf(
struct pbuf *p)
 
 1579             (
"pppSingleBuf: unable to alloc new buf (%d)\n", p->
tot_len));
 
 1593struct pppInputHeader {
 
 1605  struct pbuf *nb = (
struct pbuf *)arg;
 
 1609  pd = ((
struct pppInputHeader *)nb->
payload)->unit;
 
 1610  protocol = ((
struct pppInputHeader *)nb->
payload)->proto;
 
 1612  if(
pbuf_header(nb, -(
int)
sizeof(
struct pppInputHeader))) {
 
 1627    if(!((protocol == PPP_LQR) || (protocol == PPP_PAP) || (protocol == PPP_CHAP)) ||
 
 1636#if PPPOS_SUPPORT && VJ_SUPPORT 
 1643        pppControl[pd].netif.input(nb, &pppControl[pd].
netif);
 
 1654    case PPP_VJC_UNCOMP:    
 
 1655#if PPPOS_SUPPORT && VJ_SUPPORT 
 1662        pppControl[pd].netif.input(nb, &pppControl[pd].
netif);
 
 1670               (
"pppInput[%d]: drop VJ UnComp in %d:.*H\n", 
 
 1678        pppControl[pd].netif.input(nb, &pppControl[pd].
netif);
 
 1684      struct protent *protp;
 
 1690      for (i = 0; (protp = ppp_protocols[i]) != 
NULL; ++i) {
 
 1691        if (protp->protocol == protocol && protp->enabled_flag) {
 
 1693          nb = pppSingleBuf(nb);
 
 1706#if BYTE_ORDER == LITTLE_ENDIAN 
 1707      protocol = 
htons(protocol);
 
 1729pppFreeCurrentInputPacket(PPPControlRx *pcrx)
 
 1731  if (pcrx->inHead != 
NULL) {
 
 1732    if (pcrx->inTail && (pcrx->inTail != pcrx->inHead)) {
 
 1736    pcrx->inHead = 
NULL;
 
 1738  pcrx->inTail = 
NULL;
 
 1745pppDrop(PPPControlRx *pcrx)
 
 1747  if (pcrx->inHead != 
NULL) {
 
 1749    PPPDEBUG(
LOG_INFO, (
"pppDrop: %d:%.*H\n", pcrx->inHead->len, min(60, pcrx->inHead->len * 2), pcrx->inHead->payload));
 
 1751    PPPDEBUG(
LOG_INFO, (
"pppDrop: pbuf len=%d, addr %p\n", pcrx->inHead->len, (
void*)pcrx->inHead));
 
 1753  pppFreeCurrentInputPacket(pcrx);
 
 1762#if !PPP_INPROC_OWNTHREAD 
 1771pppos_input(
int pd, u_char* 
data, 
int len)
 
 1773  pppInProc(&pppControl[pd].rx, 
data, len);
 
 1781pppInProc(PPPControlRx *pcrx, u_char *s, 
int l)
 
 1783  struct pbuf *nextNBuf;
 
 1793    escaped = ESCAPE_P(pcrx->inACCM, curChar);
 
 1802      if (curChar == PPP_ESCAPE) {
 
 1803        pcrx->inEscaped = 1;
 
 1805      } 
else if (curChar == PPP_FLAG) {
 
 1807        if (pcrx->inState <= PDADDRESS) {
 
 1810        } 
else if (pcrx->inState < PDDATA) {
 
 1812                   (
"pppInProc[%d]: Dropping incomplete packet %d\n", 
 
 1813                    pcrx->pd, pcrx->inState));
 
 1817        } 
else if (pcrx->inFCS != PPP_GOODFCS) {
 
 1819                   (
"pppInProc[%d]: Dropping bad fcs 0x%"X16_F" proto=0x%"X16_F"\n", 
 
 1820                    pcrx->pd, pcrx->inFCS, pcrx->inProtocol));
 
 1828          if(pcrx->inTail->len >= 2) {
 
 1829            pcrx->inTail->
len -= 2;
 
 1831            pcrx->inTail->tot_len = pcrx->inTail->len;
 
 1832            if (pcrx->inTail != pcrx->inHead) {
 
 1833              pbuf_cat(pcrx->inHead, pcrx->inTail);
 
 1836            pcrx->inTail->tot_len = pcrx->inTail->len;
 
 1837            if (pcrx->inTail != pcrx->inHead) {
 
 1838              pbuf_cat(pcrx->inHead, pcrx->inTail);
 
 1847          pcrx->inHead = 
NULL;
 
 1848          pcrx->inTail = 
NULL;
 
 1849#if PPP_INPROC_MULTITHREADED 
 1851            PPPDEBUG(
LOG_ERR, (
"pppInProc[%d]: tcpip_callback() failed, dropping packet\n", pcrx->pd));
 
 1862        pcrx->inFCS = PPP_INITFCS;
 
 1863        pcrx->inState = PDADDRESS;
 
 1864        pcrx->inEscaped = 0;
 
 1869                 (
"pppInProc[%d]: Dropping ACCM char <%d>\n", pcrx->pd, curChar));
 
 1874      if (pcrx->inEscaped) {
 
 1875        pcrx->inEscaped = 0;
 
 1876        curChar ^= PPP_TRANS;
 
 1880      switch(pcrx->inState) {
 
 1884          if (curChar != PPP_ALLSTATIONS) {
 
 1891          pcrx->inFCS = PPP_INITFCS;
 
 1895          if (curChar == PPP_ALLSTATIONS) {
 
 1896            pcrx->inState = PDCONTROL;
 
 1903          if (curChar == PPP_UI) {
 
 1904            pcrx->inState = PDPROTOCOL1;
 
 1910                     (
"pppInProc[%d]: Invalid control <%d>\n", pcrx->pd, curChar));
 
 1911            pcrx->inState = PDSTART;
 
 1918            pcrx->inProtocol = curChar;
 
 1919            pcrx->inState = PDDATA;
 
 1921            pcrx->inProtocol = (u_int)curChar << 8;
 
 1922            pcrx->inState = PDPROTOCOL2;
 
 1926          pcrx->inProtocol |= curChar;
 
 1927          pcrx->inState = PDDATA;
 
 1932            if (pcrx->inTail != 
NULL) {
 
 1933              pcrx->inTail->tot_len = pcrx->inTail->len;
 
 1934              if (pcrx->inTail != pcrx->inHead) {
 
 1935                pbuf_cat(pcrx->inHead, pcrx->inTail);
 
 1937                pcrx->inTail = 
NULL;
 
 1942            if (nextNBuf == 
NULL) {
 
 1949              pcrx->inState = PDSTART;  
 
 1952            if (pcrx->inHead == 
NULL) {
 
 1953              struct pppInputHeader *pih = nextNBuf->
payload;
 
 1955              pih->unit = pcrx->pd;
 
 1956              pih->proto = pcrx->inProtocol;
 
 1958              nextNBuf->
len += 
sizeof(*pih);
 
 1960              pcrx->inHead = nextNBuf;
 
 1962            pcrx->inTail = nextNBuf;
 
 1965          ((u_char*)pcrx->inTail->payload)[pcrx->inTail->len++] = curChar;
 
 1970      pcrx->inFCS = PPP_FCS(pcrx->inFCS, curChar);
 
 1980pppInProcOverEthernet(
int pd, 
struct pbuf *pb)
 
 1982  struct pppInputHeader *pih;
 
 1985  if(pb->
len < 
sizeof(inProtocol)) {
 
 1986    PPPDEBUG(
LOG_ERR, (
"pppInProcOverEthernet: too small for protocol field\n"));
 
 1993  if (
pbuf_header(pb, 
sizeof(*pih) - 
sizeof(inProtocol)) != 0) {
 
 1994    PPPDEBUG(
LOG_ERR, (
"pppInProcOverEthernet: could not allocate room for header\n"));
 
 2001  pih->proto = inProtocol;
 
 2015#if LWIP_NETIF_STATUS_CALLBACK 
 2026  netif_set_status_callback(&pppControl[pd].
netif, status_callback); 
 
 2030#if LWIP_NETIF_LINK_CALLBACK 
 2041  netif_set_link_callback(&pppControl[pd].
netif, link_callback); 
 
#define LWIP_UNUSED_ARG(x)
 
void link_terminated(int)
 
struct protent chap_protent
 
#define LWIP_ASSERT(message, assertion)
 
err_t ip_input(struct pbuf *p, struct netif *inp)
 
struct protent ipcp_protent
 
#define IP4_ADDR(ipaddr, a, b, c, d)
 
typedefPACK_STRUCT_END struct ip_addr ip_addr_t
 
void lcp_sprotrej(int, u_char *, int)
 
lcp_options lcp_wantoptions[]
 
void lcp_close(int, char *)
 
LinkPhase lcp_phase[NUM_PPP]
 
lcp_options lcp_allowoptions[]
 
struct protent lcp_protent
 
struct netif * netif_add(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, ip_addr_t *gw, void *state, netif_init_fn init, netif_input_fn input)
 
void netif_set_down(struct netif *netif)
 
void netif_remove(struct netif *netif)
 
void netif_set_default(struct netif *netif)
 
void netif_set_up(struct netif *netif)
 
#define NETIF_FLAG_POINTTOPOINT
 
void(* netif_status_callback_fn)(struct netif *netif)
 
#define NETIF_FLAG_LINK_UP
 
int link(const char *existing, const char *new)
 
#define SMEMCPY(dst, src, len)
 
#define MEMCPY(dst, src, len)
 
#define PPP_THREAD_STACKSIZE
 
#define PBUF_POOL_BUFSIZE
 
u8_t pbuf_header(struct pbuf *p, s16_t header_size_increment)
 
void pbuf_realloc(struct pbuf *p, u16_t new_len)
 
void pbuf_cat(struct pbuf *h, struct pbuf *t)
 
void pbuf_chain(struct pbuf *h, struct pbuf *t)
 
struct pbuf * pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
 
u8_t pbuf_free(struct pbuf *p)
 
u32_t sio_write(sio_fd_t fd, u8_t *data, u32_t len)
 
u32_t sio_read(sio_fd_t fd, u8_t *data, u32_t len)
 
void sio_read_abort(sio_fd_t fd)
 
#define snmp_inc_ifoutucastpkts(ni)
 
#define snmp_inc_ifindiscards(ni)
 
#define snmp_inc_ifinucastpkts(ni)
 
#define snmp_add_ifinoctets(ni, value)
 
#define snmp_add_ifoutoctets(ni, value)
 
#define snmp_inc_ifoutdiscards(ni)
 
#define LINK_STATS_INC(x)
 
void sys_msleep(u32_t ms)
 
sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio)
 
#define SYS_ARCH_UNPROTECT(lev)
 
#define SYS_ARCH_PROTECT(lev)
 
#define SYS_ARCH_DECL_PROTECT(lev)
 
err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block)
 
void vj_compress_init(struct vjcompress *comp)
 
int vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp)
 
#define TYPE_UNCOMPRESSED_TCP
 
void vj_uncompress_err(struct vjcompress *comp)
 
#define TYPE_COMPRESSED_TCP
 
int vj_uncompress_uncomp(struct pbuf *nb, struct vjcompress *comp)
 
u_int vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb)