[Olsr-cvs] olsrd-current/src interfaces.h, 1.49, 1.50 interfaces.c, 1.39, 1.40

Bernd Petrovitsch (spam-protected)
Thu Dec 6 22:12:58 CET 2007


Update of /cvsroot/olsrd/olsrd-current/src
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17207/src

Modified Files:
	interfaces.h interfaces.c 
Log Message:
* removed the unused functions get_if_property_id(), add_if_geninfo(),
  get_if_geninfo(), del_if_geninfo()
* if_ifwithindex() is used only locally: made it "static"
* Simplified a little bit: addrsock and addrsock6 are defined and
  initialized in interfaces.c, used in src/*/net.c and passed as parameter
  to the functions getsocket{,6}() in src/*/ifnet.c.
  We now just define and initialize that locally.


Index: interfaces.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/interfaces.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -d -r1.39 -r1.40
*** interfaces.c	2 Dec 2007 19:00:27 -0000	1.39
--- interfaces.c	6 Dec 2007 21:12:56 -0000	1.40
***************
*** 48,60 ****
  #include "ipcalc.h"
  
! static olsr_u32_t if_property_id;
  
  /* The interface linked-list */
  struct interface *ifnet;
  
- /* Datastructures to use when creating new sockets */
- struct sockaddr_in addrsock;
- struct sockaddr_in6 addrsock6;
- 
  
  /* Ifchange functions */
--- 48,56 ----
  #include "ipcalc.h"
  
! static struct interface *if_ifwithindex(const int if_index);
  
  /* The interface linked-list */
  struct interface *ifnet;
  
  
  /* Ifchange functions */
***************
*** 83,107 ****
    ifnet = NULL;
  
-   /*
-    *Initializing addrsock struct to be
-    *used on all the sockets
-    */
-   if(olsr_cnf->ip_version == AF_INET)
-     {
-       /* IP version 4 */
-       memset(&addrsock, 0, sizeof (addrsock));
-       addrsock.sin_family = AF_INET;
-       addrsock.sin_port = htons(OLSRPORT);
-       (addrsock.sin_addr).s_addr = INADDR_ANY;
-     }
-   else
-     {
-       /* IP version 6 */
-       memset(&addrsock6, 0, sizeof (addrsock6));
-       addrsock6.sin6_family = AF_INET6;
-       addrsock6.sin6_port = htons(OLSRPORT);
-       //(addrsock6.sin6_addr).s_addr = IN6ADDR_ANY_INIT;
-     }
- 
    OLSR_PRINTF(1, "\n ---- Interface configuration ---- \n\n");
      /* Run trough all interfaces immedeatly */
--- 79,82 ----
***************
*** 124,209 ****
  }
  
- 
- olsr_u32_t
- get_if_property_id(void)
- {
-   return if_property_id++;
- }
- 
- olsr_bool
- add_if_geninfo(struct interface *ifp, void *data, olsr_u32_t owner_id)
- {
-   struct if_gen_property *igp;
- 
-   if(get_if_geninfo(ifp, owner_id) != NULL)
-     return OLSR_FALSE;
- 
-   igp = olsr_malloc(sizeof(struct if_gen_property), __func__);
- 
-   igp->owner_id = owner_id;
-   igp->data = data;
- 
-   /* queue */
-   igp->next = ifp->gen_properties;
-   ifp->gen_properties = igp;
- 
-   return OLSR_TRUE;
- }
- 
- void *
- get_if_geninfo(struct interface *ifp, olsr_u32_t owner_id)
- {
-   struct if_gen_property *igp_list = ifp->gen_properties;
- 
- 
-   while(igp_list)
-     {
-       if(igp_list->owner_id == owner_id)
- 	return igp_list->data;
- 
-       igp_list = igp_list->next;
-     }
- 
-   return NULL;
- }
- 
- void *
- del_if_geninfo(struct interface *ifp, olsr_u32_t owner_id)
- {
-   void *data = NULL;
-   struct if_gen_property *igp_list = ifp->gen_properties;
-   struct if_gen_property *igp_prev = NULL;
- 
- 
-   while(igp_list)
-     {
-       if(igp_list->owner_id == owner_id)
- 	break;
- 
-       igp_prev = igp_list;
-       igp_list = igp_list->next;
-     }
- 
-   /* Not found */
-   if(igp_list == NULL)
-     return NULL;
- 
-   /* Dequeue */
-   if(igp_prev == NULL)
-     {
-       /* First elem */
-       ifp->gen_properties = igp_list->next;
-     }
-   else
-     {
-       igp_prev->next = igp_list->next;
-     }
-   data = igp_list->data;
-   free(igp_list);
- 
-   return data;
- }
- 
- 
  void
  run_ifchg_cbs(struct interface *ifp, int flag)
--- 99,102 ----
***************
*** 297,315 ****
  if_ifwithname(const char *if_name)
  {
!   struct interface *ifp;
!   ifp = ifnet;
! 
!   while (ifp) 
!     {
!       /* good ol' strcmp should be sufficcient here */
!       if (!strcmp(ifp->int_name, if_name))
! 	return ifp;
!       ifp = ifp->int_next;
      }
!   
    return NULL;
  }
  
- 
  /**
   *Find the interface with a given interface index.
--- 190,204 ----
  if_ifwithname(const char *if_name)
  {
!   struct interface *ifp = ifnet;
!   while (ifp) {
!     /* good ol' strcmp should be sufficcient here */
!     if (strcmp(ifp->int_name, if_name) == 0) {
!       return ifp;
      }
!     ifp = ifp->int_next;
!   }
    return NULL;
  }
  
  /**
   *Find the interface with a given interface index.
***************
*** 320,337 ****
   *that matched the iif_index.
   */
! struct interface *
  if_ifwithindex(const int if_index)
  {
    struct interface *ifp = ifnet;
!   while (ifp) 
!     {
!       if (ifp->if_index == if_index)
!         return ifp;
        ifp = ifp->int_next;
!     }
    return NULL;
  }
  
- 
  /**
   *Get an interface name for a given interface index
--- 209,225 ----
   *that matched the iif_index.
   */
! static struct interface *
  if_ifwithindex(const int if_index)
  {
    struct interface *ifp = ifnet;
!   while (ifp != NULL) {
!       if (ifp->if_index == if_index) {
!           return ifp;
!       }
        ifp = ifp->int_next;
!   }
    return NULL;
  }
  
  /**
   *Get an interface name for a given interface index

Index: interfaces.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/interfaces.h,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -d -r1.49 -r1.50
*** interfaces.h	29 Nov 2007 17:09:16 -0000	1.49
--- interfaces.h	6 Dec 2007 21:12:56 -0000	1.50
***************
*** 1,5 ****
  /*
   * The olsr.org Optimized Link-State Routing daemon(olsrd)
!  * Copyright (c) 2004, Andreas Tønnesen((spam-protected))
   * All rights reserved.
   *
--- 1,5 ----
  /*
   * The olsr.org Optimized Link-State Routing daemon(olsrd)
!  * Copyright (c) 2004, Andreas Tønnesen((spam-protected))
   * All rights reserved.
   *
***************
*** 175,198 ****
  extern struct interface *ifnet;
  
- /* Datastructures to use when creating new sockets */
- extern struct sockaddr_in addrsock;
- extern struct sockaddr_in6 addrsock6;
- 
- 
  int
  ifinit(void);
  
- olsr_u32_t
- get_if_property_id(void);
- 
- olsr_bool
- add_if_geninfo(struct interface *, void *, olsr_u32_t);
- 
- void *
- get_if_geninfo(struct interface *, olsr_u32_t);
- 
- void *
- del_if_geninfo(struct interface *, olsr_u32_t);
- 
  void
  run_ifchg_cbs(struct interface *, int);
--- 175,181 ----
***************
*** 207,213 ****
  if_ifwithname(const char *);
  
- struct interface *
- if_ifwithindex(const int if_index);
- 
  const char *
  if_ifwithindex_name(const int if_index);
--- 190,193 ----





More information about the Olsr-cvs mailing list