Fixed signed comparison warnings
[olsrd.git] / src / build_msg.c
index de6ccfb..ac57b4d 100644 (file)
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: build_msg.c,v 1.25 2005/02/02 19:59:17 kattemat Exp $
+ * $Id: build_msg.c,v 1.29 2005/03/10 20:43:13 kattemat Exp $
  */
 
 
 #include "defs.h"
+#include "olsr.h"
+#include "log.h"
 #include "build_msg.h"
 #include "local_hna_set.h"
-#include "olsr.h"
-
 
 #define BMSG_DBGLVL 5
 
@@ -116,7 +116,7 @@ olsr_bool
 queue_hello(struct hello_message *message, struct interface *ifp)
 {
 #ifdef DEBUG
-  olsr_printf(BMSG_DBGLVL, "Building HELLO on %s\n-------------------\n", ifp->int_name);
+  OLSR_PRINTF(BMSG_DBGLVL, "Building HELLO on %s\n-------------------\n", ifp->int_name)
 #endif
 
   switch(olsr_cnf->ip_version)
@@ -147,7 +147,7 @@ olsr_bool
 queue_tc(struct tc_message *message, struct interface *ifp)           
 {
 #ifdef DEBUG
-  olsr_printf(BMSG_DBGLVL, "Building TC on %s\n-------------------\n", ifp->int_name);
+  OLSR_PRINTF(BMSG_DBGLVL, "Building TC on %s\n-------------------\n", ifp->int_name)
 #endif
 
   switch(olsr_cnf->ip_version)
@@ -173,7 +173,7 @@ olsr_bool
 queue_mid(struct interface *ifp)
 {
 #ifdef DEBUG
-  olsr_printf(BMSG_DBGLVL, "Building MID on %s\n-------------------\n", ifp->int_name);
+  OLSR_PRINTF(BMSG_DBGLVL, "Building MID on %s\n-------------------\n", ifp->int_name)
 #endif
 
   switch(olsr_cnf->ip_version)
@@ -198,7 +198,7 @@ olsr_bool
 queue_hna(struct interface *ifp)
 {
 #ifdef DEBUG
-  olsr_printf(BMSG_DBGLVL, "Building HNA on %s\n-------------------\n", ifp->int_name);
+  OLSR_PRINTF(BMSG_DBGLVL, "Building HNA on %s\n-------------------\n", ifp->int_name)
 #endif
 
   switch(olsr_cnf->ip_version)
@@ -221,7 +221,7 @@ check_buffspace(int msgsize, int buffsize, char *type)
 {
   if(msgsize > buffsize)
     {
-      olsr_printf(1, "%s build, outputbuffer to small(%d/%d)!\n", type, msgsize, buffsize);
+      OLSR_PRINTF(1, "%s build, outputbuffer to small(%d/%d)!\n", type, msgsize, buffsize)
       olsr_syslog(OLSR_LOG_ERR, "%s build, outputbuffer to small(%d/%d)!\n", type, msgsize, buffsize);
       olsr_exit(__func__, EXIT_FAILURE);
     }
@@ -241,7 +241,7 @@ check_buffspace(int msgsize, int buffsize, char *type)
 static olsr_bool
 serialize_hello4(struct hello_message *message, struct interface *ifp)
 {
-  int remainsize, curr_size;
+  olsr_u16_t remainsize, curr_size;
   struct hello_neighbor *nb;
   union olsr_message *m;
   struct hellomsg *h;
@@ -314,8 +314,8 @@ serialize_hello4(struct hello_message *message, struct interface *ifp)
                continue;
 
 #ifdef DEBUG
-             olsr_printf(BMSG_DBGLVL, "\t%s - ", olsr_ip_to_string(&nb->address));
-             olsr_printf(BMSG_DBGLVL, "L:%d N:%d\n", j, i);
+             OLSR_PRINTF(BMSG_DBGLVL, "\t%s - ", olsr_ip_to_string(&nb->address))
+             OLSR_PRINTF(BMSG_DBGLVL, "L:%d N:%d\n", j, i)
 #endif           
              /*
               * If there is not enough room left 
@@ -334,7 +334,7 @@ serialize_hello4(struct hello_message *message, struct interface *ifp)
                  if(curr_size > OLSR_HELLO_IPV4_HDRSIZE)
                    {
 #ifdef DEBUG
-                     olsr_printf(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize);
+                     OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize)
 #endif
                      /* Complete the headers */
                      m->v4.seqno = htons(get_msg_seqno());
@@ -414,7 +414,7 @@ serialize_hello4(struct hello_message *message, struct interface *ifp)
 static olsr_bool
 serialize_hello6(struct hello_message *message, struct interface *ifp)
 {
-  int remainsize, curr_size;
+  olsr_u16_t remainsize, curr_size;
   struct hello_neighbor *nb;
   union olsr_message *m;
   struct hellomsg6 *h6;
@@ -478,8 +478,8 @@ serialize_hello6(struct hello_message *message, struct interface *ifp)
                continue;
 
 #ifdef DEBUG
-             olsr_printf(BMSG_DBGLVL, "\t%s - ", olsr_ip_to_string(&nb->address));
-             olsr_printf(BMSG_DBGLVL, "L:%d N:%d\n", j, i);
+             OLSR_PRINTF(BMSG_DBGLVL, "\t%s - ", olsr_ip_to_string(&nb->address))
+             OLSR_PRINTF(BMSG_DBGLVL, "L:%d N:%d\n", j, i)
 #endif           
 
 
@@ -500,7 +500,7 @@ serialize_hello6(struct hello_message *message, struct interface *ifp)
                  if(curr_size > OLSR_HELLO_IPV6_HDRSIZE)
                    {
 #ifdef DEBUG
-                     olsr_printf(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize);
+                     OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize)
 #endif
                      /* Complete the headers */
                      m->v6.seqno = htons(get_msg_seqno());
@@ -580,7 +580,7 @@ static olsr_bool
 serialize_tc4(struct tc_message *message, struct interface *ifp)           
 {
 
-  int remainsize, curr_size;
+  olsr_u16_t remainsize, curr_size;
   struct tc_mpr_addr *mprs;
   union olsr_message *m;
   struct tcmsg *tc;
@@ -631,7 +631,7 @@ serialize_tc4(struct tc_message *message, struct interface *ifp)
          if(curr_size > OLSR_TC_IPV4_HDRSIZE)
            {
 #ifdef DEBUG
-             olsr_printf(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize);
+             OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize)
 #endif
 
              m->v4.olsr_msgsize = htons(curr_size);
@@ -653,8 +653,8 @@ serialize_tc4(struct tc_message *message, struct interface *ifp)
        }
       found = OLSR_TRUE;
 #ifdef DEBUG
-         olsr_printf(BMSG_DBGLVL, "\t%s\n", 
-                     olsr_ip_to_string(&mprs->address));
+         OLSR_PRINTF(BMSG_DBGLVL, "\t%s\n", 
+                     olsr_ip_to_string(&mprs->address))
 #endif 
       COPY_IP(&mprsaddr->addr, &mprs->address);
 
@@ -675,7 +675,8 @@ serialize_tc4(struct tc_message *message, struct interface *ifp)
     {
       if((!partial_sent) && (!TIMED_OUT(send_empty_tc)))
        {
-         olsr_printf(1, "TC: Sending empty package\n");
+         if(!TIMED_OUT(send_empty_tc))
+           OLSR_PRINTF(1, "TC: Sending empty package - (%d/%d/%d/%d)\n", partial_sent, (int)send_empty_tc, (int)now_times, (int)((send_empty_tc) - now_times))
 
          m->v4.olsr_msgsize = htons(curr_size);
          m->v4.seqno = htons(get_msg_seqno());
@@ -705,7 +706,7 @@ static olsr_bool
 serialize_tc6(struct tc_message *message, struct interface *ifp)           
 {
 
-  int remainsize, curr_size;
+  olsr_u16_t remainsize, curr_size;
   struct tc_mpr_addr *mprs;
   union olsr_message *m;
   struct tcmsg6 *tc6;
@@ -755,7 +756,7 @@ serialize_tc6(struct tc_message *message, struct interface *ifp)
          if(curr_size > OLSR_TC_IPV6_HDRSIZE)
            {
 #ifdef DEBUG
-             olsr_printf(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize);
+             OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize)
 #endif
              m->v6.olsr_msgsize = htons(curr_size);
              m->v6.seqno = htons(get_msg_seqno());
@@ -773,8 +774,8 @@ serialize_tc6(struct tc_message *message, struct interface *ifp)
        }
       found = OLSR_TRUE;
 #ifdef DEBUG
-         olsr_printf(BMSG_DBGLVL, "\t%s\n", 
-                     olsr_ip_to_string(&mprs->address));
+         OLSR_PRINTF(BMSG_DBGLVL, "\t%s\n", 
+                     olsr_ip_to_string(&mprs->address))
 #endif
       COPY_IP(&mprsaddr6->addr, &mprs->address);
       curr_size += ipsize;
@@ -794,7 +795,7 @@ serialize_tc6(struct tc_message *message, struct interface *ifp)
     {
       if((!partial_sent) && (!TIMED_OUT(send_empty_tc)))
        {
-         olsr_printf(1, "TC: Sending empty package\n");
+         OLSR_PRINTF(1, "TC: Sending empty package\n")
            
          m->v6.olsr_msgsize = htons(curr_size);
          m->v6.seqno = htons(get_msg_seqno());
@@ -822,7 +823,7 @@ serialize_tc6(struct tc_message *message, struct interface *ifp)
 static olsr_bool
 serialize_mid4(struct interface *ifp)
 {
-  int remainsize, curr_size;
+  olsr_u16_t remainsize, curr_size;
   /* preserve existing data in output buffer */
   union olsr_message *m;
   struct midaddr *addrs;
@@ -868,7 +869,7 @@ serialize_mid4(struct interface *ifp)
              if(curr_size > OLSR_MID_IPV4_HDRSIZE)
                {
 #ifdef DEBUG
-                 olsr_printf(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize);
+                 OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize)
 #endif
                  /* set size */
                  m->v4.olsr_msgsize = htons(curr_size);
@@ -883,9 +884,9 @@ serialize_mid4(struct interface *ifp)
              check_buffspace(curr_size, remainsize, "MID2");
            }
 #ifdef DEBUG
-         olsr_printf(BMSG_DBGLVL, "\t%s(%s)\n", 
+         OLSR_PRINTF(BMSG_DBGLVL, "\t%s(%s)\n", 
                      olsr_ip_to_string(&ifs->ip_addr), 
-                     ifs->int_name);
+                     ifs->int_name)
 #endif
          
          COPY_IP(&addrs->addr, &ifs->ip_addr);
@@ -918,7 +919,7 @@ serialize_mid4(struct interface *ifp)
 static olsr_bool
 serialize_mid6(struct interface *ifp)
 {
-  int remainsize, curr_size;
+  olsr_u16_t remainsize, curr_size;
   /* preserve existing data in output buffer */
   union olsr_message *m;
   struct midaddr6 *addrs6;
@@ -966,7 +967,7 @@ serialize_mid6(struct interface *ifp)
              if(curr_size > OLSR_MID_IPV6_HDRSIZE)
                {
 #ifdef DEBUG
-                 olsr_printf(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize);
+                 OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize)
 #endif
                  /* set size */
                  m->v6.olsr_msgsize = htons(curr_size);
@@ -981,9 +982,9 @@ serialize_mid6(struct interface *ifp)
              check_buffspace(curr_size + ipsize, remainsize, "MID2");
            }
 #ifdef DEBUG
-                 olsr_printf(BMSG_DBGLVL, "\t%s(%s)\n", 
+                 OLSR_PRINTF(BMSG_DBGLVL, "\t%s(%s)\n", 
                              olsr_ip_to_string(&ifs->ip_addr), 
-                             ifs->int_name);
+                             ifs->int_name)
 #endif
 
          COPY_IP(&addrs6->addr, &ifs->ip_addr);
@@ -1013,7 +1014,7 @@ serialize_mid6(struct interface *ifp)
 static olsr_bool
 serialize_hna4(struct interface *ifp)
 {
-  int remainsize, curr_size;
+  olsr_u16_t remainsize, curr_size;
   /* preserve existing data in output buffer */
   union olsr_message *m;
   struct hnapair *pair;
@@ -1056,7 +1057,7 @@ serialize_hna4(struct interface *ifp)
          if(curr_size > OLSR_HNA_IPV4_HDRSIZE)
            {
 #ifdef DEBUG
-             olsr_printf(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize);
+             OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize)
 #endif
              m->v4.seqno = htons(get_msg_seqno());
              m->v4.olsr_msgsize = htons(curr_size);
@@ -1069,9 +1070,9 @@ serialize_hna4(struct interface *ifp)
          check_buffspace(curr_size + (2 * ipsize), remainsize, "HNA2");
        }
 #ifdef DEBUG
-      olsr_printf(BMSG_DBGLVL, "\tNet: %s/%s\n", 
+      OLSR_PRINTF(BMSG_DBGLVL, "\tNet: %s/%s\n", 
                  olsr_ip_to_string(&h->net),
-                 olsr_ip_to_string(&h->netmask));
+                 olsr_ip_to_string(&h->netmask))
 #endif
       COPY_IP(&pair->addr, &h->net);
       COPY_IP(&pair->netmask, &h->netmask);
@@ -1102,7 +1103,7 @@ serialize_hna4(struct interface *ifp)
 static olsr_bool
 serialize_hna6(struct interface *ifp)
 {
-  int remainsize, curr_size;
+  olsr_u16_t remainsize, curr_size;
   /* preserve existing data in output buffer */
   union olsr_message *m;
   struct hnapair6 *pair6;
@@ -1146,7 +1147,7 @@ serialize_hna6(struct interface *ifp)
          if(curr_size > OLSR_HNA_IPV6_HDRSIZE)
            {
 #ifdef DEBUG
-             olsr_printf(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize);
+             OLSR_PRINTF(BMSG_DBGLVL, "Sending partial(size: %d, buff left:%d)\n", curr_size, remainsize)
 #endif
              m->v6.seqno = htons(get_msg_seqno());
              m->v6.olsr_msgsize = htons(curr_size);
@@ -1159,9 +1160,9 @@ serialize_hna6(struct interface *ifp)
          check_buffspace(curr_size + (2 * ipsize), remainsize, "HNA2");
        }
 #ifdef DEBUG
-      olsr_printf(BMSG_DBGLVL, "\tNet: %s/%d\n", 
+      OLSR_PRINTF(BMSG_DBGLVL, "\tNet: %s/%d\n", 
                  olsr_ip_to_string(&h->net),
-                 h->prefix_len);
+                 h->prefix_len)
 #endif
       COPY_IP(&pair6->addr, &h->net);
       olsr_prefix_to_netmask(&tmp_netmask, h->prefix_len);