diff options
author | Julian Elischer <julian@FreeBSD.org> | 1999-10-23 04:28:11 +0000 |
---|---|---|
committer | Julian Elischer <julian@FreeBSD.org> | 1999-10-23 04:28:11 +0000 |
commit | b58a8a3b1d5cdaf3b9f89a6ee064a59b1bb84326 (patch) | |
tree | da0a6d48db55b43982988a91a3e4b738558ea7c8 /sys/netgraph | |
parent | 0fe9a7da10f555dd75c1e5647e14b4dfa3c86c4e (diff) | |
download | src-b58a8a3b1d5cdaf3b9f89a6ee064a59b1bb84326.tar.gz src-b58a8a3b1d5cdaf3b9f89a6ee064a59b1bb84326.zip |
Now that Netgraph is in the system there are some cleanups we can do.
Also save a slightly closer to completion version of the PPPOE code.
Submitted by: Archie Cobbs <archie@freebsd.org>
Notes
Notes:
svn path=/head/; revision=52441
Diffstat (limited to 'sys/netgraph')
-rw-r--r-- | sys/netgraph/ng_pppoe.c | 27 | ||||
-rw-r--r-- | sys/netgraph/ng_pppoe.h | 4 | ||||
-rw-r--r-- | sys/netgraph/ng_tty.c | 10 |
3 files changed, 30 insertions, 11 deletions
diff --git a/sys/netgraph/ng_pppoe.c b/sys/netgraph/ng_pppoe.c index b59dbb3f87df..77142bb532a0 100644 --- a/sys/netgraph/ng_pppoe.c +++ b/sys/netgraph/ng_pppoe.c @@ -174,6 +174,7 @@ static void pppoe_start(sessp sp); static void sendpacket(sessp sp); static void pppoe_ticker(void *arg); static struct pppoe_tag* scan_tags(sessp sp, struct pppoe_hdr* ph); +static int pppoe_send_event(sessp sp, enum cmd cmdid); /************************************************************************* * Some basic utilities from the Linux version with author's permission.* @@ -923,6 +924,7 @@ ng_PPPoE_rcvdata(hook_p hook, struct mbuf *m, meta_p meta) make_packet(sp); sp->state = PPPOE_NEWCONNECTED; sendpacket(sp); + pppoe_send_event(sp, NGM_PPPOE_SUCCESS); /* * Having sent the last Negotiation header, * Set up the stored packet header to @@ -936,6 +938,7 @@ ng_PPPoE_rcvdata(hook_p hook, struct mbuf *m, meta_p meta) sp->pkt_hdr.eh.ether_type = ETHERTYPE_PPPOE_SESS; sp->pkt_hdr.ph.code = 0; + pppoe_send_event(sp, NGM_PPPOE_SUCCESS); break; case PADS_CODE: /* @@ -986,6 +989,7 @@ ng_PPPoE_rcvdata(hook_p hook, struct mbuf *m, meta_p meta) m_freem(neg->m); FREE(sp->neg, M_NETGRAPH); sp->neg = NULL; + pppoe_send_event(sp, NGM_PPPOE_SUCCESS); break; case PADT_CODE: /* @@ -1002,7 +1006,9 @@ ng_PPPoE_rcvdata(hook_p hook, struct mbuf *m, meta_p meta) } /* send message to creator */ /* close hook */ - ng_destroy_hook(sendhook); + if (sendhook) { + ng_destroy_hook(sendhook); + } break; default: LEAVE(EPFNOSUPPORT); @@ -1189,6 +1195,9 @@ ng_PPPoE_disconnect(hook_p hook) privp->ethernet_hook = NULL; } else { sp = hook->private; + if (sp->state != PPPOE_SNONE ) { + pppoe_send_event(sp, NGM_PPPOE_CLOSE); + } untimeout(pppoe_ticker, hook, sp->neg->timeout_handle); FREE(sp, M_NETGRAPH); } @@ -1228,6 +1237,7 @@ pppoe_ticker(void *arg) if ((neg->timeout <<= 1) > PPPOE_TIMEOUT_LIMIT) { if (sp->state == PPPOE_SREQ) { /* revert to SINIT mode */ + pppoe_start(sp); } else { neg->timeout = PPPOE_TIMEOUT_LIMIT; } @@ -1236,7 +1246,6 @@ pppoe_ticker(void *arg) case PPPOE_PRIMED: case PPPOE_SOFFER: /* a timeout on these says "give up" */ - /* XXX should notify creator */ ng_destroy_hook(hook); break; default: @@ -1341,3 +1350,17 @@ scan_tags(sessp sp, struct pppoe_hdr* ph) return NULL; } +static int +pppoe_send_event(sessp sp, enum cmd cmdid) +{ + int error; + struct ng_mesg *msg; + struct ngPPPoE_sts *sts; + + NG_MKMESSAGE(msg, NGM_PPPOE_COOKIE, cmdid, + sizeof(struct ngPPPoE_sts), M_NOWAIT); + sts = (struct ngPPPoE_sts *)msg->data; + strncpy(sts->hook, sp->hook->name, NG_HOOKLEN + 1); + error = ng_send_msg(sp->hook->node, msg, sp->creator, NULL); + return (error); +} diff --git a/sys/netgraph/ng_pppoe.h b/sys/netgraph/ng_pppoe.h index 5ee3e7dac2e1..6e71f6f4b7e4 100644 --- a/sys/netgraph/ng_pppoe.h +++ b/sys/netgraph/ng_pppoe.h @@ -66,7 +66,7 @@ * Netgraph commands understood by this node type. * FAIL, SUCCESS and CLOSE are sent by the node rather than received. ********************************************************************/ -enum { +enum cmd { NGM_PPPOE_SET_FLAG = 1, NGM_PPPOE_CONNECT = 2, /* Client, Try find this service */ NGM_PPPOE_LISTEN = 3, /* Server, Await a request for this service */ @@ -115,7 +115,7 @@ struct ngPPPoE_init_data { * (to report which hook has failed or connected). The message is sent * to whoever requested the connection. (close may use this too). */ -struct ngPPPoE_req { +struct ngPPPoE_sts { char hook[NG_HOOKLEN + 1]; /* hook associated with event session */ }; diff --git a/sys/netgraph/ng_tty.c b/sys/netgraph/ng_tty.c index 4ec7bf9d52ad..568aae73200f 100644 --- a/sys/netgraph/ng_tty.c +++ b/sys/netgraph/ng_tty.c @@ -69,6 +69,7 @@ #include <sys/fcntl.h> #include <sys/file.h> #include <sys/tty.h> +#include <sys/ttycom.h> #include <sys/syslog.h> #include <sys/errno.h> #include <sys/ioccom.h> @@ -158,7 +159,6 @@ static struct linesw ngt_disc = { ttymodem, NG_TTY_DFL_HOTCHAR /* XXX can't change this in serial driver */ }; -static int ngt_ldisc = -1; /* Netgraph node type descriptor */ static struct ng_type typestruct = { @@ -203,7 +203,7 @@ ngt_open(dev_t dev, struct tty *tp) (void) spltty(); /* XXX is this necessary? */ /* Already installed? */ - if (tp->t_line == ngt_ldisc) { + if (tp->t_line == NETGRAPHDISC) { sc = (sc_p) tp->t_sc; if (sc != NULL && sc->tp == tp) goto done; @@ -676,17 +676,13 @@ ngt_mod_event(module_t mod, int event, void *data) /* Register line discipline */ s = spltty(); - if ((ngt_ldisc = ldisc_register(LDISC_LOAD, &ngt_disc)) < 0) { + if ((ngt_ldisc = ldisc_register(NETGRAPHDISC, &ngt_disc)) < 0) { splx(s); log(LOG_ERR, "%s: can't register line discipline", __FUNCTION__); return (EIO); } splx(s); - - /* OK */ - log(LOG_INFO, "line discipline #%d registered to" - " netgraph node type \"%s\"\n", ngt_ldisc, type->name); break; case MOD_UNLOAD: |