Index: head/net/rp-pppoe/Makefile =================================================================== --- head/net/rp-pppoe/Makefile (revision 536726) +++ head/net/rp-pppoe/Makefile (revision 536727) @@ -1,97 +1,97 @@ # Created by: Mario Sergio Fujikawa Ferreira # $FreeBSD$ PORTNAME= rp-pppoe -PORTVERSION= 3.13 -PORTREVISION= 1 +PORTVERSION= 3.14 +PORTREVISION= 0 CATEGORIES= net MASTER_SITES= https://dianne.skoll.ca/projects/rp-pppoe/download/ MAINTAINER= mandree@FreeBSD.org COMMENT= Roaring Penguin's PPPoE software LICENSE= GPLv2+ GNU_CONFIGURE= yes PATCH_WRKSRC= ${WRKSRC}/src CONFIGURE_WRKSRC= ${WRKSRC}/src BUILD_WRKSRC= ${WRKSRC}/src man5= pppoe.conf.5 man8= pppoe-connect.8 pppoe-setup.8 pppoe-start.8 pppoe-status.8 \ pppoe-stop.8 pppoe-relay.8 pppoe-server.8 pppoe.8 CONFIG_FILES= firewall-masq firewall-standalone pap-secrets \ pppoe-server-options pppoe.conf DOC_FILES= CHANGES HOW-TO-CONNECT LICENSE PROBLEMS SCRIPT_FILES= pppoe-connect pppoe-init pppoe-setup pppoe-start \ pppoe-status pppoe-stop OPTIONS_DEFINE= DOCS # work around "Present But Cannot Be Compiled" issue in GNU configure: CFLAGS+= -include sys/types.h -include sys/socket.h -include netinet/in.h .include .if ${PORT_OPTIONS:MDOCS} PORTDOCS= * .endif post-patch: @${REINPLACE_CMD} -e "s!/etc/ppp!${PREFIX}/etc/ppp!g" \ ${WRKSRC}/man/* \ ${WRKSRC}/configs/* \ ${WRKSRC}/doc/HOW-TO-CONNECT @${REINPLACE_CMD} -e 's!/etc/ppp!$$(prefix)/etc/ppp!g' \ ${WRKSRC}/src/Makefile.in .for file in pppoe-connect pppoe-setup pppoe-start @${REINPLACE_CMD} -e 's!/etc/ppp!$${prefix}/etc/ppp!g' \ ${WRKSRC}/scripts/${file}.in .endfor @${REINPLACE_CMD} -e 's!pty!tty!g' ${WRKSRC}/scripts/pppoe-connect.in .for f in pppoe-status pppoe-stop.in @${REINPLACE_CMD} -e "s!/etc/ppp!${PREFIX}/etc/ppp!g" \ ${WRKSRC}/scripts/${f} .endfor @${REINPLACE_CMD} -e "s/\$$^/\$$>/g" ${WRKSRC}/src/Makefile.in do-install: # Binaries ${MKDIR} ${STAGEDIR}${PREFIX}/sbin .for f in pppoe pppoe-server pppoe-relay ${INSTALL_PROGRAM} ${BUILD_WRKSRC}/${f} ${STAGEDIR}${PREFIX}/sbin .endfor # Configurations ${MKDIR} ${STAGEDIR}${PREFIX}/etc/ppp .for f in ${CONFIG_FILES} ${INSTALL_DATA} ${WRKSRC}/configs/${f} \ ${STAGEDIR}${PREFIX}/etc/ppp/${f}.sample .endfor # Manual pages ${MKDIR} ${STAGEDIR}${MAN5PREFIX}/man/man5 .for f in ${man5} ${INSTALL_MAN} ${WRKSRC}/man/${f} ${STAGEDIR}${MAN5PREFIX}/man/man5 .endfor ${MKDIR} ${STAGEDIR}${MAN8PREFIX}/man/man8 .for f in ${man8} ${INSTALL_MAN} ${WRKSRC}/man/${f} ${STAGEDIR}${MAN8PREFIX}/man/man8 .endfor # Scripts .for f in ${SCRIPT_FILES} ${INSTALL_SCRIPT} ${WRKSRC}/scripts/${f} ${STAGEDIR}${PREFIX}/sbin .endfor # Startup scripts .for f in 04pppoe-relay.sh.sample 04pppoe-server.sh.sample ${INSTALL_SCRIPT} ${FILESDIR}/${f} ${STAGEDIR}${PREFIX}/etc/rc.d/ .endfor # Documentation post-install-DOCS-on: ${MKDIR} ${STAGEDIR}${DOCSDIR} ${INSTALL_DATA} ${WRKSRC}/doc/* ${STAGEDIR}${DOCSDIR} ${RM} ${STAGEDIR}${DOCSDIR}/KERNEL-MODE-PPPOE # cleanup REINPLACE_CMD prefix hack leftovers: ${RM} ${STAGEDIR}${DOCSDIR}/*.bak .include Index: head/net/rp-pppoe/distinfo =================================================================== --- head/net/rp-pppoe/distinfo (revision 536726) +++ head/net/rp-pppoe/distinfo (revision 536727) @@ -1,3 +1,3 @@ -TIMESTAMP = 1545915011 -SHA256 (rp-pppoe-3.13.tar.gz) = 8cd6bc71ba46bd5f6eb4daf60220ccdcd991a8525111dee466501b1b9717e676 -SIZE (rp-pppoe-3.13.tar.gz) = 224204 +TIMESTAMP = 1590618245 +SHA256 (rp-pppoe-3.14.tar.gz) = 7825232f64ab4d618ef074d62d145ae43d6edc91b9a718c6130a4742bac40e2a +SIZE (rp-pppoe-3.14.tar.gz) = 224688 Index: head/net/rp-pppoe/files/patch-configure =================================================================== --- head/net/rp-pppoe/files/patch-configure (revision 536726) +++ head/net/rp-pppoe/files/patch-configure (revision 536727) @@ -1,11 +1,11 @@ ---- configure.orig 2018-11-25 22:25:28 UTC +--- configure.orig 2020-05-27 00:29:37 UTC +++ configure -@@ -4715,7 +4715,7 @@ eval "WRAPPER=${WRAPPER}" +@@ -4620,7 +4620,7 @@ eval "WRAPPER=${WRAPPER}" # 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 Index: head/net/rp-pppoe/files/patch-if.c =================================================================== --- head/net/rp-pppoe/files/patch-if.c (revision 536726) +++ head/net/rp-pppoe/files/patch-if.c (revision 536727) @@ -1,33 +1,33 @@ ---- if.c.orig 2018-11-25 22:25:28 UTC +--- if.c.orig 2020-05-27 00:29:37 UTC +++ if.c -@@ -276,7 +276,7 @@ initFilter(int fd, UINT16_t type, unsigned char *hwadd +@@ -277,7 +277,7 @@ initFilter(int fd, UINT16_t type, unsigned char *hwadd * traffic on this network. ***********************************************************************/ int -openInterface(char const *ifname, UINT16_t type, unsigned char *hwaddr) +openInterface(char const *ifname, UINT16_t type, unsigned char *hwaddr, UINT16_t *mtu) { static int fd = -1; char bpfName[32]; -@@ -287,7 +287,12 @@ openInterface(char const *ifname, UINT16_t type, unsig +@@ -288,7 +288,12 @@ openInterface(char const *ifname, UINT16_t type, unsig 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; } -@@ -396,6 +401,8 @@ openInterface(char const *ifname, UINT16_t type, unsig +@@ -397,6 +402,8 @@ openInterface(char const *ifname, UINT16_t type, unsig ifname); rp_fatal(buffer); } + + if (mtu) *mtu = ifr.ifr_mtu; syslog(LOG_INFO, "Interface=%.16s HWaddr=%02X:%02X:%02X:%02X:%02X:%02X Device=%.32s Buffer size=%d", ifname, Index: head/net/rp-pppoe/files/patch-pppoe.h =================================================================== --- head/net/rp-pppoe/files/patch-pppoe.h (revision 536726) +++ head/net/rp-pppoe/files/patch-pppoe.h (revision 536727) @@ -1,18 +1,18 @@ ---- pppoe.h.orig 2018-11-25 22:25:28 UTC +--- pppoe.h.orig 2020-05-27 00:29:37 UTC +++ pppoe.h -@@ -65,10 +65,14 @@ extern int IsSetID; +@@ -62,10 +62,14 @@ extern int IsSetID; #include #endif +#ifdef __FreeBSD__ +#include +#include +#endif + #ifdef USE_BPF extern int bpfSize; struct PPPoEPacketStruct; -void sessionDiscoveryPacket(struct PPPoEPacketStruct *packet); #define BPF_BUFFER_IS_EMPTY (bpfSize <= 0) #define BPF_BUFFER_HAS_DATA (bpfSize > 0) #define ethhdr ether_header Index: head/net/rp-pppoe/files/patch-relay.c =================================================================== --- head/net/rp-pppoe/files/patch-relay.c (revision 536726) +++ head/net/rp-pppoe/files/patch-relay.c (revision 536727) @@ -1,181 +1,181 @@ ---- relay.c.orig 2018-11-25 22:25:28 UTC +--- relay.c.orig 2020-05-27 00:29:37 UTC +++ relay.c -@@ -754,6 +754,11 @@ void +@@ -756,6 +756,11 @@ void relayLoop() { fd_set readable, readableCopy; +#if defined(__FreeBSD__) + PPPoEPacket packet; + int size; + int type; +#endif int maxFD; int i, r; int sock; -@@ -783,6 +788,27 @@ relayLoop() +@@ -785,6 +790,27 @@ relayLoop() continue; } +#if defined(__FreeBSD__) + for (i=0; ilength) + 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) { PPPoEPacket packet; -@@ -863,6 +930,7 @@ relayGotDiscoveryPacket(PPPoEInterface const *iface) +@@ -865,6 +932,7 @@ relayGotDiscoveryPacket(PPPoEInterface const *iface) iface->name, (int) packet.code); } } +#endif /********************************************************************** *%FUNCTION: relayGotSessionPacket -@@ -873,7 +941,66 @@ relayGotDiscoveryPacket(PPPoEInterface const *iface) +@@ -875,7 +943,66 @@ relayGotDiscoveryPacket(PPPoEInterface const *iface) *%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) { PPPoEPacket packet; -@@ -939,6 +1066,7 @@ relayGotSessionPacket(PPPoEInterface const *iface) +@@ -941,6 +1068,7 @@ relayGotSessionPacket(PPPoEInterface const *iface) #endif sendPacket(NULL, sh->interface->sessionSock, &packet, size); } +#endif /********************************************************************** *%FUNCTION: relayHandlePADT Index: head/net/rp-pppoe/files/patch-relay.h =================================================================== --- head/net/rp-pppoe/files/patch-relay.h (revision 536726) +++ head/net/rp-pppoe/files/patch-relay.h (revision 536727) @@ -1,16 +1,16 @@ ---- relay.h.orig 2018-11-25 22:25:28 UTC +--- relay.h.orig 2020-05-27 00:29:37 UTC +++ relay.h -@@ -51,8 +51,13 @@ typedef struct SessionHashStruct { +@@ -52,8 +52,13 @@ typedef struct SessionHashStruct { /* 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);