mirror of
https://git.freebsd.org/ports.git
synced 2025-07-18 01:39:16 -04:00
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:
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
|
@ -2,19 +2,27 @@
|
|||
# $FreeBSD$
|
||||
|
||||
PORTNAME= mdnsd
|
||||
PORTVERSION= 0.7G
|
||||
PORTREVISION= 1
|
||||
DISTVERSIONPREFIX= v
|
||||
DISTVERSION= 0.7G-107
|
||||
DISTVERSIONSUFFIX= -gf4aee59
|
||||
PORTEPOCH= 1
|
||||
CATEGORIES= dns
|
||||
MASTER_SITES= http://www.cs.cmu.edu/~dpelleg/download/
|
||||
|
||||
MAINTAINER= daniel+mdnsd@pelleg.org
|
||||
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:
|
||||
.for f in mhttp mquery
|
||||
${INSTALL_PROGRAM} ${WRKSRC}/${f} ${STAGEDIR}${PREFIX}/bin
|
||||
.for f in mdnsd mquery
|
||||
${INSTALL_PROGRAM} ${CONFIGURE_WRKSRC}/${f} ${STAGEDIR}${PREFIX}/bin
|
||||
.endfor
|
||||
|
||||
.include <bsd.port.mk>
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
SHA256 (mdnsd-0.7G.tar.gz) = d8f07196504b8e9a243ff55e44962c843fd03b1cd4ea07022ce61ee00891cb86
|
||||
SIZE (mdnsd-0.7G.tar.gz) = 14873
|
||||
TIMESTAMP = 1514072404
|
||||
SHA256 (Pro-mdnsd-v0.7G-107-gf4aee59_GH0.tar.gz) = 5924dc3045d90ce0796dec1630d22e7f9ce191baa53e6d7fdfa4552086e1e5a2
|
||||
SIZE (Pro-mdnsd-v0.7G-107-gf4aee59_GH0.tar.gz) = 31944
|
||||
|
|
|
@ -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;
|
|
@ -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
|
11
dns/mdnsd/files/patch-libmdnsd_1035.c
Normal file
11
dns/mdnsd/files/patch-libmdnsd_1035.c
Normal 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
|
||||
|
11
dns/mdnsd/files/patch-libmdnsd_mdnsd.c
Normal file
11
dns/mdnsd/files/patch-libmdnsd_mdnsd.c
Normal 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 */
|
|
@ -1,113 +1,19 @@
|
|||
diff -ruN mdnsd.c.orig mdnsd.c
|
||||
--- mdnsd.c.orig Tue Feb 18 08:54:46 2003
|
||||
+++ mdnsd.c Mon Sep 25 22:11:17 2006
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "mdnsd.h"
|
||||
+#include <arpa/inet.h>
|
||||
#include <string.h>
|
||||
+#include <stdlib.h>
|
||||
--- mdnsd.c.orig 2017-11-22 13:47:51 UTC
|
||||
+++ mdnsd.c
|
||||
@@ -13,6 +13,7 @@
|
||||
#endif
|
||||
|
||||
// size of query/publish hashes
|
||||
#define SPRIME 108
|
||||
@@ -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 @@
|
||||
#include <sys/types.h>
|
||||
+#include <sys/socket.h>
|
||||
|
||||
if(r->class == 32768 + d->class)
|
||||
{ // 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]);
|
||||
}
|
||||
#ifdef _WIN32
|
||||
|
||||
if(r->ttl == 0)
|
||||
{ // process deletes
|
||||
- while(c = _c_next(d,c,r->name,r->type))
|
||||
+ while( (c = _c_next(d,c,r->name,r->type)) )
|
||||
if(_a_match(r,&c->rr))
|
||||
{
|
||||
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);
|
||||
}
|
||||
@@ -139,7 +140,7 @@ int msock(void)
|
||||
int s, flag = 1, ittl = 255;
|
||||
struct sockaddr_in in;
|
||||
struct ip_mreq mc;
|
||||
- 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
|
||||
|
||||
@@ -344,7 +346,11 @@
|
||||
|
||||
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
|
||||
memset(&in, 0, sizeof(in));
|
||||
in.sin_family = AF_INET;
|
||||
|
|
|
@ -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;
|
|
@ -1,51 +1,11 @@
|
|||
diff -ruN mquery.c.orig mquery.c
|
||||
--- mquery.c.orig Tue Feb 18 08:59:49 2003
|
||||
+++ mquery.c Mon Sep 25 22:11:18 2006
|
||||
@@ -1,21 +1,29 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
+#include <stdio.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>
|
||||
--- mquery.c.orig 2017-11-22 13:47:51 UTC
|
||||
+++ mquery.c
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
+#include <sys/socket.h>
|
||||
+#include <netinet/in.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; }
|
||||
|
|
|
@ -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)++;
|
|
@ -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);
|
|
@ -1,4 +1,4 @@
|
|||
To use:
|
||||
mhttp 'unique name' 12.34.56.78 80 '/optionalpath'
|
||||
mdnsd 'unique name' 12.34.56.78 80 '/optionalpath'
|
||||
For example:
|
||||
mhttp audiotron 192.168.123.195 80 '/index.asp' &
|
||||
mdnsd audiotron 192.168.123.195 80 '/index.asp' &
|
||||
|
|
Loading…
Add table
Reference in a new issue