Пример #1
0
void psm_dp_port_added_notifications_cbk(uint32_t dprm_notification_type,
        uint64_t datapath_handle,
        struct   dprm_datapath_notification_data dprm_notification_data,
        void*    callback_arg1,
        void*    callback_arg2)
{
    int32_t  ret_val;
    uint64_t crm_port_handle;
    uint8_t  port_status;

    OF_LOG_MSG(OF_LOG_CRM,OF_LOG_DEBUG, "DPRM Add Port Notification is received");

    ret_val = crm_get_port_handle(dprm_notification_data.port_name,&crm_port_handle);
    if(ret_val != CRM_SUCCESS)
    {
        OF_LOG_MSG(OF_LOG_CRM,OF_LOG_DEBUG, "PORT is not present in CRM port database = %s",dprm_notification_data.port_name);
        return;
    }

    if(dprm_notification_data.port_id != 0)
    {
        port_status = PORT_STATUS_UP;
        crm_set_port_status(dprm_notification_data.port_name,
                            crm_port_handle,
                            dprm_notification_data.port_handle,
                            port_status,
                            dprm_notification_data.port_id);
        OF_LOG_MSG(OF_LOG_CRM,OF_LOG_DEBUG, "After crm_set_port_status call ");
    }
    else
    {
        OF_LOG_MSG(OF_LOG_CRM,OF_LOG_DEBUG,"Ignoring the DPRM Port notification due to local Port registration by Applications");
        return;
    }
}
Пример #2
0
void psm_dp_port_update_notifications_cbk(uint32_t dprm_notification_type,
        uint64_t datapath_handle,
        struct   dprm_datapath_notification_data dprm_notification_data,
        void*    callback_arg1,
        void*    callback_arg2)
{
    int32_t  ret_val;
    uint64_t crm_port_handle;
    uint8_t  port_status;

    ret_val = crm_get_port_handle(dprm_notification_data.port_name,&crm_port_handle);
    if(ret_val != CRM_SUCCESS)
    {
        OF_LOG_MSG(OF_LOG_CRM,OF_LOG_DEBUG, "PORT is not present in CRM port database = %s",dprm_notification_data.port_name);
        return;
    }

    if(dprm_notification_data.port_id != 0)
    {
        //printf("\r\n psm_dp_port_update_notifications_cbk - port updated pord_id = %d",dprm_notification_data.port_id);
        port_status = PORT_STATUS_UPDATE;
        crm_set_port_status(dprm_notification_data.port_name,crm_port_handle,
                            dprm_notification_data.port_handle,
                            port_status,dprm_notification_data.port_id);
    }
    else
    {
        OF_LOG_MSG(OF_LOG_CRM,OF_LOG_DEBUG,"Ignoring the DPRM Port notification due to local Port deregistration by Applications");
        return;
    }
}
int32_t crm_port_attribute_getfirstnrecs(struct cm_array_of_iv_pairs * keys_arr_p,
		uint32_t * count_p,
		struct cm_array_of_iv_pairs ** array_of_iv_pair_arr_p)
{
  struct cm_array_of_iv_pairs *result_iv_pairs_p = NULL;
  struct   crm_attribute_name_value_pair crm_attribute_name_value_info={};
  struct   crm_attribute_name_value_output_info crm_attribute_output={};
  char port_name[CRM_MAX_VM_NAME_LEN+1]={};

  uint64_t port_handle;
  int32_t return_value = OF_FAILURE;
  uint32_t uiRecCount = 0;

  CM_CBK_DEBUG_PRINT ("Entered");

  of_memset (&crm_attribute_name_value_info, 0, sizeof (struct crm_attribute_name_value_pair));
  of_memset(port_name, 0, sizeof(port_name));
  if ((crm_port_attribute_ucm_setmandparams (keys_arr_p, port_name, &crm_attribute_name_value_info, 
					NULL)) != OF_SUCCESS)
   {
     CM_CBK_DEBUG_PRINT ("Set Mandatory Parameters Failed");
     return OF_FAILURE;
  }
  return_value = crm_get_port_handle(port_name, &port_handle);
  if (return_value != OF_SUCCESS)
  {
    CM_CBK_DEBUG_PRINT ("Subnet does not exist with id %s",port_name);
    return OF_FAILURE;
  }

  crm_attribute_output.name_length = CRM_MAX_ATTRIBUTE_NAME_LEN -1;
  crm_attribute_output.value_length = CRM_MAX_ATTRIBUTE_VALUE_LEN -1;

  return_value = crm_get_port_first_attribute(port_name, &crm_attribute_output);
  if (return_value != OF_SUCCESS)
   {
     CM_CBK_DEBUG_PRINT ("crm_get_first_port_attribute_name failed!");
     return OF_FAILURE;
   }
   result_iv_pairs_p = (struct cm_array_of_iv_pairs *) of_calloc (1, sizeof (struct cm_array_of_iv_pairs));
  if (result_iv_pairs_p == NULL)
  {
    CM_CBK_DEBUG_PRINT ("Memory allocation failed for result_iv_pairs_p");
    return OF_FAILURE;
  }
  crm_attribute_port_getparams(&crm_attribute_output, &result_iv_pairs_p[uiRecCount]);
  uiRecCount++;
  *array_of_iv_pair_arr_p = result_iv_pairs_p;
  *count_p = uiRecCount;  
  return CRM_SUCCESS;  
}
int32_t crm_port_attribute_addrec (void * config_trans_p,
		  		     struct cm_array_of_iv_pairs * pMandParams,
			             struct cm_array_of_iv_pairs * pOptParams,
			             struct cm_app_result ** result_p)
{
  struct   cm_app_result *attribute_result = NULL;
  struct   crm_attribute_name_value_pair crm_attribute_name_value_info={};
  char port_name[CRM_MAX_VM_NAME_LEN+1];

  

  uint64_t port_handle;
  int32_t  return_value = OF_FAILURE,result;

  CM_CBK_DEBUG_PRINT ("Entered");

  of_memset (&crm_attribute_name_value_info, 0, sizeof (struct crm_attribute_name_value_pair));

  of_memset(port_name, 0, sizeof(port_name));
  if ((crm_port_attribute_ucm_setmandparams (pMandParams, 
	      port_name, &crm_attribute_name_value_info, 
	      &attribute_result)) != OF_SUCCESS)
  {
    CM_CBK_DEBUG_PRINT ("Set Mandatory Parameters Failed");
    fill_app_result_struct (&attribute_result, NULL, CM_GLU_SET_MAND_PARAM_FAILED);
    *result_p = attribute_result;
    return OF_FAILURE;
  }
  return_value = crm_get_port_handle(port_name, &port_handle);
  if (return_value != OF_SUCCESS)
  {
    CM_CBK_DEBUG_PRINT ("port does not exist with name %s",port_name);
    fill_app_result_struct (&attribute_result, NULL, CM_GLU_VM_NAME_NULL);
    *result_p = attribute_result;
    return OF_FAILURE;
  }
  return_value = crm_add_attribute_to_port(port_name, &crm_attribute_name_value_info);
  if (return_value != OF_SUCCESS)
  {
    CM_CBK_DEBUG_PRINT ("Attribute Addition Failed(ret:%d",return_value);
    fill_app_result_struct (&attribute_result, NULL, CM_GLU_ATTRIBUTE_ADD_FAILED);
    *result_p = attribute_result;
    return OF_FAILURE;
  }
  CM_CBK_DEBUG_PRINT ("Attribute added succesfully");
  return OF_SUCCESS;

}
int32_t crm_port_attribute_getexactrec (struct cm_array_of_iv_pairs * keys_arr_p,
    struct cm_array_of_iv_pairs ** pIvPairArr)

{
  struct   cm_array_of_iv_pairs *result_iv_pairs_p = NULL;
  int32_t  return_value = OF_FAILURE;
  struct   crm_attribute_name_value_pair crm_attribute_name_value_info={};
  char     port_name[CRM_MAX_VM_NAME_LEN+1]={};
  uint64_t port_handle;

  CM_CBK_DEBUG_PRINT ("Entered");

  of_memset(port_name, 0, sizeof(port_name));
  result_iv_pairs_p =
                     (struct cm_array_of_iv_pairs *) of_calloc (1, sizeof (struct cm_array_of_iv_pairs));
  if (result_iv_pairs_p == NULL)
   {
     CM_CBK_DEBUG_PRINT ("Failed to allocate memory for result_iv_pairs_p");
     return OF_FAILURE;
   }

  of_memset (&crm_attribute_name_value_info, 0, sizeof (struct crm_attribute_name_value_pair));

  if ((crm_port_attribute_ucm_setmandparams (keys_arr_p,port_name, &crm_attribute_name_value_info, 
	      NULL)) != OF_SUCCESS)
   {
     CM_CBK_DEBUG_PRINT ("Set Mandatory Parameters Failed");
     return OF_FAILURE;
   }
   return_value = crm_get_port_handle(port_name, &port_handle);
   if (return_value != OF_SUCCESS)
    {
      CM_CBK_DEBUG_PRINT ("port does not exist with name %s",port_name);
      return OF_FAILURE;
    }

  return_value = crm_get_port_exact_attribute(port_name, crm_attribute_name_value_info.name_string);
    if (return_value != OF_SUCCESS)
     {
       CM_CBK_DEBUG_PRINT ("Unable to find  exact attribute record!");
       return OF_FAILURE;
     }

  crm_attribute_port_getparams (&crm_attribute_name_value_info, result_iv_pairs_p);
  *pIvPairArr = result_iv_pairs_p;
  return return_value;
}
int32_t crm_port_attribute_delrec (void * config_transaction_p,
			struct cm_array_of_iv_pairs * keys_arr_p,
			struct cm_app_result ** result_p)
{
  struct cm_app_result *attribute_result = NULL;
  int32_t return_value = OF_FAILURE; 
  struct crm_attribute_name_value_pair attribute_info={};
  uint64_t port_handle;
  char port_name[CRM_MAX_VM_NAME_LEN+1]={};

  CM_CBK_DEBUG_PRINT ("Entered");
  of_memset (&attribute_info, 0, sizeof (struct crm_attribute_name_value_pair));

  if ((crm_port_attribute_ucm_setmandparams (keys_arr_p, port_name, &attribute_info, &attribute_result)) != OF_SUCCESS)
   {
     CM_CBK_DEBUG_PRINT ("Set Mandatory Parameters Failed");
     fill_app_result_struct (&attribute_result, NULL, CM_GLU_SET_MAND_PARAM_FAILED);
     *result_p = attribute_result;
     return OF_FAILURE;
     
   }

  return_value=crm_get_port_handle(port_name, &port_handle);
  if (return_value != OF_SUCCESS)
   {
     CM_CBK_DEBUG_PRINT ("Get port handle failed");
     fill_app_result_struct (&attribute_result, NULL, CM_GLU_VM_NAME_NULL);
     *result_p = attribute_result;
     return OF_FAILURE;
   }
  return_value=crm_delete_attribute_from_port(port_name, &attribute_info);
  if (return_value != OF_SUCCESS)
  {
    CM_CBK_DEBUG_PRINT ("Delete attribute record failed");
    fill_app_result_struct (&attribute_result, NULL, CM_GLU_ATTRIBUTE_DEL_FAILED);
    *result_p = attribute_result;
    return OF_FAILURE;
  }

  CM_CBK_DEBUG_PRINT ("port attribute deleted succesfully");
  return OF_SUCCESS;
}
int32_t crm_port_attribute_getnextnrecs (struct cm_array_of_iv_pairs * keys_arr_p,
                        struct cm_array_of_iv_pairs *prev_record_key_p, uint32_t * count_p,
                        struct cm_array_of_iv_pairs ** next_n_record_data_p)
{
  struct   cm_array_of_iv_pairs *result_iv_pairs_p = NULL;
  struct   crm_attribute_name_value_pair        crm_attribute_name_value_info={};
  struct   crm_attribute_name_value_output_info crm_attribute_output={};
  char     current_name_string[CRM_MAX_ATTRIBUTE_NAME_LEN];
  char     current_value_string[CRM_MAX_ATTRIBUTE_VALUE_LEN];
  char     port_name[CRM_MAX_VM_NAME_LEN+1]={};
  uint64_t port_handle;

  CM_CBK_DEBUG_PRINT ("Entered");

  uint64_t datapath_handle;
  int32_t return_value = OF_FAILURE;
  uint32_t uiRecCount = 0;
  uint32_t uindex_i = 0;

  of_memset (&crm_attribute_name_value_info, 0, sizeof (struct crm_attribute_name_value_pair));
  of_memset(port_name, 0, sizeof(port_name));
  if ((crm_port_attribute_ucm_setmandparams (prev_record_key_p, 
		port_name, &crm_attribute_name_value_info, 
					NULL)) != OF_SUCCESS)
  {
    CM_CBK_DEBUG_PRINT ("Set Mandatory Parameters Failed");
    return OF_FAILURE;
  }

  if ((crm_port_attribute_ucm_setmandparams (keys_arr_p, 
		port_name, &crm_attribute_name_value_info, 
					NULL)) != OF_SUCCESS)
  {
    CM_CBK_DEBUG_PRINT ("Set Mandatory Parameters Failed");
    return OF_FAILURE;
  }


  return_value = crm_get_port_handle(port_name, &port_handle);
  if (return_value != OF_SUCCESS)
  {
    CM_CBK_DEBUG_PRINT ("port does not exist with name %s",port_name);
    return OF_FAILURE;
  }
#if 0
  strcpy(current_name_string,  prev_record_key_p->iv_pairs[uindex_i].value_p);
  strcpy(current_value_string, prev_record_key_p->iv_pairs[uindex_i+1].value_p);
  strcpy(crm_attribute_output.name_string, current_name_string);
#endif
  crm_attribute_output.name_length = CRM_MAX_ATTRIBUTE_NAME_LEN -1;
  crm_attribute_output.value_length = CRM_MAX_ATTRIBUTE_VALUE_LEN -1;
  return_value = crm_get_port_next_attribute(port_name, crm_attribute_name_value_info.name_string,&crm_attribute_output);
  if (return_value != OF_SUCCESS)
  {
    CM_CBK_DEBUG_PRINT ("crm_get_port_next_attribute_name failed!");
    return OF_FAILURE;
  }

 result_iv_pairs_p = (struct cm_array_of_iv_pairs *) of_calloc (1, sizeof (struct cm_array_of_iv_pairs));
 if (result_iv_pairs_p == NULL)
 {
   CM_CBK_DEBUG_PRINT ("Memory allocation failed for result_iv_pairs_p");
   return OF_FAILURE;
 }
  crm_attribute_port_getparams(&crm_attribute_output, &result_iv_pairs_p[uiRecCount]);
  uiRecCount++;
  *next_n_record_data_p = result_iv_pairs_p;
  *count_p = uiRecCount;	
  return CRM_SUCCESS;  
}