88#define PPPOE_ADD_16(PTR, VAL) \ 
   89    *(PTR)++ = (u8_t)((VAL) / 256);    \ 
   90    *(PTR)++ = (u8_t)((VAL) % 256) 
   93#define PPPOE_ADD_HEADER(PTR, CODE, SESS, LEN)  \ 
   94    *(PTR)++ = PPPOE_VERTYPE;  \ 
   96    PPPOE_ADD_16(PTR, SESS);   \ 
   97    PPPOE_ADD_16(PTR, LEN) 
   99#define PPPOE_DISC_TIMEOUT (5*1000)   
  100#define PPPOE_SLOW_RETRY   (60*1000)  
  101#define PPPOE_DISC_MAXPADI  4         
  102#define PPPOE_DISC_MAXPADR  2         
  105#error "PPPOE_SERVER is not yet supported under lwIP!" 
  107#define IFF_PASSIVE IFF_LINK0  
  110#ifndef PPPOE_ERRORSTRING_LEN 
  111#define PPPOE_ERRORSTRING_LEN     64 
  113static char pppoe_error_tmp[PPPOE_ERRORSTRING_LEN];
 
  117static void pppoe_dispatch_disc_pkt(
struct netif *, 
struct pbuf *);
 
  120static int pppoe_do_disconnect(
struct pppoe_softc *);
 
  121static void pppoe_abort_connect(
struct pppoe_softc *);
 
  122static void pppoe_clear_softc(
struct pppoe_softc *, 
const char *);
 
  125static void pppoe_timeout(
void *);
 
  128static err_t pppoe_send_padi(
struct pppoe_softc *);
 
  129static err_t pppoe_send_padr(
struct pppoe_softc *);
 
  131static err_t pppoe_send_pado(
struct pppoe_softc *);
 
  132static err_t pppoe_send_pads(
struct pppoe_softc *);
 
  137static struct pppoe_softc * pppoe_find_softc_by_session(u_int, 
struct netif *);
 
  138static struct pppoe_softc * pppoe_find_softc_by_hunique(
u8_t *, 
size_t, 
struct netif *);
 
  141static struct pppoe_softc *pppoe_softc_list;
 
  144pppoe_create(
struct netif *ethif, 
int pd, 
void (*linkStatusCB)(
int pd, 
int up), 
struct pppoe_softc **scptr)
 
  146  struct pppoe_softc *sc;
 
  148  sc = (
struct pppoe_softc *)
memp_malloc(MEMP_PPPOE_IF);
 
  153  memset(sc, 0, 
sizeof(
struct pppoe_softc));
 
  156  MEMCPY(&sc->sc_dest, ethbroadcast.addr, 
sizeof(sc->sc_dest));
 
  159  sc->sc_linkStatusCB = linkStatusCB;
 
  160  sc->sc_ethif = ethif;
 
  163  sc->
next = pppoe_softc_list;
 
  164  pppoe_softc_list = sc;
 
  172pppoe_destroy(
struct netif *ifp)
 
  174  struct pppoe_softc *sc, *prev = 
NULL;
 
  176  for (sc = pppoe_softc_list; sc != 
NULL; prev = sc, sc = sc->next) {
 
  177    if (sc->sc_ethif == ifp) {
 
  182  if(!(sc && (sc->sc_ethif == ifp))) {
 
  189    pppoe_softc_list = sc->next;
 
  192    prev->next = sc->next;
 
  196  if (sc->sc_concentrator_name) {
 
  199  if (sc->sc_service_name) {
 
  214static struct pppoe_softc *
 
  215pppoe_find_softc_by_session(u_int session, 
struct netif *rcvif)
 
  217  struct pppoe_softc *sc;
 
  223  for (sc = pppoe_softc_list; sc != 
NULL; sc = sc->next) {
 
  224    if (sc->sc_state == PPPOE_STATE_SESSION
 
  225        && sc->sc_session == session) {
 
  226      if (sc->sc_ethif == rcvif) {
 
  238static struct pppoe_softc *
 
  239pppoe_find_softc_by_hunique(
u8_t *token, 
size_t len, 
struct netif *rcvif)
 
  241  struct pppoe_softc *sc, *t;
 
  243  if (pppoe_softc_list == 
NULL) {
 
  247  if (len != 
sizeof sc) {
 
  252  for (sc = pppoe_softc_list; sc != 
NULL; sc = sc->next) {
 
  264  if (sc->sc_state < PPPOE_STATE_PADI_SENT || sc->sc_state >= PPPOE_STATE_SESSION) {
 
  265    printf(
"%c%c%"U16_F": host unique tag found, but it belongs to a connection in state %d\n",
 
  266      sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, sc->sc_state);
 
  269  if (sc->sc_ethif != rcvif) {
 
  270    printf(
"%c%c%"U16_F": wrong interface, not accepting host unique\n",
 
  271      sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num);
 
  278pppoe_linkstatus_up(
struct pppoe_softc *sc)
 
  280  sc->sc_linkStatusCB(sc->sc_pd, 1);
 
  289  struct pppoe_softc *sc;
 
  300  int off, err, errortag;
 
  301  struct eth_hdr *ethhdr;
 
  303  pb = pppSingleBuf(pb);
 
  305  strcpy(devname, 
"pppoe");  
 
  308  if (pb->
len < 
sizeof(*ethhdr)) {
 
  311  ethhdr = (
struct eth_hdr *)pb->
payload;
 
  312  off = 
sizeof(*ethhdr);
 
  321  if (pb->
len - off < PPPOE_HEADERLEN) {
 
  322    printf(
"pppoe: packet too short: %d\n", pb->
len);
 
  326  ph = (
struct pppoehdr *) (ethhdr + 1);
 
  327  if (ph->vertype != PPPOE_VERTYPE) {
 
  328    printf(
"pppoe: unknown version/type packet: 0x%x\n", ph->vertype);
 
  331  session = 
ntohs(ph->session);
 
  332  plen = 
ntohs(ph->plen);
 
  335  if (plen + off > pb->
len) {
 
  336    printf(
"pppoe: packet content does not fit: data available = %d, packet size = %u\n",
 
  337        pb->
len - off, plen);
 
  346  while (off + 
sizeof(pt) <= pb->
len) {
 
  350    if (off + 
sizeof(pt) + len > pb->
len) {
 
  351      printf(
"pppoe: tag 0x%x len 0x%x is too long\n", tag, len);
 
  357      case PPPOE_TAG_SNAME:
 
  359      case PPPOE_TAG_ACNAME:
 
  361      case PPPOE_TAG_HUNIQUE:
 
  369        sc = pppoe_find_softc_by_hunique((
u8_t*)pb->
payload + off + 
sizeof(pt), len, 
netif);
 
  371          snprintf(devname, 
sizeof(devname), 
"%c%c%"U16_F, sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num);
 
  374      case PPPOE_TAG_ACCOOKIE:
 
  375        if (ac_cookie == 
NULL) {
 
  380      case PPPOE_TAG_SNAME_ERR:
 
  381        err_msg = 
"SERVICE NAME ERROR";
 
  384      case PPPOE_TAG_ACSYS_ERR:
 
  385        err_msg = 
"AC SYSTEM ERROR";
 
  388      case PPPOE_TAG_GENERIC_ERR:
 
  389        err_msg = 
"GENERIC ERROR";
 
  394      if (errortag && len) {
 
  396        strncpy(pppoe_error_tmp, (
char*)pb->
payload + off + 
sizeof(pt), error_len);
 
  397        pppoe_error_tmp[error_len-1] = 
'\0';
 
  398        printf(
"%s: %s: %s\n", devname, err_msg, pppoe_error_tmp);
 
  400        printf(
"%s: %s\n", devname, err_msg);
 
  406    off += 
sizeof(pt) + len;
 
  411    case PPPOE_CODE_PADI:
 
  417      if (LIST_EMPTY(&pppoe_softc_list)) {
 
  420      LIST_FOREACH(sc, &pppoe_softc_list, sc_list) {
 
  421        if (!(sc->sc_sppp.pp_if.if_flags & IFF_UP)) {
 
  424        if (!(sc->sc_sppp.pp_if.if_flags & IFF_PASSIVE)) {
 
  427        if (sc->sc_state == PPPOE_STATE_INITIAL) {
 
  436        if (sc->sc_hunique) {
 
  440        if (sc->sc_hunique == 
NULL) {
 
  443        sc->sc_hunique_len = hunique_len;
 
  444        MEMCPY(sc->sc_hunique, hunique, hunique_len);
 
  446      MEMCPY(&sc->sc_dest, eh->ether_shost, 
sizeof sc->sc_dest);
 
  447      sc->sc_state = PPPOE_STATE_PADO_SENT;
 
  451    case PPPOE_CODE_PADR:
 
  456      if (ac_cookie == 
NULL) {
 
  458        printf(
"pppoe: received PADR but not includes ac_cookie\n");
 
  461      sc = pppoe_find_softc_by_hunique(ac_cookie, ac_cookie_len, 
netif);
 
  464        if (!LIST_EMPTY(&pppoe_softc_list)) {
 
  465          printf(
"pppoe: received PADR but could not find request for it\n");
 
  469      if (sc->sc_state != PPPOE_STATE_PADO_SENT) {
 
  470        printf(
"%c%c%"U16_F": received unexpected PADR\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num);
 
  474        if (sc->sc_hunique) {
 
  478        if (sc->sc_hunique == 
NULL) {
 
  481        sc->sc_hunique_len = hunique_len;
 
  482        MEMCPY(sc->sc_hunique, hunique, hunique_len);
 
  485      sc->sc_state = PPPOE_STATE_SESSION;
 
  486      pppoe_linkstatus_up(sc); 
 
  492    case PPPOE_CODE_PADO:
 
  495        if (pppoe_softc_list != 
NULL) {
 
  496          printf(
"pppoe: received PADO but could not find request for it\n");
 
  500      if (sc->sc_state != PPPOE_STATE_PADI_SENT) {
 
  501        printf(
"%c%c%"U16_F": received unexpected PADO\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num);
 
  505        sc->sc_ac_cookie_len = ac_cookie_len;
 
  506        MEMCPY(sc->sc_ac_cookie, ac_cookie, ac_cookie_len);
 
  508      MEMCPY(&sc->sc_dest, ethhdr->src.addr, 
sizeof(sc->sc_dest.addr));
 
  510      sc->sc_padr_retried = 0;
 
  511      sc->sc_state = PPPOE_STATE_PADR_SENT;
 
  512      if ((err = pppoe_send_padr(sc)) != 0) {
 
  513        PPPDEBUG(
LOG_DEBUG, (
"pppoe: %c%c%"U16_F": failed to send PADR, error=%d\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, err));
 
  515      sys_timeout(PPPOE_DISC_TIMEOUT * (1 + sc->sc_padr_retried), pppoe_timeout, sc);
 
  517    case PPPOE_CODE_PADS:
 
  521      sc->sc_session = session;
 
  523      PPPDEBUG(
LOG_DEBUG, (
"pppoe: %c%c%"U16_F": session 0x%x connected\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, session));
 
  524      sc->sc_state = PPPOE_STATE_SESSION;
 
  525      pppoe_linkstatus_up(sc); 
 
  527    case PPPOE_CODE_PADT:
 
  531      pppoe_clear_softc(sc, 
"received PADT");
 
  535        printf(
"%c%c%"U16_F": unknown code (0x%"X16_F") session = 0x%"X16_F"\n",
 
  536            sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num,
 
  537            (
u16_t)ph->code, session);
 
  539        printf(
"pppoe: unknown code (0x%"X16_F") session = 0x%"X16_F"\n", (
u16_t)ph->code, session);
 
  553  if (pppoe_softc_list != 
NULL) {
 
  554    pppoe_dispatch_disc_pkt(
netif, p);
 
  564  struct pppoe_softc *sc;
 
  566#ifdef PPPOE_TERM_UNKNOWN_SESSIONS 
  567  u8_t shost[ETHER_ADDR_LEN];
 
  570#ifdef PPPOE_TERM_UNKNOWN_SESSIONS 
  571  MEMCPY(shost, ((
struct eth_hdr *)pb->
payload)->src.addr, 
sizeof(shost));
 
  573  if (
pbuf_header(pb, -(
int)
sizeof(
struct eth_hdr)) != 0) {
 
  580  pb = pppSingleBuf (pb);
 
  582  if (pb->
len <= PPPOE_HEADERLEN) {
 
  583    printf(
"pppoe (data): dropping too short packet: %d bytes\n", pb->
len);
 
  587  if (pb->
len < 
sizeof(*ph)) {
 
  588    printf(
"pppoe_data_input: could not get PPPoE header\n");
 
  591  ph = (
struct pppoehdr *)pb->
payload;
 
  593  if (ph->vertype != PPPOE_VERTYPE) {
 
  594    printf(
"pppoe (data): unknown version/type packet: 0x%x\n", ph->vertype);
 
  601  session = 
ntohs(ph->session);
 
  602  sc = pppoe_find_softc_by_session(session, 
netif);
 
  604#ifdef PPPOE_TERM_UNKNOWN_SESSIONS 
  605    printf(
"pppoe: input for unknown session 0x%x, sending PADT\n", session);
 
  606    pppoe_send_padt(
netif, session, shost);
 
  611  plen = 
ntohs(ph->plen);
 
  613  if (
pbuf_header(pb, -(
int)(PPPOE_HEADERLEN)) != 0) {
 
  615    PPPDEBUG(
LOG_ERR, (
"pppoe_data_input: pbuf_header PPPOE_HEADERLEN failed\n"));
 
  621        sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num,
 
  624  if (pb->
len < plen) {
 
  628  pppInProcOverEthernet(sc->sc_pd, pb);
 
  637pppoe_output(
struct pppoe_softc *sc, 
struct pbuf *pb)
 
  639  struct eth_hdr *ethhdr;
 
  648  ethhdr = (
struct eth_hdr *)pb->
payload;
 
  649  etype = sc->sc_state == PPPOE_STATE_SESSION ? ETHTYPE_PPPOE : ETHTYPE_PPPOEDISC;
 
  650  ethhdr->type = 
htons(etype);
 
  651  MEMCPY(ethhdr->dest.addr, sc->sc_dest.addr, 
sizeof(ethhdr->dest.addr));
 
  652  MEMCPY(ethhdr->src.addr, ((
struct eth_addr *)sc->sc_ethif->hwaddr)->addr, 
sizeof(ethhdr->src.addr));
 
  655      sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, etype,
 
  656      sc->sc_state, sc->sc_session,
 
  657      sc->sc_dest.addr[0], sc->sc_dest.addr[1], sc->sc_dest.addr[2], sc->sc_dest.addr[3], sc->sc_dest.addr[4], sc->sc_dest.addr[5],
 
  660  res = sc->sc_ethif->linkoutput(sc->sc_ethif, pb);
 
  668pppoe_send_padi(
struct pppoe_softc *sc)
 
  677  if (sc->sc_state >PPPOE_STATE_PADI_SENT) {
 
  678    PPPDEBUG(
LOG_ERR, (
"ERROR: pppoe_send_padi in state %d", sc->sc_state));
 
  682  len = 2 + 2 + 2 + 2 + 
sizeof sc;  
 
  684  if (sc->sc_service_name != 
NULL) {
 
  685    l1 = (int)strlen(sc->sc_service_name);
 
  688  if (sc->sc_concentrator_name != 
NULL) {
 
  689    l2 = (int)strlen(sc->sc_concentrator_name);
 
  693  LWIP_ASSERT(
"sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len <= 0xffff",
 
  694    sizeof(
struct eth_hdr) + PPPOE_HEADERLEN + 
len <= 0xffff);
 
  705  PPPOE_ADD_HEADER(p, PPPOE_CODE_PADI, 0, (
u16_t)
len);
 
  706  PPPOE_ADD_16(p, PPPOE_TAG_SNAME);
 
  708  if (sc->sc_service_name != 
NULL) {
 
  710    MEMCPY(p, sc->sc_service_name, l1);
 
  718  if (sc->sc_concentrator_name != 
NULL) {
 
  719    PPPOE_ADD_16(p, PPPOE_TAG_ACNAME);
 
  721    MEMCPY(p, sc->sc_concentrator_name, l2);
 
  725  PPPOE_ADD_16(p, PPPOE_TAG_HUNIQUE);
 
  726  PPPOE_ADD_16(p, 
sizeof(sc));
 
  727  MEMCPY(p, &sc, 
sizeof sc);
 
  730  return pppoe_output(sc, pb);
 
  734pppoe_timeout(
void *arg)
 
  737  struct pppoe_softc *sc = (
struct pppoe_softc*)arg;
 
  739  PPPDEBUG(
LOG_DEBUG, (
"pppoe: %c%c%"U16_F": timeout\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num));
 
  741  switch (sc->sc_state) {
 
  742    case PPPOE_STATE_PADI_SENT:
 
  754      retry_wait = PPPOE_DISC_TIMEOUT * (1 + sc->sc_padi_retried);
 
  756      sc->sc_padi_retried++;
 
  757      if (sc->sc_padi_retried >= PPPOE_DISC_MAXPADI) {
 
  759        if ((sc->sc_sppp.pp_if.if_flags & IFF_LINK1) == 0) {
 
  761          retry_wait = PPPOE_SLOW_RETRY;
 
  765          pppoe_abort_connect(sc);
 
  769      if ((err = pppoe_send_padi(sc)) != 0) {
 
  770        sc->sc_padi_retried--;
 
  771        PPPDEBUG(
LOG_DEBUG, (
"pppoe: %c%c%"U16_F": failed to transmit PADI, error=%d\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, err));
 
  776    case PPPOE_STATE_PADR_SENT:
 
  777      sc->sc_padr_retried++;
 
  778      if (sc->sc_padr_retried >= PPPOE_DISC_MAXPADR) {
 
  779        MEMCPY(&sc->sc_dest, ethbroadcast.addr, 
sizeof(sc->sc_dest));
 
  780        sc->sc_state = PPPOE_STATE_PADI_SENT;
 
  781        sc->sc_padr_retried = 0;
 
  782        if ((err = pppoe_send_padi(sc)) != 0) {
 
  783          PPPDEBUG(
LOG_DEBUG, (
"pppoe: %c%c%"U16_F": failed to send PADI, error=%d\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, err));
 
  785        sys_timeout(PPPOE_DISC_TIMEOUT * (1 + sc->sc_padi_retried), pppoe_timeout, sc);
 
  788      if ((err = pppoe_send_padr(sc)) != 0) {
 
  789        sc->sc_padr_retried--;
 
  790        PPPDEBUG(
LOG_DEBUG, (
"pppoe: %c%c%"U16_F": failed to send PADR, error=%d\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, err));
 
  792      sys_timeout(PPPOE_DISC_TIMEOUT * (1 + sc->sc_padr_retried), pppoe_timeout, sc);
 
  794    case PPPOE_STATE_CLOSING:
 
  795      pppoe_do_disconnect(sc);
 
  804pppoe_connect(
struct pppoe_softc *sc)
 
  808  if (sc->sc_state != PPPOE_STATE_INITIAL) {
 
  814  if ((sc->sc_sppp.pp_if.if_flags & IFF_PASSIVE)) {
 
  819  sc->sc_state = PPPOE_STATE_PADI_SENT;
 
  820  sc->sc_padr_retried = 0;
 
  821  err = pppoe_send_padi(sc);
 
  822  PPPDEBUG(
LOG_DEBUG, (
"pppoe: %c%c%"U16_F": failed to send PADI, error=%d\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, err));
 
  823  sys_timeout(PPPOE_DISC_TIMEOUT, pppoe_timeout, sc);
 
  829pppoe_disconnect(
struct pppoe_softc *sc)
 
  831  if (sc->sc_state < PPPOE_STATE_SESSION) {
 
  839  sc->sc_state = PPPOE_STATE_CLOSING;
 
  844pppoe_do_disconnect(
struct pppoe_softc *sc)
 
  848  if (sc->sc_state < PPPOE_STATE_SESSION) {
 
  851    PPPDEBUG(
LOG_DEBUG, (
"pppoe: %c%c%"U16_F": disconnecting\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num));
 
  852    err = pppoe_send_padt(sc->sc_ethif, sc->sc_session, (
const u8_t *)&sc->sc_dest);
 
  856  sc->sc_state = PPPOE_STATE_INITIAL;
 
  857  MEMCPY(&sc->sc_dest, ethbroadcast.addr, 
sizeof(sc->sc_dest));
 
  858  sc->sc_ac_cookie_len = 0;
 
  860  if (sc->sc_hunique) {
 
  862    sc->sc_hunique = 
NULL;
 
  864  sc->sc_hunique_len = 0;
 
  868  sc->sc_linkStatusCB(sc->sc_pd, 0); 
 
  875pppoe_abort_connect(
struct pppoe_softc *sc)
 
  877  printf(
"%c%c%"U16_F": could not establish connection\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num);
 
  878  sc->sc_state = PPPOE_STATE_CLOSING;
 
  880  sc->sc_linkStatusCB(sc->sc_pd, 0); 
 
  883  MEMCPY(&sc->sc_dest, ethbroadcast.addr, 
sizeof(sc->sc_dest));
 
  884  sc->sc_state = PPPOE_STATE_INITIAL;
 
  889pppoe_send_padr(
struct pppoe_softc *sc)
 
  898  if (sc->sc_state != PPPOE_STATE_PADR_SENT) {
 
  902  len = 2 + 2 + 2 + 2 + 
sizeof(sc);    
 
  904  if (sc->sc_service_name != 
NULL) {    
 
  905    l1 = strlen(sc->sc_service_name);
 
  909  if (sc->sc_ac_cookie_len > 0) {
 
  910    len += 2 + 2 + sc->sc_ac_cookie_len;  
 
  912  LWIP_ASSERT(
"sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len <= 0xffff",
 
  913    sizeof(
struct eth_hdr) + PPPOE_HEADERLEN + 
len <= 0xffff);
 
  920  PPPOE_ADD_HEADER(p, PPPOE_CODE_PADR, 0, 
len);
 
  921  PPPOE_ADD_16(p, PPPOE_TAG_SNAME);
 
  923  if (sc->sc_service_name != 
NULL) {
 
  925    MEMCPY(p, sc->sc_service_name, l1);
 
  932  if (sc->sc_ac_cookie_len > 0) {
 
  933    PPPOE_ADD_16(p, PPPOE_TAG_ACCOOKIE);
 
  934    PPPOE_ADD_16(p, sc->sc_ac_cookie_len);
 
  935    MEMCPY(p, sc->sc_ac_cookie, sc->sc_ac_cookie_len);
 
  936    p += sc->sc_ac_cookie_len;
 
  938  PPPOE_ADD_16(p, PPPOE_TAG_HUNIQUE);
 
  939  PPPOE_ADD_16(p, 
sizeof(sc));
 
  940  MEMCPY(p, &sc, 
sizeof sc);
 
  942  return pppoe_output(sc, pb);
 
  947pppoe_send_padt(
struct netif *outgoing_if, u_int session, 
const u8_t *dest)
 
  950  struct eth_hdr *ethhdr;
 
  960  ethhdr = (
struct eth_hdr *)pb->
payload;
 
  961  ethhdr->type = 
PP_HTONS(ETHTYPE_PPPOEDISC);
 
  962  MEMCPY(ethhdr->dest.addr, dest, 
sizeof(ethhdr->dest.addr));
 
  963  MEMCPY(ethhdr->src.addr, ((
struct eth_addr *)outgoing_if->
hwaddr)->addr, 
sizeof(ethhdr->src.addr));
 
  965  p = (
u8_t*)(ethhdr + 1);
 
  966  PPPOE_ADD_HEADER(p, PPPOE_CODE_PADT, session, 0);
 
  968  res = outgoing_if->
linkoutput(outgoing_if, pb);
 
  977pppoe_send_pado(
struct pppoe_softc *sc)
 
  983  if (sc->sc_state != PPPOE_STATE_PADO_SENT) {
 
  990  len += 2 + 2 + 
sizeof(sc);
 
  992  len += 2 + 2 + sc->sc_hunique_len;
 
  999  PPPOE_ADD_HEADER(p, PPPOE_CODE_PADO, 0, 
len);
 
 1000  PPPOE_ADD_16(p, PPPOE_TAG_ACCOOKIE);
 
 1001  PPPOE_ADD_16(p, 
sizeof(sc));
 
 1002  MEMCPY(p, &sc, 
sizeof(sc));
 
 1004  PPPOE_ADD_16(p, PPPOE_TAG_HUNIQUE);
 
 1005  PPPOE_ADD_16(p, sc->sc_hunique_len);
 
 1006  MEMCPY(p, sc->sc_hunique, sc->sc_hunique_len);
 
 1007  return pppoe_output(sc, pb);
 
 1011pppoe_send_pads(
struct pppoe_softc *sc)
 
 1017  if (sc->sc_state != PPPOE_STATE_PADO_SENT) {
 
 1021  sc->sc_session = mono_time.tv_sec % 0xff + 1;
 
 1025  len += 2 + 2 + 2 + 2 + sc->sc_hunique_len;  
 
 1026  if (sc->sc_service_name != 
NULL) {    
 
 1027    l1 = strlen(sc->sc_service_name);
 
 1036  PPPOE_ADD_HEADER(p, PPPOE_CODE_PADS, sc->sc_session, 
len);
 
 1037  PPPOE_ADD_16(p, PPPOE_TAG_SNAME);
 
 1038  if (sc->sc_service_name != 
NULL) {
 
 1039    PPPOE_ADD_16(p, l1);
 
 1040    MEMCPY(p, sc->sc_service_name, l1);
 
 1045  PPPOE_ADD_16(p, PPPOE_TAG_HUNIQUE);
 
 1046  PPPOE_ADD_16(p, sc->sc_hunique_len);
 
 1047  MEMCPY(p, sc->sc_hunique, sc->sc_hunique_len);
 
 1048  return pppoe_output(sc, pb);
 
 1053pppoe_xmit(
struct pppoe_softc *sc, 
struct pbuf *pb)
 
 1059  if (sc->sc_state < PPPOE_STATE_SESSION) {
 
 1068  if (
pbuf_header(pb, 
sizeof(
struct eth_hdr) + PPPOE_HEADERLEN) != 0) {
 
 1070    PPPDEBUG(
LOG_ERR, (
"pppoe: %c%c%"U16_F": pppoe_xmit: could not allocate room for header\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num));
 
 1077  PPPOE_ADD_HEADER(p, 0, sc->sc_session, 
len);
 
 1079  return pppoe_output(sc, pb);
 
 1084pppoe_ifattach_hook(
void *arg, 
struct pbuf **mp, 
struct netif *ifp, 
int dir)
 
 1086  struct pppoe_softc *sc;
 
 1089  if (mp != (
struct pbuf **)PFIL_IFNET_DETACH) {
 
 1093  LIST_FOREACH(sc, &pppoe_softc_list, sc_list) {
 
 1094    if (sc->sc_ethif != ifp) {
 
 1097    if (sc->sc_sppp.pp_if.if_flags & IFF_UP) {
 
 1098      sc->sc_sppp.pp_if.if_flags &= ~(IFF_UP|IFF_RUNNING);
 
 1099      printf(
"%c%c%"U16_F": ethernet interface detached, going down\n",
 
 1100          sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num);
 
 1102    sc->sc_ethif = 
NULL;
 
 1103    pppoe_clear_softc(sc, 
"ethernet interface detached");
 
 1111pppoe_clear_softc(
struct pppoe_softc *sc, 
const char *message)
 
 1117  PPPDEBUG(
LOG_DEBUG, (
"pppoe: %c%c%"U16_F": session 0x%x terminated, %s\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, sc->sc_session, message));
 
 1120  sc->sc_state = PPPOE_STATE_INITIAL;
 
 1123  sc->sc_linkStatusCB(sc->sc_pd, 0);
 
 1126  MEMCPY(&sc->sc_dest, ethbroadcast.addr, 
sizeof(sc->sc_dest));
 
 1127  sc->sc_ac_cookie_len = 0;
 
#define LWIP_UNUSED_ARG(x)
 
#define LWIP_ASSERT(message, assertion)
 
void * mem_malloc(mem_size_t size)
 
void mem_free(void *rmem)
 
void * memp_malloc(memp_t type)
 
void memp_free(memp_t type, void *mem)
 
int link(const char *existing, const char *new)
 
#define MEMCPY(dst, src, len)
 
u8_t pbuf_header(struct pbuf *p, s16_t header_size_increment)
 
struct pbuf * pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
 
u8_t pbuf_free(struct pbuf *p)
 
#define LINK_STATS_INC(x)
 
u8_t hwaddr[NETIF_MAX_HWADDR_LEN]
 
netif_linkoutput_fn linkoutput
 
void sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg)
 
void sys_untimeout(sys_timeout_handler handler, void *arg)