/**
 *
 * @brief Get Proxyserver info
 *
 * @param[out] ProxyServer
 * @param[in] ProxyServerLen
 * @param[out] ProxyServerLenReq
 *
 * @return HTTPReturnCode
 */
HTTPReturnCode HTTPStackHelper::GetProxyServer
(
 char* ProxyServer,
 size_t ProxyServerLen,
 size_t &ProxyServerLenReq
)
{
  HTTPReturnCode rsltCode = HTTP_FAILURE;
  ProxyServerLenReq = 0;

  if (m_ProxyServerName)
  {
    size_t servLen = std_strlen(m_ProxyServerName);
    if (servLen > 0)
    {
      size_t reqProxyStrLen = servLen + 7; //(7 characters assuming max port 65535,":","\0" )

      char *localProxyStr = (char *)QTV_Malloc((reqProxyStrLen) * sizeof(char));
      if (localProxyStr)
      {
        size_t offset = 0;
        offset += std_strlprintf(localProxyStr+offset,reqProxyStrLen-offset, "%s:%d",
                                 m_ProxyServerName,m_ProxyServerPort);

        size_t actualProxyStrLen = std_strlen(localProxyStr);
        if (actualProxyStrLen > 0)
        {
          if (ProxyServer != NULL && ProxyServerLen > 0 )
          {
            if (ProxyServerLen > actualProxyStrLen)
            {
              std_strlcpy(ProxyServer,localProxyStr,ProxyServerLen);
              ProxyServerLenReq = actualProxyStrLen ;
              rsltCode = HTTP_SUCCESS;
            }
            else if (ProxyServerLen <= actualProxyStrLen )
            {
              ProxyServerLenReq = actualProxyStrLen+1 ;
              rsltCode = HTTP_BADPARAM;
            }
          }
          else if(ProxyServer == NULL && ProxyServerLen == 0)
          {
            ProxyServerLenReq = actualProxyStrLen ;
            rsltCode = HTTP_SUCCESS;
          }
        }
        QTV_Free(localProxyStr);
        localProxyStr = NULL;
      }
    }
  }
  return rsltCode;
}
HTTPReturnCode
HTTPStackHelper::GetContentType(uint32 requestId,
                                char *contentType,
                                size_t contentTypeLen,
                                size_t *contentTypeLenReq)
{
  HTTPReturnCode result = HTTP_FAILURE;

  if (NULL == m_HTTPState)
  {
    QTV_MSG_PRIO(QTVDIAG_HTTP_STACK, QTVDIAG_PRIO_ERROR,
      "HTTPStackHelper::GetContentType : m_HTTPState is NULL");
  }
  else
  {
    GetContentTypeArgument arg(contentType, contentTypeLen, contentTypeLenReq);

    const char *respContentType = m_HTTPStateInfo.GetContentType(requestId);
    if (NULL == contentType)
    {
      if(NULL != respContentType)
      {
        *contentTypeLenReq = std_strlen(respContentType) + 1;
        result = HTTP_SUCCESS;
      }
    }
    else
    {
      if (NULL != respContentType)
      {
        std_strlcpy(contentType, respContentType, contentTypeLen);
        result = HTTP_SUCCESS;
      }
    }
  }

  return result;
}
int qdp_test_10(void)
{
  int ret = QDP_FAILURE;
  int i=0, rc, qmi_err_code;
  char * params[QDP_RIL_PARAM_MAX];
  unsigned int profile_id_3gpp = 0, profile_id_3gpp2 = 0;
  qdp_profile_pdn_type profile_3gpp_pdn, profile_3gpp2_pdn;
  int qmi_wds_hndl = -1;
  qmi_wds_profile_id_type profile_id;
  qmi_wds_profile_params_type profile_params;
  boolean profile_created = FALSE;
  qdp_error_info_t error_info;
  qmi_wds_addr_alloc_pref addr_pref = DHCP_USED;
  qmi_wds_lte_qos_params_type lte_qos_params;
  unsigned long bit_rate = 0x11;
  lte_qos_params.g_dl_bit_rate = bit_rate;
  lte_qos_params.max_ul_bit_rate = bit_rate;


  memset( &profile_id, 0x0, sizeof(profile_id));

  QDP_TEST_LOG("%s","qdp_test_10: prereq: use QMI to create IPv6 3GPP profile at beginning");
  QDP_TEST_LOG("qdp_test_10: 3gpp/3gpp2 profiles look up for APN [%s]ENTRY",
                QDP_TEST_APN_NAME);

  do
  {
#ifdef FEATURE_QDP_FUSION
    if (qdp_init(FUSION_PORT) == QDP_SUCCESS)
    {
      QDP_TEST_LOG("INIT QDP success on %s for Fusion", FUSION_PORT);
    }
    else
    {
      QDP_TEST_LOG("INIT QDP failed on %s for Fusion", FUSION_PORT);
    }
#else
    if (qdp_init(NON_FUSION_PORT) == QDP_SUCCESS)
    {
      QDP_TEST_LOG("INIT QDP success on %s for non-Fusion", NON_FUSION_PORT);
    }
    else
    {
      QDP_TEST_LOG("INIT QDP failed on %s for non-Fusion", NON_FUSION_PORT);
    }
#endif
    memset(params, 0, sizeof(char *)*QDP_RIL_PARAM_MAX);

    /* create 3GPP profile with "qdp_test_apn" as APN */
#ifdef FEATURE_QDP_FUSION
    qmi_wds_hndl = qmi_wds_srvc_init_client(FUSION_PORT,
                                            NULL,
                                            NULL,
                                            &qmi_err_code);
    QDP_TEST_LOG("INIT qmi_wds_srvc_init_client on %s for Fusion", FUSION_PORT);
#else
    qmi_wds_hndl = qmi_wds_srvc_init_client(NON_FUSION_PORT,
                                            NULL,
                                            NULL,
                                            &qmi_err_code);
    QDP_TEST_LOG("INIT qmi_wds_srvc_init_client on %s for Non-Fusion", NON_FUSION_PORT);
#endif

    if (qmi_wds_hndl < 0)
    {
      QDP_LOG_ERROR("can not init wds hndl err=[%d]",
                    qmi_err_code);
    }

    memset(&profile_params, 0, sizeof(profile_params));
    profile_params.umts_profile_params.param_mask |=
      QMI_WDS_UMTS_PROFILE_PDP_TYPE_PARAM_MASK;

    profile_params.umts_profile_params.pdp_type =
      QMI_WDS_PDP_TYPE_IPV6;

    profile_params.umts_profile_params.param_mask |=
      QMI_WDS_UMTS_PROFILE_APN_NAME_PARAM_MASK;

    std_strlcpy(profile_params.umts_profile_params.apn_name,
                "qdp-cr_nandan",
                strlen(QDP_TEST_APN_NAME)+1);

    QDP_TEST_LOG("profile setting addr_alloc_pref to %d", addr_pref);

    profile_params.umts_profile_params.param_mask |=
      QMI_WDS_UMTS_PROFILE_ADDR_ALLOC_PREF_PARAM_MASK;

    profile_params.umts_profile_params.addr_alloc_pref=
      addr_pref;

    QDP_TEST_LOG("profile setting lte qos g_dl_bit_rate to %lud", lte_qos_params.g_dl_bit_rate);
    QDP_TEST_LOG("profile setting lte qos max_ul_bit_rate to %lud", lte_qos_params.max_ul_bit_rate);

    profile_params.umts_profile_params.param_mask |=
      QMI_WDS_UMTS_PROFILE_LTE_QOS_PARAMS_PARAM_MASK;
    profile_params.umts_profile_params.lte_qos_params=
      lte_qos_params;

    profile_params.umts_profile_params.param_mask |=
      QMI_WDS_UMTS_PROFILE_APN_DISABLED_FLAG_PARAM_MASK;

    profile_params.umts_profile_params.apn_disabled_flag = 1;
    QDP_TEST_LOG("profile setting apn_disabled_flag to %d",
      profile_params.umts_profile_params.apn_disabled_flag);

    profile_params.umts_profile_params.param_mask |=
      QMI_WDS_UMTS_PROFILE_PDN_INACTIVITY_TIMEOUT_PARAM_MASK;
    profile_params.umts_profile_params.pdn_inactivity_timeout= 12;

    QDP_TEST_LOG("profile setting pdn_inactivity_timeout to %lud",
      profile_params.umts_profile_params.pdn_inactivity_timeout);

    profile_id.technology = QMI_WDS_PROFILE_TECH_3GPP;

    rc = qmi_wds_create_profile(
                                 qmi_wds_hndl,
                                 &profile_id,
                                 &profile_params,
                                 &qmi_err_code);
    if (QMI_NO_ERR != rc)
    {
      QDP_LOG_ERROR("can not create prereq 3gpp profile rc=[%d], err=[%d]",
                     rc, qmi_err_code);
    }

    QDP_TEST_LOG("profile [%d] created",(int)profile_id.profile_index);
    profile_created = TRUE;

    QDP_TEST_LOG("%s", "Profile created. Enter any key to move forward\n");
    getchar();

    params[QDP_RIL_APN] = (char *)malloc((strlen(QDP_TEST_APN_NAME)+1)*sizeof(char));
    if (NULL == params[QDP_RIL_APN])
    {
      QDP_LOG_ERROR("%s","memory error");
      break;
    }
    std_strlcpy(params[QDP_RIL_APN],QDP_TEST_APN_NAME, strlen(QDP_TEST_APN_NAME)+1);

    params[QDP_RIL_IP_FAMILY] = (char *)malloc((strlen(QDP_RIL_IP_6)+1)*sizeof(char));;
    if (NULL == params[QDP_RIL_IP_FAMILY])
    {
      QDP_LOG_ERROR("%s","memory error");
      break;
    }
    std_strlcpy(params[QDP_RIL_IP_FAMILY],QDP_RIL_IP_6, strlen(QDP_RIL_IP_6)+1);

    rc = qdp_profile_look_up( (const char **)params,
                              &profile_id_3gpp,
                              &profile_3gpp_pdn,
                              &profile_id_3gpp2,
                              &profile_3gpp2_pdn,
                              &error_info );

    QDP_TEST_LOG("profile id [%d] 3gpp found/created", profile_id_3gpp);
    QDP_TEST_LOG("profile id [%d] 3gpp2 found/created", profile_id_3gpp2);
    QDP_TEST_LOG("error code[%d] tech[%d]", error_info.error, error_info.tech);

    if (0 != profile_id_3gpp)
    {
      qdp_profile_release(profile_id_3gpp);
      QDP_TEST_LOG("profile id [%d] 3gpp released", profile_id_3gpp);
    }
    if (0 != profile_id_3gpp2)
    {
      qdp_profile_release(profile_id_3gpp2);
      QDP_TEST_LOG("profile id [%d] 3gpp2 released", profile_id_3gpp2);
    }
    /* Query the profile info and match */
    memset(&profile_params, 0, sizeof(profile_params));

    rc = qmi_wds_query_profile
    (
      qmi_wds_hndl,
      &profile_id,
      &profile_params,
      &qmi_err_code
    );
    /* Verify the parameters */
    QDP_TEST_LOG("profile addr_alloc_pref is %d",
    profile_params.umts_profile_params.addr_alloc_pref );
    QDP_TEST_LOG("profile  lte qos g_dl_bit_rate to %lud",
      profile_params.umts_profile_params.lte_qos_params.g_dl_bit_rate);
    QDP_TEST_LOG("profile  lte qos max_ul_bit_rate to %lud",
      profile_params.umts_profile_params.lte_qos_params.max_ul_bit_rate);
    QDP_TEST_LOG("profile  apn_disabled_flag to %d",
      profile_params.umts_profile_params.apn_disabled_flag);
    QDP_TEST_LOG("profile  pdn_inactivity_timeout  to %lud",
      profile_params.umts_profile_params.pdn_inactivity_timeout);


    QDP_TEST_LOG("%s", "Enter any key to quit\n");
    getchar();

    qdp_deinit();

    if (QMI_NO_ERR != rc)
    {
      QDP_LOG_ERROR("qdp_profile_look_up failed err [%d]",
                    rc);
      break;
    }

    ret = QDP_SUCCESS;
  } while (0);

  if (profile_created)
  {
    rc = qmi_wds_delete_profile(qmi_wds_hndl,
                                &profile_id,
                                &qmi_err_code);
    if (QMI_NO_ERR != rc)
    {
      QDP_TEST_LOG("profile [%d] deleted",(int)profile_id.profile_index);
    }
    else
    {
      QDP_LOG_ERROR("could not delete profile [%d]. rc=[%d],qmi_err=[%d]",profile_id.profile_index,
                    rc,qmi_err_code);
    }
  }

  if (qmi_wds_hndl >= 0)
  {
    rc = qmi_wds_srvc_release_client(qmi_wds_hndl, &qmi_err_code);
    if (QMI_NO_ERR != rc)
    {
      QDP_LOG_ERROR("can not release wds hndl  rc=[%d], err=[%d]",
                    rc, qmi_err_code);
    }
  }

  for(i=0; i<QDP_RIL_PARAM_MAX; i++)
  {
    if (NULL != params[i])
    {
      QDP_TEST_LOG("freeing [%p]", params[i]);
      free(params[i]);
    }
  }

  if (QDP_SUCCESS != ret)
  {
    QDP_LOG_ERROR("%s","qdp_init EXIT failed");
  }
  else
  {
    QDP_TEST_LOG("%s","qdp_init EXIT success");
  }

  return ret;
}
HTTPReturnCode
HTTPStackHelper::NotifyEvent(uint32 requestId, HTTPStackNotifyCode notifyCode)
{
  HTTPReturnCode rsltCode = HTTP_FAILURE;

  HTTPStackNotificationCbData cbData = {0,NULL,NULL,false,NULL,NULL,NULL};
  cbData.m_serverCode = m_HTTPStateInfo.GetHTTPResponseCode(requestId);
  cbData.m_serverMessage = (char*)m_HTTPStateInfo.GetReasonPhraseStr(requestId);
  cbData.m_entityBody = (char*)m_HTTPStateInfo.GetEntityBody(requestId);
  cbData.m_method = (char *)HTTPStackCommon::GetStringForMethod(m_HTTPStateInfo.GetRequestMethod(requestId));
  cbData.m_protocolHeaders = NULL;
  cbData.m_pHTTPStack = m_pHTTPStack;

  int reqLen = 0;

  /**
  * This commented code is in line with what is specified for
  * protocol header events. However, current decision is to send
  * protocol header event for authorization or porxy-authoirzation
  * only. If this changes then this can be uncommented and th the
  * code following this can be
  * removed.
  *
  * httpResponse.GetHeaders(NULL, 0, reqLen);
  *
  * if (reqLen > 0)
  *{
  * int bufSize = reqLen; cbData.m_protocolHeaders = (char
  *
  *  *)QTV_Malloc(bufSize * sizeof(char));
  *
  * if (cbData.m_protocolHeaders)
  * {
  *   httpResponse.GetHeaders(cbData.m_protocolHeaders,bufSize,
  *reqLen);
  *  }
  *  }
  *  else {
  *  QTV_MSG_PRIO1(QTVDIAG_HTTP_STREAMING, QTVDIAG_PRIO_ERROR,
  *
  *   "HTTPStackHelper::NotifyEvent Did not find headers for
  *   response. ServerCode %d", cbData.m_serverCode);
  *   }
  */

  static const int AUTHENTICATE_KEY_LEN = (int)std_strlen(HTTPStackCommon::AUTHENTICATE_KEY);
  static const int PROXY_AUTHENTICATE_KEY_LEN = (int)std_strlen(HTTPStackCommon::PROXY_AUTHENTICATE_KEY);
  static const char *DELIM = ": ";
  static const int DELIM_LEN = (int)std_strlen(DELIM);
  static const char *TERMINATE = "\r\n\r\n";
  static const int TERMINATE_LEN = (int)std_strlen(TERMINATE);

    m_HTTPStateInfo.GetHeaderValue(requestId,
    HTTPStackCommon::AUTHENTICATE_KEY, AUTHENTICATE_KEY_LEN,
    NULL, 0, &reqLen);

  if (reqLen > 0)
  {
    // response header contains "WWW-Authenticate"
    int reqdBufSize = AUTHENTICATE_KEY_LEN + DELIM_LEN + reqLen + TERMINATE_LEN + 1;
    cbData.m_protocolHeaders = (char *)QTV_Malloc(reqdBufSize * sizeof(char));
    if (cbData.m_protocolHeaders)
    {
      std_strlcpy(cbData.m_protocolHeaders, HTTPStackCommon::AUTHENTICATE_KEY, reqdBufSize);
      std_strlcat(cbData.m_protocolHeaders, DELIM, reqdBufSize);
      int tmpLen = reqLen;
      m_HTTPStateInfo.GetHeaderValue(requestId,
        HTTPStackCommon::AUTHENTICATE_KEY, AUTHENTICATE_KEY_LEN,
        cbData.m_protocolHeaders + AUTHENTICATE_KEY_LEN + DELIM_LEN, reqLen, &tmpLen);
      std_strlcat(cbData.m_protocolHeaders, TERMINATE, reqdBufSize);
    }
    else
    {
      QTV_MSG_PRIO(QTVDIAG_HTTP_STREAMING, QTVDIAG_PRIO_ERROR,
        "cbData.m_protocolHeaders for authentication is NULL");
    }
  }
  else
  {
      m_HTTPStateInfo.GetHeaderValue(requestId,
      HTTPStackCommon::PROXY_AUTHENTICATE_KEY, PROXY_AUTHENTICATE_KEY_LEN,
      NULL, 0, &reqLen);

    if (reqLen > 0)
    {
      int reqdBufSize = PROXY_AUTHENTICATE_KEY_LEN + DELIM_LEN + reqLen + TERMINATE_LEN + 1;
      cbData.m_protocolHeaders = (char *)QTV_Malloc(reqdBufSize * sizeof(char));

      if (cbData.m_protocolHeaders)
      {
        std_strlcpy(cbData.m_protocolHeaders, HTTPStackCommon::PROXY_AUTHENTICATE_KEY, reqdBufSize);
        std_strlcat(cbData.m_protocolHeaders, DELIM, reqdBufSize);
        int tmpLen = reqLen;
        m_HTTPStateInfo.GetHeaderValue(requestId,
          HTTPStackCommon::PROXY_AUTHENTICATE_KEY, PROXY_AUTHENTICATE_KEY_LEN,
          cbData.m_protocolHeaders + PROXY_AUTHENTICATE_KEY_LEN + DELIM_LEN, reqLen, &tmpLen);
        std_strlcat(cbData.m_protocolHeaders, TERMINATE, reqdBufSize);
      }
      else
      {
        QTV_MSG_PRIO(QTVDIAG_HTTP_STREAMING, QTVDIAG_PRIO_ERROR,
          "cbData.m_protocolHeaders for proxy-authentication is NULL");
      }
    }
  }

  rsltCode =  m_fNotifyCallback(requestId, notifyCode,&cbData, m_pOwner);

  return rsltCode;
}
HTTPReturnCode HTTPStackHelper::SetProxyServer (const char* proxyServer, size_t proxyServerLen)
{
  HTTPReturnCode result = HTTP_FAILURE;

  char *localProxyUrl = NULL;

  if (proxyServerLen > (size_t)HTTPStackCommon::MAX_PROXY_URL_LEN)
  {
    result = HTTP_BADPARAM;

    QTV_MSG_PRIO1(QTVDIAG_HTTP_STACK, QTVDIAG_PRIO_ERROR,
      "HTTPStackHelper::SetProxyServer : Invalid proxyServerLen '%d'",
       proxyServerLen);
  }
  else
  {
    localProxyUrl = (char *)QTV_Malloc( (proxyServerLen + 1) * sizeof(char));
    if (NULL == localProxyUrl)
    {
      QTV_MSG_PRIO(QTVDIAG_HTTP_STACK, QTVDIAG_PRIO_ERROR,
        "HTTPStackHelper::SetProxyServer : Failed to allocate localProxyUrl");
    }
    else
    {
      std_strlcpy(localProxyUrl, proxyServer, proxyServerLen + 1);
      localProxyUrl[proxyServerLen] = 0;

      if (NULL != m_ProxyServerName)
      {
        QTV_Free(m_ProxyServerName);
        m_ProxyServerName = NULL;
      }

      m_ProxyServerName = (char *)QTV_Malloc((proxyServerLen + 1) * sizeof(char));
      if (NULL == m_ProxyServerName)
      {
        QTV_MSG_PRIO(QTVDIAG_HTTP_STACK, QTVDIAG_PRIO_ERROR,
        "HTTPStackHelper::SetProxyServer : Failed to allocate m_ProxyServerName");
      }
      else
      {
        result = HTTP_SUCCESS;
        char *posPort = std_strstr(localProxyUrl, ":");
        if (NULL == posPort)
        {
          m_ProxyServerPort = HTTPStackCommon::DEFAULT_HTTP_PORT;
          std_strlcpy(m_ProxyServerName, localProxyUrl, (proxyServerLen + 1));
        }
        else
        {
          int32 m_temp_ProxyServerPort = atoi(posPort+1);
          if (!m_temp_ProxyServerPort)
          {
            // not able to parse
            QTV_MSG_PRIO(QTVDIAG_HTTP_STACK, QTVDIAG_PRIO_ERROR,
             "HTTPStackHelper::SetProxyServer - Error in  parsing");
          }
          else
          {
            m_ProxyServerPort = (unsigned short)m_temp_ProxyServerPort;
          }
          *posPort = '\0';
          std_strlcpy(m_ProxyServerName, localProxyUrl, proxyServerLen + 1);
        }
      } // end if (m_ProxyServerName...)

    } // end if(localProxyUrl...)

    if (localProxyUrl)
    {
      QTV_Free(localProxyUrl);
      localProxyUrl = NULL;
    }
  }

  if (result == HTTP_SUCCESS)
  {
    result = m_HTTPStateInfo.SetProxyInfo(m_ProxyServerName,m_ProxyServerPort);
  }
  return result;
}
Exemplo n.º 6
0
/*===========================================================================
FUNCTION DS707_DATA_READ_SPECIAL_NAIS_FROM_EFS()

DESCRIPTION
  This function will parese the special_nai.txt file frome efs and fills the profile_info data 
  structure

DEPENDENCIES
  None.

PARAMETERS
  None

RETURN VALUE
  SUCCESS - if parsing is completed correctly.
  FAILURE - if parsing found to be incorrect.
  
SIDE EFFECTS
  None.
===========================================================================*/
boolean ds707_data_read_special_nais_from_efs( )
{
   int copy_len, i;
   char *from, *to;
   ds_efs_token_type fparser;
   ds_efs_token_parse_status_enum_type  ret_val;
   ds707_data_session_profile_field_type profile_field;
   char value[PPP_MAX_USER_ID_LEN];
   uint32 data = 0;
   boolean bad_record = FALSE;
   boolean skipped_port = FALSE;
   /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
   ret_val = DS_EFS_TOKEN_PARSE_SUCCESS;
   profile_field = DS_APP_TYPE;
   
   if( ds_efs_file_init ("/nv/item_files/modem/3GPP2/omh_nai_config.txt", &fparser) == -1 )
   {
     MSG_ERROR("Exiting OUT", 0, 0, 0);
     return FALSE;
   }

   /*-------------------------------------------------------------------------
     Parse each token at a time and assign it to the appropriate variable
    ------------------------------------------------------------------------*/
   i = 0;

   while ( DS_EFS_TOKEN_PARSE_EOF != (ret_val = ds_efs_tokenizer(&fparser, &from, &to )))
   {
      MSG_HIGH(" Ret val %d ",ret_val,0,0);
     /*------------------------------------------------------------------------
       Token being read. from points to the beginning of the token and
       to point to the end of the token.
      ------------------------------------------------------------------------*/
     if( DS_EFS_TOKEN_PARSE_SUCCESS == ret_val )
     {
       if(to == from )
       {
         continue ;
       }
       copy_len = 0;
       switch(profile_field)
       {
         case DS_APP_TYPE:
           value[0] = '\0';
           copy_len = (to-from);
           memcpy((void*)&value, (void*)from, copy_len);
           value[copy_len] = '\0';
           (void)dsatutil_atoi((void*)&data,(void*)&value,10);
           special_nai_info[num_valid_nais].app_type = data;           
           profile_field = DS_NAI;
           break;
 
         case DS_NAI:
           value[0] = '\0';
           copy_len = (to-from);
           memcpy((void*)&value, (void*)from, copy_len);
           value[copy_len] = '\0';
           std_strlcpy((char *)(special_nai_info[num_valid_nais].nai),(char*)&value,copy_len+1);
           profile_field = DS_APP_TYPE;
           num_valid_nais++;
           break;
       }
     }
     else if(DS_EFS_TOKEN_PARSE_EOL == ret_val )
     {
       if(profile_field == DS_NAI)
       {
         value[0] = '\0';
         copy_len = (to-from);
         if(copy_len == 0)
         { 
           continue;
         }
         memcpy((void*)&value, (void*)from, copy_len);
         value[copy_len] = '\0';
         std_strlcpy((char *)(special_nai_info[num_valid_nais].nai),(char*)&value,copy_len+1);
         profile_field = DS_APP_TYPE;
         num_valid_nais++;
       }
       if( fparser.eof == 1 )
       { 
         MSG_HIGH("Parsing completed. Valid special NAIs read : %d",num_valid_nais,0,0);
         return TRUE;
       }
     }
   }

   MSG_HIGH("Done Parsing the file",0,0,0);
 } /* ds707_data_read_special_nais_from_efs() */
/** @brief Parses the input URL and fills in the default port if port already
  * not present.
  *
  * @param[in] pDefaultPort - Default HTTP port to use if port not present in URL
  * @param[out] pLaunchURL - Launch URL used to connect to server
  * @return
  * TRUE - Launch URL ready
  * FALSE - Otherwise
  */
bool PlaylistDownloadHelper::ParseURL
(
 const char* pDefaultPort,
 char*& pLaunchURL
 )
{
  bool bOk = false;

  URL url(GetURL());
  size_t launchURLLen = url.GetUrlLength() + 1;
  uint32 port = 0;

  if (pLaunchURL)
  {
    QTV_Free(pLaunchURL);
    pLaunchURL = NULL;
  }

  if (url.GetPort(&port) == URL::URL_OK)
  {
    if (port)
    {
      pLaunchURL = (char*)QTV_Malloc(launchURLLen);
      if (pLaunchURL && url.GetUrlBuffer())
      {
        bOk = true;
        (void)std_strlcpy(pLaunchURL, url.GetUrlBuffer(), launchURLLen);
      }
    }
    else if (pDefaultPort)
    {
      char hostName[HTTP_MAX_HOSTNAME_LEN] = {0};

      //Extra space for ":9300"
      launchURLLen += std_strlen(pDefaultPort) + 1;
      pLaunchURL = (char*)QTV_Malloc(launchURLLen);
      if (pLaunchURL &&
        url.GetHost(hostName, sizeof(hostName)) == URL::URL_OK)
      {
        //Write http://
        size_t arg2 = std_strlen("http://") + 1;
        size_t dstBufLen = STD_MIN(launchURLLen, arg2);
        size_t numURLBytes = std_strlcpy(pLaunchURL,
          "http://", dstBufLen);

        //Write hostname
        arg2 = std_strlen(hostName) + 1;
        dstBufLen = STD_MIN(launchURLLen - numURLBytes, arg2);
        numURLBytes += std_strlcpy(pLaunchURL + numURLBytes,
          hostName, dstBufLen);

        //Write :
        arg2 = std_strlen(":") + 1;
        dstBufLen = STD_MIN(launchURLLen - numURLBytes, arg2);
        numURLBytes += std_strlcpy(pLaunchURL + numURLBytes,
          ":", dstBufLen);

        //Write default port
        arg2 = std_strlen(pDefaultPort) + 1;
        dstBufLen = STD_MIN(launchURLLen - numURLBytes, arg2);
        numURLBytes += std_strlcpy(pLaunchURL + numURLBytes,
          pDefaultPort, dstBufLen);

        //Write /
        arg2 = std_strlen("/") + 1;
        dstBufLen = STD_MIN(launchURLLen - numURLBytes, arg2);
        numURLBytes += std_strlcpy(pLaunchURL + numURLBytes,
          "/", dstBufLen);

        //Write clipname
        dstBufLen = launchURLLen - numURLBytes;
        char* pClipName = NULL;
        pClipName = (char*)QTV_Malloc(dstBufLen);
        if (pClipName)
        {
          if (url.GetClipName(pClipName, dstBufLen) == URL::URL_OK)
          {
            bOk = true;
            (void)std_strlcpy(pLaunchURL + numURLBytes,
              pClipName, dstBufLen);
          }
          QTV_Free(pClipName);
        }
      }
    }
    else
    {
      QTV_MSG_PRIO( QTVDIAG_HTTP_STREAMING, QTVDIAG_PRIO_ERROR,
        "Error: Invalid port" );
    }
  }
  if(!bOk)
  {
    if(pLaunchURL)
    {
      QTV_Free(pLaunchURL);
    }
  }
  return bOk;
}
Exemplo n.º 8
0
/*==============================================================================

FUNCTION          HSU_CONF_SEL_NV_IMEI_READ

DESCRIPTION
Read the IMEI from NV and convert it into ascii.

DEPENDENCIES
None.

RETURN VALUE
TRUE for success, FALSE for failure.

SIDE EFFECTS
The calling function is stopped until NV read operation is finished.

==============================================================================*/
boolean hsu_conf_sel_nv_imei_read
(
 char * return_buff_ptr,                  /* Pointer to return buffer */
 uint32 return_buff_size                  /* The size of the giver buffer */
 ) 
{
  nv_item_type      nv_item_data;
  nv_stat_enum_type nv_operation_status;
  uint8 imei_bcd_len = 0;
  uint8 n = 0;
  uint8 digit;
  /* We need an extra digit for the id digit so we keep a size of (NV_UE_IMEI_SIZE-1)*2+1 */
  char imei_ascii[HSU_CFG_SELECTOR_MAX_ESN_IMEI_SIZE+1];

  return_buff_ptr[0] = '\0';

  nv_operation_status = hsu_conf_sel_nv_read(NV_UE_IMEI_I, &nv_item_data);
  /* Note that because IMEI is a special read only variable, it may return an all 0s   */
  /* value to indicate that it has never been written rather than the result code that */
  /* indicates the item is not active */
  if ((nv_operation_status != NV_DONE_S) || (nv_item_data.ue_imei.ue_imei[0] == 0))
  {
    /*    HSU_MSG_HIGH(
    "*_nv_imei_read(): Couldn't read NV_UE_IMEI_I from NV (status = %d)",
    nv_operation_status, 0, 0);
    ERR(
    "*_nv_imei_read(): Couldn't read NV_UE_IMEI_I from NV (status = %d)",
    nv_operation_status, 0, 0);*/
    return FALSE;
  }

  /* Convert it to ASCII */
  /* The first byte is the imei_bcd_len */
  imei_bcd_len = nv_item_data.ue_imei.ue_imei[0];

  /* Each byte contains two digits.
  The first byte contains an ID (that we should ignore later on 
  when we copy the imei_ascii) and then the first actual digit*/
  if( imei_bcd_len <= (NV_UE_IMEI_SIZE-1) )
  {
    /* This is a valid IMEI */
    memset(imei_ascii, 0, HSU_CFG_SELECTOR_MAX_ESN_IMEI_SIZE+1);

    for( n = 1; n <= imei_bcd_len; n++ )
    {
      digit = nv_item_data.ue_imei.ue_imei[n] & 0x0F;
      if( ( digit <= 9 ) || ( n <= 1 ) )
      {
        imei_ascii[ (n - 1) * 2 ] = digit + '0';
      }
      else
      {
        imei_ascii[ (n - 1) * 2 ] = '\0';
        break;
      }

      digit = nv_item_data.ue_imei.ue_imei[n] >> 4;
      if( ( digit <= 9 ) || ( n <= 1 ) )
      {
        imei_ascii[ ((n - 1) * 2) + 1 ] = digit + '0';
      }
      else
      {
        imei_ascii[ ((n - 1) * 2) + 1 ] = '\0';
        break;
      }
    }
    imei_ascii[HSU_CFG_SELECTOR_MAX_ESN_IMEI_SIZE] = '\0';

    /* Lose the first byte because it is just the ID */
    std_strlcpy(return_buff_ptr, imei_ascii + 1, (int)return_buff_size);
  }