This commit is contained in:
zhangsz
2025-03-03 11:01:26 +08:00
parent 5f1710dc22
commit dae6fc93f7
1057 changed files with 519829 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
/*
** PACS-WLL 2000 project, Prepaid System.
**
** The module Copyright (C) 2000-2001 interWAVE Inc.
** Written completely by Zhang Shuzhong at iCRD January, 2001
**
** module name: config.h
** CVS $Id: config.h,v 1.2 2001/01/11 04:07:56 zhangsz Exp $
**
** configuration of Prepaid System.
**
*/
#ifndef CONFIG__H
#define CONFIG__H
#define HAVE_FUNCTION_MACRO 1
#define HAVE_FILE_MACRO 1
#define HAVE_TIME_MACRO 1
#define HAVE_DATE_MACRO 1
#define HAVE_LINE_MACRO 1
#endif /* endof CONFIG__H */

View File

@@ -0,0 +1,37 @@
/*
** PACS-WLL 2000 project, Prepaid System.
**
** The module Copyright (C) 2000-2001 interWAVE Inc.
** Written completely by Zhang Shuzhong at iCRD January, 2001
**
** file name: dbsync.h
** CVS $Id: dbsync.h,v 1.2 2001/02/08 10:53:33 zhangsz Exp $
**
** Defination for Database Synchronization (dbsync.c).
*/
#ifndef DBSYNC__H
#define DBSYNC__H
#include "iptrans.h"
#define DS_PORT_NO 4959 /* Prepaid service port */
#define DS_PORT_ID DS_PORT_NO - PORT_BASE_NUM
#define DS_SHM_KEY 0x80000000
#define DS_SHM_PERM 0664
#define DS_MSG_TYPE "D0"
#define DS_DBNAME_MAX_LEN 14
#define DS_SQLSCRIPT_MAX_LEN MAX_CONTENT_LEN-DS_DBNAME_MAX_LEN-2
typedef struct _dbsync_msg {
char type[2];
char db_name[DS_DBNAME_MAX_LEN];
char sql_script[DS_SQLSCRIPT_MAX_LEN];
} _dbsync_msg;
typedef struct ds_shm {
char time_created[15];
} ds_shm;
#endif /* DBSYNC__H */

View File

@@ -0,0 +1,53 @@
/*
** PACS-WLL 2000 project, Prepaid System.
**
** The module Copyright (C) 2000-2001 interWAVE Inc.
**
** Written completely by Zhang Shuzhong at iCRD January, 2001
**
** file name: debug.h
** CVS $Id: debug.h,v 1.2 2001/01/20 19:58:49 zhangsz Exp $
**
** The debug information defination.
**
*/
#ifndef DEBUG__H
#define DEBUG__H
#include "config.h"
#define UNDER_DEVELOP 1
#define DEBUG 1
/* If we have these macros, we can add additional info to the header. */
#ifdef HAVE_FILE_MACRO
#define FILE_MACRO (__FILE__)
#else
#define FILE_MACRO ("")
#endif
#ifdef HAVE_FUNCTION_MACRO
#define FUNCTION_MACRO (__FUNCTION__)
#else
#define FUNCTION_MACRO ("")
#endif
#ifdef HAVE_DATE_MACRO
#define DATE_MACRO (__DATE__)
#else
#define DATE_MACRO ("")
#endif
#ifdef HAVE_TIME_MACRO
#define TIME_MACRO (__TIME__)
#else
#define TIME_MACRO ("")
#endif
#ifdef HAVE_LINE_MACRO
#define LINE_MACRO (__LINE__)
#else
#define LINE_MACRO ("")
#endif
#endif /* DEBUG__H */

View File

@@ -0,0 +1,39 @@
/*
** Error and log proccess functions header file,
** to be included *after* all standard system headers
**
** CVS: $Id: errlog.h,v 1.2 2001/01/11 04:03:57 zhangsz Exp $
*/
#ifndef ERRLOG__H
#define ERRLOG__H
#include <sys/types.h> /* required for some of our prototypes */
#include <stdio.h> /* for convenience */
#include <stdlib.h> /* for convenience */
#include <string.h> /* for convenience */
#include <unistd.h> /* for convenience */
/* default file access permissions for new files */
#define FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
/* default permissions for new directories */
#define DIR_MODE (FILE_MODE | S_IXUSR | S_IXGRP | S_IXOTH)
#define log_flag() \
log_debug("%s: %s: %d", FILE_MACRO, FUNCTION_MACRO, LINE_MACRO)
void err_dump(const char *, ...); /* {App misc_source} */
void err_msg(const char *, ...);
void err_quit(const char *, ...);
void err_ret(const char *, ...);
void err_sys(const char *, ...);
void log_debug(const char *, ...); /* {App misc_source} */
void log_msg(const char *, ...); /* {App misc_source} */
void log_open(const char *, int, int);
void log_quit(const char *, ...);
void log_sys(const char *, ...);
void log_ret(const char *, ...);
#endif /* ERRLOG__H */

View File

@@ -0,0 +1,127 @@
/*
** CVS: $Id: function.h,v 1.6 2001/02/08 10:53:33 zhangsz Exp $
**
** function.h
** Created at 2000/07/23
** public domain code by Zhang Shuzhong
**
** Description: Header file of function definations.
*/
#ifndef FUNCTION__H
#define FUNCTION__H
#define DisplayContent(buf, bcd_buf, nbytes) \
BcdToAscii(buf, bcd_buf, 2 * nbytes); \
FormatOutput(buf, 2*nbytes, 2, ' '); \
log_debug("packets contains (%s):\n%s", FUNCTION_MACRO, buf);
#define BzeroContent(content, length) \
bzero(content+length, MAX_CONTENT_LEN-length);
#define WriteOutBuffer WriteToOutBuffer
#define WriteToOutBuffer(PROG_NAME, ip_semid, poutbuf, pbuf) \
SemLock(PROG_NAME, ip_semid, PORT_NUM, 1, IPC_NOWAIT); \
WriteMsg((in_buffer *) poutbuf, pbuf, OUT_LIST_NUM); \
SemUnlock(PROG_NAME, ip_semid, PORT_NUM, 1, IPC_NOWAIT); \
SemUnlock(PROG_NAME, ip_semid, SEM_NUM-1, 1, IPC_NOWAIT);
#define ReadInBuffer ReadFromInBuffer
#define ReadFromInBuffer(PROG_NAME, ip_semid, port_id, pinbuf, pbuf) \
SemLock(PROG_NAME, ip_semid, port_id, 1, IPC_NOWAIT); \
ReadMsg((in_buffer *) pinbuf, pbuf, IN_LIST_NUM); \
SemUnlock(PROG_NAME, ip_semid, port_id, 1, IPC_NOWAIT); \
int InitDaemon(void); /* Initialize a daemon process */
void
SetTermSignal(struct termio *ptermio, void (*handler)(int));
/* Initialize a daemon process */
void DaemonInit(const char *pname, int);
/* passive a socket handler, from comfunc.c */
int passivesock( const char * transport, u_short portbase, int qlen);
/* passive a UDP socket handler, from comfunc.c */
int passiveUDP(u_short portbase);
/* Fill string 'c' into last area of 'str'. */
void StringCat(char *str, char *c, int slen);
int ByteLength(BYTE *bcd, int c);
/* Cut string while match character c. */
void StringCut(char *str, int c);
void Bstr2Hstr(char *cptr);
void bitstring(char *str, long byze, int biz, int strwid);
/* Binary string convert to int. */
unsigned int Bstr2Int(char *cptr);
/* Hex string convert to int. */
unsigned int Hstr2Int(char *cptr);
/* Get current hour */
int gethour(char * hour_buf);
int getweek(char * week_buf);
/* Get current hour */
int getmin(char * min_buf);
/* Convert data from ASCII form to left-aligned compact BCD form. */
void AsciiToBcd (BYTE *bcd_buf, const char *ascii_buf, int len);
/* Convert data from left-aligned compact BCD form to ASCII form. */
void BcdToAscii (char *ascii_buf, const BYTE *bcd_buf, int len);
/* Convert data from ASCII form to right-aligned compact BCD form. */
void AsciiToRbcd (BYTE *bcd_buf, const char *ascii_buf, int len);
const char *
getdaytime(char *daytime_buf);
char *GetASCTime(char *timep);
void *
ShmInit(int shm_id, char *prog_name, key_t key, int size, int shmflg);
int
SemInit(char *prog_name, key_t key, int sem_num, int sem_flg);
BOOL
SemLock(char *prog_name, int sem_id, int sem_num,
unsigned nsops, int sem_flg);
BOOL
SemUnlock(char *prog_name, int sem_id, int sem_num,
unsigned nsops, int sem_flg);
BOOL
ReadMsg(void *pbuf, void *pmsg, int max_num);
BOOL
WriteMsg(void *pbuf, void *pmsg, int max_num);
const char *
Inet_ntoa(const long addr);
const long
Inet_pton(const char *sp);
char *
FormatOutput(char *sp, size_t, int, int);
void
ByteReverse(BYTE *p1, BYTE *p2, size_t size);
void
SafeFree(void *pmem);
void
GetAsciiField(char *dest, BYTE *src, size_t n);
#endif

View File

@@ -0,0 +1,47 @@
/*
** CVS $Id: includes.h,v 1.3 2001/02/08 10:53:33 zhangsz Exp $
** includes.h
** Created at 2000-10-17
** by Zhang SZ.
** Include all header files of PACS-WLL 2000 Project.
*/
#ifndef INCLUDES__H
#define INCLUDES__H
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <memory.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/wait.h>
#include <unistd.h>
#include <signal.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <sys/msg.h>
#include <sys/time.h>
#include <time.h>
#include <net/if.h>
#include <syslog.h>
#include <termio.h>
#include <fcntl.h>
#include "public.h"
#include "function.h"
#include "errlog.h"
#include "debug.h"
#ifndef NO_CONFIG_H
#include "config.h"
#endif
#endif /* INCLUDES__H */

View File

@@ -0,0 +1,206 @@
/*
**
**
** file name:
**
** header file include by IP transceiver.
** defination of shared memory structure.
**
*/
#ifndef IPTRANS__H
#define IPTRANS__H
#include "../../../public/src/include/includes.h"
#include "../../../public/src/include/public.h"
#include "../../../public/src/include/pub_fmt.h"
#include "errlog.h"
#include "debug.h"
#ifndef NO_CONFIG_H
#include "config.h"
#endif
#define IN_LIST_NUM 200 /* list number of in_buffer that
can store in the buffer space
*/
#define DS_LIST_NUM IN_LIST_NUM
#define OUT_LIST_NUM 1024 /* list number of out_buffer that
can store in the buffer space
*/
#define PORT_IN_NUM 24 /* number of in port defined */
#define PORT_DS_NUM 1 /* number of port to database sync process */
#define PORT_OUT_NUM 1 /* number of out port defined */
#define PORT_NUM PORT_IN_NUM /* pre-defined port number */
/* Port service */
#define PORT_BASE_NUM 4950 /* minimum port number */
#define MAX_CONTENT_LEN 1514
/* IP transceiver shared memory ipc key and permission */
#define IPTRANS_SHM_KEY 0x60000000
#define IPTRANS_SHM_PERM 0777
#define IPTRANS_DEBUG_SHM 0x61610000
#define IPTRANS_DEBUG_PERM 0664
/* IP transceiver semaphore ipc key and permission */
#define RELEASE 1 /* release semaphore */
#define ACQUIRE -1 /* acquire semaphore */
#define MAX_STATISTICS_SEG 96
#define _msg_list message_list
typedef struct message_list {
long msgSrcIP; /* ip number of source host */
u_short msgSrcPort; /* port of source host */
long msgDstIP; /* ip number of Destination host */
u_short msgDstPort; /* port of Destination host */
int msgBroadcast; /* message sent with broadcast mode,
0(default)/1=no/yes.
*/
u_short msgLength; /* message's length */
BYTE msgContent[MAX_CONTENT_LEN]; /* message of packet received */
} message_list;
typedef struct ds_msg {
long msgSrcIP; /* ip number of source host */
u_short msgSrcPort; /* port of source host */
long msgDstIP; /* ip number of Destination host */
u_short msgDstPort; /* port of Destination host */
int msgBroadcast; /* message sent with broadcast mode,
0(default)/1=no/yes.
*/
u_short msgLength; /* message's length */
char msgContent[MAX_CONTENT_LEN]; /* message of packet received */
} db_msg;
typedef struct ds_buffer {
u_short msgReadSub; /* subscript of array msgList for reader */
u_short msgWriteSub; /* subscript of array msgList for writer */
db_msg msgList[DS_LIST_NUM]; /* message list buffer */
} ds_buffer;
#define _in_buffer in_buffer
typedef struct in_buffer {
u_short msgReadSub; /* subscript of array msgList for reader */
u_short msgWriteSub; /* subscript of array msgList for writer */
message_list msgList[IN_LIST_NUM]; /* message list buffer */
} in_buffer;
#define _out_buffer out_buffer
typedef struct out_buffer {
u_short msgReadSub; /* subscript of array msgList for reader */
u_short msgWriteSub; /* subscript of array msgList for writer */
message_list msgList[OUT_LIST_NUM]; /* message list buffer */
} out_buffer;
#define _port_stat port_stat
typedef struct port_stat {
short portStatus; /* port status:
0=idle 1=normal -1=abnormal
*/
u_long inPackets; /* number of packets received */
u_long inBytes;
u_long outPackets; /* number of packets sent */
u_long outBytes;
u_long errorPackets; /* number of error packets received */
} port_stat;
/*
#define _port_stat port_stat
typedef struct port_stat{
port_stat_15m port_stat_static[PORT_NUM];
}port_stat;
*/
typedef struct debug_info
{
DWORD debug_status_id[20];
BYTE debug_status;
DWORD debug_ascin_id[20];
DWORD debug_ascout_id[20];
DWORD debug_name_id[20];
DWORD debug_page_title[20];
DWORD debug_page_line[20];
BYTE title0_p[1024];
BYTE title1_p[1024];
BYTE title2_p[1024];
BYTE title3_p[1020];
char iptr_asciin_buf[4096];
char iptr_asciout_buf[4096];
BYTE port_onoff[PORT_NUM];
BYTE port_status[PORT_NUM]; //overflow
BYTE resettimer[4];
u_long logflag;
u_long srclog;
u_long dstlog;
}debug_info;
typedef struct port_configure
{
BYTE port_config[PORT_NUM];
}port_configure;
typedef struct iptrans_cdr_rec
{
u_long inPackets;
u_long inBytes;
u_long outPackets;
u_long outBytes;
u_long errorPackets;
}iptrans_cdr_rec;
typedef struct iptrans_cdr_period
{
iptrans_cdr_rec cdr_record[PORT_NUM];
}iptrans_cdr_period;
typedef struct snmp_info
{
BYTE process_conf;
BYTE version[3];
//port_configure port_conf;
//PORT STATUS ; debug_info.port_status
iptrans_cdr_period iptrans_cdr[96];
}snmp_info;
#define _iptrans_shm iptrans_shm
typedef struct iptrans_shm { /* type defination of IP transceiver
shared memory
*/
in_buffer msgPortIn[PORT_NUM]; /* message in_buffer defination,
a port buffer attach only a
application module.
*/
out_buffer msgPortOut;
out_buffer msgPlatPortOut;
} iptrans_shm;
typedef struct _iptrans_status
{
port_stat msgPortStat[PORT_NUM];
debug_info debug_msg;
snmp_info snmp_data;
}iptrans_status;
int iptrans_init();
void iptrans_timer();
int iptrMainInit();
int iptrGetMessage(message_list *msgGet, u_short port);
int iptrDirectRecvMsg(message_list *msgGet, u_short port);
int iptrPutMessage(message_list msgPut);
int iptrDirectSendMsg(message_list msgPut);
int iptrPlatPutMessage(message_list msgPut);
int set_iptrans(BYTE oidlen, DWORD *oid, BYTE *pdata, WORD datalen);
int get_iptrans(BYTE oidlen, DWORD *oid, BYTE *pdata, WORD *vartype);
int trap_iptrans(BYTE oidlen, DWORD *oid_ptr, BYTE *msg_ptr, BYTE msg_len);
int CloseTcpConn();
BOOL iptrSemLock(char *prog_name, int sem_id, int sem_num, unsigned nsops, int sem_flg);
BOOL iptrWriteMsg(void *pbuf, void *pmsg, int max_num);
BOOL iptrSemUnlock(char *prog_name, int sem_id, int sem_num, unsigned nsops, int sem_flg);
BOOL iptrReadMsg(void *pbuf, void *pmsg, int max_num);
int InitSingleSocket(int portno);
int mcast_join(int sockfd, struct sockaddr *sa, socklen_t salen, const char *ifname, u_int ifindex);
#endif /* IPTRANS__H */

View File

@@ -0,0 +1,9 @@
#ifndef _IPTR_FUNCTION
#define _IPTR_FUNCTION
int init_iptrans();
void iptr_timer_IRQ();
void iptrans_close();
#endif