72#if PPP_SUPPORT && PPPOE_SUPPORT
94#define PPPOE_ADD_16(PTR, VAL) \
95 *(PTR)++ = (u8_t)((VAL) / 256); \
96 *(PTR)++ = (u8_t)((VAL) % 256)
99#define PPPOE_ADD_HEADER(PTR, CODE, SESS, LEN) \
100 *(PTR)++ = PPPOE_VERTYPE; \
102 PPPOE_ADD_16(PTR, SESS); \
103 PPPOE_ADD_16(PTR, LEN)
105#define PPPOE_DISC_TIMEOUT (5*1000)
106#define PPPOE_SLOW_RETRY (60*1000)
107#define PPPOE_DISC_MAXPADI 4
108#define PPPOE_DISC_MAXPADR 2
111#error "PPPOE_SERVER is not yet supported under lwIP!"
113#define IFF_PASSIVE IFF_LINK0
116#define PPPOE_ERRORSTRING_LEN 64
120static err_t pppoe_write(ppp_pcb *ppp,
void *
ctx,
struct pbuf *
p);
122static void pppoe_connect(ppp_pcb *ppp,
void *
ctx);
123static void pppoe_disconnect(ppp_pcb *ppp,
void *
ctx);
124static err_t pppoe_destroy(ppp_pcb *ppp,
void *
ctx);
127static void pppoe_abort_connect(
struct pppoe_softc *);
129static void pppoe_clear_softc(
struct pppoe_softc *,
const char *);
133static void pppoe_timeout(
void *);
136static err_t pppoe_send_padi(
struct pppoe_softc *);
137static err_t pppoe_send_padr(
struct pppoe_softc *);
139static err_t pppoe_send_pado(
struct pppoe_softc *);
140static err_t pppoe_send_pads(
struct pppoe_softc *);
145static err_t pppoe_xmit(
struct pppoe_softc *sc,
struct pbuf *pb);
146static struct pppoe_softc* pppoe_find_softc_by_session(
u_int session,
struct netif *rcvif);
147static struct pppoe_softc* pppoe_find_softc_by_hunique(
u8_t *
token,
size_t len,
struct netif *rcvif);
150static struct pppoe_softc *pppoe_softc_list;
153static const struct link_callbacks pppoe_callbacks = {
171ppp_pcb *pppoe_create(
struct netif *pppif,
173 const char *
service_name,
const char *concentrator_name,
174 ppp_link_status_cb_fn link_status_cb,
void *ctx_cb)
177 struct pppoe_softc *sc;
178#if PPPOE_SCNAME_SUPPORT
186#if PPPOE_SCNAME_SUPPORT
206 ppp = ppp_new(pppif, &pppoe_callbacks, sc, link_status_cb, ctx_cb);
212 memset(sc, 0,
sizeof(
struct pppoe_softc));
214 sc->sc_ethif = ethif;
215#if PPPOE_SCNAME_SUPPORT
217 sc->sc_concentrator_name = concentrator_name;
220 sc->next = pppoe_softc_list;
221 pppoe_softc_list = sc;
226static err_t pppoe_write(ppp_pcb *ppp,
void *
ctx,
struct pbuf *
p) {
227 struct pppoe_softc *sc = (
struct pppoe_softc *)
ctx;
254 ret = pppoe_xmit(sc, ph);
269 struct pppoe_softc *sc = (
struct pppoe_softc *)
ctx;
298 if( (
err = pppoe_xmit(sc, pb)) !=
ERR_OK) {
311pppoe_destroy(ppp_pcb *ppp,
void *
ctx)
313 struct pppoe_softc *sc = (
struct pppoe_softc *)
ctx;
314 struct pppoe_softc **copp, *
freep;
317 sys_untimeout(pppoe_timeout, sc);
320 for (copp = &pppoe_softc_list; (
freep = *copp); copp = &
freep->next) {
337static struct pppoe_softc* pppoe_find_softc_by_session(
u_int session,
struct netif *rcvif) {
338 struct pppoe_softc *sc;
340 for (sc = pppoe_softc_list; sc !=
NULL; sc = sc->
next) {
341 if (sc->sc_state == PPPOE_STATE_SESSION
343 && sc->sc_ethif == rcvif) {
352static struct pppoe_softc* pppoe_find_softc_by_hunique(
u8_t *
token,
size_t len,
struct netif *rcvif) {
353 struct pppoe_softc *sc, *
t;
355 if (
len !=
sizeof sc) {
360 for (sc = pppoe_softc_list; sc !=
NULL; sc = sc->
next) {
367 PPPDEBUG(
LOG_DEBUG, (
"pppoe: alien host unique tag, no session found\n"));
372 if (sc->sc_state < PPPOE_STATE_PADI_SENT || sc->sc_state >= PPPOE_STATE_SESSION) {
373 PPPDEBUG(
LOG_DEBUG, (
"%c%c%"U16_F": host unique tag found, but it belongs to a connection in state %d\n",
374 sc->sc_ethif->
name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, sc->sc_state));
377 if (sc->sc_ethif != rcvif) {
378 PPPDEBUG(
LOG_DEBUG, (
"%c%c%"U16_F": wrong interface, not accepting host unique\n",
379 sc->sc_ethif->
name[0], sc->sc_ethif->name[1], sc->sc_ethif->num));
391 struct pppoe_softc *sc;
393 const char *err_msg =
NULL;
407 if (pppoe_softc_list ==
NULL) {
427 off =
sizeof(
struct eth_hdr) +
sizeof(
struct pppoehdr);
429 PPPDEBUG(
LOG_DEBUG, (
"pppoe: packet too short: %d\n", pb->
len));
433 ph = (
struct pppoehdr *) (ethhdr + 1);
434 if (ph->vertype != PPPOE_VERTYPE) {
435 PPPDEBUG(
LOG_DEBUG, (
"pppoe: unknown version/type packet: 0x%x\n", ph->vertype));
441 if (plen > (pb->
len - off)) {
442 PPPDEBUG(
LOG_DEBUG, (
"pppoe: packet content does not fit: data available = %d, packet size = %u\n",
443 pb->
len - off, plen));
447 u16_t framelen = off + plen;
448 if (framelen < pb->
len) {
456 while (off +
sizeof(
pt) <= pb->
len) {
460 if (off +
sizeof(
pt) +
len > pb->
len) {
461 PPPDEBUG(
LOG_DEBUG, (
"pppoe: tag 0x%x len 0x%x is too long\n",
tag,
len));
467 case PPPOE_TAG_SNAME:
469 case PPPOE_TAG_ACNAME:
471 case PPPOE_TAG_HUNIQUE:
481 case PPPOE_TAG_ACCOOKIE:
482 if (ac_cookie ==
NULL) {
483 if (
len > PPPOE_MAX_AC_COOKIE_LEN) {
484 PPPDEBUG(
LOG_DEBUG, (
"pppoe: AC cookie is too long: len = %d, max = %d\n",
len, PPPOE_MAX_AC_COOKIE_LEN));
492 case PPPOE_TAG_SNAME_ERR:
493 err_msg =
"SERVICE NAME ERROR";
495 case PPPOE_TAG_ACSYS_ERR:
496 err_msg =
"AC SYSTEM ERROR";
498 case PPPOE_TAG_GENERIC_ERR:
499 err_msg =
"GENERIC ERROR";
506 if (err_msg !=
NULL) {
507 char error_tmp[PPPOE_ERRORSTRING_LEN];
510 error_tmp[error_len] =
'\0';
512 PPPDEBUG(
LOG_DEBUG, (
"pppoe: %c%c%"U16_F": %s: %s\n", sc->sc_ethif->
name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, err_msg, error_tmp));
514 PPPDEBUG(
LOG_DEBUG, (
"pppoe: %s: %s\n", err_msg, error_tmp));
518 off +=
sizeof(
pt) +
len;
523 case PPPOE_CODE_PADI:
533 if (!(sc->sc_sppp.pp_if.if_flags &
IFF_UP)) {
536 if (!(sc->sc_sppp.pp_if.if_flags & IFF_PASSIVE)) {
539 if (sc->sc_state == PPPOE_STATE_INITIAL) {
548 if (sc->sc_hunique) {
552 if (sc->sc_hunique ==
NULL) {
555 sc->sc_hunique_len = hunique_len;
556 MEMCPY(sc->sc_hunique, hunique, hunique_len);
558 MEMCPY(&sc->sc_dest, eh->ether_shost,
sizeof sc->sc_dest);
559 sc->sc_state = PPPOE_STATE_PADO_SENT;
563 case PPPOE_CODE_PADR:
568 if (ac_cookie ==
NULL) {
570 PPPDEBUG(
LOG_DEBUG, (
"pppoe: received PADR but not includes ac_cookie\n"));
573 sc = pppoe_find_softc_by_hunique(ac_cookie, ac_cookie_len,
netif);
577 PPPDEBUG(
LOG_DEBUG, (
"pppoe: received PADR but could not find request for it\n"));
581 if (sc->sc_state != PPPOE_STATE_PADO_SENT) {
582 PPPDEBUG(
LOG_DEBUG, (
"%c%c%"U16_F": received unexpected PADR\n", sc->sc_ethif->
name[0], sc->sc_ethif->name[1], sc->sc_ethif->num));
586 if (sc->sc_hunique) {
590 if (sc->sc_hunique ==
NULL) {
593 sc->sc_hunique_len = hunique_len;
594 MEMCPY(sc->sc_hunique, hunique, hunique_len);
597 sc->sc_state = PPPOE_STATE_SESSION;
604 case PPPOE_CODE_PADO:
607 if (pppoe_softc_list !=
NULL) {
608 PPPDEBUG(
LOG_DEBUG, (
"pppoe: received PADO but could not find request for it\n"));
612 if (sc->sc_state != PPPOE_STATE_PADI_SENT) {
613 PPPDEBUG(
LOG_DEBUG, (
"%c%c%"U16_F": received unexpected PADO\n", sc->sc_ethif->
name[0], sc->sc_ethif->name[1], sc->sc_ethif->num));
617 sc->sc_ac_cookie_len = ac_cookie_len;
618 MEMCPY(sc->sc_ac_cookie, ac_cookie, ac_cookie_len);
620 MEMCPY(&sc->sc_dest, ethhdr->src.addr,
sizeof(sc->sc_dest.addr));
621 sys_untimeout(pppoe_timeout, sc);
622 sc->sc_padr_retried = 0;
623 sc->sc_state = PPPOE_STATE_PADR_SENT;
624 if ((
err = pppoe_send_padr(sc)) != 0) {
625 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));
628 sys_timeout(PPPOE_DISC_TIMEOUT * (1 + sc->sc_padr_retried), pppoe_timeout, sc);
630 case PPPOE_CODE_PADS:
635 sys_untimeout(pppoe_timeout, sc);
636 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));
637 sc->sc_state = PPPOE_STATE_SESSION;
640 case PPPOE_CODE_PADT:
650 pppoe_clear_softc(sc,
"received PADT");
656 sc->sc_ethif->
name[0], sc->sc_ethif->name[1], sc->sc_ethif->num,
673 struct pppoe_softc *sc;
675#ifdef PPPOE_TERM_UNKNOWN_SESSIONS
679#ifdef PPPOE_TERM_UNKNOWN_SESSIONS
684 PPPDEBUG(
LOG_ERR, (
"pppoe_data_input: pbuf_remove_header failed\n"));
689 if (pb->
len <
sizeof(*ph)) {
690 PPPDEBUG(
LOG_DEBUG, (
"pppoe_data_input: could not get PPPoE header\n"));
693 ph = (
struct pppoehdr *)pb->
payload;
695 if (ph->vertype != PPPOE_VERTYPE) {
696 PPPDEBUG(
LOG_DEBUG, (
"pppoe (data): unknown version/type packet: 0x%x\n", ph->vertype));
706#ifdef PPPOE_TERM_UNKNOWN_SESSIONS
707 PPPDEBUG(
LOG_DEBUG, (
"pppoe: input for unknown session 0x%x, sending PADT\n",
session));
717 PPPDEBUG(
LOG_ERR, (
"pppoe_data_input: pbuf_remove_header PPPOE_HEADERLEN failed\n"));
722 PPPDEBUG(
LOG_DEBUG, (
"pppoe_data_input: %c%c%"U16_F": pkthdr.len=%d, pppoe.len=%d\n",
723 sc->sc_ethif->
name[0], sc->sc_ethif->name[1], sc->sc_ethif->num,
731 ppp_input(sc->pcb, pb);
739pppoe_output(
struct pppoe_softc *sc,
struct pbuf *pb)
748 PPPDEBUG(
LOG_ERR, (
"pppoe: %c%c%"U16_F": pppoe_output: could not allocate room for Ethernet header\n", sc->sc_ethif->
name[0], sc->sc_ethif->name[1], sc->sc_ethif->num));
756 MEMCPY(ðhdr->dest.addr, &sc->sc_dest.addr,
sizeof(ethhdr->dest.addr));
757 MEMCPY(ðhdr->src.addr, &sc->sc_ethif->hwaddr,
sizeof(ethhdr->src.addr));
760 sc->sc_ethif->
name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, etype,
761 sc->sc_state, sc->sc_session,
762 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],
765 res = sc->sc_ethif->linkoutput(sc->sc_ethif, pb);
773pppoe_send_padi(
struct pppoe_softc *sc)
778#if PPPOE_SCNAME_SUPPORT
779 size_t l1 = 0, l2 = 0;
783 len = 2 + 2 + 2 + 2 +
sizeof sc;
784#if PPPOE_SCNAME_SUPPORT
785 if (sc->sc_service_name !=
NULL) {
786 l1 =
strlen(sc->sc_service_name);
789 if (sc->sc_concentrator_name !=
NULL) {
790 l2 =
strlen(sc->sc_concentrator_name);
794 LWIP_ASSERT(
"sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len <= 0xffff",
795 sizeof(
struct eth_hdr) + PPPOE_HEADERLEN +
len <= 0xffff);
806 PPPOE_ADD_HEADER(
p, PPPOE_CODE_PADI, 0, (
u16_t)
len);
807 PPPOE_ADD_16(
p, PPPOE_TAG_SNAME);
808#if PPPOE_SCNAME_SUPPORT
809 if (sc->sc_service_name !=
NULL) {
811 MEMCPY(
p, sc->sc_service_name, l1);
818#if PPPOE_SCNAME_SUPPORT
819 if (sc->sc_concentrator_name !=
NULL) {
820 PPPOE_ADD_16(
p, PPPOE_TAG_ACNAME);
822 MEMCPY(
p, sc->sc_concentrator_name, l2);
826 PPPOE_ADD_16(
p, PPPOE_TAG_HUNIQUE);
827 PPPOE_ADD_16(
p,
sizeof(sc));
831 return pppoe_output(sc, pb);
835pppoe_timeout(
void *
arg)
839 struct pppoe_softc *sc = (
struct pppoe_softc*)
arg;
841 PPPDEBUG(
LOG_DEBUG, (
"pppoe: %c%c%"U16_F": timeout\n", sc->sc_ethif->
name[0], sc->sc_ethif->name[1], sc->sc_ethif->num));
843 switch (sc->sc_state) {
844 case PPPOE_STATE_PADI_SENT:
854 if (sc->sc_padi_retried < 0xff) {
855 sc->sc_padi_retried++;
857 if (!sc->pcb->settings.persist && sc->sc_padi_retried >= PPPOE_DISC_MAXPADI) {
859 if ((sc->sc_sppp.pp_if.if_flags & IFF_LINK1) == 0) {
861 retry_wait = PPPOE_SLOW_RETRY;
865 pppoe_abort_connect(sc);
870 retry_wait =
LWIP_MIN(PPPOE_DISC_TIMEOUT * sc->sc_padi_retried, PPPOE_SLOW_RETRY);
871 if ((
err = pppoe_send_padi(sc)) != 0) {
872 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));
875 sys_timeout(retry_wait, pppoe_timeout, sc);
878 case PPPOE_STATE_PADR_SENT:
879 sc->sc_padr_retried++;
880 if (sc->sc_padr_retried >= PPPOE_DISC_MAXPADR) {
881 MEMCPY(&sc->sc_dest, ethbroadcast.addr,
sizeof(sc->sc_dest));
882 sc->sc_state = PPPOE_STATE_PADI_SENT;
883 sc->sc_padr_retried = 0;
884 if ((
err = pppoe_send_padi(sc)) != 0) {
885 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));
888 sys_timeout(PPPOE_DISC_TIMEOUT * (1 + sc->sc_padi_retried), pppoe_timeout, sc);
891 if ((
err = pppoe_send_padr(sc)) != 0) {
892 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));
895 sys_timeout(PPPOE_DISC_TIMEOUT * (1 + sc->sc_padr_retried), pppoe_timeout, sc);
904pppoe_connect(ppp_pcb *ppp,
void *
ctx)
907 struct pppoe_softc *sc = (
struct pppoe_softc *)
ctx;
910#if PPP_IPV4_SUPPORT && VJ_SUPPORT
911 ipcp_options *ipcp_wo;
912 ipcp_options *ipcp_ao;
916 sc->sc_ac_cookie_len = 0;
917 sc->sc_padi_retried = 0;
918 sc->sc_padr_retried = 0;
920 MEMCPY(&sc->sc_dest, ethbroadcast.addr,
sizeof(sc->sc_dest));
923 if ((sc->sc_sppp.pp_if.if_flags & IFF_PASSIVE)) {
928 lcp_wo = &ppp->lcp_wantoptions;
929 lcp_wo->mru = sc->sc_ethif->mtu-PPPOE_HEADERLEN-2;
930 lcp_wo->neg_asyncmap = 0;
931 lcp_wo->neg_pcompression = 0;
932 lcp_wo->neg_accompression = 0;
936 lcp_ao = &ppp->lcp_allowoptions;
937 lcp_ao->mru = sc->sc_ethif->mtu-PPPOE_HEADERLEN-2;
938 lcp_ao->neg_asyncmap = 0;
939 lcp_ao->neg_pcompression = 0;
940 lcp_ao->neg_accompression = 0;
942#if PPP_IPV4_SUPPORT && VJ_SUPPORT
943 ipcp_wo = &ppp->ipcp_wantoptions;
947 ipcp_ao = &ppp->ipcp_allowoptions;
953 sc->sc_state = PPPOE_STATE_PADI_SENT;
954 if ((
err = pppoe_send_padi(sc)) != 0) {
955 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));
957 sys_timeout(PPPOE_DISC_TIMEOUT, pppoe_timeout, sc);
962pppoe_disconnect(ppp_pcb *ppp,
void *
ctx)
964 struct pppoe_softc *sc = (
struct pppoe_softc *)
ctx;
966 PPPDEBUG(
LOG_DEBUG, (
"pppoe: %c%c%"U16_F": disconnecting\n", sc->sc_ethif->
name[0], sc->sc_ethif->name[1], sc->sc_ethif->num));
967 if (sc->sc_state == PPPOE_STATE_SESSION) {
968 pppoe_send_padt(sc->sc_ethif, sc->sc_session, (
const u8_t *)&sc->sc_dest);
972 sys_untimeout(pppoe_timeout, sc);
973 sc->sc_state = PPPOE_STATE_INITIAL;
975 if (sc->sc_hunique) {
977 sc->sc_hunique =
NULL;
979 sc->sc_hunique_len = 0;
987pppoe_abort_connect(
struct pppoe_softc *sc)
989 PPPDEBUG(
LOG_DEBUG, (
"%c%c%"U16_F": could not establish connection\n", sc->sc_ethif->
name[0], sc->sc_ethif->name[1], sc->sc_ethif->num));
990 sc->sc_state = PPPOE_STATE_INITIAL;
991 ppp_link_failed(sc->pcb);
996pppoe_send_padr(
struct pppoe_softc *sc)
1001#if PPPOE_SCNAME_SUPPORT
1005 len = 2 + 2 + 2 + 2 +
sizeof(sc);
1006#if PPPOE_SCNAME_SUPPORT
1007 if (sc->sc_service_name !=
NULL) {
1008 l1 =
strlen(sc->sc_service_name);
1012 if (sc->sc_ac_cookie_len > 0) {
1013 len += 2 + 2 + sc->sc_ac_cookie_len;
1015 LWIP_ASSERT(
"sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len <= 0xffff",
1016 sizeof(
struct eth_hdr) + PPPOE_HEADERLEN +
len <= 0xffff);
1023 PPPOE_ADD_HEADER(
p, PPPOE_CODE_PADR, 0,
len);
1024 PPPOE_ADD_16(
p, PPPOE_TAG_SNAME);
1025#if PPPOE_SCNAME_SUPPORT
1026 if (sc->sc_service_name !=
NULL) {
1027 PPPOE_ADD_16(
p, l1);
1028 MEMCPY(
p, sc->sc_service_name, l1);
1035 if (sc->sc_ac_cookie_len > 0) {
1036 PPPOE_ADD_16(
p, PPPOE_TAG_ACCOOKIE);
1037 PPPOE_ADD_16(
p, sc->sc_ac_cookie_len);
1038 MEMCPY(
p, sc->sc_ac_cookie, sc->sc_ac_cookie_len);
1039 p += sc->sc_ac_cookie_len;
1041 PPPOE_ADD_16(
p, PPPOE_TAG_HUNIQUE);
1042 PPPOE_ADD_16(
p,
sizeof(sc));
1045 return pppoe_output(sc, pb);
1064 PPPDEBUG(
LOG_ERR, (
"pppoe: pppoe_send_padt: could not allocate room for PPPoE header\n"));
1071 MEMCPY(ðhdr->dest.addr,
dest,
sizeof(ethhdr->dest.addr));
1072 MEMCPY(ðhdr->src.addr, &outgoing_if->
hwaddr,
sizeof(ethhdr->src.addr));
1074 p = (
u8_t*)(ethhdr + 1);
1075 PPPOE_ADD_HEADER(
p, PPPOE_CODE_PADT,
session, 0);
1086pppoe_send_pado(
struct pppoe_softc *sc)
1095 len += 2 + 2 +
sizeof(sc);
1097 len += 2 + 2 + sc->sc_hunique_len;
1104 PPPOE_ADD_HEADER(
p, PPPOE_CODE_PADO, 0,
len);
1105 PPPOE_ADD_16(
p, PPPOE_TAG_ACCOOKIE);
1106 PPPOE_ADD_16(
p,
sizeof(sc));
1109 PPPOE_ADD_16(
p, PPPOE_TAG_HUNIQUE);
1110 PPPOE_ADD_16(
p, sc->sc_hunique_len);
1111 MEMCPY(
p, sc->sc_hunique, sc->sc_hunique_len);
1112 return pppoe_output(sc, pb);
1116pppoe_send_pads(
struct pppoe_softc *sc)
1122 sc->sc_session = mono_time.tv_sec % 0xff + 1;
1126 len += 2 + 2 + 2 + 2 + sc->sc_hunique_len;
1127 if (sc->sc_service_name !=
NULL) {
1128 l1 =
strlen(sc->sc_service_name);
1137 PPPOE_ADD_HEADER(
p, PPPOE_CODE_PADS, sc->sc_session,
len);
1138 PPPOE_ADD_16(
p, PPPOE_TAG_SNAME);
1139 if (sc->sc_service_name !=
NULL) {
1140 PPPOE_ADD_16(
p, l1);
1141 MEMCPY(
p, sc->sc_service_name, l1);
1146 PPPOE_ADD_16(
p, PPPOE_TAG_HUNIQUE);
1147 PPPOE_ADD_16(
p, sc->sc_hunique_len);
1148 MEMCPY(
p, sc->sc_hunique, sc->sc_hunique_len);
1149 return pppoe_output(sc, pb);
1154pppoe_xmit(
struct pppoe_softc *sc,
struct pbuf *pb)
1164 PPPDEBUG(
LOG_ERR, (
"pppoe: %c%c%"U16_F": pppoe_xmit: could not allocate room for PPPoE header\n", sc->sc_ethif->
name[0], sc->sc_ethif->name[1], sc->sc_ethif->num));
1171 PPPOE_ADD_HEADER(
p, 0, sc->sc_session,
len);
1173 return pppoe_output(sc, pb);
1178pppoe_ifattach_hook(
void *
arg,
struct pbuf **mp,
struct netif *ifp,
int dir)
1180 struct pppoe_softc *sc;
1183 if (mp != (
struct pbuf **)PFIL_IFNET_DETACH) {
1188 if (sc->sc_ethif != ifp) {
1191 if (sc->sc_sppp.pp_if.if_flags &
IFF_UP) {
1192 sc->sc_sppp.pp_if.if_flags &= ~(
IFF_UP|IFF_RUNNING);
1193 PPPDEBUG(
LOG_DEBUG, (
"%c%c%"U16_F": ethernet interface detached, going down\n",
1194 sc->sc_ethif->
name[0], sc->sc_ethif->name[1], sc->sc_ethif->num));
1196 sc->sc_ethif =
NULL;
1197 pppoe_clear_softc(sc,
"ethernet interface detached");
1206pppoe_clear_softc(
struct pppoe_softc *sc,
const char *
message)
1211 sys_untimeout(pppoe_timeout, sc);
1212 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));
1213 sc->sc_state = PPPOE_STATE_INITIAL;
1214 ppp_link_end(sc->pcb);
static char service_name[100]
ACPI_SIZE strlen(const char *String)
static VOID freep(LPSTR *p)
#define mem_free(ptr, bsize)
void * mem_malloc(mem_size_t size_in)
#define LWIP_ASSERT(message, assertion)
#define MIB2_STATS_NETIF_ADD(n, x, val)
#define MIB2_STATS_NETIF_INC(n, x)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
#define LWIP_UNUSED_ARG(x)
#define LWIP_ASSERT_CORE_LOCKED()
#define LWIP_MEMPOOL_DECLARE(name, num, size, desc)
#define LWIP_MEMPOOL_ALLOC(name)
#define LWIP_MEMPOOL_FREE(name, x)
struct pbuf * pbuf_coalesce(struct pbuf *p, pbuf_layer layer)
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)
#define MEMCPY(DST, SRC, BYTES)
u8_t pbuf_add_header(struct pbuf *p, size_t header_size_increment)
u8_t pbuf_remove_header(struct pbuf *p, size_t header_size_decrement)
#define LINK_STATS_INC(x)
u8_t hwaddr[NETIF_MAX_HWADDR_LEN]
netif_linkoutput_fn linkoutput
#define LIST_FOREACH(var, head, field)