]> git.karo-electronics.de Git - mdnsd.git/commitdiff
Simons initial import with slight changes
authorOle Reinhardt <ole.reinhardt@kernelconcepts.de>
Sun, 28 Apr 2013 22:57:15 +0000 (00:57 +0200)
committerOle Reinhardt <ole.reinhardt@kernelconcepts.de>
Sun, 28 Apr 2013 22:57:15 +0000 (00:57 +0200)
1035.c
1035.h
mdnsd.c
mdnsd.h
mhttp.c
mquery.c
xht.c

diff --git a/1035.c b/1035.c
index b63d073c0ee21f2465c48afaaf76f0dfea526987..b067ea12c6572f8ac75394cd5c68873fd7cf3e0f 100644 (file)
--- a/1035.c
+++ b/1035.c
@@ -1,5 +1,5 @@
 #include "1035.h"
-#include <string.h>
+#include <string.h> 
 
 unsigned short int net2short(unsigned char **bufp)
 {
@@ -30,7 +30,7 @@ void short2net(unsigned short int i, unsigned char **bufp)
     *(*bufp + 1) = (unsigned char)i;
     i >>= 8;
     **bufp = (unsigned char)i;
-    *bufp += 2;
+    *bufp += 2;    
 }
 
 void long2net(unsigned long int l, unsigned char **bufp)
@@ -76,7 +76,7 @@ void _label(struct message *m, unsigned char **bufp, unsigned char **namep)
         // copy chars for this label
         memcpy(name,label+1,*label);
         name[*label] = '.';
-    }
+    } 
 
     // advance buffer
     for(label = *bufp; *label != 0 && !(*label & 0xc0 && label++); label += *label + 1);
@@ -104,22 +104,22 @@ int _lmatch(struct message *m, unsigned char *l1, unsigned char *l2)
     // always ensure we get called w/o a pointer
     if(*l1 & 0xc0) return _lmatch(m, m->_buf + _ldecomp(l1),l2);
     if(*l2 & 0xc0) return _lmatch(m, l1, m->_buf + _ldecomp(l2));
-
+    
     // same already?
     if(l1 == l2) return 1;
-
+    
     // compare all label characters
     if(*l1 != *l2) return 0;
-    for(len = 1; len <= *l1; len++)
+    for(len = 1; len <= *l1; len++) 
         if(l1[len] != l2[len]) return 0;
 
     // get new labels
     l1 += *l1 + 1;
     l2 += *l2 + 1;
-
+    
     // at the end, all matched
     if(*l1 == 0 && *l2 == 0) return 1;
-
+    
     // try next labels
     return _lmatch(m,l1,l2);
 }
@@ -224,7 +224,7 @@ int _rrparse(struct message *m, struct resource *rr, int count, unsigned char **
             rr[i].known.srv.weight = net2short(bufp);
             rr[i].known.srv.port = net2short(bufp);
             _label(m, bufp, &(rr[i].known.srv.name));
-            break;
+            break;            
         default:
             *bufp += rr[i].rdlength;
         }
@@ -237,7 +237,7 @@ void message_parse(struct message *m, unsigned char *packet)
 {
     unsigned char *buf;
     int i;
-
+    
     if(packet == 0 || m == 0) return;
 
     // keep all our mem in one (aligned) block for easy freeing
diff --git a/1035.h b/1035.h
index ef88022f3102aacf2b28e6556c517d9b848225bd..41a2d339f771a1adbbc311fb6fd7da0a8522a060 100644 (file)
--- a/1035.h
+++ b/1035.h
@@ -48,7 +48,7 @@ struct message
     // internal variables
     unsigned char *_buf, *_labels[20];
     int _len, _label;
-
+    
     // packet acts as padding, easier mem management
     unsigned char _packet[MAX_PACKET_LEN];
 };
diff --git a/mdnsd.c b/mdnsd.c
index 10c66a74068b6c6923bfc64401d314f1014eeec9..2efc0a7106167a39ecd44a311ccd176f0926e798 100644 (file)
--- a/mdnsd.c
+++ b/mdnsd.c
@@ -291,7 +291,7 @@ void _cache(mdnsd d, struct resource *r)
         while(c = _c_next(d,c,r->name,r->type)) c->rr.ttl = 0;
         _c_expire(d,&d->cache[i]);
     }
-
+    
     if(r->ttl == 0)
     { // process deletes
         while(c = _c_next(d,c,r->name,r->type))
@@ -467,7 +467,7 @@ int mdnsd_out(mdnsd d, struct message *m, unsigned long int *ip, unsigned short
     *ip = inet_addr("224.0.0.251");
     m->header.qr = 1;
     m->header.aa = 1;
-
+    
     if(d->uanswers)
     { // send out individual unicast answers
         struct unicast *u = d->uanswers;
@@ -620,7 +620,7 @@ struct timeval *mdnsd_sleep(mdnsd d)
     if(d->uanswers || d->a_now) return &d->sleep;
 
     gettimeofday(&d->now,0);
-
+    
     if(d->a_pause)
     { // then check for paused answers
         if((usec = _tvdiff(d->now,d->pause)) > 0) d->sleep.tv_usec = usec;
diff --git a/mdnsd.h b/mdnsd.h
index bc86df680e7c31562826aba8d430baa98ecb95b3..d7afb2ce36d1d4ec5bf1833d4b837f7118622490 100644 (file)
--- a/mdnsd.h
+++ b/mdnsd.h
@@ -44,14 +44,14 @@ void mdnsd_in(mdnsd d, struct message *m, unsigned long int ip, unsigned short i
 // outgoing messge to be delivered to host, returns >0 if one was returned and m/ip/port set
 int mdnsd_out(mdnsd d, struct message *m, unsigned long int *ip, unsigned short int *port);
 //
-// returns the max wait-time until mdnsd_out() needs to be called again
+// returns the max wait-time until mdnsd_out() needs to be called again 
 struct timeval *mdnsd_sleep(mdnsd d);
 //
 ////////////
 
 ///////////
 // Q/A functions
-//
+// 
 // register a new query
 //   answer(record, arg) is called whenever one is found/changes/expires (immediate or anytime after, mdnsda valid until ->ttl==0)
 //   either answer returns -1, or another mdnsd_query with a NULL answer will remove/unregister this query
@@ -70,7 +70,7 @@ mdnsda mdnsd_list(mdnsd d, char *host, int type, mdnsda last);
 //   conflict(arg) called at any point when one is detected and unable to recover
 //   after the first data is set_*(), any future changes effectively expire the old one and attempt to create a new unique record
 mdnsdr mdnsd_unique(mdnsd d, char *host, int type, long int ttl, void (*conflict)(char *host, int type, void *arg), void *arg);
-//
+// 
 // create a new shared record
 mdnsdr mdnsd_shared(mdnsd d, char *host, int type, long int ttl);
 //
diff --git a/mhttp.c b/mhttp.c
index c70bd15d9176159320939ae6d4b8c10bef3ce47c..1dbc9e62dae7f158340b13fbc59730ade2cd4add 100644 (file)
--- a/mhttp.c
+++ b/mhttp.c
@@ -48,7 +48,7 @@ int msock()
 
     mc.imr_multiaddr.s_addr = inet_addr("224.0.0.251");
     mc.imr_interface.s_addr = htonl(INADDR_ANY);
-    setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mc, sizeof(mc));
+    setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mc, sizeof(mc)); 
     setsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl));
     setsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL, &ittl, sizeof(ittl));
 
index 36f98fdc7125cb670f0c536265d905fe1e89b86f..9547d079a7fc21f4bff391faf7c3962aff646311 100644 (file)
--- a/mquery.c
+++ b/mquery.c
@@ -50,7 +50,7 @@ int msock()
 
     mc.imr_multiaddr.s_addr = inet_addr("224.0.0.251");
     mc.imr_interface.s_addr = htonl(INADDR_ANY);
-    setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mc, sizeof(mc));
+    setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mc, sizeof(mc)); 
     setsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl));
     setsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL, &ittl, sizeof(ittl));
 
diff --git a/xht.c b/xht.c
index 108c99b0439a869b5c622ed190930daf9abd5a57..c647f54ac143c57dc3025debdd672841b079c0ee 100644 (file)
--- a/xht.c
+++ b/xht.c
@@ -15,7 +15,7 @@ struct xht_struct
 };
 
 /* Generates a hash code for a string.
- * This function uses the ELF hashing algorithm as reprinted in
+ * This function uses the ELF hashing algorithm as reprinted in 
  * Andrew Binstock, "Hashing Rehashed," Dr. Dobb's Journal, April 1996.
  */
 int _xhter(const char *s)