diff options
author | krion <krion@FreeBSD.org> | 2004-08-02 00:31:10 +0800 |
---|---|---|
committer | krion <krion@FreeBSD.org> | 2004-08-02 00:31:10 +0800 |
commit | 4cb847c3f9a6cb73d37ed5fdd76abb9d9fd72a36 (patch) | |
tree | c5e1e068852e6f3e8bb301c137be7a9015ff5deb /net | |
parent | 2dfd7a4d6c2e49d07c5cf0a439fa0ab335d58206 (diff) | |
download | freebsd-ports-gnome-4cb847c3f9a6cb73d37ed5fdd76abb9d9fd72a36.tar.gz freebsd-ports-gnome-4cb847c3f9a6cb73d37ed5fdd76abb9d9fd72a36.tar.zst freebsd-ports-gnome-4cb847c3f9a6cb73d37ed5fdd76abb9d9fd72a36.zip |
Enable pppoe-relay
PR: ports/69868
Submitted by: maintainer
Diffstat (limited to 'net')
-rw-r--r-- | net/rp-pppoe/Makefile | 13 | ||||
-rw-r--r-- | net/rp-pppoe/files/04pppoe-relay.sh.sample | 30 | ||||
-rw-r--r-- | net/rp-pppoe/files/04pppoe-server.sh.sample | 31 | ||||
-rw-r--r-- | net/rp-pppoe/files/patch-ab | 11 | ||||
-rw-r--r-- | net/rp-pppoe/files/patch-ac | 15 | ||||
-rw-r--r-- | net/rp-pppoe/files/patch-ad | 179 | ||||
-rw-r--r-- | net/rp-pppoe/files/patch-ae | 16 | ||||
-rw-r--r-- | net/rp-pppoe/pkg-message | 4 | ||||
-rw-r--r-- | net/rp-pppoe/pkg-plist | 5 |
9 files changed, 298 insertions, 6 deletions
diff --git a/net/rp-pppoe/Makefile b/net/rp-pppoe/Makefile index f9d6b096b1c7..20e9d24408c7 100644 --- a/net/rp-pppoe/Makefile +++ b/net/rp-pppoe/Makefile @@ -7,6 +7,7 @@ PORTNAME= rp-pppoe PORTVERSION= 3.5 +PORTREVISION= 1 CATEGORIES= net MASTER_SITES= http://www.roaringpenguin.com/penguin/pppoe/ @@ -15,6 +16,7 @@ COMMENT= "The popular Roaring Penguin's PPPoE software" USE_REINPLACE= yes GNU_CONFIGURE= yes +PATCH_WRKSRC= ${WRKSRC}/src CONFIGURE_WRKSRC= ${WRKSRC}/src BUILD_WRKSRC= ${WRKSRC}/src @@ -50,7 +52,7 @@ post-patch: do-install: # Binaries -.for f in pppoe pppoe-server +.for f in pppoe pppoe-server pppoe-relay @${INSTALL_PROGRAM} ${BUILD_WRKSRC}/${f} ${PREFIX}/sbin .endfor # Configurations @@ -59,10 +61,6 @@ do-install: @${INSTALL_DATA} ${WRKSRC}/configs/${f} \ ${PREFIX}/etc/ppp/${f}.sample .endfor -.if !exists(${PREFIX}/etc/ppp/pppoe.conf) - ${INSTALL_SCRIPT} ${PREFIX}/etc/ppp/pppoe.conf.sample \ - ${PREFIX}/etc/ppp/pppoe.conf -.endif # Manual pages @${MKDIR} ${MAN5PREFIX}/man/man5 .for f in ${MAN5} @@ -76,6 +74,11 @@ do-install: .for f in ${SCRIPT_FILES} @${INSTALL_SCRIPT} ${WRKSRC}/scripts/${f} ${PREFIX}/sbin .endfor +# Startup scripts +.for f in 04pppoe-relay.sh.sample 04pppoe-server.sh.sample + @${INSTALL_SCRIPT} ${FILESDIR}/${f} ${PREFIX}/etc/rc.d/ +.endfor + # Documentation .ifndef (NOPORTDOCS) @${MKDIR} ${DOCSDIR} diff --git a/net/rp-pppoe/files/04pppoe-relay.sh.sample b/net/rp-pppoe/files/04pppoe-relay.sh.sample new file mode 100644 index 000000000000..1915d5c7b578 --- /dev/null +++ b/net/rp-pppoe/files/04pppoe-relay.sh.sample @@ -0,0 +1,30 @@ +#! /bin/sh + +# use a subshell to support new -CURRENT rc.d structure +( +daemon=pppoe-relay +daemon_path=/usr/local/sbin +daemon_flags= + +case $1 in + start) + if [ -x ${daemon_path}/$daemon ]; then + ${daemon_path}/$daemon $daemon_flags + echo -n " $daemon" + fi + ;; + stop) + killall $daemon && echo -n " $daemon" + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + *) + echo "Usage: `basename $0` {start|stop|restart}" >&2 + exit 64 + ;; +esac +exit 0 +) diff --git a/net/rp-pppoe/files/04pppoe-server.sh.sample b/net/rp-pppoe/files/04pppoe-server.sh.sample new file mode 100644 index 000000000000..6195e84b9d8c --- /dev/null +++ b/net/rp-pppoe/files/04pppoe-server.sh.sample @@ -0,0 +1,31 @@ +#! /bin/sh + +# use a subshell to support new -CURRENT rc.d structure +( +daemon=pppoe-server +daemon_path=/usr/local/sbin +daemon_flags= + +case $1 in + start) + if [ -x ${daemon_path}/$daemon ]; then + ${daemon_path}/$daemon $daemon_flags + echo -n " $daemon" + fi + ;; + stop) + killall $daemon && echo -n " $daemon" + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + *) + echo "Usage: `basename $0` {start|stop|restart}" >&2 + exit 64 + ;; +esac + +exit 0 +) diff --git a/net/rp-pppoe/files/patch-ab b/net/rp-pppoe/files/patch-ab new file mode 100644 index 000000000000..e5185a1c211b --- /dev/null +++ b/net/rp-pppoe/files/patch-ab @@ -0,0 +1,11 @@ +--- configure.orig Mon Jul 8 20:38:24 2002 ++++ configure Wed Mar 10 15:50:51 2004 +@@ -2083,7 +2083,7 @@ + + + # Determine what targets to build +-TARGETS="pppoe pppoe-server" ++TARGETS="pppoe pppoe-server pppoe-relay" + + # pppoe-sniff is built only on Linux and Solaris + if test "$ac_cv_header_linux_if_packet_h" = "yes" -o "$ac_cv_header_sys_dlpi_h" = "yes" ; then diff --git a/net/rp-pppoe/files/patch-ac b/net/rp-pppoe/files/patch-ac new file mode 100644 index 000000000000..0203a0b745dc --- /dev/null +++ b/net/rp-pppoe/files/patch-ac @@ -0,0 +1,15 @@ +--- if.c.orig Mon Jul 8 20:38:24 2002 ++++ if.c Wed Mar 10 15:47:26 2004 +@@ -285,7 +285,12 @@ + int i; + + /* BSD only opens one socket for both Discovery and Session packets */ ++#if defined(__FreeBSD__) ++ /* Confirmed for FreeBSD 4.8-R [SeaD] */ ++ if (!hwaddr) { ++#else + if (fd >= 0) { ++#endif + return fd; + } + diff --git a/net/rp-pppoe/files/patch-ad b/net/rp-pppoe/files/patch-ad new file mode 100644 index 000000000000..5bab53ed4e0d --- /dev/null +++ b/net/rp-pppoe/files/patch-ad @@ -0,0 +1,179 @@ +--- relay.c.orig Mon Jul 8 20:38:24 2002 ++++ relay.c Wed Mar 10 16:29:40 2004 +@@ -743,6 +743,11 @@ + relayLoop() + { + fd_set readable, readableCopy; ++#if defined(__FreeBSD__) ++ PPPoEPacket packet; ++ int size; ++ int type; ++#endif + int maxFD; + int i, r; + int sock; +@@ -772,6 +777,27 @@ + continue; + } + ++#if defined(__FreeBSD__) ++ for (i=0; i<NumInterfaces; i++) { ++ /* Because FreeBSD use one interface for both Discovery and ++ Session types we use first socket for packet receiving [SeaD] */ ++ if (!FD_ISSET(Interfaces[i].discoverySock, &readableCopy)) ++ continue; ++ if (receivePacket(Interfaces[i].discoverySock, &packet, &size) < 0) ++ continue; ++ ++ /* Ignore unknown code/version */ ++ if (packet.ver != 1 || packet.type != 1) ++ continue; ++ ++ type = etherType(&packet); ++ if (type == Eth_PPPOE_Discovery) { ++ relayGotDiscoveryPacket(&Interfaces[i], &packet, size); ++ } else if (type == Eth_PPPOE_Session) { ++ relayGotSessionPacket(&Interfaces[i], &packet, size); ++ } ++ } ++#else + /* Handle session packets first */ + for (i=0; i<NumInterfaces; i++) { + if (FD_ISSET(Interfaces[i].sessionSock, &readableCopy)) { +@@ -786,6 +812,7 @@ + } + } + ++#endif + /* Handle the session-cleaning process */ + if (FD_ISSET(CleanPipe[0], &readableCopy)) { + char dummy; +@@ -805,6 +832,46 @@ + *%DESCRIPTION: + * Receives and processes a discovery packet. + ***********************************************************************/ ++#if defined(__FreeBSD__) ++void ++relayGotDiscoveryPacket(PPPoEInterface const *iface, ++ PPPoEPacket *packet, ++ int size) ++{ ++ ++ if (ntohs(packet->length) + HDR_SIZE > size) { ++ syslog(LOG_ERR, "Bogus PPPoE length field (%u)", ++ (unsigned int) ntohs(packet->length)); ++ return; ++ } ++ ++ /* Drop Ethernet frame padding */ ++ if (size > ntohs(packet->length) + HDR_SIZE) { ++ size = ntohs(packet->length) + HDR_SIZE; ++ } ++ ++ switch(packet->code) { ++ case CODE_PADT: ++ relayHandlePADT(iface, packet, size); ++ break; ++ case CODE_PADI: ++ relayHandlePADI(iface, packet, size); ++ break; ++ case CODE_PADO: ++ relayHandlePADO(iface, packet, size); ++ break; ++ case CODE_PADR: ++ relayHandlePADR(iface, packet, size); ++ break; ++ case CODE_PADS: ++ relayHandlePADS(iface, packet, size); ++ break; ++ default: ++ syslog(LOG_ERR, "Discovery packet on %s with unknown code %d", ++ iface->name, (int) packet->code); ++ } ++} ++#else + void + relayGotDiscoveryPacket(PPPoEInterface const *iface) + { +@@ -852,6 +919,7 @@ + iface->name, (int) packet.code); + } + } ++#endif + + /********************************************************************** + *%FUNCTION: relayGotSessionPacket +@@ -862,6 +930,65 @@ + *%DESCRIPTION: + * Receives and processes a session packet. + ***********************************************************************/ ++#if defined(__FreeBSD__) ++void ++relayGotSessionPacket(PPPoEInterface const *iface, ++ PPPoEPacket *packet, ++ int size) ++{ ++ SessionHash *sh; ++ PPPoESession *ses; ++ ++ /* Must be a session packet */ ++ if (packet->code != CODE_SESS) { ++ syslog(LOG_ERR, "Session packet with code %d", (int) packet->code); ++ return; ++ } ++ ++ /* Ignore session packets whose destination address isn't ours */ ++ if (memcmp(packet->ethHdr.h_dest, iface->mac, ETH_ALEN)) { ++ return; ++ } ++ ++ /* Validate length */ ++ if (ntohs(packet->length) + HDR_SIZE > size) { ++ syslog(LOG_ERR, "Bogus PPPoE length field (%u)", ++ (unsigned int) ntohs(packet->length)); ++ return; ++ } ++ ++ /* Drop Ethernet frame padding */ ++ if (size > ntohs(packet->length) + HDR_SIZE) { ++ size = ntohs(packet->length) + HDR_SIZE; ++ } ++ ++ /* We're in business! Find the hash */ ++ sh = findSession(packet->ethHdr.h_source, packet->session); ++ if (!sh) { ++ /* Don't log this. Someone could be running the client and the ++ relay on the same box. */ ++ return; ++ } ++ ++ /* Relay it */ ++ ses = sh->ses; ++ ses->epoch = Epoch; ++ sh = sh->peer; ++ packet->session = sh->sesNum; ++ memcpy(packet->ethHdr.h_source, sh->interface->mac, ETH_ALEN); ++ memcpy(packet->ethHdr.h_dest, sh->peerMac, ETH_ALEN); ++#if 0 ++ fprintf(stderr, "Relaying %02x:%02x:%02x:%02x:%02x:%02x(%s:%d) to %02x:%02x:%02x:%02x:%02x:%02x(%s:%d)\n", ++ sh->peer->peerMac[0], sh->peer->peerMac[1], sh->peer->peerMac[2], ++ sh->peer->peerMac[3], sh->peer->peerMac[4], sh->peer->peerMac[5], ++ sh->peer->interface->name, ntohs(sh->peer->sesNum), ++ sh->peerMac[0], sh->peerMac[1], sh->peerMac[2], ++ sh->peerMac[3], sh->peerMac[4], sh->peerMac[5], ++ sh->interface->name, ntohs(sh->sesNum)); ++#endif ++ sendPacket(NULL, sh->interface->sessionSock, packet, size); ++} ++#else + void + relayGotSessionPacket(PPPoEInterface const *iface) + { +@@ -928,6 +1055,7 @@ + #endif + sendPacket(NULL, sh->interface->sessionSock, &packet, size); + } ++#endif + + /********************************************************************** + *%FUNCTION: relayHandlePADT diff --git a/net/rp-pppoe/files/patch-ae b/net/rp-pppoe/files/patch-ae new file mode 100644 index 000000000000..10ecb35213df --- /dev/null +++ b/net/rp-pppoe/files/patch-ae @@ -0,0 +1,16 @@ +--- relay.h.orig Mon Jul 8 20:38:24 2002 ++++ relay.h Wed Mar 10 15:50:51 2004 +@@ -51,8 +51,13 @@ + + /* Function prototypes */ + ++#if defined(__FreeBSD__) ++void relayGotSessionPacket(PPPoEInterface const *iface, PPPoEPacket *packet, int size); ++void relayGotDiscoveryPacket(PPPoEInterface const *iface, PPPoEPacket *packet, int size); ++#else + void relayGotSessionPacket(PPPoEInterface const *i); + void relayGotDiscoveryPacket(PPPoEInterface const *i); ++#endif + PPPoEInterface *findInterface(int sock); + unsigned int hash(unsigned char const *mac, UINT16_t sesNum); + SessionHash *findSession(unsigned char const *mac, UINT16_t sesNum); diff --git a/net/rp-pppoe/pkg-message b/net/rp-pppoe/pkg-message new file mode 100644 index 000000000000..cde1a1b25cb6 --- /dev/null +++ b/net/rp-pppoe/pkg-message @@ -0,0 +1,4 @@ +Note that many of the script this port installs haven't been tested in +a long time and the components tested are pppoe and pppoe-relay for the +major part. Use the adsl-* configuration scripts at your own risk. +Feedback about success and failure to the port maintainer is appreciated though. diff --git a/net/rp-pppoe/pkg-plist b/net/rp-pppoe/pkg-plist index d127ac2a78ad..2119af2c4bb2 100644 --- a/net/rp-pppoe/pkg-plist +++ b/net/rp-pppoe/pkg-plist @@ -5,11 +5,14 @@ sbin/adsl-start sbin/adsl-status sbin/adsl-stop sbin/pppoe +sbin/pppoe-relay sbin/pppoe-server etc/ppp/firewall-masq.sample etc/ppp/firewall-standalone.sample etc/ppp/pap-secrets.sample etc/ppp/pppoe-server-options.sample -@unexec if cmp -s %D/etc/ppp/pppoe.conf.sample %D/etc/ppp/pppoe.conf ; then rm %D/etc/ppp/pppoe.conf ; fi +@unexec for i in ppp/pppoe.conf rc.d/04pppoe-server.sh rc.d/04pppoe-relay.sh ; do if cmp -s %D/etc/$i.sample %D/etc/$i ; then rm %D/etc/$i ; fi ; done etc/ppp/pppoe.conf.sample +etc/rc.d/04pppoe-server.sh.sample +etc/rc.d/04pppoe-relay.sh.sample @unexec rmdir %D/etc/ppp 2>/dev/null || echo "If you are permanently removing pppoe, you should also ``rm -Rf ${PKG_PREFIX}/etc/ppp'' removing any configuration and password files left." | /usr/bin/fmt |