mirror of
https://git.freebsd.org/ports.git
synced 2025-07-18 01:39:16 -04:00
Enable pppoe-relay
PR: ports/69868 Submitted by: maintainer
This commit is contained in:
parent
e90cae0339
commit
b88d4fa6e7
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=115208
9 changed files with 298 additions and 6 deletions
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
PORTNAME= rp-pppoe
|
PORTNAME= rp-pppoe
|
||||||
PORTVERSION= 3.5
|
PORTVERSION= 3.5
|
||||||
|
PORTREVISION= 1
|
||||||
CATEGORIES= net
|
CATEGORIES= net
|
||||||
MASTER_SITES= http://www.roaringpenguin.com/penguin/pppoe/
|
MASTER_SITES= http://www.roaringpenguin.com/penguin/pppoe/
|
||||||
|
|
||||||
|
@ -15,6 +16,7 @@ COMMENT= "The popular Roaring Penguin's PPPoE software"
|
||||||
|
|
||||||
USE_REINPLACE= yes
|
USE_REINPLACE= yes
|
||||||
GNU_CONFIGURE= yes
|
GNU_CONFIGURE= yes
|
||||||
|
PATCH_WRKSRC= ${WRKSRC}/src
|
||||||
CONFIGURE_WRKSRC= ${WRKSRC}/src
|
CONFIGURE_WRKSRC= ${WRKSRC}/src
|
||||||
BUILD_WRKSRC= ${WRKSRC}/src
|
BUILD_WRKSRC= ${WRKSRC}/src
|
||||||
|
|
||||||
|
@ -50,7 +52,7 @@ post-patch:
|
||||||
|
|
||||||
do-install:
|
do-install:
|
||||||
# Binaries
|
# Binaries
|
||||||
.for f in pppoe pppoe-server
|
.for f in pppoe pppoe-server pppoe-relay
|
||||||
@${INSTALL_PROGRAM} ${BUILD_WRKSRC}/${f} ${PREFIX}/sbin
|
@${INSTALL_PROGRAM} ${BUILD_WRKSRC}/${f} ${PREFIX}/sbin
|
||||||
.endfor
|
.endfor
|
||||||
# Configurations
|
# Configurations
|
||||||
|
@ -59,10 +61,6 @@ do-install:
|
||||||
@${INSTALL_DATA} ${WRKSRC}/configs/${f} \
|
@${INSTALL_DATA} ${WRKSRC}/configs/${f} \
|
||||||
${PREFIX}/etc/ppp/${f}.sample
|
${PREFIX}/etc/ppp/${f}.sample
|
||||||
.endfor
|
.endfor
|
||||||
.if !exists(${PREFIX}/etc/ppp/pppoe.conf)
|
|
||||||
${INSTALL_SCRIPT} ${PREFIX}/etc/ppp/pppoe.conf.sample \
|
|
||||||
${PREFIX}/etc/ppp/pppoe.conf
|
|
||||||
.endif
|
|
||||||
# Manual pages
|
# Manual pages
|
||||||
@${MKDIR} ${MAN5PREFIX}/man/man5
|
@${MKDIR} ${MAN5PREFIX}/man/man5
|
||||||
.for f in ${MAN5}
|
.for f in ${MAN5}
|
||||||
|
@ -76,6 +74,11 @@ do-install:
|
||||||
.for f in ${SCRIPT_FILES}
|
.for f in ${SCRIPT_FILES}
|
||||||
@${INSTALL_SCRIPT} ${WRKSRC}/scripts/${f} ${PREFIX}/sbin
|
@${INSTALL_SCRIPT} ${WRKSRC}/scripts/${f} ${PREFIX}/sbin
|
||||||
.endfor
|
.endfor
|
||||||
|
# Startup scripts
|
||||||
|
.for f in 04pppoe-relay.sh.sample 04pppoe-server.sh.sample
|
||||||
|
@${INSTALL_SCRIPT} ${FILESDIR}/${f} ${PREFIX}/etc/rc.d/
|
||||||
|
.endfor
|
||||||
|
|
||||||
# Documentation
|
# Documentation
|
||||||
.ifndef (NOPORTDOCS)
|
.ifndef (NOPORTDOCS)
|
||||||
@${MKDIR} ${DOCSDIR}
|
@${MKDIR} ${DOCSDIR}
|
||||||
|
|
30
net/rp-pppoe/files/04pppoe-relay.sh.sample
Normal file
30
net/rp-pppoe/files/04pppoe-relay.sh.sample
Normal file
|
@ -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
|
||||||
|
)
|
31
net/rp-pppoe/files/04pppoe-server.sh.sample
Normal file
31
net/rp-pppoe/files/04pppoe-server.sh.sample
Normal file
|
@ -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
|
||||||
|
)
|
11
net/rp-pppoe/files/patch-ab
Normal file
11
net/rp-pppoe/files/patch-ab
Normal file
|
@ -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
|
15
net/rp-pppoe/files/patch-ac
Normal file
15
net/rp-pppoe/files/patch-ac
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
|
179
net/rp-pppoe/files/patch-ad
Normal file
179
net/rp-pppoe/files/patch-ad
Normal file
|
@ -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
|
16
net/rp-pppoe/files/patch-ae
Normal file
16
net/rp-pppoe/files/patch-ae
Normal file
|
@ -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);
|
4
net/rp-pppoe/pkg-message
Normal file
4
net/rp-pppoe/pkg-message
Normal file
|
@ -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.
|
|
@ -5,11 +5,14 @@ sbin/adsl-start
|
||||||
sbin/adsl-status
|
sbin/adsl-status
|
||||||
sbin/adsl-stop
|
sbin/adsl-stop
|
||||||
sbin/pppoe
|
sbin/pppoe
|
||||||
|
sbin/pppoe-relay
|
||||||
sbin/pppoe-server
|
sbin/pppoe-server
|
||||||
etc/ppp/firewall-masq.sample
|
etc/ppp/firewall-masq.sample
|
||||||
etc/ppp/firewall-standalone.sample
|
etc/ppp/firewall-standalone.sample
|
||||||
etc/ppp/pap-secrets.sample
|
etc/ppp/pap-secrets.sample
|
||||||
etc/ppp/pppoe-server-options.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/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
|
@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
|
||||||
|
|
Loading…
Add table
Reference in a new issue