コード例 #1
0
ファイル: switch_neighbor.c プロジェクト: krambn/switch
static switch_status_t switch_dmac_rewrite_delete_hash(switch_device_t device,
                                                       switch_mac_addr_t *mac) {
  switch_dmac_rewrite_t *dmac_rewrite = NULL;
  unsigned char key[SWITCH_DMAC_REWRITE_HASH_KEY_SIZE];
  unsigned int len = 0;
  uint32_t hash = 0;
  switch_status_t status = SWITCH_STATUS_SUCCESS;

  dmac_rewrite = switch_dmac_rewrite_search_hash(mac);
  if (!dmac_rewrite) {
    return SWITCH_STATUS_ITEM_NOT_FOUND;
  }
  dmac_rewrite->ref_count--;
  if (dmac_rewrite->ref_count == 0) {
    switch_dmac_rewrite_hash_key_init(key, mac, &len, &hash);
    dmac_rewrite = tommy_hashtable_remove(
        &switch_dmac_rewrite_table, switch_dmac_rewrite_hash_cmp, key, hash);
    status = switch_pd_tunnel_dmac_rewrite_table_delete_entry(
        device, dmac_rewrite->rewrite_entry);
    if (status != SWITCH_STATUS_SUCCESS) {
      SWITCH_API_ERROR(
          "%s:%d unabl to delete tunnel dmac entry!", __FUNCTION__, __LINE__);
      return status;
    }
    switch_api_id_allocator_release(dmac_rewrite_index_allocator,
                                    dmac_rewrite->index);
    switch_free(dmac_rewrite);
  }
  return status;
}
コード例 #2
0
static void
switch_smac_rewrite_hash_delete(switch_smac_entry_t *smac_entry)
{
    unsigned char                      key[ETH_LEN];
    uint32_t                           hash = 0;
    unsigned int                       len = 0;

    switch_smac_rewrite_hash_key_init(key, &smac_entry->mac, &len, &hash);
    tommy_hashtable_remove(&smac_rewrite_table, switch_smac_rewrite_hash_cmp, key, hash);
}
コード例 #3
0
ファイル: switch_neighbor.c プロジェクト: krambn/switch
static switch_status_t switch_neighbor_dmac_delete_hash(
    switch_device_t device, switch_handle_t bd_handle, switch_mac_addr_t *mac) {
  switch_neighbor_dmac_t *neighbor_dmac = NULL;
  unsigned char key[SWITCH_NEIGHBOR_DMAC_HASH_KEY_SIZE];
  unsigned int len = 0;
  uint32_t hash = 0;
  switch_status_t status = SWITCH_STATUS_SUCCESS;

  neighbor_dmac = switch_neighbor_dmac_search_hash(bd_handle, mac);
  if (!neighbor_dmac) {
    return SWITCH_STATUS_ITEM_NOT_FOUND;
  }
  switch_neighbor_dmac_hash_key_init(key, bd_handle, mac, &len, &hash);
  neighbor_dmac = tommy_hashtable_remove(
      &switch_neighbor_dmac_table, switch_neighbor_dmac_hash_cmp, key, hash);
  switch_free(neighbor_dmac);
  return status;
}
コード例 #4
0
ファイル: switch_l3.c プロジェクト: krambn/switch
static switch_status_t switch_l3_delete_hash(switch_handle_t vrf,
                                             switch_ip_addr_t *ip_addr) {
  switch_l3_hash_t *hash_entry = NULL;
  unsigned char key[SWITCH_L3_HASH_KEY_SIZE];
  unsigned int len = 0;
  uint32_t hash;
  switch_status_t status = SWITCH_STATUS_SUCCESS;

  if (!switch_l3_host_entry(ip_addr)) {
    switch_l3_remove_from_lpm_trie(vrf, ip_addr);
  }

  switch_l3_hash_key_init(key, vrf, ip_addr, &len, &hash);
  hash_entry = tommy_hashtable_remove(
      &switch_l3_hash_table, switch_l3_hash_cmp, key, hash);
  switch_l3_remove_from_vrf_list(hash_entry);
  switch_free(hash_entry);
  return status;
}
コード例 #5
0
static switch_status_t
switch_nhop_delete_hash(switch_spath_info_t *spath_info)
{
    switch_nhop_key_t                 *temp_nhop_key = NULL;
    unsigned char                      key[SWITCH_NHOP_HASH_KEY_SIZE];
    uint32_t                           len = 0;
    uint32_t                           hash = 0;

    temp_nhop_key = &spath_info->nhop_key;
    if (!temp_nhop_key->ip_addr_valid) {
        return SWITCH_STATUS_SUCCESS;
    }
    switch_nhop_hash_key_init(key, temp_nhop_key, &len, &hash);
    spath_info = tommy_hashtable_remove(&switch_nhop_hash_table,
                                        switch_nhop_hash_cmp,
                                        key, hash);
    if (!spath_info) {
        return SWITCH_STATUS_ITEM_NOT_FOUND;
    }
    return SWITCH_STATUS_SUCCESS;
}