diff options
author | darrenr <darrenr@FreeBSD.org> | 1997-02-09 22:50:16 +0000 |
---|---|---|
committer | darrenr <darrenr@FreeBSD.org> | 1997-02-09 22:50:16 +0000 |
commit | cb8d46a179f2d30ac1cd0a01eb156e1a4c08d717 (patch) | |
tree | 93c7db298b1fd70f9e27663b3fd527da063d0008 /contrib/ipfilter/ipl_ldev.c | |
download | FreeBSD-src-cb8d46a179f2d30ac1cd0a01eb156e1a4c08d717.zip FreeBSD-src-cb8d46a179f2d30ac1cd0a01eb156e1a4c08d717.tar.gz |
Import IP Filter v3.1.7 into FreeBSD tree
Diffstat (limited to 'contrib/ipfilter/ipl_ldev.c')
-rw-r--r-- | contrib/ipfilter/ipl_ldev.c | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/contrib/ipfilter/ipl_ldev.c b/contrib/ipfilter/ipl_ldev.c new file mode 100644 index 0000000..a289325 --- /dev/null +++ b/contrib/ipfilter/ipl_ldev.c @@ -0,0 +1,83 @@ +/* + * (C)opyright 1993,1994,1995 by Darren Reed. + * + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and due credit is given + * to the original author and the contributors. + */ + +/* + * routines below for saving IP headers to buffer + */ +int iplopen(struct inode * inode, struct file * filp) +{ + u_int min = MINOR(inode->i_rdev); + + if (flags & FWRITE) + return ENXIO; + if (min) + return ENXIO; + iplbusy++; + return 0; +} + + +int iplclose(struct inode * inode, struct file * filp) +{ + u_int min = MINOR(inode->i_rdev); + + if (min) + return ENXIO; + iplbusy--; + return 0; +} + + +/* + * iplread/ipllog + * all three of these must operate with at least splnet() lest they be + * called during packet processing and cause an inconsistancy to appear in + * the filter lists. + */ +int iplread(struct inode *inode, struct file *file, char *buf, int count) +{ + register int ret, s; + register size_t sz, sx; + int error; + + if (!uio->uio_resid) + return 0; + while (!iplused) { + error = SLEEP(iplbuf, "ipl sleep"); + if (error) + return error; + } + + SPLNET(s); + + ret = sx = sz = MIN(count, iplused); + if (iplh < iplt) + sz = MIN(sz, LOGSIZE - (iplt - iplbuf)); + sx -= sz; + + memcpy_tofs(buf, iplt, sz); + buf += sz; + iplt += sz; + iplused -= sz; + if ((iplh < iplt) && (iplt == iplbuf + LOGSIZE)) + iplt = iplbuf; + + if (sx) { + memcpy_tofs(buf, iplt, sx); + ret += sx; + iplt += sx; + iplused -= sx; + if ((iplh < iplt) && (iplt == iplbuf + LOGSIZE)) + iplt = iplbuf; + } + if (!iplused) /* minimise wrapping around the end */ + iplh = iplt = iplbuf; + + SPLX(s); + return ret; +} |