2G ems initial

This commit is contained in:
2024-03-13 09:30:40 +08:00
commit eed6460ad2
1234 changed files with 419571 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
ClearCase CopyAreaDB|4
vobs\r9\plat\iptrans
2
5
3:doc|2|0|0|0|d5b9670cbfa411dc851a001c23e19543|0
2:ut|2|0|0|0|e53969e4bfa411dc851a001c23e19543|0
3:src|2|0|0|0|d6e96760bfa411dc851a001c23e19543|0
8:Makefile|1|11d70a3f1ce|b34|6c55c172|d6496744bfa411dc851a001c23e19543|0
3:lib|2|0|0|0|d6496728bfa411dc851a001c23e19543|0

98
omc/plat/iptrans/Makefile Normal file
View File

@@ -0,0 +1,98 @@
##----------------------------------------------------------##
## ##
## Universal Makefile for module template : V1.6.3 ##
## ##
## Created : Wei Liu 07/04/11 ##
## Revision: [Last]Wei Liu 07/07/07 ##
## ##
##----------------------------------------------------------##
##---------------------------------------------------------------------##
##--------------------------------------
##
## Project correlation(Customer define)
##
##--------------------------------------
## MODULE= [Module Name]
## TYPE = app/plat => Module Type
## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Debug ]
## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Release]
## BUILD = lib/exef => Output file format
## CFG = debug/release => Build Configuration
## SRC_PATH = [Source file path]
## INC_PATH = [Include file path]
## APP_PATH = [App Module path]
## PLT_PATH = [Plat Module path]
## PLT_LIB = [Needed plat lib for Link] => just for test or wxc2main
## APP_LIB = [Needed app lib for Link] => just for test or wxc2main
## LIB_ADD = [Needed Extend lib for Link] => just for test or wxc2main
## PLT_LIB e.g. = haepub fsm mng proto kernel aif mgc mgcp sip rtp \
## 8ecp bicc smpp xapp tcap mtp3 m2ua \
## snmp iptrans debug sccp public
##
## APP_LIB e.g. = msc vlr ssf hlr ae pps mnp smsc vms aas
## LIB_ADD e.g. = -liba3a8 -lm
## OBJ_ADD = [Extend third party object files needed]
## TEST_OBJ_PATH = [module object files Path for test ] => just for test
##---------------------------------------------------------------------##
MODULE = iptrans
TYPE = plat
DBUG_FLAGS_ADD =
RELS_FLAGS_ADD =
##Default commonly as below
BUILD = lib
CFG = debug
PLT_LIB =
APP_LIB =
LIB_ADD =
SRC_PATH = ./src
INC_PATH = ./src/include
PLT_PATH = ../../plat
APP_PATH = ../../mss
OBJ_ADD =
TEST_OBJ_PATH =
PREPROC_CMD =
POSTPROC_CMD =
##---------------------------------------------------------------------##
##--------------------------------------
##
## Make configuration(Customer define)
##
##--------------------------------------
## CCFLAG_SWITCH = on/off => gcc flag show on/off
## COVER_NEED = yes/no => PTF cover report needed
## COVER_REPORT_PATH = [path ] => PTF cover report path
CCFLAG_SWITCH = off
COVER_NEED = no
COVER_REPORT_PATH = ./output
##---------------------------------------------------------------------##
##--------------------------------------
##
## include makefile.rules (Do not change)
##
##--------------------------------------
include Makefile.rules

Binary file not shown.

View File

@@ -0,0 +1,3 @@
#!/bin/bash
#gcc -o iptrans ./src/iptrmain.c -Llib/ -liptrans -L../debug/lib -ldebug -lcurses -L../snmp/lib -lsnmp -L../public/lib -lpublic -lm
gcc -o iptrans ./src/iptrmain.c -Llib/ -liptrans -L../debug/lib -ldebug -L../snmp/lib -lsnmp -L../public/lib -lpublic -lm

BIN
omc/plat/iptrans/iptrans Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,18 @@
ClearCase CopyAreaDB|4
vobs\r9\plat\iptrans\src
2
e
8:signal.c|1|11d70a3f306|2ec|7d67e483|d8a967b4bfa411dc851a001c23e19543|0
9:readmsg.c|1|11d70a3f364|1414|665f1dce|d9d967ecbfa411dc851a001c23e19543|0
8:daemon.c|1|11d70a3f48d|5b1|2e908d67|dd796878bfa411dc851a001c23e19543|0
b:queuefunc.c|1|11d70a3f3f1|aa7|40dd25f6|db096824bfa411dc851a001c23e19543|0
7:include|2|0|0|0|de096894bfa411dc851a001c23e19543|0
7:error.c|1|11d70a3f335|85b|6d837e1c|d94967d0bfa411dc851a001c23e19543|0
9:comfunc.c|1|11d70a3f45e|615|c89ac934|dc39685cbfa411dc851a001c23e19543|0
c:simu_debug.c|1|11d70a3f27a|117|6e58531e|d779677cbfa411dc851a001c23e19543|0
a:iptrmain.c|1|11d70a3f393|7c0|23214b44|da796808bfa411dc851a001c23e19543|0
a:ipmsgfun.c|1|11d70a3f539|59a|2821d3c2|e49969c8bfa411dc851a001c23e19543|0
9:ipcfunc.c|1|11d70a3f2b8|847|be8b6e69|d8196798bfa411dc851a001c23e19543|0
c:mcast_join.c|1|11d70a3f4db|5ef|492dc215|e3696990bfa411dc851a001c23e19543|0
a:errorlog.c|1|11d70a3f4fa|9fe|37b70443|e3f969acbfa411dc851a001c23e19543|0
9:iptrans.c|1|11d70a3f42f|c21e|27cb93c8|e6b482e66cf311dd91a5001c23e19543|0

View File

@@ -0,0 +1,81 @@
/*
** CVS: $Id: comfunc.c,v 1.3 2001/01/20 19:58:49 zhangsz Exp $
**
** Title: comfunc.c
** Author: Zhang Shuzhong
** Date: 2000.07.03
**
** Description: Functions of comunication for PACS WLL.
**
*/
#include "../../public/src/include/includes.h"
/*
** passivesock - allocate & bind a server socket using TCP or UDP
*/
/*@ignore@*/
int
passivesock( const char * transport, u_short portbase, int qlen)
{
struct sockaddr_in sin;
int s, type;
memset(& sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_port = htons(portbase);
sin.sin_addr.s_addr = INADDR_ANY;
bzero(&(sin.sin_zero), 8);
if ( strcmp(transport, "UDP") == 0)
type = SOCK_DGRAM;
else
type = SOCK_STREAM;
s = socket(AF_INET, type, 0);
if (s < 0) {
perror("socket");
return -3;
}
if (bind(s, (struct sockaddr *) & sin, sizeof(sin)) < 0) {
perror("bind");
close(s);
return -4;
}
if (type == SOCK_STREAM && listen(s, qlen) < 0) {
perror("listen");
close(s);
return -5;
}
return s;
}
/*
** passiveUDP - create a passive socket for use in a UDP server
*/
int
passiveUDP(u_short portbase)
{
return (passivesock("UDP", portbase, 0) );
}
const char *
Inet_ntoa(const long addr)
{
struct sockaddr_in sin;
sin.sin_addr.s_addr = addr;
return ((char *) inet_ntoa(sin.sin_addr) );
}
const long
Inet_pton(const char *sp)
{
struct in_addr i_addr;
inet_pton(AF_INET, sp, &i_addr);
return i_addr.s_addr;
}
/*@end@*/

View File

@@ -0,0 +1,65 @@
/*
** CVS: $Id: daemon.c,v 1.4 2001/01/11 04:03:57 zhangsz Exp $
** daemon.c
** created at 2000/08/22
** By Zhang Shuzhong.
** Functions of daemon process.
*/
#include "./include/iptrans.h"
#include <sys/stat.h>
#include <fcntl.h>
#define MAXFD 64
/*@ignore@*/
int
InitDaemon(void)
{
pid_t pid;
if ( (pid = fork()) < 0)
return FAILURE;
else if (pid != 0)
exit(0); /* parent goes bye-bye */
/* child continues */
setsid(); /* become session leader */
// chdir("/"); /* change working direactory */
umask(0); /* clear our file mode creation mask */
return SUCCESS;
}
void
DaemonInit(const char *pname, int facility)
{
int i;
pid_t pid;
if ( (pid = fork()) < 0) /* parent terminates */
err_sys("%s: %s: fork (%d)",
FILE_MACRO, FUNCTION_MACRO, LINE_MACRO);
else if (pid != 0)
exit(0); /* parent goes bye-bye */
/* 41st child continues */
setsid(); /* become session leader */
signal(SIGHUP, SIG_IGN);
if ( (pid = fork()) < 0) /* 1st child terminates */
err_sys("%s: %s: fork (%d)",
FILE_MACRO, FUNCTION_MACRO, LINE_MACRO);
else if (pid != 0)
exit(0); /* 1st child goes bye-bye */
// chdir("/"); /* change working directory */
umask(0); /* clear our file mode creation mask */
for (i = 0; i < MAXFD; i++)
close(i);
openlog(pname, LOG_PID, facility);
}
/*@end@*/

View File

@@ -0,0 +1,114 @@
#include <stdio.h>
#include <errno.h> /* for definition of errno */
#include <stdarg.h> /* ANSI C header file */
#include <string.h>
#include "./include/iptrans.h"
static void err_doit(int, const char *, va_list);
char *pname = NULL; /* caller can set this from argv[0] */
/*
** Nonfatal error related to a system call.
** Print a message and return.
*/
/*@ignore@*/
void
err_ret(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_doit(1, fmt, ap);
va_end(ap);
return;
}
/*
** Fatal error related to a system call.
** Print a message and terminate.
*/
void
err_sys(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_doit(1, fmt, ap);
va_end(ap);
exit(1);
}
/*
** Fatal error related to a system call.
** Print a message, dump core, and terminate.
*/
void
err_dump(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_doit(1, fmt, ap);
va_end(ap);
abort(); /* dump core and terminate */
exit(1); /* shouldn't get here */
}
/*
** Nonfatal error unrelated to a system call.
** Print a message and return.
*/
void
err_msg(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_doit(0, fmt, ap);
va_end(ap);
return;
}
/*
** Fatal error unrelated to a system call.
** Print a message and terminate.
*/
void
err_quit(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_doit(0, fmt, ap);
va_end(ap);
exit(1);
}
/*
** Print a message and return to caller.
** Caller specifies "errnoflag".
*/
static void
err_doit(int errnoflag, const char *fmt, va_list ap)
{
int errno_save;
char buf[MAXLINE];
errno_save = errno; /* value caller might want printed */
vsprintf(buf, fmt, ap);
if (errnoflag)
sprintf(buf+strlen(buf), ": %s", strerror(errno_save));
strcat(buf, "\n");
fflush(stdout); /* in case stdout and stderr are the same */
fputs(buf, stderr);
fflush(NULL); /* flushes all stdio output streams */
return;
}
/*@end@*/

View File

@@ -0,0 +1,131 @@
/* Error routines for programs that can run as a daemon. */
#include <errno.h> /* for definition of errno */
#include <stdarg.h> /* ANSI C header file */
#include <syslog.h>
#include "./include/iptrans.h"
static void log_doit(int, int, const char *, va_list ap);
int debug=1; /* caller must define and set this:
nonzero if interactive, zero if daemon */
int under_develop=1; /* caller must define and set this:
nonzero if under develop, zero if not */
/*@ignore@*/
/* Initialize syslog(), if running as daemon. */
void
log_open(const char *ident, int option, int facility)
{
if (debug == 0)
openlog(ident, option, facility);
}
/*
** Nonfatal error related to a system call.
** Print a message with the system's errno value and return.
*/
void
log_ret(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
log_doit(1, LOG_ERR, fmt, ap);
va_end(ap);
return;
}
/*
** Fatal error related to a system call.
** Print a message and terminate.
*/
void
log_sys(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
log_doit(1, LOG_ERR, fmt, ap);
va_end(ap);
exit(2);
}
/*
** Nonfatal error unrelated to a system call.
** Print a message and return.
*/
void
log_msg(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
log_doit(0, LOG_ERR, fmt, ap);
va_end(ap);
return;
}
/*
** Debug message unrelated to a system call.
** Print a message and return while .
*/
void
log_debug(const char *fmt, ...)
{
va_list ap;
if (!under_develop) return;
va_start(ap, fmt);
log_doit(0, LOG_ERR, fmt, ap);
va_end(ap);
return;
}
/*
** Fatal error unrelated to a system call.
** Print a message and terminate.
*/
void
log_quit(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
log_doit(0, LOG_ERR, fmt, ap);
va_end(ap);
exit(2);
}
/*
** Print a message and return to caller.
** Caller specifies "errnoflag" and "priority".
*/
static void
log_doit(int errnoflag, int priority, const char *fmt, va_list ap)
{
int errno_save;
char buf[MAXLINE];
errno_save = errno; /* value caller might want printed */
vsprintf(buf, fmt, ap);
if (errnoflag)
sprintf(buf+strlen(buf), ": %s", strerror(errno_save));
strcat(buf, "\n");
if (debug) {
fflush(stdout);
fputs(buf, stderr);
fflush(stderr);
} else
syslog(priority, buf);
return;
}
/*@end@*/

View File

@@ -0,0 +1,3 @@
#!/bin/bash
gcc -o iptrans iptrmain.c -L../lib/ -liptrans -L../../debug/lib -ldebug -lcurses -L../../snmp/lib -lsnmp -L../../public/lib -lpublic -lm

View File

@@ -0,0 +1,12 @@
ClearCase CopyAreaDB|4
vobs\r9\plat\iptrans\src\include
2
8
a:iptrfunc.h|1|11d70a3f6bf|7a|61ee278e|e1096920bfa411dc851a001c23e19543|0
8:errlog.h|1|11d70a3f76b|538|fbdb8e2b|e2c96974bfa411dc851a001c23e19543|0
8:dbsync.h|1|11d70a3f72c|39e|e3790e4e|e2396958bfa411dc851a001c23e19543|0
7:debug.h|1|11d70a3f6ee|3d8|2f1d1a9c|e199693cbfa411dc851a001c23e19543|0
9:iptrans.h|1|11d70a3f5c5|1ba8|babffb23|de0968b0bfa411dc851a001c23e19543|0
a:function.h|1|11d70a3f671|d35|d1703d82|e0696904bfa411dc851a001c23e19543|0
8:config.h|1|11d70a3f652|20a|3e469456|dfd968e8bfa411dc851a001c23e19543|0
a:includes.h|1|11d70a3f604|39f|d85a1d82|df3968ccbfa411dc851a001c23e19543|0

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,201 @@
/*
**
**
** 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 {
unsigned int msgSrcIP; //long msgSrcIP; /* ip number of source host */
u_short msgSrcPort; /* port of source host */
unsigned int msgDstIP; //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 {
unsigned int msgSrcIP; //long msgSrcIP; /* ip number of source host */
u_short msgSrcPort; /* port of source host */
unsigned int msgDstIP; //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
*/
DWORD inPackets; /* number of packets received */
DWORD inBytes;
DWORD outPackets; /* number of packets sent */
DWORD outBytes;
DWORD 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];
DWORD logflag;
DWORD srclog;
DWORD dstlog;
}debug_info;
typedef struct port_configure
{
BYTE port_config[PORT_NUM];
}port_configure;
typedef struct iptrans_cdr_rec
{
DWORD inPackets;
DWORD inBytes;
DWORD outPackets;
DWORD outBytes;
DWORD 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, int 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();
extern void *iptrShmInit(int shm_id, char *prog_name, key_t key, int size, int shmflg);
#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

View File

@@ -0,0 +1,93 @@
/*
** CVS $Id: ipcfunc.c,v 1.4 2001/01/20 19:58:49 zhangsz Exp $
**
** ipcfunc.c
** created at 2000/12/20
** by Zhang SZ
**
** IPC functions for PACS-WLL project.
**
*/
#include "./include/iptrans.h"
/*@ignore@*/
void *
iptrShmInit(int shm_id, char *prog_name, key_t key, int size, int shmflg)
{
void *retp;
char *func_name = "ShmInit";
shm_id = shmget(key, size, shmflg);
if (shm_id == -1)
{
log_sys("%s: %s: shmget(key: %x)", prog_name, func_name, key);
return NULL;
}
retp = shmat(shm_id, (char *)0, 0);
if (retp == (void *) -1)
{
log_sys("%s: %s: shmat", prog_name, func_name);
return NULL;
}
return retp;
}
int
iptrSemInit(char *prog_name, key_t key, int sem_num, int sem_flg)
{
int initarray[sem_num];
int sem_id, retval, i;
char *func_name = "SemInit";
sem_id = semget(key, sem_num, sem_flg);
if (sem_id == -1)
log_sys("%s: %s: semget", prog_name, func_name);
for (i=0; i<sem_num; i++) {
initarray[i] = 1;
retval = semctl(sem_id, i, SETVAL, initarray[i]);
if (retval == -1)
log_sys("%s: %s: semctl", prog_name, func_name);
}
return sem_id;
}
BOOL
iptrSemLock(char *prog_name, int sem_id, int sem_num, unsigned nsops, int sem_flg)
{
int retval;
struct sembuf lock = {0, ACQUIRE, SEM_UNDO};
lock.sem_num = sem_num;
lock.sem_flg |= sem_flg;
retval = semop(sem_id, &lock, nsops);
if (retval == -1) {
// char *func_name = "SemLock";
// log_ret("%s: %s: semop(%d)", prog_name, func_name, sem_num);
return FAILURE;
}
return SUCCESS;
}
BOOL
iptrSemUnlock(char *prog_name, int sem_id, int sem_num, unsigned nsops, int sem_flg)
{
int retval;
struct sembuf unlock = {0, RELEASE, IPC_NOWAIT|SEM_UNDO};
unlock.sem_num = sem_num;
unlock.sem_flg |= sem_flg;
retval = semop(sem_id, &unlock, nsops);
if (retval == -1) {
// char *func_name = "SemUnlock";
// log_ret("%s: %s: semop(%d)", prog_name, func_name, sem_num);
return FAILURE;
}
return SUCCESS;
}
/*@end@*/

View File

@@ -0,0 +1,51 @@
#include <sys/ipc.h>
#include "./include/iptrans.h"
static iptrans_shm *IPTRANS_shm_ptr;
static int IPTRANS_shm_id;
/*@ignore@*/
int iptransCreate()
{
IPTRANS_shm_ptr = (iptrans_shm *)ShmInit(IPTRANS_shm_id,"iptrans",IPTRANS_SHM_KEY,
sizeof(iptrans_shm),IPTRANS_SHM_PERM | IPC_CREAT);
}
int GetMessage(message_list *msgGet,int port_in)
{
int port;
port=port_in-PORT_BASE_NUM;
if(IPTRANS_shm_ptr->msgPortIn[port].msgReadSub !=
IPTRANS_shm_ptr->msgPortIn[port].msgWriteSub)
{
memcpy(msgGet,
&IPTRANS_shm_ptr->msgPortIn[port].msgList[IPTRANS_shm_ptr->msgPortIn[port].msgReadSub],
sizeof(struct message_list));
IPTRANS_shm_ptr->msgPortIn[port].msgReadSub++;
if(IPTRANS_shm_ptr->msgPortIn[port].msgReadSub==IN_LIST_NUM)
IPTRANS_shm_ptr->msgPortIn[port].msgReadSub=0;
return 1;
}
return 0;
}
int PutMessage(message_list msgPut)
{
memcpy(&IPTRANS_shm_ptr->msgPortOut.msgList[IPTRANS_shm_ptr->msgPortOut.msgWriteSub],
&msgPut, sizeof(struct message_list));
IPTRANS_shm_ptr->msgPortOut.msgWriteSub ++;
if(IPTRANS_shm_ptr->msgPortOut.msgWriteSub==OUT_LIST_NUM)
IPTRANS_shm_ptr->msgPortOut.msgWriteSub=0;
return 0;
}
int clearPort(int port_in)
{
int port;
port=port_in-PORT_BASE_NUM;
IPTRANS_shm_ptr->msgPortIn[port].msgReadSub=0;
IPTRANS_shm_ptr->msgPortIn[port].msgWriteSub=0;
return 1;
}
/*@end@*/

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -0,0 +1,100 @@
#include "./include/iptrans.h"
extern void iptrans_timer();
/*@ignore@*/
void init_timer_interrupt(void)
{
struct sigaction newact;
newact.sa_handler =iptrans_timer;
newact.sa_flags =0;
sigemptyset(&newact.sa_mask);
sigaction(SIGALRM,&newact,NULL);
}
void setup_interval_timer(void)
{
struct itimerval value;
value.it_interval.tv_sec =0;
value.it_interval.tv_usec =10*1000;
value.it_value.tv_sec = 0;
value.it_value.tv_usec = 10*1000;
setitimer(ITIMER_REAL,&value,NULL);
}
void init_timer()
{
init_timer_interrupt();
setup_interval_timer();
}
void interrupt_handler(int signo)
{
CloseTcpConn();
}
int initSystem()
{
struct sigaction act;
//close(0);
//close(1);
//close(2);
act.sa_handler = interrupt_handler;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
if(sigaction(SIGPIPE,&act,NULL)<0)
fprintf(stderr,"set signal failed\n");
system("sysctl -w net.ipv4.tcp_keepalive_time=20");
system("sysctl -w net.ipv4.tcp_keepalive_probes=2");
return 1;
}
int
main(int argc, char *argv[])
{
int err_flag = FALSE;
int test_mode = FALSE;
int ret;
SetDebugFlag();
/*
** Get option from command line.
** option 'd' is enable to run program with daemon mode.
*/
while ((ret = getopt(argc, argv, "dt")) != -1)
switch (ret)
{
case 'd':
/* Set daemon mode and open a syslog */
DaemonInit("IPTRANS", LOG_USER);
break;
case 't':
test_mode = TRUE; /* test mode: bind port 4950 to recvfrom */
break;
case '?':
err_flag = TRUE;
}
if (err_flag) {
log_msg("Usage: %s -d -t \n", argv[0]);
log_msg(" -d with daemon mode");
log_msg(" -t with test mode");
exit(1);
}
debug_init();
initSystem();
iptrMainInit();
init_timer();
while(1){
usleep(1);
}
exit(0);
}
/*@end@*/

View File

@@ -0,0 +1,59 @@
#include "./include/iptrans.h"
/*@ignore@*/
int
mcast_join(int sockfd, struct sockaddr *sa, socklen_t salen,
const char *ifname,u_int ifindex)
{
u_char flag=1;
int len;
struct hostent *myhost;
switch(sa->sa_family)
{
case AF_INET:{
struct ip_mreq mreq;
struct ifreq ifreq;
memcpy(&mreq.imr_multiaddr,
&((struct sockaddr_in *)sa)->sin_addr,
sizeof(struct in_addr));
if(ifindex>0){
if(if_indextoname(ifindex,ifreq.ifr_name)==NULL){
// errno=ENXIO;
return(-1);
}
goto doioctl;
}
else if(ifname !=NULL){
strncpy(ifreq.ifr_name,ifname,IFNAMSIZ);
doioctl:
if(ioctl(sockfd,SIOCGIFADDR,&ifreq)<0)
return (-1);
memcpy(&mreq.imr_interface.s_addr,
&((struct sockaddr_in *)&ifreq.ifr_addr)->sin_addr,
sizeof(struct in_addr));
return (setsockopt(sockfd,IPPROTO_IP,IP_ADD_MEMBERSHIP,
&mreq,sizeof(mreq)));
}
else
mreq.imr_interface.s_addr=htonl(INADDR_ANY);// inet_addr(name);
// setsockopt(sockfd,IPPROTO_IP,IP_MULTICAST_IF,&flag,sizeof(flag));
return (setsockopt(sockfd,IPPROTO_IP,IP_ADD_MEMBERSHIP,
&mreq,sizeof(mreq)));
}
default:
// errno=EPROTONOSUPPORT;
return(-1);
}
}
int
mcast_set_loop(int sockfd, int onoff)
{
u_char flag;
flag=onoff;
return (setsockopt(sockfd,IPPROTO_IP,IP_MULTICAST_LOOP,
&flag,sizeof(flag)));
}
/*@end@*/

View File

@@ -0,0 +1,133 @@
/*
** CVS $Id: queuefunc.c,v 1.3 2001/02/08 10:53:33 zhangsz Exp $
**
** filename: queuefunc.c
** created at 2000/12/29
** by Zhang Shuzhong
**
** loop message queue operating functions.
**
*/
#include "./include/iptrans.h"
extern u_char warningFlag;
/*@ignore@*/
/* Read a message from loop queue. */
BOOL
iptrReadMsg(void *pbuf, void *pmsg, int max_num)
{
in_buffer *p;
message_list *msg_ptr;
p = (in_buffer *) pbuf;
msg_ptr = (message_list *) pmsg;
// memset(msg_ptr, EMPTY, sizeof(struct message_list));
/*
** these are some messages not to be read
** while subscript of read isn't equal to subscipt of write.
*/
if (p->msgReadSub == p->msgWriteSub)
return FAILURE;
memcpy(msg_ptr, &p->msgList[p->msgReadSub],
p->msgList[p->msgReadSub].msgLength + 44);
/*message head length */
// sizeof(struct message_list));
/*
** increase READ SUBSCRIPT after got a message,
** set READ SUBSCRIPT to 0 while it equal to max_num.
*/
p->msgReadSub ++;
if (p->msgReadSub == max_num)
p->msgReadSub = 0;
return SUCCESS;
}
/* Write a message to loop queue. */
BOOL
iptrWriteMsg(void *pbuf, void *pmsg, int max_num)
{
in_buffer *p;
message_list *msg_ptr;
int port;
p = (in_buffer *) pbuf;
msg_ptr = (message_list *) pmsg;
memcpy(&p->msgList[p->msgWriteSub], msg_ptr,
msg_ptr->msgLength + 44);//sizeof(struct message_list));
p->msgWriteSub ++;
/*
** if write subscript more than max_num,
** write subscript equal 0.
*/
if (p->msgWriteSub == max_num)
p->msgWriteSub = 0;
/*
** if message written successful,
** Read subscript is same as Write subscript,
** then Read subsrcipt add 1.
*/
if (p->msgReadSub == p->msgWriteSub)
{
(p->msgReadSub == max_num-1) ?
(p->msgReadSub = 0) : (p->msgReadSub ++);
if(warningFlag){
port = msg_ptr->msgDstPort;
SetAsciioutMsg(1,"Warning! Port: %d overflowed!\r\n",port);
return 0;
}
}
return 1;
}
void
iptrByteRev(BYTE *pbuf, BYTE *p, size_t size)
{
int i;
char ch;
for (i=0; i<size; i++) {
ch = *(pbuf++) >> 4;
*pbuf <<= 4;
*pbuf &= ch;
}
memcpy(p, pbuf, size);
}
void
iptrStrrev(char *sp)
{
char ch;
ch = sp[0];
sp[0] = sp[1];
sp[1] = ch;
}
void
iptrByteReverse(BYTE *pbuf, BYTE *p, size_t size)
{
int i;
char *sp=NULL, tmpbuf[3];
sp = (char *) malloc(4*size + 1);
bzero(p, size);
for (i=0; i<2*size; i+=2) {
sprintf(tmpbuf, "%02x", *(pbuf++));
tmpbuf[2]=0;
iptrStrrev(tmpbuf);
strncpy(sp+i, tmpbuf, 2);
}
AsciiToBcd(pbuf, sp, 4*size);
memcpy(p, pbuf, 2*size);
free(sp);
}
/*@end@*/

View File

@@ -0,0 +1,189 @@
/*
** 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: iptrans.c
** CVS: $Id: iptrans.c,v 1.9 2001/02/09 08:53:43 zhangsz Exp $
**
** Description: IP transceiver common module of PACS-WLL Project.
**
*/
#include "./include/iptrans.h"
#define PROG_NAME "iptrans"
extern int debug; /* defined in errorlog.c */
extern int under_develop; /* defined in errorlog.c */
static int iptrans_shm_id;
static int iptrans_sem_id;
static struct termio prev_termio;
static iptrans_shm *iptrans_shm_ptr;
int GetMessage(message_list *msgGet,int port);
void PutMessage(message_list msgPut);
/*@ignore@*/
/* Set debug flag to control debug message print or not */
void SetDebugFlag(void)
{
debug = DEBUG; /* DEBUG defined in debug.h */
under_develop = UNDER_DEVELOP; /* UNDER_DEVELOP defined in debug.h */
}
/*
** Handler of terminatation,
** process while received a signal from user.
*/
static void Terminate(int sig)
{
int retval, i;
usleep(100000);
retval = (int) shmdt(0);
if (retval == -1) log_ret("%s: %s: shmdt", PROG_NAME, FUNCTION_MACRO);
retval = shmctl(iptrans_shm_id, IPC_RMID, NULL);
if (retval == -1) log_ret("%s: %s: shmctl", PROG_NAME, FUNCTION_MACRO);
retval = semctl(iptrans_sem_id, PORT_NUM, IPC_RMID, NULL);
if (retval == -1) log_ret("%s: %s: semctl", PROG_NAME, FUNCTION_MACRO);
exit(sig);
}
int GetMessage(struct message_list *msgGet,int port)
{
message_list msgSend;
if(iptrans_shm_ptr->msgPortIn[port].msgReadSub != iptrans_shm_ptr->msgPortIn[port].msgWriteSub)
{
memcpy(msgGet,
&iptrans_shm_ptr->msgPortIn[port].msgList[iptrans_shm_ptr->msgPortIn[port].msgReadSub],
sizeof(struct message_list));
memcpy(&msgSend,msgGet,sizeof(struct message_list));
PutMessage(msgSend);
fprintf(stderr,"Recv msg %d.\n",port+4951);
iptrans_shm_ptr->msgPortIn[port].msgReadSub ++;
if(iptrans_shm_ptr->msgPortIn[port].msgReadSub==IN_LIST_NUM)
iptrans_shm_ptr->msgPortIn[port].msgReadSub =0;
/*
fprintf(stderr,"iptrans state:\n port=%d\n packet in=%ld out=%ld errors=%ld %ld\n",
port,
iptrans_shm_ptr->msgPortStat[port].inPackets,
iptrans_shm_ptr->msgPortStat[port].outPackets,
iptrans_shm_ptr->msgPortStat[port].errorInPackets,
iptrans_shm_ptr->msgPortStat[port].errorOutPackets);
*/
return 1;
}
else
{
return 0;
}
}
void PutMessage(struct message_list msgPut)
{
memcpy(&iptrans_shm_ptr->msgPortOut.msgList[iptrans_shm_ptr->msgPortOut.msgWriteSub],
&msgPut,sizeof(struct message_list));
iptrans_shm_ptr->msgPortOut.msgWriteSub ++;
if(iptrans_shm_ptr->msgPortOut.msgWriteSub==OUT_LIST_NUM)
iptrans_shm_ptr->msgPortOut.msgWriteSub=0;
}
void timer_IRQ()
{
int i;
struct message_list msgList;
for(i=0;i<13;i++)
{
GetMessage(&msgList,i);
// PutMessage(msgList);
}
}
void init_timer_interrupt(void)
{
struct sigaction newact;
newact.sa_handler =timer_IRQ;
newact.sa_flags =0;
sigemptyset(&newact.sa_mask);
sigaction(SIGALRM,&newact,NULL);
}
void setup_interval_timer(void)
{
struct itimerval value;
value.it_interval.tv_sec =0;
value.it_interval.tv_usec =5*1000;
value.it_value =value.it_interval;
setitimer(ITIMER_REAL,&value,NULL);
}
void init_timer()
{
init_timer_interrupt();
setup_interval_timer();
}
int
main(int argc, char *argv[])
{
int err_flag = FALSE;
int test_mode = FALSE;
int ret;
SetDebugFlag();
/*
** Get option from command line.
** option 'd' is enable to run program with daemon mode.
*/
while ((ret = getopt(argc, argv, "dt")) != -1)
switch (ret)
{
case 'd':
/* Set daemon mode and open a syslog */
DaemonInit(PROG_NAME, LOG_USER);
break;
case 't':
test_mode = TRUE; /* test mode: bind port 4950 to recvfrom */
break;
case '?':
err_flag = TRUE;
}
if (err_flag) {
log_msg("Usage: %s -d -t \n", argv[0]);
log_msg(" -d with daemon mode");
log_msg(" -t with test mode");
exit(1);
}
/*
** Get shared memory block,
** IPTRANS_SHM_KEY to be defined in iptrans.h.
*/
iptrans_shm_ptr = (iptrans_shm *) ShmInit(iptrans_shm_id, PROG_NAME,
IPTRANS_SHM_KEY, sizeof(iptrans_shm), IPTRANS_SHM_PERM|IPC_CREAT);
memset(iptrans_shm_ptr, 0, sizeof(iptrans_shm));
/*
** Get semaphores ID used by shared memory block,
** IPTRANS_SEM_KEY to be defined in iptrans.h.
*/
SetTermSignal(&prev_termio, Terminate);
/*
** Open socket handler for IP transceiver.
** maxinum number is PORT_NUM.
*/
init_timer();
while(1){
usleep(1);
}
exit(0);
}
/*@end@*/

View File

@@ -0,0 +1,33 @@
/*
** 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: signal.c
** CVS $Id: signal.c,v 1.2 2001/01/11 04:07:56 zhangsz Exp $
**
** Signal functions
**
*/
#include "./include/iptrans.h"
/*
** Set termination signal in a loop program,
** handler of function mostly deal with something,
** e.g. closing file handler, socket handler or free allocatied memory.
*/
/*@ignore@*/
void
SetTermSignal(struct termio *ptermio, void (*handler)(int))
{
ioctl(0, TCGETA, ptermio);
ptermio->c_cc[VINTR] = '\x03';
ioctl(0, TCSETA, ptermio);
signal(SIGINT, handler);
signal(SIGTERM, handler);
}
/*@end@*/

View File

@@ -0,0 +1,21 @@
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
/*@ignore@*/
int main()
{
debug_init();
init_iptrans();
snmp_init(4957);
// heartbeat_init(0);
while(1)
{
debug_rt();
snmp_timer();
// heartbeat_timer();
usleep(1);
}
return 1;
}
/*@end@*/