Deleted Added
full compact
ether.c (90975) ether.c (93418)
1/*-
2 * Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/usr.sbin/ppp/ether.c 90975 2002-02-20 15:52:20Z brian $
26 * $FreeBSD: head/usr.sbin/ppp/ether.c 93418 2002-03-30 12:30:09Z brian $
27 */
28
29#include <sys/param.h>
30#include <sys/socket.h>
31#include <sys/un.h>
32#include <netinet/in.h>
33#include <arpa/inet.h>
34#include <netdb.h>

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

44#include <netgraph/ng_socket.h>
45
46#include <errno.h>
47#include <stdio.h>
48#include <stdlib.h>
49#include <string.h>
50#include <sysexits.h>
51#include <sys/fcntl.h>
27 */
28
29#include <sys/param.h>
30#include <sys/socket.h>
31#include <sys/un.h>
32#include <netinet/in.h>
33#include <arpa/inet.h>
34#include <netdb.h>

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

44#include <netgraph/ng_socket.h>
45
46#include <errno.h>
47#include <stdio.h>
48#include <stdlib.h>
49#include <string.h>
50#include <sysexits.h>
51#include <sys/fcntl.h>
52#if defined(__FreeBSD__) && !defined(NOKLDLOAD)
53#include <sys/linker.h>
54#include <sys/module.h>
55#endif
56#include <sys/stat.h>
57#include <sys/uio.h>
58#include <termios.h>
59#include <sys/time.h>
60#include <unistd.h>
61
62#include "layer.h"
63#include "defs.h"

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

297 1492,
298 { CD_REQUIRED, DEF_ETHERCDDELAY },
299 ether_AwaitCarrier,
300 ether_RemoveFromSet,
301 NULL,
302 NULL,
303 NULL,
304 NULL,
52#include <sys/stat.h>
53#include <sys/uio.h>
54#include <termios.h>
55#include <sys/time.h>
56#include <unistd.h>
57
58#include "layer.h"
59#include "defs.h"

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

293 1492,
294 { CD_REQUIRED, DEF_ETHERCDDELAY },
295 ether_AwaitCarrier,
296 ether_RemoveFromSet,
297 NULL,
298 NULL,
299 NULL,
300 NULL,
301 NULL,
305 ether_Free,
306 ether_Read,
307 ether_Write,
308 ether_device2iov,
309 NULL,
310 ether_OpenInfo
311};
312

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

427 struct ngm_connect ngc;
428 const char *iface, *provider;
429 char etherid[12];
430 int providerlen;
431 char connectpath[sizeof dev->hook + 2]; /* .:<hook> */
432
433 p->fd--; /* We own the device - change fd */
434
302 ether_Free,
303 ether_Read,
304 ether_Write,
305 ether_device2iov,
306 NULL,
307 ether_OpenInfo
308};
309

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

424 struct ngm_connect ngc;
425 const char *iface, *provider;
426 char etherid[12];
427 int providerlen;
428 char connectpath[sizeof dev->hook + 2]; /* .:<hook> */
429
430 p->fd--; /* We own the device - change fd */
431
435#if defined(__FreeBSD__) && !defined(NOKLDLOAD)
436 if (modfind("netgraph") == -1 && ID0kldload("netgraph") == -1) {
437 log_Printf(LogWARN, "kldload: netgraph: %s\n", strerror(errno));
438 return NULL;
439 }
432 loadmodules(LOAD_VERBOSLY, "netgraph", "ng_ether", "ng_pppoe", "ng_socket",
433 NULL);
440
434
441 if (modfind("ng_ether") == -1 && ID0kldload("ng_ether") == -1)
442 /*
443 * Don't treat this as an error as older kernels have this stuff
444 * built in as part of the netgraph node itself.
445 */
446 log_Printf(LogWARN, "kldload: ng_ether: %s\n", strerror(errno));
447
448 if (modfind("ng_pppoe") == -1 && ID0kldload("ng_pppoe") == -1) {
449 log_Printf(LogWARN, "kldload: ng_pppoe: %s\n", strerror(errno));
450 return NULL;
451 }
452
453 if (modfind("ng_socket") == -1 && ID0kldload("ng_socket") == -1) {
454 log_Printf(LogWARN, "kldload: ng_socket: %s\n", strerror(errno));
455 return NULL;
456 }
457#endif
458
459 if ((dev = malloc(sizeof *dev)) == NULL)
460 return NULL;
461
462 iface = p->name.full + PPPOE_NODE_TYPE_LEN + 1;
463
464 provider = strchr(iface, ':');
465 if (provider) {
466 ifacelen = provider - iface;

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

493 * `--->(tunX)
494 */
495
496 /* Create a socket node */
497 if (ID0NgMkSockNode(NULL, &dev->cs, &p->fd) == -1) {
498 log_Printf(LogWARN, "Cannot create netgraph socket node: %s\n",
499 strerror(errno));
500 free(dev);
435 if ((dev = malloc(sizeof *dev)) == NULL)
436 return NULL;
437
438 iface = p->name.full + PPPOE_NODE_TYPE_LEN + 1;
439
440 provider = strchr(iface, ':');
441 if (provider) {
442 ifacelen = provider - iface;

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

469 * `--->(tunX)
470 */
471
472 /* Create a socket node */
473 if (ID0NgMkSockNode(NULL, &dev->cs, &p->fd) == -1) {
474 log_Printf(LogWARN, "Cannot create netgraph socket node: %s\n",
475 strerror(errno));
476 free(dev);
477 p->fd = -2;
501 return NULL;
502 }
503
504 /*
505 * Ask for a list of hooks attached to the "ether" node. This node should
506 * magically exist as a way of hooking stuff onto an ethernet device
507 */
508 path = (char *)alloca(ifacelen + 2);

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

560 }
561 break;
562 }
563 }
564
565 if (f == ninfo->hooks) {
566 /*
567 * Create a new ``PPPoE'' node connected to the ``ether'' node using
478 return NULL;
479 }
480
481 /*
482 * Ask for a list of hooks attached to the "ether" node. This node should
483 * magically exist as a way of hooking stuff onto an ethernet device
484 */
485 path = (char *)alloca(ifacelen + 2);

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

537 }
538 break;
539 }
540 }
541
542 if (f == ninfo->hooks) {
543 /*
544 * Create a new ``PPPoE'' node connected to the ``ether'' node using
568 * the magic ``orphan'' and ``ethernet'' hooks
545 * the ``orphan'' and ``ethernet'' hooks
569 */
570 snprintf(mkp.type, sizeof mkp.type, "%s", NG_PPPOE_NODE_TYPE);
571 snprintf(mkp.ourhook, sizeof mkp.ourhook, "%s", NG_ETHER_HOOK_ORPHAN);
572 snprintf(mkp.peerhook, sizeof mkp.peerhook, "%s", NG_PPPOE_HOOK_ETHERNET);
573 snprintf(etherid, sizeof etherid, "[%x]:", ninfo->id);
574
575 log_Printf(LogDEBUG, "Creating PPPoE netgraph node %s%s -> %s\n",
576 etherid, mkp.ourhook, mkp.peerhook);

--- 121 unchanged lines hidden ---
546 */
547 snprintf(mkp.type, sizeof mkp.type, "%s", NG_PPPOE_NODE_TYPE);
548 snprintf(mkp.ourhook, sizeof mkp.ourhook, "%s", NG_ETHER_HOOK_ORPHAN);
549 snprintf(mkp.peerhook, sizeof mkp.peerhook, "%s", NG_PPPOE_HOOK_ETHERNET);
550 snprintf(etherid, sizeof etherid, "[%x]:", ninfo->id);
551
552 log_Printf(LogDEBUG, "Creating PPPoE netgraph node %s%s -> %s\n",
553 etherid, mkp.ourhook, mkp.peerhook);

--- 121 unchanged lines hidden ---