ocs init
This commit is contained in:
187
plat/smpp/src/include/smpp.h
Normal file
187
plat/smpp/src/include/smpp.h
Normal file
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
** CDMA 2000 project, SMPP module
|
||||
**
|
||||
** File name: smpp.h
|
||||
** Written by Li Long at 2004-11-25
|
||||
** CVS $Id: smpp.h,v0.1 2004/11/25 17:03:14 lilong Exp $
|
||||
**
|
||||
*/
|
||||
#ifndef _SMPP_h
|
||||
#define _SMPP_h
|
||||
|
||||
|
||||
#include "smpp_public.h"
|
||||
#include "smpp_const.h"
|
||||
#include "../../../debug/src/include/debug.h"
|
||||
#include "../../../sccp/src/include/sccp.h"
|
||||
#include "../../../iptrans/src/include/iptrans.h"
|
||||
#include "../../../mtp3/src/include/mtp3.h"
|
||||
#include "../../../snmp/src/include/snmp.h"
|
||||
#include "../../../public/src/include/public.h"
|
||||
|
||||
#include "smpp_msg.h"
|
||||
|
||||
enum SMPP_State_Constant {INIT, IDLE, WAITING, ESTABLISHED, SUSPEND};
|
||||
enum SMPP_APIEvent {APIEventReversed, Register, Setup, Close};
|
||||
enum SMPP_InterEvent {InterEventReserved, Outbind, Unbind, UnbindResp,
|
||||
BindTransmitter, BindReceiver, BindTransceiver, //4
|
||||
BindTransmitterResp, BindReceiverResp, BindTransceiverResp, //7
|
||||
EnquireLink, EnquireLinkResp, //10
|
||||
SubmitSM, SubmitSMResp, //12
|
||||
SubmitMulti, SubmitMultiResp, //14
|
||||
DeliverSM, DeliverSMResp, //16
|
||||
DataSM, DataSMResp, //18
|
||||
GenericNak, //20
|
||||
SessionInitTimeout, EnquireLinkTimeout, InactivityTimeout, ResponseTimeOut, //21
|
||||
QuerySM, QuerySMResp, //25
|
||||
CancelSM, CancelSMResp, //27
|
||||
ReplaceSM, ReplaceSMResp, //29
|
||||
AlertNotification, //31
|
||||
UnknownCommandID}; //32
|
||||
|
||||
typedef struct SMPP_LINK
|
||||
{
|
||||
DWORD seq_num;
|
||||
DWORD command_status;
|
||||
}SMPP_LINK;
|
||||
|
||||
typedef struct SMPP_DEBUG_STRUCT
|
||||
{
|
||||
BYTE debug_switch;
|
||||
BYTE link_switch[MAX_SMPP_LINK];
|
||||
}SMPP_DEBUG_STRUCT;
|
||||
|
||||
typedef struct SMPP_PARAM
|
||||
{
|
||||
BYTE link_no; //0~31
|
||||
BYTE link_enable; //0-Disable, 1-Enable
|
||||
BYTE link_type; //0-UDP 1-TCP
|
||||
BYTE server_type; //0-SMPP_CLIENT; 1-SMPP_SERVER
|
||||
BYTE session_type; //0-BIND_TX; 1-BIND_RX; 2-BIND_TRX
|
||||
char sys_id[16];
|
||||
char password[9];
|
||||
char system_type[13];
|
||||
char localGTT[16];
|
||||
char remoteGTT[16];
|
||||
DWORD local_ip;
|
||||
DWORD remote_ip;
|
||||
DWORD session_init_timer;
|
||||
DWORD enquire_link_timer;
|
||||
DWORD inactivity_timer;
|
||||
DWORD response_timer;
|
||||
char service_number[8];
|
||||
BYTE localSSN;
|
||||
BYTE remoteSSN;
|
||||
BYTE message_mode;
|
||||
} SMPP_PARAM;
|
||||
|
||||
// Inter-Function define
|
||||
int smpp_Register(BYTE);
|
||||
void smpp_PrimitiveSend(int linkNo, int command_id);
|
||||
|
||||
void smpp_initTCPClient();
|
||||
void smpp_initTCPServer();
|
||||
void smpp_tcp_connect(int link);
|
||||
void smpp_debugInit();
|
||||
void smpp_stateInit();
|
||||
void smpp_msgInit();
|
||||
void smpp_debugTimer();
|
||||
char *smpp_getLocalIP();
|
||||
void smpp_setupTCPLink(int);
|
||||
void smpp_rvMsgOverSCCP(BYTE sccp_usertype);
|
||||
void smpp_rvMsgOverTCP();
|
||||
WORD smpp_getServerPort();
|
||||
DWORD smpp_getSequenceNumber(int);
|
||||
int smpp_decode_msg(int, SMPP_GENERAL*, int);
|
||||
int smpp_closeTCPConnection(int);
|
||||
int smpp_encode_msg(int, SMPP_MSG *, int);
|
||||
void smpp_setSccpAddr(int, SCCP_ADDR *, SCCP_ADDR *);
|
||||
BYTE smpp_ascii2GTAI(BYTE *pGTAI, char *pGTT);
|
||||
void smpp_GTAI2ascii(char *, BYTE *, BYTE);
|
||||
void smpp_send_ascout(char *);
|
||||
void smpp_send_error(char *);
|
||||
void smpp_display_hex_msg(BYTE* disp_ptr, int len);
|
||||
void smpp_command_id_to_string(char *comm_str, DWORD command_id);
|
||||
void smpp_command_status_to_string(char* status_str, DWORD command_status);
|
||||
void smpp_ton_to_string(char* ton_str, BYTE ton);
|
||||
void smpp_npi_to_string(char* npi_str, BYTE npi);
|
||||
|
||||
void smpp_sendBindResp(int, int, DWORD command_status);
|
||||
void smpp_sendUnbind(int);
|
||||
void smpp_sendUnbindResp(int);
|
||||
void smpp_sendEnquireLink(int);
|
||||
void smpp_sendEnquireLinkResp(int);
|
||||
void smpp_sendOutbind(int);
|
||||
void smpp_sendBind(int, int);
|
||||
void smpp_sendGenericNack(int, DWORD, DWORD);
|
||||
void smpp_sendResponse(int , DWORD , DWORD , DWORD );
|
||||
|
||||
void smpp_addTLV(BYTE *, WORD, BYTE *, WORD);
|
||||
|
||||
int smpp_loadParam();
|
||||
int smpp_writeParam();
|
||||
void smpp_checkParam();
|
||||
int smpp_setParam(DWORD *oid, BYTE *pdata, WORD datalen);
|
||||
void smpp_reset();
|
||||
void smpp_debug(DWORD mask, const char *fmt, ...);
|
||||
void smpp_close(BYTE linkNo);
|
||||
void smpp_mibInit();
|
||||
int smpp_decode_optional_parameter(SMPP_OPTIONAL_PARAMETER* opt_ptr, BYTE* msg_ptr, int t_len);
|
||||
int smpp_check_sysid_route(char* sysid_rv, BYTE sysidlen_rv, BYTE server_type, BYTE session_type);
|
||||
int smpp_decode_setup(BYTE link_type, int tcp_linkNo, BYTE src_ref, SMPP_GENERAL *pData, int len);
|
||||
|
||||
/* TCP connection */
|
||||
typedef struct SocketsMsg
|
||||
{
|
||||
int AcceptNum;
|
||||
int ReadNum;
|
||||
int ReadQueue[MAX_SMPP_LINK];
|
||||
int WriteNum;
|
||||
int WriteQueue[MAX_SMPP_LINK];
|
||||
int ExceptNum;
|
||||
int ExceptQueue[MAX_SMPP_LINK];
|
||||
}SocketsMsg;
|
||||
|
||||
typedef struct SocketsInUse
|
||||
{
|
||||
int DaemonSock;
|
||||
int SockNum;
|
||||
int Sockets[MAX_SMPP_LINK];
|
||||
int client_sock[MAX_SMPP_LINK];
|
||||
int server_sock[MAX_SMPP_LINK];
|
||||
u32 remote_ip[MAX_SMPP_LINK];
|
||||
fd_set readfds,writefds,exceptfds;
|
||||
int Port;
|
||||
}SocketsInUse;
|
||||
|
||||
//SocketsMsg SockMsg;
|
||||
int QuerySocketsMsg();
|
||||
|
||||
// Call back function define
|
||||
//param1:linkNo; param2:msg mode; param3: pData; param4:pDataLen
|
||||
typedef int (*smpp_callBack_dataProc) (BYTE, SMPP_MSG*, WORD);
|
||||
//param1:linkNo; param2:link status
|
||||
typedef int (*smpp_callBack_linkProc) (BYTE, BYTE);
|
||||
|
||||
typedef struct SMPP_CALLBACK
|
||||
{
|
||||
smpp_callBack_dataProc data_proc;
|
||||
smpp_callBack_linkProc link_proc;
|
||||
} SMPP_CALLBACK;
|
||||
|
||||
// API
|
||||
int smpp_init_new(u8 sys_id); //call in main program.
|
||||
void smpp_fsm_new();
|
||||
BYTE smpp_registerLink(BYTE server_type, BYTE session_type, char* service_number_ptr, BYTE message_mode);
|
||||
void smpp_attach_link(BYTE linkNo,
|
||||
smpp_callBack_dataProc onDataRecv,
|
||||
smpp_callBack_linkProc onLinkStateChange);
|
||||
|
||||
/* return sequence number */
|
||||
WORD smpp_send(BYTE linkNo, SMPP_MSG* pMsg, WORD dataLen);
|
||||
|
||||
void init_link(u32 link);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
240
plat/smpp/src/include/smpp_const.h
Normal file
240
plat/smpp/src/include/smpp_const.h
Normal file
@@ -0,0 +1,240 @@
|
||||
//public constant define
|
||||
#ifndef _SMPP_CONST_h
|
||||
#define _SMPP_CONST_h
|
||||
|
||||
|
||||
#define MAX_SMPP_LINK 32
|
||||
#define SMPP_LINK_QUEUE_NUM 32 //queue number per link
|
||||
#define MAX_PACKET_SIZE 1500
|
||||
#define MAX_MSG_SIZE 1300
|
||||
#define SMPP_MSG_LEN 512
|
||||
#define MAX_ASCOUT_BUF_LEN 4096
|
||||
#define MAX_ASCIN_BUF_LEN 1024
|
||||
#define SMPP_MAX_MULTI_ADDRESS 5
|
||||
#define CMD_BUF_SIZE 8
|
||||
#define SMPP_PORT 2775
|
||||
#define SMPP_MODULE_VERSION "V1.0.01"//merge R9v0_02 p4 ot R90v0_12 p4
|
||||
#define SMPP_MODULE_PATCH 2
|
||||
#define TITLE_CHAR 2048
|
||||
#define SMPP_PPS_SSN 19
|
||||
#define SMPP_SMSC_SSN 20
|
||||
#define SMPP_PPS_USERTYPE 1
|
||||
#define SMPP_SMSC_USERTYPE 2
|
||||
#define SMPP_CONF_FILE "./conf/smpp.conf"
|
||||
#define SMPP_CONF_FILE_w "./conf/smpp_w.conf"
|
||||
#define SMPP_UDP 0
|
||||
#define SMPP_TCP 1
|
||||
#define SMPP_OID {1,3,6,1,4,1,1373,1,3,2,3,4}
|
||||
#define SMPP_OIDLEN 12
|
||||
#define MAX_SME 1
|
||||
#define SMPP_VERSION 0x34
|
||||
#define SMPP_OPT_PARAM_NUM 64
|
||||
|
||||
#define SMPP_SYSID_LEN 16
|
||||
#define SMPP_PASSWD_LEN 9
|
||||
#define SMPP_SYSTYPE_LEN 13
|
||||
#define SMPP_GTT_LEN 16
|
||||
|
||||
/* time interval */
|
||||
#define SESSION_INIT_INTERVAL (50*5) /* 5s */
|
||||
|
||||
/* debug id */
|
||||
#define SMPP_DEBUG_ID 15
|
||||
#define SMPP_HEARTBEAT_COMPONENT_ID 9
|
||||
|
||||
// define if print screen and debug needed.
|
||||
//#define SMPP_PRINT_SCREEN TRUE
|
||||
#define SMPP_DEBUG true
|
||||
|
||||
/* Define server mode */
|
||||
#define SMPP_CLIENT 0
|
||||
#define SMPP_SERVER 1
|
||||
|
||||
/* Define session type */
|
||||
#define BIND_TX 0
|
||||
#define BIND_RX 1
|
||||
#define BIND_TRX 2
|
||||
|
||||
/* Define message mode */
|
||||
#define STORE_AND_FORWARD 0
|
||||
#define DATAGRAM 1
|
||||
#define TRANSACTION 2
|
||||
|
||||
//command ID define
|
||||
#define GENERIC_NAK 0x80000000
|
||||
#define BIND_RECEIVER 0x00000001
|
||||
#define BIND_RECEIVER_RESP 0x80000001
|
||||
#define BIND_TRANSMITTER 0x00000002
|
||||
#define BIND_TRANSMITTER_RESP 0x80000002
|
||||
#define QUERY_SM 0x00000003
|
||||
#define QUERY_SM_RESP 0x80000003
|
||||
#define SUBMIT_SM 0x00000004
|
||||
#define SUBMIT_SM_RESP 0x80000004
|
||||
#define DELIVER_SM 0x00000005
|
||||
#define DELIVER_SM_RESP 0x80000005
|
||||
#define UNBIND 0x00000006
|
||||
#define UNBIND_RESP 0x80000006
|
||||
#define REPLACE_SM 0x00000007
|
||||
#define REPLACE_SM_RESP 0x80000007
|
||||
#define CANCEL_SM 0x00000008
|
||||
#define CANCEL_SM_RESP 0x80000008
|
||||
#define BIND_TRANSCEIVER 0x00000009
|
||||
#define BIND_TRANSCEIVER_RESP 0x80000009
|
||||
#define OUTBIND 0x0000000B
|
||||
#define ENQUIRE_LINK 0x00000015
|
||||
#define ENQUIRE_LINK_RESP 0x80000015
|
||||
#define SUBMIT_MULTI 0x00000021
|
||||
#define SUBMIT_MULTI_RESP 0x80000021
|
||||
#define ALERT_NOTIFICATION 0x00000102
|
||||
#define DATA_SM 0x00000103
|
||||
#define DATA_SM_RESP 0x80000103
|
||||
|
||||
/* Optional parameter tag definitions */
|
||||
#define DEST_ADDR_SUBUNIT 0x0005
|
||||
#define DEST_NETWORK_TYPE 0x0006
|
||||
#define DEST_BEARER_TYPE 0x0007
|
||||
#define DEST_TELEMATICS_ID 0x0008
|
||||
#define SOURCE_ADDR_SUBUNIT 0x000D
|
||||
#define SOURCE_NETWORK_TYPE 0x000E
|
||||
#define SOURCE_BEARER_TYPE 0x000F
|
||||
#define SOURCE_TELEMATICS_ID 0x0010
|
||||
#define QOS_TIME_TO_LIVE 0x0017
|
||||
#define PAYLOAD_TYPE 0x0019
|
||||
#define ADDITIONAL_STATUS_INFO_TEXT 0x001D
|
||||
#define RECEIPTED_MESSAGE_ID 0x001E
|
||||
#define MS_MSG_WAIT_FACILITIES 0x0030
|
||||
#define PRIVACY_INDICATOR 0x0201
|
||||
#define SOURCE_SUBADDRESS 0x0202
|
||||
#define DEST_SUBADDRESS 0x0203
|
||||
#define USER_MESSAGE_REFERENCE 0x0204
|
||||
#define USER_RESPONSE_CODE 0x0205
|
||||
#define SOURCE_PORT 0x020A
|
||||
#define DESTINATION_PORT 0x020B
|
||||
#define SAR_MSG_REF_NUM 0x020C
|
||||
#define LANGUAGE_INDICATOR 0x020D
|
||||
#define SAR_TOTAL_SEGMENTS 0x020E
|
||||
#define SAR_SEGMENT_SEQNUM 0x020F
|
||||
#define SC_INTERFACE_VERSION 0x0210
|
||||
#define CALLBACK_NUM_PRES_IND 0x0302
|
||||
#define CALLBACK_NUM_ATAG 0x0303
|
||||
#define NUMBER_OF_MESSAGES 0x0304
|
||||
#define CALLBACK_NUM 0x0381
|
||||
#define DPF_RESULT 0x0420
|
||||
#define SET_DPF 0x0421
|
||||
#define MS_AVAILABILITY_STATUS 0x0422
|
||||
#define NETWORK_ERROR_CODE 0x0423
|
||||
#define MESSAGE_PAYLOAD 0x0424
|
||||
#define DELIVERY_FAILURE_REASON 0x0425
|
||||
#define MORE_MESSAGES_TO_SEND 0x0426
|
||||
#define MESSAGE_STATE 0x0427
|
||||
#define USSD_SERVICE_OP 0x0501
|
||||
#define DISPLAY_TIME 0x1201
|
||||
#define SMS_SIGNAL 0x1203
|
||||
#define MS_VALIDITY 0x1204
|
||||
#define ALERT_ON_MESSAGE_DELIVERY 0x130C
|
||||
#define ITS_REPLY_TYPE 0x1380
|
||||
#define ITS_SESSION_INFO 0x1383
|
||||
|
||||
/* Command status definition. */
|
||||
#define ESME_ROK 0x00000000
|
||||
#define ESME_RINVMSGLEN 0x00000001
|
||||
#define ESME_RINVCMDLEN 0x00000002
|
||||
#define ESME_RINVCMDID 0x00000003
|
||||
#define ESME_RINVBNDSTS 0x00000004
|
||||
#define ESME_RALYBND 0x00000005
|
||||
#define ESME_RINVPRTFLG 0x00000006
|
||||
#define ESME_RINVREGDLVFLG 0x00000007
|
||||
#define ESME_RSYSERR 0x00000008
|
||||
/* #define Reserved 0x00000009 */
|
||||
#define ESME_RINVSRCADR 0x0000000A
|
||||
#define ESME_RINVDSTADR 0x0000000B
|
||||
#define ESME_RINVMSGID 0x0000000C
|
||||
#define ESME_RBINDFAIL 0x0000000D
|
||||
#define ESME_RINVPASWD 0x0000000E
|
||||
#define ESME_RINVSYSID 0x0000000F
|
||||
/* #define Reserved 0x00000010 */
|
||||
#define ESME_RCANCELFAIL 0x00000011
|
||||
/*#define Reserved 0x00000012 */
|
||||
#define ESME_RREPLACEFAIL 0x00000013
|
||||
#define ESME_RMSGQFUL 0x00000014
|
||||
#define ESME_RINVSERTYP 0x00000015
|
||||
/* #define Reserved 0x00000016-0x00000032 */
|
||||
#define ESME_RINVNUMDESTS 0x00000033
|
||||
#define ESME_RINVDLNAME 0x00000034
|
||||
/* #define Reserved 0x00000035-0x0000003F */
|
||||
#define ESME_RINVDESTFLAG 0x00000040
|
||||
/* #define Reserved 0x00000041 */
|
||||
#define ESME_RINVSUBREP 0x00000042
|
||||
#define ESME_RINVESMCLASS 0x00000043
|
||||
#define ESME_RCNTSUBDL 0x00000044
|
||||
#define ESME_RSUBMITFAIL 0x00000045
|
||||
/* #define Reserved 0x00000046-0x00000047 */
|
||||
#define ESME_RINVSRCTON 0x00000048
|
||||
#define ESME_RINVSRCNPI 0x00000049
|
||||
/* #define Reserved 0x0000004A-0x0000004F */
|
||||
#define ESME_RINVDSTTON 0x00000050
|
||||
#define ESME_RINVDSTNPI 0x00000051
|
||||
/* #define Reserved 0x00000052 */
|
||||
#define ESME_RINVSYSTYP 0x00000053
|
||||
#define ESME_RINVREPFLAG 0x00000054
|
||||
#define ESME_RINVNUMMSGS 0x00000055
|
||||
/* #define Reserved 0x00000056-0x00000057 */
|
||||
#define ESME_RTHROTTLED 0x00000058
|
||||
/* #define Reserved 0x00000059-0x00000060 */
|
||||
#define ESME_RINVSCHED 0x00000061
|
||||
#define ESME_RINVEXPIRY 0x00000062
|
||||
#define ESME_RINVDFTMSGID 0x00000063
|
||||
#define ESME_RX_T_APPN 0x00000064
|
||||
#define ESME_RX_P_APPN 0x00000065
|
||||
#define ESME_RX_R_APPN 0x00000066
|
||||
#define ESME_RQUERYFAIL 0x00000067
|
||||
/* #define Reserved 0x00000068-0x000000BF */
|
||||
#define ESME_RINVOPTPARSTREAM 0x000000C0
|
||||
#define ESME_ROPTPARNOTALLWD 0x000000C1
|
||||
#define ESME_RINVPARSLEN 0x000000C2
|
||||
#define ESME_RMISSINGOPTPARAM 0x000000C3
|
||||
#define ESME_RINVOPTPARAMVAL 0x000000C4
|
||||
/* #define Reserved 0x000000C5-0x000000FD */
|
||||
#define ESME_RDELIVERYFAILURE 0x000000FE
|
||||
#define ESME_RUNKNOWNERR 0x000000FF
|
||||
/* #define Reserved_for_SMPP_extention 0x00000100-0x000003FF */
|
||||
/* #define Reserved_for_SMSC_vendor_specific_errors 0x00000100-0x000003FF */
|
||||
/* #define Reserved 0x00000500-0xFFFFFFFF */
|
||||
|
||||
/* define dest_network_type optional parameters */
|
||||
#define DEST_NETWORK_TYPE_UNKNOWN 0x00
|
||||
#define DEST_NETWORK_TYPE_GSM 0x01
|
||||
#define DEST_NETWORK_TYPE_ANSI136_TDMA 0x02
|
||||
#define DEST_NETWORK_TYPE_IS95_CDMA 0x03
|
||||
#define DEST_NETWORK_TYPE_PDC 0x04
|
||||
#define DEST_NETWORK_TYPE_PHS 0x05
|
||||
#define DEST_NETWORK_TYPE_IDEN 0x06
|
||||
#define DEST_NETWORK_TYPE_AMPS 0x07
|
||||
#define DEST_NETWORK_TYPE_PAGING_NETWORK 0x08
|
||||
|
||||
/* define destination address type */
|
||||
#define DESTINATION_ADDRESS_SME_ADDRESS 0x01
|
||||
#define DESTINATION_ADDRESS_DISTRIBUTION_LIST_NAME 0x02
|
||||
|
||||
/* define Type of Number(TON) */
|
||||
#define TON_UNKNOWN 0x0
|
||||
#define TON_INTERNATIONAL 0x1
|
||||
#define TON_NATIONAL 0x2
|
||||
#define TON_NETWORK_SPECIFIC 0x3
|
||||
#define TON_SUBSCRIBER_NUMBER 0x4
|
||||
#define TON_ALPHANUMERIC 0x5
|
||||
#define TON_ABBREVIATE 0x6
|
||||
|
||||
/* define Numeric Plan Indicator(NPI) */
|
||||
#define NPI_UNKNOWN 0x0
|
||||
#define NPI_ISDN 0x1
|
||||
#define NPI_DATA 0x3
|
||||
#define NPI_TELEX 0x4
|
||||
#define NPI_LAND_MOBILE 0x6
|
||||
#define NPI_NATIONAL 0x8
|
||||
#define NPI_PRIVATE 0x9
|
||||
#define NPI_ERMES 0xa
|
||||
#define NPI_INTERNET 0xe
|
||||
|
||||
#endif
|
||||
|
||||
39
plat/smpp/src/include/smpp_def.h
Normal file
39
plat/smpp/src/include/smpp_def.h
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
#ifndef _SMPP_DEF_h
|
||||
#define _SMPP_DEF_h
|
||||
|
||||
/*SMPP_CALLBACK callBackFunc[MAX_SMPP_LINK];
|
||||
SMPP_PARAM smpp_param[MAX_SMPP_LINK];
|
||||
SMPP_LINK smpp_link[MAX_SMPP_LINK];
|
||||
struct SocketsInUse Mysock;
|
||||
SMPP_DEBUG_STRUCT smppDebug;
|
||||
|
||||
BYTE exterEvent[MAX_SMPP_LINK][CMD_BUF_SIZE];
|
||||
BYTE interEvent[MAX_SMPP_LINK][CMD_BUF_SIZE];
|
||||
BYTE exter_head[MAX_SMPP_LINK];
|
||||
BYTE exter_tail[MAX_SMPP_LINK];
|
||||
BYTE inter_head[MAX_SMPP_LINK];
|
||||
BYTE inter_tail[MAX_SMPP_LINK];
|
||||
|
||||
BYTE smpp_state[MAX_SMPP_LINK];
|
||||
BYTE smpp_hearbeat_status[MAX_SMPP_LINK/4];
|
||||
BYTE interface_mode[MAX_SMPP_LINK];
|
||||
BYTE data_mode[MAX_SMPP_LINK];
|
||||
|
||||
BYTE linkAttachFlag[MAX_SMPP_LINK];
|
||||
BYTE smpp_TCPClientFlag[MAX_SMPP_LINK];
|
||||
char smpp_debug_asciiIn[MAX_ASCIN_BUF_LEN];
|
||||
char smpp_debug_asciiOut[MAX_ASCOUT_BUF_LEN];
|
||||
BYTE smppDebugFull = 0;
|
||||
|
||||
BYTE src_ref[MAX_SMPP_LINK];
|
||||
BYTE dst_ref[MAX_SMPP_LINK];
|
||||
|
||||
BYTE smpp_msg[MAX_PACKET_SIZE];
|
||||
|
||||
BYTE smpp_system_no;*/
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
38
plat/smpp/src/include/smpp_ext.h
Normal file
38
plat/smpp/src/include/smpp_ext.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef _SMPP_EXT_h
|
||||
#define _SMPP_EXT_h
|
||||
|
||||
extern SMPP_CALLBACK callBackFunc[MAX_SMPP_LINK];
|
||||
extern SMPP_PARAM smpp_param[MAX_SMPP_LINK];
|
||||
extern SMPP_LINK smpp_link[MAX_SMPP_LINK];
|
||||
extern struct SocketsInUse Mysock;
|
||||
extern SMPP_DEBUG_STRUCT smppDebug;
|
||||
|
||||
extern BYTE exterEvent[MAX_SMPP_LINK][CMD_BUF_SIZE];
|
||||
extern BYTE interEvent[MAX_SMPP_LINK][CMD_BUF_SIZE];
|
||||
extern BYTE exter_head[MAX_SMPP_LINK];
|
||||
extern BYTE exter_tail[MAX_SMPP_LINK];
|
||||
extern BYTE inter_head[MAX_SMPP_LINK];
|
||||
extern BYTE inter_tail[MAX_SMPP_LINK];
|
||||
|
||||
extern BYTE smpp_state[MAX_SMPP_LINK];
|
||||
extern BYTE smpp_hearbeat_status[MAX_SMPP_LINK/4];
|
||||
extern BYTE interface_mode[MAX_SMPP_LINK];
|
||||
extern BYTE data_mode[MAX_SMPP_LINK];
|
||||
|
||||
extern BYTE linkAttachFlag[MAX_SMPP_LINK];
|
||||
extern BYTE smpp_TCPClientFlag[MAX_SMPP_LINK];
|
||||
extern char smpp_debug_asciiIn[MAX_ASCIN_BUF_LEN];
|
||||
extern char smpp_debug_asciiOut[MAX_ASCOUT_BUF_LEN];
|
||||
extern BYTE smppDebugFull;
|
||||
|
||||
extern BYTE src_ref[MAX_SMPP_LINK];
|
||||
extern BYTE dst_ref[MAX_SMPP_LINK];
|
||||
|
||||
extern BYTE smpp_msg[MAX_PACKET_SIZE];
|
||||
|
||||
extern BYTE smpp_system_no;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
465
plat/smpp/src/include/smpp_msg.h
Normal file
465
plat/smpp/src/include/smpp_msg.h
Normal file
@@ -0,0 +1,465 @@
|
||||
|
||||
#ifndef _SMPP_MSG_h
|
||||
#define _SMPP_MSG_h
|
||||
|
||||
|
||||
typedef struct SMPP_HEAD
|
||||
{
|
||||
DWORD command_length;
|
||||
DWORD command_id;
|
||||
DWORD command_status;
|
||||
DWORD sequence_number;
|
||||
}SMPP_HEAD;
|
||||
|
||||
typedef struct SMPP_GENERAL
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
BYTE msg[SMPP_MSG_LEN];
|
||||
}SMPP_GENERAL;
|
||||
|
||||
typedef struct PDU_BIND
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
char system_id[16];
|
||||
char password[9];
|
||||
char system_type[13];
|
||||
BYTE interface_version;
|
||||
BYTE addr_ton;
|
||||
BYTE addr_npi;
|
||||
char address_range[41];
|
||||
}PDU_BIND;
|
||||
|
||||
typedef struct PDU_BIND_RESP
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
char system_id[16];
|
||||
/* optional parameter */
|
||||
BYTE sc_interface_version;
|
||||
}PDU_BIND_RESP;
|
||||
|
||||
typedef struct PDU_OUTBIND
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
char system_id[16];
|
||||
char password[9];
|
||||
}PDU_OUTBIND;
|
||||
|
||||
typedef struct PDU_UNBIND
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
}PDU_UNBIND;
|
||||
|
||||
typedef struct PDU_UNBIND_RESP
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
}PDU_UNBIND_RESP;
|
||||
|
||||
typedef struct PDU_GENERIC_NACK
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
}PDU_GENERIC_NACK;
|
||||
|
||||
typedef struct PDU_SUBMIT_SM
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
|
||||
/* define mandatory parameters */
|
||||
char service_type[6];
|
||||
BYTE source_addr_ton;
|
||||
BYTE source_addr_npi;
|
||||
char source_addr[21];
|
||||
BYTE dest_addr_ton;
|
||||
BYTE dest_addr_npi;
|
||||
char destination_addr[21];
|
||||
BYTE esm_class;
|
||||
BYTE protocol_id;
|
||||
BYTE priority_flag;
|
||||
char schedule_delivery_time[17];
|
||||
char validity_period[17];
|
||||
BYTE registered_delivery;
|
||||
BYTE replace_if_present_flag;
|
||||
BYTE data_coding;
|
||||
BYTE sm_default_msg_id;
|
||||
BYTE sm_length;
|
||||
BYTE short_message[254];
|
||||
|
||||
/* define optional parameters */
|
||||
/* total: 28 parameters. */ /* param_flag1 */
|
||||
WORD user_message_reference; /* 0x0000 0001 */
|
||||
WORD source_port; /* 0x0000 0002 */
|
||||
BYTE source_addr_subunit; /* 0x0000 0004 */
|
||||
WORD destination_port; /* 0x0000 0008 */
|
||||
BYTE dest_addr_subunit; /* 0x0000 0010 */
|
||||
WORD sar_msg_ref_num; /* 0x0000 0020 */
|
||||
BYTE sar_total_segments; /* 0x0000 0040 */
|
||||
BYTE sar_segment_seqnum; /* 0x0000 0080 */
|
||||
BYTE more_messages_to_send; /* 0x0000 0100 */
|
||||
BYTE payload_type; /* 0x0000 0200 */
|
||||
char message_payload[MAX_MSG_SIZE]; /* 0x0000 0400 */
|
||||
BYTE privacy_indicator; /* 0x0000 0800 */
|
||||
char callback_num[19]; /* 0x0000 1000 */
|
||||
BYTE callback_num_pres_ind; /* 0x0000 2000 */
|
||||
char callback_num_atag[65]; /* 0x0000 4000 */
|
||||
char source_subaddress[23]; /* 0x0000 8000 */
|
||||
char dest_subaddress[23]; /* 0x0001 0000 */
|
||||
BYTE user_response_code; /* 0x0002 0000 */
|
||||
BYTE display_time; /* 0x0004 0000 */
|
||||
WORD sms_signal; /* 0x0008 0000 */
|
||||
BYTE ms_validity; /* 0x0010 0000 */
|
||||
BYTE ms_msg_wait_facilities; /* 0x0020 0000 */
|
||||
BYTE number_of_messages; /* 0x0040 0000 */
|
||||
BYTE alert_on_message_delivery; /* 0 byte. */ /* 0x0080 0000 */
|
||||
BYTE language_indicator; /* 0x0100 0000 */
|
||||
BYTE its_reply_type; /* 0x0200 0000 */
|
||||
BYTE its_session_info[2]; /* 0x0400 0000 */
|
||||
BYTE ussd_service_op; /* 0x0800 0000 */
|
||||
BYTE dest_network_type; /* 0x1000 0000 */ /* smpp v5.0 */
|
||||
}PDU_SUBMIT_SM;
|
||||
|
||||
typedef struct PDU_SUBMIT_SM_RESP
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
char message_id[65];
|
||||
}PDU_SUBMIT_SM_RESP;
|
||||
|
||||
typedef struct SME_DEST_ADDRESS
|
||||
{
|
||||
BYTE dest_addr_ton;
|
||||
BYTE dest_addr_npi;
|
||||
char destination_addr[21];
|
||||
}SME_DEST_ADDRESS;
|
||||
|
||||
typedef struct DL_NAME
|
||||
{
|
||||
char dl_name[21];
|
||||
}DL_NAME;
|
||||
|
||||
typedef union DEST_ADDR
|
||||
{
|
||||
SME_DEST_ADDRESS sme_dest_address;
|
||||
DL_NAME dl_name;
|
||||
}DEST_ADDR;
|
||||
|
||||
typedef struct DESTINATION_ADDRESS_DEFINITION
|
||||
{
|
||||
BYTE dest_flag;
|
||||
DEST_ADDR dest_addr;
|
||||
}DESTINATION_ADDRESS_DEFINITIAON;
|
||||
|
||||
typedef struct PDU_SUBMIT_MULTI
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
|
||||
/* define mandatory parameters */
|
||||
char service_type[6];
|
||||
BYTE source_addr_ton;
|
||||
BYTE source_addr_npi;
|
||||
char source_addr[21];
|
||||
BYTE number_of_dests;
|
||||
DESTINATION_ADDRESS_DEFINITIAON dest_address[SMPP_MAX_MULTI_ADDRESS];
|
||||
BYTE esm_class;
|
||||
BYTE protocol_id;
|
||||
BYTE priority_flag;
|
||||
char schedule_delivery_time[17];
|
||||
char validity_period[17];
|
||||
BYTE registered_delivery;
|
||||
BYTE replace_if_present_flag; /* set to NULL */
|
||||
BYTE data_coding;
|
||||
BYTE sm_default_msg_id;
|
||||
BYTE sm_length;
|
||||
BYTE short_message[254];
|
||||
|
||||
/* define optional parameters */
|
||||
/* total: 22 parameters. */ /* param_flag1 */
|
||||
WORD user_message_reference; /* 0x0000 0001 */
|
||||
WORD source_port; /* 0x0000 0002 */
|
||||
BYTE source_addr_subunit; /* 0x0000 0004 */
|
||||
WORD destination_port; /* 0x0000 0008 */
|
||||
BYTE dest_addr_subunit; /* 0x0000 0010 */
|
||||
WORD sar_msg_ref_num; /* 0x0000 0020 */
|
||||
BYTE sar_total_segments; /* 0x0000 0040 */
|
||||
BYTE sar_segment_seqnum; /* 0x0000 0080 */
|
||||
BYTE payload_type; /* 0x0000 0100 */
|
||||
char message_payload[MAX_MSG_SIZE]; /* 0x0000 0200 */
|
||||
BYTE privacy_indicator; /* 0x0000 0400 */
|
||||
char callback_num[19]; /* 0x0000 0800 */
|
||||
BYTE callback_num_pres_ind; /* 0x0000 1000 */
|
||||
char callback_num_atag[65]; /* 0x0000 2000 */
|
||||
char source_subaddress[23]; /* 0x0000 4000 */
|
||||
char dest_subaddress[23]; /* 0x0000 8000 */
|
||||
BYTE display_time; /* 0x0001 0000 */
|
||||
WORD sms_signal; /* 0x0002 0000 */
|
||||
BYTE ms_validity; /* 0x0004 0000 */
|
||||
BYTE ms_msg_wait_facilities; /* 0x0008 0000 */
|
||||
BYTE alert_on_message_delivery;/* 0byte */ /* 0x0010 0000 */
|
||||
BYTE language_indicator; /* 0x0020 0000 */
|
||||
BYTE dest_network_type; /* 0x0040 0000 */
|
||||
}PDU_SUBMIT_MULTI;
|
||||
|
||||
typedef struct UNSUCCESS_SME
|
||||
{
|
||||
BYTE dest_addr_ton;
|
||||
BYTE dest_addr_npi;
|
||||
char destination_addr[21];
|
||||
DWORD error_status_code;
|
||||
}UNSUCCESS_SME;
|
||||
|
||||
typedef struct PDU_SUBMIT_MULTI_RESP
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
char message_id[65];
|
||||
BYTE no_unsuccess;
|
||||
UNSUCCESS_SME unsuccess_sme[MAX_SME];
|
||||
}PDU_SUBMIT_MULTI_RESP;
|
||||
|
||||
typedef struct PDU_DELIVER_SM
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
|
||||
/* define mandatory parameter. */
|
||||
char service_type[6];
|
||||
BYTE source_addr_ton;
|
||||
BYTE source_addr_npi;
|
||||
char source_addr[21];
|
||||
BYTE dest_addr_ton;
|
||||
BYTE dest_addr_npi;
|
||||
char destination_addr[21];
|
||||
BYTE esm_class;
|
||||
BYTE protocol_id;
|
||||
BYTE priority_flag;
|
||||
char schedule_delivery_time; /* set to NULL */
|
||||
char validity_period; /* set to NULL */
|
||||
BYTE registered_delivery;
|
||||
BYTE replace_if_present_flag; /* set to NULL */
|
||||
BYTE data_coding;
|
||||
BYTE sm_default_msg_id; /* set to NULL */
|
||||
BYTE sm_length;
|
||||
BYTE short_message[254];
|
||||
|
||||
/* define optional parameter. */
|
||||
/* total: 19 parameters. */ /* param_flag1 */
|
||||
WORD user_message_reference; /* 0x0000 0001 */
|
||||
WORD source_port; /* 0x0000 0002 */
|
||||
WORD destination_port; /* 0x0000 0004 */
|
||||
WORD sar_msg_ref_num; /* 0x0000 0008 */
|
||||
BYTE sar_total_segments; /* 0x0000 0010 */
|
||||
BYTE sar_segment_seqnum; /* 0x0000 0020 */
|
||||
BYTE user_response_code; /* 0x0000 0040 */
|
||||
BYTE privacy_indicator; /* 0x0000 0080 */
|
||||
BYTE payload_type; /* 0x0000 0100 */
|
||||
char message_payload[MAX_MSG_SIZE]; /* 0x0000 0200 */
|
||||
char callback_num[49]; /* 0x0000 0400 */
|
||||
char source_subaddress[23]; /* 0x0000 0800 */
|
||||
char dest_subaddress[23]; /* 0x0000 1000 */
|
||||
BYTE language_indicator; /* 0x0000 2000 */
|
||||
BYTE its_session_info[2]; /* 0x0000 4000 */
|
||||
char network_error_code[3]; /* 0x0000 8000 */
|
||||
BYTE message_state; /* 0x0001 0000 */
|
||||
char receipted_message_id[65]; /* 0x0002 0000 */
|
||||
BYTE ussd_service_op; /* 0x0004 0000 */ /* smpp v5.0 */
|
||||
}PDU_DELIVER_SM;
|
||||
|
||||
typedef struct PDU_DELIVER_SM_RESP
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
char message_id;
|
||||
}PDU_DELIVER_SM_RESP;
|
||||
|
||||
typedef struct PDU_DATA_SM
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
|
||||
/* define mandatory paramter. */
|
||||
char service_type[6];
|
||||
BYTE source_addr_ton;
|
||||
BYTE source_addr_npi;
|
||||
char source_addr[65];
|
||||
BYTE dest_addr_ton;
|
||||
BYTE dest_addr_npi;
|
||||
char destination_addr[65];
|
||||
BYTE esm_class;
|
||||
BYTE registered_delivery;
|
||||
BYTE data_coding;
|
||||
|
||||
/* define optional parameter. */
|
||||
/* total: 38 paramters. */ /* param_flag */
|
||||
WORD source_port; /* 0x0000 0001 */ /* param_flag1 start. */
|
||||
BYTE source_addr_subunit; /* 0x0000 0002 */
|
||||
BYTE source_network_type; /* 0x0000 0004 */
|
||||
BYTE source_bearer_type; /* 0x0000 0008 */
|
||||
WORD source_telematics_id; /* 0x0000 0010 */
|
||||
WORD destination_port; /* 0x0000 0020 */
|
||||
BYTE dest_addr_subunit; /* 0x0000 0040 */
|
||||
BYTE dest_network_type; /* 0x0000 0080 */
|
||||
BYTE dest_bearer_type; /* 0x0000 0100 */
|
||||
WORD dest_telematics_id; /* 0x0000 0200 */
|
||||
WORD sar_msg_ref_num; /* 0x0000 0400 */
|
||||
BYTE sar_total_segments; /* 0x0000 0800 */
|
||||
BYTE sar_segment_seqnum; /* 0x0000 1000 */
|
||||
BYTE more_messages_to_send; /* 0x0000 2000 */
|
||||
DWORD qos_time_to_live; /* 0x0000 4000 */
|
||||
BYTE payload_type; /* 0x0000 8000 */
|
||||
char message_payload[MAX_MSG_SIZE]; /* 0x0001 0000 */
|
||||
BYTE set_dpf; /* 0x0002 0000 */
|
||||
char receipted_message_id[65]; /* 0x0004 0000 */
|
||||
BYTE message_state; /* 0x0008 0000 */
|
||||
char network_error_code[3]; /* 0x0010 0000 */
|
||||
WORD user_message_reference; /* 0x0020 0000 */
|
||||
BYTE privacy_indicator; /* 0x0040 0000 */
|
||||
char callback_num[19]; /* 0x0080 0000 */
|
||||
BYTE callback_num_pres_ind; /* 0x0100 0000 */
|
||||
char callback_num_atag[65]; /* 0x0200 0000 */
|
||||
char source_subaddress[23]; /* 0x0400 0000 */
|
||||
char dest_subaddress[23]; /* 0x0800 0000 */
|
||||
BYTE user_response_code; /* 0x1000 0000 */
|
||||
BYTE display_time; /* 0x2000 0000 */
|
||||
WORD sms_signal; /* 0x4000 0000 */
|
||||
BYTE ms_validity; /* 0x8000 0000 */ /* param_flag1 end. */
|
||||
BYTE ms_msg_wait_facilities; /* 0x0000 0001 */ /* param_flag2 start. */
|
||||
BYTE number_of_messages; /* 0x0000 0002 */
|
||||
BYTE alert_on_message_delivery;/* 0byte */ /* 0x0000 0004 */
|
||||
BYTE language_indicator; /* 0x0000 0008 */
|
||||
BYTE its_reply_type; /* 0x0000 0010 */
|
||||
BYTE its_session_info[2]; /* 0x0000 0020 */
|
||||
}PDU_DATA_SM;
|
||||
|
||||
typedef struct PDU_DATA_SM_RESP
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
char message_id[65];
|
||||
}PDU_DATA_SM_RESP;
|
||||
|
||||
typedef struct PDU_QUERY_SM
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
char message_id[65];
|
||||
BYTE source_addr_ton;
|
||||
BYTE source_addr_npi;
|
||||
char source_addr[21];
|
||||
}PDU_QUERY_SM;
|
||||
|
||||
typedef struct PDU_QUERY_SM_RESP
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
char message_id[65];
|
||||
char final_date[17];
|
||||
BYTE message_state;
|
||||
BYTE error_code;
|
||||
}PDU_QUERY_SM_RESP;
|
||||
|
||||
typedef struct PDU_CANCEL_SM
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
char service_type[6];
|
||||
char message_id[65];
|
||||
BYTE source_addr_ton;
|
||||
BYTE source_addr_npi;
|
||||
char source_addr[21];
|
||||
BYTE dest_addr_ton;
|
||||
BYTE dest_addr_npi;
|
||||
char destination_addr[21];
|
||||
}PDU_CANCEL_SM;
|
||||
|
||||
typedef struct PDU_CANCEL_SM_RESP
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
}PDU_CANCEL_SM_RESP;
|
||||
|
||||
typedef struct PDU_REPLACE_SM
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
|
||||
/* define mandatory parameter */
|
||||
char message_id[65];
|
||||
BYTE source_addr_ton;
|
||||
BYTE source_addr_npi;
|
||||
char source_addr[21];
|
||||
char schedule_delivery_time[17];
|
||||
char validity_period[17];
|
||||
BYTE registered_delivery;
|
||||
BYTE sm_default_msg_id;
|
||||
BYTE sm_length;
|
||||
BYTE short_message[254];
|
||||
}PDU_REPLACE_SM;
|
||||
|
||||
typedef struct PDU_REPLACE_SM_RESP
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
}PDU_REPLACE_SM_RESP;
|
||||
|
||||
typedef struct PDU_ENQUIRE_LINK
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
}PDU_ENQUIRE_LINK;
|
||||
|
||||
typedef struct PDU_ENQUIRE_LINK_RESP
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
}PDU_ENQUIRE_LINK_RESP;
|
||||
|
||||
typedef struct PDU_ALERT_NOTIFICATION
|
||||
{
|
||||
SMPP_HEAD head;
|
||||
BYTE source_addr_ton;
|
||||
BYTE source_addr_npi;
|
||||
BYTE source_addr[65];
|
||||
BYTE esme_addr_ton;
|
||||
BYTE esme_addr_npi;
|
||||
BYTE esme_addr[65];
|
||||
BYTE ms_availability_status;
|
||||
}PDU_ALERT_NOTIFICATION;
|
||||
|
||||
typedef union SMPP_PDU
|
||||
{
|
||||
PDU_BIND bind_transmitter; /* message_type = 0x01 */
|
||||
PDU_BIND_RESP bind_transmitter_resp; /* message_type = 0x02 */
|
||||
PDU_BIND bind_receiver; /* message_type = 0x03 */
|
||||
PDU_BIND_RESP bind_receiver_resp; /* message_type = 0x04 */
|
||||
PDU_BIND bind_transceiver; /* message_type = 0x05 */
|
||||
PDU_BIND_RESP bind_transceiver_resp; /* message_type = 0x06 */
|
||||
PDU_OUTBIND outbind; /* message_type = 0x07 */
|
||||
PDU_UNBIND unbind; /* message_type = 0x08 */
|
||||
PDU_UNBIND_RESP unbind_resp; /* message_type = 0x09 */
|
||||
PDU_GENERIC_NACK generic_nack; /* message_type = 0x0A */
|
||||
PDU_SUBMIT_SM submit_sm; /* message_type = 0x0B */
|
||||
PDU_SUBMIT_SM_RESP submit_sm_resp; /* message_type = 0x0C */
|
||||
PDU_SUBMIT_MULTI submit_multi; /* message_type = 0x0D */
|
||||
PDU_SUBMIT_MULTI_RESP submit_multi_resp; /* message_type = 0x0E */
|
||||
PDU_DELIVER_SM deliver_sm; /* message_type = 0x0F */
|
||||
PDU_DELIVER_SM_RESP deliver_sm_resp; /* message_type = 0x10 */
|
||||
PDU_DATA_SM data_sm; /* message_type = 0x11 */
|
||||
PDU_DATA_SM_RESP data_sm_resp; /* message_type = 0x12 */
|
||||
PDU_QUERY_SM query_sm; /* message_type = 0x13 */
|
||||
PDU_QUERY_SM_RESP query_sm_resp; /* message_type = 0x14 */
|
||||
PDU_CANCEL_SM cancel_sm; /* message_type = 0x15 */
|
||||
PDU_CANCEL_SM_RESP cancel_sm_resp; /* message_type = 0x16 */
|
||||
PDU_REPLACE_SM replace_sm; /* message_type = 0x17 */
|
||||
PDU_REPLACE_SM_RESP replace_sm_resp; /* message_type = 0x18 */
|
||||
PDU_ENQUIRE_LINK enquire_link; /* message_type = 0x19 */
|
||||
PDU_ENQUIRE_LINK_RESP enquire_link_resp; /* message_type = 0x1A */
|
||||
PDU_ALERT_NOTIFICATION alert_notification; /* message_type = 0x1B */
|
||||
}SMPP_PDU;
|
||||
|
||||
typedef struct SMPP_MSG
|
||||
{
|
||||
BYTE message_type;
|
||||
DWORD optional_param_flag1; /* for optional parameter 1~32 */
|
||||
DWORD optional_param_flag2; /* for optional parameter 33~64 */
|
||||
SMPP_PDU pdu;
|
||||
}SMPP_MSG;
|
||||
|
||||
typedef struct SMPP_OPTIONAL_PARAMETER
|
||||
{
|
||||
WORD tag;
|
||||
WORD len;
|
||||
BYTE value[MAX_MSG_SIZE];
|
||||
}SMPP_OPTIONAL_PARAMETER;
|
||||
|
||||
//BYTE smpp_msg_buf[MAX_SMPP_LINK][MAX_PACKET_SIZE];
|
||||
//int smpp_msg_buf_len[MAX_SMPP_LINK];
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
62
plat/smpp/src/include/smpp_public.h
Normal file
62
plat/smpp/src/include/smpp_public.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
** CDMA 2000 project, SMPP module
|
||||
**
|
||||
** File name: public.h
|
||||
** Written by Li Long at 2004-11-25
|
||||
** CVS $Id: public.h,v0.1 2004/11/25 17:03:14 lilong Exp $
|
||||
**
|
||||
*/
|
||||
#ifndef _SMPP_PUBLIC_h
|
||||
#define _SMPP_PUBLIC_h
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#ifndef _T_BYTE
|
||||
#define _T_BYTE
|
||||
typedef unsigned char BYTE;
|
||||
#endif
|
||||
|
||||
#ifndef _T_WORD
|
||||
#define _T_WORD
|
||||
typedef unsigned short WORD;
|
||||
#endif
|
||||
|
||||
#ifndef _T_DWORD
|
||||
#define _T_DWORD
|
||||
typedef unsigned int DWORD;
|
||||
#endif
|
||||
|
||||
#ifndef _T_BOOL
|
||||
#define _T_BOOL
|
||||
typedef int BOOL;
|
||||
#endif
|
||||
|
||||
#ifndef SUCCESS
|
||||
#define SUCCESS (0)
|
||||
#endif
|
||||
|
||||
#ifndef FAILURE
|
||||
#define FAILURE (-1)
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE (1)
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE (0)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
471
plat/smpp/src/smpp_debug.c
Normal file
471
plat/smpp/src/smpp_debug.c
Normal file
@@ -0,0 +1,471 @@
|
||||
/*
|
||||
** CDMA 2000 project, smpp module
|
||||
**
|
||||
** File name: smpp_debug.c
|
||||
** Written by Li Long at 2004-11-25
|
||||
** CVS $Id: smpp_debug.c,v0.1 2004/11/25 17:03:14 lilong Exp $
|
||||
**
|
||||
*/
|
||||
|
||||
#include "./include/smpp.h"
|
||||
#include "./include/smpp_ext.h"
|
||||
|
||||
static char smpp_debug_status = 1;
|
||||
static WORD disp_page[10];
|
||||
static char *disp_ptr = (char *) disp_page;
|
||||
|
||||
static DWORD smpp_status_id[20] =
|
||||
{
|
||||
1,3,6,1,4,1,1373,1,1,2,3,1,2,SMPP_DEBUG_ID+2,1
|
||||
};
|
||||
|
||||
static DWORD smpp_version_id[20] =
|
||||
{
|
||||
1,3,6,1,4,1,1373,1,1,2,3,1,2,SMPP_DEBUG_ID+2,2
|
||||
};
|
||||
|
||||
static DWORD smpp_ascii_in_id[20] =
|
||||
{
|
||||
1,3,6,1,4,1,1373,1,1,2,3,1,2,SMPP_DEBUG_ID+2,3
|
||||
};
|
||||
|
||||
static DWORD smpp_ascii_out_id[20] =
|
||||
{
|
||||
1,3,6,1,4,1,1373,1,1,2,3,1,2,SMPP_DEBUG_ID+2,4
|
||||
};
|
||||
|
||||
static DWORD smpp_page_title[20] =
|
||||
{
|
||||
1,3,6,1,4,1,1373,1,1,2,3,1,2,SMPP_DEBUG_ID+2,1,1
|
||||
};
|
||||
|
||||
static DWORD smpp_page_line[20] =
|
||||
{
|
||||
1,3,6,1,4,1,1373,1,1,2,3,1,2,SMPP_DEBUG_ID+2,1,2,1
|
||||
};
|
||||
|
||||
const static BYTE PAGE_POINT = 14;
|
||||
const static BYTE LINE_POINT = 15;
|
||||
const static BYTE BASE_ID_LEN = 15;
|
||||
|
||||
static char title1_p[] =
|
||||
{
|
||||
" SMPP R9 Page 01 link status (32 links)\n\r\
|
||||
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
|
||||
link_status\n\r\
|
||||
\n\r\
|
||||
daemon sock\r\n\
|
||||
tcp_client_flag\r\n\
|
||||
\r\n\
|
||||
sock_fd\r\n\
|
||||
\r\n\
|
||||
\r\n\
|
||||
\r\n\
|
||||
\r\n\
|
||||
\r\n\
|
||||
\r\n\
|
||||
\r\n\
|
||||
\r\n\
|
||||
\tLink status:\r\n\
|
||||
\t\t00 -- Not init\r\n\
|
||||
\t\t01 -- IDLE\r\n\
|
||||
\t\t02 -- WAITING\r\n\
|
||||
\t\t03 -- ESTABLISHED\r\n\
|
||||
\t\t04 -- SUSPEND"
|
||||
};
|
||||
|
||||
static char title2_p[] =
|
||||
{
|
||||
" SMPP R9 Page 02 debug struct (32 links)\n\r\
|
||||
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
|
||||
debug_switch\n\r\
|
||||
link_switch\n\r"
|
||||
};
|
||||
|
||||
static char title3_p[] =
|
||||
{
|
||||
" SMPP R9 Page 03 link type (link 0~21)\n\r\
|
||||
type\t\t00 -- UDP,\t01 -- TCP\n\r\
|
||||
link 0\n\r\
|
||||
link 1\n\r\
|
||||
link 2\n\r\
|
||||
link 3\n\r\
|
||||
link 4\n\r\
|
||||
link 5\n\r\
|
||||
link 6\n\r\
|
||||
link 7\n\r\
|
||||
link 8\n\r\
|
||||
link 9\n\r\
|
||||
link 10\n\r\
|
||||
link 11\n\r\
|
||||
link 12\n\r\
|
||||
link 13\n\r\
|
||||
link 14\n\r\
|
||||
link 15\n\r\
|
||||
link 16\n\r\
|
||||
link 17\n\r\
|
||||
link 18\n\r\
|
||||
link 19\n\r\
|
||||
link 20\n\r\
|
||||
link 21\n\r"
|
||||
};
|
||||
|
||||
static char title4_p[] =
|
||||
{
|
||||
" SMPP R9 Page 04 link type (link 22~31)\n\r\
|
||||
type\t\t00 -- UDP,\t01 -- TCP\n\r\
|
||||
link 22\n\r\
|
||||
link 23\n\r\
|
||||
link 24\n\r\
|
||||
link 25\n\r\
|
||||
link 26\n\r\
|
||||
link 27\n\r\
|
||||
link 28\n\r\
|
||||
link 29\n\r\
|
||||
link 30\n\r\
|
||||
link 31\n\r"
|
||||
};
|
||||
|
||||
static char title5_p[] =
|
||||
{
|
||||
" SMPP R9 Page 05 server_sock & client_sock\n\r\
|
||||
\r\n\
|
||||
server_sock\n\r\
|
||||
\n\r\
|
||||
\n\r\
|
||||
\n\r\
|
||||
\n\r\
|
||||
\n\r\
|
||||
\n\r\
|
||||
\n\r\
|
||||
client_sock\n\r\
|
||||
\n\r"
|
||||
};
|
||||
|
||||
BYTE smpp_disp_line(BYTE page, BYTE line)
|
||||
{
|
||||
BYTE disp_length;
|
||||
|
||||
disp_length = 16;
|
||||
disp_ptr = (char *) disp_page;
|
||||
|
||||
switch (page)
|
||||
{
|
||||
case 1:
|
||||
switch (line)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
disp_ptr = (char *) &smpp_state[disp_page[page]] + (line * 16);
|
||||
break;
|
||||
case 2:
|
||||
disp_ptr = (char *) &(Mysock.DaemonSock);
|
||||
disp_length = 1;
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
disp_ptr = (char *) &smpp_TCPClientFlag[disp_page[page]]+(line-3)*16;
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
disp_ptr = (char *) &(Mysock.Sockets[disp_page[page]]) + ((line-5)*16);
|
||||
break;
|
||||
default:
|
||||
disp_length = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2: // Page 2: link debug status
|
||||
if (line == 0)
|
||||
{
|
||||
disp_ptr = (char *) &smppDebug.debug_switch;
|
||||
disp_length = 1;
|
||||
}
|
||||
else if (line < 3)
|
||||
disp_ptr = (char *) &smppDebug.link_switch[disp_page[page]] + ((line - 1) * 16);
|
||||
else
|
||||
disp_length = 0;
|
||||
break;
|
||||
case 3: //page 3: link type
|
||||
if (line<22)
|
||||
{
|
||||
disp_ptr = (char *) &smpp_param[line].link_type;
|
||||
disp_length = 1;
|
||||
}
|
||||
break;
|
||||
case 4: //page 3: link type(0~21)
|
||||
if (line<10)
|
||||
{
|
||||
disp_ptr = (char *) &smpp_param[line+22].link_type;
|
||||
disp_length = 1;
|
||||
}else
|
||||
disp_length = 0;
|
||||
break;
|
||||
case 5: //page 5: server_socket and client_sockets
|
||||
switch (line) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
disp_ptr = (char *) &Mysock.server_sock[disp_page[page]] + line*16;
|
||||
break;
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
disp_ptr = (char *) &Mysock.client_sock[disp_page[page]] + (line-8)*16;
|
||||
break;
|
||||
default:
|
||||
disp_length = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
disp_length = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return disp_length;
|
||||
}
|
||||
|
||||
void smpp_disp_page(BYTE page)
|
||||
{
|
||||
BYTE disp_line;
|
||||
BYTE disp_length;
|
||||
|
||||
smpp_page_line[PAGE_POINT] = page + 5;
|
||||
|
||||
for (disp_line = 0; disp_line < 22; disp_line++)
|
||||
{
|
||||
disp_length = smpp_disp_line(page, disp_line);
|
||||
smpp_page_line[LINE_POINT] = disp_line + 2;
|
||||
smpp_page_line[LINE_POINT + 1] = 2; // Data Pointer
|
||||
debug_set_response(BASE_ID_LEN + 2, smpp_page_line, (BYTE *)disp_ptr, disp_length);
|
||||
}
|
||||
}
|
||||
|
||||
void smpp_debugInit()
|
||||
{
|
||||
int page;
|
||||
char* ptr;
|
||||
|
||||
smppDebug.debug_switch = 0;
|
||||
|
||||
debug_set_response(15, smpp_status_id, (BYTE *)&smpp_debug_status, 1);//smpp status
|
||||
debug_set_response(15, smpp_version_id, (BYTE *)SMPP_MODULE_VERSION, strlen(SMPP_MODULE_VERSION));
|
||||
debug_set_response(15, smpp_ascii_in_id, (BYTE *)smpp_debug_asciiIn, MAX_ASCIN_BUF_LEN);
|
||||
debug_set_response(15, smpp_ascii_out_id, (BYTE *)smpp_debug_asciiOut, MAX_ASCOUT_BUF_LEN);
|
||||
|
||||
for (page=1; page<=5; page++)
|
||||
{
|
||||
switch (page)
|
||||
{
|
||||
case 1:
|
||||
ptr = title1_p;
|
||||
break;
|
||||
case 2:
|
||||
ptr = title2_p;
|
||||
break;
|
||||
case 3:
|
||||
ptr = title3_p;
|
||||
break;
|
||||
case 4:
|
||||
ptr = title4_p;
|
||||
break;
|
||||
case 5:
|
||||
ptr = title5_p;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
smpp_page_title[PAGE_POINT] = 5 + page;
|
||||
debug_set_response(BASE_ID_LEN + 1, smpp_page_title, (BYTE *)ptr, strlen(ptr));
|
||||
smpp_disp_page(page);
|
||||
}
|
||||
|
||||
#ifdef SMPP_DEBUG
|
||||
printf("smpp debug init.\n");
|
||||
#endif //end ifdef SMPP_DEBUG
|
||||
}
|
||||
|
||||
void smpp_list_linkparam(int linkNo) {
|
||||
char debug_str[256];
|
||||
struct in_addr addr;
|
||||
|
||||
if (linkNo >= MAX_SMPP_LINK)
|
||||
{
|
||||
smpp_send_error("Link number is too big.\n\r");
|
||||
return;
|
||||
}
|
||||
|
||||
sprintf(debug_str, "\r\nLink %d parameter:\r\n", linkNo);
|
||||
smpp_send_ascout(debug_str);
|
||||
sprintf(debug_str, "link_enable: %d\r\n", smpp_param[linkNo].link_enable);
|
||||
smpp_send_ascout(debug_str);
|
||||
sprintf(debug_str, "link_type: %d\r\n", smpp_param[linkNo].link_type);
|
||||
smpp_send_ascout(debug_str);
|
||||
sprintf(debug_str, "server_type: %d\r\n", smpp_param[linkNo].server_type);
|
||||
smpp_send_ascout(debug_str);
|
||||
sprintf(debug_str, "session_type: %d\r\n", smpp_param[linkNo].session_type);
|
||||
smpp_send_ascout(debug_str);
|
||||
sprintf(debug_str, "system_id: %s\r\n", smpp_param[linkNo].sys_id);
|
||||
smpp_send_ascout(debug_str);
|
||||
sprintf(debug_str, "password: %s\r\n", smpp_param[linkNo].password);
|
||||
smpp_send_ascout(debug_str);
|
||||
sprintf(debug_str, "system_type: %s\r\n", smpp_param[linkNo].system_type);
|
||||
smpp_send_ascout(debug_str);
|
||||
sprintf(debug_str, "localGTT: %s\r\n", smpp_param[linkNo].localGTT);
|
||||
smpp_send_ascout(debug_str);
|
||||
sprintf(debug_str, "remoteGTT: %s\r\n", smpp_param[linkNo].remoteGTT);
|
||||
smpp_send_ascout(debug_str);
|
||||
addr.s_addr = smpp_param[linkNo].local_ip;
|
||||
sprintf(debug_str, "local_ip: %s\r\n", inet_ntoa(addr));
|
||||
smpp_send_ascout(debug_str);
|
||||
addr.s_addr = smpp_param[linkNo].remote_ip;
|
||||
sprintf(debug_str, "remote_ip: %s\r\n", inet_ntoa(addr));
|
||||
smpp_send_ascout(debug_str);
|
||||
sprintf(debug_str, "session_init_timer: %u\r\n", smpp_param[linkNo].session_init_timer);
|
||||
smpp_send_ascout(debug_str);
|
||||
sprintf(debug_str, "enquire_link_timer: %u\r\n", smpp_param[linkNo].enquire_link_timer);
|
||||
smpp_send_ascout(debug_str);
|
||||
sprintf(debug_str, "inactivity_timer: %u\r\n", smpp_param[linkNo].inactivity_timer);
|
||||
smpp_send_ascout(debug_str);
|
||||
sprintf(debug_str, "response_timer: %u\r\n", smpp_param[linkNo].response_timer);
|
||||
smpp_send_ascout(debug_str);
|
||||
sprintf(debug_str, "service_number: %s\r\n", smpp_param[linkNo].service_number);
|
||||
smpp_send_ascout(debug_str);
|
||||
sprintf(debug_str, "localSSN: %d\r\n", smpp_param[linkNo].localSSN);
|
||||
smpp_send_ascout(debug_str);
|
||||
sprintf(debug_str, "remoteSSN: %d\r\n", smpp_param[linkNo].remoteSSN);
|
||||
smpp_send_ascout(debug_str);
|
||||
}
|
||||
|
||||
void smpp_debugTimer()
|
||||
{
|
||||
int i, linkNo = 0;
|
||||
char debugBuf[1024];
|
||||
|
||||
if (strlen(smpp_debug_asciiIn) > 0)
|
||||
{
|
||||
if (strcmp(smpp_debug_asciiIn+1, "help") == 0)
|
||||
{
|
||||
smpp_send_ascout("SMPP Debug Monitor Help:\n\r\n\r");
|
||||
smpp_send_ascout("log none Turn off all log items\n\r");
|
||||
smpp_send_ascout("log all Turn on all log items\n\r");
|
||||
smpp_send_ascout("log link=\x1b[34mxx\x1b[0m on/off Turn on/off link x messages\n\r");
|
||||
smpp_send_ascout("list par.\x1b[34mxx\x1b[0m List link x parameter\r\n");
|
||||
sprintf(debugBuf, "ver. %s T%03d\r\n",SMPP_MODULE_VERSION,SMPP_MODULE_PATCH);
|
||||
smpp_send_ascout(debugBuf);
|
||||
}else if (strcmp(smpp_debug_asciiIn+1, "log none") == 0)
|
||||
{
|
||||
smppDebug.debug_switch = 0;
|
||||
for (i=0; i<MAX_SMPP_LINK; i++)
|
||||
{
|
||||
smppDebug.link_switch[i] = 0;
|
||||
}
|
||||
smpp_send_ascout("smpp turn off all log items.\n\r");
|
||||
}
|
||||
else if (strcmp(smpp_debug_asciiIn+1, "log all") == 0) {
|
||||
smppDebug.debug_switch = 1;
|
||||
smpp_send_ascout("smpp turn on all log items.\n\r");
|
||||
}
|
||||
else if (strncmp(smpp_debug_asciiIn+1, "list par.", 9) == 0) {
|
||||
if ((smpp_debug_asciiIn[10] >= '0') && (smpp_debug_asciiIn[10] <= '9')) {
|
||||
linkNo = smpp_debug_asciiIn[10] - '0';
|
||||
if ((smpp_debug_asciiIn[11] >= '0') && (smpp_debug_asciiIn[11] <= '9')) {
|
||||
linkNo = linkNo*10+(smpp_debug_asciiIn[11]-'0');
|
||||
// if (linkNo > MAX_SMPP_LINK)
|
||||
// smpp_send_error("Link number is too big.\n\r");
|
||||
smpp_list_linkparam(linkNo);
|
||||
}
|
||||
else
|
||||
smpp_list_linkparam(linkNo);
|
||||
}
|
||||
else
|
||||
smpp_send_error("Link number is error");
|
||||
}
|
||||
else if (strncmp(smpp_debug_asciiIn+1, "save", 4) == 0) {
|
||||
smpp_writeParam();
|
||||
}
|
||||
else if (strncmp(smpp_debug_asciiIn+1, "log link=", 9) == 0) {
|
||||
if ((smpp_debug_asciiIn[10] >= '0') && (smpp_debug_asciiIn[10] <= '9'))
|
||||
{
|
||||
linkNo = smpp_debug_asciiIn[10] - '0';
|
||||
if ((smpp_debug_asciiIn[11] >= '0') && (smpp_debug_asciiIn[11] <= '9'))
|
||||
{
|
||||
linkNo = linkNo*10+(smpp_debug_asciiIn[11]-'0');
|
||||
if (linkNo > MAX_SMPP_LINK)
|
||||
{
|
||||
smpp_send_error("Link number is too big.\n\r");
|
||||
}
|
||||
else if (strncmp(smpp_debug_asciiIn+13, "on", 2) == 0)
|
||||
{
|
||||
smppDebug.link_switch[linkNo] = 1;
|
||||
sprintf(debugBuf, "Link %d debug on.\n\r", linkNo);
|
||||
smpp_send_ascout(debugBuf);
|
||||
}else if (strncmp(smpp_debug_asciiIn+13, "off", 3) == 0)
|
||||
{
|
||||
smppDebug.link_switch[linkNo] = 0;
|
||||
sprintf(debugBuf, "Link %d debug off.\n\r", linkNo);
|
||||
smpp_send_ascout(debugBuf);
|
||||
}else
|
||||
{
|
||||
smpp_send_error("Command Error.\n\r");
|
||||
}
|
||||
}else if (strncmp(smpp_debug_asciiIn+12, "on", 2) == 0)
|
||||
{
|
||||
smppDebug.link_switch[linkNo] = 1;
|
||||
sprintf(debugBuf, "Link %d debug on.\n\r", linkNo);
|
||||
smpp_send_ascout(debugBuf);
|
||||
}else if (strncmp(smpp_debug_asciiIn+12, "off", 3) == 0)
|
||||
{
|
||||
smppDebug.link_switch[linkNo] = 0;
|
||||
sprintf(debugBuf, "Link %d debug off.\n\r", linkNo);
|
||||
smpp_send_ascout(debugBuf);
|
||||
}else
|
||||
{
|
||||
smpp_send_error("Command Error.\n\r");
|
||||
}
|
||||
}
|
||||
else
|
||||
smpp_send_error("Link number error.\n\r");
|
||||
}else
|
||||
{
|
||||
smpp_send_error("Command Error.\n\r");
|
||||
}
|
||||
|
||||
smpp_debug_asciiIn[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
void smpp_send_ascout(char *sdBuf)
|
||||
{
|
||||
if (strlen(sdBuf)+strlen(smpp_debug_asciiOut) < MAX_ASCOUT_BUF_LEN)
|
||||
{
|
||||
strcat(smpp_debug_asciiOut, sdBuf);
|
||||
}
|
||||
}
|
||||
|
||||
void smpp_send_error(char *sdBuf)
|
||||
{
|
||||
if (smppDebug.debug_switch == 1)
|
||||
{
|
||||
smpp_send_ascout("\x1b[31m");
|
||||
smpp_send_ascout(sdBuf);
|
||||
smpp_send_ascout("\x1b[0m");
|
||||
}
|
||||
}
|
||||
676
plat/smpp/src/smpp_fsm.c
Normal file
676
plat/smpp/src/smpp_fsm.c
Normal file
@@ -0,0 +1,676 @@
|
||||
/*
|
||||
** CDMA 2000 project, SMPP module
|
||||
**
|
||||
** File name: smpp_fsm.c
|
||||
** Written by Li Long at 2004-11-25
|
||||
** CVS $Id: smpp_fsm.c,v0.1 2004/11/25 17:03:14 lilong Exp $
|
||||
**
|
||||
*/
|
||||
|
||||
#include "./include/smpp.h"
|
||||
#include "./include/smpp_ext.h"
|
||||
|
||||
// fix multiple definition====================================
|
||||
extern int smpp_msg_buf_len[MAX_SMPP_LINK];
|
||||
//
|
||||
|
||||
static int smpp_timerCount = 0;
|
||||
//static int flag=-1;
|
||||
|
||||
/* Timer variable definitions. */
|
||||
static BYTE session_init_flag[MAX_SMPP_LINK];
|
||||
static WORD session_init_timer[MAX_SMPP_LINK];
|
||||
static BYTE enquire_link_flag[MAX_SMPP_LINK];
|
||||
static WORD enquire_link_timer[MAX_SMPP_LINK];
|
||||
static BYTE inactivity_flag[MAX_SMPP_LINK];
|
||||
static WORD inactivity_timer[MAX_SMPP_LINK];
|
||||
static BYTE response_flag[MAX_SMPP_LINK];
|
||||
static WORD response_timer[MAX_SMPP_LINK];
|
||||
static BYTE init_tcp_client_timeout[MAX_SMPP_LINK]={0};
|
||||
static WORD suspend_timer = 0;
|
||||
|
||||
void smpp_stateInit()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<MAX_SMPP_LINK; i++)
|
||||
{
|
||||
session_init_flag[i] = 0;
|
||||
enquire_link_flag[i] = 0;
|
||||
inactivity_flag[i] = 0;
|
||||
response_flag[i] = 0;
|
||||
session_init_timer[i] = 0;
|
||||
enquire_link_timer[i] = 0;
|
||||
inactivity_timer[i] = 0;
|
||||
response_timer[i] = 0;
|
||||
smpp_state[i] = 0;
|
||||
smpp_msg_buf_len[i] = 0;
|
||||
if (i<MAX_SMPP_LINK/4)
|
||||
{
|
||||
smpp_hearbeat_status[i] = 0;
|
||||
}
|
||||
|
||||
memset(exterEvent[i], 0, CMD_BUF_SIZE);
|
||||
memset(interEvent[i], 0, CMD_BUF_SIZE);
|
||||
inter_head[i] = 0;
|
||||
inter_tail[i] = 0;
|
||||
exter_head[i] = 0;
|
||||
exter_tail[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void smpp_fsm_new()
|
||||
{
|
||||
int link;
|
||||
char debugBuf[256];
|
||||
BYTE temp_status;
|
||||
BYTE platform_heartbeat_len;
|
||||
|
||||
if(smpp_timerCount++>1000)//1000*10ms=10s
|
||||
{
|
||||
smpp_checkParam();
|
||||
smpp_timerCount = 0;
|
||||
}
|
||||
|
||||
smpp_rvMsgOverTCP();
|
||||
// smpp_rvMsgOverSCCP(SMPP_PPS_USERTYPE);
|
||||
smpp_rvMsgOverSCCP(SMPP_SMSC_USERTYPE);
|
||||
smpp_debugTimer();
|
||||
for(link=0; link<MAX_SMPP_LINK; link++)
|
||||
{
|
||||
if ((smpp_param[link].link_enable&0x01) == 0) continue;
|
||||
// printf("link %d tcp client flag =%d, Mysock.Sockets[%d] = %d\n",
|
||||
// link, smpp_TCPClientFlag[link],
|
||||
// link, Mysock.Sockets[link]);
|
||||
if ((smpp_TCPClientFlag[link] == TRUE) && (Mysock.Sockets[link] == 0) && (init_tcp_client_timeout[link] == 0) ) {
|
||||
// printf("link %d start TCP connect.\n", link);
|
||||
smpp_tcp_connect(link);
|
||||
init_tcp_client_timeout[link] = 200;
|
||||
continue;
|
||||
}
|
||||
if (init_tcp_client_timeout[link] > 0) init_tcp_client_timeout[link]--;
|
||||
|
||||
/* Session init timer */
|
||||
if (TRUE == session_init_flag[link])
|
||||
{
|
||||
session_init_timer[link]++;
|
||||
if (session_init_timer[link] > 100*smpp_param[link].session_init_timer)
|
||||
{
|
||||
session_init_timer[link] = 0;
|
||||
inter_head[link] = (inter_head[link]+1)&0x7;
|
||||
interEvent[link][inter_head[link]] = SessionInitTimeout;
|
||||
#ifdef SMPP_DEBUG
|
||||
if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[link] == 1))
|
||||
{
|
||||
sprintf(debugBuf, "link %d session_init_timer TIMEOUT.\n", link);
|
||||
smpp_send_ascout(debugBuf);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
/* Enquire link timer */
|
||||
if (TRUE == enquire_link_flag[link])
|
||||
{
|
||||
enquire_link_timer[link]++;
|
||||
if (enquire_link_timer[link] > 100*smpp_param[link].enquire_link_timer)
|
||||
{
|
||||
enquire_link_timer[link] = 0;
|
||||
inter_head[link] = (inter_head[link]+1)&0x7;
|
||||
interEvent[link][inter_head[link]] = EnquireLinkTimeout;
|
||||
#ifdef SMPP_DEBUG
|
||||
if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[link] == 1))
|
||||
{
|
||||
sprintf(debugBuf, "link %d T1 (Enquire link timer) TIMEOUT.\n", link);
|
||||
smpp_send_ascout(debugBuf);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
/* Inactivity timer */
|
||||
if (TRUE == inactivity_flag[link])
|
||||
{
|
||||
inactivity_timer[link]++;
|
||||
if (inactivity_timer[link] > 100*smpp_param[link].inactivity_timer)
|
||||
{
|
||||
inactivity_timer[link] = 0;
|
||||
inter_head[link] = (inter_head[link]+1)&0x7;
|
||||
interEvent[link][inter_head[link]] = InactivityTimeout;
|
||||
#ifdef SMPP_DEBUG
|
||||
if ((smppDebug.debug_switch == 1) || (smppDebug.link_switch[link] == 1))
|
||||
{
|
||||
sprintf(debugBuf, "link %d T2 (Inactivity timer) TIMEOUT.\n", link);
|
||||
smpp_send_ascout(debugBuf);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(link=0; link<MAX_SMPP_LINK; link++)
|
||||
{
|
||||
if (linkAttachFlag[link] == FALSE) continue;
|
||||
if ( (Mysock.Sockets[link] <= 0) && (SMPP_TCP == smpp_param[link].link_type) )
|
||||
continue;
|
||||
switch(smpp_state[link])
|
||||
{
|
||||
case INIT:
|
||||
smpp_state[link] = IDLE;
|
||||
temp_status = IDLE;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
/*
|
||||
if (exterEvent[link][exter_tail[link]] > 0)
|
||||
{
|
||||
if (TRUE == linkUseFlag[link])
|
||||
smpp_state[link] = IDLE;
|
||||
}
|
||||
*/
|
||||
break;
|
||||
case IDLE:
|
||||
//IDLE state:: external event start.
|
||||
switch (exterEvent[link][exter_tail[link]]) {
|
||||
case Setup:
|
||||
switch (smpp_param[link].server_type) {
|
||||
case SMPP_SERVER:
|
||||
switch (smpp_param[link].session_type) {
|
||||
case BIND_RX:
|
||||
smpp_state[link] = WAITING;
|
||||
smpp_PrimitiveSend(link, Outbind);
|
||||
session_init_flag[link] = TRUE;
|
||||
//flag = 2;
|
||||
//smpp_state[link] = WAITING;//ch:if smpp_PrimitiveSend failed,that would be error
|
||||
temp_status = WAITING;//ch:if smpp_PrimitiveSend failed,that would be error
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
break;
|
||||
/*
|
||||
case BIND_TRX:
|
||||
smpp_PrimitiveSend(link, BindTransceiver);
|
||||
session_init_flag[link] = TRUE;
|
||||
flag = 1;
|
||||
smpp_state[link] = WAITING;
|
||||
temp_status = WAITING;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
break;
|
||||
*/
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SMPP_CLIENT:
|
||||
switch (smpp_param[link].session_type) {
|
||||
case BIND_TX:
|
||||
smpp_state[link] = WAITING;
|
||||
smpp_PrimitiveSend(link, BindTransmitter);
|
||||
session_init_flag[link] = TRUE;
|
||||
//flag = 1;
|
||||
//smpp_state[link] = WAITING;
|
||||
temp_status = WAITING;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
break;
|
||||
/*
|
||||
case BIND_RX:
|
||||
smpp_PrimitiveSend(link, BindReceiver);
|
||||
session_init_flag[link] = TRUE;
|
||||
flag = 0;
|
||||
smpp_state[link] = WAITING;
|
||||
temp_status = WAITING;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
break;
|
||||
*/
|
||||
case BIND_TRX:
|
||||
smpp_state[link] = WAITING;
|
||||
smpp_PrimitiveSend(link, BindTransceiver);
|
||||
session_init_flag[link] = TRUE;
|
||||
//flag = 1;
|
||||
//smpp_state[link] = WAITING;
|
||||
temp_status = WAITING;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
exterEvent[link][exter_tail[link]] = 0;
|
||||
exter_tail[link] = (exter_tail[link]+1)&0x7;
|
||||
//IDLE state:: external event end.
|
||||
//IDLE state:: internal event start.
|
||||
switch (interEvent[link][inter_tail[link]]) {
|
||||
case Outbind:
|
||||
smpp_state[link] = WAITING;
|
||||
smpp_PrimitiveSend(link, BindReceiver);
|
||||
session_init_flag[link] = TRUE;
|
||||
//flag = 0;
|
||||
//smpp_state[link] = WAITING;
|
||||
temp_status = WAITING;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
break;
|
||||
case BindTransmitter:
|
||||
smpp_state[link] = ESTABLISHED;
|
||||
smpp_PrimitiveSend(link, BindTransmitterResp);
|
||||
enquire_link_flag[link] = TRUE;
|
||||
//smpp_state[link] = ESTABLISHED;
|
||||
temp_status = ESTABLISHED;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
platform_heartbeat_len = (MAX_SMPP_LINK%4)?(MAX_SMPP_LINK/4+1):(MAX_SMPP_LINK/4);
|
||||
set_status(SMPP_HEARTBEAT_COMPONENT_ID, platform_heartbeat_len, smpp_hearbeat_status);
|
||||
if(callBackFunc[link].link_proc!= NULL)
|
||||
callBackFunc[link].link_proc(link,TRUE);
|
||||
interEvent[link][inter_tail[link]] = 0;
|
||||
inter_tail[link] = (inter_tail[link]+1)&0x7;
|
||||
return;
|
||||
|
||||
break;
|
||||
case BindTransceiver:
|
||||
smpp_state[link] = ESTABLISHED;
|
||||
smpp_PrimitiveSend(link, BindTransceiverResp);
|
||||
enquire_link_flag[link] = TRUE;
|
||||
//smpp_state[link] = ESTABLISHED;
|
||||
temp_status = ESTABLISHED;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
platform_heartbeat_len = (MAX_SMPP_LINK%4)?(MAX_SMPP_LINK/4+1):(MAX_SMPP_LINK/4);
|
||||
set_status(SMPP_HEARTBEAT_COMPONENT_ID, platform_heartbeat_len, smpp_hearbeat_status);
|
||||
if(callBackFunc[link].link_proc!= NULL)
|
||||
callBackFunc[link].link_proc(link,TRUE);
|
||||
interEvent[link][inter_tail[link]] = 0;
|
||||
inter_tail[link] = (inter_tail[link]+1)&0x7;
|
||||
return;
|
||||
|
||||
break;//fixed 2008-1-11
|
||||
case BindReceiver:
|
||||
smpp_state[link] = ESTABLISHED;
|
||||
smpp_PrimitiveSend(link, BindReceiverResp);
|
||||
session_init_flag[link] = FALSE;
|
||||
enquire_link_flag[link] = TRUE;
|
||||
temp_status = ESTABLISHED;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
platform_heartbeat_len = (MAX_SMPP_LINK%4)?(MAX_SMPP_LINK/4+1):(MAX_SMPP_LINK/4);
|
||||
set_status(SMPP_HEARTBEAT_COMPONENT_ID, platform_heartbeat_len, smpp_hearbeat_status);
|
||||
if(callBackFunc[link].link_proc!= NULL)
|
||||
callBackFunc[link].link_proc(link,TRUE);
|
||||
interEvent[link][inter_tail[link]] = 0;
|
||||
inter_tail[link] = (inter_tail[link]+1)&0x7;
|
||||
return;
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
interEvent[link][inter_tail[link]] = 0;
|
||||
inter_tail[link] = (inter_tail[link]+1)&0x7;
|
||||
//IDLE state:: internal event end.
|
||||
break;
|
||||
case WAITING:
|
||||
switch (exterEvent[link][exter_tail[link]]) {
|
||||
case Close:
|
||||
smpp_state[link] = IDLE;
|
||||
temp_status = IDLE;
|
||||
dst_ref[link] = 0;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
exterEvent[link][exter_tail[link]] = 0;
|
||||
exter_tail[link] = (exter_tail[link]+1)&0x7;
|
||||
//WAITING state:: external event end.
|
||||
//WAITING state:: Internal event start.
|
||||
switch (interEvent[link][inter_tail[link]])
|
||||
{
|
||||
case SessionInitTimeout:
|
||||
session_init_flag[link] = FALSE;
|
||||
smpp_state[link] = IDLE;
|
||||
temp_status = IDLE;
|
||||
dst_ref[link] = 0;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
break;
|
||||
case BindReceiverResp:
|
||||
//if (0 == flag) {
|
||||
session_init_flag[link] = FALSE;
|
||||
enquire_link_flag[link] = TRUE;
|
||||
smpp_state[link] = ESTABLISHED;
|
||||
temp_status = ESTABLISHED;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
platform_heartbeat_len = (MAX_SMPP_LINK%4)?(MAX_SMPP_LINK/4+1):(MAX_SMPP_LINK/4);
|
||||
set_status(SMPP_HEARTBEAT_COMPONENT_ID, platform_heartbeat_len, smpp_hearbeat_status);
|
||||
if(callBackFunc[link].link_proc!= NULL)
|
||||
callBackFunc[link].link_proc(link,TRUE);
|
||||
interEvent[link][inter_tail[link]] = 0;
|
||||
inter_tail[link] = (inter_tail[link]+1)&0x7;
|
||||
return;
|
||||
|
||||
/*
|
||||
}
|
||||
else
|
||||
smpp_state[link] = WAITING;
|
||||
*/
|
||||
break;
|
||||
case BindTransmitterResp:
|
||||
case BindTransceiverResp:
|
||||
//if (1 == flag) {
|
||||
session_init_flag[link] = FALSE;
|
||||
enquire_link_flag[link] = TRUE;
|
||||
smpp_state[link] = ESTABLISHED;
|
||||
temp_status = ESTABLISHED;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
platform_heartbeat_len = (MAX_SMPP_LINK%4)?(MAX_SMPP_LINK/4+1):(MAX_SMPP_LINK/4);
|
||||
set_status(SMPP_HEARTBEAT_COMPONENT_ID, platform_heartbeat_len, smpp_hearbeat_status);
|
||||
if(callBackFunc[link].link_proc!= NULL)
|
||||
callBackFunc[link].link_proc(link,TRUE);
|
||||
interEvent[link][inter_tail[link]] = 0;
|
||||
inter_tail[link] = (inter_tail[link]+1)&0x7;
|
||||
return;
|
||||
|
||||
/*
|
||||
}
|
||||
else
|
||||
smpp_state[link] = WAITING;
|
||||
*/
|
||||
break;
|
||||
case BindReceiver:
|
||||
//if (2 == flag) {
|
||||
smpp_PrimitiveSend(link, BindReceiverResp);
|
||||
session_init_flag[link] = FALSE;
|
||||
enquire_link_flag[link] = TRUE;
|
||||
smpp_state[link] = ESTABLISHED;
|
||||
temp_status = ESTABLISHED;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
platform_heartbeat_len = (MAX_SMPP_LINK%4)?(MAX_SMPP_LINK/4+1):(MAX_SMPP_LINK/4);
|
||||
set_status(SMPP_HEARTBEAT_COMPONENT_ID, platform_heartbeat_len, smpp_hearbeat_status);
|
||||
if(callBackFunc[link].link_proc!= NULL)
|
||||
callBackFunc[link].link_proc(link,TRUE);
|
||||
interEvent[link][inter_tail[link]] = 0;
|
||||
inter_tail[link] = (inter_tail[link]+1)&0x7;
|
||||
return;
|
||||
/*
|
||||
}
|
||||
else
|
||||
smpp_state[link] = WAITING;
|
||||
*/
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
interEvent[link][inter_tail[link]] = 0;
|
||||
inter_tail[link] = (inter_tail[link]+1)&0x7;
|
||||
//WAITING state:: internal event end.
|
||||
break;
|
||||
case ESTABLISHED:
|
||||
switch (exterEvent[link][exter_tail[link]])
|
||||
{
|
||||
case Close:
|
||||
smpp_state[link] = SUSPEND;
|
||||
smpp_PrimitiveSend(link, Unbind);
|
||||
//smpp_state[link] = SUSPEND;
|
||||
temp_status = IDLE;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
exterEvent[link][exter_tail[link]] = 0;
|
||||
exter_tail[link] = (exter_tail[link]+1)&0x7;
|
||||
//ESTABLISHED state:: external event end.
|
||||
//ESTABLISHED state:: internal event start.
|
||||
switch (interEvent[link][inter_tail[link]])
|
||||
{
|
||||
//normal messages
|
||||
case Unbind:
|
||||
smpp_PrimitiveSend(link, UnbindResp);
|
||||
dst_ref[link] = 0;
|
||||
smpp_closeTCPConnection(link);
|
||||
enquire_link_flag[link] = FALSE;
|
||||
inactivity_flag[link] = FALSE;
|
||||
inactivity_timer[link] = 0;
|
||||
smpp_state[link] = IDLE;
|
||||
temp_status = IDLE;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
platform_heartbeat_len = (MAX_SMPP_LINK%4)?(MAX_SMPP_LINK/4+1):(MAX_SMPP_LINK/4);
|
||||
set_status(SMPP_HEARTBEAT_COMPONENT_ID, platform_heartbeat_len, smpp_hearbeat_status);
|
||||
if(callBackFunc[link].link_proc!= NULL)
|
||||
callBackFunc[link].link_proc(link,FALSE);
|
||||
return;
|
||||
break;
|
||||
case SubmitSM:
|
||||
case SubmitSMResp:
|
||||
case SubmitMulti:
|
||||
case SubmitMultiResp:
|
||||
case DeliverSM:
|
||||
case DeliverSMResp:
|
||||
case DataSM:
|
||||
case DataSMResp:
|
||||
case QuerySM:
|
||||
case QuerySMResp:
|
||||
case CancelSM:
|
||||
case CancelSMResp:
|
||||
case ReplaceSM:
|
||||
case ReplaceSMResp:
|
||||
enquire_link_timer[link] = 0;
|
||||
inactivity_flag[link] = FALSE;
|
||||
inactivity_timer[link] = 0;
|
||||
smpp_state[link] = ESTABLISHED;
|
||||
temp_status = ESTABLISHED;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
break;
|
||||
case EnquireLinkTimeout:
|
||||
smpp_state[link] = ESTABLISHED;
|
||||
smpp_PrimitiveSend(link, EnquireLink);
|
||||
inactivity_flag[link] = TRUE;
|
||||
//smpp_state[link] = ESTABLISHED;
|
||||
temp_status = ESTABLISHED;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
break;
|
||||
case EnquireLink:
|
||||
smpp_state[link] = ESTABLISHED;
|
||||
smpp_PrimitiveSend(link, EnquireLinkResp);
|
||||
enquire_link_timer[link] = 0;
|
||||
//smpp_state[link] = ESTABLISHED;
|
||||
temp_status = ESTABLISHED;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
break;
|
||||
case EnquireLinkResp:
|
||||
enquire_link_timer[link] = 0;
|
||||
inactivity_flag[link] = FALSE;
|
||||
inactivity_timer[link] = 0;
|
||||
smpp_state[link] = ESTABLISHED;
|
||||
temp_status = ESTABLISHED;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
break;
|
||||
case InactivityTimeout:
|
||||
//smpp_PrimitiveSend(link, Unbind);
|
||||
//smpp_state[link] = SUSPEND;
|
||||
dst_ref[link] = 0;
|
||||
if (smpp_param[link].link_type == SMPP_TCP)
|
||||
{
|
||||
smpp_closeTCPConnection(link);
|
||||
}
|
||||
enquire_link_flag[link] = FALSE;
|
||||
inactivity_flag[link] = FALSE;
|
||||
inactivity_timer[link] = 0;
|
||||
smpp_state[link] = IDLE;
|
||||
temp_status = IDLE;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
platform_heartbeat_len = (MAX_SMPP_LINK%4)?(MAX_SMPP_LINK/4+1):(MAX_SMPP_LINK/4);
|
||||
set_status(SMPP_HEARTBEAT_COMPONENT_ID, platform_heartbeat_len, smpp_hearbeat_status);
|
||||
if(callBackFunc[link].link_proc!= NULL)
|
||||
callBackFunc[link].link_proc(link,FALSE);
|
||||
return;
|
||||
break;
|
||||
/* error handing messages */
|
||||
case BindTransmitter:
|
||||
smpp_state[link] = ESTABLISHED;
|
||||
// smpp_sendBindResp(link, BindTransmitterResp, ESME_RALYBND);
|
||||
smpp_sendBindResp(link, BindTransmitterResp, 0);
|
||||
enquire_link_timer[link] = 0;
|
||||
inactivity_flag[link] = FALSE;
|
||||
inactivity_timer[link] = 0;
|
||||
//smpp_state[link] = ESTABLISHED;
|
||||
temp_status = ESTABLISHED;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
break;
|
||||
case BindReceiver:
|
||||
smpp_state[link] = ESTABLISHED;
|
||||
// smpp_sendBindResp(link, BindReceiverResp, ESME_RALYBND);
|
||||
smpp_sendBindResp(link, BindReceiverResp, 0);
|
||||
enquire_link_timer[link] = 0;
|
||||
inactivity_flag[link] = FALSE;
|
||||
inactivity_timer[link] = 0;
|
||||
//smpp_state[link] = ESTABLISHED;
|
||||
temp_status = ESTABLISHED;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
break;
|
||||
case BindTransceiver:
|
||||
smpp_state[link] = ESTABLISHED;
|
||||
// smpp_sendBindResp(link, BindTransceiverResp, ESME_RALYBND);
|
||||
smpp_sendBindResp(link, BindTransceiverResp, 0);
|
||||
enquire_link_timer[link] = 0;
|
||||
inactivity_flag[link] = FALSE;
|
||||
inactivity_timer[link] = 0;
|
||||
//smpp_state[link] = ESTABLISHED;
|
||||
temp_status = ESTABLISHED;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
break;
|
||||
default:
|
||||
smpp_state[link] = ESTABLISHED;
|
||||
temp_status = ESTABLISHED;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
break;
|
||||
}
|
||||
interEvent[link][inter_tail[link]] = 0;
|
||||
inter_tail[link] = (inter_tail[link]+1)&0x7;
|
||||
//ESTABLISHED state:: internal event end.
|
||||
break;
|
||||
case SUSPEND:
|
||||
//SUSPEND state:: internal event start.
|
||||
suspend_timer ++;
|
||||
switch (interEvent[link][inter_tail[link]])
|
||||
{
|
||||
case UnbindResp:
|
||||
suspend_timer = 0;
|
||||
dst_ref[link] = 0;
|
||||
smpp_closeTCPConnection(link);
|
||||
enquire_link_flag[link] = FALSE;
|
||||
inactivity_flag[link] = FALSE;
|
||||
inactivity_timer[link] = 0;
|
||||
smpp_state[link] = IDLE;
|
||||
temp_status = IDLE;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
platform_heartbeat_len = (MAX_SMPP_LINK%4)?(MAX_SMPP_LINK/4+1):(MAX_SMPP_LINK/4);
|
||||
set_status(SMPP_HEARTBEAT_COMPONENT_ID, platform_heartbeat_len, smpp_hearbeat_status);
|
||||
if(callBackFunc[link].link_proc!= NULL)
|
||||
callBackFunc[link].link_proc(link,FALSE);
|
||||
return;
|
||||
break;
|
||||
/* case InactivityTimeout://ch
|
||||
if(callBackFunc[link].link_proc!= NULL)
|
||||
callBackFunc[link].link_proc(link,FALSE);
|
||||
dst_ref[link] = 0;
|
||||
if (smpp_param[link].link_type == SMPP_TCP)
|
||||
smpp_closeTCPConnection(link);
|
||||
enquire_link_flag[link] = FALSE;
|
||||
inactivity_flag[link] = FALSE;
|
||||
inactivity_timer[link] = 0;
|
||||
smpp_state[link] = IDLE;
|
||||
temp_status = IDLE;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
break;
|
||||
case SessionInitTimeout://ch
|
||||
if(callBackFunc[link].link_proc!= NULL)
|
||||
callBackFunc[link].link_proc(link,FALSE);
|
||||
dst_ref[link] = 0;
|
||||
if (smpp_param[link].link_type == SMPP_TCP)
|
||||
smpp_closeTCPConnection(link);
|
||||
enquire_link_flag[link] = FALSE;
|
||||
inactivity_flag[link] = FALSE;
|
||||
inactivity_timer[link] = 0;
|
||||
smpp_state[link] = IDLE;
|
||||
temp_status = IDLE;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
break; */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
interEvent[link][inter_tail[link]] = 0;
|
||||
inter_tail[link] = (inter_tail[link]+1)&0x7;
|
||||
if( suspend_timer++ > smpp_param[link].inactivity_timer)
|
||||
{
|
||||
suspend_timer = 0;
|
||||
dst_ref[link] = 0;
|
||||
if (smpp_param[link].link_type == SMPP_TCP)
|
||||
smpp_closeTCPConnection(link);
|
||||
enquire_link_flag[link] = FALSE;
|
||||
inactivity_flag[link] = FALSE;
|
||||
inactivity_timer[link] = 0;
|
||||
smpp_state[link] = IDLE;
|
||||
temp_status = IDLE;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
platform_heartbeat_len = (MAX_SMPP_LINK%4)?(MAX_SMPP_LINK/4+1):(MAX_SMPP_LINK/4);
|
||||
set_status(SMPP_HEARTBEAT_COMPONENT_ID, platform_heartbeat_len, smpp_hearbeat_status);
|
||||
if(callBackFunc[link].link_proc!= NULL)
|
||||
callBackFunc[link].link_proc(link,FALSE);
|
||||
return;
|
||||
}
|
||||
//SUSPEND state:: internal event end.
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
} //end switch(state)
|
||||
} //end for(froc...
|
||||
|
||||
//platform heartbeat
|
||||
platform_heartbeat_len = (MAX_SMPP_LINK%4)?(MAX_SMPP_LINK/4+1):(MAX_SMPP_LINK/4);
|
||||
set_status(SMPP_HEARTBEAT_COMPONENT_ID, platform_heartbeat_len, smpp_hearbeat_status);
|
||||
}
|
||||
|
||||
void init_link(u32 link)
|
||||
{
|
||||
BYTE temp_status;
|
||||
dst_ref[link] = 0;
|
||||
smpp_closeTCPConnection(link);
|
||||
enquire_link_flag[link] = FALSE;
|
||||
inactivity_flag[link] = FALSE;
|
||||
inactivity_timer[link] = 0;
|
||||
smpp_state[link] = IDLE;
|
||||
temp_status = IDLE;
|
||||
temp_status = temp_status<<((link%4)*2);
|
||||
smpp_hearbeat_status[link/4] |= temp_status;
|
||||
if(callBackFunc[link].link_proc!= NULL)
|
||||
callBackFunc[link].link_proc(link,FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
1204
plat/smpp/src/smpp_func.c
Normal file
1204
plat/smpp/src/smpp_func.c
Normal file
File diff suppressed because it is too large
Load Diff
819
plat/smpp/src/smpp_mib.c
Normal file
819
plat/smpp/src/smpp_mib.c
Normal file
@@ -0,0 +1,819 @@
|
||||
/*
|
||||
** CDMA 2000 project, SMPP module
|
||||
**
|
||||
** File name: smpp_mib.c
|
||||
** Written by Li Long at 2004-12-6
|
||||
** CVS $Id: smpp_mib.c,v0.1 2004-12-6 17:03:14 lilong Exp $
|
||||
**
|
||||
*/
|
||||
|
||||
#include "./include/smpp.h"
|
||||
#include "./include/smpp_ext.h"
|
||||
#include "../../../plat/snmp/src/include/macro.h"
|
||||
|
||||
void smpp_mibInit();
|
||||
int smpp_setMib(BYTE oidlen, DWORD *oid, BYTE *pData,WORD datalen);
|
||||
int smpp_getMib(BYTE oidlen, DWORD *oid, BYTE *pData,BYTE *vartype);
|
||||
int smpp_get_system(u32 column, u32 *instance, u8 *pdata, u8 *vartype);
|
||||
int smpp_set_system(u32 column, u32 *instance, u8 *pdata, u16 datalen);
|
||||
int smpp_get_link(u32 column, u32 *instance, u8 *pdata, u8 *vartype);
|
||||
int smpp_set_link(u32 column, u32 *instance, u8 *pdata, u16 datalen);
|
||||
int smpp_getnext_link(u32 *instance);
|
||||
int smpp_enable_link();
|
||||
static u8 smpp_param_flag=0;//0:unchange 1:changed
|
||||
|
||||
/*
|
||||
void smpp_set_smsc_param(BYTE *ptr, DWORD linkNo) {
|
||||
DWORD smpp_param_oid[20] = {1,3,6,1,4,1,1373,1,3,3,5,2,2};
|
||||
|
||||
smpp_param_oid[13] = linkNo;
|
||||
smpp_param_oid[14] = 0;
|
||||
set_response(15, smpp_param_oid, ptr, 25);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
int smpp_setMib(BYTE oidlen, DWORD *oid, BYTE *pData,WORD datalen)
|
||||
{
|
||||
BYTE len = 0;
|
||||
DWORD instance;
|
||||
SMPP_PARAM *pParam;
|
||||
|
||||
smpp_param_flag = 1;
|
||||
|
||||
switch(oid[SMPP_OIDLEN]) {
|
||||
case 1: //Mesurement
|
||||
return (-1);
|
||||
case 2: //Configuration
|
||||
instance = oid[SMPP_OIDLEN+2];
|
||||
if (instance > MAX_SMPP_LINK) return -1;
|
||||
pParam = &smpp_param[instance];
|
||||
switch(oid[SMPP_OIDLEN+1]) {
|
||||
case 1:
|
||||
pParam->link_enable = pData[0];
|
||||
len = 1;
|
||||
//link type
|
||||
pParam->link_type = pData[1];
|
||||
len += 1;
|
||||
//server type
|
||||
pParam->server_type = pData[2];
|
||||
len += 1;
|
||||
//session type
|
||||
pParam->session_type = pData[3];
|
||||
len += 1;
|
||||
//system id
|
||||
memset(pParam->sys_id, 0, SMPP_SYSID_LEN); //16
|
||||
memcpy(pParam->sys_id, pData+len, SMPP_SYSID_LEN);
|
||||
pParam->sys_id[SMPP_SYSID_LEN] = '\0';
|
||||
len += SMPP_SYSID_LEN;
|
||||
//password
|
||||
memset(pParam->password, 0, SMPP_PASSWD_LEN); //9
|
||||
memcpy(pParam->password, pData+len, SMPP_PASSWD_LEN);
|
||||
pParam->password[SMPP_PASSWD_LEN] = '\0';
|
||||
len += SMPP_PASSWD_LEN;
|
||||
//system type
|
||||
memset(pParam->system_type, 0, SMPP_SYSTYPE_LEN); //13
|
||||
memcpy(pParam->system_type, pData+len, SMPP_SYSTYPE_LEN);
|
||||
pParam->system_type[SMPP_SYSTYPE_LEN] = '\0';
|
||||
len += SMPP_SYSTYPE_LEN;
|
||||
//local gtt
|
||||
memset(pParam->localGTT, 0, SMPP_GTT_LEN); //16
|
||||
memcpy(pParam->localGTT, pData+len, SMPP_GTT_LEN);
|
||||
pParam->localGTT[SMPP_GTT_LEN] = '\0';
|
||||
len += SMPP_GTT_LEN;
|
||||
//remote gtt
|
||||
memset(pParam->remoteGTT, 0, SMPP_GTT_LEN);
|
||||
memcpy(pParam->remoteGTT, pData+len, SMPP_GTT_LEN);
|
||||
pParam->remoteGTT[SMPP_GTT_LEN] = '\0';
|
||||
len += SMPP_GTT_LEN;
|
||||
//local ip
|
||||
memcpy(&pParam->local_ip, pData+len, 4);
|
||||
len += 4;
|
||||
//remote ip
|
||||
memcpy(&pParam->remote_ip, pData+len, 4);
|
||||
len += 4;
|
||||
//session init timer
|
||||
pParam->session_init_timer = bcdtou32(pData+len, 4);
|
||||
len += 4;
|
||||
// enquire link timer
|
||||
pParam->enquire_link_timer = bcdtou32(pData+len, 4);
|
||||
len += 4;
|
||||
//inactivity timer
|
||||
pParam->inactivity_timer = bcdtou32(pData+len, 4);
|
||||
len += 4;
|
||||
//response timer
|
||||
pParam->response_timer = bcdtou32(pData+len, 4);
|
||||
len += 4;
|
||||
//remote service number
|
||||
memset(pParam->service_number, 0, 8);
|
||||
memcpy(pParam->service_number, pData+len, 8);
|
||||
len += 8;
|
||||
pParam->localSSN = pData[len];
|
||||
len += 1;
|
||||
pParam->remoteSSN = pData[len];
|
||||
len += 1;
|
||||
break;
|
||||
default:
|
||||
return (-1);
|
||||
}
|
||||
break;
|
||||
case 3: //Status
|
||||
switch (oid[SMPP_OIDLEN + 1]) {
|
||||
case 1: //version, read only
|
||||
return -1;
|
||||
case 2: //command
|
||||
switch (pData[0]) {
|
||||
case 0: //reset
|
||||
smpp_reset();
|
||||
break;
|
||||
case 1: //load
|
||||
smpp_loadParam();
|
||||
break;
|
||||
case 2: //save
|
||||
smpp_writeParam();
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
case 3: //status, read only
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return datalen;
|
||||
}
|
||||
|
||||
int smpp_getMib(BYTE oidlen, DWORD *oid, BYTE *pData, BYTE *vartype)
|
||||
{
|
||||
int len=0, datalen = -1;
|
||||
DWORD instance;
|
||||
SMPP_PARAM *pParam;
|
||||
|
||||
switch(oid[SMPP_OIDLEN])
|
||||
{
|
||||
case 1: //Measurement
|
||||
break;
|
||||
case 2: //Configuration
|
||||
instance = oid[SMPP_OIDLEN+2];
|
||||
if (instance > MAX_SMPP_LINK) return -1;
|
||||
pParam = &smpp_param[instance];
|
||||
switch(oid[SMPP_OIDLEN+1])
|
||||
{
|
||||
case 1: //smpp parameter
|
||||
//link enable
|
||||
pData[0] = pParam->link_enable;
|
||||
len = 1;
|
||||
//link type
|
||||
pData[1] = pParam->link_type;
|
||||
len += 1;
|
||||
//server type
|
||||
pData[2] = pParam->server_type;
|
||||
len += 1;
|
||||
//session type
|
||||
pData[3] = pParam->session_type;
|
||||
len += 1;
|
||||
//system id
|
||||
memcpy(pData+len, pParam->sys_id, SMPP_SYSID_LEN);
|
||||
len += SMPP_SYSID_LEN;
|
||||
//password
|
||||
memcpy(pData+len, pParam->password, SMPP_PASSWD_LEN);
|
||||
len += SMPP_PASSWD_LEN;
|
||||
//system type
|
||||
memcpy(pData+len, pParam->system_type, SMPP_SYSTYPE_LEN);
|
||||
len += SMPP_SYSTYPE_LEN;
|
||||
//local gtt
|
||||
memcpy(pData+len, pParam->localGTT, SMPP_GTT_LEN);
|
||||
len += SMPP_GTT_LEN;
|
||||
//remote gtt
|
||||
memcpy(pData+len, pParam->remoteGTT, SMPP_GTT_LEN);
|
||||
len += SMPP_GTT_LEN;
|
||||
//local ip
|
||||
memcpy(pData+len, &pParam->local_ip, 4);
|
||||
len += 4;
|
||||
//remote ip
|
||||
memcpy(pData+len, &pParam->remote_ip, 4);
|
||||
len += 4;
|
||||
//session init timer
|
||||
u32tobyte(pData+len, pParam->session_init_timer);
|
||||
len += 4;
|
||||
//enquire link timer
|
||||
u32tobyte(pData+len, pParam->enquire_link_timer);
|
||||
len += 4;
|
||||
//inactivity timer
|
||||
u32tobyte(pData+len, pParam->inactivity_timer);
|
||||
len += 4;
|
||||
//response timer
|
||||
u32tobyte(pData+len, pParam->response_timer);
|
||||
len += 4;
|
||||
//remote service number
|
||||
memcpy(pData+len, &pParam->service_number, 8);
|
||||
len += 8;
|
||||
pData[len] = pParam->localSSN;
|
||||
len += 1;
|
||||
pData[len] = pParam->remoteSSN;
|
||||
len += 1;
|
||||
*vartype = 4;
|
||||
datalen = len;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3: //Status
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return datalen;
|
||||
}
|
||||
|
||||
int smpp_parseLine(char *str, char (*row)[128], int maxrow)
|
||||
{
|
||||
char *pstr = str;
|
||||
int len, index = 0, i;
|
||||
BOOL black = 0;
|
||||
|
||||
len = strlen(str);
|
||||
for(i = 0; i < len && index < maxrow; i++)
|
||||
{
|
||||
if(isspace(str[i]))
|
||||
{
|
||||
if(black == 0)
|
||||
pstr = str + i + 1;
|
||||
else
|
||||
{
|
||||
str[i] = '\0';
|
||||
if(strlen(pstr) > 128)
|
||||
pstr[127] = 0;
|
||||
sprintf(row[index++], "%s", pstr);
|
||||
pstr = str + i + 1;
|
||||
}
|
||||
black = 0;
|
||||
}
|
||||
else
|
||||
black = 1;
|
||||
}
|
||||
if(black == 1)
|
||||
{
|
||||
if(strlen(pstr) > 128)
|
||||
pstr[127] = 0;
|
||||
sprintf(row[index++], "%s", pstr);
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
int smpp_loadParam()
|
||||
{
|
||||
FILE *fp;
|
||||
char str[512] = "\0", *pChr;
|
||||
char info[19][128];
|
||||
int rtn;
|
||||
int ver[3];
|
||||
BYTE linkNo;
|
||||
|
||||
fp = fopen(SMPP_CONF_FILE, "r");
|
||||
if (fp == NULL)
|
||||
{
|
||||
printf("SMPP init parameters....search %s FAILED\n",SMPP_CONF_FILE);
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
while (fgets(str, 512, fp) != NULL) {
|
||||
if ((pChr = strchr(str, '#')) != NULL) {
|
||||
if((pChr = strstr(pChr,"SMPP Config file"))!=NULL)
|
||||
{
|
||||
if ((pChr = strchr(pChr, 'R')) != NULL)
|
||||
{
|
||||
ver[0] = atoi(pChr+1);
|
||||
ver[1] = atoi(pChr+3);
|
||||
ver[2] = atoi(pChr+5);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
rtn = smpp_parseLine(str, info, 19);
|
||||
if (rtn < 17) {
|
||||
//smpp_debug(SCCPDB_ERR, "<001>Invalid line in Local_Node Table, field count = %d", rtn);
|
||||
printf("Invalid line in ./conf/smpp.conf table, field count = %d\n", rtn);
|
||||
return FALSE;
|
||||
}
|
||||
else if(rtn < 19)
|
||||
{
|
||||
sprintf(info[17],"0");
|
||||
sprintf(info[18],"0");
|
||||
}
|
||||
|
||||
linkNo = atoi(info[0]);
|
||||
smpp_param[linkNo].link_enable = atoi(info[1]);
|
||||
smpp_param[linkNo].link_type = atoi(info[2]);
|
||||
smpp_param[linkNo].server_type = atoi(info[3]);
|
||||
smpp_param[linkNo].session_type = atoi(info[4]);
|
||||
|
||||
if (strncmp(info[5], "--", 2) == 0)
|
||||
strcpy(smpp_param[linkNo].sys_id, "");
|
||||
else
|
||||
sprintf(smpp_param[linkNo].sys_id, "%s", info[5]);
|
||||
|
||||
if (strncmp(info[6], "--", 2) == 0)
|
||||
strcpy(smpp_param[linkNo].password, "");
|
||||
else
|
||||
sprintf(smpp_param[linkNo].password, "%s", info[6]);
|
||||
|
||||
if (strncmp(info[7], "--", 2) == 0)
|
||||
strcpy(smpp_param[linkNo].system_type, "");
|
||||
else
|
||||
sprintf(smpp_param[linkNo].system_type, "%s", info[7]);
|
||||
|
||||
if (strncmp(info[8], "--", 2) == 0)
|
||||
strcpy(smpp_param[linkNo].localGTT, "");
|
||||
else
|
||||
sprintf(smpp_param[linkNo].localGTT, "%s", info[8]);
|
||||
|
||||
if (strncmp(info[9], "--", 2) == 0)
|
||||
strcpy(smpp_param[linkNo].remoteGTT, "");
|
||||
else
|
||||
sprintf(smpp_param[linkNo].remoteGTT, "%s", info[9]);
|
||||
|
||||
smpp_param[linkNo].local_ip = inet_addr(info[10]);
|
||||
smpp_param[linkNo].remote_ip = inet_addr(info[11]);
|
||||
smpp_param[linkNo].session_init_timer = atol(info[12]);
|
||||
smpp_param[linkNo].enquire_link_timer = atol(info[13]);
|
||||
smpp_param[linkNo].inactivity_timer = atol(info[14]);
|
||||
smpp_param[linkNo].response_timer = atol(info[15]);
|
||||
|
||||
if (strncmp(info[16], "--", 2) == 0)
|
||||
strcpy(smpp_param[linkNo].service_number, "");
|
||||
else
|
||||
sprintf(smpp_param[linkNo].service_number, "%s", info[16]);
|
||||
|
||||
smpp_param[linkNo].localSSN = atoi(info[17]);
|
||||
smpp_param[linkNo].remoteSSN = atoi(info[18]);
|
||||
|
||||
if(ver[2] == 1)
|
||||
if(smpp_param[linkNo].link_enable & 0x01)
|
||||
smpp_param[linkNo].link_enable = 0x81;
|
||||
/*
|
||||
printf("link %d: link_enable=%d, link_type=%d; session_type=%d; sys_id=%s; password=%s; \
|
||||
system_type=%s; localGTT=%s; retmoteGTT=%s; local_ip=%s; remote ip=%s; \
|
||||
session init timer=%d; enquire link timer=%d; inactivity timer=%d; response timer=%d \
|
||||
remote service number: %s\n",
|
||||
linkNo, smpp_param[linkNo].link_enable, smpp_param[linkNo].link_type, smpp_param[linkNo].session_type, smpp_param[linkNo].sys_id, smpp_param[linkNo].password,
|
||||
smpp_param[linkNo].system_type, smpp_param[linkNo].localGTT, smpp_param[linkNo].remoteGTT, info[8], info[9],
|
||||
smpp_param[linkNo].session_init_timer, smpp_param[linkNo].enquire_link_timer, smpp_param[linkNo].inactivity_timer, smpp_param[linkNo].response_timer,
|
||||
smpp_param[linkNo].service_number
|
||||
);
|
||||
*/
|
||||
}
|
||||
fclose(fp);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int smpp_writeParam()
|
||||
{
|
||||
FILE *fp;
|
||||
int i;
|
||||
struct in_addr addr;
|
||||
|
||||
if((fp = fopen(SMPP_CONF_FILE,"w")) == NULL)
|
||||
return FAILURE;
|
||||
|
||||
fprintf(fp,"#SMPP Config file (%s)\n",SMPP_MODULE_VERSION);
|
||||
fprintf(fp,"#Copy this file to ./conf/smpp.conf to set global options\n");
|
||||
fprintf(fp,"#No lkEn lkType serverType sessionType sysID pwd sysType LGTT RGTT LIP RIP sessionTimer enqTimer inactTimer rspTimer ServiceNum localSSN remoteSSN\n");
|
||||
for(i=0; i< MAX_SMPP_LINK; i++)
|
||||
{
|
||||
fprintf(fp,"%d ", i);
|
||||
fprintf(fp,"%d ", smpp_param[i].link_enable);
|
||||
fprintf(fp,"%d ", smpp_param[i].link_type);
|
||||
fprintf(fp,"%d ", smpp_param[i].server_type);
|
||||
fprintf(fp,"%d ", smpp_param[i].session_type);
|
||||
|
||||
if (smpp_param[i].sys_id[0] == 0)
|
||||
strcpy(smpp_param[i].sys_id, "--");
|
||||
|
||||
fprintf(fp,"%s ", smpp_param[i].sys_id);
|
||||
|
||||
if (smpp_param[i].password[0] == 0)
|
||||
strcpy(smpp_param[i].password, "--");
|
||||
|
||||
fprintf(fp,"%s ", smpp_param[i].password);
|
||||
|
||||
if (smpp_param[i].system_type[0] == 0)
|
||||
fprintf(fp,"%s ", "--");
|
||||
else
|
||||
fprintf(fp,"%s ", smpp_param[i].system_type);
|
||||
|
||||
if (smpp_param[i].localGTT[0] == 0)
|
||||
strcpy(smpp_param[i].localGTT, "--");
|
||||
fprintf(fp,"%s ", smpp_param[i].localGTT);
|
||||
|
||||
if (smpp_param[i].remoteGTT[0] == 0)
|
||||
strcpy(smpp_param[i].remoteGTT, "--");
|
||||
fprintf(fp,"%s ", smpp_param[i].remoteGTT);
|
||||
|
||||
addr.s_addr = smpp_param[i].local_ip;
|
||||
fprintf(fp,"%s ", inet_ntoa(addr));
|
||||
|
||||
addr.s_addr = smpp_param[i].remote_ip;
|
||||
fprintf(fp,"%s ", inet_ntoa(addr));
|
||||
|
||||
fprintf(fp,"%u ", smpp_param[i].session_init_timer);
|
||||
fprintf(fp,"%u ", smpp_param[i].enquire_link_timer);
|
||||
fprintf(fp,"%u ", smpp_param[i].inactivity_timer);
|
||||
fprintf(fp,"%u ", smpp_param[i].response_timer);
|
||||
|
||||
if (smpp_param[i].service_number[0] == 0)
|
||||
strcpy(smpp_param[i].service_number, "--");
|
||||
fprintf(fp, "%s ", smpp_param[i].service_number);
|
||||
|
||||
fprintf(fp,"%d ", smpp_param[i].localSSN);
|
||||
fprintf(fp,"%d\n", smpp_param[i].remoteSSN);
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void smpp_checkParam()
|
||||
{
|
||||
if(smpp_param_flag)
|
||||
{
|
||||
smpp_writeParam();
|
||||
smpp_param_flag=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int smpp_enable_link()
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<MAX_SMPP_LINK; i++)
|
||||
{
|
||||
if ((smpp_param[i].link_enable&0x80)==0)
|
||||
{
|
||||
smpp_param[i].link_enable = 0x80;
|
||||
memset(smpp_param[i].service_number,0,8);
|
||||
smpp_param[i].link_type = SMPP_UDP;
|
||||
smpp_param[i].server_type = SMPP_CLIENT;
|
||||
smpp_param[i].session_type = BIND_TX;
|
||||
memset(smpp_param[i].sys_id,0,SMPP_SYSID_LEN);
|
||||
memset(smpp_param[i].password,0,SMPP_PASSWD_LEN);
|
||||
memset(smpp_param[i].system_type,0,SMPP_SYSTYPE_LEN);
|
||||
memset(smpp_param[i].localGTT,0,SMPP_GTT_LEN);
|
||||
memset(smpp_param[i].remoteGTT,0,SMPP_GTT_LEN);
|
||||
strcpy(smpp_param[i].sys_id,"--");
|
||||
strcpy(smpp_param[i].password,"--");
|
||||
strcpy(smpp_param[i].system_type, "--");
|
||||
sprintf(smpp_param[i].localGTT,"%s","--");
|
||||
sprintf(smpp_param[i].remoteGTT,"%s","--");
|
||||
strcpy(smpp_param[i].service_number, "--");
|
||||
smpp_param[i].local_ip = 0;
|
||||
smpp_param[i].remote_ip = 0;
|
||||
smpp_param[i].session_init_timer = 5;
|
||||
smpp_param[i].enquire_link_timer = 10;
|
||||
smpp_param[i].inactivity_timer = 5;
|
||||
smpp_param[i].response_timer = 5;
|
||||
smpp_param[i].localSSN = 0;
|
||||
smpp_param[i].remoteSSN = 0;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int smpp_getnext_link(u32 *instance)
|
||||
{
|
||||
int i;
|
||||
for (i=*instance; i<MAX_SMPP_LINK; i++)
|
||||
{
|
||||
if (smpp_param[i].link_enable&0x80)
|
||||
{
|
||||
*instance = i;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int smpp_set_link(u32 column, u32 *instance, u8 *pdata, u16 datalen)
|
||||
{
|
||||
SMPP_PARAM *pParam;
|
||||
int ret;
|
||||
|
||||
smpp_param_flag = 1;
|
||||
|
||||
if(column == 1)
|
||||
{
|
||||
ret = smpp_enable_link();
|
||||
if(ret == -1)
|
||||
{
|
||||
strcpy((char*)pdata,"Maximum Link is 32.");
|
||||
return -2;
|
||||
}
|
||||
else
|
||||
{
|
||||
pdata[0] = ret;
|
||||
return datalen;
|
||||
}
|
||||
}
|
||||
|
||||
if (instance[0] >= MAX_SMPP_LINK)
|
||||
return -1;
|
||||
pParam = &smpp_param[instance[0]];
|
||||
|
||||
switch(column)
|
||||
{
|
||||
case 2: //remote service number
|
||||
if (datalen > 8)
|
||||
return -1;
|
||||
memset(pParam->service_number,0,8);
|
||||
SET_OCTETSTRING(pParam->service_number, datalen);
|
||||
break;
|
||||
case 3: //link type
|
||||
SET_INTEGER(pParam->link_type);
|
||||
break;
|
||||
case 4: //server type
|
||||
SET_INTEGER(pParam->server_type);
|
||||
break;
|
||||
case 5: //session type
|
||||
SET_INTEGER(pParam->session_type);
|
||||
break;
|
||||
case 6: //system id
|
||||
if (datalen > SMPP_SYSID_LEN)
|
||||
return -1;
|
||||
memset(pParam->sys_id,0,SMPP_SYSID_LEN);
|
||||
SET_OCTETSTRING(pParam->sys_id, datalen);
|
||||
break;
|
||||
case 7: //password
|
||||
if (datalen > SMPP_PASSWD_LEN)
|
||||
return -1;
|
||||
memset(pParam->password,0,SMPP_PASSWD_LEN);
|
||||
SET_OCTETSTRING(pParam->password, datalen);
|
||||
break;
|
||||
case 8: //system type
|
||||
if (datalen > SMPP_SYSTYPE_LEN)
|
||||
return -1;
|
||||
memset(pParam->system_type,0,SMPP_SYSTYPE_LEN);
|
||||
SET_OCTETSTRING(pParam->system_type, datalen);
|
||||
break;
|
||||
case 9: //local gtt
|
||||
if (datalen > SMPP_GTT_LEN)
|
||||
return -1;
|
||||
memset(pParam->localGTT,0,SMPP_GTT_LEN);
|
||||
SET_OCTETSTRING(pParam->localGTT, datalen);
|
||||
break;
|
||||
case 10: //remote gtt
|
||||
if (datalen > SMPP_GTT_LEN)
|
||||
return -1;
|
||||
memset(pParam->remoteGTT,0,SMPP_GTT_LEN);
|
||||
SET_OCTETSTRING(pParam->remoteGTT, datalen);
|
||||
break;
|
||||
case 11: //local ip
|
||||
SET_IP(&pParam->local_ip);
|
||||
break;
|
||||
case 12: //remote ip
|
||||
SET_IP(&pParam->remote_ip);
|
||||
break;
|
||||
case 13: //session init timer
|
||||
SET_INTEGER(pParam->session_init_timer);
|
||||
break;
|
||||
case 14: // enquire link timer
|
||||
SET_INTEGER(pParam->enquire_link_timer);
|
||||
break;
|
||||
case 15: //inactivity timer
|
||||
SET_INTEGER(pParam->inactivity_timer);
|
||||
break;
|
||||
case 16: //response timer
|
||||
SET_INTEGER(pParam->response_timer);
|
||||
break;
|
||||
case 17:
|
||||
SET_INTEGER(pParam->localSSN);
|
||||
break;
|
||||
case 18:
|
||||
SET_INTEGER(pParam->remoteSSN);
|
||||
break;
|
||||
case 19://enable/disable flag
|
||||
{
|
||||
u8 temp8;
|
||||
SET_U8(temp8);
|
||||
temp8 &= 0x01;
|
||||
if(temp8 == 1)//enable
|
||||
pParam->link_enable |= 0x01;
|
||||
else
|
||||
{
|
||||
pParam->link_enable &= ~0x01;
|
||||
init_link(instance[0]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 20://delete
|
||||
{
|
||||
u8 temp8;
|
||||
SET_U8(temp8);
|
||||
if(temp8 == 6)//delete
|
||||
{
|
||||
pParam->link_enable = 0;
|
||||
init_link(instance[0]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return datalen;
|
||||
}
|
||||
|
||||
int smpp_get_link(u32 column, u32 *instance, u8 *pdata, u8 *vartype)
|
||||
{
|
||||
int datalen = -1;
|
||||
SMPP_PARAM *pParam;
|
||||
|
||||
if (instance[0] >= MAX_SMPP_LINK)
|
||||
return -1;
|
||||
pParam = &smpp_param[instance[0]];
|
||||
switch(column)
|
||||
{
|
||||
case 1: //index
|
||||
GET_INTEGER(instance[0]);
|
||||
break;
|
||||
case 2: //remote service number (LinkAlias)
|
||||
if((datalen = strlen(pParam->service_number)) > 8)
|
||||
datalen = 8;
|
||||
GET_OCTETSTRING(pParam->service_number, datalen);
|
||||
break;
|
||||
case 3: //link type
|
||||
GET_INTEGER(pParam->link_type);
|
||||
break;
|
||||
case 4: //server type
|
||||
GET_INTEGER(pParam->server_type);
|
||||
break;
|
||||
case 5: //session type
|
||||
GET_INTEGER(pParam->session_type);
|
||||
break;
|
||||
case 6: //system id
|
||||
if((datalen = strlen(pParam->sys_id)) > SMPP_SYSID_LEN)
|
||||
datalen = SMPP_SYSID_LEN;
|
||||
GET_OCTETSTRING(pParam->sys_id, datalen);
|
||||
break;
|
||||
case 7: //password
|
||||
if((datalen = strlen(pParam->password)) > SMPP_PASSWD_LEN)
|
||||
datalen = SMPP_PASSWD_LEN;
|
||||
GET_OCTETSTRING(pParam->password, datalen);
|
||||
break;
|
||||
case 8: //system type
|
||||
if((datalen = strlen(pParam->system_type)) > SMPP_SYSTYPE_LEN)
|
||||
datalen = SMPP_SYSTYPE_LEN;
|
||||
GET_OCTETSTRING(pParam->system_type, datalen);
|
||||
break;
|
||||
case 9: //local gtt
|
||||
if((datalen = strlen(pParam->localGTT)) > SMPP_GTT_LEN)
|
||||
datalen = SMPP_GTT_LEN;
|
||||
GET_OCTETSTRING(pParam->localGTT, datalen);
|
||||
break;
|
||||
case 10: //remote gtt
|
||||
if((datalen = strlen(pParam->remoteGTT)) > SMPP_GTT_LEN)
|
||||
datalen = SMPP_GTT_LEN;
|
||||
GET_OCTETSTRING(pParam->remoteGTT, datalen);
|
||||
break;
|
||||
case 11: //local ip
|
||||
GET_IP(&pParam->local_ip);
|
||||
break;
|
||||
case 12: //remote ip
|
||||
GET_IP(&pParam->remote_ip);
|
||||
break;
|
||||
case 13: //session init timer
|
||||
GET_INTEGER(pParam->session_init_timer);
|
||||
break;
|
||||
case 14: //enquire link timer
|
||||
GET_INTEGER(pParam->enquire_link_timer);
|
||||
break;
|
||||
case 15: //inactivity timer
|
||||
GET_INTEGER(pParam->inactivity_timer);
|
||||
break;
|
||||
case 16: //response timer
|
||||
GET_INTEGER(pParam->response_timer);
|
||||
break;
|
||||
case 17:
|
||||
GET_INTEGER(pParam->localSSN);
|
||||
break;
|
||||
case 18:
|
||||
GET_INTEGER(pParam->remoteSSN);
|
||||
break;
|
||||
case 19: //enable flag
|
||||
GET_U8(pParam->link_enable&0x01);
|
||||
break;
|
||||
case 20: //link enable
|
||||
GET_U8(1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return datalen;
|
||||
}
|
||||
int smpp_get_system(u32 column, u32 *instance, u8 *pdata, u8 *vartype)
|
||||
{
|
||||
int datalen = -1;
|
||||
|
||||
GET_OCTETSTRING(" ",1);
|
||||
return datalen;
|
||||
}
|
||||
|
||||
int smpp_set_system(u32 column, u32 *instance, u8 *pdata, u16 datalen)
|
||||
{
|
||||
switch(column)
|
||||
{
|
||||
case 1:
|
||||
switch (pdata[0])
|
||||
{
|
||||
case 0: //reset
|
||||
smpp_reset();
|
||||
break;
|
||||
case 1: //load
|
||||
smpp_loadParam();
|
||||
break;
|
||||
case 2: //save
|
||||
smpp_writeParam();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return datalen;
|
||||
}
|
||||
|
||||
static struct snmp_table_profile smpp_tables[] = {
|
||||
/****** Parameter table ******/
|
||||
{
|
||||
.name = "system",
|
||||
.index.len = 13,
|
||||
.index.oid = {1, 3, 6, 1, 4, 1, 1373, 2, 3, 2, 18, 2, 1},//1.3.6.1.4.1.1373.2.3.2.18.2.1
|
||||
.column = {0},
|
||||
.level = 0,
|
||||
.get_instance = NULL,
|
||||
.get_resp = smpp_get_system,
|
||||
.set_resp = smpp_set_system
|
||||
},
|
||||
{
|
||||
.name = "smpp link",
|
||||
.index.len = 14,
|
||||
.index.oid = {1, 3, 6, 1, 4, 1, 1373, 2, 3, 2, 18, 2, 2, 1},//1.3.6.1.4.1.1373.2.3.2.18.2.2.1
|
||||
.column = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0},
|
||||
.level = 1,
|
||||
.get_instance = smpp_getnext_link,
|
||||
.get_resp = smpp_get_link,
|
||||
.set_resp = smpp_set_link
|
||||
},
|
||||
};
|
||||
|
||||
static struct snmp_register smpp_register = {
|
||||
.name = "SMPP",
|
||||
.prefix_len = 11,
|
||||
.prefix_oid = {1, 3, 6, 1, 4, 1, 1373, 2, 3, 2, 18},
|
||||
.num_of_table = sizeof(smpp_tables)/sizeof(struct snmp_table_profile),
|
||||
.table = smpp_tables,
|
||||
.default_get_resp = smpp_getMib,
|
||||
.default_set_resp = smpp_setMib
|
||||
};
|
||||
|
||||
|
||||
void smpp_mibInit()
|
||||
{
|
||||
int i;
|
||||
// DWORD oid[20] = SMPP_OID;
|
||||
|
||||
for (i=0; i<MAX_SMPP_LINK; i++) {
|
||||
linkAttachFlag[i] = 0;
|
||||
smpp_TCPClientFlag[i] = 0;
|
||||
smpp_param[i].link_enable = 0;
|
||||
smpp_param[i].link_type = SMPP_UDP;
|
||||
smpp_param[i].server_type = SMPP_CLIENT;
|
||||
smpp_param[i].session_type = BIND_TX;
|
||||
smpp_param[i].localSSN = 0;
|
||||
smpp_param[i].remoteSSN = 0;
|
||||
strcpy(smpp_param[i].sys_id,"Test");
|
||||
strcpy(smpp_param[i].password,"123456");
|
||||
strcpy(smpp_param[i].system_type, "GSM");
|
||||
sprintf(smpp_param[i].localGTT,"%s","--");
|
||||
sprintf(smpp_param[i].remoteGTT,"%s","--");
|
||||
smpp_param[i].local_ip = 0;
|
||||
smpp_param[i].remote_ip = 0;
|
||||
smpp_param[i].session_init_timer= 5;
|
||||
smpp_param[i].enquire_link_timer= 10;
|
||||
smpp_param[i].inactivity_timer = 5;
|
||||
smpp_param[i].response_timer = 5;
|
||||
strcpy(smpp_param[i].service_number, "--");
|
||||
smpp_link[i].seq_num = 0;
|
||||
|
||||
Mysock.Sockets[i] = 0;
|
||||
}
|
||||
|
||||
// inquire_setmsg(SMPP_OIDLEN, oid, smpp_setMib);
|
||||
// inquire_getmsg(SMPP_OIDLEN, oid, smpp_getMib);
|
||||
|
||||
register_snmp_table(&smpp_register);
|
||||
|
||||
}
|
||||
|
||||
5897
plat/smpp/src/smpp_msg.c
Normal file
5897
plat/smpp/src/smpp_msg.c
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user