dns/mdnsd: Updating to the current revision

PR:		225114
Approved by:	tcberner (mentor)
Differential Revision:	https://reviews.freebsd.org/D13600
This commit is contained in:
Yuri Victorovich 2018-01-27 20:09:57 +00:00
parent 43ec911f85
commit 2cf8a65558
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=460149
12 changed files with 65 additions and 323 deletions

View file

@ -2,19 +2,27 @@
# $FreeBSD$ # $FreeBSD$
PORTNAME= mdnsd PORTNAME= mdnsd
PORTVERSION= 0.7G DISTVERSIONPREFIX= v
PORTREVISION= 1 DISTVERSION= 0.7G-107
DISTVERSIONSUFFIX= -gf4aee59
PORTEPOCH= 1
CATEGORIES= dns CATEGORIES= dns
MASTER_SITES= http://www.cs.cmu.edu/~dpelleg/download/
MAINTAINER= daniel+mdnsd@pelleg.org MAINTAINER= daniel+mdnsd@pelleg.org
COMMENT= Advertise a service via Rendezvous COMMENT= Advertise a service via Rendezvous
PLIST_FILES= bin/mhttp bin/mquery LICENSE= BSD3CLAUSE
LICENSE_FILE= ${WRKSRC}/LICENSE
USES= cmake:outsource
USE_GITHUB= yes
GH_ACCOUNT= Pro
PLIST_FILES= bin/mdnsd bin/mquery
do-install: do-install:
.for f in mhttp mquery .for f in mdnsd mquery
${INSTALL_PROGRAM} ${WRKSRC}/${f} ${STAGEDIR}${PREFIX}/bin ${INSTALL_PROGRAM} ${CONFIGURE_WRKSRC}/${f} ${STAGEDIR}${PREFIX}/bin
.endfor .endfor
.include <bsd.port.mk> .include <bsd.port.mk>

View file

@ -1,2 +1,3 @@
SHA256 (mdnsd-0.7G.tar.gz) = d8f07196504b8e9a243ff55e44962c843fd03b1cd4ea07022ce61ee00891cb86 TIMESTAMP = 1514072404
SIZE (mdnsd-0.7G.tar.gz) = 14873 SHA256 (Pro-mdnsd-v0.7G-107-gf4aee59_GH0.tar.gz) = 5924dc3045d90ce0796dec1630d22e7f9ce191baa53e6d7fdfa4552086e1e5a2
SIZE (Pro-mdnsd-v0.7G-107-gf4aee59_GH0.tar.gz) = 31944

View file

@ -1,18 +0,0 @@
diff -ruN 1035.c.orig 1035.c
--- 1035.c.orig Tue Feb 18 08:54:33 2003
+++ 1035.c Mon Sep 25 22:11:14 2006
@@ -1,4 +1,5 @@
#include "1035.h"
+#include <stdio.h>
#include <string.h>
unsigned short int net2short(unsigned char **bufp)
@@ -241,7 +242,7 @@
if(packet == 0 || m == 0) return;
// keep all our mem in one (aligned) block for easy freeing
- #define my(x,y) while(m->_len&7) m->_len++; (void*)x = (void*)(m->_packet + m->_len); m->_len += y;
+ #define my(x,y) x = (void *) x; while(m->_len&7) m->_len++; x = (void*)(m->_packet + m->_len); m->_len += y;
// header stuff bit crap
m->_buf = buf = packet;

View file

@ -1,17 +0,0 @@
--- Makefile.orig 2003-02-18 08:00:04.000000000 +0100
+++ Makefile 2014-02-19 13:13:13.848094695 +0100
@@ -1,10 +1,12 @@
+CC?=gcc
+
all: mquery mhttp
mhttp: mhttp.c
- gcc -g -o mhttp mhttp.c mdnsd.c 1035.c sdtxt.c xht.c
+ ${CC} ${CFLAGS} -o mhttp mhttp.c mdnsd.c 1035.c sdtxt.c xht.c
mquery: mquery.c
- gcc -g -o mquery mquery.c mdnsd.c 1035.c
+ ${CC} ${CFLAGS} -o mquery mquery.c mdnsd.c 1035.c
clean:
rm -f mquery mhttp

View file

@ -0,0 +1,11 @@
--- libmdnsd/1035.c.orig 2017-11-22 13:47:51 UTC
+++ libmdnsd/1035.c
@@ -1,6 +1,7 @@
+
+#include <stdio.h>
#include "1035.h"
#include <string.h>
-#include <stdio.h>
#if defined(_MSC_VER) && _MSC_VER < 1900

View file

@ -0,0 +1,11 @@
--- libmdnsd/mdnsd.c.orig 2017-11-22 13:47:51 UTC
+++ libmdnsd/mdnsd.c
@@ -3,6 +3,8 @@
#include <string.h>
#include <stdlib.h>
#include <errno.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
#define SPRIME 108 /* Size of query/publish hashes */
#define LPRIME 1009 /* Size of cache hash */

View file

@ -1,113 +1,19 @@
diff -ruN mdnsd.c.orig mdnsd.c --- mdnsd.c.orig 2017-11-22 13:47:51 UTC
--- mdnsd.c.orig Tue Feb 18 08:54:46 2003 +++ mdnsd.c
+++ mdnsd.c Mon Sep 25 22:11:17 2006 @@ -13,6 +13,7 @@
@@ -1,5 +1,7 @@ #endif
#include "mdnsd.h"
+#include <arpa/inet.h>
#include <string.h>
+#include <stdlib.h>
// size of query/publish hashes #include <sys/types.h>
#define SPRIME 108 +#include <sys/socket.h>
@@ -198,7 +200,7 @@
struct cached *cur = 0;
q->nexttry = 0;
q->tries = 0;
- while(cur = _c_next(d,cur,q->name,q->type))
+ while( (cur = _c_next(d,cur,q->name,q->type)) )
if(q->nexttry == 0 || cur->rr.ttl - 7 < q->nexttry) q->nexttry = cur->rr.ttl - 7;
if(q->nexttry != 0 && q->nexttry < d->checkqlist) d->checkqlist = q->nexttry;
}
@@ -208,7 +210,7 @@
struct cached *c = 0;
struct query *cur;
int i = _namehash(q->name) % LPRIME;
- while(c = _c_next(d,c,q->name,q->type)) c->q = 0;
+ while( (c = _c_next(d,c,q->name,q->type)) ) c->q = 0;
if(d->qlist == q) d->qlist = q->list;
else {
for(cur=d->qlist;cur->list != q;cur = cur->list);
@@ -288,13 +290,13 @@
if(r->class == 32768 + d->class) #ifdef _WIN32
{ // cache flush
- while(c = _c_next(d,c,r->name,r->type)) c->rr.ttl = 0;
+ while( (c = _c_next(d,c,r->name,r->type)) ) c->rr.ttl = 0;
_c_expire(d,&d->cache[i]);
}
if(r->ttl == 0) @@ -139,7 +140,7 @@ int msock(void)
{ // process deletes int s, flag = 1, ittl = 255;
- while(c = _c_next(d,c,r->name,r->type)) struct sockaddr_in in;
+ while( (c = _c_next(d,c,r->name,r->type)) ) struct ip_mreq mc;
if(_a_match(r,&c->rr)) - char ttl = 255; // send to any reachable net, not only the subnet
{ + u_char ttl = 255; // send to any reachable net, not only the subnet
c->rr.ttl = 0;
@@ -330,7 +332,7 @@
}
c->next = d->cache[i];
d->cache[i] = c;
- if(c->q = _q_next(d, 0, r->name, r->type))
+ if( (c->q = _q_next(d, 0, r->name, r->type)) )
_q_answer(d,c);
}
@@ -344,7 +346,11 @@ memset(&in, 0, sizeof(in));
in.sin_family = AF_INET;
int _r_out(mdnsd d, struct message *m, mdnsdr *list)
{ // copy a published record into an outgoing message
- mdnsdr r, next;
+ /*
+ * Unused
+ * mdnsdr next;
+ */
+ mdnsdr r;
int ret = 0;
while((r = *list) != 0 && message_packet_len(m) + _rr_len(&r->rr) < d->frame)
{
@@ -363,7 +369,10 @@
mdnsd mdnsd_new(int class, int frame)
{
- int i;
+ /*
+ * Unused
+ * int i;
+ */
mdnsd d;
d = (mdnsd)malloc(sizeof(struct mdnsd_struct));
bzero(d,sizeof(struct mdnsd_struct));
@@ -401,7 +410,10 @@
void mdnsd_free(mdnsd d)
{
- int i;
+ /*
+ * Unused
+ * int i;
+ */
// loop through all hashes, free everything
// free answers if any
free(d);
@@ -611,8 +623,11 @@
struct timeval *mdnsd_sleep(mdnsd d)
{
+ /*
+ * Unused
+ * mdnsdr r;
+ */
int sec, usec;
- mdnsdr r;
d->sleep.tv_sec = d->sleep.tv_usec = 0;
#define RET while(d->sleep.tv_usec > 1000000) {d->sleep.tv_sec++;d->sleep.tv_usec -= 1000000;} return &d->sleep;
@@ -665,7 +680,7 @@
q->next = d->queries[i];
q->list = d->qlist;
d->qlist = d->queries[i] = q;
- while(cur = _c_next(d,cur,q->name,q->type))
+ while( (cur = _c_next(d,cur,q->name,q->type)) )
cur->q = q; // any cached entries should be associated
_q_reset(d,q);
q->nexttry = d->checkqlist = d->now.tv_sec; // new questin, immediately send out

View file

@ -1,57 +0,0 @@
diff -ruN mhttp.c.orig mhttp.c
--- mhttp.c.orig Tue Feb 18 08:54:56 2003
+++ mhttp.c Mon Sep 25 22:11:17 2006
@@ -1,9 +1,16 @@
+#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
+#include <sys/uio.h>
#include <netinet/in.h>
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <unistd.h>
#include "mdnsd.h"
#include "sdtxt.h"
@@ -64,7 +71,8 @@
mdnsd d;
mdnsdr r;
struct message m;
- unsigned long int ip;
+ //unsigned long int ip;
+ struct in_addr ip;
unsigned short int port;
struct timeval *tv;
int bsize, ssize = sizeof(struct sockaddr_in);
@@ -76,9 +84,9 @@
int len = 0;
xht h;
- if(argc < 4) { printf("usage: mhttp 'unique name' 12.34.56.78 80 '/optionalpath'\n"); return; }
+ if(argc < 4) { printf("usage: mhttp 'unique name' 12.34.56.78 80 '/optionalpath'\n"); return 0; }
- ip = inet_addr(argv[2]);
+ ip.s_addr = inet_addr(argv[2]);
port = atoi(argv[3]);
printf("Announcing .local site named '%s' to %s:%d and extra path '%s'\n",argv[1],inet_ntoa(ip),port,argv[4]);
@@ -127,12 +135,12 @@
}
if(bsize < 0 && errno != EAGAIN) { printf("can't read from socket %d: %s\n",errno,strerror(errno)); return 1; }
}
- while(mdnsd_out(d,&m,&ip,&port))
+ while(mdnsd_out(d,&m,(unsigned long int *)&(ip.s_addr),&port))
{
bzero(&to, sizeof(to));
to.sin_family = AF_INET;
to.sin_port = port;
- to.sin_addr.s_addr = ip;
+ to.sin_addr.s_addr = ip.s_addr;
if(sendto(s,message_packet(&m),message_packet_len(&m),0,(struct sockaddr *)&to,sizeof(struct sockaddr_in)) != message_packet_len(&m)) { printf("can't write to socket: %s\n",strerror(errno)); return 1; }
}
if(_shutdown) break;

View file

@ -1,51 +1,11 @@
diff -ruN mquery.c.orig mquery.c --- mquery.c.orig 2017-11-22 13:47:51 UTC
--- mquery.c.orig Tue Feb 18 08:59:49 2003 +++ mquery.c
+++ mquery.c Mon Sep 25 22:11:18 2006 @@ -10,6 +10,8 @@
@@ -1,21 +1,29 @@ #include <stdlib.h>
#include <sys/types.h> #include <string.h>
#include <sys/socket.h> #include <time.h>
+#include <stdio.h> +#include <sys/socket.h>
#include <netinet/in.h> +#include <netinet/in.h>
+#include <arpa/inet.h>
#include <fcntl.h>
#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <unistd.h>
#include "mdnsd.h" #include <libmdnsd/mdnsd.h>
// print an answer
int ans(mdnsda a, void *arg)
{
+ struct in_addr ip;
int now;
+ ip.s_addr = a->ip;
if(a->ttl == 0) now = 0;
else now = a->ttl - time(0);
switch(a->type)
{
case QTYPE_A:
- printf("A %s for %d seconds to ip %s\n",a->name,now,inet_ntoa(a->ip));
+ printf("A %s for %d seconds to ip %s\n",a->name,now,inet_ntoa(ip));
break;
case QTYPE_PTR:
printf("PTR %s for %d seconds to %s\n",a->name,now,a->rdname);
@@ -26,6 +34,7 @@
default:
printf("%d %s for %d seconds with %d data\n",a->type,a->name,now,a->rdlen);
}
+ return 0;
}
// create multicast 224.0.0.251:5353 socket
@@ -74,7 +83,7 @@
fd_set fds;
int s;
- if(argc != 3) { printf("usage: mquery 12 _http._tcp.local.\n"); return; }
+ if(argc != 3) { printf("usage: mquery 12 _http._tcp.local.\n"); return 0; }
d = mdnsd_new(1,1000);
if((s = msock()) == 0) { printf("can't create socket: %s\n",strerror(errno)); return 1; }

View file

@ -1,27 +0,0 @@
diff -ruN sdtxt.c.orig sdtxt.c
--- sdtxt.c.orig Tue Feb 18 08:55:19 2003
+++ sdtxt.c Mon Sep 25 22:11:19 2006
@@ -1,5 +1,5 @@
#include "sdtxt.h"
-
+#include <stdlib.h>
#include <string.h>
// the universe is bound in equal parts by arrogance and altruism, any attempt to alter this would be suicide
@@ -21,10 +21,14 @@
void _sd2txt_write(xht h, const char *key, void *val, void *arg)
{
+ /*
+ * Unused
+ * int len;
+ */
unsigned char **txtp = (unsigned char **)arg;
char *cval = (char*)val;
- int len;
-
+
+
// copy in lengths, then strings
**txtp = _sd2txt_len(key,(char*)val);
(*txtp)++;

View file

@ -1,36 +0,0 @@
diff -ruN xht.c.orig xht.c
--- xht.c.orig Tue Feb 18 08:57:07 2003
+++ xht.c Mon Sep 25 22:11:20 2006
@@ -1,4 +1,6 @@
#include "xht.h"
+#include <stdlib.h>
+#include <string.h>
typedef struct xhn_struct
{
@@ -83,13 +85,15 @@
/* when flag is set, we manage their mem and free em first */
if(n->flag)
{
- free(n->key);
+ free((void *)n->key);
free(n->val);
}
n->flag = flag;
n->key = key;
n->val = val;
+
+ return NULL;
}
void xht_set(xht h, const char *key, void *val)
@@ -140,7 +144,7 @@
f = n->next;
if(n->flag)
{
- free(n->key);
+ free((void *)n->key);
free(n->val);
}
free(n);

View file

@ -1,4 +1,4 @@
To use: To use:
mhttp 'unique name' 12.34.56.78 80 '/optionalpath' mdnsd 'unique name' 12.34.56.78 80 '/optionalpath'
For example: For example:
mhttp audiotron 192.168.123.195 80 '/index.asp' & mdnsd audiotron 192.168.123.195 80 '/index.asp' &