int
olsr_delete_neighbor_table(const union olsr_ip_addr *neighbor_addr)
{  
  struct  neighbor_2_list_entry *two_hop_list, *two_hop_to_delete;
  olsr_u32_t                    hash;
  struct neighbor_entry         *entry;

  //printf("inserting neighbor\n");

  hash = olsr_ip_hashing(neighbor_addr);

  entry = neighbortable[hash].next;

  /*
   * Find neighbor entry
   */
  while(entry != &neighbortable[hash])
    {
      if(ipequal(&entry->neighbor_main_addr, neighbor_addr))
	break;
      
      entry = entry->next;
    }

  if(entry == &neighbortable[hash])
    return 0;


  two_hop_list = entry->neighbor_2_list.next;

  while (two_hop_list != &entry->neighbor_2_list) {
      two_hop_to_delete = two_hop_list;
      two_hop_list = two_hop_list->next;

      two_hop_to_delete->neighbor_2->neighbor_2_pointer--;
      olsr_delete_neighbor_pointer(two_hop_to_delete->neighbor_2,
                                   &entry->neighbor_main_addr);

      olsr_del_nbr2_list(two_hop_to_delete);
    }


  /* Dequeue */
  DEQUEUE_ELEM(entry);

  free(entry);

  changes_neighborhood = OLSR_TRUE;
  return 1;

}
Exemple #2
0
/**
 * Delete a two hop neighbor from a neighbors two hop neighbor list.
 *
 * @param neighbor the neighbor to delete the two hop neighbor from.
 * @param address the IP address of the two hop neighbor to delete.
 *
 * @return positive if entry deleted
 */
int
olsr_delete_neighbor_2_pointer(struct neighbor_entry *neighbor, struct neighbor_2_entry *neigh2)
{
  struct neighbor_2_list_entry *nbr2_list;

  nbr2_list = neighbor->neighbor_2_list.next;

  while (nbr2_list != &neighbor->neighbor_2_list) {
    if (nbr2_list->neighbor_2 == neigh2) {
      olsr_del_nbr2_list(nbr2_list);
      return 1;
    }
    nbr2_list = nbr2_list->next;
  }
  return 0;
}
/**
 * Delete a two hop neighbor from a neighbors two hop neighbor list.
 *
 * @param neighbor the neighbor to delete the two hop neighbor from.
 * @param address the IP address of the two hop neighbor to delete.
 *
 * @return positive if entry deleted
 */
int
olsr_delete_neighbor_2_pointer(struct neighbor_entry *neighbor, union olsr_ip_addr *address)
{
  struct neighbor_2_list_entry *nbr2_list;
  
  nbr2_list = neighbor->neighbor_2_list.next;

  while (nbr2_list != &neighbor->neighbor_2_list) {
    if (ipequal(&nbr2_list->neighbor_2->neighbor_2_addr, address)) {
      olsr_del_nbr2_list(nbr2_list);
      return 1;	  
    }
    nbr2_list = nbr2_list->next;      
  }
  return 0;
}
Exemple #4
0
/**
 * Callback for the nbr2_list timer.
 */
void
olsr_expire_nbr2_list(void *context)
{
  struct neighbor_2_list_entry *nbr2_list;
  struct neighbor_entry *nbr;
  struct neighbor_2_entry *nbr2;

  nbr2_list = (struct neighbor_2_list_entry *)context;
  nbr2_list->nbr2_list_timer = NULL;

  nbr = nbr2_list->nbr2_nbr;
  nbr2 = nbr2_list->neighbor_2;

  nbr2->neighbor_2_pointer--;
  olsr_delete_neighbor_pointer(nbr2, nbr);

  olsr_del_nbr2_list(nbr2_list);
}