init ems server code
This commit is contained in:
76
plat/public_bak/src/include/asn1.h
Normal file
76
plat/public_bak/src/include/asn1.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/********************************************************************/
|
||||
/*Title: asn1.h */
|
||||
/*Descr: ASN.1 Encoding/Decoding Module(Head file) */
|
||||
/*Author: Liang Hanxi */
|
||||
/*Create: 2002-1-15 */
|
||||
/*Version: R3V03_01 */
|
||||
/*Modify: 2002-10-22 */
|
||||
/********************************************************************/
|
||||
#ifndef _ASN_1_HEAD
|
||||
#define _ASN_1_HEAD
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
typedef struct ASN_TLV
|
||||
{
|
||||
u_char tagtype;
|
||||
u_short tagcode;
|
||||
int length;
|
||||
u_char *pvalue;
|
||||
struct ASN_TLV *pnext;
|
||||
struct ASN_TLV *psub;
|
||||
}ASN_TLV;
|
||||
|
||||
typedef struct _ASN_BUFFER
|
||||
{
|
||||
u_char *msgbuf; //store pointer of buffer
|
||||
int maxlen;
|
||||
int msglen; //totallength of message
|
||||
int pos;
|
||||
|
||||
ASN_TLV heap[256];
|
||||
char errmsg[1024];
|
||||
short tlvcount;
|
||||
}ASN_BUF;
|
||||
|
||||
//interface======>
|
||||
void AsnEncode(u_char *msg_buf,u_int maxlen,ASN_BUF *asnbuf);
|
||||
int AsnDecode(u_char *msg_buf,int msglen,int maxtlv,int *errpos,ASN_BUF *asnbuf);
|
||||
int GetTLV(const char *tag_seq,int maxlen,u_char *pvalue,u_char flag,ASN_BUF *asnbuf);
|
||||
int GetAnyTLV(const char *tag_seq,int maxlen,u_char *pvalue,u_char *pflag,u_short *ptagcode,ASN_BUF *asnbuf);
|
||||
int AddTLV(const char *tag_seq,u_int length,u_char *pvalue,u_char tlv_type,ASN_BUF *asnbuf);
|
||||
int GetInteger(const char *tag_seq,int *rtn,u_char flag,ASN_BUF *asnbuf);
|
||||
int AddInteger(const char *tag_seq,int value,u_char tlv_type,ASN_BUF *asnbuf);
|
||||
|
||||
void asn_encode(u_char *asn_buf,ASN_BUF *asnbuf);
|
||||
void asn_encode_v3(u_char *msg_buf,u_int maxlen,ASN_BUF *asnbuf);
|
||||
int add_tlv(const char *tag_seq,u_int length,u_char *pvalue,u_char tlv_type,ASN_BUF *asnbuf);
|
||||
int asn_decode(u_char *asn_buf,int ntlv,ASN_BUF *asnbuf);
|
||||
int asn_decode_v2(u_char *msg_buf,int ntlv,int *plen,ASN_BUF *asnbuf);
|
||||
int asn_decode_v3(u_char *msg_buf,int msglen,int *errpos,ASN_BUF *asnbuf);
|
||||
int get_tlv(const char *tag_seq,u_char *pvalue,ASN_BUF *asnbuf);
|
||||
int get_tlv_v2(const char *tag_seq,u_char *pvalue,u_char *flag,ASN_BUF *asnbuf);
|
||||
int parse_tlv(ASN_TLV **pnode,ASN_BUF *asnbuf);
|
||||
//int parse_tlv2(u_char *asn_buf,int rest,u_short (*tags)[2],int order,ASN_BUF *asnbuf);
|
||||
int findtlv(u_char *pasn,u_int tagcode,u_char **pnext,int rest);
|
||||
int findtlv2(u_char *pasn,int index,u_char **pnext,int rest);
|
||||
int gettagcode(u_char *asnbuf,u_int *tagcode,u_char *type);
|
||||
int getlength(u_char *asnbuf,int *len);
|
||||
int addtagcode(u_char *asn_buf,u_int tagcode,u_char type);
|
||||
int addlength(u_char *asn_buf,u_int len);
|
||||
int parse_tags(const char *tag_seq,u_short (*tags)[2]);
|
||||
int modifylength(u_char *ptr[],int level,int addval);
|
||||
void showbuf(u_char *buf,int len);
|
||||
|
||||
int add_bool(const char *tag_seq,u_char value,u_char tlv_type,ASN_BUF *asnbuf);
|
||||
u_char get_bool(const char *tag_seq,ASN_BUF *asnbuf);
|
||||
int add_int(const char *tag_seq,int value,u_char tlv_type,ASN_BUF *asnbuf);
|
||||
int get_int(const char *tag_seq,ASN_BUF *asnbuf);
|
||||
int get_int_v2(const char *tag_seq,int *rtn,ASN_BUF *asnbuf);
|
||||
int add_oid(const char *tag_seq,const char *oidstr,u_char tlv_type,ASN_BUF *asnbuf);
|
||||
int get_oid(const char *tag_seq,char *oid,ASN_BUF *asnbuf);
|
||||
int add_null(const char *tag_seq,u_char tlv_type,ASN_BUF *asnbuf);
|
||||
int get_null(const char *tag_seq,ASN_BUF *asnbuf);
|
||||
int DecodeInteger(u_char *buf, u_char len);
|
||||
#endif
|
||||
123
plat/public_bak/src/include/bisearch.h
Normal file
123
plat/public_bak/src/include/bisearch.h
Normal file
@@ -0,0 +1,123 @@
|
||||
|
||||
/******************************************/
|
||||
/*Title : bisearch.h */
|
||||
/*Descr : BiSearch arithmetic Structure */
|
||||
/*Author : Liu Wei */
|
||||
/*Create : 2006-12-13 */
|
||||
/*Version : R1V00_01 */
|
||||
/*Modify : 2006-12-13 */
|
||||
/******************************************/
|
||||
|
||||
#ifndef _BISEARCH_H_
|
||||
#define _BISEARCH_H_
|
||||
|
||||
#define LL long long
|
||||
#define u8 unsigned char
|
||||
|
||||
typedef struct BiSearch
|
||||
{
|
||||
LL llKey; //BiSearch Array Node Key
|
||||
int nDUPosIndex; //Data Unit array Position Index
|
||||
}
|
||||
BiSearch;
|
||||
|
||||
#define BS_SIZE sizeof(BiSearch)
|
||||
|
||||
typedef struct BiSearchArray
|
||||
{
|
||||
int nArrayCount;
|
||||
int nArrayTotalLen;
|
||||
BiSearch *pBiArray; //SearchArray pointer
|
||||
int (*GetIdleNodeFunc)(int* nDUIndex);
|
||||
}
|
||||
BiSearchArray;
|
||||
|
||||
/*********************************************************************/
|
||||
/*BiSearchReg : Init BiSearch Struct, Alloc BiSearch Memery */
|
||||
/*Return : [0]:BiSearchReg fail [1] :BiSearchReg Success */
|
||||
/*********************************************************************/
|
||||
extern int BISearchReg ( BiSearchArray * pBSA, int nTotalSize ,void *GetIdleNodeFunc );
|
||||
|
||||
|
||||
/*********************************************************************/
|
||||
/*BiSearchUnReg : Release BiSearch Memery */
|
||||
/*Return : [0]:BiSearchUnReg fail [1] :BiSearchUnReg Success */
|
||||
/*********************************************************************/
|
||||
int BISearchUnReg ( BiSearchArray * pBSA);
|
||||
|
||||
|
||||
/*********************************************************************/
|
||||
/*BSearch : BiSearch from nStart to nEnd with the llKey */
|
||||
/* Search Result save in the val "nPosResult" */
|
||||
/*Return : [0]:BSearch fail [1] :BSearch Success */
|
||||
/*********************************************************************/
|
||||
int BSearch ( BiSearchArray * pBSA, int nStart, int nEnd, LL llKey, int *nPosResult );
|
||||
|
||||
|
||||
/*********************************************************************/
|
||||
/*BSearchArray : BiSearch from 0 to ArrayEndIndex with the llKey */
|
||||
/* Search nPos Result save in the val "nPosResult" */
|
||||
/*Return : [0]:BSearchArray fail [1] :BSearchArray Success */
|
||||
/*********************************************************************/
|
||||
int BSearchArray ( BiSearchArray * pBSA, LL llKey, int *nPosResult );
|
||||
|
||||
|
||||
/*********************************************************************/
|
||||
/*BISInsert : Insert a BiSearch Array Element with the llKey */
|
||||
/* return Data Unit Array Index Get by GetIdleNodeFunc*/
|
||||
/*Return : [0]:BISInsert fail [1]:BISInsert Success */
|
||||
/*********************************************************************/
|
||||
int BISInsert ( BiSearchArray * pBSA, LL llKey, int nDUPosIndex );
|
||||
|
||||
/*********************************************************************/
|
||||
/*BISDelete : Delete a BiSearch Array Element with the llKey */
|
||||
/*Return : [0]:BISDelete fail [1]:BISDelete Success */
|
||||
/*********************************************************************/
|
||||
int BISDelete ( BiSearchArray * pBSA, LL llKey );
|
||||
|
||||
|
||||
/*********************************************************************/
|
||||
/*BISSearch : BiSearch from 0 to ArrayEndIndex with the llKey */
|
||||
/* Search DUIndex Result save in the val "nDUPosIndex"*/
|
||||
/*Return : [0]:BISSearch fail [1]:BISSearch Success */
|
||||
/*********************************************************************/
|
||||
int BISSearch ( BiSearchArray * pBSA, LL llKey , int* nDUPosIndex);
|
||||
|
||||
/*********************************************************************/
|
||||
/*GetBISearchCount : Get The BiSearch struct counter */
|
||||
/*Return : return The BiSearch struct counter */
|
||||
/*********************************************************************/
|
||||
int GetBISearchCount ( BiSearchArray * pBSA);
|
||||
|
||||
/*********************************************************************/
|
||||
/*GetDUIndex : Get The Data Unit Index by bisearch struct index */
|
||||
/*Return : return the BiSearch struct dataunit index */
|
||||
/*********************************************************************/
|
||||
int GetDUIndex ( BiSearchArray * pBSA, int nBIIndex);
|
||||
|
||||
//BiSearch ManageMent Operation
|
||||
typedef enum _BIS_OP
|
||||
{
|
||||
BIS_INIT = 0,
|
||||
BIS_SEARCH,
|
||||
BIS_INSERT,
|
||||
BIS_DELETE,
|
||||
}BIS_OP;
|
||||
|
||||
/*********************************************************************/
|
||||
/*BISSearchMng : BiSearch Management Opertion fuction */
|
||||
/* Init : use BIS_OP [BIS_INIT] Insert the elment */
|
||||
/* with the key_str and nDUIndex */
|
||||
/* Search : use BIS_OP [BIS_SEARCH] search the elemnt */
|
||||
/* with the key_str ,return nDUIndex */
|
||||
/* Insert : se BIS_OP [BIS_Insert] Insert a BiSearch */
|
||||
/* Array Element with the llKey ,return Data */
|
||||
/* Unit Array Index Get by GetIdleNodeFunc() */
|
||||
/* by GetIdleNodeFunc() */
|
||||
/* Delete : use BIS_OP [BIS_DELETE] Delete the elment */
|
||||
/* with the key_str */
|
||||
/*Return : [0] fail [1] success */
|
||||
/*********************************************************************/
|
||||
int BISSearchMng( BiSearchArray * pBSA, BIS_OP mng_type,LL llkey, int* nDUIndex );
|
||||
|
||||
#endif
|
||||
28
plat/public_bak/src/include/crypt.h
Normal file
28
plat/public_bak/src/include/crypt.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* crypt.h ---- Key management and data encryption/decryption.
|
||||
*/
|
||||
|
||||
#ifndef CRYPT__H
|
||||
#define CRYPT__H
|
||||
|
||||
void des(unsigned char *output, const unsigned char *input, const unsigned char *key, int direction);
|
||||
void atob (unsigned char *bcd_buf, const char *ascii_buf, int len);
|
||||
void btoa (char *ascii_buf, const unsigned char *bcd_buf, int len);
|
||||
void EncryptPIN (unsigned char cipher[], const char plain[], const char pan[], const unsigned char pin_key[]);
|
||||
void DecryptPIN (char plain[], const unsigned char cipher[], const char pan[], const unsigned char pin_key[]);
|
||||
void CalcMAC (char mac[], const char data[], const unsigned char mac_key[]);
|
||||
void CalcMAC1 (unsigned char mac[], const unsigned char data[], int len, const unsigned char mac_key[]);
|
||||
void EncryptKey (char cipher[], const unsigned char plain[]);
|
||||
void DecryptKey (unsigned char plain[], const char cipher[]);
|
||||
|
||||
typedef enum _des_crypt_mode{
|
||||
_DES_ENCRYPT_ = 0,
|
||||
_DES_DECRYPT_
|
||||
}_DesMode;
|
||||
|
||||
void DesCrypt(
|
||||
unsigned char *Output /*8 bytes*/,
|
||||
unsigned char *Input /*8 bytes*/,
|
||||
unsigned char *DesKey/*default=NULL.While using for user licenses control,can keep the default value*/,
|
||||
unsigned char DesMode/*encrpt or decrypt,refer to enum _DesMode*/);
|
||||
#endif
|
||||
47
plat/public_bak/src/include/includes.h
Normal file
47
plat/public_bak/src/include/includes.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/* public include head file */
|
||||
/* written by Liu Zhiguo 2002-03-26 */
|
||||
/* Version 1.0 */
|
||||
/* -------------------------------- */
|
||||
|
||||
#ifndef _PUBLIC_INCLUDES_H_
|
||||
#define _PUBLIC_INCLUDES_H_
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <math.h>
|
||||
#include <netdb.h>
|
||||
#include <setjmp.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <syslog.h>
|
||||
#include <termio.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <memory.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_arp.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/ip_icmp.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/io.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/msg.h>
|
||||
#include <sys/sem.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/timeb.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
|
||||
#endif
|
||||
31
plat/public_bak/src/include/license_id.h
Normal file
31
plat/public_bak/src/include/license_id.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef _LICENCE_ID__H
|
||||
#define _LICENCE_ID__H
|
||||
|
||||
typedef enum _WXC2_LICENSE_ID
|
||||
{
|
||||
LIC_MSC_TRUNK,
|
||||
LIC_HLR_USERS,
|
||||
LIC_VLR_USERS,
|
||||
LIC_AUC_USERS,
|
||||
LIC_EIR_USERS,
|
||||
LIC_PPS_USERS,
|
||||
LIC_SMSC_USERS,
|
||||
LIC_MNP_USERS,
|
||||
|
||||
LIC_GPRS,
|
||||
LIC_USSD,
|
||||
LIC_ISUP,
|
||||
LIC_BICC,
|
||||
LIC_AIF,
|
||||
LIC_MGC,
|
||||
LIC_CAP,
|
||||
LIC_OPPS_USERS,
|
||||
LIC_OPPS_OPR,
|
||||
LIC_OPPS_IMDM,
|
||||
}WXC2_LICENSE_ID;
|
||||
|
||||
/* functionID: listed above,
|
||||
if functionID doesn't exist, return -1, else return license value
|
||||
*/
|
||||
int wxc2_get_license(int functionID);
|
||||
#endif
|
||||
707
plat/public_bak/src/include/memwatch.h
Normal file
707
plat/public_bak/src/include/memwatch.h
Normal file
@@ -0,0 +1,707 @@
|
||||
/*
|
||||
** MEMWATCH.H
|
||||
** Nonintrusive ANSI C memory leak / overwrite detection
|
||||
** Copyright (C) 1992-2002 Johan Lindh
|
||||
** All rights reserved.
|
||||
** Version 2.71
|
||||
**
|
||||
************************************************************************
|
||||
**
|
||||
** PURPOSE:
|
||||
**
|
||||
** MEMWATCH has been written to allow guys and gals that like to
|
||||
** program in C a public-domain memory error control product.
|
||||
** I hope you'll find it's as advanced as most commercial packages.
|
||||
** The idea is that you use it during the development phase and
|
||||
** then remove the MEMWATCH define to produce your final product.
|
||||
** MEMWATCH is distributed in source code form in order to allow
|
||||
** you to compile it for your platform with your own compiler.
|
||||
** It's aim is to be 100% ANSI C, but some compilers are more stingy
|
||||
** than others. If it doesn't compile without warnings, please mail
|
||||
** me the configuration of operating system and compiler you are using
|
||||
** along with a description of how to modify the source, and the version
|
||||
** number of MEMWATCH that you are using.
|
||||
**
|
||||
************************************************************************
|
||||
|
||||
This file is part of MEMWATCH.
|
||||
|
||||
MEMWATCH is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
MEMWATCH is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with MEMWATCH; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
************************************************************************
|
||||
**
|
||||
** REVISION HISTORY:
|
||||
**
|
||||
** 920810 JLI [1.00]
|
||||
** 920830 JLI [1.10 double-free detection]
|
||||
** 920912 JLI [1.15 mwPuts, mwGrab/Drop, mwLimit]
|
||||
** 921022 JLI [1.20 ASSERT and VERIFY]
|
||||
** 921105 JLI [1.30 C++ support and TRACE]
|
||||
** 921116 JLI [1.40 mwSetOutFunc]
|
||||
** 930215 JLI [1.50 modified ASSERT/VERIFY]
|
||||
** 930327 JLI [1.51 better auto-init & PC-lint support]
|
||||
** 930506 JLI [1.55 MemWatch class, improved C++ support]
|
||||
** 930507 JLI [1.60 mwTest & CHECK()]
|
||||
** 930809 JLI [1.65 Abort/Retry/Ignore]
|
||||
** 930820 JLI [1.70 data dump when unfreed]
|
||||
** 931016 JLI [1.72 modified C++ new/delete handling]
|
||||
** 931108 JLI [1.77 mwSetAssertAction() & some small changes]
|
||||
** 940110 JLI [1.80 no-mans-land alloc/checking]
|
||||
** 940328 JLI [2.00 version 2.0 rewrite]
|
||||
** Improved NML (no-mans-land) support.
|
||||
** Improved performance (especially for free()ing!).
|
||||
** Support for 'read-only' buffers (checksums)
|
||||
** ^^ NOTE: I never did this... maybe I should?
|
||||
** FBI (free'd block info) tagged before freed blocks
|
||||
** Exporting of the mwCounter variable
|
||||
** mwBreakOut() localizes debugger support
|
||||
** Allocation statistics (global, per-module, per-line)
|
||||
** Self-repair ability with relinking
|
||||
** 950913 JLI [2.10 improved garbage handling]
|
||||
** 951201 JLI [2.11 improved auto-free in emergencies]
|
||||
** 960125 JLI [X.01 implemented auto-checking using mwAutoCheck()]
|
||||
** 960514 JLI [2.12 undefining of existing macros]
|
||||
** 960515 JLI [2.13 possibility to use default new() & delete()]
|
||||
** 960516 JLI [2.20 suppression of file flushing on unfreed msgs]
|
||||
** 960516 JLI [2.21 better support for using MEMWATCH with DLL's]
|
||||
** 960710 JLI [X.02 multiple logs and mwFlushNow()]
|
||||
** 960801 JLI [2.22 merged X.01 version with current]
|
||||
** 960805 JLI [2.30 mwIsXXXXAddr() to avoid unneeded GP's]
|
||||
** 960805 JLI [2.31 merged X.02 version with current]
|
||||
** 961002 JLI [2.32 support for realloc() + fixed STDERR bug]
|
||||
** 961222 JLI [2.40 added mwMark() & mwUnmark()]
|
||||
** 970101 JLI [2.41 added over/underflow checking after failed ASSERT/VERIFY]
|
||||
** 970113 JLI [2.42 added support for PC-Lint 7.00g]
|
||||
** 970207 JLI [2.43 added support for strdup()]
|
||||
** 970209 JLI [2.44 changed default filename to lowercase]
|
||||
** 970405 JLI [2.45 fixed bug related with atexit() and some C++ compilers]
|
||||
** 970723 JLI [2.46 added MW_ARI_NULLREAD flag]
|
||||
** 970813 JLI [2.47 stabilized marker handling]
|
||||
** 980317 JLI [2.48 ripped out C++ support; wasn't working good anyway]
|
||||
** 980318 JLI [2.50 improved self-repair facilities & SIGSEGV support]
|
||||
** 980417 JLI [2.51 more checks for invalid addresses]
|
||||
** 980512 JLI [2.52 moved MW_ARI_NULLREAD to occur before aborting]
|
||||
** 990112 JLI [2.53 added check for empty heap to mwIsOwned]
|
||||
** 990217 JLI [2.55 improved the emergency repairs diagnostics and NML]
|
||||
** 990224 JLI [2.56 changed ordering of members in structures]
|
||||
** 990303 JLI [2.57 first maybe-fixit-for-hpux test]
|
||||
** 990516 JLI [2.58 added 'static' to the definition of mwAutoInit]
|
||||
** 990517 JLI [2.59 fixed some high-sensitivity warnings]
|
||||
** 990610 JLI [2.60 fixed some more high-sensitivity warnings]
|
||||
** 990715 JLI [2.61 changed TRACE/ASSERT/VERIFY macro names]
|
||||
** 991001 JLI [2.62 added CHECK_BUFFER() and mwTestBuffer()]
|
||||
** 991007 JLI [2.63 first shot at a 64-bit compatible version]
|
||||
** 991009 JLI [2.64 undef's strdup() if defined, mwStrdup made const]
|
||||
** 000704 JLI [2.65 added some more detection for 64-bits]
|
||||
** 010502 JLI [2.66 incorporated some user fixes]
|
||||
** [mwRelink() could print out garbage pointer (thanks mac@phobos.ca)]
|
||||
** [added array destructor for C++ (thanks rdasilva@connecttel.com)]
|
||||
** [added mutex support (thanks rdasilva@connecttel.com)]
|
||||
** 010531 JLI [2.67 fix: mwMutexXXX() was declared even if MW_HAVE_MUTEX was not defined]
|
||||
** 010619 JLI [2.68 fix: mwRealloc() could leave the mutex locked]
|
||||
** 020918 JLI [2.69 changed to GPL, added C++ array allocation by Howard Cohen]
|
||||
** 030212 JLI [2.70 mwMalloc() bug for very large allocations (4GB on 32bits)]
|
||||
** 030520 JLI [2.71 added ULONG_LONG_MAX as a 64-bit detector (thanks Sami Salonen)]
|
||||
**
|
||||
** To use, simply include 'MEMWATCH.H' as a header file,
|
||||
** and add MEMWATCH.C to your list of files, and define the macro
|
||||
** 'MEMWATCH'. If this is not defined, MEMWATCH will disable itself.
|
||||
**
|
||||
** To call the standard C malloc / realloc / calloc / free; use mwMalloc_(),
|
||||
** mwCalloc_() and mwFree_(). Note that mwFree_() will correctly
|
||||
** free both malloc()'d memory as well as mwMalloc()'d.
|
||||
**
|
||||
** 980317: C++ support has been disabled.
|
||||
** The code remains, but is not compiled.
|
||||
**
|
||||
** For use with C++, which allows use of inlining in header files
|
||||
** and class specific new/delete, you must also define 'new' as
|
||||
** 'mwNew' and 'delete' as 'mwDelete'. Do this *after* you include
|
||||
** C++ header files from libraries, otherwise you can mess up their
|
||||
** class definitions. If you don't define these, the C++ allocations
|
||||
** will not have source file and line number information. Also note,
|
||||
** most C++ class libraries implement their own C++ memory management,
|
||||
** and don't allow anyone to override them. MFC belongs to this crew.
|
||||
** In these cases, the only thing to do is to use MEMWATCH_NOCPP.
|
||||
**
|
||||
** You can capture output from MEMWATCH using mwSetOutFunc().
|
||||
** Just give it the adress of a "void myOutFunc(int c)" function,
|
||||
** and all characters to be output will be redirected there.
|
||||
**
|
||||
** A failing ASSERT() or VERIFY() will normally always abort your
|
||||
** program. This can be changed using mwSetAriFunc(). Give it a
|
||||
** pointer to a "int myAriFunc(const char *)" function. Your function
|
||||
** must ask the user whether to Abort, Retry or Ignore the trap.
|
||||
** Return 2 to Abort, 1 to Retry or 0 to Ignore. Beware retry; it
|
||||
** causes the expression to be evaluated again! MEMWATCH has a
|
||||
** default ARI handler. It's disabled by default, but you can enable
|
||||
** it by calling 'mwDefaultAri()'. Note that this will STILL abort
|
||||
** your program unless you define MEMWATCH_STDIO to allow MEMWATCH
|
||||
** to use the standard C I/O streams. Also, setting the ARI function
|
||||
** will cause MEMWATCH *NOT* to write the ARI error to stderr. The
|
||||
** error string is passed to the ARI function instead, as the
|
||||
** 'const char *' parameter.
|
||||
**
|
||||
** You can disable MEMWATCH's ASSERT/VERIFY and/or TRACE implementations.
|
||||
** This can be useful if you're using a debug terminal or smart debugger.
|
||||
** Disable them by defining MW_NOASSERT, MW_NOVERIFY or MW_NOTRACE.
|
||||
**
|
||||
** MEMWATCH fills all allocated memory with the byte 0xFE, so if
|
||||
** you're looking at erroneous data which are all 0xFE:s, the
|
||||
** data probably was not initialized by you. The exception is
|
||||
** calloc(), which will fill with zero's. All freed buffers are
|
||||
** zapped with 0xFD. If this is what you look at, you're using
|
||||
** data that has been freed. If this is the case, be aware that
|
||||
** MEMWATCH places a 'free'd block info' structure immediately
|
||||
** before the freed data. This block contains info about where
|
||||
** the block was freed. The information is in readable text,
|
||||
** in the format "FBI<counter>filename(line)", for example:
|
||||
** "FBI<267>test.c(12)". Using FBI's slows down free(), so it's
|
||||
** disabled by default. Use mwFreeBufferInfo(1) to enable it.
|
||||
**
|
||||
** To aid in tracking down wild pointer writes, MEMWATCH can perform
|
||||
** no-mans-land allocations. No-mans-land will contain the byte 0xFC.
|
||||
** MEMWATCH will, when this is enabled, convert recently free'd memory
|
||||
** into NML allocations.
|
||||
**
|
||||
** MEMWATCH protects it's own data buffers with checksums. If you
|
||||
** get an internal error, it means you're overwriting wildly,
|
||||
** or using an uninitialized pointer.
|
||||
**
|
||||
************************************************************************
|
||||
**
|
||||
** Note when compiling with Microsoft C:
|
||||
** - MSC ignores fflush() by default. This is overridden, so that
|
||||
** the disk log will always be current.
|
||||
**
|
||||
** This utility has been tested with:
|
||||
** PC-lint 7.0k, passed as 100% ANSI C compatible
|
||||
** Microsoft Visual C++ on Win16 and Win32
|
||||
** Microsoft C on DOS
|
||||
** SAS C on an Amiga 500
|
||||
** Gnu C on a PC running Red Hat Linux
|
||||
** ...and using an (to me) unknown compiler on an Atari machine.
|
||||
**
|
||||
************************************************************************
|
||||
**
|
||||
** Format of error messages in MEMWATCH.LOG:
|
||||
** message: <sequence-number> filename(linenumber), information
|
||||
**
|
||||
** Errors caught by MemWatch, when they are detected, and any
|
||||
** actions taken besides writing to the log file MEMWATCH.LOG:
|
||||
**
|
||||
** Double-freeing:
|
||||
** A pointer that was recently freed and has not since been
|
||||
** reused was freed again. The place where the previous free()
|
||||
** was executed is displayed.
|
||||
** Detect: delete or free() using the offending pointer.
|
||||
** Action: The delete or free() is cancelled, execution continues.
|
||||
** Underflow:
|
||||
** You have written just ahead of the allocated memory.
|
||||
** The size and place of the allocation is displayed.
|
||||
** Detect: delete or free() of the damaged buffer.
|
||||
** Action: The buffer is freed, but there may be secondary damage.
|
||||
** Overflow:
|
||||
** Like underflow, but you've written after the end of the buffer.
|
||||
** Detect: see Underflow.
|
||||
** Action: see Underflow.
|
||||
** WILD free:
|
||||
** An unrecognized pointer was passed to delete or free().
|
||||
** The pointer may have been returned from a library function;
|
||||
** in that case, use mwFree_() to force free() of it.
|
||||
** Also, this may be a double-free, but the previous free was
|
||||
** too long ago, causing MEMWATCH to 'forget' it.
|
||||
** Detect: delete or free() of the offending pointer.
|
||||
** Action: The delete or free() is cancelled, execution continues.
|
||||
** NULL free:
|
||||
** It's unclear to me whether or not freeing of NULL pointers
|
||||
** is legal in ANSI C, therefore a warning is written to the log file,
|
||||
** but the error counter remains the same. This is legal using C++,
|
||||
** so the warning does not appear with delete.
|
||||
** Detect: When you free(NULL).
|
||||
** Action: The free() is cancelled.
|
||||
** Failed:
|
||||
** A request to allocate memory failed. If the allocation is
|
||||
** small, this may be due to memory depletion, but is more likely
|
||||
** to be memory fragmentation problems. The amount of memory
|
||||
** allocated so far is displayed also.
|
||||
** Detect: When you new, malloc(), realloc() or calloc() memory.
|
||||
** Action: NULL is returned.
|
||||
** Realloc:
|
||||
** A request to re-allocate a memory buffer failed for reasons
|
||||
** other than out-of-memory. The specific reason is shown.
|
||||
** Detect: When you realloc()
|
||||
** Action: realloc() is cancelled, NULL is returned
|
||||
** Limit fail:
|
||||
** A request to allocate memory failed since it would violate
|
||||
** the limit set using mwLimit(). mwLimit() is used to stress-test
|
||||
** your code under simulated low memory conditions.
|
||||
** Detect: At new, malloc(), realloc() or calloc().
|
||||
** Action: NULL is returned.
|
||||
** Assert trap:
|
||||
** An ASSERT() failed. The ASSERT() macro works like C's assert()
|
||||
** macro/function, except that it's interactive. See your C manual.
|
||||
** Detect: On the ASSERT().
|
||||
** Action: Program ends with an advisory message to stderr, OR
|
||||
** Program writes the ASSERT to the log and continues, OR
|
||||
** Program asks Abort/Retry/Ignore? and takes that action.
|
||||
** Verify trap:
|
||||
** A VERIFY() failed. The VERIFY() macro works like ASSERT(),
|
||||
** but if MEMWATCH is not defined, it still evaluates the
|
||||
** expression, but it does not act upon the result.
|
||||
** Detect: On the VERIFY().
|
||||
** Action: Program ends with an advisory message to stderr, OR
|
||||
** Program writes the VERIFY to the log and continues, OR
|
||||
** Program asks Abort/Retry/Ignore? and takes that action.
|
||||
** Wild pointer:
|
||||
** A no-mans-land buffer has been written into. MEMWATCH can
|
||||
** allocate and distribute chunks of memory solely for the
|
||||
** purpose of trying to catch random writes into memory.
|
||||
** Detect: Always on CHECK(), but can be detected in several places.
|
||||
** Action: The error is logged, and if an ARI handler is installed,
|
||||
** it is executed, otherwise, execution continues.
|
||||
** Unfreed:
|
||||
** A memory buffer you allocated has not been freed.
|
||||
** You are informed where it was allocated, and whether any
|
||||
** over or underflow has occured. MemWatch also displays up to
|
||||
** 16 bytes of the data, as much as it can, in hex and text.
|
||||
** Detect: When MemWatch terminates.
|
||||
** Action: The buffer is freed.
|
||||
** Check:
|
||||
** An error was detected during a CHECK() operation.
|
||||
** The associated pointer is displayed along with
|
||||
** the file and line where the CHECK() was executed.
|
||||
** Followed immediately by a normal error message.
|
||||
** Detect: When you CHECK()
|
||||
** Action: Depends on the error
|
||||
** Relink:
|
||||
** After a MEMWATCH internal control block has been trashed,
|
||||
** MEMWATCH tries to repair the damage. If successful, program
|
||||
** execution will continue instead of aborting. Some information
|
||||
** about the block may be gone permanently, though.
|
||||
** Detect: N/A
|
||||
** Action: Relink successful: program continues.
|
||||
** Relink fails: program aborts.
|
||||
** Internal:
|
||||
** An internal error is flagged by MEMWATCH when it's control
|
||||
** structures have been damaged. You are likely using an uninitialized
|
||||
** pointer somewhere in your program, or are zapping memory all over.
|
||||
** The message may give you additional diagnostic information.
|
||||
** If possible, MEMWATCH will recover and continue execution.
|
||||
** Detect: Various actions.
|
||||
** Action: Whatever is needed
|
||||
** Mark:
|
||||
** The program terminated without umarking all marked pointers. Marking
|
||||
** can be used to track resources other than memory. mwMark(pointer,text,...)
|
||||
** when the resource is allocated, and mwUnmark(pointer) when it's freed.
|
||||
** The 'text' is displayed for still marked pointers when the program
|
||||
** ends.
|
||||
** Detect: When MemWatch terminates.
|
||||
** Action: The error is logged.
|
||||
**
|
||||
**
|
||||
************************************************************************
|
||||
**
|
||||
** The author may be reached by e-mail at the address below. If you
|
||||
** mail me about source code changes in MEMWATCH, remember to include
|
||||
** MW's version number.
|
||||
**
|
||||
** Johan Lindh
|
||||
** johan@linkdata.se
|
||||
**
|
||||
** The latest version of MEMWATCH may be downloaded from
|
||||
** http://www.linkdata.se/
|
||||
*/
|
||||
|
||||
#ifndef __MEMWATCH_H
|
||||
#define __MEMWATCH_H
|
||||
|
||||
/* Make sure that malloc(), realloc(), calloc() and free() are declared. */
|
||||
/*lint -save -e537 */
|
||||
#include <stdlib.h>
|
||||
/*lint -restore */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
** Constants used
|
||||
** All MEMWATCH constants start with the prefix MW_, followed by
|
||||
** a short mnemonic which indicates where the constant is used,
|
||||
** followed by a descriptive text about it.
|
||||
*/
|
||||
|
||||
#define MW_ARI_NULLREAD 0x10 /* Null read (to start debugger) */
|
||||
#define MW_ARI_ABORT 0x04 /* ARI handler says: abort program! */
|
||||
#define MW_ARI_RETRY 0x02 /* ARI handler says: retry action! */
|
||||
#define MW_ARI_IGNORE 0x01 /* ARI handler says: ignore error! */
|
||||
|
||||
#define MW_VAL_NEW 0xFE /* value in newly allocated memory */
|
||||
#define MW_VAL_DEL 0xFD /* value in newly deleted memory */
|
||||
#define MW_VAL_NML 0xFC /* value in no-mans-land */
|
||||
#define MW_VAL_GRB 0xFB /* value in grabbed memory */
|
||||
|
||||
#define MW_TEST_ALL 0xFFFF /* perform all tests */
|
||||
#define MW_TEST_CHAIN 0x0001 /* walk the heap chain */
|
||||
#define MW_TEST_ALLOC 0x0002 /* test allocations & NML guards */
|
||||
#define MW_TEST_NML 0x0004 /* test all-NML areas for modifications */
|
||||
|
||||
#define MW_NML_NONE 0 /* no NML */
|
||||
#define MW_NML_FREE 1 /* turn FREE'd memory into NML */
|
||||
#define MW_NML_ALL 2 /* all unused memory is NML */
|
||||
#define MW_NML_DEFAULT 0 /* the default NML setting */
|
||||
|
||||
#define MW_STAT_GLOBAL 0 /* only global statistics collected */
|
||||
#define MW_STAT_MODULE 1 /* collect statistics on a module basis */
|
||||
#define MW_STAT_LINE 2 /* collect statistics on a line basis */
|
||||
#define MW_STAT_DEFAULT 0 /* the default statistics setting */
|
||||
|
||||
/*
|
||||
** MemWatch internal constants
|
||||
** You may change these and recompile MemWatch to change the limits
|
||||
** of some parameters. Respect the recommended minimums!
|
||||
*/
|
||||
#define MW_TRACE_BUFFER 2048 /* (min 160) size of TRACE()'s output buffer */
|
||||
#define MW_FREE_LIST 64 /* (min 4) number of free()'s to track */
|
||||
|
||||
/*
|
||||
** Exported variables
|
||||
** In case you have to remove the 'const' keyword because your compiler
|
||||
** doesn't support it, be aware that changing the values may cause
|
||||
** unpredictable behaviour.
|
||||
** - mwCounter contains the current action count. You can use this to
|
||||
** place breakpoints using a debugger, if you want.
|
||||
*/
|
||||
#ifndef __MEMWATCH_C
|
||||
extern const unsigned long mwCounter;
|
||||
#endif
|
||||
|
||||
/*
|
||||
** System functions
|
||||
** Normally, it is not nessecary to call any of these. MEMWATCH will
|
||||
** automatically initialize itself on the first MEMWATCH function call,
|
||||
** and set up a call to mwAbort() using atexit(). Some C++ implementations
|
||||
** run the atexit() chain before the program has terminated, so you
|
||||
** may have to use mwInit() or the MemWatch C++ class to get good
|
||||
** behaviour.
|
||||
** - mwInit() can be called to disable the atexit() usage. If mwInit()
|
||||
** is called directly, you must call mwTerm() to end MemWatch, or
|
||||
** mwAbort().
|
||||
** - mwTerm() is usually not nessecary to call; but if called, it will
|
||||
** call mwAbort() if it finds that it is cancelling the 'topmost'
|
||||
** mwInit() call.
|
||||
** - mwAbort() cleans up after MEMWATCH, reports unfreed buffers, etc.
|
||||
*/
|
||||
void mwInit( void );
|
||||
void mwTerm( void );
|
||||
void mwAbort( void );
|
||||
|
||||
/*
|
||||
** Setup functions
|
||||
** These functions control the operation of MEMWATCH's protective features.
|
||||
** - mwFlushNow() causes MEMWATCH to flush it's buffers.
|
||||
** - mwDoFlush() controls whether MEMWATCH flushes the disk buffers after
|
||||
** writes. The default is smart flushing: MEMWATCH will not flush buffers
|
||||
** explicitly until memory errors are detected. Then, all writes are
|
||||
** flushed until program end or mwDoFlush(0) is called.
|
||||
** - mwLimit() sets the allocation limit, an arbitrary limit on how much
|
||||
** memory your program may allocate in bytes. Used to stress-test app.
|
||||
** Also, in virtual-memory or multitasking environs, puts a limit on
|
||||
** how much MW_NML_ALL can eat up.
|
||||
** - mwGrab() grabs up X kilobytes of memory. Allocates actual memory,
|
||||
** can be used to stress test app & OS both.
|
||||
** - mwDrop() drops X kilobytes of grabbed memory.
|
||||
** - mwNoMansLand() sets the behaviour of the NML logic. See the
|
||||
** MW_NML_xxx for more information. The default is MW_NML_DEFAULT.
|
||||
** - mwStatistics() sets the behaviour of the statistics collector. See
|
||||
** the MW_STAT_xxx defines for more information. Default MW_STAT_DEFAULT.
|
||||
** - mwFreeBufferInfo() enables or disables the tagging of free'd buffers
|
||||
** with freeing information. This information is written in text form,
|
||||
** using sprintf(), so it's pretty slow. Disabled by default.
|
||||
** - mwAutoCheck() performs a CHECK() operation whenever a MemWatch function
|
||||
** is used. Slows down performance, of course.
|
||||
** - mwCalcCheck() calculates checksums for all data buffers. Slow!
|
||||
** - mwDumpCheck() logs buffers where stored & calc'd checksums differ. Slow!!
|
||||
** - mwMark() sets a generic marker. Returns the pointer given.
|
||||
** - mwUnmark() removes a generic marker. If, at the end of execution, some
|
||||
** markers are still in existence, these will be reported as leakage.
|
||||
** returns the pointer given.
|
||||
*/
|
||||
void mwFlushNow( void );
|
||||
void mwDoFlush( int onoff );
|
||||
void mwLimit( long bytes );
|
||||
unsigned mwGrab( unsigned kilobytes );
|
||||
unsigned mwDrop( unsigned kilobytes );
|
||||
void mwNoMansLand( int mw_nml_level );
|
||||
void mwStatistics( int level );
|
||||
void mwFreeBufferInfo( int onoff );
|
||||
void mwAutoCheck( int onoff );
|
||||
void mwCalcCheck( void );
|
||||
void mwDumpCheck( void );
|
||||
void * mwMark( void *p, const char *description, const char *file, unsigned line );
|
||||
void * mwUnmark( void *p, const char *file, unsigned line );
|
||||
|
||||
/*
|
||||
** Testing/verification/tracing
|
||||
** All of these macros except VERIFY() evaluates to a null statement
|
||||
** if MEMWATCH is not defined during compilation.
|
||||
** - mwIsReadAddr() checks a memory area for read privilige.
|
||||
** - mwIsSafeAddr() checks a memory area for both read & write privilige.
|
||||
** This function and mwIsReadAddr() is highly system-specific and
|
||||
** may not be implemented. If this is the case, they will default
|
||||
** to returning nonzero for any non-NULL pointer.
|
||||
** - CHECK() does a complete memory integrity test. Slow!
|
||||
** - CHECK_THIS() checks only selected components.
|
||||
** - CHECK_BUFFER() checks the indicated buffer for errors.
|
||||
** - mwASSERT() or ASSERT() If the expression evaluates to nonzero, execution continues.
|
||||
** Otherwise, the ARI handler is called, if present. If not present,
|
||||
** the default ARI action is taken (set with mwSetAriAction()).
|
||||
** ASSERT() can be disabled by defining MW_NOASSERT.
|
||||
** - mwVERIFY() or VERIFY() works just like ASSERT(), but when compiling without
|
||||
** MEMWATCH the macro evaluates to the expression.
|
||||
** VERIFY() can be disabled by defining MW_NOVERIFY.
|
||||
** - mwTRACE() or TRACE() writes some text and data to the log. Use like printf().
|
||||
** TRACE() can be disabled by defining MW_NOTRACE.
|
||||
*/
|
||||
int mwIsReadAddr( const void *p, unsigned len );
|
||||
int mwIsSafeAddr( void *p, unsigned len );
|
||||
int mwTest( const char *file, int line, int mw_test_flags );
|
||||
int mwTestBuffer( const char *file, int line, void *p );
|
||||
int mwAssert( int, const char*, const char*, int );
|
||||
int mwVerify( int, const char*, const char*, int );
|
||||
|
||||
/*
|
||||
** User I/O functions
|
||||
** - mwTrace() works like printf(), but dumps output either to the
|
||||
** function specified with mwSetOutFunc(), or the log file.
|
||||
** - mwPuts() works like puts(), dumps output like mwTrace().
|
||||
** - mwSetOutFunc() allows you to give the adress of a function
|
||||
** where all user output will go. (exeption: see mwSetAriFunc)
|
||||
** Specifying NULL will direct output to the log file.
|
||||
** - mwSetAriFunc() gives MEMWATCH the adress of a function to call
|
||||
** when an 'Abort, Retry, Ignore' question is called for. The
|
||||
** actual error message is NOT printed when you've set this adress,
|
||||
** but instead it is passed as an argument. If you call with NULL
|
||||
** for an argument, the ARI handler is disabled again. When the
|
||||
** handler is disabled, MEMWATCH will automatically take the
|
||||
** action specified by mwSetAriAction().
|
||||
** - mwSetAriAction() sets the default ARI return value MEMWATCH should
|
||||
** use if no ARI handler is specified. Defaults to MW_ARI_ABORT.
|
||||
** - mwAriHandler() is an ANSI ARI handler you can use if you like. It
|
||||
** dumps output to stderr, and expects input from stdin.
|
||||
** - mwBreakOut() is called in certain cases when MEMWATCH feels it would
|
||||
** be nice to break into a debugger. If you feel like MEMWATCH, place
|
||||
** an execution breakpoint on this function.
|
||||
*/
|
||||
void mwTrace( const char* format_string, ... );
|
||||
void mwPuts( const char* text );
|
||||
void mwSetOutFunc( void (*func)(int) );
|
||||
void mwSetAriFunc( int (*func)(const char*) );
|
||||
void mwSetAriAction( int mw_ari_value );
|
||||
int mwAriHandler( const char* cause );
|
||||
void mwBreakOut( const char* cause );
|
||||
|
||||
/*
|
||||
** Allocation/deallocation functions
|
||||
** These functions are the ones actually to perform allocations
|
||||
** when running MEMWATCH, for both C and C++ calls.
|
||||
** - mwMalloc() debugging allocator
|
||||
** - mwMalloc_() always resolves to a clean call of malloc()
|
||||
** - mwRealloc() debugging re-allocator
|
||||
** - mwRealloc_() always resolves to a clean call of realloc()
|
||||
** - mwCalloc() debugging allocator, fills with zeros
|
||||
** - mwCalloc_() always resolves to a clean call of calloc()
|
||||
** - mwFree() debugging free. Can only free memory which has
|
||||
** been allocated by MEMWATCH.
|
||||
** - mwFree_() resolves to a) normal free() or b) debugging free.
|
||||
** Can free memory allocated by MEMWATCH and malloc() both.
|
||||
** Does not generate any runtime errors.
|
||||
*/
|
||||
void* mwMalloc( size_t, const char*, int );
|
||||
void* mwMalloc_( size_t );
|
||||
void* mwRealloc( void *, size_t, const char*, int );
|
||||
void* mwRealloc_( void *, size_t );
|
||||
void* mwCalloc( size_t, size_t, const char*, int );
|
||||
void* mwCalloc_( size_t, size_t );
|
||||
void mwFree( void*, const char*, int );
|
||||
void mwFree_( void* );
|
||||
char* mwStrdup( const char *, const char*, int );
|
||||
|
||||
/*
|
||||
** Enable/disable precompiler block
|
||||
** This block of defines and if(n)defs make sure that references
|
||||
** to MEMWATCH is completely removed from the code if the MEMWATCH
|
||||
** manifest constant is not defined.
|
||||
*/
|
||||
#ifndef __MEMWATCH_C
|
||||
#ifdef MEMWATCH
|
||||
|
||||
#define mwASSERT(exp) while(mwAssert((int)(exp),#exp,__FILE__,__LINE__))
|
||||
#ifndef MW_NOASSERT
|
||||
#ifndef ASSERT
|
||||
#define ASSERT mwASSERT
|
||||
#endif /* !ASSERT */
|
||||
#endif /* !MW_NOASSERT */
|
||||
#define mwVERIFY(exp) while(mwVerify((int)(exp),#exp,__FILE__,__LINE__))
|
||||
#ifndef MW_NOVERIFY
|
||||
#ifndef VERIFY
|
||||
#define VERIFY mwVERIFY
|
||||
#endif /* !VERIFY */
|
||||
#endif /* !MW_NOVERIFY */
|
||||
#define mwTRACE mwTrace
|
||||
#ifndef MW_NOTRACE
|
||||
#ifndef TRACE
|
||||
#define TRACE mwTRACE
|
||||
#endif /* !TRACE */
|
||||
#endif /* !MW_NOTRACE */
|
||||
|
||||
/* some compilers use a define and not a function */
|
||||
/* for strdup(). */
|
||||
#ifdef strdup
|
||||
#undef strdup
|
||||
#endif
|
||||
|
||||
#define malloc(n) mwMalloc(n,__FILE__,__LINE__)
|
||||
#define strdup(p) mwStrdup(p,__FILE__,__LINE__)
|
||||
#define realloc(p,n) mwRealloc(p,n,__FILE__,__LINE__)
|
||||
#define calloc(n,m) mwCalloc(n,m,__FILE__,__LINE__)
|
||||
#define free(p) mwFree(p,__FILE__,__LINE__)
|
||||
#define CHECK() mwTest(__FILE__,__LINE__,MW_TEST_ALL)
|
||||
#define CHECK_THIS(n) mwTest(__FILE__,__LINE__,n)
|
||||
#define CHECK_BUFFER(b) mwTestBuffer(__FILE__,__LINE__,b)
|
||||
#define MARK(p) mwMark(p,#p,__FILE__,__LINE__)
|
||||
#define UNMARK(p) mwUnmark(p,__FILE__,__LINE__)
|
||||
|
||||
#else /* MEMWATCH */
|
||||
|
||||
#define mwASSERT(exp)
|
||||
#ifndef MW_NOASSERT
|
||||
#ifndef ASSERT
|
||||
#define ASSERT mwASSERT
|
||||
#endif /* !ASSERT */
|
||||
#endif /* !MW_NOASSERT */
|
||||
|
||||
#define mwVERIFY(exp) exp
|
||||
#ifndef MW_NOVERIFY
|
||||
#ifndef VERIFY
|
||||
#define VERIFY mwVERIFY
|
||||
#endif /* !VERIFY */
|
||||
#endif /* !MW_NOVERIFY */
|
||||
|
||||
/*lint -esym(773,mwTRACE) */
|
||||
#define mwTRACE /*lint -save -e506 */ 1?(void)0:mwDummyTraceFunction /*lint -restore */
|
||||
#ifndef MW_NOTRACE
|
||||
#ifndef TRACE
|
||||
/*lint -esym(773,TRACE) */
|
||||
#define TRACE mwTRACE
|
||||
#endif /* !TRACE */
|
||||
#endif /* !MW_NOTRACE */
|
||||
|
||||
extern void mwDummyTraceFunction(const char *,...);
|
||||
/*lint -save -e652 */
|
||||
#define mwDoFlush(n)
|
||||
#define mwPuts(s)
|
||||
#define mwInit()
|
||||
#define mwGrab(n)
|
||||
#define mwDrop(n)
|
||||
#define mwLimit(n)
|
||||
#define mwTest(f,l)
|
||||
#define mwSetOutFunc(f)
|
||||
#define mwSetAriFunc(f)
|
||||
#define mwDefaultAri()
|
||||
#define mwNomansland()
|
||||
#define mwStatistics(f)
|
||||
#define mwMark(p,t,f,n) (p)
|
||||
#define mwUnmark(p,f,n) (p)
|
||||
#define mwMalloc(n,f,l) malloc(n)
|
||||
#define mwStrdup(p,f,l) strdup(p)
|
||||
#define mwRealloc(p,n,f,l) realloc(p,n)
|
||||
#define mwCalloc(n,m,f,l) calloc(n,m)
|
||||
#define mwFree(p) free(p)
|
||||
#define mwMalloc_(n) malloc(n)
|
||||
#define mwRealloc_(p,n) realloc(p,n)
|
||||
#define mwCalloc_(n,m) calloc(n,m)
|
||||
#define mwFree_(p) free(p)
|
||||
#define mwAssert(e,es,f,l)
|
||||
#define mwVerify(e,es,f,l) (e)
|
||||
#define mwTrace mwDummyTrace
|
||||
#define mwTestBuffer(f,l,b) (0)
|
||||
#define CHECK()
|
||||
#define CHECK_THIS(n)
|
||||
#define CHECK_BUFFER(b)
|
||||
#define MARK(p) (p)
|
||||
#define UNMARK(p) (p)
|
||||
/*lint -restore */
|
||||
|
||||
#endif /* MEMWATCH */
|
||||
#endif /* !__MEMWATCH_C */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0 /* 980317: disabled C++ */
|
||||
|
||||
/*
|
||||
** C++ support section
|
||||
** Implements the C++ support. Please note that in order to avoid
|
||||
** messing up library classes, C++ support is disabled by default.
|
||||
** You must NOT enable it until AFTER the inclusion of all header
|
||||
** files belonging to code that are not compiled with MEMWATCH, and
|
||||
** possibly for some that are! The reason for this is that a C++
|
||||
** class may implement it's own new() function, and the preprocessor
|
||||
** would substitute this crucial declaration for MEMWATCH new().
|
||||
** You can forcibly deny C++ support by defining MEMWATCH_NOCPP.
|
||||
** To enble C++ support, you must be compiling C++, MEMWATCH must
|
||||
** be defined, MEMWATCH_NOCPP must not be defined, and finally,
|
||||
** you must define 'new' to be 'mwNew', and 'delete' to be 'mwDelete'.
|
||||
** Unlike C, C++ code can begin executing *way* before main(), for
|
||||
** example if a global variable is created. For this reason, you can
|
||||
** declare a global variable of the class 'MemWatch'. If this is
|
||||
** is the first variable created, it will then check ALL C++ allocations
|
||||
** and deallocations. Unfortunately, this evaluation order is not
|
||||
** guaranteed by C++, though the compilers I've tried evaluates them
|
||||
** in the order encountered.
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
#ifndef __MEMWATCH_C
|
||||
#ifdef MEMWATCH
|
||||
#ifndef MEMWATCH_NOCPP
|
||||
extern int mwNCur;
|
||||
extern const char *mwNFile;
|
||||
extern int mwNLine;
|
||||
class MemWatch {
|
||||
public:
|
||||
MemWatch();
|
||||
~MemWatch();
|
||||
};
|
||||
void * operator new(size_t);
|
||||
void * operator new(size_t,const char *,int);
|
||||
void * operator new[] (size_t,const char *,int); // hjc 07/16/02
|
||||
void operator delete(void *);
|
||||
#define mwNew new(__FILE__,__LINE__)
|
||||
#define mwDelete (mwNCur=1,mwNFile=__FILE__,mwNLine=__LINE__),delete
|
||||
#endif /* MEMWATCH_NOCPP */
|
||||
#endif /* MEMWATCH */
|
||||
#endif /* !__MEMWATCH_C */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* 980317: disabled C++ */
|
||||
|
||||
#endif /* __MEMWATCH_H */
|
||||
|
||||
/* EOF MEMWATCH.H */
|
||||
643
plat/public_bak/src/include/omc_public.h
Normal file
643
plat/public_bak/src/include/omc_public.h
Normal file
@@ -0,0 +1,643 @@
|
||||
|
||||
/************************************************************************/
|
||||
/* Title: omc_public.h */
|
||||
/* Desc: Public variables def for PACS OMC Project. */
|
||||
/* Author: Meng Xiaozhen */
|
||||
/* CrtDate: 2000-08-16 */
|
||||
/* AltDate: 2001-06-21 */
|
||||
/* CVS: $Id: omc_public.h,v 1.1 2000/08/03 01:09:33 mengxz Exp $ */
|
||||
/************************************************************************/
|
||||
#ifndef OMC_PUBLIC__H
|
||||
#define OMC_PUBLIC__H
|
||||
|
||||
#ifndef PUBLIC__H
|
||||
#include "public.h"
|
||||
#endif
|
||||
|
||||
#ifndef IPTRANS__H
|
||||
#include "iptrans.h"
|
||||
#endif
|
||||
|
||||
#define DEBUG 1
|
||||
|
||||
/***************************************************/
|
||||
/* Macro define for Server's system number */
|
||||
#define GRP_NUM 32
|
||||
|
||||
#define TS_NUM 32
|
||||
#define TS_SUB 16
|
||||
#define TS_E1 8
|
||||
|
||||
#define PW_NUM 32
|
||||
#define PW_SUB 3
|
||||
|
||||
#define ETH_NUM 32
|
||||
#define ETH_SUB 16
|
||||
|
||||
#define RDEV_NUM 32
|
||||
#define RDEV_SUB 8
|
||||
#define RDEV_E1 1
|
||||
|
||||
#define BSS_NUM 48
|
||||
|
||||
#define BSC_NUM 12
|
||||
#define BSC_SUB 9
|
||||
#define BSC_E1 2
|
||||
|
||||
#define BTS_NUM 24 //BTS system include 12 BTS subsystem
|
||||
#define BTSSITE_NUM 48 //BTS site include 6 BTS subsystem
|
||||
#define BTS_SUB 12
|
||||
#define BTS_E1 2
|
||||
|
||||
#define SVR_NUM 36
|
||||
|
||||
#define CONN_NUM 128
|
||||
#define CLIENT_NUM 50
|
||||
#define BTN_NUM 66
|
||||
|
||||
#define ALARM_NUM 20
|
||||
#define CACHE_BUF 512
|
||||
/***************************************************/
|
||||
|
||||
/***************************************************/
|
||||
/* Macro definition of start ID for applet's button used by system device */
|
||||
#define TS_START_BTN 0
|
||||
#define RDEV_START_BTN 18
|
||||
#define SVR_START_BTN 34
|
||||
#define BSC_START_BTN 54
|
||||
/***************************************************/
|
||||
|
||||
|
||||
/***************************************************/
|
||||
/* Macro define for Server's IP Address */
|
||||
#define OMC_0 "172.18.128.1"
|
||||
#define OMC_1 "172.18.129.1"
|
||||
#define HLR_0 "172.18.132.1"
|
||||
#define HLR_1 "172.18.133.1"
|
||||
#define PPS_0 "172.18.136.1"
|
||||
#define PPS_1 "172.18.137.1"
|
||||
#define CDR_0 "172.18.160.1"
|
||||
#define CDR_1 "172.18.161.1"
|
||||
/***************************************************/
|
||||
|
||||
/***************************************************/
|
||||
/* Macro define for Mysql Database */
|
||||
#define HOST_NAME "localhost"
|
||||
#define DB_NAME1 "mysql"
|
||||
#define DB_PORT_NUM 0
|
||||
#define SOCKET_NAME NULL
|
||||
#define FLAGS 0
|
||||
#define USER_NAME "root"
|
||||
#define PASSWORD "rootaa"
|
||||
/***************************************************/
|
||||
|
||||
/***************************************************/
|
||||
/* Macro def for (UDP)Communication port used by OMC */
|
||||
#define PORT_OUT 4951 //for sending message to ts
|
||||
#define PORT_BASE 4951
|
||||
#define PORT_REALSTAT 3 /* 4951 + 3 = 4954 */
|
||||
#define PORT_CSTA 4 /* 4951 + 4 = 4955 */
|
||||
#define PORT_COMM 5 /* 4951 + 5 = 4956 */
|
||||
#define PORT_HEARTBEAT 6 /* 4951 + 6 = 4957 */
|
||||
#define PORT_CLUSTER 27 /* 4951 + 27 =4978 */
|
||||
#define BROADCAST_IP "172.18.255.255"
|
||||
#define CLUSTER_IP "239.255.10.1"
|
||||
#define BROADCAST 0 //if broadcast message
|
||||
|
||||
/***************************************************/
|
||||
/* Macro def for shm key and sem key used by OMC */
|
||||
#define COMM_FLAG_SHM_KEY 0x6a000000
|
||||
#define COMM_FLAG_SHM_PERM 0666
|
||||
#define COMM_FLAG_SEM_KEY 300
|
||||
#define COMM_FLAG_SEM_PERM 0666
|
||||
#define COMM_FLAG_SEM_NUM 1
|
||||
#define COMM_FLAG_SIZE 1024
|
||||
|
||||
#define COMM_LIST_SHM_KEY 0x6a100000
|
||||
#define COMM_LIST_SHM_PERM 0666
|
||||
#define COMM_LIST_SEM_KEY 310
|
||||
#define COMM_LIST_SEM_PERM 0666
|
||||
#define COMM_LIST_SEM_NUM 1
|
||||
|
||||
#define STATUS_SHM_KEY 0x6a200000
|
||||
#define STATUS_SHM_PERM 0666
|
||||
#define STATUS_SEM_KEY 320
|
||||
#define STATUS_SEM_PERM 0666
|
||||
#define STATUS_SEM_NUM 1
|
||||
|
||||
#define CACHE_SHM_KEY 0x6a400000
|
||||
#define CACHE_SHM_PERM 0666
|
||||
#define CACHE_SEM_KEY 340
|
||||
#define CACHE_SEM_PERM 0666
|
||||
#define CACHE_SEM_NUM 1
|
||||
|
||||
#define BSS_SHM_KEY 0x6a600000
|
||||
#define BSS_SHM_PERM 0666
|
||||
#define BSS_SEM_KEY 360
|
||||
#define BSS_SEM_PERM 0666
|
||||
#define BSS_SEM_NUM 1
|
||||
|
||||
#define LED_SHM_KEY 0x6a800000
|
||||
#define LED_SHM_PERM 0666
|
||||
#define LED_SEM_KEY 380
|
||||
#define LED_SEM_PERM 0666
|
||||
#define LED_SEM_NUM 1
|
||||
|
||||
#define CLUSTER_SHM_KEY 0x6a900000
|
||||
#define CLUSTER_SHM_PERM 0666
|
||||
#define CLUSTER_SEM_KEY 390
|
||||
#define CLUSTER_SEM_PERM 0666
|
||||
#define CLUSTER_SEM_NUM 1
|
||||
/***************************************************/
|
||||
|
||||
/*############################################################################
|
||||
* shm structure
|
||||
* between heartbeat transceiver and heartbeat processor
|
||||
* &
|
||||
* between heartbeat transceiver and svr cluster processor
|
||||
*###########################################################################*/
|
||||
typedef struct cache_list{
|
||||
long msgSrcIP;
|
||||
u_short msgLength;
|
||||
BYTE msgContent[CACHE_BUF];
|
||||
}cache_list;
|
||||
|
||||
typedef struct status_cahce{
|
||||
//int send_flag;
|
||||
/*this flag is only for server cluster funciton
|
||||
*0/1/2=ignore cluster FSM influence,directly send heartbeat/cluster permit *to send heartbeat/can't send heartbeat,waiting cluster's info
|
||||
*/
|
||||
u_short msgReadSub;
|
||||
u_short msgWriteSub;
|
||||
cache_list msgcache[CACHE_BUF];
|
||||
}status_cache;
|
||||
|
||||
/*############################################################################
|
||||
* shm structure between real status processor and heartbeat processor
|
||||
*###########################################################################*/
|
||||
|
||||
typedef struct clientinfo {
|
||||
BYTE used_flag; // 0/1=not used/used
|
||||
BYTE grp_id; // group which is requested by client now
|
||||
BYTE is_responsed; // 0/1/2=not response/responsing/responsed
|
||||
long ip;
|
||||
unsigned int waittime; //if waittime>60seconds,timeout
|
||||
BYTE updatetime[16]; //last time when client request info
|
||||
} client_info;
|
||||
|
||||
typedef struct conninfo {
|
||||
BYTE avail_flag; // 0/1=unavailable/available
|
||||
BYTE disp_name; // 0/1=not display/display
|
||||
char name[16];
|
||||
char remark[44];
|
||||
BYTE lsys_type;// local device system type
|
||||
BYTE lsys_id; //local device system id
|
||||
BYTE lsub_id; //local device subsystem id
|
||||
BYTE rsys_type; //remote device system type
|
||||
BYTE rsys_id; //remote device system id
|
||||
BYTE rsub_id; //remote device subsystem id
|
||||
} conn_info;
|
||||
|
||||
typedef struct btninfo {
|
||||
BYTE used_flag; // 0/1=not use/used
|
||||
BYTE sys_type; // device system type
|
||||
BYTE sys_id; // device system id
|
||||
BYTE sub_id; // device subsystem id
|
||||
} btn_info;
|
||||
|
||||
typedef struct grp_simple_stat {
|
||||
btn_info btn[BTN_NUM]; // relationship between button and device
|
||||
unsigned int coord[2]; // X,Y coord for group icon
|
||||
int critical; // critical counter
|
||||
int alarm; // alarm counter
|
||||
BYTE isinstalled; // 0/1=not install/install
|
||||
BYTE ts_id[2]; // Transit switch id(default=99,no ts)
|
||||
BYTE disp_name; // 0/1=not display/display
|
||||
BYTE grp_name[17]; // Group name
|
||||
BYTE grp_remark[45]; // remark about group
|
||||
BYTE stat_amount; // number of status for group icon
|
||||
BYTE stat_direct; // direction of display status (0/1=h/v)
|
||||
BYTE ischanged;
|
||||
/* 0/1=N/Y,process will send message to client if status is changed
|
||||
*/
|
||||
BYTE status;
|
||||
/*0=critical ; 1=normal ; 2=alarm ; 3= uninstalled
|
||||
*/
|
||||
}grpsimple_stat;
|
||||
|
||||
typedef struct subts_detail_stat {
|
||||
BYTE subtype; //subsystem status
|
||||
BYTE timeout; //if the subsystem is timeout(0/1=timeout/not)
|
||||
BYTE substat0[8];// simple status of this subsystem
|
||||
/* substat0[0] -- if subsys is installed(0/1=not/yes)
|
||||
* substat0[1] -- if subsys is normal(0/1=abnormal/normal)
|
||||
* substat0[2] -- if subsys send master clock(0/1=not/sending)
|
||||
* substat0[3] -- locking clock(0-7:2=normal,7=idle,other=abnormal)
|
||||
*/
|
||||
BYTE substat1[8]; // performance or status data of subsystem
|
||||
/* substat1[0-1] -- CPU Load ('00'-'45')
|
||||
* substat1[2-4] -- Clock frequency('000'-'255')
|
||||
*/
|
||||
|
||||
BYTE e1stat0[TS_E1][8]; //simple status of all E1
|
||||
/* e1[i][0] -- e1[i] installed/not installed (0/1=not/yes)
|
||||
* e1[i][1] -- e1[i] layer 2 installed/not installed (0/1=not/yes)
|
||||
* e1[i][2] -- e1[i] layer 1 connected/disconnected (0/1=not/yes)
|
||||
* e1[i][3] -- e1[i] layer 2 connected/disconnected (0/1=not/yes)
|
||||
* e1[i][4] -- e1[i] without/with ECHO CANCELLER (0/1=not/yes)
|
||||
*/
|
||||
BYTE e1stat1[TS_E1][8]; // performance or status data of all E1
|
||||
/* e1[i][0-1] -- e1[i] idle channels('00'/'30')
|
||||
*/
|
||||
|
||||
long lock_alarmtime;
|
||||
/*last time inserting alarm log into db because of clock locking error
|
||||
*/
|
||||
long e1_alarmtime[TS_E1][2];
|
||||
/*last time inserting alarm log into db because of e1 1,2th error
|
||||
*/
|
||||
BYTE version_info[16];
|
||||
/*version information for the application
|
||||
*/
|
||||
BYTE updatetime[16]; //last time refreshing subsystem status
|
||||
}subtsdetail_stat;
|
||||
|
||||
typedef struct subpw_detail_stat {
|
||||
BYTE timeout; //if the subsystem is timeout(0/1=timeout/not)
|
||||
BYTE substat[2]; // status of this subsystem(0/1=abnomal/normal)
|
||||
/* substat[0] -- if subsys is installed(0/1=not/yes)
|
||||
* substat[1] -- if subsys is normal(0/1=abnormal/normal)
|
||||
*/
|
||||
|
||||
long pcard_alarmtime;
|
||||
/*last time inserting alarm log into db because of power card error
|
||||
*/
|
||||
BYTE updatetime[16]; //last time refreshing subsystem status
|
||||
}subpwdetail_stat;
|
||||
|
||||
typedef struct ts_detail_stat {
|
||||
BYTE grp_id;
|
||||
BYTE clock_status;//if master clock is normal(0/1=N/Y)
|
||||
long clock_alarmtime;//master clock status
|
||||
/*last time inserting alarm log into db because of master clock error
|
||||
*/
|
||||
subtsdetail_stat sub_detail[TS_SUB];
|
||||
subpwdetail_stat subpw_detail[PW_SUB];
|
||||
}tsdetail_stat;
|
||||
|
||||
typedef struct subts_simple_stat {
|
||||
BYTE isinstalled;
|
||||
BYTE ischanged;
|
||||
/* 0/1=N/Y,process will send message to client if status is changed
|
||||
*/
|
||||
BYTE status;
|
||||
/*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled
|
||||
*/
|
||||
int critical; // critical counter
|
||||
int alarm; // alarm counter
|
||||
int waittime; // if TS subsystem is timeout
|
||||
BYTE issent ; // if sending get request to timeout ts subsystem
|
||||
} subtssimple_stat;
|
||||
|
||||
|
||||
typedef struct ts_simple_stat {
|
||||
BYTE isinstalled; // 0/1=N/Y
|
||||
BYTE location; // 0/1=local/remote
|
||||
BYTE ischanged;
|
||||
/* 0/1=N/Y,process will send message to client if status is changed
|
||||
*/
|
||||
BYTE status;
|
||||
/*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled
|
||||
*/
|
||||
int critical; // critical counter
|
||||
int alarm; // alarm counter
|
||||
BYTE grp_id;
|
||||
BYTE disp_name; // 0/1=not display/display
|
||||
BYTE name[16];
|
||||
BYTE remark[44];
|
||||
int coord[2];
|
||||
BYTE stat_amount; // number of status for ts icon
|
||||
BYTE stat_direct; // direction of display status (0/1=h/v)
|
||||
subtssimple_stat sub_simple[TS_SUB];
|
||||
subtssimple_stat subpw_simple[PW_SUB];
|
||||
} tssimple_stat;
|
||||
|
||||
typedef struct subeth_detail_stat {
|
||||
BYTE timeout; //if the subsystem is timeout(0/1=timeout/not)
|
||||
long self_ip; //ip address of LAN Module self
|
||||
BYTE mac[6]; //physical address of LAN Module
|
||||
|
||||
BYTE substat[6];
|
||||
/* substat[0] -- if LAN Module is installed(0/1)
|
||||
* substat[1] -- if LAN Module is normal(0/1)
|
||||
* substat[2] -- if there is unreachable ip(0/1)
|
||||
* substat[3] -- if LAN Module upload program to csu(0/1)
|
||||
* substat[4] -- if csu is availabe (0/1)
|
||||
*/
|
||||
|
||||
BYTE cpu_load[2]; //CPU load of LAN module(hex value)
|
||||
BYTE unreachable_ip[4]; //ip Can't be found by LAN Module (hex value)
|
||||
long unreach_time;
|
||||
|
||||
long alarmtime[2];
|
||||
/*CSU Upload program status
|
||||
*alarmtime[0] -- can't reach target ip address
|
||||
*alarmtime[1] -- uploading program
|
||||
*/
|
||||
BYTE version_info[16];
|
||||
/*version information for the application
|
||||
*/
|
||||
char updatetime[16];
|
||||
}subethdetail_stat;
|
||||
|
||||
typedef struct eth_detail_stat {
|
||||
BYTE grp_id;
|
||||
subethdetail_stat sub_detail[ETH_SUB];
|
||||
}ethdetail_stat;
|
||||
|
||||
typedef struct subeth_simple_stat {
|
||||
BYTE isinstalled;
|
||||
BYTE ischanged;
|
||||
/* 0/1=N/Y,process will send message to client if status is changed
|
||||
*/
|
||||
BYTE status;
|
||||
/*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled
|
||||
*/
|
||||
int critical; // critical counter
|
||||
int alarm; // alarm counter
|
||||
int waittime; // if TS subsystem is timeout
|
||||
BYTE issent ; // if sending get request to timeout ts subsystem
|
||||
} subethsimple_stat;
|
||||
|
||||
typedef struct eth_simple_stat {
|
||||
BYTE isinstalled; // 0/1=N/Y
|
||||
BYTE ischanged;
|
||||
/* 0/1=N/Y,process will send message to client if status is changed
|
||||
*/
|
||||
BYTE status;
|
||||
/*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled
|
||||
*/
|
||||
int critical; // critical counter
|
||||
int alarm; // alarm counter
|
||||
BYTE grp_id;
|
||||
subethsimple_stat sub_simple[ETH_SUB];
|
||||
} ethsimple_stat;
|
||||
|
||||
typedef struct subrdev_detail_stat {
|
||||
BYTE subtype; //0-4
|
||||
|
||||
BYTE timeout; //if the subsystem is timeout(0/1=timeout/not)
|
||||
BYTE substat0[6];
|
||||
/* substat[0] -- if subsys is installed(0/1=N/Y)
|
||||
* substat[1] -- if subsys is normal(0/1=N/Y)
|
||||
* sysstat[2] -- if send master clock(0/1=N/Y)
|
||||
*/
|
||||
BYTE substat1[6];
|
||||
/* substat[0-1] -- used CPU(00/30)
|
||||
*/
|
||||
|
||||
BYTE e1stat0[RDEV_E1][8];
|
||||
/* e1[0] -- e1 installed/not installed (0/1=N/Y)
|
||||
* e1[1] -- e1 layer 1 connected/disconnected (0/1=N/Y)
|
||||
* e1[2] -- e1 layer 2 connected/disconnected (0/1=N/Y)
|
||||
*/
|
||||
BYTE e1stat1[RDEV_E1][8];
|
||||
/* e1[i][0-1] -- e1 idle channels('00'--'30')
|
||||
*/
|
||||
|
||||
long e1_alarmtime[RDEV_E1][2];
|
||||
/* alarmtime[i][0] -- e1[i] layer 1
|
||||
* alarmtime[i][1] -- e1[i] layer 2
|
||||
*/
|
||||
BYTE version_info[16];
|
||||
/*version information for the application
|
||||
*/
|
||||
char updatetime[16];
|
||||
}subrdevdetail_stat;
|
||||
|
||||
typedef struct rdev_detail_stat {
|
||||
BYTE grp_id;
|
||||
BYTE systype; //05=VPS;06=PCR
|
||||
BYTE clock_status;//if master clock is normal(0/1=N/Y)
|
||||
long clock_alarmtime;//master clock status
|
||||
/*last time inserting alarm log into db because of master clock error
|
||||
*/
|
||||
subrdevdetail_stat sub_detail[RDEV_SUB];
|
||||
}rdevdetail_stat;
|
||||
|
||||
typedef struct subrdev_simple_stat {
|
||||
BYTE isinstalled;
|
||||
BYTE ischanged;
|
||||
/* 0/1=N/Y,process will send message to client if status is changed
|
||||
*/
|
||||
BYTE status;
|
||||
/*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled
|
||||
*/
|
||||
int critical; // critical counter
|
||||
int alarm; // alarm counter
|
||||
int waittime; // if Rdev subsystem is timeout
|
||||
BYTE issent ; // if sending get request to timeout ts subsystem
|
||||
} subrdevsimple_stat;
|
||||
|
||||
typedef struct rdev_simple_stat {
|
||||
BYTE isinstalled; // 0/1=N/Y
|
||||
BYTE location; // 0/1=local/remote
|
||||
BYTE ischanged;
|
||||
/* 0/1=N/Y,process will send message to client if status is changed
|
||||
*/
|
||||
BYTE status;
|
||||
/*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled
|
||||
*/
|
||||
int critical; // critical counter
|
||||
int alarm; // alarm counter
|
||||
BYTE grp_id;
|
||||
BYTE disp_name; // 0/1=not display/display
|
||||
BYTE name[16];
|
||||
BYTE remark[44];
|
||||
int coord[2];
|
||||
BYTE stat_amount; // number of status for rdev icon
|
||||
BYTE stat_direct; // direction of display status (0/1=h/v)
|
||||
subrdevsimple_stat sub_simple[RDEV_SUB];
|
||||
} rdevsimple_stat;
|
||||
|
||||
typedef struct bts_simple_stat {
|
||||
BYTE isinstalled; // 0/1=not/installed
|
||||
BYTE bts_site_id;
|
||||
BYTE bts_link_id;
|
||||
BYTE location; // 0/1=local/remote
|
||||
BYTE ischanged;
|
||||
/* 0/1=N/Y,process will send message to client if status is changed
|
||||
*/
|
||||
BYTE status;
|
||||
/*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled
|
||||
*/
|
||||
int critical; // critical counter
|
||||
int alarm; // alarm counter
|
||||
BYTE grp_id;
|
||||
BYTE disp_name; // 0/1=not display/display
|
||||
BYTE name[16];
|
||||
BYTE remark[44];
|
||||
int coord[2];
|
||||
BYTE stat_amount; // number of status for bts site icon
|
||||
BYTE stat_direct; // direction of display status (0/1=h/v)
|
||||
} btssimple_stat;
|
||||
|
||||
typedef struct bsc_simple_stat {
|
||||
BYTE isinstalled; // 0/1=not/installed
|
||||
BYTE location; // 0/1=local/remote
|
||||
BYTE timeout; // 0/1=timeout/not timeout
|
||||
BYTE ischanged;
|
||||
/* 0/1=N/Y,process will send message to client if status is changed
|
||||
*/
|
||||
BYTE status;
|
||||
/*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled
|
||||
*/
|
||||
int critical; // critical counter
|
||||
int alarm; // alarm counter
|
||||
BYTE grp_id;
|
||||
BYTE disp_name; // 0/1=not display/display
|
||||
BYTE name[16];
|
||||
BYTE remark[44];
|
||||
int coord[2];
|
||||
BYTE stat_amount; // number of status for bsc icon
|
||||
BYTE stat_direct; // direction of display status (0/1=h/v)
|
||||
} bscsimple_stat;
|
||||
|
||||
|
||||
/* structure for server detail status in heartbeat processor
|
||||
************************************/
|
||||
typedef struct svr_detail_stat {
|
||||
BYTE timeout; //if the subsystem is timeout(0/1=not/timeout)
|
||||
BYTE grp_id;
|
||||
BYTE systype;
|
||||
BYTE sys_id;
|
||||
int cpuused;
|
||||
int viravail;
|
||||
int virfree;
|
||||
int memavail;
|
||||
int memfree;
|
||||
int hdavail;
|
||||
int hdfree;
|
||||
BYTE init_progress[3];
|
||||
BYTE proc_id[16];
|
||||
BYTE proc_status[16];
|
||||
BYTE subproc_num[16];
|
||||
BYTE sysstat[16]; // 0/1=abnormal/normal
|
||||
/*
|
||||
* 0=Normal,1=abnormal
|
||||
*sysstat[0]: system status
|
||||
* sysstat[1]:cpu status sysstat[2]:swap status
|
||||
* sysstat[3]:memory status sysstat[4]:disk status
|
||||
* sysstat[5]:proc_status sysstat[6]:server working status
|
||||
* sysstat[7]:database status
|
||||
*/
|
||||
long alarmtime[6];
|
||||
|
||||
BYTE version_info[16];
|
||||
/*version information for the application
|
||||
*/
|
||||
BYTE updatetime[16];
|
||||
} svrdetail_stat;
|
||||
|
||||
typedef struct svr_simple_stat {
|
||||
BYTE grp_id;
|
||||
BYTE location;
|
||||
BYTE isinstalled;
|
||||
int waittime;
|
||||
BYTE ischanged;
|
||||
/* 0/1=N/Y,process will send message to client if status is changed
|
||||
*/
|
||||
BYTE status;
|
||||
/*0=critical ; 1=normal ; 2=alarm ; 3=uninstalled
|
||||
*/
|
||||
int critical; // critical counter
|
||||
int alarm; // alarm counter
|
||||
BYTE disp_name; // 0/1=not display/display
|
||||
BYTE name[16];
|
||||
BYTE remark[44];
|
||||
int coord[2];
|
||||
BYTE stat_amount; // number of status for bts site icon
|
||||
BYTE stat_direct; // direction of display status (0/1=h/v)
|
||||
} svrsimple_stat;
|
||||
|
||||
struct alarm_log {
|
||||
BYTE systype;
|
||||
BYTE sys_id;
|
||||
BYTE sub_id;
|
||||
BYTE e1no;
|
||||
BYTE alarmnum;
|
||||
BYTE occurtime[16];
|
||||
};
|
||||
|
||||
typedef struct ts_alarm_log {
|
||||
int readSub;
|
||||
int writeSub;
|
||||
struct alarm_log alrlist[ALARM_NUM];
|
||||
} tsalarm_log;
|
||||
|
||||
typedef struct ask_alarm_log {
|
||||
long client_ip; //ip address where the request is sent from
|
||||
int init_Req_Flag;
|
||||
int readSub;
|
||||
int writeSub;
|
||||
struct alarm_log alrlist[ALARM_NUM];
|
||||
} askalarm_log;
|
||||
|
||||
/*
|
||||
* shared memory structure
|
||||
*************************/
|
||||
typedef struct shm_ts_stat {
|
||||
BYTE init_flag;
|
||||
BYTE sys_struct;//0/1=single/double plane system structure
|
||||
grpsimple_stat grp_simple[GRP_NUM];
|
||||
tsdetail_stat ts_detail[TS_NUM];
|
||||
tssimple_stat ts_simple[TS_NUM];
|
||||
ethdetail_stat eth_detail[ETH_NUM];
|
||||
ethsimple_stat eth_simple[ETH_NUM];
|
||||
rdevdetail_stat vps_detail[RDEV_NUM];
|
||||
rdevsimple_stat vps_simple[RDEV_NUM];
|
||||
rdevdetail_stat pcr_detail[RDEV_NUM];
|
||||
rdevsimple_stat pcr_simple[RDEV_NUM];
|
||||
svrdetail_stat svr_detail[SVR_NUM];
|
||||
svrsimple_stat svr_simple[SVR_NUM];
|
||||
/*
|
||||
sysnum=systype*2+sys_id
|
||||
svr_simple[0]=OMC-0
|
||||
svr_simple[1]=OMC-1
|
||||
svr_simple[2]=HLR-0
|
||||
svr_simple[3]=HLR-1
|
||||
svr_simple[4]=PRP-0
|
||||
svr_simple[5]=PRP-1
|
||||
svr_simple[6]=CDR-0
|
||||
svr_simple[7]=CDR-1
|
||||
*/
|
||||
bscsimple_stat bsc_simple[BSC_NUM];
|
||||
|
||||
BYTE global_status[ETH_NUM];
|
||||
conn_info connection[CONN_NUM];
|
||||
client_info client[CLIENT_NUM];
|
||||
/*global_status[0]= if normal ;global_status[1]= if changed*/
|
||||
tsalarm_log alarmlog;
|
||||
} shm_stat;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Lan Module's global status*/
|
||||
typedef struct global_status{
|
||||
BYTE eth_mac[ETH_NUM][ETH_SUB][7];
|
||||
long update_time[ETH_NUM][ETH_SUB];
|
||||
long alarm_time[ETH_NUM][ETH_SUB];
|
||||
}eth_global;
|
||||
/***************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* structure for BSS simple status in heartbeat processor
|
||||
************************************/
|
||||
typedef struct bss_simple_stat {
|
||||
BYTE isinstalled[BSS_NUM];
|
||||
BYTE ischanged[BSS_NUM];
|
||||
BYTE isnormal[BSS_NUM];
|
||||
unsigned int waittime[BSS_NUM];
|
||||
} bsssimple_stat;
|
||||
/***************************************************/
|
||||
|
||||
#endif /*OMC_PUBLIC__H */
|
||||
127
plat/public_bak/src/include/pub_base.h
Normal file
127
plat/public_bak/src/include/pub_base.h
Normal file
@@ -0,0 +1,127 @@
|
||||
//////////////////////////////////////////////////
|
||||
//Title : pub_basic.c
|
||||
//Auhtor : Liu Wei
|
||||
//Desc : public basic function
|
||||
//Created : 2007-06-23
|
||||
//Revision :
|
||||
//
|
||||
//Revision :
|
||||
//
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
#ifndef _PUB_BASE_H_
|
||||
#define _PUB_BASE_H_
|
||||
|
||||
typedef struct VALUE_STRING
|
||||
{
|
||||
u32 dValue;
|
||||
u8 *pStr;
|
||||
} StringVal;
|
||||
|
||||
#define ALPHA_TABLE_LOWER "abcdefghijklmnopqrstuvwsyz"
|
||||
#define ALPHA_TABLE_UPPER "ABCDEFGHIJKLMNOPQRSTUVWSYZ"
|
||||
|
||||
#define NOTSO(n) ( !(n) )
|
||||
#define IsNull(n) ( ((n) == NULL) )
|
||||
#define CNULL '\0'
|
||||
#define IsChNull(ch) ( ch==CNULL )
|
||||
#define STR_CHECK_LAST(str,ch) ( str[strlen(str)-1] == ch )
|
||||
#define STR_CHECK_FIRST(str,ch) ( str[0] == ch )
|
||||
#define STR_CUT_LAST(str) ( str[strlen(str)-1] = CNULL )
|
||||
|
||||
|
||||
#define BitSet(arg,posn) ((arg) | (1L << (posn)))
|
||||
#define BitClr(arg,posn) ((arg) & ~(1L << (posn)))
|
||||
#define BitFlp(arg,posn) ((arg) ^ (1L << (posn)))
|
||||
#define BitTst(arg,posn) (!(!((arg) & (1L << (posn)))))
|
||||
|
||||
|
||||
#define HexToChar(ch) ( (ch) + ( ((ch) > 9)? 'A'-10 : '0') )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) ( (a) > (b) ? (a) : (b) )
|
||||
#define MIN(a, b) ( (a) < (b) ? (a) : (b) )
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name : GET_U8 GET_U16 GET_U32
|
||||
// Function : Return the u8 /u16 / u32 value of the pointer memery
|
||||
// Parameter: x : pointer
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
#define GET_U8( x ) ( *( (u8 *) (x) ) )
|
||||
#define GET_U16( x ) ( *( (u16 *) (x) ) )
|
||||
#define GET_U32( x ) ( *( (u32 *) (x) ) )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
#define U16_LOW_BYTE ( x ) ( (u8 )( ((u16) (x) ) & 0xFF ) )
|
||||
#define U16_HIG_BYTE ( x ) ( (u8 )( ((u16) (x) ) >> 8 ) )
|
||||
|
||||
#define LSB_BYTE2WORD( uVal ) ( (((u16) (uVal)[0]) * 256) + (uVal)[1] )
|
||||
#define MSB_BYTE2WORD( uVal ) ( (((u16) (uVal)[1]) * 256) + (uVal)[0] )
|
||||
|
||||
#define LSB_WORD2BYTE( wVal , uVal ) \
|
||||
(uVal)[0] = ((wVal) / 256); \
|
||||
(uVal)[1] = ((wVal) & 0xFF )
|
||||
|
||||
#define MSB_WORD2BYTE( wVal , uVal ) \
|
||||
(uVal)[1] = ((wVal) / 256 ); \
|
||||
(uVal)[0] = ((wVal) & 0xFF)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name : ARR_SIZE
|
||||
// Function : Return array size of a
|
||||
// Parameter: a : array
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
#define ARR_SIZE( a ) ( sizeof( (a) ) / sizeof( (a[0]) ) )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Name : STR
|
||||
// Function : Convert the s to string
|
||||
// Parameter: a : a value you want to Convert to string but no need ""
|
||||
// e.g. : printf(STR(if(NOTSO(a)) return 0));
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
#define STR(s) #s
|
||||
#define FILL_VALSTR(n) {n,#n}
|
||||
#define GET_FILE_NAME(fn) \
|
||||
{ \
|
||||
static char fn[] = STR(_FILE_); \
|
||||
}
|
||||
|
||||
#define GetValueString(i,p,Maxtrix,IdMax) \
|
||||
{ \
|
||||
if( (i) >= (IdMax) ) \
|
||||
{ \
|
||||
(p) = Maxtrix[(IdMax)].pStr; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
(p) = Maxtrix[(i)].pStr; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define GET_MODULE_VER(x) (x##_VERSION)
|
||||
|
||||
#define FPOS( type, field ) \
|
||||
/*lint -e545 */ ( ( dword ) & ( ( type * ) 0 )->field ) /*lint +e545 */
|
||||
|
||||
#define FSIZ( type, field ) sizeof( ((type *) 0)->field )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// DivRndUp: Divide and Round Up ///
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define DivRndUp(Num,Div) ( ((Num) % (Div))?((Num)/(Div) + 1):((Num)/(Div)) )
|
||||
|
||||
|
||||
#endif
|
||||
43
plat/public_bak/src/include/pub_debug.h
Normal file
43
plat/public_bak/src/include/pub_debug.h
Normal file
@@ -0,0 +1,43 @@
|
||||
//////////////////////////////////////////////////
|
||||
//Title : pub_debug.h
|
||||
//Auhtor : Liu Wei
|
||||
//Desc : public debug api header
|
||||
//Created : 2007-05-01
|
||||
//Revision :
|
||||
//
|
||||
//Revision :
|
||||
//
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
#ifndef _PUB_DEBUG_H_
|
||||
#define _PUB_DEBUG_H_
|
||||
|
||||
#include "stdio.h"
|
||||
#include "assert.h"
|
||||
#include "string.h"
|
||||
#include "stdlib.h"
|
||||
#include <execinfo.h>
|
||||
#include <signal.h>
|
||||
|
||||
|
||||
extern void WxcDump(int nSigno);
|
||||
|
||||
extern void WxcBackTrace();
|
||||
|
||||
#ifdef DEBUG
|
||||
#define WxcAssert(Expression,pStr) \
|
||||
{ \
|
||||
int nVal = (Expression); \
|
||||
if(!nVal) \
|
||||
{ \
|
||||
WxcBackTrace(); \
|
||||
} \
|
||||
assert( nVal && pStr ); \
|
||||
}
|
||||
|
||||
#else
|
||||
#define WxcAssert(uVal,pStr)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
22
plat/public_bak/src/include/pub_file.h
Normal file
22
plat/public_bak/src/include/pub_file.h
Normal file
@@ -0,0 +1,22 @@
|
||||
//////////////////////////////////////////////////
|
||||
//Title : wxc_file.h
|
||||
//Auhtor : Liu Wei
|
||||
//Desc : wxc file handle header
|
||||
//Created : 2007-06-04
|
||||
//Revision :
|
||||
//
|
||||
//Revision :
|
||||
//
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
#ifndef _PUB_FILE_H_
|
||||
#define _PUB_FILE_H_
|
||||
|
||||
#include "./public.h"
|
||||
#include "./includes.h"
|
||||
#include "./pub_base.h"
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
132
plat/public_bak/src/include/pub_fmt.h
Normal file
132
plat/public_bak/src/include/pub_fmt.h
Normal file
@@ -0,0 +1,132 @@
|
||||
//////////////////////////////////////////////////
|
||||
//Title : pub_convert.h
|
||||
//Auhtor : Liu Wei
|
||||
//Desc : public type fomat convert inplementation
|
||||
//Created : 2007-06-24
|
||||
//Revision :
|
||||
//
|
||||
//Revision :
|
||||
//
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// lCRD software network data type assumpsit
|
||||
//
|
||||
// Memery Low <<============[Little Endian]===========>> Memery High
|
||||
// Type abbr. e.g. Remark
|
||||
// const value CVal 0x12345678
|
||||
// Host BCD HBcd/BCd 0x78 0x56 0x34 0x12
|
||||
// Anti BCD ABcd 0x87 0x65 0x43 0x21
|
||||
// NetBCD NBcd 0x12 0x34 0x56 0x78
|
||||
// String Str 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 "12345678"
|
||||
// U64 U64 0x4E 0x61 0xBC 0x00 0x00 0x00 0x00 0x00 12345678=0xBC614E
|
||||
// Digit Dig 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _PUB_FMT_H_
|
||||
#define _PUB_FMT_H_
|
||||
|
||||
#include "public.h"
|
||||
#include "includes.h"
|
||||
#include "pub_base.h"
|
||||
#include "pub_debug.h"
|
||||
|
||||
extern inline char HexToCh ( u8 uHex );
|
||||
extern inline u8 ChToHex ( char ch );
|
||||
|
||||
|
||||
void AsciiToBcd (BYTE *bcd_buf, const char *ascii_buf, int len);
|
||||
void BcdToAscii (char *ascii_buf, const BYTE *bcd_buf, int len);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ReverseByte : 0010 1010 =>> 0101 0100
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
extern u8 ReverseByte(u8 uByteIn );
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ReverseBCD : 0x12 0x34 0x56 0x78 =>> 0x21 0x43 0x65 0x87
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
extern void ReverseBCD( u8 *pDst , const u8 *pSrc , int nBcdLen );
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ReverseArray : 0x12 0x34 0x56 0x78 =>> 0x78 0x56 0x34 0x12
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
extern void ReverseArray( u8 *pDst , const u8 *pSrc , int nBcdLen );
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// BcdToStr : 0x12 0x34 0x56 0x78 =>> "12345678"
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
extern void BcdToStr( char *pStr , const u8 *pBcd , int nBcdLen );
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// BcdToU64 : 0x12 0x34 0x56 0x78 =>> 12345678
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
extern u64 BcdToU64( const u8 *pBcd , int nBcdLen );
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// BcdToDig : 0x12 0x34 0x56 =>>0x01 0x02 0x03 0x04 0x05 0x06
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
extern int BcdToDig( u8 *pDig , int nDigBuffLen, u8 *pBcd , int nBcdLen );
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// StrToBcd : "123456" =>> 0x12 0x34 0x56
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
extern int StrToBcd( u8 *pBcd , char *pStr , int nBcdBuffLen );
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// U64ToBcd : 1234567 => 0x01 0x23 0x45 0x67
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
extern int U64ToBcd( u8 *pBcd ,u64 llInput , int nBcdBuffLen );
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// DigToBcd : 0x01 0x02 0x03 x04 0x05 0x06 0x07 => 0x01 0x23 0x45 0x67
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
extern int DigToBcd( u8* pBcd , int nBcdBuffLen , u8 *pDig , int nDigLen );
|
||||
extern int DigToBcdE( u8* pBcd , int nBcdBuffLen , u8 *pDig , int nDigLen , int nEnd );
|
||||
|
||||
|
||||
int Str2Bcd ( BYTE * pBcd, char *pStr, int maxLen );
|
||||
int Bcd2Str ( char *pStr, const BYTE * pBcd, int len );
|
||||
int DigitsLen(BYTE *pDigits, int maxLen);
|
||||
int BcdLen(BYTE *pBcd, int maxLen);
|
||||
int Digits2Str(char *pStr, BYTE *pDigits, int DigitsLen);
|
||||
ull Digits2Ull(BYTE *pDigits, int DigitsLen);
|
||||
int Ull2Digits(BYTE *pDigits, ull value, int DigitsLen);
|
||||
int Str2Digits(BYTE *pDigits, char *pStr, int DigitsLen);
|
||||
int Ull2Digits_Ralign(BYTE *pDigits, ull value, int DigitsLen);
|
||||
ull Bcd2Ull(BYTE *pBcd, int BcdLen);
|
||||
int Ull2Bcd(BYTE *pBcd, ull value, int BcdLen);
|
||||
int Digits2Bcd(BYTE *pBcd, BYTE *pDigits, int maxLen);
|
||||
int Bcd2Digits(BYTE *pDigits, BYTE *pBcd, int maxLen);
|
||||
int Bcd2Digits_dLen(BYTE *pDigits, BYTE *pBcd, int maxLen);
|
||||
int Str2Oid(DWORD *pOid, char *pStr, BYTE maxLen);
|
||||
int TrimLeft(char *pStr);
|
||||
int TrimRight(char *pStr);
|
||||
int Array2Digits(BYTE *pDigits, BYTE *pArray, int ArrayLen);
|
||||
ull Str2Ull(char *pStr);
|
||||
int Digits2Array(BYTE *pArray, BYTE *pDigits, int DigitsLen);
|
||||
int Bcd2Array(BYTE *pArray, BYTE *pBcd, int BcdLen);
|
||||
int Str2Array(BYTE *pArray, char *str, int ArrayLen);
|
||||
BYTE EditDigits(BYTE *digits_out, BYTE len_max, BYTE *digits_in, BYTE len_in, BYTE len_del, BYTE *digits_ins, BYTE len_ins, BYTE filler);
|
||||
BYTE DelDigits(BYTE *in_digit, BYTE in_len, BYTE *out_digit, BYTE count, BYTE filler);
|
||||
void DWORD2BYTE(BYTE *pdword, BYTE *pbyte, int len);
|
||||
void u32tobyte(u8 *str, u32 data);
|
||||
u8 u16tobcd(u8 *bcd_string, u16 data);
|
||||
u16 bcdtou16(u8 *bcd_string, u8 bcd_len);
|
||||
u8 u32tobcd(u8 *bcd_string, u32 data);
|
||||
u32 bcdtou32(u8 *bcd_string, u8 bcd_len);
|
||||
void AsciiToRbcd(BYTE *bcd_buf, const char *ascii_buf, int len);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
39
plat/public_bak/src/include/pub_include.h
Normal file
39
plat/public_bak/src/include/pub_include.h
Normal file
@@ -0,0 +1,39 @@
|
||||
//////////////////////////////////////////////////
|
||||
//Title : pub_incudes.h
|
||||
//Auhtor : Liu Wei
|
||||
//Desc : public header includes
|
||||
//Created : 2007-07-13
|
||||
//Revision :
|
||||
//
|
||||
//Revision :
|
||||
//
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef _PUB_INCLUDE_H_
|
||||
#define _PUB_INCLUDE_H_
|
||||
|
||||
#include "public.h"
|
||||
#include "includes.h"
|
||||
#include "pub_base.h"
|
||||
#include "asn1.h"
|
||||
#include "crypt.h"
|
||||
#include "bisearch.h"
|
||||
#include "pub_base.h"
|
||||
#include "pub_debug.h"
|
||||
#include "pub_log.h"
|
||||
#include "pub_file.h"
|
||||
#include "pub_list.h"
|
||||
#include "pub_malloc.h"
|
||||
#include "pub_fmt.h"
|
||||
#include "pub_base.h"
|
||||
#include "pub_time.h"
|
||||
#include "pub_timer.h"
|
||||
#include "pub_sys.h"
|
||||
#include "pub_str.h"
|
||||
#include "pub_inet.h"
|
||||
#include "pub_wnet.h"
|
||||
#include "pub_netcap.h"
|
||||
#include "pub_sdp.h"
|
||||
|
||||
#endif
|
||||
75
plat/public_bak/src/include/pub_inet.h
Normal file
75
plat/public_bak/src/include/pub_inet.h
Normal file
@@ -0,0 +1,75 @@
|
||||
//////////////////////////////////////////////////
|
||||
//Title : pub_inet.h
|
||||
//Auhtor : Liu Wei
|
||||
//Desc : public inet function header
|
||||
//Created : 2007-06-22
|
||||
//Revision :
|
||||
//
|
||||
//Revision :
|
||||
//
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
#ifndef _PUB_INET_H_
|
||||
#define _PUB_INET_H_
|
||||
|
||||
#include "public.h"
|
||||
#include "includes.h"
|
||||
#include "pub_debug.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Inet If Address infomation interface
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define MAXINTERFACES 16
|
||||
|
||||
typedef struct IF_ADDR
|
||||
{
|
||||
u8 uIfNum;
|
||||
struct
|
||||
{
|
||||
u32 dIfIP;
|
||||
u8 uIfState;
|
||||
}
|
||||
tIfEntity[MAXINTERFACES];
|
||||
}
|
||||
IfAddr;
|
||||
|
||||
extern int GetNetIfInfo ( IfAddr * pIfAddr );
|
||||
|
||||
extern u32 GetLocalIP();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Ping Interface
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define PACKET_SIZE 4096
|
||||
#define MAX_NO_PACKETS 3
|
||||
|
||||
typedef void PingCallBack( int nPingResult );
|
||||
|
||||
typedef struct ICMP_SERVICE
|
||||
{
|
||||
u8 uSrvState;
|
||||
u8 uIcmpState;
|
||||
u8 uPackNo;
|
||||
u8 uDataLen;
|
||||
u8 nPackNumSend;
|
||||
u8 nPackNumRecv;
|
||||
u8 aSendBuff[PACKET_SIZE];
|
||||
u8 aRecvBuff[PACKET_SIZE];
|
||||
u32 wSockfd;
|
||||
pid_t tPid;
|
||||
struct sockaddr_in tToAddr;
|
||||
struct sockaddr_in tFromAddr;
|
||||
struct protoent *pProtoent;
|
||||
PingCallBack *fCallBack;
|
||||
}
|
||||
IcmpSrv;
|
||||
|
||||
extern int PingInit ( IcmpSrv *pIS , int nDataLen );
|
||||
|
||||
extern int PingStart( IcmpSrv *pIS , char *sIP , PingCallBack fCallBack );
|
||||
|
||||
extern int PingTimer ( IcmpSrv *pIS );
|
||||
|
||||
#endif
|
||||
501
plat/public_bak/src/include/pub_list.h
Normal file
501
plat/public_bak/src/include/pub_list.h
Normal file
@@ -0,0 +1,501 @@
|
||||
//////////////////////////////////////////////////
|
||||
//Title : pool.c
|
||||
//Auhtor : Liu Wei
|
||||
//Desc : List and Pool Queue struct implement
|
||||
//Created : 2007-05-01
|
||||
//Revision :
|
||||
//
|
||||
//Revision :
|
||||
//
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
#ifndef _PUB_LIST_H_
|
||||
#define _PUB_LIST_H_
|
||||
|
||||
//LIFO Queue
|
||||
|
||||
#define LIFOQ_HEAD( name , type ) \
|
||||
struct name \
|
||||
{ \
|
||||
struct type *pLqFirst;/*First elment*/ \
|
||||
}
|
||||
|
||||
#define LIFOQ_ENTRY(type) \
|
||||
struct \
|
||||
{ \
|
||||
struct type *pLqNext; \
|
||||
}
|
||||
|
||||
#define LIFOQ_EMPTY(head) \
|
||||
((head)->pLqFirst == NULL)
|
||||
|
||||
#define LIFOQ_FIRST(head) \
|
||||
((head)->pLqFirst)
|
||||
|
||||
#define LIFOQ_FOREACH(var, head, field) \
|
||||
for((var) = (head)->pLqFirst; (var); (var) = (var)->field.pLqNext)
|
||||
|
||||
#define LIFOQ_INIT(head) \
|
||||
{ \
|
||||
(head)->pLqFirst = NULL; \
|
||||
}
|
||||
|
||||
#define LIFOQ_INSERT_AFTER(lifoq_elm, elm, field) \
|
||||
do \
|
||||
{ \
|
||||
(elm)->field.pLqNext = (lifoq_elm)->field.pLqNext; \
|
||||
(lifoq_elm)->field.pLqNext = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define LIFOQ_INSERT_HEAD(head, elm, field) \
|
||||
do \
|
||||
{ \
|
||||
(elm)->field.pLqNext = (head)->pLqFirst; \
|
||||
(head)->pLqFirst = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define LIFOQ_NEXT(elm, field) ((elm)->field.pLqNext)
|
||||
|
||||
#define LIFOQ_REMOVE_HEAD(head, field) \
|
||||
do \
|
||||
{ \
|
||||
(head)->pLqFirst = (head)->pLqFirst->field.pLqNext; \
|
||||
} while (0)
|
||||
|
||||
#define LIFOQ_REMOVE(head, elm, type, field) \
|
||||
do \
|
||||
{ \
|
||||
if ((head)->pLqFirst == (elm)) \
|
||||
{ \
|
||||
LIFOQ_REMOVE_HEAD((head), field); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
struct type *curelm = (head)->pLqFirst; \
|
||||
\
|
||||
while( curelm->field.pLqNext != (elm) ) \
|
||||
{ \
|
||||
curelm = curelm->field.pLqNext; \
|
||||
} \
|
||||
curelm->field.pLqNext = \
|
||||
curelm->field.pLqNext->field.pLqNext; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
//FIFO Quence
|
||||
|
||||
#define FIFOQ_HEAD(name, type) \
|
||||
struct name \
|
||||
{ \
|
||||
struct type *pFqFirst;/* first element */ \
|
||||
struct type **pFqLast;/* addr of last next element */ \
|
||||
}
|
||||
|
||||
#define FIFOQ_HEAD_INITIALIZER(head) \
|
||||
{ NULL, &(head).pFqFirst }
|
||||
|
||||
#define FIFOQ_ENTRY(type) \
|
||||
struct \
|
||||
{ \
|
||||
struct type *pFqNext; /* next element */ \
|
||||
}
|
||||
|
||||
#define FIFOQ_EMPTY(head) ((head)->pFqFirst == NULL)
|
||||
|
||||
#define FIFOQ_INIT(head) \
|
||||
do \
|
||||
{ \
|
||||
(head)->pFqFirst = NULL; \
|
||||
(head)->spTQLast = &(head)->pFqFirst; \
|
||||
} while (0)
|
||||
|
||||
#define FIFOQ_FIRST(head) ((head)->pFqFirst)
|
||||
|
||||
#define FIFOQ_LAST(head, type, field) \
|
||||
(FIFOQ_EMPTY(head) ? NULL : ((struct type *) \
|
||||
((char *)((head)->spTQLast) - __offsetof(struct type, field))))
|
||||
|
||||
#define FIFOQ_FOREACH(var, head, field) \
|
||||
for((var) = (head)->pFqFirst; (var); (var) = (var)->field.pFqNext)
|
||||
|
||||
#define FIFOQ_INSERT_HEAD(head, elm, field) \
|
||||
do \
|
||||
{ \
|
||||
if (((elm)->field.pFqNext = (head)->pFqFirst) == NULL) \
|
||||
(head)->spTQLast = &(elm)->field.pFqNext; \
|
||||
(head)->pFqFirst = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define FIFOQ_INSERT_TAIL(head, elm, field) \
|
||||
do \
|
||||
{ \
|
||||
(elm)->field.pFqNext = NULL; \
|
||||
*(head)->spTQLast = (elm); \
|
||||
(head)->spTQLast = &(elm)->field.pFqNext; \
|
||||
} while (0)
|
||||
|
||||
#define FIFOQ_INSERT_AFTER(head, tqelm, elm, field) \
|
||||
do \
|
||||
{ \
|
||||
if (((elm)->field.pFqNext = (tqelm)->field.pFqNext) == NULL)\
|
||||
(head)->spTQLast = &(elm)->field.pFqNext; \
|
||||
(tqelm)->field.pFqNext = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define FIFOQ_NEXT(elm, field) ((elm)->field.pFqNext)
|
||||
|
||||
#define FIFOQ_REMOVE_HEAD(head, field) \
|
||||
do \
|
||||
{ \
|
||||
if (((head)->pFqFirst = (head)->pFqFirst->field.pFqNext) == NULL) \
|
||||
(head)->spTQLast = &(head)->pFqFirst; \
|
||||
} while (0)
|
||||
|
||||
#define FIFOQ_REMOVE_HEAD_UNTIL(head, elm, field) \
|
||||
do \
|
||||
{ \
|
||||
if (((head)->pFqFirst = (elm)->field.pFqNext) == NULL) \
|
||||
(head)->spTQLast = &(head)->pFqFirst; \
|
||||
} while (0)
|
||||
|
||||
#define FIFOQ_REMOVE(head, elm, type, field) \
|
||||
do \
|
||||
{ \
|
||||
if ((head)->pFqFirst == (elm)) \
|
||||
{ \
|
||||
FIFOQ_REMOVE_HEAD(head, field); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
struct type *curelm = (head)->pFqFirst; \
|
||||
while( curelm->field.pFqNext != (elm) ) \
|
||||
curelm = curelm->field.pFqNext; \
|
||||
\
|
||||
if((curelm->field.pFqNext = \
|
||||
curelm->field.pFqNext->field.pFqNext) == NULL)\
|
||||
(head)->spTQLast = &(curelm)->field.pFqNext; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
// List
|
||||
|
||||
#define LIST_HEAD(name, type) \
|
||||
struct name \
|
||||
{ \
|
||||
struct type *pListFirst; /* first element */ \
|
||||
}
|
||||
|
||||
#define LIST_HEAD_INITIALIZER(head) \
|
||||
{ NULL }
|
||||
|
||||
#define LIST_ENTRY(type) \
|
||||
struct \
|
||||
{ \
|
||||
struct type *pListNext; /* next element */ \
|
||||
struct type **pListPrev; /* address of previous next element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* List functions.
|
||||
*/
|
||||
|
||||
#define LIST_EMPTY(head) ((head)->pListFirst == NULL)
|
||||
|
||||
#define LIST_FIRST(head) ((head)->pListFirst)
|
||||
|
||||
#define LIST_FOREACH(var, head, field) \
|
||||
for((var) = (head)->pListFirst; (var); (var) = (var)->field.pListNext)
|
||||
|
||||
#define LIST_INIT(head) \
|
||||
do \
|
||||
{ \
|
||||
(head)->pListFirst = NULL; \
|
||||
} while (0)
|
||||
|
||||
#define LIST_INSERT_AFTER(listelm, elm, field) \
|
||||
do \
|
||||
{ \
|
||||
if (((elm)->field.pListNext = (listelm)->field.pListNext) != NULL) \
|
||||
{ \
|
||||
(listelm)->field.pListNext->field.pListPrev = \
|
||||
&(elm)->field.pListNext; \
|
||||
} \
|
||||
(listelm)->field.pListNext = (elm); \
|
||||
(elm)->field.pListPrev = &(listelm)->field.pListNext; \
|
||||
} while (0)
|
||||
|
||||
#define LIST_INSERT_BEFORE(listelm, elm, field) \
|
||||
do \
|
||||
{ \
|
||||
(elm)->field.pListPrev = (listelm)->field.pListPrev; \
|
||||
(elm)->field.pListNext = (listelm); \
|
||||
*(listelm)->field.pListPrev = (elm); \
|
||||
(listelm)->field.pListPrev = &(elm)->field.pListNext; \
|
||||
} while (0)
|
||||
|
||||
#define LIST_INSERT_HEAD(head, elm, field) \
|
||||
do \
|
||||
{ \
|
||||
if (((elm)->field.pListNext = (head)->pListFirst) != NULL) \
|
||||
(head)->pListFirst->field.pListPrev = &(elm)->field.pListNext; \
|
||||
(head)->pListFirst = (elm); \
|
||||
(elm)->field.pListPrev = &(head)->pListFirst; \
|
||||
} while (0)
|
||||
|
||||
#define LIST_NEXT(elm, field) ((elm)->field.pListNext)
|
||||
|
||||
#define LIST_REMOVE(elm, field) \
|
||||
do \
|
||||
{ \
|
||||
if ((elm)->field.pListNext != NULL) \
|
||||
(elm)->field.pListNext->field.pListPrev = \
|
||||
(elm)->field.pListPrev; \
|
||||
*(elm)->field.pListPrev = (elm)->field.pListNext; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Tail queue definitions.
|
||||
*/
|
||||
#define TAILQ_HEAD(name, type) \
|
||||
struct name \
|
||||
{ \
|
||||
struct type *pTQFirst; /* first element */ \
|
||||
struct type **pTQLast; /* addr of last next element */ \
|
||||
}
|
||||
|
||||
#define TAILQ_HEAD_INITIALIZER(head) \
|
||||
{ NULL, &(head).pTQFirst }
|
||||
|
||||
#define TAILQ_ENTRY(type) \
|
||||
struct \
|
||||
{ \
|
||||
struct type *pTQNext; /* next element */ \
|
||||
struct type **pTQPrev; /* address of previous next element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* Tail queue functions.
|
||||
*/
|
||||
#define TAILQ_EMPTY(head) ((head)->pTQFirst == NULL)
|
||||
|
||||
#define TAILQ_FOREACH(var, head, field) \
|
||||
for (var = TAILQ_FIRST(head); var; var = TAILQ_NEXT(var, field))
|
||||
|
||||
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
|
||||
for ((var) = TAILQ_LAST((head), headname); \
|
||||
(var); \
|
||||
(var) = TAILQ_PREV((var), headname, field))
|
||||
|
||||
#define TAILQ_FIRST(head) ((head)->pTQFirst)
|
||||
|
||||
#define TAILQ_LAST(head, headname) \
|
||||
(*(((struct headname *)((head)->pTQLast))->pTQLast))
|
||||
|
||||
#define TAILQ_NEXT(elm, field) ((elm)->field.pTQNext)
|
||||
|
||||
#define TAILQ_PREV(elm, headname, field) \
|
||||
(*(((struct headname *)((elm)->field.pTQPrev))->pTQLast))
|
||||
|
||||
#define TAILQ_INIT(head) \
|
||||
do \
|
||||
{ \
|
||||
(head)->pTQFirst = NULL; \
|
||||
(head)->pTQLast = &(head)->pTQFirst; \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_HEAD(head, elm, field) \
|
||||
do \
|
||||
{ \
|
||||
if (((elm)->field.pTQNext = (head)->pTQFirst) != NULL) \
|
||||
(head)->pTQFirst->field.pTQPrev = \
|
||||
&(elm)->field.pTQNext; \
|
||||
else \
|
||||
(head)->pTQLast = &(elm)->field.pTQNext; \
|
||||
(head)->pTQFirst = (elm); \
|
||||
(elm)->field.pTQPrev = &(head)->pTQFirst; \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_TAIL(head, elm, field) \
|
||||
do \
|
||||
{ \
|
||||
(elm)->field.pTQNext = NULL; \
|
||||
(elm)->field.pTQPrev = (head)->pTQLast; \
|
||||
*(head)->pTQLast = (elm); \
|
||||
(head)->pTQLast = &(elm)->field.pTQNext; \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) \
|
||||
do \
|
||||
{ \
|
||||
if (((elm)->field.pTQNext = (listelm)->field.pTQNext) != NULL) \
|
||||
(elm)->field.pTQNext->field.pTQPrev = &(elm)->field.pTQNext; \
|
||||
else \
|
||||
(head)->pTQLast = &(elm)->field.pTQNext; \
|
||||
(listelm)->field.pTQNext = (elm); \
|
||||
(elm)->field.pTQPrev = &(listelm)->field.pTQNext; \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_BEFORE(listelm, elm, field) \
|
||||
do { \
|
||||
(elm)->field.pTQPrev = (listelm)->field.pTQPrev; \
|
||||
(elm)->field.pTQNext = (listelm); \
|
||||
*(listelm)->field.pTQPrev = (elm); \
|
||||
(listelm)->field.pTQPrev = &(elm)->field.pTQNext; \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_REMOVE(head, elm, field) \
|
||||
do { \
|
||||
if (((elm)->field.pTQNext) != NULL) \
|
||||
(elm)->field.pTQNext->field.pTQPrev = (elm)->field.pTQPrev; \
|
||||
else \
|
||||
(head)->pTQLast = (elm)->field.pTQPrev; \
|
||||
*(elm)->field.pTQPrev = (elm)->field.pTQNext; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Pool -- Circular queue definitions.
|
||||
*/
|
||||
#define POOL_HEAD(name, type) \
|
||||
struct name \
|
||||
{ \
|
||||
struct type *pPoolFirst; /* first element */ \
|
||||
struct type *pPoolLast; /* last element */ \
|
||||
}
|
||||
|
||||
#define POOL_ENTRY(type) \
|
||||
struct \
|
||||
{ \
|
||||
struct type *pPoolNext; /* next element */ \
|
||||
struct type *pPoolPrev; /* previous element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* Pool -- Circular queue functions.
|
||||
*/
|
||||
|
||||
#define POOL_EMPTY(head) ((head)->pPoolFirst == (void *)(head))
|
||||
|
||||
#define POOL_FIRST(head) ((head)->pPoolFirst)
|
||||
|
||||
#define POOL_FOREACH(var, head, field) \
|
||||
for((var) = (head)->pPoolFirst; \
|
||||
(var) != (void *)(head); \
|
||||
(var) = (var)->field.pPoolNext)
|
||||
|
||||
#define POOL_FOREACH_REVERSE(var, head, field) \
|
||||
for((var) = (head)->pPoolLast; \
|
||||
(var) != (void *)(head); \
|
||||
(var) = (var)->field.pPoolPrev)
|
||||
|
||||
#define POOL_INIT(head) \
|
||||
do \
|
||||
{ \
|
||||
(head)->pPoolFirst = (void *)(head); \
|
||||
(head)->pPoolLast = (void *)(head); \
|
||||
} while (0)
|
||||
|
||||
#define POOL_INSERT_AFTER(head, listelm, elm, field) \
|
||||
do { \
|
||||
(elm)->field.pPoolNext = (listelm)->field.pPoolNext; \
|
||||
(elm)->field.pPoolPrev = (listelm); \
|
||||
if ((listelm)->field.pPoolNext == (void *)(head)) \
|
||||
(head)->pPoolLast = (elm); \
|
||||
else \
|
||||
(listelm)->field.pPoolNext->field.pPoolPrev = (elm); \
|
||||
(listelm)->field.pPoolNext = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define POOL_INSERT_BEFORE(head, listelm, elm, field) \
|
||||
do { \
|
||||
(elm)->field.pPoolNext = (listelm); \
|
||||
(elm)->field.pPoolPrev = (listelm)->field.pPoolPrev; \
|
||||
if ((listelm)->field.pPoolPrev == (void *)(head)) \
|
||||
(head)->pPoolFirst = (elm); \
|
||||
else \
|
||||
(listelm)->field.pPoolPrev->field.pPoolNext = (elm); \
|
||||
(listelm)->field.pPoolPrev = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define POOL_INSERT_HEAD(head, elm, field) \
|
||||
do { \
|
||||
(elm)->field.pPoolNext = (head)->pPoolFirst; \
|
||||
(elm)->field.pPoolPrev = (void *)(head); \
|
||||
if ((head)->pPoolLast == (void *)(head)) \
|
||||
(head)->pPoolLast = (elm); \
|
||||
else \
|
||||
(head)->pPoolFirst->field.pPoolPrev = (elm); \
|
||||
(head)->pPoolFirst = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define POOL_INSERT_TAIL(head, elm, field) \
|
||||
do { \
|
||||
(elm)->field.pPoolNext = (void *)(head); \
|
||||
(elm)->field.pPoolPrev = (head)->pPoolLast; \
|
||||
if ((head)->pPoolFirst == (void *)(head)) \
|
||||
(head)->pPoolFirst = (elm); \
|
||||
else \
|
||||
(head)->pPoolLast->field.pPoolNext = (elm); \
|
||||
(head)->pPoolLast = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define POOL_LAST(head) ((head)->pPoolLast)
|
||||
|
||||
#define POOL_NEXT(elm,field) ((elm)->field.pPoolNext)
|
||||
|
||||
#define POOL_PREV(elm,field) ((elm)->field.pPoolPrev)
|
||||
|
||||
#define POOL_REMOVE(head, elm, field) \
|
||||
do { \
|
||||
if ((elm)->field.pPoolNext == (void *)(head)) \
|
||||
(head)->pPoolLast = (elm)->field.pPoolPrev; \
|
||||
else \
|
||||
(elm)->field.pPoolNext->field.pPoolPrev = (elm)->field.pPoolPrev; \
|
||||
\
|
||||
if ((elm)->field.pPoolPrev == (void *)(head)) \
|
||||
(head)->pPoolFirst = (elm)->field.pPoolNext; \
|
||||
else \
|
||||
(elm)->field.pPoolPrev->field.pPoolNext =(elm)->field.pPoolNext; \
|
||||
} while (0)
|
||||
|
||||
#ifdef _KERNEL
|
||||
/*
|
||||
* XXX insque() and remque() are an old way of handling certain queues.
|
||||
* They bogusly assumes that all queue heads look alike.
|
||||
*/
|
||||
|
||||
struct quehead
|
||||
{
|
||||
struct quehead *qh_link;
|
||||
struct quehead *qh_rlink;
|
||||
};
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
static __inline void insque ( void *a, void *b )
|
||||
{
|
||||
struct quehead *element = a, *head = b;
|
||||
|
||||
element->qh_link = head->qh_link;
|
||||
element->qh_rlink = head;
|
||||
head->qh_link = element;
|
||||
element->qh_link->qh_rlink = element;
|
||||
}
|
||||
|
||||
static __inline void remque ( void *a )
|
||||
{
|
||||
struct quehead *element = a;
|
||||
|
||||
element->qh_link->qh_rlink = element->qh_rlink;
|
||||
element->qh_rlink->qh_link = element->qh_link;
|
||||
element->qh_rlink = 0;
|
||||
}
|
||||
|
||||
#else /* !__GNUC__ */
|
||||
|
||||
void insque __P ( ( void *a, void *b ) );
|
||||
void remque __P ( ( void *a ) );
|
||||
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
#endif /* _KERNEL */
|
||||
#endif
|
||||
68
plat/public_bak/src/include/pub_log.h
Normal file
68
plat/public_bak/src/include/pub_log.h
Normal file
@@ -0,0 +1,68 @@
|
||||
//////////////////////////////////////////////////
|
||||
//Title : pub_log.h
|
||||
//Auhtor : Liu Wei
|
||||
//Desc : public log function header
|
||||
//Created : 2007-05-21
|
||||
//Revision :
|
||||
//
|
||||
//Revision :
|
||||
//
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef _PUB_LOG_H_
|
||||
#define _PUB_LOG_H_
|
||||
|
||||
#include "public.h"
|
||||
#include "includes.h"
|
||||
#include "pub_base.h"
|
||||
#include "pub_debug.h"
|
||||
#include "pub_fmt.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
#define RESET 0
|
||||
#define BRIGHT 1
|
||||
#define DIM 2
|
||||
#define UNDERLINE 3
|
||||
#define BLINK 4
|
||||
#define REVERSE 7
|
||||
#define HIDDEN 8
|
||||
#define BLACK 0
|
||||
#define RED 1
|
||||
#define GREEN 2
|
||||
#define YELLOW 3
|
||||
#define BLUE 4
|
||||
#define MAGENTA 5
|
||||
#define CYAN 6
|
||||
#define WHITE 7
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// Public print information
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define PIF_INFO 0x01 // Normal Information
|
||||
#define PIF_WARN 0x02 // Warnings
|
||||
#define PIF_GERR 0x04 // General errors
|
||||
#define PIF_CERR 0x10 // Critical errors
|
||||
#define PIF_DBG 0x20 // Debugging
|
||||
#define PIF_UNKN 0x40 // Things that are unknown
|
||||
|
||||
// Default SIM output
|
||||
#define PIF_DEFAULT (PIF_INFO|PIF_WARN|PIF_CERR)
|
||||
// Everything, but DBG
|
||||
#define PIF_ALL (PIF_INFO|PIF_WARN|PIF_GERR|PIF_CERR|PIF_UNKN)
|
||||
|
||||
#define SYSERR strerror(errno)
|
||||
|
||||
extern char *ByteBinToStr( char *pDst , const u8 *pSrc , int nByte );
|
||||
extern char *TxtColor ( int nAttr, int nFg, int nBg, char *pStr );
|
||||
extern int MsgToFmtLog ( const BYTE * pBcd, int nBcdLen, char *pStr, int nStrBuffSize );
|
||||
|
||||
#ifdef DEBUG
|
||||
#define WxcDebugLog printf
|
||||
#else
|
||||
#define WxcDebugLog
|
||||
#endif
|
||||
|
||||
#endif
|
||||
26
plat/public_bak/src/include/pub_malloc.h
Normal file
26
plat/public_bak/src/include/pub_malloc.h
Normal file
@@ -0,0 +1,26 @@
|
||||
//////////////////////////////////////////////////
|
||||
//Title : pub_malloc.h
|
||||
//Auhtor : Liu Wei
|
||||
//Desc : Public heap memery management
|
||||
//Created : 2007-05-01
|
||||
//Revision :
|
||||
//
|
||||
//Revision :
|
||||
//
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
#ifndef _PUB_MALLOC_H_
|
||||
#define _PUB_MALLOC_H_
|
||||
|
||||
#include "public.h"
|
||||
#include "includes.h"
|
||||
//#ifdef _USE_SYS_MALLOC_
|
||||
|
||||
#define WxcMalloc malloc
|
||||
#define WxcFree free
|
||||
|
||||
//#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
35
plat/public_bak/src/include/pub_netcap.h
Normal file
35
plat/public_bak/src/include/pub_netcap.h
Normal file
@@ -0,0 +1,35 @@
|
||||
//////////////////////////////////////////////////
|
||||
//Title : pub_netcap.h
|
||||
//Auhtor : Liu Wei
|
||||
//Desc : public netcap header
|
||||
//Created : 2007-06-05
|
||||
//Revision :
|
||||
//
|
||||
//Revision :
|
||||
//
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
#ifndef _PUB_NETCAP_H_
|
||||
#define _PUB_NETCAP_H_
|
||||
|
||||
#include "public.h"
|
||||
#include "includes.h"
|
||||
|
||||
typedef struct NET_CAPTURE
|
||||
{
|
||||
u8 uState;
|
||||
u32 nSock;
|
||||
u32 nPort;
|
||||
u32 nDstIp;
|
||||
}
|
||||
NetCap;
|
||||
|
||||
int NcInit();
|
||||
int NcStart( u32 wIP , u32 wPort );
|
||||
int NcStop( );
|
||||
void NcSetPort( u32 port );
|
||||
void NcSetIP( u32 ip );
|
||||
void NcMtp3Send( u8 *pMtp3Msg , u32 wMtp3Len , u8 uAnsiFlag );
|
||||
int NcSccpSend( u8 *pSccpMsg , u32 wSccpLen , u8 *pIntraMsg , u8 uAnsiFlag );
|
||||
|
||||
#endif
|
||||
196
plat/public_bak/src/include/pub_sdp.h
Normal file
196
plat/public_bak/src/include/pub_sdp.h
Normal file
@@ -0,0 +1,196 @@
|
||||
#ifndef _PUB_SDP__H
|
||||
#define _PUB_SDP__H
|
||||
|
||||
#define PUB_SDP_MAX_USER_NAME_LEN 64
|
||||
#define PUB_SDP_MAX_SESS_ID_LEN 32
|
||||
#define PUB_SDP_MAX_SESS_VER_LEN 16
|
||||
#define PUB_SDP_MAX_ADDR_LEN 64
|
||||
#define PUB_SDP_MAX_SESS_NAME_LEN 64
|
||||
#define PUB_SDP_MAX_SESS_INFO_LEN 64
|
||||
#define PUB_SDP_MAX_PAYLOAD_NUM 8
|
||||
#define PUB_SDP_MAX_MEDIA_NUM 8
|
||||
#define PUB_SDP_MAX_ATTR_NUM 16
|
||||
#define PUB_SDP_MAX_ATTR_LEN 32
|
||||
|
||||
#define PUB_SDP_FLAG_V 0x00000001
|
||||
#define PUB_SDP_FLAG_O 0x00000002
|
||||
#define PUB_SDP_FLAG_S 0x00000004
|
||||
#define PUB_SDP_FLAG_I 0x00000008
|
||||
#define PUB_SDP_FLAG_U 0x00000010
|
||||
#define PUB_SDP_FLAG_E 0x00000020
|
||||
#define PUB_SDP_FLAG_P 0x00000040
|
||||
#define PUB_SDP_FLAG_C 0x00000080
|
||||
#define PUB_SDP_FLAG_B 0x00000100
|
||||
#define PUB_SDP_FLAG_Z 0x00000200
|
||||
#define PUB_SDP_FLAG_K 0x00000400
|
||||
#define PUB_SDP_FLAG_A 0x00000800
|
||||
#define PUB_SDP_FLAG_T 0x00001000
|
||||
#define PUB_SDP_FLAG_R 0x00002000
|
||||
#define PUB_SDP_FLAG_M 0x00004000
|
||||
|
||||
#define PUB_MGCP_PARA_FLAG_TFO 0x00000800
|
||||
|
||||
#define PUB_SDP_STR_TO_API 1
|
||||
#define PUB_SDP_API_TO_STR 2
|
||||
|
||||
#define PUB_SDP_NET_TYPE_IN 1
|
||||
|
||||
#define PUB_SDP_ADDR_TYPE_IPV4 1
|
||||
#define PUB_SDP_ADDR_TYPE_IPV6 2
|
||||
|
||||
#define PUB_SDP_ATTR_TYPE_RTPMAP 1
|
||||
#define PUB_SDP_ATTR_TYPE_PTIME 2
|
||||
#define PUB_SDP_ATTR_TYPE_FMTP 3
|
||||
#define PUB_SDP_ATTR_TYPE_RECVONLY 4
|
||||
#define PUB_SDP_ATTR_TYPE_SENDONLY 5
|
||||
#define PUB_SDP_ATTR_TYPE_SENDRECV 6
|
||||
|
||||
#define PUB_SDP_MEDIA_TYPE_AUDIO 1
|
||||
#define PUB_SDP_MEDIA_TYPE_VIDEO 2
|
||||
|
||||
#define PUB_SDP_PROTO_TYPE_RTP_AVP 1
|
||||
|
||||
typedef struct _PUB_SDP_V
|
||||
{
|
||||
BYTE value;
|
||||
}PUB_SDP_V;
|
||||
|
||||
typedef struct _PUB_SDP_O
|
||||
{
|
||||
char userName[PUB_SDP_MAX_USER_NAME_LEN];
|
||||
char sessId[PUB_SDP_MAX_SESS_ID_LEN];
|
||||
char sessVer[PUB_SDP_MAX_SESS_VER_LEN];
|
||||
BYTE netType;
|
||||
BYTE addrType;
|
||||
char addr[PUB_SDP_MAX_ADDR_LEN];
|
||||
}PUB_SDP_O;
|
||||
|
||||
typedef struct _PUB_SDP_S
|
||||
{
|
||||
char sessName[PUB_SDP_MAX_SESS_NAME_LEN];
|
||||
}PUB_SDP_S;
|
||||
|
||||
typedef struct _PUB_SDP_I
|
||||
{
|
||||
char info[PUB_SDP_MAX_SESS_INFO_LEN];
|
||||
}PUB_SDP_I;
|
||||
|
||||
typedef struct _PUB_SDP_U
|
||||
{
|
||||
}PUB_SDP_U;
|
||||
|
||||
typedef struct _PUB_SDP_E
|
||||
{
|
||||
}PUB_SDP_E;
|
||||
|
||||
typedef struct _PUB_SDP_P
|
||||
{
|
||||
}PUB_SDP_P;
|
||||
|
||||
typedef struct _PUB_SDP_C
|
||||
{
|
||||
BYTE netType;
|
||||
BYTE addrType;
|
||||
char addr[PUB_SDP_MAX_ADDR_LEN];
|
||||
}PUB_SDP_C;
|
||||
|
||||
typedef struct _PUB_SDP_B
|
||||
{
|
||||
}PUB_SDP_B;
|
||||
|
||||
typedef struct _PUB_SDP_Z
|
||||
{
|
||||
}PUB_SDP_Z;
|
||||
|
||||
typedef struct _PUB_SDP_K
|
||||
{
|
||||
}PUB_SDP_K;
|
||||
|
||||
typedef struct _PUB_SDP_T
|
||||
{
|
||||
DWORD startTime;
|
||||
DWORD stopTime;
|
||||
}PUB_SDP_T;
|
||||
|
||||
typedef struct _PUB_SDP_R
|
||||
{
|
||||
}PUB_SDP_R;
|
||||
|
||||
typedef struct _PUB_SDP_M
|
||||
{
|
||||
BYTE media;
|
||||
WORD port;
|
||||
BYTE portNum;
|
||||
BYTE proto;
|
||||
BYTE plNum;
|
||||
BYTE payloads[PUB_SDP_MAX_PAYLOAD_NUM];
|
||||
}PUB_SDP_M;
|
||||
|
||||
typedef struct _PUB_SDP_A
|
||||
{
|
||||
BYTE aType;
|
||||
char aValue[PUB_SDP_MAX_ATTR_LEN];
|
||||
}PUB_SDP_A;
|
||||
|
||||
typedef struct _PUB_SDP_ATTRS
|
||||
{
|
||||
BYTE num;
|
||||
PUB_SDP_A attrs[PUB_SDP_MAX_ATTR_NUM];
|
||||
}PUB_SDP_ATTRS;
|
||||
|
||||
typedef struct _PUB_SDP_MEDIA
|
||||
{
|
||||
DWORD flag;
|
||||
|
||||
PUB_SDP_M m;
|
||||
PUB_SDP_I i;
|
||||
PUB_SDP_C c;
|
||||
PUB_SDP_B b;
|
||||
PUB_SDP_K k;
|
||||
PUB_SDP_ATTRS attrs;
|
||||
}PUB_SDP_MEDIA;
|
||||
|
||||
typedef struct _PUB_SDP_MEDIAS
|
||||
{
|
||||
BYTE num;
|
||||
PUB_SDP_MEDIA medias[PUB_SDP_MAX_MEDIA_NUM];
|
||||
}PUB_SDP_MEDIAS;
|
||||
|
||||
typedef struct _PUB_SDP_MSG
|
||||
{
|
||||
DWORD flag;
|
||||
|
||||
PUB_SDP_V v;
|
||||
PUB_SDP_O o;
|
||||
PUB_SDP_S s;
|
||||
PUB_SDP_I i;
|
||||
PUB_SDP_U u;
|
||||
PUB_SDP_E e;
|
||||
PUB_SDP_P p;
|
||||
PUB_SDP_C c;
|
||||
PUB_SDP_B b;
|
||||
PUB_SDP_Z z;
|
||||
PUB_SDP_K k;
|
||||
PUB_SDP_A a;
|
||||
|
||||
PUB_SDP_T t;
|
||||
PUB_SDP_R r;
|
||||
|
||||
PUB_SDP_MEDIAS medias;
|
||||
}PUB_SDP_MSG;
|
||||
|
||||
void pub_replace_all_lws(char *msg);
|
||||
char *pub_strncpy(char *dest, const char *src, WORD length);
|
||||
int pub_set_next_token(char *dest, char *buf, int endSeparator, char **next);
|
||||
|
||||
int pub_sdp_msg_init(PUB_SDP_MSG *sdp);
|
||||
int pub_sdp_parse(PUB_SDP_MSG *sdp, char *buf, char **nextMsg, DWORD flag);
|
||||
int pub_sdp_encode(PUB_SDP_MSG *sdp, char *dest, WORD flag);
|
||||
|
||||
int pub_sdp_net_type_conv(char *str, BYTE *netType, BYTE flag);
|
||||
int pub_sdp_addr_type_conv(char *str, BYTE *addrType, BYTE flag);
|
||||
int pub_sdp_attr_type_conv(char *str, BYTE *attrType, BYTE flag);
|
||||
int pub_sdp_media_type_conv(char *str, BYTE *mediaType, BYTE flag);
|
||||
int pub_sdp_proto_type_conv(char *str, BYTE *protoType, BYTE flag);
|
||||
|
||||
#endif
|
||||
26
plat/public_bak/src/include/pub_str.h
Normal file
26
plat/public_bak/src/include/pub_str.h
Normal file
@@ -0,0 +1,26 @@
|
||||
//////////////////////////////////////////////////
|
||||
//Title : pub_str.h
|
||||
//Auhtor : Liu Wei
|
||||
//Desc : wxc2 string library
|
||||
//Created : 2007-06-02
|
||||
//Revision :
|
||||
//
|
||||
//Revision :
|
||||
//
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
#ifndef _PUB_STR_H_
|
||||
#define _PUB_STR_H_
|
||||
|
||||
#include "public.h"
|
||||
#include "includes.h"
|
||||
#include "pub_base.h"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
53
plat/public_bak/src/include/pub_sys.h
Normal file
53
plat/public_bak/src/include/pub_sys.h
Normal file
@@ -0,0 +1,53 @@
|
||||
//////////////////////////////////////////////////
|
||||
//Title : pub_sys.c
|
||||
//Auhtor : Liu Wei
|
||||
//Desc : Public Linux system infomation
|
||||
//Created : 2007-06-02
|
||||
//Revision :
|
||||
//
|
||||
//Revision :
|
||||
//
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
#ifndef _PUB_SYS_H_
|
||||
#define _PUB_SYS_H_
|
||||
|
||||
#include "public.h"
|
||||
#include "includes.h"
|
||||
#include "pub_base.h"
|
||||
#include "pub_time.h"
|
||||
#include <sys/mount.h>
|
||||
#include <mntent.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <fstab.h>
|
||||
#include <sys/stat.h>
|
||||
#include <linux/kernel.h>
|
||||
//#include <linux/sys.h>
|
||||
|
||||
#define SIM_NONL 0x1000 // Don't add newline to output
|
||||
#define SIM_NOLBL 0x2000 // Don't print "Public: Error:"
|
||||
|
||||
|
||||
#define MHERTZ 1000000 // MegaHertz
|
||||
#define BYTES ((u32)1) // Bytes
|
||||
#define KBYTES ((u32)1024) // Kilo bytes
|
||||
#define MBYTES ((u32)(1024*1024)) // Mega bytes
|
||||
#define GBYTES ((u32)(1024*1024*1024)) // Giga bytes
|
||||
|
||||
#define BytesToGBytes(N) ( (float) N / (float) GBYTES )
|
||||
#define BytesToMBytes(N) ( (float) N / (float) MBYTES )
|
||||
#define BytesToKBytes(N) ( (float) (N / (float) KBYTES) )
|
||||
#define MBytesToBytes(N) ( (float) ( (float) N * (float) MBYTES ) )
|
||||
#define KBytesToMbytes(N) ( (float) ( (float) N / (float) KBYTES ) )
|
||||
#define KBytesToGbytes(N) ( (float) ( (float) N / (float) MBYTES ) )
|
||||
#define MbytesToGbytes(N) ( (float) ( (float) N / (float) KBYTES ) )
|
||||
|
||||
#define EQ(a,b) (a && b && strcasecmp(a,b)==0)
|
||||
#define EQN(a,b,n) (a && b && strncasecmp(a,b,n)==0)
|
||||
#define eq(a,b) (a && b && strcmp(a,b)==0)
|
||||
#define eqn(a,b,n) (a && b && strncmp(a,b,n)==0)
|
||||
#define ARG(s) ((s) ? s : "<null>")
|
||||
#define PRTS(s) ( ( s && *s ) ? s : "" )
|
||||
|
||||
#endif
|
||||
29
plat/public_bak/src/include/pub_time.h
Normal file
29
plat/public_bak/src/include/pub_time.h
Normal file
@@ -0,0 +1,29 @@
|
||||
//////////////////////////////////////////////////
|
||||
//Title : pub_time.h
|
||||
//Auhtor : Liu Wei
|
||||
//Desc : Linux time function
|
||||
//Created : 2007-06-02
|
||||
//Revision :
|
||||
//
|
||||
//Revision :
|
||||
//
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
#ifndef _PUB_TIME_H_
|
||||
#define _PUB_TIME_H_
|
||||
|
||||
#include "public.h"
|
||||
#include "includes.h"
|
||||
#include "pub_base.h"
|
||||
#include "pub_log.h"
|
||||
#include <sys/time.h>
|
||||
|
||||
/* pub_time.c */
|
||||
long GetTickCount(void);
|
||||
int GetCurrentTime(u8 *pNowTime);
|
||||
char *GetAsciiTime(void);
|
||||
char *TimeToStr(time_t TimeVal, char *Format);
|
||||
char *GetTimeHMS(char *pTimeBuf);
|
||||
|
||||
|
||||
#endif
|
||||
96
plat/public_bak/src/include/pub_timer.h
Normal file
96
plat/public_bak/src/include/pub_timer.h
Normal file
@@ -0,0 +1,96 @@
|
||||
//////////////////////////////////////////////////
|
||||
//Title : wxc_timer.h
|
||||
//Auhtor : Liu Wei
|
||||
//Desc : WXC2 Public Timer Managemnet
|
||||
//Created : 2007-04-27
|
||||
//Revision :
|
||||
//
|
||||
//Revision :
|
||||
//
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
#ifndef _PUB_TIMER_H_
|
||||
#define _PUB_TIMER_H_
|
||||
|
||||
#include "public.h"
|
||||
#include "includes.h"
|
||||
#include "pub_base.h"
|
||||
#include "pub_malloc.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef void ( *TimerCallBack ) ( u16 dSuitId, u16 dData );
|
||||
|
||||
#define TM_CLOCK_MAX (24*60*60*100) //one day based on wxc2 base timer 10ms
|
||||
|
||||
typedef struct WXC_TIMER
|
||||
{
|
||||
u32 dExpires; //dExpires : Timer expired number
|
||||
u32 dSuitNumber; //dSuitNumber : Timer suit size of member
|
||||
TimerCallBack pFunc; //pFunc : Timer call back function
|
||||
u16 dData; //dData : Pointer for parameter of callback
|
||||
void *pTimerNode; //pTimerNode : Reserved for timer Managemnet
|
||||
}
|
||||
WxcTimer;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct WXC_TIMER_NODE
|
||||
{
|
||||
u32 *dClockArray; //dClockArray : Timer set member clock array
|
||||
WxcTimer *pTimer;
|
||||
struct WXC_TIMER_NODE *pNext;
|
||||
struct WXC_TIMER_NODE *pPrev;
|
||||
}
|
||||
WxcTimerNode;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define MAX_TM_MODE 512
|
||||
|
||||
#define TIMER_NODE_SIZE ( sizeof( WxcTimerNode ) + sizeof( WxcTimer ) )
|
||||
|
||||
#define CLOCK_SZIE ( sizeof ( u32 ) )
|
||||
|
||||
#define TMHEAP_MM_SIZE ( MAX_TM_MODE * TIMER_NODE_SIZE )
|
||||
|
||||
#define GET_TNODE_SIZE(n) ( TIMER_NODE_SIZE + ( n ) *( CLOCK_SZIE ))
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
u8 TMHeap[TMHEAP_MM_SIZE];
|
||||
|
||||
WxcTimerNode tTimerListHead;
|
||||
WxcTimerNode *pTLHead;
|
||||
WxcTimerNode *pTLCur;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _LINUX_TIMER_H
|
||||
#define time_after(a,b) ((long)(b) - (long)(a) < 0)
|
||||
#define time_before(a,b) time_after(b,a)
|
||||
|
||||
#define time_after_eq(a,b) ((long)(a) - (long)(b) >= 0)
|
||||
#define time_before_eq(a,b) time_after_eq(b,a)
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TimerAfter(a,b) time_after(a,b)
|
||||
#define TimerBefore(a,b) time_before(a,b)
|
||||
#define TimerAfterEq(a,b) time_after_eq(a,b)
|
||||
#define TimerBeforeEq(a,b) time_before_eq(a,b)
|
||||
|
||||
|
||||
extern void TimerAdd ( WxcTimer * pTimer );
|
||||
extern void TimerMod ( WxcTimer * pTimer, u16 dExpires );
|
||||
extern void TimerDel ( WxcTimer * pTimer );
|
||||
|
||||
|
||||
inline void TimerStart ( WxcTimer * pTimer, u16 dSuitId );
|
||||
inline void TimerStop ( WxcTimer * pTimer, u16 dSuitId );
|
||||
inline void TM_Init ( );
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
41
plat/public_bak/src/include/pub_wnet.h
Normal file
41
plat/public_bak/src/include/pub_wnet.h
Normal file
@@ -0,0 +1,41 @@
|
||||
//////////////////////////////////////////////////
|
||||
//Title : pub_wnet.h
|
||||
//Auhtor : Liu Wei
|
||||
//Desc : wireless network publice function
|
||||
//Created : 2007-06-05
|
||||
//Revision :
|
||||
//
|
||||
//Revision :
|
||||
//
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef _WXC_WNET_H_
|
||||
#define _WXC_WNET_H_
|
||||
|
||||
#include "public.h"
|
||||
#include "includes.h"
|
||||
#include "pub_base.h"
|
||||
#include "pub_fmt.h"
|
||||
|
||||
#define ISDN_LEN 9
|
||||
#define IMSI_LEN 8
|
||||
|
||||
/* ./src/pub_wnet.c */
|
||||
u8 GetBcdStr(char *str, u8 *bcd, u8 bcd_len);
|
||||
void ImsiNtoA(u8 *pAntiImsi, u8 *pNormalImsi);
|
||||
void ImsiAToN(u8 *pNormalImsi, u8 *pAntiImsi);
|
||||
void ImsiNToS(u8 *pImsiStr, u8 *pNormalImsi);
|
||||
void ImsiSToN(u8 *pNormalImsi, u8 *pImsiStr);
|
||||
void IsdnNToA(u8 *pAntiIsdn, u8 *pNormalIsdn);
|
||||
void IsdnAToN(u8 *pNormalIsdn, u8 *pAntiIsdn);
|
||||
void IsdnNToS(u8 *pIsdnStr, u8 *pNormalIsdn);
|
||||
u8 IsdnSToN(u8 *pNormalIsdn, u8 *pIsdnStr);
|
||||
void GttToIsdn(u8 *pIsdn, u8 *pGtt);
|
||||
u8 IsdnToGtai(u8 *pGtai, u8 *pIsdn);
|
||||
void GtaiToIsdn(u8 *pIsdn, u8 *pGtai, u8 len);
|
||||
u8 BcdToStrPE(char *str, u8 *bcd, u8 bcd_len);
|
||||
void AddCcToIsdn(u8 *isdn_str, u8 *cc);
|
||||
void AddNdcToIsdn(u8 *isdn_str, u8 *ndc);
|
||||
|
||||
#endif
|
||||
102
plat/public_bak/src/include/public.h
Normal file
102
plat/public_bak/src/include/public.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
** PACS WLL 2000 project, Prepaid System.
|
||||
**
|
||||
** File name: public.h
|
||||
** Written completely by Zhang Shuzhong at 2000-10-17
|
||||
** CVS $Id: public.h,v 1.4 2001/01/20 19:58:49 zhangsz Exp $
|
||||
**
|
||||
** Public type definitions for PACS-WLL Project.
|
||||
**
|
||||
*/
|
||||
|
||||
#ifndef PUBLIC__H
|
||||
#define PUBLIC__H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "memwatch.h"
|
||||
|
||||
#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_ULL
|
||||
#define _T_ULL
|
||||
typedef unsigned long long ull;
|
||||
#endif
|
||||
|
||||
#ifndef _T_U8
|
||||
#define _T_U8
|
||||
typedef unsigned char u8;
|
||||
#endif
|
||||
|
||||
#ifndef _T_U16
|
||||
#define _T_U16
|
||||
typedef unsigned short u16;
|
||||
#endif
|
||||
|
||||
#ifndef _T_U32
|
||||
#define _T_U32
|
||||
typedef unsigned int u32;
|
||||
#endif
|
||||
|
||||
#ifndef _T_U64
|
||||
#define _T_U64
|
||||
typedef unsigned long long u64;
|
||||
#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
|
||||
|
||||
#ifndef YES
|
||||
#define YES (1)
|
||||
#endif
|
||||
|
||||
#ifndef NO
|
||||
#define NO (0)
|
||||
#endif
|
||||
|
||||
#ifndef ERROR
|
||||
#define ERROR (-1)
|
||||
#endif
|
||||
|
||||
#ifndef EMPTY
|
||||
#define EMPTY (0)
|
||||
#endif
|
||||
|
||||
#define BUFSIZE 8192
|
||||
#define MAXBUFLEN 8192
|
||||
#define MAXLINE 8192
|
||||
|
||||
//#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
//#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
#endif /* PUBLIC__H */
|
||||
100
plat/public_bak/src/include/svrstat.h
Normal file
100
plat/public_bak/src/include/svrstat.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
** PACS-WLL 2000 project, WAVEloop System.
|
||||
**
|
||||
** The module Copyright (C) 2000-2001 interWAVE Inc.
|
||||
** Written completely by Zhang Shuzhong at iCRD Sep, 2001
|
||||
**
|
||||
** file name: svrstat.h
|
||||
** CVS $Id: $
|
||||
**
|
||||
** The header file is defination about shared memory
|
||||
** of server state information.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SVRSTAT__H
|
||||
#define SVRSTAT__H
|
||||
|
||||
#define SVRSTAT_SHM_KEY 0x00010000
|
||||
#define SVRSTAT_SHM_PERM 0666
|
||||
#define SVRSTAT_SEM_KEY 0x00010000
|
||||
#define SVRSTAT_SEM_PERM 0666
|
||||
#define SVRSTAT_SEM_NUM 1
|
||||
|
||||
enum _server_state_enum {
|
||||
SS_IDLE,
|
||||
SS_INITIATE,
|
||||
SS_NORMAL,
|
||||
SS_SERVICE_SUSPEND,
|
||||
SS_SERVICE_HALT,
|
||||
SS_SHM_REINITIATE,
|
||||
SS_SERVICE_RESTART,
|
||||
SS_SYSTEM_RESTART,
|
||||
SS_SYSTEM_HALT,
|
||||
};
|
||||
|
||||
enum _oper_state_enum {
|
||||
OS_NO_COMMAND,
|
||||
OS_SET_COMMAND,
|
||||
OS_GOT_COMMAND,
|
||||
OS_FINISHED_COMMAND,
|
||||
OS_REFUSED_COMMAND,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
u_char component_type;
|
||||
u_char component_id;
|
||||
u_char alarm_level;
|
||||
u_char alarm_code;
|
||||
DWORD timestamp;
|
||||
} _alarm_log;
|
||||
|
||||
typedef struct {
|
||||
u_short read_sub;
|
||||
u_short write_sub;
|
||||
_alarm_log alarm_log[16];
|
||||
} _alarm_buffer;
|
||||
|
||||
typedef struct {
|
||||
u_char version[3];
|
||||
DWORD distrib_date;
|
||||
u_char current_state; // Please view server's state enum.
|
||||
// The server's current state.
|
||||
u_char received_state; // State received from OMC.
|
||||
// Please view server's state enum
|
||||
// for detail.
|
||||
u_char oper_state; /* 0: No command.
|
||||
** 1: Agent set command.
|
||||
** 2: Function server got the command.
|
||||
** 3: Function server finished.
|
||||
** 4: Function server refused.
|
||||
** refer to enum of _oper_state_enum
|
||||
*/
|
||||
u_char net_status; // 0/1=normal/abnormal,
|
||||
// status of network
|
||||
u_char rate_progress; // Rate of progress.
|
||||
DWORD time_updated;
|
||||
_alarm_buffer alarm_buffer; // Alarm code
|
||||
} _server_state;
|
||||
|
||||
typedef struct {
|
||||
DWORD time_created; // Heartbeating module set the field
|
||||
DWORD server_list; /* Bit0-15:
|
||||
** Server exist if set '1' in bit
|
||||
** Bit16-31:
|
||||
** 0/1 = Primary/Secondary server.
|
||||
** that base server object id.
|
||||
*/
|
||||
u_char led_state[16]; /* Led's state:
|
||||
** 0: Idle/Disable/Suspend/Halt
|
||||
** 1: Enable/Normal
|
||||
** 2: Initiating/Activated
|
||||
*/
|
||||
u_char port_stat[3];
|
||||
_server_state server_state[16]; /* Subscript of array
|
||||
** base on server object ID
|
||||
*/
|
||||
} _ss_buffer;
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user