diff options
author | Norikatsu Shigemura <nork@FreeBSD.org> | 2006-04-08 06:34:33 +0000 |
---|---|---|
committer | Norikatsu Shigemura <nork@FreeBSD.org> | 2006-04-08 06:34:33 +0000 |
commit | 649bf0e9bff7af6da3540968d8cd5cae888c6def (patch) | |
tree | 9a9aabc66a72d1067b72c0a726aeb26b47daffe4 /net-mgmt/choparp | |
parent | * Chase the opal library name changes (diff) |
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.
Notes
Notes:
svn path=/head/; revision=159103
Diffstat (limited to 'net-mgmt/choparp')
-rw-r--r-- | net-mgmt/choparp/Makefile | 6 | ||||
-rw-r--r-- | net-mgmt/choparp/files/choparp.sh.in | 34 | ||||
-rw-r--r-- | net-mgmt/choparp/files/patch-choparp.c | 59 |
3 files changed, 95 insertions, 4 deletions
diff --git a/net-mgmt/choparp/Makefile b/net-mgmt/choparp/Makefile index cc0c2d4daf04..493535244db6 100644 --- a/net-mgmt/choparp/Makefile +++ b/net-mgmt/choparp/Makefile @@ -7,13 +7,17 @@ PORTNAME= choparp PORTVERSION= 20021107 +PORTREVISION= 1 CATEGORIES= net-mgmt MASTER_SITES= ${MASTER_SITE_SOURCEFORGE} MASTER_SITE_SUBDIR= choparp -MAINTAINER= ports@FreeBSD.org +MAINTAINER= nork@FreeBSD.org COMMENT= Simple proxy arp daemon +USE_RC_SUBR= choparp.sh + +MANCOMPRESSED= yes MAN8= choparp.8 PLIST_FILES= sbin/choparp 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); |