/** *Links a one-hop neighbor with a 2-hop neighbor. * *@param neighbor the 1-hop neighbor *@param two_hop_neighbor the 2-hop neighbor *@return nada */ static void linking_this_2_entries(struct neighbor_entry *neighbor, struct neighbor_2_entry *two_hop_neighbor, olsr_reltime vtime) { struct neighbor_list_entry *list_of_1_neighbors = olsr_malloc(sizeof(struct neighbor_list_entry), "Link entries 1"); struct neighbor_2_list_entry *list_of_2_neighbors = olsr_malloc(sizeof(struct neighbor_2_list_entry), "Link entries 2"); list_of_1_neighbors->neighbor = neighbor; list_of_1_neighbors->path_linkcost = LINK_COST_BROKEN; list_of_1_neighbors->saved_path_linkcost = LINK_COST_BROKEN; list_of_1_neighbors->second_hop_linkcost = LINK_COST_BROKEN; /* Queue */ two_hop_neighbor->neighbor_2_nblist.next->prev = list_of_1_neighbors; list_of_1_neighbors->next = two_hop_neighbor->neighbor_2_nblist.next; two_hop_neighbor->neighbor_2_nblist.next = list_of_1_neighbors; list_of_1_neighbors->prev = &two_hop_neighbor->neighbor_2_nblist; list_of_2_neighbors->neighbor_2 = two_hop_neighbor; list_of_2_neighbors->nbr2_nbr = neighbor; /* XXX refcount */ olsr_change_timer(list_of_2_neighbors->nbr2_list_timer, vtime, OLSR_NBR2_LIST_JITTER, OLSR_TIMER_ONESHOT); /* Queue */ neighbor->neighbor_2_list.next->prev = list_of_2_neighbors; list_of_2_neighbors->next = neighbor->neighbor_2_list.next; neighbor->neighbor_2_list.next = list_of_2_neighbors; list_of_2_neighbors->prev = &neighbor->neighbor_2_list; /*increment the pointer counter */ two_hop_neighbor->neighbor_2_pointer++; }
/** *Create a new interf_name struct using a given *name and insert it into the interface list. * *@param name the name of the interface. * *@return nada */ struct olsr_if * queue_if(const char *name, int hemu) { struct olsr_if *interf_n = olsr_cnf->interfaces; size_t name_size; //printf("Adding interface %s\n", name); /* check if the inerfaces already exists */ while(interf_n != NULL) { if(memcmp(interf_n->name, name, strlen(name)) == 0) { fprintf(stderr, "Duplicate interfaces defined... not adding %s\n", name); return NULL; } interf_n = interf_n->next; } interf_n = olsr_malloc(sizeof(struct olsr_if), "queue interface"); name_size = strlen(name) + 1; interf_n->name = olsr_malloc(name_size, "queue interface name"); interf_n->cnf = NULL; interf_n->interf = NULL; interf_n->configured = 0; interf_n->host_emul = hemu ? OLSR_TRUE : OLSR_FALSE; strscpy(interf_n->name, name, name_size); interf_n->next = olsr_cnf->interfaces; olsr_cnf->interfaces = interf_n; return interf_n; }
olsr_pktbuf_t * olsr_pktbuf_alloc_with_capa(const size_t capa) { // olsr_pktbuf_t *r = (olsr_pktbuf_t *)malloc(sizeof(olsr_pktbuf_t)); olsr_pktbuf_t *r = (olsr_pktbuf_t *)olsr_malloc(sizeof(olsr_pktbuf_t), __FUNCTION__); r->capa = capa; r->data = (olsr_u8_t *)olsr_malloc(capa, "olsr_pktbuf_t:data"); r->len = 0; r->p = r->data; return r; }
void insert_association_set(struct olsrv2 *olsr, OLSR_LIST *iface_list, double validity_time){ OLSR_LIST_ENTRY **entry = NULL, *iface_entry = NULL; OLSR_LOCAL_INTERFACE_BLOCK_ENTRY *local_iface_data = NULL; int i,j, seq, listNum; OLSR_ASSOCIATION_TUPLE *data = NULL; listNum = iface_list->numEntry; entry = (OLSR_LIST_ENTRY **)olsr_malloc(listNum * sizeof(OLSR_LIST_ENTRY *), __FUNCTION__); for(i = 0; i < listNum; i++) { entry[i] = (OLSR_LIST_ENTRY *)olsr_malloc(sizeof(OLSR_LIST_ENTRY), __FUNCTION__); entry[i]->data = (OLSR_ASSOCIATION_TUPLE *)olsr_malloc(sizeof(OLSR_ASSOCIATION_TUPLE), __FUNCTION__); entry[i]->size = sizeof(OLSR_ASSOCIATION_TUPLE); } iface_entry = iface_list->head; i = 0; while(iface_entry) { local_iface_data = (OLSR_LOCAL_INTERFACE_BLOCK_ENTRY *)iface_entry->data; data = (OLSR_ASSOCIATION_TUPLE *)entry[i]->data; get_current_time(olsr, &data->NA_time); update_time(&data->NA_time, (olsr_32_t)validity_time); olsr_ip_copy(olsr, &data->NA_iface_addr, &local_iface_data->iface_addr); data->num_NAlist = listNum -1; data->NA_list = (OLSR_LIST_ENTRY **)olsr_malloc(sizeof(OLSR_LIST_ENTRY*) * (listNum-1), __FUNCTION__); seq = 0; for(j = 0; j < listNum; j++) { if(i == j) continue; data->NA_list[seq++] = entry[j]; } OLSR_InsertListEntry(&olsr->associ_set[olsr_hashing(olsr,&data->NA_iface_addr)].list, entry[i]); iface_entry = iface_entry->next; i++; } free(entry); }
inline static char * get_multi_value_address_tlv(char *msg_ptr, struct tlv_tuple_local *tuple) { int i; if(tuple->one_field_size > sizeof(olsr_u32_t)){ if(DEBUG_OLSRV2) { olsr_printf("Not Support\n"); } tuple->extended_value = (olsr_u8_t* )olsr_malloc(tuple->length, __FUNCTION__); memcpy(tuple->extended_value, msg_ptr, tuple->length); msg_ptr += tuple->length; }else{ tuple->multi_value = (olsr_u32_t* )olsr_malloc(sizeof(olsr_u32_t) * tuple->number_value, __FUNCTION__); for(i = 0; i < tuple->number_value; i++){ switch(tuple->one_field_size){ case sizeof(olsr_u8_t): { olsr_u8_t v = *(olsr_u8_t *)msg_ptr; msg_ptr += tuple->one_field_size; tuple->multi_value[i] = v; break; } case sizeof(olsr_u16_t): { olsr_u16_t v = *(olsr_u16_t *)msg_ptr; msg_ptr += tuple->one_field_size; tuple->multi_value[i] = ntohs(v); break; } case sizeof(olsr_u32_t): { olsr_u32_t v = *(olsr_u32_t *)msg_ptr; msg_ptr += tuple->one_field_size; tuple->multi_value[i] = ntohl(v); break; } }//for }//if } return msg_ptr; }
/** Initialise the position average list: allocate memory for the entries and reset fields. @param positionAverageList The position average list @param maxEntries The maximum number of entries in the list (the number of entries that should be averaged) @return - false on failure - true otherwise */ bool initPositionAverageList(PositionAverageList * positionAverageList, unsigned long long maxEntries) { void * p; if (positionAverageList == NULL) { return false; } if (maxEntries < 2) { return false; } p = olsr_malloc((maxEntries + 1) * sizeof(PositionUpdateEntry), "PositionAverageEntry entries for PositionAverageList (PUD)"); if (p == NULL) { return false; } positionAverageList->entriesMaxCount = maxEntries; positionAverageList->entries = p; positionAverageList->newestEntryIndex = 0; flushPositionAverageList(positionAverageList); return true; }
unsigned char *zpacket_redistribute (uint16_t cmd, unsigned char type) { unsigned char *data, *pnt; uint16_t size; data = olsr_malloc(ZEBRA_MAX_PACKET_SIZ , "QUAGGA: New redistribute packet"); pnt = &data[2]; switch (zebra.version) { case 0: *pnt++ = (unsigned char) cmd; break; case 1: case 2: *pnt++ = ZEBRA_HEADER_MARKER; *pnt++ = zebra.version; cmd = htons(cmd); memcpy(pnt, &cmd, sizeof cmd); pnt += sizeof cmd; break; default: olsr_exit("(QUAGGA) Unsupported zebra packet version!\n", EXIT_FAILURE); break; } *pnt++ = type; size = htons(pnt - data); memcpy(data, &size, sizeof size); return data; }
/** *Insert a plc peer entry in the table * *@param main_addr the main address of the new node * *@return 0 if plc peer already exists 1 if inserted */ struct plc_peer_entry * insert_plc_peer_neighbor(const union olsr_ip_addr *main_addr, unsigned char *mac) { uint32_t hash; struct plc_peer_entry *new_peer; hash = olsr_ip_hashing(main_addr); /* Check if entry exists */ for (new_peer = plc_peer_neighbors[hash].next; new_peer != &plc_peer_neighbors[hash]; new_peer = new_peer->next) { if (ipequal(&new_peer->plc_peer_main_addr, main_addr)) return 0; } //olsr_printf(3, "inserting peer\n"); new_peer = olsr_malloc(sizeof(struct plc_peer_entry), "New peer entry"); /* Set address, willingness and status */ new_peer->plc_peer_main_addr = *main_addr; memcpy(new_peer->plc_data.mac, mac, 6); /* Queue */ QUEUE_ELEM(plc_peer_neighbors[hash], new_peer); table_size++; return 1; }
OLSR_LIST * search_proc_set(struct olsrv2 *olsr, union olsr_ip_addr orig_addr, olsr_u16_t seq_number, olsr_u8_t type) { OLSR_LIST *result = NULL; //WIN FIX: explicit typecast required char *search = (char *)olsr_malloc(sizeof(union olsr_ip_addr)+sizeof(olsr_u16_t)+sizeof(olsr_u8_t), __FUNCTION__); memcpy(search, &orig_addr, sizeof(union olsr_ip_addr)); search += sizeof(union olsr_ip_addr); memcpy(search, &seq_number, sizeof(olsr_u16_t)); search += sizeof(olsr_u16_t); memcpy(search, &type, sizeof(olsr_u8_t)); search -= sizeof(olsr_u16_t); search -= sizeof(union olsr_ip_addr); //struct olsrv2 result = OLSR_SearchList((void*)olsr,&olsr->proc_set[olsr_hashing(olsr,&orig_addr)].list, (void* )&search, &search_proc_set_handler); free(search); return result; }
/** * olsr_malloc_tc_mpr_addr * * this function allocates memory for an tc_mpr_addr inclusive * linkquality data. * * @param id string for memory debugging * * @return pointer to tc_mpr_addr */ struct tc_mpr_addr * olsr_malloc_tc_mpr_addr(const char *id) { struct tc_mpr_addr *t; t = olsr_malloc(sizeof(struct tc_mpr_addr) + active_lq_handler->tc_lq_size, id); assert((const char *)t + sizeof(*t) >= (const char *)t->linkquality); active_lq_handler->clear_tc(t->linkquality); return t; }
/** * olsr_malloc_link_entry * * this function allocates memory for an link_entry inclusive * linkquality data. * * @param id string for memory debugging * * @return pointer to link_entry */ struct link_entry * olsr_malloc_link_entry(const char *id) { struct link_entry *h; h = olsr_malloc(sizeof(struct link_entry) + active_lq_handler->hello_lq_size, id); assert((const char *)h + sizeof(*h) >= (const char *)h->linkquality); active_lq_handler->clear_hello(h->linkquality); return h; }
/* * Adds the given IP-address to the invalid list. */ void olsr_add_invalid_address(const union olsr_ip_addr *adr) { struct ipaddr_str buf; struct deny_address_entry *new_entry = olsr_malloc(sizeof(struct deny_address_entry), "Add deny address"); new_entry->addr = *adr; new_entry->next = deny_entries; deny_entries = new_entry; OLSR_PRINTF(1, "Added %s to IP deny set\n", olsr_ip_to_string(&buf, &new_entry->addr)); }
/** * olsr_malloc_hello_neighbor * * this function allocates memory for an hello_neighbor inclusive * linkquality data. * * @param id string for memory debugging * * @return pointer to hello_neighbor */ struct hello_neighbor * olsr_malloc_hello_neighbor(const char *id) { struct hello_neighbor *h; h = olsr_malloc(sizeof(struct hello_neighbor) + active_lq_handler->hello_lq_size, id); assert((const char *)h + sizeof(*h) >= (const char *)h->linkquality); active_lq_handler->clear_hello(h->linkquality); return h; }
olsr_pktbuf_t * olsr_pktbuf_alloc_child(olsr_pktbuf_t *buf, size_t len) { if (olsr_pktbuf_remain(buf) < len) return NULL; olsr_pktbuf_t *r = (olsr_pktbuf_t *)olsr_malloc(sizeof(olsr_pktbuf_t), __FUNCTION__); r->capa = 0; r->len = len; r->data = r->p = buf->p; buf->p += len; // increments the pointer of the parent buffer return r; }
/** * set_lq_handler * * this function is used by routing metric plugins to activate their link * quality handler * * The name parameter is marked as "unused" to squelch a compiler warning if debug * output is not active * * @param pointer to lq_handler structure * @param name of the link quality handler for debug output */ void register_lq_handler(struct lq_handler *handler, const char *name) { struct lq_handler_node *node; size_t name_size = sizeof(*node) + strlen(name) + 1; node = olsr_malloc(name_size, "olsr lq handler"); strscpy(node->name, name, name_size); node->node.key = node->name; node->handler = handler; avl_insert(&lq_handler_tree, &node->node, false); }
void register_pcf(int (*f) (int, int, int)) { struct pcf *new_pcf; OLSR_PRINTF(1, "Registering pcf function\n"); new_pcf = olsr_malloc(sizeof(struct pcf), "New PCF"); new_pcf->function = f; new_pcf->next = pcf_list; pcf_list = new_pcf; }
struct dup_entry * olsr_create_duplicate_entry(void *ip, uint16_t seqnr) { struct dup_entry *entry; entry = olsr_malloc(sizeof(struct dup_entry), "New duplicate entry"); if (entry != NULL) { memcpy(&entry->ip, ip, olsr_cnf->ip_version == AF_INET ? sizeof(entry->ip.v4) : sizeof(entry->ip.v6)); entry->seqnr = seqnr; entry->too_low_counter = 0; entry->avl.key = &entry->ip; entry->array = 0; } return entry; }
/** * Sets the provided configuration on all unconfigured * interfaces * * @param ifs a linked list of interfaces to check and possible update * @param cnf the default configuration to set on unconfigured interfaces */ int set_default_ifcnfs(struct olsr_if *ifs, struct if_config_options *cnf) { int changes = 0; while (ifs) { if (ifs->cnf == NULL) { ifs->cnf = olsr_malloc(sizeof(struct if_config_options), "Set default config"); *ifs->cnf = *cnf; changes++; } ifs = ifs->next; } return changes; }
/** *Find all 2 hop neighbors with 1 link *connecting them to us trough neighbors *with a given willingness. * *@param willingness the willigness of the neighbors * *@return a linked list of allocated neighbor_2_list_entry structures */ static struct neighbor_2_list_entry * olsr_find_2_hop_neighbors_with_1_link(int willingness) { uint8_t idx; struct neighbor_2_list_entry *two_hop_list_tmp = NULL; struct neighbor_2_list_entry *two_hop_list = NULL; struct neighbor_entry *dup_neighbor; struct neighbor_2_entry *two_hop_neighbor = NULL; for (idx = 0; idx < HASHSIZE; idx++) { for (two_hop_neighbor = two_hop_neighbortable[idx].next; two_hop_neighbor != &two_hop_neighbortable[idx]; two_hop_neighbor = two_hop_neighbor->next) { //two_hop_neighbor->neighbor_2_state=0; //two_hop_neighbor->mpr_covered_count = 0; dup_neighbor = olsr_lookup_neighbor_table(&two_hop_neighbor->neighbor_2_addr); if ((dup_neighbor != NULL) && (dup_neighbor->status != NOT_SYM)) { //OLSR_PRINTF(1, "(1)Skipping 2h neighbor %s - already 1hop\n", olsr_ip_to_string(&buf, &two_hop_neighbor->neighbor_2_addr)); continue; } if (two_hop_neighbor->neighbor_2_pointer == 1) { if ((two_hop_neighbor->neighbor_2_nblist.next->neighbor->willingness == willingness) && (two_hop_neighbor->neighbor_2_nblist.next->neighbor->status == SYM)) { two_hop_list_tmp = olsr_malloc(sizeof(struct neighbor_2_list_entry), "MPR two hop list"); //OLSR_PRINTF(1, "ONE LINK ADDING %s\n", olsr_ip_to_string(&buf, &two_hop_neighbor->neighbor_2_addr)); /* Only queue one way here */ two_hop_list_tmp->neighbor_2 = two_hop_neighbor; two_hop_list_tmp->next = two_hop_list; two_hop_list = two_hop_list_tmp; } } } } return (two_hop_list_tmp); }
/** *Create a new interf_name struct using a given *name and insert it into the interface list. * *@param name the name of the interface. * *@return nada */ struct olsr_if * olsr_create_olsrif(const char *name, int hemu) { struct olsr_if *interf_n = olsr_cnf->interfaces; size_t name_size; //printf("Adding interface %s\n", name); /* check if the inerfaces already exists */ while (interf_n != NULL) { if (strcmp(interf_n->name, name) == 0) { fprintf(stderr, "Duplicate interfaces defined... not adding %s\n", name); return NULL; } interf_n = interf_n->next; } interf_n = olsr_malloc(sizeof(struct olsr_if), "queue interface"); name_size = strlen(name) + 1; interf_n->name = olsr_malloc(name_size, "queue interface name"); strscpy(interf_n->name, name, name_size); interf_n->cnf = olsr_malloc(sizeof(*interf_n->cnf), "queue cnf"); interf_n->cnfi = olsr_malloc(sizeof(*interf_n->cnfi), "queue cnfi"); memset(interf_n->cnfi, 0xFF, sizeof(*interf_n->cnfi)); interf_n->cnfi->orig_lq_mult_cnt=0; interf_n->host_emul = hemu ? true : false; interf_n->next = olsr_cnf->interfaces; olsr_cnf->interfaces = interf_n; return interf_n; }
/** *Add an ifchange function. These functions are called on all (non-initial) *changes in the interface set. * *@param * *@return */ int olsr_add_ifchange_handler(void (*f) (int if_index, struct interface *, enum olsr_ifchg_flag)) { struct ifchgf *new_ifchgf; new_ifchgf = olsr_malloc(sizeof(struct ifchgf), "Add ifchgfunction"); new_ifchgf->next = ifchgf_list; new_ifchgf->function = f; ifchgf_list = new_ifchgf; return 1; }
/** * Add a packet transform function. Theese are functions * called just prior to sending data in a buffer. * * @param f the function pointer * * @returns 1 */ int add_ptf(packet_transform_function f) { struct ptf *new_ptf; new_ptf = olsr_malloc(sizeof(struct ptf), "Add PTF"); new_ptf->next = ptf_list; new_ptf->function = f; ptf_list = new_ptf; return 1; }
/** *Add an ifchange function. These functions are called on all (non-initial) *changes in the interface set. * *@param * *@return */ int add_ifchgf(int (*f)(struct interface *, int)) { struct ifchgf *new_ifchgf; new_ifchgf = olsr_malloc(sizeof(struct ifchgf), "Add ifchgfunction"); new_ifchgf->next = ifchgf_list; new_ifchgf->function = f; ifchgf_list = new_ifchgf; return 1; }
/** * queue the name/forwarder/service given in value * to the front of my_list */ struct name_entry* add_name_to_list(struct name_entry *my_list, const char *value, int type, const union olsr_ip_addr *ip) { struct name_entry *tmp = olsr_malloc(sizeof(struct name_entry), "new name_entry add_name_to_list"); tmp->name = strndup( value, MAX_NAME ); tmp->len = strlen( tmp->name ); tmp->type = type; // all IPs with value 0 will be set to main_addr later if (ip==NULL) memset(&tmp->ip, 0, sizeof(tmp->ip)); else tmp->ip = *ip; tmp->next = my_list; return tmp; }
/** Create a receive interface and add it to the list of receive network interface objects @param ifName the network interface name @param rxSocketHandlerFunction the function that handles reception of data on the network interface @param rxMcAddr The receive multicast address @return - true on success - false on failure */ static bool createRxInterface(const char * ifName, socket_handler_func rxSocketHandlerFunction, union olsr_sockaddr * rxMcAddr) { int socketFd = -1; TRxTxNetworkInterface * networkInterface = NULL; if (ifName == NULL) { goto bail; } networkInterface = olsr_malloc(sizeof(TRxTxNetworkInterface), "TRxTxNetworkInterface (PUD)"); if (networkInterface == NULL) { goto bail; } memcpy(networkInterface->name, ifName, sizeof(networkInterface->name)); networkInterface->name[IFNAMSIZ] = '\0'; networkInterface->handler = NULL; networkInterface->next = NULL; /* networkInterface needs to be filled in when calling createRxSocket */ socketFd = createRxSocket(networkInterface, rxSocketHandlerFunction, rxMcAddr); if (socketFd < 0) { goto bail; } networkInterface->socketFd = socketFd; networkInterface->handler = rxSocketHandlerFunction; /* Add new object to the end of the global list. */ if (rxNetworkInterfacesListHead == NULL) { rxNetworkInterfacesListHead = networkInterface; lastRxNetworkInterface = networkInterface; } else { lastRxNetworkInterface->next = networkInterface; lastRxNetworkInterface = networkInterface; } return true; bail: if (networkInterface != NULL) { free(networkInterface); } return false; }
static int insert_plugin_ipnet(const char *sz_net, const char *sz_mask, struct allowed_net **allowed_nets) { struct allowed_net *an; an = olsr_malloc(sizeof(*an), __func__); if (an == NULL) { fprintf(stderr, "(HTTPINFO) register param net out of memory!\n"); exit(0); } if(inet_aton(sz_net, &an->net.v4) == 0 || inet_aton(sz_mask, &an->mask.v4) == 0) { free(an); return 1; } an->next = *allowed_nets; *allowed_nets = an; return 0; }
char * parse_address(struct olsrv2 *olsr, struct address_list **list, char *msg_ptr, char *num_addr) { struct address_block_info info; struct address_list *new_list = NULL, *tail = NULL; int i; union olsr_ip_addr mid; msg_ptr = get_address_block_header(olsr, &info, msg_ptr); debug_code(print_address_block_info(olsr, &info)); *num_addr = info.num_addr;// use after tail = NULL; for (i = 0; i < info.num_addr; i++) { new_list = (struct address_list *)olsr_malloc(sizeof(struct address_list), __FUNCTION__); memset(new_list, 0, sizeof(struct address_list)); memset(&mid, 0, sizeof(union olsr_ip_addr)); new_list->next = NULL; new_list->index = i; msg_ptr = get_bytes(msg_ptr, info.mid_length, &mid); make_address(&new_list->ip_addr, &mid, &info); debug_code(print_new_list(olsr, new_list)); // QUEUE address if (*list == NULL){ *list = new_list; //tail = new_list; }else{ new_list->next = *list; *list = new_list; //tail->next = new_list; //tail = new_list; } } debug_code(print_address_list(olsr, *list)); return msg_ptr; }
inline static char * get_address_tlv_value(char *msg_ptr, struct tlv_tuple_local *tuple) { tuple->value = 0; tuple->multi_value = NULL; tuple->extended_value = NULL; switch (tuple->length) { case sizeof(olsr_u8_t): { olsr_u8_t v; msg_ptr = get_u8(msg_ptr, &v); tuple->value = v; } break; case sizeof(olsr_u16_t): { olsr_u16_t v; msg_ptr = get_u16(msg_ptr, &v); tuple->value = v; } break; case sizeof(olsr_u32_t): { olsr_u32_t v; msg_ptr = get_u32(msg_ptr, &v); tuple->value = v; } break; default: tuple->extended_value = (olsr_u8_t *)olsr_malloc(tuple->length, __FUNCTION__); memcpy(tuple->extended_value, msg_ptr, tuple->length); msg_ptr += tuple->length; } return msg_ptr; }
/** *Insert a neighbor entry in the neighbor table * *@param main_addr the main address of the new node * *@return 0 if neighbor already exists 1 if inserted */ struct neighbor_entry * olsr_insert_neighbor_table(const union olsr_ip_addr *main_addr) { olsr_u32_t hash; struct neighbor_entry *new_neigh; hash = olsr_ip_hashing(main_addr); /* Check if entry exists */ for(new_neigh = neighbortable[hash].next; new_neigh != &neighbortable[hash]; new_neigh = new_neigh->next) { if(ipequal(&new_neigh->neighbor_main_addr, main_addr)) return new_neigh; } //printf("inserting neighbor\n"); new_neigh = olsr_malloc(sizeof(struct neighbor_entry), "New neighbor entry"); /* Set address, willingness and status */ new_neigh->neighbor_main_addr = *main_addr; new_neigh->willingness = WILL_NEVER; new_neigh->status = NOT_SYM; new_neigh->neighbor_2_list.next = &new_neigh->neighbor_2_list; new_neigh->neighbor_2_list.prev = &new_neigh->neighbor_2_list; new_neigh->linkcount = 0; new_neigh->is_mpr = OLSR_FALSE; new_neigh->was_mpr = OLSR_FALSE; /* Queue */ QUEUE_ELEM(neighbortable[hash], new_neigh); return new_neigh; }
/** *Add a MPR selector to the MPR selector set * *@param add address of the MPR selector *@param vtime validity time for the new entry * *@return a pointer to the new entry */ struct mpr_selector * olsr_add_mpr_selector(const union olsr_ip_addr *addr, olsr_reltime vtime) { struct ipaddr_str buf; struct mpr_selector *new_entry; OLSR_PRINTF(1, "MPRS: adding %s\n", olsr_ip_to_string(&buf, addr)); new_entry = olsr_malloc(sizeof(struct mpr_selector), "Add MPR selector"); /* Fill struct */ new_entry->MS_main_addr = *addr; olsr_set_mpr_sel_timer(new_entry, vtime); /* Queue */ QUEUE_ELEM(mprs_list, new_entry); /* new_entry->prev = &mprs_list; new_entry->next = mprs_list.next; mprs_list.next->prev = new_entry; mprs_list.next = new_entry; */ return new_entry; }