diff options
author | nork <nork@FreeBSD.org> | 2006-04-08 14:34:33 +0800 |
---|---|---|
committer | nork <nork@FreeBSD.org> | 2006-04-08 14:34:33 +0800 |
commit | aefffb90af22cd00b476eb0cd5927cb7d413bd1e (patch) | |
tree | f315d073e3e15b2f6b6a0a65b9f94f6e5038c31c /net-mgmt/choparp/files | |
parent | c23b7200483c88cbbeb89e3662520832b072b814 (diff) | |
download | freebsd-ports-gnome-aefffb90af22cd00b476eb0cd5927cb7d413bd1e.tar.gz freebsd-ports-gnome-aefffb90af22cd00b476eb0cd5927cb7d413bd1e.tar.zst freebsd-ports-gnome-aefffb90af22cd00b476eb0cd5927cb7d413bd1e.zip |
Improved choparp.
o Add rcNG script.
o Use kqueue(2)/kevent(2) instead of select(2).
o Change MAINTAINER to myself.
o Bump PORTREVISION, accordingly.
Diffstat (limited to 'net-mgmt/choparp/files')
-rw-r--r-- | net-mgmt/choparp/files/choparp.sh.in | 34 | ||||
-rw-r--r-- | net-mgmt/choparp/files/patch-choparp.c | 59 |
2 files changed, 90 insertions, 3 deletions
diff --git a/net-mgmt/choparp/files/choparp.sh.in b/net-mgmt/choparp/files/choparp.sh.in new file mode 100644 index 000000000000..a093fead391e --- /dev/null +++ b/net-mgmt/choparp/files/choparp.sh.in @@ -0,0 +1,34 @@ +#!/bin/sh +# +# $FreeBSD$ +# +# PROVIDE: choparp +# REQUIRE: LOGIN +# +choparp_enable=${choparp_enable-"NO"} +choparp_iface=${choparp_iface-} +choparp_macaddr=${choparp_macaddr-"auto"} +choparp_network=${choparp_interface-} + +. %%RC_SUBR%% + +name="choparp" +rcvar=`set_rcvar` +start_precmd="choparp_precmd" +restart_precmd="choparp_precmd" + +load_rc_config ${name} + +choparp_precmd () { + if [ -z "${choparp_iface}" \ + -o -z "${choparp_macaddr}" \ + -o -z "${choparp_network}" ]; then + warn "set choparp_iface, choparp_macaddr and choparp_network." + return 1 + fi +} + +command="%%PREFIX%%/sbin/${name}" +command_args="${choparp_iface} ${choparp_macaddr} ${choparp_network}" + +run_rc_command "$1" diff --git a/net-mgmt/choparp/files/patch-choparp.c b/net-mgmt/choparp/files/patch-choparp.c index 7032650e038b..76c197045fbd 100644 --- a/net-mgmt/choparp/files/patch-choparp.c +++ b/net-mgmt/choparp/files/patch-choparp.c @@ -1,6 +1,59 @@ ---- choparp.c.orig Fri Feb 13 20:27:14 2004 -+++ choparp.c Fri Feb 13 20:27:51 2004 -@@ -437,6 +437,9 @@ +--- choparp.c.orig Fri Nov 8 07:36:03 2002 ++++ choparp.c Sat Apr 8 14:37:41 2006 +@@ -42,6 +42,7 @@ + #include <string.h> + #include <sys/types.h> + #include <fcntl.h> ++#include <sys/event.h> + #include <sys/time.h> + #include <sys/ioctl.h> + #include <net/bpf.h> +@@ -280,13 +281,22 @@ + char *rframe; + char *sframe; + size_t frame_len; +- fd_set fdset; ++ int kq; ++ struct kevent kev; + +- FD_ZERO(&fdset); +- FD_SET(fd,&fdset); ++ if ((kq = kqueue()) < 0) { ++ perror("kqueue"); ++ return; ++ } ++ ++ EV_SET(&kev, fd, EVFILT_READ, EV_ADD, 0, 0, NULL); ++ if (kevent(kq, &kev, 1, NULL, 0, NULL) < 0 ) { ++ perror("kevent"); ++ return; ++ } + + for(;;){ +- int r = select(fd+1,&fdset, 0, 0, 0); ++ int r = kevent(kq, NULL, 0, &kev, 1, NULL); + + if (r < 0) { + if (errno == EINTR) +@@ -295,7 +305,7 @@ + return; + } + +- rlen = read(fd, buf, buflen); ++ rlen = read(kev.ident, buf, buflen); + if (rlen < 0) { + if (errno == EINTR) + continue; +@@ -307,7 +317,7 @@ + while((rframe = getarp(p, rlen, &nextp, &nextlen)) != NULL){ + if (checkarp(rframe)){ + sframe = gen_arpreply(rframe, &frame_len); +- write(fd, sframe, frame_len); ++ write(kev.ident, sframe, frame_len); + } + p = nextp; + rlen = nextlen; +@@ -437,6 +447,9 @@ #endif if ((fd = openbpf(ifname, &buf, &buflen)) < 0) return(-1); |