Deleted Added
full compact
ng_device.c (129823) ng_device.c (130585)
1/*
2 * Copyright (c) 2002 Mark Santcroos <marks@ripe.net>
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

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

23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * Netgraph "device" node
27 *
28 * This node presents a /dev/ngd%d device that interfaces to an other
29 * netgraph node.
30 *
1/*
2 * Copyright (c) 2002 Mark Santcroos <marks@ripe.net>
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

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

23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * Netgraph "device" node
27 *
28 * This node presents a /dev/ngd%d device that interfaces to an other
29 * netgraph node.
30 *
31 * $FreeBSD: head/sys/netgraph/ng_device.c 129823 2004-05-29 00:51:19Z julian $
31 * $FreeBSD: head/sys/netgraph/ng_device.c 130585 2004-06-16 09:47:26Z phk $
32 *
33 */
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/kernel.h>
38#include <sys/mbuf.h>
39#include <sys/uio.h>

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

76 .disconnect = ng_device_disconnect,
77};
78NETGRAPH_INIT(device, &typestruct);
79
80/* per hook data */
81struct ngd_connection {
82 SLIST_ENTRY(ngd_connection) links;
83
32 *
33 */
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/kernel.h>
38#include <sys/mbuf.h>
39#include <sys/uio.h>

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

76 .disconnect = ng_device_disconnect,
77};
78NETGRAPH_INIT(device, &typestruct);
79
80/* per hook data */
81struct ngd_connection {
82 SLIST_ENTRY(ngd_connection) links;
83
84 dev_t ngddev;
84 struct cdev *ngddev;
85 struct ng_hook *active_hook;
86 char *readq;
87 int loc;
88 int unit;
89};
90
91/* global data */
92struct ngd_softc {

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

407 SLIST_REMOVE(&sc->head,connection,ngd_connection,links);
408
409 return(0);
410}
411/*
412 * the device is opened
413 */
414static int
85 struct ng_hook *active_hook;
86 char *readq;
87 int loc;
88 int unit;
89};
90
91/* global data */
92struct ngd_softc {

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

407 SLIST_REMOVE(&sc->head,connection,ngd_connection,links);
408
409 return(0);
410}
411/*
412 * the device is opened
413 */
414static int
415ngdopen(dev_t dev, int flag, int mode, struct thread *td)
415ngdopen(struct cdev *dev, int flag, int mode, struct thread *td)
416{
417
418#ifdef NGD_DEBUG
419 printf("%s()\n",__func__);
420#endif /* NGD_DEBUG */
421
422 return(0);
423}
424
425/*
426 * the device is closed
427 */
428static int
416{
417
418#ifdef NGD_DEBUG
419 printf("%s()\n",__func__);
420#endif /* NGD_DEBUG */
421
422 return(0);
423}
424
425/*
426 * the device is closed
427 */
428static int
429ngdclose(dev_t dev, int flag, int mode, struct thread *td)
429ngdclose(struct cdev *dev, int flag, int mode, struct thread *td)
430{
431
432#ifdef NGD_DEBUG
433 printf("%s()\n",__func__);
434#endif
435
436 return(0);
437}
438
439
440/*
441 * process ioctl
442 *
443 * they are translated into netgraph messages and passed on
444 *
445 */
446static int
430{
431
432#ifdef NGD_DEBUG
433 printf("%s()\n",__func__);
434#endif
435
436 return(0);
437}
438
439
440/*
441 * process ioctl
442 *
443 * they are translated into netgraph messages and passed on
444 *
445 */
446static int
447ngdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
447ngdioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
448{
449 struct ngd_softc *sc = &ngd_softc;
450 struct ngd_connection * connection = NULL;
451 struct ngd_connection * tmp;
452 int error = 0;
453 struct ng_mesg *msg;
454 struct ngd_param_s * datap;
455

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

491
492
493/*
494 * This function is called when a read(2) is done to our device.
495 * We pass the data available in kernelspace on into userland using
496 * uiomove.
497 */
498static int
448{
449 struct ngd_softc *sc = &ngd_softc;
450 struct ngd_connection * connection = NULL;
451 struct ngd_connection * tmp;
452 int error = 0;
453 struct ng_mesg *msg;
454 struct ngd_param_s * datap;
455

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

491
492
493/*
494 * This function is called when a read(2) is done to our device.
495 * We pass the data available in kernelspace on into userland using
496 * uiomove.
497 */
498static int
499ngdread(dev_t dev, struct uio *uio, int flag)
499ngdread(struct cdev *dev, struct uio *uio, int flag)
500{
501 int ret = 0, amnt;
502 char buffer[uio->uio_resid+1];
503 struct ngd_softc *sc = &ngd_softc;
504 struct ngd_connection * connection = NULL;
505 struct ngd_connection * tmp;
506
507#ifdef NGD_DEBUG

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

542
543/*
544 * This function is called when our device is written to.
545 * We read the data from userland into our local buffer and pass it on
546 * into the remote hook.
547 *
548 */
549static int
500{
501 int ret = 0, amnt;
502 char buffer[uio->uio_resid+1];
503 struct ngd_softc *sc = &ngd_softc;
504 struct ngd_connection * connection = NULL;
505 struct ngd_connection * tmp;
506
507#ifdef NGD_DEBUG

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

542
543/*
544 * This function is called when our device is written to.
545 * We read the data from userland into our local buffer and pass it on
546 * into the remote hook.
547 *
548 */
549static int
550ngdwrite(dev_t dev, struct uio *uio, int flag)
550ngdwrite(struct cdev *dev, struct uio *uio, int flag)
551{
552 int ret;
553 int error = 0;
554 struct mbuf *m;
555 char buffer[uio->uio_resid];
556 int len = uio->uio_resid;
557 struct ngd_softc *sc =& ngd_softc;
558 struct ngd_connection * connection = NULL;

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

592 return(ret);
593}
594
595/*
596 * we are being polled/selected
597 * check if there is data available for read
598 */
599static int
551{
552 int ret;
553 int error = 0;
554 struct mbuf *m;
555 char buffer[uio->uio_resid];
556 int len = uio->uio_resid;
557 struct ngd_softc *sc =& ngd_softc;
558 struct ngd_connection * connection = NULL;

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

592 return(ret);
593}
594
595/*
596 * we are being polled/selected
597 * check if there is data available for read
598 */
599static int
600ngdpoll(dev_t dev, int events, struct thread *td)
600ngdpoll(struct cdev *dev, int events, struct thread *td)
601{
602 int revents = 0;
603 struct ngd_softc *sc = &ngd_softc;
604 struct ngd_connection * connection = NULL;
605 struct ngd_connection * tmp;
606
607
608 if (events & (POLLIN | POLLRDNORM)) {

--- 18 unchanged lines hidden ---
601{
602 int revents = 0;
603 struct ngd_softc *sc = &ngd_softc;
604 struct ngd_connection * connection = NULL;
605 struct ngd_connection * tmp;
606
607
608 if (events & (POLLIN | POLLRDNORM)) {

--- 18 unchanged lines hidden ---