示例#1
0
void tommy_list_concat(tommy_list* first, tommy_list* second)
{
	tommy_node* first_head;
	tommy_node* first_tail;
	tommy_node* second_head;

	if (tommy_list_empty(second))
		return;

	if (tommy_list_empty(first)) {
		*first = *second;
		return;
	}

	first_head = tommy_list_head(first);
	second_head = tommy_list_head(second);
	first_tail = tommy_list_tail(first);

	/* set the "circular" prev list */
	first_head->prev = second_head->prev;
	second_head->prev = first_tail;

	/* set the "0 terminated" next list */
	first_tail->next = second_head;
}
示例#2
0
void *get_first_elem_list(void *ll)
{
	if (tommy_list_head(ll))
		return tommy_list_head(ll)->data;
	else
		return NULL;
}
示例#3
0
uint16_t
switch_smac_rewrite_index_from_rmac(switch_handle_t rmac_handle)
{
    switch_rmac_info_t                *rmac_info = NULL;
    switch_rmac_entry_t               *rmac_entry = NULL;
    tommy_node                        *node = NULL;
    switch_mac_addr_t                 *mac = NULL;
    uint16_t                           smac_index = 0;
    switch_smac_entry_t               *smac_entry = NULL;

    rmac_info = switch_api_rmac_info_get_internal(rmac_handle);
    if (!rmac_info) {
        return smac_index;
    }

    node = tommy_list_head(&(rmac_info->rmac_list));
    while (node) {
        rmac_entry = node->data;
        mac = &rmac_entry->mac;
        smac_entry = switch_smac_rewrite_search_entry(mac);
        if (smac_entry) {
            smac_index = smac_entry->smac_index;
            break;
        }
        node = node->next;
    }
    return smac_index;
}
示例#4
0
文件: switch_l3.c 项目: krambn/switch
switch_status_t switch_api_l3_v6_routes_print_by_vrf(
    switch_handle_t vrf_handle) {
  switch_l3_hash_t *hash_entry = NULL;
  tommy_node *node = NULL;
  switch_vrf_route_list_t *vrf_route_list = NULL;
  void *temp = NULL;
  switch_ip_addr_t ip_addr;
  char v6_addr[INET6_ADDRSTRLEN];

  JLG(temp, switch_vrf_v6_routes, vrf_handle);
  if (!temp) {
    return SWITCH_STATUS_ITEM_NOT_FOUND;
  }
  vrf_route_list = (switch_vrf_route_list_t *)(*(unsigned long *)temp);
  node = tommy_list_head(&(vrf_route_list->routes));
  while (node) {
    hash_entry = node->data;
    switch_l3_hash_key_decode(hash_entry, &vrf_handle, &ip_addr);
    inet_ntop(AF_INET6, ip_addr.ip.v6addr, v6_addr, INET6_ADDRSTRLEN);
    printf("\nvrf_handle %x ip %s -> nhop %x",
           (unsigned int)vrf_handle,
           v6_addr,
           (unsigned int)hash_entry->nhop_handle);
    node = node->next;
  }
  return SWITCH_STATUS_SUCCESS;
}
void
switchlink_db_mroute_mdb_walk(switchlink_db_mdb_info_t *mdb_info,
                              switchlink_db_mroute_walk_fn notify) {
    if (!mdb_info || !notify) {
        return;
    }

    switchlink_handle_t mdb_vrf_h;
    switchlink_db_bridge_info_t bridge_info;
    if (switchlink_db_bridge_handle_get_info(
            mdb_info->bridge_h, &bridge_info) != SWITCHLINK_DB_STATUS_SUCCESS) {
        return;
    }
    mdb_vrf_h = bridge_info.vrf_h;

    tommy_node * node = tommy_list_head(&switchlink_db_mroute_obj_list);
    while (node) {
        switchlink_db_mroute_obj_t * obj = node->data;
        node = node->next;
        if ((obj->mroute_info.vrf_h == mdb_vrf_h) &&
            (memcmp(&(obj->mroute_info.dst_ip), &(mdb_info->grp_ip),
                    sizeof(switchlink_ip_addr_t)) == 0)) {
            switchlink_db_mroute_info_t mroute_info;
            memcpy(&mroute_info, &(obj->mroute_info),
                   sizeof(switchlink_db_mroute_info_t));
            (*notify)(&mroute_info);
        }
    }
}
示例#6
0
文件: hash.c 项目: tnako/pureble
void pcore_hash_done(phash_pool *ptr)
{
    phash_pool pool = (*ptr);

    if (!pool) {
        plog_error("%s(): Нет phash_pool!", __PRETTY_FUNCTION__);
        return;
    }

    plog_dbg("%s(): Очистка пула 0x%08X", __PRETTY_FUNCTION__, pool);

    tommy_node* i = tommy_list_head(pool->list);
    while (i) {
        tommy_node* i_next = i->next;
        if (!pcore_hash_deleteObject((phash_object*)&i->data)) {
            break;
        }
        i = i_next;
    }

    switch (pool->type) {
    case PHASH_FAST_SEARCH:
        tommy_hashdyn_done((tommy_hashdyn *)pool->hash_struct);
        break;
    case PHASH_FAST_INSERT:
    default:
        tommy_hashtable_done((tommy_hashtable *)pool->hash_struct);
        break;
    }

    pfree(&pool->hash_struct);
    pfree(&pool->list);

    pfree(&pool);
}
示例#7
0
switchlink_db_status_t
switchlink_db_ecmp_get_info(switchlink_db_ecmp_info_t *ecmp_info) {
    tommy_node * node = tommy_list_head(&switchlink_db_ecmp_obj_list);
    while (node) {
        switchlink_db_ecmp_obj_t * obj = node->data;
        node = node->next;
        if (obj->ecmp_info.num_nhops == ecmp_info->num_nhops) {
            int i, j;
            for (i = 0; i < ecmp_info->num_nhops; i++) {
                bool match_found = false;
                for (j = 0; j < ecmp_info->num_nhops; j++) {
                    if (obj->ecmp_info.nhops[i] == ecmp_info->nhops[j]) {
                        match_found = true;
                        break;
                    }
                }
                if (!match_found) {
                    return SWITCHLINK_DB_STATUS_ITEM_NOT_FOUND;
                }
            }
            memcpy(ecmp_info, &(obj->ecmp_info),
                   sizeof(switchlink_db_ecmp_info_t));
            return SWITCHLINK_DB_STATUS_SUCCESS;
        }
    }
    return SWITCHLINK_DB_STATUS_ITEM_NOT_FOUND;
}
示例#8
0
switch_status_t
switch_api_nhop_print_entry(switch_handle_t nhop_handle)
{
    switch_nhop_info_t                *nhop_info = NULL;
    switch_spath_info_t               *spath_info = NULL;
    switch_ecmp_info_t                *ecmp_info = NULL;
    switch_ecmp_member_t              *ecmp_member = NULL;
    tommy_node                        *node = NULL;

    nhop_info = switch_nhop_get(nhop_handle);
    if (!nhop_info) {
        return SWITCH_STATUS_INVALID_NHOP;
    }

    printf("\n\nnhop_handle %x", (unsigned int) nhop_handle);
    if (nhop_info->type == SWITCH_NHOP_INDEX_TYPE_ONE_PATH) {
        spath_info = &(SWITCH_NHOP_SPATH_INFO(nhop_info));
        printf("\ntype : single path");
        printf("\nintf_handle %x", (unsigned int) spath_info->nhop_key.intf_handle);
    } else {
        ecmp_info = &(SWITCH_NHOP_ECMP_INFO(nhop_info));
        printf("\ntype : ecmp path");
        printf("\nnumber of ecmp path %d", ecmp_info->count);
        node = tommy_list_head(&(ecmp_info->members));
        while (node) {
            ecmp_member = node->data;
            printf("\n\tecmp_member_nhop %x", (unsigned int) ecmp_member->nhop_handle);
            node = node->next;
        }
    }
    return SWITCH_STATUS_SUCCESS;
}
示例#9
0
void cheap_tcam_insert(cheap_tcam_t *tcam,
		       uint8_t *mask,
		       uint8_t *key,
		       cheap_tcam_node *node,
		       void *data) {
  tommy_list *hashmaps = &tcam->hashmaps;
  tcam_hashmap_t *tcam_hashmap;
  uint32_t hash = hashlittle(key, tcam->key_size, 0);
  tommy_node* elem = tommy_list_head(hashmaps);
  
  while(elem) {
    tcam_hashmap = (tcam_hashmap_t *) elem->data;
    if(!memcmp(mask, tcam_hashmap->mask, tcam->key_size)) {
      tommy_hashlin_insert(&tcam_hashmap->hashmap, node, data, hash);
      return;
    }
    elem = elem->next;
  }

  tcam_hashmap = malloc(sizeof(tcam_hashmap_t));
  tommy_hashlin_init(&tcam_hashmap->hashmap);
  tcam_hashmap->mask = malloc(tcam->key_size);
  memcpy(tcam_hashmap->mask, mask, tcam->key_size);
  tommy_list_insert_head(hashmaps, &tcam_hashmap->node, tcam_hashmap);
  tommy_hashlin_insert(&tcam_hashmap->hashmap, node, data, hash);
}
示例#10
0
switch_status_t
switch_api_router_mac_group_print_entry(switch_handle_t rmac_handle)
{
    switch_rmac_info_t                *rmac_info = NULL;
    switch_rmac_entry_t               *rmac_entry = NULL;
    tommy_node                        *node = NULL;
    switch_mac_addr_t                 *mac = NULL;

    rmac_info = switch_api_rmac_info_get_internal(rmac_handle);
    if (!rmac_info) {
        return SWITCH_STATUS_INVALID_HANDLE;
    }
    printf("\n\nrmac_handle %x", (unsigned int) rmac_handle);
    node = tommy_list_head(&(rmac_info->rmac_list));
    while (node) {
        rmac_entry = node->data;
        mac = &rmac_entry->mac;
        printf("\n\t mac %02x:%02x:%02x:%02x:%02x:%02x",
                mac->mac_addr[0], mac->mac_addr[1], mac->mac_addr[2],
                mac->mac_addr[3], mac->mac_addr[4], mac->mac_addr[5]);
        node = node->next;
    }
    printf("\n");
    return SWITCH_STATUS_SUCCESS;
}
示例#11
0
//:: for name, vs_info in value_sets.items():
//::   byte_width = vs_info["byte_width"]
void *value_set_${name}_lookup(uint8_t *value, uint8_t *mask) {
  tommy_node* node = tommy_list_head(&value_set_${name});
  while (node) {
    value_set_${name}_entry_t * data = node->data;
    if((!memcmp(data->value, value, sizeof(data->value))) &&
       (!memcmp(data->mask, mask, sizeof(data->mask))))
      return &data->node;
    node = node->next;
  }
  return NULL;
}
示例#12
0
/*
 * @function: switch_api_router_mac_add
 * Add Router mac to rmac group
 * @param device - Device to be programmed
 * @param rmac_handle - ID of the RMAC group
 * @param mac - Router mac address to be added to the group
 * @return: Returns success if mac is added successfully
 */
switch_status_t
switch_api_router_mac_add(switch_device_t device, switch_handle_t rmac_handle, switch_mac_addr_t *mac)
{
    switch_rmac_info_t                *rmac_info = NULL;
    switch_rmac_entry_t               *rmac_entry = NULL;
    tommy_node                        *node = NULL;
    switch_status_t                    status = SWITCH_STATUS_SUCCESS;

    if (!SWITCH_RMAC_HANDLE_VALID(rmac_handle)) {
        return SWITCH_STATUS_INVALID_HANDLE;
    }

    rmac_info = switch_api_rmac_info_get_internal(rmac_handle);
    if (!rmac_info) {
        return SWITCH_STATUS_INVALID_HANDLE;
    }
    node = tommy_list_head(&(rmac_info->rmac_list));
    while (node) {
        rmac_entry = node->data;
        if (memcmp(&(rmac_entry->mac), mac, sizeof(switch_mac_addr_t)) == 0) {
            return SWITCH_STATUS_SUCCESS;
        }
        node = node->next;
    }
    rmac_entry = switch_malloc(sizeof(switch_rmac_entry_t), 1);
    if (!rmac_entry) {
        return SWITCH_STATUS_NO_MEMORY;
    }
    memcpy(&rmac_entry->mac, mac, sizeof(switch_mac_addr_t));
    tommy_list_insert_head(&(rmac_info->rmac_list), &(rmac_entry->node), rmac_entry);
    status = switch_smac_rewrite_add_entry(mac);
    if (status != SWITCH_STATUS_SUCCESS) {
        printf("MAC rewrite table add failed with error code %d\n", status);
        return status;
    }
#ifdef SWITCH_PD
    
    status = switch_pd_inner_rmac_table_add_entry(device,
                                              handle_to_id(rmac_handle), mac,
                                              &rmac_entry->inner_rmac_entry);
    if(status != SWITCH_STATUS_SUCCESS) {
        printf("Inner RMAC table add failed with error code %d\n", status);
        return status;
    }

    status = switch_pd_outer_rmac_table_add_entry(device,
                                              handle_to_id(rmac_handle), mac,
                                              &rmac_entry->outer_rmac_entry);
    if(status != SWITCH_STATUS_SUCCESS) {
        printf("Outer RMAC table add failed with error code %d\n", status);
    }
#endif
    return status; 
}
示例#13
0
//:: for name, vs_info in value_sets.items():
//::   byte_width = vs_info["byte_width"]
int value_set_${name}_contains(uint8_t *key) {
  tommy_node* node = tommy_list_head(&value_set_${name});
  while (node) {
    value_set_${name}_entry_t * data = node->data;
    int result = cmp_values(key, data->value, ${byte_width}, data->mask);
    if(result)
      return 1;
    node = node->next;
  }
  return 0;
}
示例#14
0
switch_status_t
switch_api_stp_group_print_entry(switch_handle_t stg_handle)
{
    switch_stp_info_t                 *stp_info = NULL;
    switch_stp_vlan_entry_t           *vlan_entry = NULL;
    switch_stp_port_entry_t           *port_entry = NULL;
    tommy_node                        *node = NULL;
    switch_handle_t                    bd_handle = 0;
    switch_handle_t                    intf_handle = 0;

    if (!SWITCH_STP_HANDLE_VALID(stg_handle)) {
        return SWITCH_STATUS_INVALID_HANDLE;
    }

    stp_info = switch_api_stp_get_internal(stg_handle);
    if (!stp_info) {
        return SWITCH_STATUS_INVALID_HANDLE;
    }

    printf("\n\nstp_group_handle: %x", (unsigned int) stg_handle);
    node = tommy_list_head(&(stp_info->vlan_list));
    printf("\nlist of vlan handles:");
    while (node) {
        vlan_entry = node->data;
        bd_handle = vlan_entry->bd_handle;
        printf("\n\tvlan_handle: %x", (unsigned int) bd_handle);
        node = node->next;
    }
    printf("\nlist of interface handles:");
    node = tommy_list_head(&(stp_info->port_list));
    while (node) {
        port_entry = node->data;
        intf_handle = port_entry->intf_handle;
        printf("\n\tintf_handle: %x stp_state %x",
                (unsigned int) intf_handle,
                port_entry->intf_state);
        node = node->next;
    }
    printf("\n");
    return SWITCH_STATUS_SUCCESS;
}
示例#15
0
switch_status_t
switch_api_stp_group_vlans_remove(switch_device_t device,
                                 switch_handle_t stg_handle,
                                 uint16_t vlan_count,
                                 switch_handle_t *vlan_handle)
{
    switch_stp_info_t                 *stp_info = NULL;
    switch_bd_info_t                  *bd_info = NULL;
    switch_stp_vlan_entry_t           *vlan_entry = NULL;
    tommy_node                        *node = NULL;
    switch_handle_t                    bd_handle;
    int                                count = 0;

    if (!SWITCH_STP_HANDLE_VALID(stg_handle)) {
        return SWITCH_STATUS_INVALID_HANDLE;
    }

    stp_info = switch_api_stp_get_internal(stg_handle);
    if (!stp_info) {
        return SWITCH_STATUS_INVALID_HANDLE;
    }

    for (count = 0; count < vlan_count; count++) {
        bd_handle = vlan_handle[count];
        bd_info = switch_bd_get(bd_handle);
        if (!bd_info) {
            return SWITCH_STATUS_INVALID_VLAN_ID;
        }

        node = tommy_list_head(&(stp_info->vlan_list));
        while (node) {
            vlan_entry = node->data;
            if (vlan_entry->bd_handle == bd_handle) {
                break;
            }
            node = node->next;
        }

        if (!node) {
            return SWITCH_STATUS_ITEM_NOT_FOUND;
        }

        bd_info->stp_handle = 0;
        switch_pd_bd_table_update_entry(device, handle_to_id(bd_handle),
                                        bd_info);

        vlan_entry = tommy_list_remove_existing(&(stp_info->vlan_list), node);
        switch_free(vlan_entry);
    }
    return SWITCH_STATUS_SUCCESS;
}
示例#16
0
switch_status_t
switch_stp_update_flood_list(switch_device_t device, switch_handle_t stg_handle,
                             switch_handle_t intf_handle, switch_stp_state_t state)
{
    switch_stp_info_t                 *stp_info = NULL;
    switch_bd_info_t                  *bd_info = NULL;
    switch_stp_vlan_entry_t           *vlan_entry = NULL;
    tommy_node                        *node = NULL;
    switch_handle_t                    bd_handle = 0;
    switch_status_t                    status = SWITCH_STATUS_SUCCESS;
    switch_vlan_interface_t            vlan_intf;

    if (!SWITCH_STP_HANDLE_VALID(stg_handle)) {
        return SWITCH_STATUS_INVALID_HANDLE;
    }

    stp_info = switch_api_stp_get_internal(stg_handle);
    if (!stp_info) {
        return SWITCH_STATUS_INVALID_HANDLE;
    }

    node = tommy_list_head(&(stp_info->vlan_list));
    while (node) {
        vlan_entry = node->data;
        bd_handle = vlan_entry->bd_handle;
        bd_info = switch_bd_get(bd_handle);
        if (!bd_info) {
            return SWITCH_STATUS_INVALID_VLAN_ID;
        }

        memset(&vlan_intf, 0, sizeof(vlan_intf));
        vlan_intf.vlan_handle = bd_handle;
        vlan_intf.intf_handle = intf_handle;
        switch (state) {
            case SWITCH_PORT_STP_STATE_FORWARDING:
                status = switch_api_multicast_member_add(
                    device, bd_info->uuc_mc_index, 1, &vlan_intf);
                break;
            case SWITCH_PORT_STP_STATE_BLOCKING:
            case SWITCH_PORT_STP_STATE_NONE:
                status = switch_api_multicast_member_delete(
                    device, bd_info->uuc_mc_index, 1, &vlan_intf);
                break;

            default:
                break;
        }
        node = node->next;
    }
    return status;
}
示例#17
0
switch_status_t switch_api_packet_net_filter_tx_delete(
    switch_device_t device, switch_packet_tx_key_t *tx_key) {
  switch_packet_tx_entry_t *tmp_tx_entry = NULL;
  switch_packet_tx_info_t *tmp_tx_info = NULL;
  switch_packet_tx_entry_t tx_entry;
  tommy_node *node = NULL;
  switch_hostif_info_t *hostif_info = NULL;
  bool node_found = FALSE;
  switch_status_t status = SWITCH_STATUS_SUCCESS;

  if (!tx_key) {
    SWITCH_API_ERROR("filter tx delete failed. invalid params");
    return SWITCH_STATUS_INVALID_PARAMETER;
  }

  memset(&tx_entry, 0x0, sizeof(tx_entry));
  if (tx_key->handle_valid) {
    hostif_info = switch_hostif_get(tx_key->hostif_handle);
    if (!hostif_info) {
      SWITCH_API_ERROR("invalid hostif handle");
      return SWITCH_STATUS_INVALID_HANDLE;
    }
    tx_entry.intf_fd = hostif_info->intf_fd;
  }

  if (tx_key->vlan_valid) {
    tx_entry.vlan_id = tx_key->vlan_id;
  }

  node = tommy_list_head(&packet_tx_filter_list);
  while (node) {
    tmp_tx_info = (switch_packet_tx_info_t *)node->data;
    tmp_tx_entry = &tmp_tx_info->tx_entry;

    if (switch_packet_tx_filter_match(tmp_tx_entry, &tx_entry)) {
      node_found = TRUE;
      break;
    }
    node = node->next;
  }

  if (!node_found) {
    SWITCH_API_ERROR("tx filter delete failed. node find failed");
    return SWITCH_STATUS_ITEM_NOT_FOUND;
  }

  tommy_list_remove_existing(&packet_tx_filter_list, node);
  switch_free(tmp_tx_info);
  return status;
}
示例#18
0
switchlink_db_status_t switchlink_db_mac_intf_delete(
    switchlink_handle_t intf_h) {
  tommy_node *node = tommy_list_head(&switchlink_db_mac_obj_list);
  while (node) {
    switchlink_db_mac_obj_t *obj = node->data;
    node = node->next;
    if (obj->intf_h == intf_h) {
      tommy_hashlin_remove_existing(&switchlink_db_mac_obj_hash,
                                    &obj->hash_node);
      tommy_list_remove_existing(&switchlink_db_mac_obj_list, &obj->list_node);
      switchlink_free(obj);
    }
  }
  return SWITCHLINK_DB_STATUS_SUCCESS;
}
示例#19
0
switch_status_t
switch_api_stp_group_delete(switch_device_t device, switch_handle_t stg_handle)
{
    switch_stp_info_t                 *stp_info = NULL;
    tommy_node                        *node = NULL;
    switch_stp_port_entry_t           *port_entry = NULL;
    switch_stp_vlan_entry_t           *vlan_entry = NULL;

    if (!SWITCH_STP_HANDLE_VALID(stg_handle)) {
        return SWITCH_STATUS_INVALID_HANDLE;
    }

    stp_info = switch_api_stp_get_internal(stg_handle);
    if (!stp_info) {
        return SWITCH_STATUS_INVALID_HANDLE;
    }

    node = tommy_list_head(&(stp_info->port_list));
    while (node) {
        port_entry = node->data;
        node = node->next;
        switch_api_stp_port_state_set(device, stg_handle,
                          port_entry->intf_handle,
                          SWITCH_PORT_STP_STATE_NONE);
    }
    node = tommy_list_head(&(stp_info->vlan_list));
    while (node) {
        vlan_entry = node->data;
        node = node->next;
        switch_api_stp_group_vlans_remove(device, 
                                          stg_handle, 1,
                                          &vlan_entry->bd_handle);
    }
    switch_stg_handle_delete(stg_handle);
    return SWITCH_STATUS_SUCCESS;
}
示例#20
0
文件: elem.c 项目: CrawX/snapraid
static int filter_element(tommy_list* filterlist, struct snapraid_filter** reason, const char* disk, const char* sub, int is_dir)
{
	tommy_node* i;

	int direction = 1; /* by default include all */

	/* for each filter */
	for (i = tommy_list_head(filterlist); i != 0; i = i->next) {
		int ret;
		struct snapraid_filter* filter = i->data;

		if (filter->is_disk) {
			if (fnmatch(filter->pattern, disk, FNM_CASEINSENSITIVE_FOR_WIN) == 0)
				ret = filter->direction;
			else
				ret = 0;
			if (reason != 0 && ret < 0)
				*reason = filter;
		} else {
			ret = filter_recurse(filter, reason, sub, is_dir);
		}

		if (ret > 0) {
			/* include the file */
			return 0;
		} else if (ret < 0) {
			/* exclude the file */
			return -1;
		} else {
			/* default is opposite of the last filter */
			direction = -filter->direction;
			if (reason != 0 && direction < 0)
				*reason = filter;
			/* continue with the next one */
		}
	}

	/* directories are always included by default, otherwise we cannot apply rules */
	/* to the contained files */
	if (is_dir)
		return 0;

	/* files are excluded/included depending of the last rule processed */
	if (direction < 0)
		return -1;

	return 0;
}
示例#21
0
void cheap_tcam_destroy(cheap_tcam_t *tcam) {
  tommy_node* elem = tommy_list_head(&tcam->hashmaps);
  tommy_node* next;
  tcam_hashmap_t *tcam_hashmap;
  while(elem) {
    tcam_hashmap = (tcam_hashmap_t *) elem->data;
    tommy_hashlin_done(&tcam_hashmap->hashmap);
    free(tcam_hashmap->mask);
    next = elem->next;
    free(tcam_hashmap);
    elem = next;
  }
  
  free(tcam->masked_key);
  free(tcam);
}
示例#22
0
switch_status_t switch_sflow_match_entry_remove(switch_sflow_info_t *sflow_info,
                                                switch_handle_t entry_hdl) {
  tommy_node *node = tommy_list_head(&sflow_info->match_list);
  while (node) {
    switch_sflow_match_entry_t *obj = (switch_sflow_match_entry_t *)node->data;
    if (obj->sflow_ace_hdl == entry_hdl) {
      break;
    }
    node = node->next;
  }
  if (node) {
    tommy_list_remove_existing(&sflow_info->match_list, node);
    return SWITCH_STATUS_SUCCESS;
  }
  return SWITCH_STATUS_ITEM_NOT_FOUND;
}
示例#23
0
switchlink_db_status_t
switchlink_db_route_get_info(switchlink_db_route_info_t *route_info) {
    tommy_node * node = tommy_list_head(&switchlink_db_route_obj_list);
    while (node) {
        switchlink_db_route_obj_t * obj = node->data;
        node = node->next;
        if ((obj->route_info.vrf_h == route_info->vrf_h) &&
                (memcmp(&(obj->route_info.ip_addr), &(route_info->ip_addr),
                        sizeof(switchlink_ip_addr_t)) == 0)) {
            memcpy(route_info, &(obj->route_info),
                   sizeof(switchlink_db_route_info_t));
            return SWITCHLINK_DB_STATUS_SUCCESS;
        }
    }
    return SWITCHLINK_DB_STATUS_ITEM_NOT_FOUND;
}
示例#24
0
switchlink_db_status_t
switchlink_db_mdb_update(switchlink_db_mdb_info_t *mdb_info) {
    tommy_node * node = tommy_list_head(&switchlink_db_mdb_obj_list);
    while (node) {
        switchlink_db_mdb_obj_t * obj = node->data;
        node = node->next;
        if ((obj->mdb_info.bridge_h == mdb_info->bridge_h) &&
            (memcmp(&(obj->mdb_info.grp_ip), &(mdb_info->grp_ip),
                    sizeof(switchlink_ip_addr_t)) == 0)) {
            memcpy(&(obj->mdb_info), mdb_info,
                   sizeof(switchlink_db_mdb_info_t));
            return SWITCHLINK_DB_STATUS_SUCCESS;
        }
    }
    return SWITCHLINK_DB_STATUS_ITEM_NOT_FOUND;
}
示例#25
0
void cheap_tcam_delete(cheap_tcam_t *tcam,
		       uint8_t *mask,
		       uint8_t *key,
		       cheap_tcam_node *node) {
  tommy_list *hashmaps = &tcam->hashmaps;
  tcam_hashmap_t *tcam_hashmap;
  tommy_node* elem = tommy_list_head(hashmaps);

  while(elem) {
    tcam_hashmap = (tcam_hashmap_t *) elem->data;
    if(!memcmp(mask, tcam_hashmap->mask, tcam->key_size)) {
      tommy_hashlin_remove_existing(&tcam_hashmap->hashmap, node);
      return;
    }
    elem = elem->next;
  }
}
示例#26
0
switchlink_db_status_t
switchlink_db_neighbor_delete(switchlink_db_neigh_info_t *neigh_info) {
    tommy_node * node = tommy_list_head(&switchlink_db_neigh_obj_list);
    while (node) {
        switchlink_db_neigh_obj_t * obj = node->data;
        node = node->next;
        if ((memcmp(&(neigh_info->ip_addr), &(obj->neigh_info.ip_addr),
                    sizeof(switchlink_ip_addr_t)) == 0) &&
                (neigh_info->intf_h == obj->neigh_info.intf_h)) {
            tommy_list_remove_existing(&switchlink_db_neigh_obj_list,
                                       &obj->list_node);
            switchlink_free(obj);
            return SWITCHLINK_DB_STATUS_SUCCESS;
        }
    }
    return SWITCHLINK_DB_STATUS_ITEM_NOT_FOUND;
}
示例#27
0
/*
 * @function: switch_api_router_mac_delete
 * Add Router mac to rmac group
 * @param device - Device to be programmed
 * @param rmac_handle - ID of the RMAC group
 * @param mac - Router mac address to be removed from the group
 * @return: Returns success if mac is deleted successfully
 */
switch_status_t
switch_api_router_mac_delete(switch_device_t device, switch_handle_t rmac_handle, switch_mac_addr_t *mac)
{
    switch_rmac_info_t                *rmac_info = NULL;
    switch_rmac_entry_t               *rmac_entry = NULL;
    tommy_node                        *node = NULL;
    switch_status_t                    status = SWITCH_STATUS_SUCCESS;

    if (!SWITCH_RMAC_HANDLE_VALID(rmac_handle)) {
        return SWITCH_STATUS_INVALID_HANDLE;
    }

    rmac_info = switch_api_rmac_info_get_internal(rmac_handle);
    if (!rmac_info) {
        return SWITCH_STATUS_ITEM_NOT_FOUND;
    }

    node = tommy_list_head(&(rmac_info->rmac_list));
    while (node) {
        rmac_entry = node->data;
        if (memcmp(&(rmac_entry->mac), mac, sizeof(switch_mac_addr_t)) == 0) {
            break;
        }
        node = node->next;
    }
    if (!node) {
        return SWITCH_STATUS_ITEM_NOT_FOUND;
    }

    switch_smac_rewrite_delete_entry(mac);
    rmac_entry = tommy_list_remove_existing(&(rmac_info->rmac_list), node);
#ifdef SWITCH_PD
    status = switch_pd_outer_rmac_table_delete_entry(device, rmac_entry->outer_rmac_entry);
    if (status != SWITCH_STATUS_SUCCESS) {
        return status;
    }
    status = switch_pd_inner_rmac_table_delete_entry(device, rmac_entry->inner_rmac_entry);
    if (status != SWITCH_STATUS_SUCCESS) {
        return status;
    }
#endif
    free(rmac_entry);
    return status;
}
示例#28
0
void tommy_list_sort(tommy_list* list, tommy_compare_func* cmp)
{
	tommy_chain chain;
	tommy_node* head;

	if (tommy_list_empty(list))
		return;

	head = tommy_list_head(list);

	/* create a chain from the list */
	chain.head = head;
	chain.tail = head->prev;

	tommy_chain_mergesort(&chain, cmp);

	/* restore the list */
	tommy_list_set(list, chain.head, chain.tail);
}
示例#29
0
switchlink_db_status_t
switchlink_db_mroute_delete(switchlink_db_mroute_info_t *mroute_info) {
    tommy_node * node = tommy_list_head(&switchlink_db_mroute_obj_list);
    while (node) {
        switchlink_db_mroute_obj_t * obj = node->data;
        node = node->next;
        if ((obj->mroute_info.vrf_h == mroute_info->vrf_h) &&
            (memcmp(&(obj->mroute_info.src_ip), &(mroute_info->src_ip),
                    sizeof(switchlink_ip_addr_t)) == 0) &&
            (memcmp(&(obj->mroute_info.dst_ip), &(mroute_info->dst_ip),
                    sizeof(switchlink_ip_addr_t)) == 0)) {
            tommy_list_remove_existing(&switchlink_db_mroute_obj_list,
                                       &obj->list_node);
            switchlink_free(obj);
            return SWITCHLINK_DB_STATUS_SUCCESS;
        }
    }
    return SWITCHLINK_DB_STATUS_ITEM_NOT_FOUND;
}
示例#30
0
switch_status_t switch_api_sflow_session_delete(switch_device_t device,
                                                switch_handle_t sflow_hdl,
                                                bool all_cleanup) {
#ifdef P4_SFLOW_ENABLE
  switch_sflow_info_t *sflow_info;

  sflow_info = switch_sflow_info_get(sflow_hdl);
  if (!sflow_info) {
    return SWITCH_STATUS_INVALID_HANDLE;
  }
  if (!tommy_list_empty(&sflow_info->match_list) && !all_cleanup) {
    return SWITCH_STATUS_RESOURCE_IN_USE;
  }
  if (all_cleanup) {
    switch_sflow_match_entry_t *entry;
    tommy_node *node = NULL;
    while ((node = tommy_list_head(&sflow_info->match_list)) && node) {
      entry = (switch_sflow_match_entry_t *)node->data;
      // could be ingress or egress match entry
      switch_pd_sflow_match_table_delete(device, entry);
      tommy_list_remove_existing(&sflow_info->match_list, node);
      switch_sflow_ace_handle_delete(entry->sflow_ace_hdl);
    }
  }

  switch_pd_sflow_session_delete(device, sflow_info);

  if (sflow_info->mirror_hdl != SWITCH_API_INVALID_HANDLE) {
    switch_api_mirror_session_delete(device, sflow_info->mirror_hdl);
  }

  switch_sflow_handle_delete(sflow_hdl);

  return SWITCH_STATUS_SUCCESS;
#else
  (void)device;
  (void)sflow_hdl;
  (void)all_cleanup;
  return SWITCH_STATUS_FAILURE;
#endif  // P4_SFLOW_ENABLE
}