Commits

Markus Tzoe committed 7c1069c

default PUSH:
- txt_record{} -> class to _class: eliminate warnings;
- delete pull/fetch related code: deprecated;
- nsreporter: default action push.

Comments (0)

Files changed (5)

 struct txt_record {
   char *name;
   unsigned char *txt;
-  unsigned short class, len;
+  unsigned short _class, len;
   struct txt_record *next;
 };
 
 #define RPRT_PRNO 0x7F64u // protocol number
 enum flag
 {
-    RPRT_PULL = 0x01,
+    RPRT_PULL = 0x01, // deprecated
     RPRT_PUSH = 0x02,
     RPRT_IPV6 = 0x04,
     RPRT_ACKN = 0x08,
             struct sockaddr_in v4;
             struct sockaddr_in6 v6;
         } address;
-        uint64_t size;
+        //uint64_t size;
     } payload;
 };
 void write_record(struct report*);
-void report_cache(struct report**, size_t size);
+// void report_cache(struct report*);
 void read_cache();
 void save_cache();
 #endif
 
 #ifndef HAVE_RPRT
 #define HAVE_RPRT
-#define RPRT_PORT_S "5335"
+#define RPRT_PORT_STRING "5335"
 #endif
 #include "dnsmasq.h"
 
     fprintf(stderr, " %s <actions>\n\n", prog);
     fprintf(stderr, "Actions:\n");
     fprintf(stderr, " -p, --push                        Push local computer [hostname:address] to server.\n");
-    fprintf(stderr, " -f, --fetch <count>               Fetch stored [hostname:address]s in server.\n");
     fprintf(stderr, " -s, --server <host>               Override default server.\n");
     fprintf(stderr, "     --name <hostname>             Override hostname.\n");
     fprintf(stderr, "     --ack                         Ask server to send an ack after the primary action.\n");
     fprintf(stderr, " -h, --help                        Print this help.\n");
     fprintf(stderr, " -v, --version                     Print version infomation.\n\n");
     fprintf(stderr, "Examples:\n");
-    fprintf(stderr, " Select eth1: %s --device eth1 --push\n", prog);
     fprintf(stderr, " Override name: %s --name mycomputer --push\n", prog);
     fprintf(stderr, " Override host: %s --server localhost --push\n", prog);
     fprintf(stderr, " Wait for an ack: %s --push -s localhost --ack\n\n", prog);
     {
         { "help", no_argument, NULL, 'h' },
         { "push", no_argument, NULL, 'p' },
-        { "fetch", required_argument, NULL, 'f' },
         { "server", required_argument, NULL, 's' },
         { "version", no_argument, NULL, 'v' },
         { "name", required_argument, NULL, 256 },
     (void) setlocale(LC_ALL, "");
 
     unsigned int flag = 0u;
-    uint64_t size = 0ull;
-    char *endptr = NULL;
+    flag |= RPRT_PUSH;
     int family = AF_INET;
 
-    while ((oc = getopt_long(argc, (char * const *)argv, "f:hps:v", longopts, NULL)) != -1)
+    while ((oc = getopt_long(argc, (char * const *)argv, "hps:v", longopts, NULL)) != -1)
     {
         switch (oc)
         {
             print_help();
             break;
         }
-        case 'f':
-        {
-            flag |= RPRT_PULL;
-            size = strtol(optarg, &endptr, 10);
-            if (endptr[0] != 0)
-            {
-                fprintf(stderr, "Invalid size option. Set to default 1.\n");
-                size = 1;
-            }
-            break;
-        }
         case 'p':
         {
-            flag |= RPRT_PUSH;
             break;
         }
         case 's':
         int sockfd;
         struct sockaddr_in s;
 
-        sockfd = makesocket(server, RPRT_PORT_S, (struct sockaddr *)&s);
+        sockfd = makesocket(server, RPRT_PORT_STRING, (struct sockaddr *)&s);
         if(sockfd == -1){
             abort();
         }
         close(sockfd);
     }
 
-    if (flag & RPRT_PULL)
-    {
-        fprintf(stderr, "fetch function under construction.\n");
-    }
-
     return 0;
 }
   r->name = opt_string_alloc(name);
   r->next = daemon->txt;
   daemon->txt = r;
-  r->class = C_CHAOS;
+  r->_class = C_CHAOS;
   r->txt = opt_malloc(len+1);
   r->len = len+1;
   *(r->txt) = len;
 	new = opt_malloc(sizeof(struct txt_record));
 	new->next = daemon->txt;
 	daemon->txt = new;
-	new->class = C_IN;
+	new->_class = C_IN;
 	
 	if (!(new->name = canonicalise_opt(arg)))
 	  {
 #ifdef HAVE_RPRT
 #include <sys/poll.h>
 
-void reply_ack(int fd, struct report* rt, struct sockaddr* sk) {
+void reply_ack(int fd, struct report *rt, struct sockaddr *sk)
+{
     struct pollfd fds;
     fds.fd = fd;
     fds.events = POLLOUT | POLLWRBAND;
     int ret = poll(&fds, 1, 5);
-    if(ret == -1 || ret == 0){
+    if (ret == -1 || ret == 0)
+    {
         return;
     }
-    if (fds.revents & (POLLOUT | POLLWRBAND)) {
-        if(sendto(fd, rt, sizeof(struct report), 0, sk, INET_ADDRSTRLEN) == -1){
+    if (fds.revents & (POLLOUT | POLLWRBAND))
+    {
+        if (sendto(fd, rt, sizeof(struct report), 0, sk, INET_ADDRSTRLEN) == -1)
+        {
             my_syslog(LOG_ERR, _("reply_ack: error %d occurs."), errno);
             return;
         }
         return;
     }
 
-    if(inet_ntop(faddr.sin_family, &faddr.sin_addr, daemon->addrbuff, ADDRSTRLEN) == NULL) {
+    if (inet_ntop(faddr.sin_family, &faddr.sin_addr, daemon->addrbuff, ADDRSTRLEN) == NULL)
+    {
         my_syslog(LOG_ERR, ("%d: inet_ntop() error. abort cache insertion."), now);
         return;
     }
 
-    if(report.proto != RPRT_PRNO){
+    if (report.proto != RPRT_PRNO)
+    {
         report.flags |= RPRT_ABRT;
     }
-    else {
+    else
+    {
         report.flags &= 0x0F;
         report.flags |= RPRT_OKAY;
-    
-        /*if (report.flags & RPRT_PULL)
+
+        /*if (RPRT_PULL & report.flags)
         {
-            //my_syslog(LOG_INFO, _("flag: PULL"));
+            report_cache(&report);
         }*/
 
         if (RPRT_PUSH & report.flags)
             write_record(&report);
         }
     }
-    
+
     if (RPRT_ACKN & report.flags)
     {
         reply_ack(fd, &report, (struct sockaddr *)&faddr);
 	  struct txt_record *t;
 	  for(t = daemon->txt; t ; t = t->next)
 	    {
-	      if (t->class == qclass && hostname_isequal(name, t->name))
+	      if (t->_class == qclass && hostname_isequal(name, t->name))
 		{
 		  ans = 1;
 		  if (!dryrun)
 		      log_query(F_CONFIG | F_RRNAME, name, NULL, "<TXT>");
 		      if (add_resource_record(header, limit, &trunc, nameoffset, &ansp, 
 					      daemon->local_ttl, NULL,
-					      T_TXT, t->class, "t", t->len, t->txt))
+					      T_TXT, t->_class, "t", t->len, t->txt))
 			anscount++;
 
 		    }