Since v7 dualserver doesn't work well with FreeBSD,

the patch must be reworked but this is a time consuming task.
In the meanwhile, I chose to revert updates and go back to the
last working version.

PR:		ports/193556
Submitted by:	rodrigo
Approved by:	bapt (mentor)
This commit is contained in:
Rodrigo Osorio 2014-09-12 08:10:10 +00:00
parent 3d9938df7f
commit 247f046d59
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=368011
4 changed files with 81 additions and 61 deletions

View File

@ -2,15 +2,17 @@
# $FreeBSD$
PORTNAME= dualserver
PORTVERSION= 7.02
PORTVERSION= 6.94
PORTEPOCH= 1
CATEGORIES= dns net
MASTER_SITES= SF/dhcp-dns-server/Dual%20DHCP%20DNS%20Server/ \
http://rodrigo.osorio.free.fr/freebsd/distfiles/
MASTER_SITES= http://rodrigo.osorio.free.fr/freebsd/distfiles/
DISTNAME= ${PORTNAME}V${PORTVERSION}
MAINTAINER= rodrigo@FreeBSD.org
COMMENT= Combined DHCP/DNS server for small LANs
LICENSE= GPLv2
USES= dos2unix
USE_RC_SUBR= dualserver
PLIST_FILES= sbin/dualserver etc/dualserver.conf.sample

View File

@ -1,2 +1,2 @@
SHA256 (dualserverV7.02.tar.gz) = 9d828a7d72810ed2a42a4949413fa3ac60c753e58b4d0569327cad3b7bf1e716
SIZE (dualserverV7.02.tar.gz) = 138876
SHA256 (dualserverV6.94.tar.gz) = 3007e6508eb95d06f3c8764951ff6d3276733409e2119f6299c9485060b9445c
SIZE (dualserverV6.94.tar.gz) = 796893

View File

@ -1,5 +1,5 @@
--- dualserverd.cpp 2013-05-12 01:36:36.000000000 +0200
+++ dualserverd.cpp 2013-05-18 16:54:53.000000000 +0200
--- dualserverd.cpp 2012-11-09 17:02:36.000000000 +0100
+++ dualserverd.cpp 2012-11-12 13:17:25.000000000 +0100
@@ -22,10 +22,16 @@
#include <math.h>
#include <sys/types.h>
@ -27,80 +27,91 @@
using namespace std;
#include "dualserverd.h"
@@ -88,7 +97,11 @@
const char send403[] = "HTTP/1.1 403 Forbidden\r\n\r\n<h1>403 Forbidden</h1>";
const char send404[] = "HTTP/1.1 404 Not Found\r\n\r\n<h1>404 Not Found</h1>";
const char td200[] = "<td>%s</td>";
@@ -84,7 +93,11 @@
const char send200[] = "HTTP/1.1 200 OK\r\nDate: %s\r\nLast-Modified: %s\r\nContent-Type: text/html\r\nConnection: Close\r\nContent-Length: \r\n\r\n";
//const char send200[] = "HTTP/1.1 200 OK\r\nDate: %s\r\nLast-Modified: %s\r\nContent-Type: text/html\r\nConnection: Close\r\nTransfer-Encoding: chunked\r\n";
const char line200[] = "<td>%s</td>";
+#ifdef __FreeBSD__
+const char sVersion[] = "Dual DHCP DNS Server Version 7.02 for FreeBSD Build 7019";
+const char sVersion[] = "Dual DHCP DNS Server Version 6.94 for FreeBSD";
+#else
const char sVersion[] = "Dual DHCP DNS Server Version 7.02 Linux Build 7019";
const char sVersion[] = "Dual DHCP DNS Server Version 6.94 Linux Build 7011";
+#endif
//const char toprow[] = "<body bgcolor=\"#cccccc\"><table width=\"800\"><tr><td align=\"center\"><font size=\"5\"><b>%s</b></font></b></b></td></tr><tr><td align=\"right\"><a target=\"_new\" href=\"http://dhcp-dns-server.sourceforge.net/\">http://dhcp-dns-server.sourceforge.net/</b></b></td></tr></table>";
const char toprow[] = "<body bgcolor=\"#cccccc\"><table width=640><tr><td align=\"center\"><font size=\"5\"><b>%s</b></font></td></tr><tr><td align=\"right\"><a target=\"_new\" href=\"http://dhcp-dns-server.sourceforge.net\">http://dhcp-dns-server.sourceforge.net</td></tr></table>";
const data4 opData[] =
@@ -281,7 +294,11 @@
{
{ "SubnetMask", DHCP_OPTION_NETMASK, 3 },
@@ -261,7 +274,7 @@
strcpy(leaFile, "/tmp/dualserver.state");
if (!iniFile[0])
+#ifdef __FreeBSD__
- strcpy(iniFile, "/etc/dualserver.ini");
+ strcpy(iniFile, "/usr/local/etc/dualserver.conf");
+#else
strcpy(iniFile, "/etc/dualserver.ini");
+#endif
strcpy(filePATH, iniFile);
@@ -4268,7 +4285,12 @@
if (verbatim)
{
@@ -4002,7 +4015,13 @@
else if (req->dhcpp.header.bp_broadcast || !req->remote.sin_addr.s_addr || req->reqIP)
{
req->remote.sin_port = htons(IPPORT_DHCPC);
+#ifdef __FreeBSD__
+ req->remote.sin_addr.s_addr = network.dhcpConn[req->sockInd].addr.sin_addr.s_addr | (~network.dhcpConn[req->sockInd].mask);
+ //printf("broadcast dhcp response to %s\n",inet_ntoa(req->remote.sin_addr));
+ req->remote.sin_addr.s_addr = network.dhcpConn[req->sockInd].addr.sin_addr.s_addr |
+ (~network.dhcpConn[req->sockInd].mask);
+ //printf("broadcast dhcp response to %s\n",inet_ntoa(req->remote.sin_addr));
+#else
req->remote.sin_addr.s_addr = INADDR_BROADCAST;
+#endif
req->dhcpp.header.bp_broadcast = 1;
}
else
{
@@ -9455,6 +9477,10 @@
@@ -8983,6 +9002,10 @@
newNetwork.dhcpConn[i].broadCastSize = sizeof(newNetwork.dhcpConn[i].broadCastVal);
setsockopt(newNetwork.dhcpConn[i].sock, SOL_SOCKET, SO_BROADCAST, (char*)&newNetwork.dhcpConn[i].broadCastVal, newNetwork.dhcpConn[i].broadCastSize);
+#ifdef __FreeBSD__
+ // See man ip
+ setsockopt(newNetwork.dhcpConn[i].sock,IPPROTO_IP, IP_ONESBCAST,(char*)&newNetwork.dhcpConn[i].broadCastVal, newNetwork.dhcpConn[i].broadCastSize);
+ // See man ip
+ setsockopt(newNetwork.dhcpConn[i].sock,IPPROTO_IP, IP_ONESBCAST,(char*)&newNetwork.dhcpConn[i].broadCastVal, newNetwork.dhcpConn[i].broadCastSize);
+#endif
int nRet = bind(newNetwork.dhcpConn[i].sock, (sockaddr*)&newNetwork.dhcpConn[i].addr, sizeof(struct sockaddr_in));
if (nRet == SOCKET_ERROR)
@@ -9506,7 +9532,11 @@
@@ -9034,7 +9057,11 @@
setsockopt(newNetwork.dhcpListener.sock, SOL_SOCKET, SO_REUSEADDR, (char*)&newNetwork.dhcpListener.reUseVal, newNetwork.dhcpListener.reUseSize);
newNetwork.dhcpListener.pktinfoVal = true;
newNetwork.dhcpListener.pktinfoSize = sizeof(newNetwork.dhcpListener.pktinfoVal);
+#ifdef __FreeBSD__
+ setsockopt(newNetwork.dhcpListener.sock, IPPROTO_IP, IP_RECVIF, &newNetwork.dhcpListener.pktinfoVal, newNetwork.dhcpListener.pktinfoSize);
+ setsockopt(newNetwork.dhcpListener.sock, IPPROTO_IP, IP_RECVIF, &newNetwork.dhcpListener.pktinfoVal, newNetwork.dhcpListener.pktinfoSize);
+#else
setsockopt(newNetwork.dhcpListener.sock, IPPROTO_IP, IP_PKTINFO, &newNetwork.dhcpListener.pktinfoVal, newNetwork.dhcpListener.pktinfoSize);
+#endif
newNetwork.dhcpListener.addr.sin_family = AF_INET;
newNetwork.dhcpListener.addr.sin_addr.s_addr = INADDR_ANY;
@@ -10149,6 +10179,12 @@
@@ -9496,8 +9523,11 @@
if (addr && !(flags & IFF_LOOPBACK))
addServer(network->allServers, addr);
-
+#ifdef __FreeBSD__
+ if (addr && mask && !(flags & IFF_POINTOPOINT) && !(flags & IFF_LOOPBACK))
+#else
if (addr && mask && !(flags & IFF_POINTOPOINT) && !(flags & IFF_LOOPBACK) && !(flags & IFF_DYNAMIC))
+#endif
{
if ((flags & IFF_RUNNING) && (flags & IFF_UP))
{
@@ -9656,6 +9686,12 @@
MYWORD gdmess(data9 *req, MYBYTE sockInd)
{
+#ifdef __FreeBSD__
+ struct cmsghdr *cmsg;
+ struct sockaddr_dl * isdl;
+ struct sockaddr_in *isin;
+ struct ifaddrs *ifap, *ifa;
+ struct cmsghdr *cmsg;
+ struct sockaddr_dl * isdl;
+ struct sockaddr_in *isin;
+ struct ifaddrs *ifap, *ifa;
+#endif
//sprintf(logBuff, "Socket=%u", sockInd);
//logMess(logBuff, 1);
//logDHCPMess(logBuff, 1);
memset(req, 0, sizeof(data9));
@@ -10164,7 +10200,11 @@
@@ -9671,7 +9707,11 @@
req->msg.msg_name = &req->remote;
req->msg.msg_namelen = sizeof(sockaddr_in);
req->msg.msg_control = &req->msgcontrol;
@ -112,7 +123,7 @@
req->msg.msg_flags = msgflags;
int flags = 0;
@@ -10173,6 +10213,45 @@
@@ -9680,6 +9720,45 @@
if (errno || req->bytes <= 0)
return 0;
@ -153,12 +164,12 @@
+
+ //printf("IF = %s\n", isdl->sdl_data);
+ //printf("RADDR = %s\n", inet_ntoa(isin->sin_addr));
+
+
+#else
//printf("%u\n", req->msg.msg_controllen);
//msgcontrol = (msg_control*)msg.msg_control;
@@ -10204,6 +10283,7 @@
@@ -9711,6 +9790,7 @@
break;
}
}

View File

@ -1,34 +1,41 @@
--- dualserverd.h 2013-05-06 19:27:45.000000000 +0200
+++ dualserverd.h 2013-05-18 16:36:54.000000000 +0200
@@ -623,10 +623,19 @@
--- dualserverd.h 2012-11-09 15:45:52.000000000 +0100
+++ dualserverd.h 2012-11-09 15:55:00.000000000 +0100
@@ -52,9 +52,11 @@
#define INADDR_NONE ULONG_MAX
#endif
+#ifndef __FreeBSD__
#ifndef IFF_DYNAMIC
#define IFF_DYNAMIC 0x8000
#endif
+#endif
#define MYWORD unsigned short
#define MYBYTE unsigned char
@@ -594,10 +596,15 @@
struct msg_control
{
+#ifdef __FreeBSD__
+ u_long cmsg_len;
+#else
ulong cmsg_len;
+#endif
- ulong cmsg_len;
+ u_long cmsg_len;
int cmsg_level;
int cmsg_type;
+#ifdef __FreeBSD__
+ // Arbitrary size, when the size is required we use sizeof
+ unsigned char pktinfo[100];
+#else
in_pktinfo pktinfo;
+#endif
- in_pktinfo pktinfo;
+ #ifdef __FreeBSD__
+ // Arbitrary size, when the size is required we use sizeof
+ unsigned char pktinfo[100];
+ #else
+ in_pktinfo pktinfo;
+ #endif
};
#if defined(__hppa__) || \
@@ -744,7 +753,11 @@
@@ -713,7 +720,7 @@
union
{
int broadCastVal;
+#ifdef __FreeBSD__
+ int pktinfoVal;
+#else
bool pktinfoVal;
+#endif
- bool pktinfoVal;
+ int pktinfoVal;
};
union
{