Esempio n. 1
0
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;
}
Esempio n. 2
0
switch_status_t
switch_smac_rewrite_delete_entry(switch_mac_addr_t *mac)
{
    switch_smac_entry_t               *smac_entry = NULL;
    switch_status_t                    status = SWITCH_STATUS_SUCCESS;
    switch_device_t                    device = SWITCH_DEV_ID;

    smac_entry = switch_smac_rewrite_search_entry(mac);
    if (!smac_entry) {
        SWITCH_API_ERROR("%s:%d: unable to find mac!", __FUNCTION__, __LINE__);
        return SWITCH_STATUS_ITEM_NOT_FOUND;
    }

    smac_entry->ref_count--;
    if (smac_entry->ref_count == 0) {
        switch_pd_smac_rewrite_table_delete_entry(device, smac_entry);
        switch_smac_rewrite_hash_delete(smac_entry);
        switch_api_id_allocator_release(smac_rewrite_index_allocator, smac_entry->smac_index);
        free(smac_entry);
    }
    return status;
}