From Sven-Ola Tuecke: 138-optimize-message-generation
authorHannes Gredler <hannes@gredler.at>
Fri, 28 Dec 2007 10:58:48 +0000 (11:58 +0100)
committerHannes Gredler <hannes@gredler.at>
Fri, 28 Dec 2007 10:58:48 +0000 (11:58 +0100)
lib/nameservice/src/nameservice.c
src/interfaces.h
src/lq_packet.c
src/unix/ifnet.c
src/win32/ifnet.c

index a435220..086ef73 100644 (file)
@@ -562,43 +562,43 @@ olsr_event(void *foo __attribute__((unused)))
        struct interface *ifn;
        int namesize;
 
+       /* fill message */
+       if(olsr_cnf->ip_version == AF_INET)
+       {
+               /* IPv4 */
+               message->v4.olsr_msgtype = MESSAGE_TYPE;
+               message->v4.olsr_vtime = double_to_me(my_timeout);
+               memcpy(&message->v4.originator, &olsr_cnf->main_addr, olsr_cnf->ipsize);
+               message->v4.ttl = MAX_TTL;
+               message->v4.hopcnt = 0;
+               message->v4.seqno = htons(get_msg_seqno());
+
+               namesize = encap_namemsg((struct namemsg*)&message->v4.message);
+               namesize = namesize + sizeof(struct olsrmsg);
+
+               message->v4.olsr_msgsize = htons(namesize);
+       }
+       else
+       {
+               /* IPv6 */
+               message->v6.olsr_msgtype = MESSAGE_TYPE;
+               message->v6.olsr_vtime = double_to_me(my_timeout);
+               memcpy(&message->v6.originator, &olsr_cnf->main_addr, olsr_cnf->ipsize);
+               message->v6.ttl = MAX_TTL;
+               message->v6.hopcnt = 0;
+               message->v6.seqno = htons(get_msg_seqno());
+
+               namesize = encap_namemsg((struct namemsg*)&message->v6.message);
+               namesize = namesize + sizeof(struct olsrmsg6);
+               
+               message->v6.olsr_msgsize = htons(namesize);
+       }
+
        /* looping trough interfaces */
        for (ifn = ifnet; ifn ; ifn = ifn->int_next) 
        {
                OLSR_PRINTF(3, "NAME PLUGIN: Generating packet - [%s]\n", ifn->int_name);
 
-               /* fill message */
-               if(olsr_cnf->ip_version == AF_INET)
-               {
-                       /* IPv4 */
-                       message->v4.olsr_msgtype = MESSAGE_TYPE;
-                       message->v4.olsr_vtime = double_to_me(my_timeout);
-                       memcpy(&message->v4.originator, &olsr_cnf->main_addr, olsr_cnf->ipsize);
-                       message->v4.ttl = MAX_TTL;
-                       message->v4.hopcnt = 0;
-                       message->v4.seqno = htons(get_msg_seqno());
-                       
-                       namesize = encap_namemsg((struct namemsg*)&message->v4.message);
-                       namesize = namesize + sizeof(struct olsrmsg);
-                       
-                       message->v4.olsr_msgsize = htons(namesize);
-               }
-               else
-               {
-                       /* IPv6 */
-                       message->v6.olsr_msgtype = MESSAGE_TYPE;
-                       message->v6.olsr_vtime = double_to_me(my_timeout);
-                       memcpy(&message->v6.originator, &olsr_cnf->main_addr, olsr_cnf->ipsize);
-                       message->v6.ttl = MAX_TTL;
-                       message->v6.hopcnt = 0;
-                       message->v6.seqno = htons(get_msg_seqno());
-                       
-                       namesize = encap_namemsg((struct namemsg*)&message->v6.message);
-                       namesize = namesize + sizeof(struct olsrmsg6);
-                       
-                       message->v6.olsr_msgsize = htons(namesize);
-               }
-               
                if(net_outbuffer_push(ifn, message, namesize) != namesize ) {
                        /* send data and try again */
                        net_output(ifn);
index 0b549e4..2585774 100644 (file)
@@ -162,6 +162,8 @@ struct interface
   struct        if_gen_property *gen_properties;/* Generic interface properties */
   
   int           ttl_index; /* index in TTL array for fish-eye */
+  
+  olsr_bool    immediate_send_tc; /* Hello's are sent immediately normally, this flag prefers to send TC's */
 
   struct       interface *int_next;
 };
index 916e54a..82f61ba 100644 (file)
@@ -638,7 +638,7 @@ olsr_output_lq_hello(void *para)
   // destroy internal format
   destroy_lq_hello(&lq_hello);
 
-  if(net_output_pending(outif)) {
+  if(net_output_pending(outif) && (!outif->immediate_send_tc || TIMED_OUT(outif->fwdtimer))) {
     net_output(outif);
   }
 }
@@ -685,7 +685,7 @@ olsr_output_lq_tc(void *para)
 
   destroy_lq_tc(&lq_tc);
 
-  if(net_output_pending(outif) && TIMED_OUT(outif->fwdtimer)) {
+  if(net_output_pending(outif) && (outif->immediate_send_tc || TIMED_OUT(outif->fwdtimer))) {
     set_buffer_timer(outif);
   }
 }
index 2cf0cec..2c6bf6a 100644 (file)
@@ -935,6 +935,8 @@ chk_if_up(struct olsr_if *iface, int debuglvl __attribute__((unused)))
     }
   
   ifp = olsr_malloc(sizeof (struct interface), "Interface update 2");
+  
+  ifp->immediate_send_tc = (iface->cnf->tc_params.emission_interval < iface->cnf->hello_params.emission_interval);
 
   iface->configured = 1;
   iface->interf = ifp;
index beb9183..752ea31 100644 (file)
@@ -954,6 +954,9 @@ int chk_if_up(struct olsr_if *IntConf, int DebugLevel __attribute__((unused)))
     return 0;
 
   New = olsr_malloc(sizeof (struct interface), "Interface 1");
+
+  New->immediate_send_tc = (IntConf->cnf->tc_params.emission_interval < IntConf->cnf->hello_params.emission_interval);
+
   New->gen_properties = NULL;
 
   AddrIn = (struct sockaddr_in *)&New->int_addr;