📄 simu112.h
字号:
#include <time.h>#ifdef WIN32_ENV#include <windows.h>#else#define TIME_ONESHOT 0x0000#define TIME_PERIODIC 0x0001#endif#define DRV_IDLE 1#define DRV_BUSY 2#define MAX_TIMERS 200#define MAX_FD 200/* status values for status in SO_STRUCT */#define STATUS_READY 0#define STATUS_SUSPENDED 1#define STATUS_RESTART 2#define STATUS_CONNECT 3/* Defines for current_process in client_status */#define NEW 0#define CLIENT 1#define SERVER 2#define DRIVER 3/* Defines for whichType in SOCKETSTRUCT */#define IS_HIMSELF 1#define IS_CLIENT 2#define IS_SIMDRV 3#define TL1_MAX 2048/* Return values for functions in parsefnc.c */#define PRS_SUCCESS 0#define PRS_FAILURE 1/* Bit settings for type_flag */#define CONNECT 1#define DISCONNECT 2#define SPECIAL 4#define UNKNOWN 8#define MAX_SWITCH 30#define MAX_PARAMS 6/* Licences *//* #define LIC_USERNAME "XIAN Telecomm Bureau" *//* #define LIC_USERNAME "ZHONGSHAN Telecomm Bureau" *//* #define LIC_USERNAME "DONGGUAN Telecomm Bureau" *//* #define LIC_USERNAME "ZHUHAI Telecomm Bureau" *//* #define LIC_USERNAME "BAISE Telecomm Bureau" *//* #define LIC_USERNAME "SHANTOU Telecomm Bureau" *//* #define LIC_USERNAME "JIANGMEN Telecomm Bureau" *//* #define LIC_USERNAME "SHUNDE Telecomm Bureau" */#define LIC_VERSION "1.1"/*#define LIC_USERNAME "PANYU Telecomm Bureau"#define LIC_DRIVERNUMBER 2*//* commands */enum cmds{ TST_FULL, TST_LOOP, TST_QUERY, CONN_TSTSIG_SOUNDER, CONN_TACC_POTS, DISC_TACC, MEAS_TN, MEAS_FEEDVOL, MEAS_LOOPRING, MEAS_OUTPLSE, MEAS_VG_DC, MEAS_VG_AC, MEAS_LOOP_CUREST, MEAS_LOOP_RES, MEAS_RES, MEAS_CAPNC, MEAS_IMPED, MEAS_NSE, MEAS_ISDN, TST_RINGSGNL, CONN_MONEST, DISC_MON, CONN_MONBRDGD, CONN_FMONBRDGD, UNKNOWN_CMD_NO};typedef struct{ char CommandType; char SwitchType; char CorrelationTag[7]; char TSN[6]; char PortPassword[10]; char SwitchUserName[17]; /* SwitchUserName, add by DZH 1999.1.12 */ char TestPortType; char DialNumber[11]; char TSAddress[21]; char TSPortNo[7]; char TeleNumber[11]; char V5EN[21]; char OffHook[8]; char Num[2]; char Loop[5]; char Channel[6]; char Grade[2]; char ExkNumber[11]; char Tid[25]; /* add by DZH 1998.11.2 */ char UseGrade; /* 1-use Grade 0-not use */ char EndFlag; /*the same as tl1 command,it is ';' */}TESTREQMSG;typedef struct{ char SwitchName[11]; char TestConclusion[101]; char TR2_DCres[12]; /*dr1:a-b resistant */ char TG2_DCres[12]; /*dr2:a-ground resistant */ char RG2_DCres[12]; /*dr3:b-ground resistant */ char TG2_DCvol[9]; /*dr4:a-ground voltage */ char RG2_DCvol[9]; /*dr5:b-ground voltage */ char TG_ACvol[9]; /*af1:a-ground AC voltage */ char RG_ACvol[9]; /*af2:b-ground AC voltage */ char TR_ACres[12]; /*ac1:a-b AC resistant */ char TG_ACres[12]; /*ac2:a-ground AC resistant */ char RG_ACres[12]; /*ac3:b-ground AC resistant */ char TR_cap[9]; /*ac4:a-b capacity */ char TG_cap[9]; /*ac5:a-ground capacity */ char RG_cap[9]; /*ac6:b-ground capacity */ char LongBal[5]; /*bl1:longititude balance */ char CapBal[6]; /*bl1:capacitive balance */ char MetalNoise[5]; /*nse:metalic noise */ char TG_Line[7]; /*lc1:a-ground line circuit */ char RG_Line[7]; /*lc2:b-ground line circuit */ char DialTone1; /*ct1:reserved */ char DialTone2; /*ct2:reserved */ char BatteryVol[6]; /*reserved */ char LoopCur[9]; /*lcr:loop current */ char LoopRes[9]; /*lr:loop resistant */ char TR_imped[9]; /*imp1:a-b impedance */ char TG_imped[9]; /*imp2:a-g impedance */ char RG_imped[9]; /*imp3:b-g impedance */ char OutResult[3]; /* OUTRESULT Outside Test Result -- for Access Net Test */ char DialToneResult[3]; /* DIALTONERESULT Dial Toner Test Result -- for Access Net Test */ char FeedVolResult[3]; /* FEEDVOLRESULT Feed Vol Test Result -- for Access Net Test */ char LoopRingResult[3]; /* LOOPRINGRESULT Loop Ring Test Result -- for Access Net Test */ char VBatValue[9]; /* VBATVALUE Feed Vol Test Value -- for Access Net Test */ char ILoopValue[9]; /* ILOOPVALUE Loop Current Test Value -- for Access Net Test */}TESTRESULT;typedef struct{ char CommandType; char CorrelationTag[7]; char Error[4]; TESTRESULT TestResult; char EndFlag; /*the same as tl1 command,it is ';' */}TESTMSG;typedef struct{ char TestConclusion[4]; char TR2_DCres_flag; double TR2_DCres; /*dr1:a-b resistant */ char TG2_DCres_flag; double TG2_DCres; /*dr2:a-ground resistant */ char RG2_DCres_flag; double RG2_DCres; /*dr3:b-ground resistant */ char TG2_DCvol_flag; double TG2_DCvol; /*dr4:a-ground voltage */ char RG2_DCvol_flag; double RG2_DCvol; /*dr5:b-ground voltage */ char TG_ACvol_flag; double TG_ACvol; /*af1:a-ground AC voltage */ char RG_ACvol_flag; double RG_ACvol; /*af2:b-ground AC voltage */ char TR_ACres_flag; double TR_ACres; /*ac1:a-b AC resistant */ char TG_ACres_flag; double TG_ACres; /*ac2:a-ground AC resistant */ char RG_ACres_flag; double RG_ACres; /*ac3:b-ground AC resistant */ char TR_cap_flag; double TR_cap; /*ac4:a-b capacity */ char TG_cap_flag; double TG_cap; /*ac5:a-ground capacity */ char RG_cap_flag; double RG_cap; /*ac6:b-ground capacity */ char LongBal_flag; double LongBal; /*bl1:longititude balance */ char CapBal_flag; double CapBal; /*bl1:capacitive balance */ char MetalNoise_flag; double MetalNoise; /*nse:metalic noise */ char TG_Line_flag; double TG_Line; /*lc1:a-ground line circuit */ char RG_Line_flag; double RG_Line; /*lc2:b-ground line circuit */ char DialTone1_flag; char DialTone1; /*ct1:reserved */ char DialTone2_flag; char DialTone2; /*ct2:reserved */ char BatteryVol_flag; double BatteryVol; /*reserved */ char OutResult_flag; /* OUTRESULT Outside Test Result -- for Access Net Test */ double OutResult; /*reserved */ char DialToneResult_flag; /* DIALTONERESULT Dial Toner Test Result -- for Access Net Test */ double DialToneResult; /*reserved */ char FeedVolResult_flag; /* FEEDVOLRESULT Feed Vol Test Result -- for Access Net Test */ double FeedVolResult; /*reserved */ char LoopRingResult_flag; /* LOOPRINGRESULT Loop Ring Test Result -- for Access Net Test */ double LoopRingResult; /*reserved */ char VBatValue_flag; /* VBATVALUE Feed Vol Test Value -- for Access Net Test */ double VBatValue; /*reserved */ char ILoopValue_flag; /* ILOOPVALUE Loop Current Test Value -- for Access Net Test */ double ILoopValue; /*reserved */}TESTVALUE;typedef struct{ char SwitchType; /*switch type:SIMswitchType */ char RtuId[21]; /*RtuId, add by DZH 1998.11.2 */ char ExkNumber[11]; /*exchange code:officenum */ char TSAddress[21]; /*TS address:Address */ char TSPortNo[7]; /*TS port number:PortNumber */ char TestPortType; /*TestPortType */ char PortPassword[10]; /*SIMSwitchPasswd */ char SwitchUserName[17]; /* SwitchUserName, add by DZH 1999.1.12 */ char DialNumber[11]; /*ModemTelephone */ char ServerAddress[21]; /*simdrv address:SIMSwitchIP */ int ServerPort; /*simdrv port:SIMSwitchPort */ char UseGrade; /* for access net use Grade 1-use Grade 0-not use */ char MultConnect; /* MultConnect=0: the TS port can be connected only once, MultConnect=1: the TS port can be connected more than once */}TESTDEVICE;typedef struct{ int count; TESTDEVICE *test_device;}DEVICEHEAD;typedef struct{ char item[7]; char range; double upper; double lower; char sumcode[5];}COMPTABLE;typedef struct{ int item; char item_str[7]; int first; int last;}COMPINDEX;typedef struct{ int count; COMPINDEX *comp_index;}INDEXHEAD;typedef struct{ char SwitchName[11]; char SwitchType; INDEXHEAD *index_head; COMPTABLE *compare_table;}COMPRULEDATA;typedef void (*TIMER_PROC) (void *);typedef int (*CBF) (int, void *, int);/* structure used by event timers */typedef struct{ TIMER_PROC lptc; /* timer callback !!! */ unsigned int delay; /* delay requested */ void *cbptr; unsigned int flags; time_t start; /* time when event was requested */}TIMERSTRUCT;/* Data structures for management of external events. */struct client_status{ TESTREQMSG test_req_msg; char TL1response[TL1_MAX]; /* response to TL1 command */ char tid[20]; int tsn; int current_process; /* CLIENT, SERVER, DRIVER */ int driver_fd; int himself_fd; int timer_id; int line_on; /* 1 - line has been accessed, 0 - line has been released Add by dzh 1998.12.11 */ struct client_status *next;};typedef struct client_status CLIENT_STATUS;struct driver_status{ char ctag[7]; int status; /* DRV_IDLE or DRV_BUSY */ int ts_port; /* */ char ts_address[20]; /* TCP/IP address */ int simdrv_port; char simdrv_address[20]; int client_fd; int himself_fd; int timer_id; struct driver_status *next;};typedef struct driver_status DRIVER_STATUS;typedef struct{ unsigned char *readBuffer; /* Input buffer */ int readSize; int readOffset; unsigned char *writeBuffer; int writeSize; int writeOffset; CBF cbfptr; /* call-back function pointer */ int status; int count; /*for simdrv's terminal server */ int whichType; /*0:himself 1:client 2:simdrv -1:other */ int driver_fd; /* Only for whichType=1(client) */ int client_fd; /* Only for whichType=2(driver) */ CLIENT_STATUS *clientStatus; DRIVER_STATUS *driverStatus;}SOCKETSTRUCT;typedef struct{ char *cmd; int type_flag; int cmd_number;}COMMAND;int setVercode(int sum_code, TESTVALUE test_value);int setSumCode(double test_value, char *test_item, COMPRULEDATA * p);int getSIMterm(TESTREQMSG * term_srv, char *sim_drv_addr, int *sim_drv_port);int freeCompareTable();void getTL1response(TESTRESULT test_result, char *TL1response);void deny(char *tid, char *ctag, char *buffer, char *errcode);int so_write(int handle, void *buffer, unsigned count);int so_close(int fd);void driverIdleTimeout(void *cbptr);char *normalizeTCP(char *host, char *service);unsigned int processTimers();unsigned int setEventTimer(unsigned int delay, TIMER_PROC lptc, void *cbptr, unsigned int flags);void killEventTimer(unsigned int timerid);int writeSocket(int sock_fd, char *data, int nbytes);int readSocket(int sock_fd, char *data, int nbytes);int startSIMsrv(char *service, int port);int connectToSIMdrv(char *host, char *service, int port);int clientRequest(int fd, void *buffer, int cnt);int driverResponse(int fd, void *buffer, int cnt);int attachSocket(int socket_fd, CBF fptr, int whtype);int attachClient(int fd, void *buf, int cnt);void schedProcess();char *RemoveWhitespace(char *pstr);int loadSetTable();int freeSetTable();int fqgetpass(char *);void f_split_addr_port(char *str_addr_port, char *addr, char *port);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -