Deleted Added
sdiff udiff text old ( 68876 ) new ( 69922 )
full compact
1
2/*
3 * ng_pppoe.c
4 *
5 * Copyright (c) 1996-1999 Whistle Communications, Inc.
6 * All rights reserved.
7 *
8 * Subject to the following obligations and disclaimer of warranty, use and

--- 22 unchanged lines hidden (view full) ---

31 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
35 * OF SUCH DAMAGE.
36 *
37 * Author: Julian Elischer <julian@freebsd.org>
38 *
39 * $FreeBSD: head/sys/netgraph/ng_pppoe.c 68876 2000-11-18 15:17:43Z dwmalone $
40 * $Whistle: ng_pppoe.c,v 1.10 1999/11/01 09:24:52 julian Exp $
41 */
42#if 0
43#define AAA printf("pppoe: %s\n", __FUNCTION__ );
44#define BBB printf("-%d-", __LINE__ );
45#else
46#define AAA
47#define BBB

--- 64 unchanged lines hidden (view full) ---

112 NGM_PPPOE_COOKIE,
113 NGM_PPPOE_OFFER,
114 "pppoe_offer",
115 &ngpppoe_init_data_state_type,
116 NULL
117 },
118 {
119 NGM_PPPOE_COOKIE,
120 NGM_PPPOE_SUCCESS,
121 "pppoe_success",
122 &ng_pppoe_sts_state_type,
123 NULL
124 },
125 {
126 NGM_PPPOE_COOKIE,
127 NGM_PPPOE_FAIL,

--- 18 unchanged lines hidden (view full) ---

146 NULL,
147 ng_pppoe_constructor,
148 ng_pppoe_rcvmsg,
149 ng_pppoe_rmnode,
150 ng_pppoe_newhook,
151 NULL,
152 ng_pppoe_connect,
153 ng_pppoe_rcvdata,
154 ng_pppoe_rcvdata,
155 ng_pppoe_disconnect,
156 ng_pppoe_cmds
157};
158NETGRAPH_INIT(pppoe, &typestruct);
159
160/*
161 * States for the session state machine.
162 * These have no meaning if there is no hook attached yet.

--- 356 unchanged lines hidden (view full) ---

519/*
520 * Allocate the private data structure and the generic node
521 * and link them together.
522 *
523 * ng_make_node_common() returns with a generic node struct
524 * with a single reference for us.. we transfer it to the
525 * private structure.. when we free the private struct we must
526 * unref the node so it gets freed too.
527 *
528 * If this were a device node than this work would be done in the attach()
529 * routine and the constructor would return EINVAL as you should not be able
530 * to creatednodes that depend on hardware (unless you can add the hardware :)
531 */
532static int
533ng_pppoe_constructor(node_p *nodep)
534{
535 priv_p privdata;
536 int error;
537
538AAA

--- 17 unchanged lines hidden (view full) ---

556
557/*
558 * Give our ok for a hook to be added...
559 * point the hook's private info to the hook structure.
560 *
561 * The following hook names are special:
562 * Ethernet: the hook that should be connected to a NIC.
563 * debug: copies of data sent out here (when I write the code).
564 */
565static int
566ng_pppoe_newhook(node_p node, hook_p hook, const char *name)
567{
568 const priv_p privp = node->private;
569 sessp sp;
570
571AAA

--- 41 unchanged lines hidden (view full) ---

613AAA
614 /* Deal with message according to cookie and command */
615 switch (msg->header.typecookie) {
616 case NGM_PPPOE_COOKIE:
617 switch (msg->header.cmd) {
618 case NGM_PPPOE_CONNECT:
619 case NGM_PPPOE_LISTEN:
620 case NGM_PPPOE_OFFER:
621 ourmsg = (struct ngpppoe_init_data *)msg->data;
622 if (msg->header.arglen < sizeof(*ourmsg)) {
623 printf("pppoe: init data too small\n");
624 LEAVE(EMSGSIZE);
625 }
626 if (msg->header.arglen - sizeof(*ourmsg) >
627 PPPOE_SERVICE_NAME_SIZE) {
628 printf("pppoe_rcvmsg: service name too big");

--- 19 unchanged lines hidden (view full) ---

648 if (hook == NULL) {
649 LEAVE(ENOENT);
650 }
651 if ((hook->private == &privp->debug_hook)
652 || (hook->private == &privp->ethernet_hook)) {
653 LEAVE(EINVAL);
654 }
655 sp = hook->private;
656 if (sp->state |= PPPOE_SNONE) {
657 printf("pppoe: Session already active\n");
658 LEAVE(EISCONN);
659 }
660
661 /*
662 * set up prototype header
663 */

--- 66 unchanged lines hidden (view full) ---

730 break;
731 case NGM_PPPOE_LISTEN:
732 /*
733 * Check the hook exists and is Uninitialised.
734 * Install the service matching string.
735 * Store the originator of this message so we can send
736 * a success of fail message to them later.
737 * Move the hook to 'LISTENING'
738
739 */
740 neg->service.hdr.tag_type = PTT_SRV_NAME;
741 neg->service.hdr.tag_len =
742 htons((u_int16_t)ourmsg->data_len);
743
744 if (ourmsg->data_len)
745 bcopy(ourmsg->data, neg->service.data,
746 ourmsg->data_len);

--- 19 unchanged lines hidden (view full) ---

766 ourmsg->data_len);
767 neg->ac_name_len = ourmsg->data_len;
768 neg->pkt->pkt_header.ph.code = PADO_CODE;
769 /*
770 * Wait for PADI packet coming from hook
771 */
772 sp->state = PPPOE_PRIMED;
773 break;
774 default:
775 LEAVE(EINVAL);
776 }
777 break;
778 default:
779 LEAVE(EINVAL);
780 }
781

--- 41 unchanged lines hidden (view full) ---

823
824/*
825 * Receive data, and do something with it.
826 * The caller will never free m or meta, so
827 * if we use up this data or abort we must free BOTH of these.
828 */
829static int
830ng_pppoe_rcvdata(hook_p hook, struct mbuf *m, meta_p meta,
831 struct mbuf **ret_m, meta_p *ret_meta)
832{
833 node_p node = hook->node;
834 const priv_p privp = node->private;
835 sessp sp = hook->private;
836 struct pppoe_full_hdr *wh;
837 struct pppoe_hdr *ph;
838 int error = 0;
839 u_int16_t session;

--- 423 unchanged lines hidden (view full) ---

1263 */
1264 uniqtag.hdr.tag_type = PTT_AC_COOKIE;
1265 uniqtag.hdr.tag_len = htons((u_int16_t)sizeof(sp));
1266 uniqtag.data.pointer = sp;
1267 init_tags(sp);
1268 insert_tag(sp, &neg->ac_name.hdr); /* AC_NAME */
1269 if ((tag = get_tag(ph, PTT_SRV_NAME)))
1270 insert_tag(sp, tag); /* return service */
1271 if ((tag = get_tag(ph, PTT_HOST_UNIQ)))
1272 insert_tag(sp, tag); /* returned hostunique */
1273 insert_tag(sp, &uniqtag.hdr);
1274 /* XXX maybe put the tag in the session store */
1275 scan_tags(sp, ph);
1276 make_packet(sp);
1277 sendpacket(sp);
1278 break;
1279
1280 /*
1281 * Packets coming from the hook make no sense
1282 * to sessions in these states. Throw them away.

--- 295 unchanged lines hidden (view full) ---

1578{
1579 int error;
1580 struct ng_mesg *msg;
1581 struct ngpppoe_sts *sts;
1582
1583AAA
1584 NG_MKMESSAGE(msg, NGM_PPPOE_COOKIE, cmdid,
1585 sizeof(struct ngpppoe_sts), M_NOWAIT);
1586 sts = (struct ngpppoe_sts *)msg->data;
1587 strncpy(sts->hook, sp->hook->name, NG_HOOKLEN + 1);
1588 error = ng_send_msg(sp->hook->node, msg, sp->creator, NULL);
1589 return (error);
1590}