selfcare init
This commit is contained in:
206
proxy_c/curl_adaptor.h
Normal file
206
proxy_c/curl_adaptor.h
Normal file
@@ -0,0 +1,206 @@
|
||||
#ifndef __CURL_ADAPTOR_H__
|
||||
#define __CURL_ADAPTOR_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
#include "multi.h"
|
||||
#include "curl.h"
|
||||
#include "easy.h"
|
||||
#include "common.h"
|
||||
|
||||
/* for For querying monetary or wallet balance */
|
||||
#define URLPrefix "" // "http://"
|
||||
#define URLFetchSub "/rest-services/subscriber/%s"
|
||||
#define URLFetchUPBalance "/rest-services/subscriber/%s/info/userpaymentbalance"
|
||||
#define URLFetchInfoBalance "/rest-services/subscriber/%s/info/balance"
|
||||
|
||||
/* url: <20><>ѯ */
|
||||
#define URLFetchWalletBalanceGetsubsid g_rest_proxy_env.cnf.url_fetchwalletbalance_getsubsid
|
||||
#define URLFetchWalletBalance g_rest_proxy_env.cnf.url_fetchwalletbalance
|
||||
|
||||
/* url: <20><>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>ֵ */
|
||||
#define URLRechargeGetsubsid g_rest_proxy_env.cnf.url_recharge_getsubsid
|
||||
#define URLRecharge g_rest_proxy_env.cnf.url_recharge
|
||||
|
||||
/* url: <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA> */
|
||||
#define URLTransGetsubidSender g_rest_proxy_env.cnf.url_trans_getsubsid_sender
|
||||
#define URLTransGetsubidReceiver g_rest_proxy_env.cnf.url_trans_getsubsid_receiver
|
||||
#define URLTrans g_rest_proxy_env.cnf.url_trans
|
||||
|
||||
#define RESTFUL_IP_SIZE 32
|
||||
#define RESTFUL_CUL_BUF_MAX 256
|
||||
|
||||
#define RESTFUL_SUBSID_LEN 24
|
||||
#define RESTFUL_MSISDN_LEN 24
|
||||
#define RESTFUL_USERNAME 64
|
||||
#define RESTFUL_PASSWOR 64
|
||||
|
||||
typedef struct _SRestfulInfo
|
||||
{
|
||||
char queryIP[RESTFUL_IP_SIZE];
|
||||
unsigned int queryPort;
|
||||
|
||||
char recharegeIP[RESTFUL_IP_SIZE];
|
||||
unsigned int recharegePort;
|
||||
}SRestFulInfo;
|
||||
|
||||
extern SRestFulInfo g_restful;
|
||||
|
||||
|
||||
typedef struct _SubscriberIdentity
|
||||
{
|
||||
unsigned char identityChoice; /*1:imsi,2:msisdn*/
|
||||
unsigned char msisdn[8+1]; /* TBCD */
|
||||
unsigned char imsi[8+1]; /* TBCD */
|
||||
|
||||
}SubscriberIdentity;
|
||||
|
||||
|
||||
typedef enum _ECurlType
|
||||
{
|
||||
// URL_FETCH_SUB = 0x00,
|
||||
|
||||
URL_FETCH_UPBalance = 0x00,
|
||||
URL_FETCH_InfoBalance,
|
||||
URL_FETCH_WalletBalance_Getsubsid,
|
||||
URL_FETCH_WalletBalance, /* for For querying monetary or wallet balance */
|
||||
URL_RECHAGRGE_Getsubsid,
|
||||
URL_RECHAGRGE, /* for Voucher recharge */
|
||||
|
||||
URL_TRANS_GetsubsidSender, /* ת<>˻<EFBFBD>ȡsender<65><72>subscriberID<49><44>url */
|
||||
URL_TRANS_GetsubsidReceiver, /* ת<>˻<EFBFBD>ȡreceiver<65><72>subscriberID<49><44>url */
|
||||
URL_TRANS, /* ת<>˵<EFBFBD>url */
|
||||
|
||||
URL_PPC_OfferGetAllV2_1,
|
||||
|
||||
URL_MAX_NUM,
|
||||
}ECurlType;
|
||||
|
||||
|
||||
|
||||
typedef struct _SCurlRestAdaptorHeader
|
||||
{
|
||||
unsigned short ppsAppID;
|
||||
unsigned short restproxyAppID;
|
||||
}SCurlRestAdaptorHeader;
|
||||
|
||||
typedef struct _SCurlDataFetchSubscribe
|
||||
{
|
||||
SubscriberIdentity subID;
|
||||
}SCurlDataFetchSubscribe;
|
||||
|
||||
typedef union _UCurlAdaptorVal
|
||||
{
|
||||
SCurlDataFetchSubscribe subscribeID;
|
||||
}UCurlAdaptorVal;
|
||||
|
||||
/* restful query struct */
|
||||
typedef struct _SCurlRestAdaptorQuery
|
||||
{
|
||||
char msisdn[RESTFUL_MSISDN_LEN];
|
||||
char subsid[RESTFUL_SUBSID_LEN];
|
||||
}SCurlRestAdaptorQuery;
|
||||
|
||||
/* restful query response struct */
|
||||
typedef struct _SCurlRestAdatptorQueryRes
|
||||
{
|
||||
char optional_flag;
|
||||
char result;
|
||||
char error_code;
|
||||
unsigned int balance;
|
||||
unsigned int mo_expiry;
|
||||
unsigned int mt_expiry;
|
||||
}SCurlRestAdatptorQueryRes;
|
||||
|
||||
/* restful topup struct */
|
||||
typedef struct _SCurlRestAdatptorTopup
|
||||
{
|
||||
char msisdn[RESTFUL_MSISDN_LEN];
|
||||
char pin[RESTFUL_MSISDN_LEN];
|
||||
|
||||
char subsid[RESTFUL_SUBSID_LEN];
|
||||
}SCurlRestAdatptorTopup;
|
||||
|
||||
/* restful topup response struct */
|
||||
typedef struct _SCurlRestAdatptorTopupRes
|
||||
{
|
||||
char optional_flag;
|
||||
char result;
|
||||
char error_code;
|
||||
unsigned int balance;
|
||||
unsigned int mo_expiry;
|
||||
unsigned int mt_expiry;
|
||||
}SCurlRestAdatptorTopupRes;
|
||||
|
||||
typedef struct _SCurlRestAdatptorTransfer
|
||||
{
|
||||
char msisdn_sender[24]; // ת<><D7AA><EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD>
|
||||
char msisdn_receiver[24]; // ת<><D7AA><EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD>
|
||||
unsigned int money; // ת<>˽<EFBFBD><CBBD><EFBFBD>
|
||||
|
||||
char subsid_sender[RESTFUL_SUBSID_LEN]; // ת<><D7AA><EFBFBD>˺Ŷ<CBBA>Ӧ<EFBFBD><D3A6>subscriber-id
|
||||
char subsid_receiver[RESTFUL_SUBSID_LEN]; // ת<><D7AA><EFBFBD>˺Ŷ<CBBA>Ӧ<EFBFBD><D3A6>subscriber-id
|
||||
}SCurlRestAdatptorTransfer;
|
||||
|
||||
typedef struct _SCurlRestAdatptorTransferRes
|
||||
{
|
||||
unsigned char optional_flag;
|
||||
unsigned char result;
|
||||
unsigned char error_code;
|
||||
}SCurlRestAdatptorTransferRes;
|
||||
|
||||
typedef struct _SCurlAdaptor
|
||||
{
|
||||
ECurlType urlType;
|
||||
char urlBuf[RESTFUL_CUL_BUF_MAX];
|
||||
|
||||
SCurlRestAdaptorHeader header;
|
||||
union
|
||||
{
|
||||
SCurlRestAdaptorQuery query;
|
||||
SCurlRestAdatptorQueryRes query_res;
|
||||
SCurlRestAdatptorTopup topup;
|
||||
SCurlRestAdatptorTopupRes topup_res;
|
||||
SCurlRestAdatptorTransfer transfer;
|
||||
SCurlRestAdatptorTransferRes transfer_res;
|
||||
}msg;
|
||||
}SCurlAdaptor;
|
||||
|
||||
|
||||
/*
|
||||
* curl adaptor deliver the http request, receive and resolve the reponse, then pass the info to up layer
|
||||
* curAdaptor: resolve information
|
||||
* retCode: 200->success
|
||||
*/
|
||||
typedef int (*CURL_ADAPTOR_APP_CB)(SCurlAdaptor *curAdaptor, int retCode);
|
||||
|
||||
|
||||
/*
|
||||
* function: init curl adaptor.
|
||||
* appCB: curl upper layer call back
|
||||
* restfulIP: restful host ip. host order
|
||||
* restfulPort: restful port. host order
|
||||
* ret: SUCCESS or FAILURE
|
||||
*/
|
||||
int curl_adaptor_init(CURL_ADAPTOR_APP_CB appCB, const char* queryIP, unsigned int queryPort, const char* recharegeIP, unsigned int recharegePort);
|
||||
|
||||
/*
|
||||
* function: prepare to call restful api
|
||||
* curAdaptor: para that to be send as parameter
|
||||
* ret: SUCCESS or FAILURE
|
||||
*/
|
||||
int curl_adaptor_add(SCurlAdaptor* curAdaptor);
|
||||
|
||||
/*
|
||||
* function: relese curl adaptor resource
|
||||
* ret: SUCCESS or FAILURE
|
||||
*/
|
||||
int curl_adaptor_fini();
|
||||
|
||||
|
||||
#endif /* __CURL_ADAPTOR_H__ */
|
||||
Reference in New Issue
Block a user