init ems server code
This commit is contained in:
24
src/README.md
Normal file
24
src/README.md
Normal file
@@ -0,0 +1,24 @@
|
||||
ALTER TABLE `OBJ_503`.`paramConf`
|
||||
MODIFY COLUMN `desc_1` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '' AFTER `name_2`,
|
||||
MODIFY COLUMN `desc_2` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '' AFTER `desc_1`,
|
||||
MODIFY COLUMN `initValue` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '' AFTER `valueType`,
|
||||
MODIFY COLUMN `minValue` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '' AFTER `initValue`,
|
||||
MODIFY COLUMN `maxValue` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '' AFTER `minValue`,
|
||||
MODIFY COLUMN `setTemplate_1` text CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL AFTER `maxValue`,
|
||||
MODIFY COLUMN `setTemplate_2` text CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL AFTER `setTemplate_1`;
|
||||
|
||||
ALTER TABLE `OBJ_223`.`paramConf`
|
||||
MODIFY COLUMN `valueType` smallint NOT NULL DEFAULT 0 AFTER `operType`;
|
||||
|
||||
ALTER TABLE `OBJ_390`.`paramConf`
|
||||
MODIFY COLUMN `note_1` varchar(200) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '' AFTER `setTemplate_2`,
|
||||
MODIFY COLUMN `note_2` varchar(200) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '' AFTER `note_1`;
|
||||
|
||||
ALTER TABLE `OBJ_390`.`paramConf`
|
||||
MODIFY COLUMN `note_1` text CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL AFTER `setTemplate_2`,
|
||||
MODIFY COLUMN `note_2` text CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL AFTER `note_1`;
|
||||
|
||||
|
||||
ALTER TABLE `OBJ_390`.`paramConf`
|
||||
MODIFY COLUMN `note_1` text CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL AFTER `setTemplate_2`,
|
||||
MODIFY COLUMN `note_2` text CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL AFTER `note_1`;
|
||||
90
src/accountMgr/c_program/cdrCollector/Makefile
Normal file
90
src/accountMgr/c_program/cdrCollector/Makefile
Normal file
@@ -0,0 +1,90 @@
|
||||
#/bin/sh
|
||||
|
||||
# Makefile for CDR Module.
|
||||
|
||||
CC = gcc
|
||||
CFLAGS=-g -Wall -I/usr/local/mysql/include
|
||||
CFLAGS.ES=-g -Wall -I/usr/include/mariadb
|
||||
|
||||
COMPILE.c=$(CC) $(CFLAGS)
|
||||
COMPILE.c.ES=$(CC) $(CFLAGS.ES)
|
||||
|
||||
LINK.c=$(CC) $(CFLAGS)
|
||||
LINK.c.ES=$(CC) $(CFLAGS.ES)
|
||||
|
||||
LINKFLAG=-L../../../omcLib/c_program/omcLib -lomcLib \
|
||||
-L../../../omcLib/c_program/ftp -lftp \
|
||||
-L../../../../wxc2plat/snmp -lsnmp \
|
||||
-L../../../../wxc2plat/debug -ldebug \
|
||||
-L../../../../wxc2plat/iptrans -liptrans \
|
||||
-L../../../../wxc2plat/public -lpublic \
|
||||
-L/usr/local/mysql/lib -lmariadbclient -lz
|
||||
|
||||
LINKFLAG.ES=-L../../../omcLib/c_program/omcLib -lomcLib \
|
||||
-L../../../omcLib/c_program/ftp -lftp \
|
||||
-L../../../../plat/snmp/lib -lsnmp \
|
||||
-L../../../../plat/debug/lib -ldebug \
|
||||
-L../../../../plat/sccp/lib -lsccp \
|
||||
-L../../../../plat/iptrans/lib -liptrans \
|
||||
-L../../../../plat/public/lib -lpublic \
|
||||
-L/usr/lib/mysql -lmariadbclient -lz
|
||||
|
||||
PROGS=cdrCollector
|
||||
CDR_OBJ = cdr.o cdrdb.o
|
||||
CDR_OBJ.ES = cdr.o.ES cdrdb.o.ES
|
||||
|
||||
default: linuxES
|
||||
|
||||
all:
|
||||
@echo " **** Compiling $(PROGS) ****"
|
||||
@echo "make clean -- Delete the target files(*.o, *.a)"
|
||||
@echo "make linux72 -- Generate target files for Redhat Linux 7.2"
|
||||
@echo "make linuxES -- Generate target files for Redhat ES 4.0"
|
||||
|
||||
linux72: $(CDR_OBJ) cdrmain.o
|
||||
@cd ../../../omcLib/c_program/ftp; make linux72; cd ..
|
||||
@cd ../../../accountMgr/c_program/cdrCollector;
|
||||
@echo Linking $(PROGS)
|
||||
@$(LINK.c) -o $(PROGS) cdrmain.o $(CDR_OBJ) $(LINKFLAG) -lm
|
||||
ar r libcdr.a $(CDR_OBJ)
|
||||
rm -rf *.o
|
||||
rm -rf *bak
|
||||
rm -rf *~
|
||||
cp -f $(PROGS) ../../../bin
|
||||
cp -f $(PROGS) /usr/local/omc/bin/
|
||||
|
||||
linuxES: $(CDR_OBJ.ES) cdrmain.o.ES
|
||||
@cd ../../../omcLib/c_program/ftp; make linuxES; cd ..
|
||||
@cd ../../../accountMgr/c_program/cdrCollector;
|
||||
@echo Linking $(PROGS)
|
||||
@$(LINK.c.ES) -o $(PROGS) cdrmain.o $(CDR_OBJ) $(LINKFLAG.ES) -lm
|
||||
ar r libcdr.a $(CDR_OBJ)
|
||||
|
||||
installbin: linuxES
|
||||
cp -f $(PROGS) ../../../../bin/
|
||||
|
||||
installomc: linuxES
|
||||
cp -f $(PROGS) /usr/local/omc/bin/
|
||||
|
||||
installall: installbin installomc
|
||||
|
||||
cdrmain.o: cdrmain.c
|
||||
$(COMPILE.c) -c cdrmain.c
|
||||
|
||||
cdr.o: cdr.c cdr.h
|
||||
$(COMPILE.c) -c cdr.c
|
||||
|
||||
cdrmain.o.ES: cdrmain.c
|
||||
$(COMPILE.c.ES) -c cdrmain.c
|
||||
|
||||
cdr.o.ES: cdr.c cdr.h
|
||||
$(COMPILE.c.ES) -c cdr.c
|
||||
|
||||
cdrdb.o.ES: cdrdb.c
|
||||
$(COMPILE.c.ES) -c cdrdb.c
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(PROGS)
|
||||
@cd ../../../omcLib/c_program/ftp; rm -f *.o *.a; cd ..
|
||||
@cd ../../../accountMgr/c_program/cdrCollector;rm -f *.o *.a; cd ..
|
||||
|
||||
2494
src/accountMgr/c_program/cdrCollector/cdr.c
Normal file
2494
src/accountMgr/c_program/cdrCollector/cdr.c
Normal file
File diff suppressed because it is too large
Load Diff
145
src/accountMgr/c_program/cdrCollector/cdr.h
Normal file
145
src/accountMgr/c_program/cdrCollector/cdr.h
Normal file
@@ -0,0 +1,145 @@
|
||||
|
||||
|
||||
#ifndef __CDR_HEAD_FILE
|
||||
#define __CDR_HEAD_FILE
|
||||
|
||||
#include "mysql.h"
|
||||
#include "errmsg.h"
|
||||
#include <dirent.h>
|
||||
#include "../../../../plat/public/src/include/asn1.h"
|
||||
#include "../../../../plat/snmp/src/include/snmp.h"
|
||||
#include "../../../../plat/public/src/include/pub_include.h"
|
||||
#include "../../../omcLib/c_program/omcLib/omcLib.h"
|
||||
|
||||
#ifndef _T_DWORD
|
||||
#define _T_DWORD
|
||||
typedef unsigned int DWORD;
|
||||
#endif
|
||||
|
||||
/* Added for show version by Simon
|
||||
* --Begin
|
||||
*/
|
||||
#define CDRCOLLECTOR_VERSION "1.2311.15"
|
||||
/* --End
|
||||
*
|
||||
*/
|
||||
|
||||
#define CDR_DEBUG 0
|
||||
|
||||
#define MAX_CDR_PTR 0x7FFFFFFF
|
||||
#define CDR_PORT 4968
|
||||
#define MAX_TAG_VALUE 32
|
||||
#define MAX_FLD_NUM 128
|
||||
#define MAX_PROCESS_CDR_NUM 256
|
||||
#define MAX_SNMP_MSG_NUM 64
|
||||
#define MAX_BIND_VAR_NUM 16
|
||||
#define MAX_SRC_NUM 32
|
||||
#define MAX_SYS_NUM 128
|
||||
#define MAX_SQL_COMM_NUM 256
|
||||
#define MAX_RETRY 300
|
||||
#define MAX_MSG_TIMEOUT 20
|
||||
#define MAX_IDLE_TIMEOUT 5
|
||||
#define INSTANT_TIMEOUT -1
|
||||
#define HOST_NAME "localhost"
|
||||
#define CDRDB_NAME "CDR_DB"
|
||||
#define CSV_PATH "/usr/local/cdr"
|
||||
#define CDR_LOG_PATH "../log"
|
||||
#define CDR_LOG_FILE "cdrlog"
|
||||
|
||||
|
||||
#define OMC_SINGLE 7
|
||||
#define OMC_MASTER 5
|
||||
|
||||
#define STATE_IDLE 0
|
||||
#define STATE_INFO_GET 1
|
||||
#define STATE_INFO_RESPONSE 2
|
||||
#define STATE_CDR_GET 3
|
||||
#define STATE_CDR_RESPONSE 4
|
||||
#define STATE_TAIL_SET 5
|
||||
#define STATE_TAIL_RESPONSE 6
|
||||
#define STATE_RESET_SET 7
|
||||
#define STATE_RESET_RESPONSE 8
|
||||
|
||||
void cdr_timer();
|
||||
void cdr_init();
|
||||
|
||||
typedef struct field_def
|
||||
{
|
||||
char fieldName[64];
|
||||
char type;
|
||||
char optional;
|
||||
int width;
|
||||
char tags[MAX_TAG_VALUE][24];
|
||||
char tagFlag[MAX_TAG_VALUE];
|
||||
}field_def;
|
||||
|
||||
typedef struct cdr_def
|
||||
{
|
||||
char tags[MAX_TAG_VALUE];
|
||||
char allFieldList[8192];
|
||||
char outFieldList[8192];
|
||||
int fieldCount;
|
||||
field_def fields[MAX_FLD_NUM];
|
||||
}cdr_def;
|
||||
|
||||
typedef struct cdr_src
|
||||
{
|
||||
char dataPotOid[128];
|
||||
char headPotOid[128];
|
||||
char tailPotOid[128];
|
||||
DWORD dataOid[32];
|
||||
DWORD headOid[32];
|
||||
DWORD tailOid[32];
|
||||
BYTE dataOidLen;
|
||||
BYTE headOidLen;
|
||||
BYTE tailOidLen;
|
||||
int bufferSize;
|
||||
int sysTypeNo;
|
||||
int port;
|
||||
char recordTable[64];
|
||||
char defineTable[64];
|
||||
char csvPath[128];
|
||||
int version;
|
||||
|
||||
cdr_def define;
|
||||
}cdr_src;
|
||||
|
||||
typedef struct cdr_sys
|
||||
{
|
||||
int cdrSrcNo;
|
||||
int sysTypeNo;
|
||||
int sysNo;
|
||||
int subSysNo;
|
||||
|
||||
char ip[24];
|
||||
snmp_addr addr;
|
||||
DWORD requestId;
|
||||
int timeout;
|
||||
int retry;
|
||||
|
||||
DWORD head;
|
||||
DWORD tail;
|
||||
DWORD tmptail;
|
||||
int prepareSetTail;
|
||||
int isVarTooBig;
|
||||
int maxVarNum;
|
||||
int state;
|
||||
int processNum;
|
||||
int error;
|
||||
|
||||
}cdr_sys;
|
||||
|
||||
typedef struct msg
|
||||
{
|
||||
snmp_pdu pdu;
|
||||
unsigned char use;
|
||||
int timeout;
|
||||
}msg;
|
||||
|
||||
typedef struct sql_comm_buf
|
||||
{
|
||||
char sqlstr[MAX_SQL_COMM_NUM][8192];
|
||||
int commNum;
|
||||
}sql_comm_buf;
|
||||
|
||||
#endif
|
||||
1534
src/accountMgr/c_program/cdrCollector/cdrdb.c
Normal file
1534
src/accountMgr/c_program/cdrCollector/cdrdb.c
Normal file
File diff suppressed because it is too large
Load Diff
132
src/accountMgr/c_program/cdrCollector/cdrmain.c
Normal file
132
src/accountMgr/c_program/cdrCollector/cdrmain.c
Normal file
@@ -0,0 +1,132 @@
|
||||
/*************************************************
|
||||
File name: cdr.c
|
||||
Author:
|
||||
Version: 9:00:00
|
||||
Date: 2002-5-7
|
||||
Description:cdrCollectorģ<72><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>snmp<6D><70>iptransģ<73>飬<EFBFBD><E9A3AC><EFBFBD><EFBFBD>cdr.c<><63><EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD>
|
||||
<09><><EFBFBD>嶨ʱ<E5B6A8><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD>ʱ
|
||||
|
||||
<09><><EFBFBD><EFBFBD><EFBFBD>ⲿģ<E2B2BF><C4A3><EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD>
|
||||
void snmp_init(WORD nport);
|
||||
void iptrans_init();
|
||||
|
||||
|
||||
History:
|
||||
No.
|
||||
Author:
|
||||
Date:
|
||||
Version:
|
||||
Description:
|
||||
*************************************************/
|
||||
|
||||
#include "cdr.h"
|
||||
|
||||
static struct itimerval itimer, old_itimer;
|
||||
static void On_Timer();
|
||||
static void SetTimer();
|
||||
|
||||
/*************************************************
|
||||
Function: // main
|
||||
Description: // <20><>ʼ<EFBFBD><CABC>snmp<6D><70>iptransģ<73><C4A3>,<2C><>ʼ<EFBFBD><CABC><EFBFBD>ö<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Calls: // iptrans_init; snmp_init;
|
||||
Called By: //
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
pid_t pid;
|
||||
|
||||
/* Added to show version by Simon
|
||||
* --Begin
|
||||
*/
|
||||
if (argc == 2 && strstr(argv[1], "-v")) {
|
||||
fprintf(stdout, "%s version: %s \n", argv[0], CDRCOLLECTOR_VERSION);
|
||||
exit(0);
|
||||
}
|
||||
/* --End
|
||||
*
|
||||
*/
|
||||
|
||||
debug_init();
|
||||
|
||||
fprintf(stderr, "\n Calling iptrans_init()");
|
||||
iptrans_init();
|
||||
|
||||
fprintf(stderr, "\n Calling snmp_init()");
|
||||
snmp_init(CDR_PORT);
|
||||
|
||||
if (argc == 2 && strstr(argv[1], "-d")) {
|
||||
if ((pid = fork()) != 0)
|
||||
exit(0);
|
||||
setsid();
|
||||
//umask(0);
|
||||
}
|
||||
cdr_init();
|
||||
//cdr_start();
|
||||
SetTimer();
|
||||
while (1) {
|
||||
//cdr_loop();
|
||||
usleep(50);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // On_Timer
|
||||
Description: // <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Calls: // cdr_timer
|
||||
Called By: //
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void On_Timer()
|
||||
{
|
||||
//debug_rt();
|
||||
//snmp_timer();
|
||||
cdr_timer();
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // SetTimer
|
||||
Description: // <20><><EFBFBD>ö<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Calls: // On_Timer
|
||||
Called By: //
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void SetTimer()
|
||||
{
|
||||
struct sigaction act;
|
||||
act.sa_handler = On_Timer;
|
||||
sigemptyset(&act.sa_mask);
|
||||
act.sa_flags = 0;
|
||||
if (sigaction(SIGALRM, &act, NULL) < 0) {
|
||||
perror("Produce Sigaction");
|
||||
exitLog("cdrCollector:SetTimer, sigaction function error");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
itimer.it_interval.tv_sec = 0;
|
||||
itimer.it_interval.tv_usec = 10 * 1000;
|
||||
itimer.it_value.tv_sec = 0;
|
||||
itimer.it_value.tv_usec = 10 * 1000;
|
||||
|
||||
if (setitimer(ITIMER_REAL, &itimer, &old_itimer) != 0) {
|
||||
printf("Setting Timer error! \n");
|
||||
exitLog("cdrCollector:SetTimer, setitimer function error");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
29
src/accountMgr/c_program/cdrCollector/test.txt
Normal file
29
src/accountMgr/c_program/cdrCollector/test.txt
Normal file
@@ -0,0 +1,29 @@
|
||||
CREATE TABLE IF NOT EXISTS CDR_DB.cdrFromPPS_18 (
|
||||
key_sys_id tinyint(2) DEFAULT '0' NOT NULL,
|
||||
instance int(4) DEFAULT '0' NOT NULL,
|
||||
recordType int(2),
|
||||
callType int(2),
|
||||
servedIMSI varchar(20),
|
||||
servedMSISDN varchar(20),
|
||||
callingNumber varchar(20),
|
||||
calledNumber varchar(20),
|
||||
recordingEntity varchar(20),
|
||||
mscIncomingTKGP varchar(20),
|
||||
mscOutgoingTKGP varchar(20),
|
||||
locationAreaCode int(4),
|
||||
cellId varchar(4),
|
||||
seizureTime datetime,
|
||||
answerTime datetime,
|
||||
releaseTime datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
|
||||
callDuration int(4),
|
||||
causeForTerm int(4),
|
||||
callReference int(4),
|
||||
charge int(4),
|
||||
balance int(4),
|
||||
gprs_sgsn_ip varchar(16),
|
||||
gprs_ggsn_ip varchar(16),
|
||||
gprs_dest_ip varchar(16),
|
||||
gprs_volume int(10),
|
||||
srcCode text,
|
||||
PRIMARY KEY (key_sys_id, instance, releaseTime)
|
||||
);
|
||||
77
src/accountMgr/c_program/ftpsend/Makefile
Normal file
77
src/accountMgr/c_program/ftpsend/Makefile
Normal file
@@ -0,0 +1,77 @@
|
||||
#/bin/sh
|
||||
|
||||
CC = gcc
|
||||
CFLAGS=-g -Wall -I/usr/local/mysql/include
|
||||
CFLAGS.ES=-g -Wall -I/usr/include/mariadb
|
||||
|
||||
COMPILE.c=$(CC) $(CFLAGS)
|
||||
COMPILE.c.ES=$(CC) $(CFLAGS.ES)
|
||||
|
||||
LINK.c=$(CC) $(CFLAGS)
|
||||
LINK.c.ES=$(CC) $(CFLAGS.ES)
|
||||
|
||||
LINKFLAG=-L../../../omcLib/c_program/omcLib -lomcLib \
|
||||
-L../../../omcLib/c_program/ftp -lftp \
|
||||
-L/usr/local/mysql/lib -lmariadbclient -lz
|
||||
|
||||
|
||||
LINKFLAG.ES=-L../../../omcLib/c_program/omcLib -lomcLib \
|
||||
-L../../../omcLib/c_program/ftp -lftp \
|
||||
-L../../../../plat/snmp/lib -lsnmp \
|
||||
-L../../../../plat/sccp/lib -lsccp \
|
||||
-L../../../../plat/iptrans/lib -liptrans \
|
||||
-L../../../../plat/debug/lib -ldebug \
|
||||
-L../../../../plat/public/lib -lpublic \
|
||||
-L/usr/lib/mysql -lmariadbclient -lz \
|
||||
|
||||
PROGS=ftpSend
|
||||
FTPSEND_OBJ = ftpsend.o
|
||||
FTPSEND_OBJ.ES = ftpsend.o.ES
|
||||
|
||||
default: linuxES
|
||||
|
||||
all:
|
||||
@echo " **** Compiling $(PROGS) ****"
|
||||
@echo "make clean -- Delete the target files"
|
||||
@echo "make linux72 -- Generate target files for Redhat Linux 72"
|
||||
@echo "make linuxES -- Generate target files for Redhat Linux ES"
|
||||
|
||||
linux72: $(FTPSEND_OBJ)
|
||||
@cd ../../../omcLib/c_program/ftp; make linux72; cd ..
|
||||
@cd ../../../accountMgr/c_program/ftpsend;
|
||||
@echo Linking $(PROGS)
|
||||
@$(LINK.c) -o $(PROGS) $(FTPSEND_OBJ) $(LINKFLAG) -lm
|
||||
ar r libftpsend.a $(FTPSEND_OBJ)
|
||||
# rm -rf *.o
|
||||
# rm -rf *bak
|
||||
# rm -rf *~
|
||||
# cp -f $(PROGS) ../../../bin
|
||||
# cp -f $(PROGS) /usr/local/omc/bin/
|
||||
|
||||
linuxES: $(FTPSEND_OBJ.ES)
|
||||
@cd ../../../omcLib/c_program/ftp; make linuxES; cd ..
|
||||
@cd ../../../accountMgr/c_program/ftpsend;
|
||||
@echo Linking $(PROGS)
|
||||
@$(LINK.c.ES) -o $(PROGS) $(FTPSEND_OBJ) $(LINKFLAG.ES) -lm
|
||||
ar r libftpsend.a $(FTPSEND_OBJ)
|
||||
|
||||
installbin: linuxES
|
||||
cp -f $(PROGS) ../../../../bin/
|
||||
|
||||
installomc: linuxES
|
||||
cp -f $(PROGS) /usr/local/omc/bin/
|
||||
|
||||
installall: installbin installomc
|
||||
|
||||
ftpsend.o:ftpsend.c
|
||||
$(COMPILE.c) -c ftpsend.c
|
||||
|
||||
ftpsend.o.ES:ftpsend.c
|
||||
$(COMPILE.c.ES) -c ftpsend.c
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(PROGS)
|
||||
@cd ../../../omcLib/c_program/ftp; rm -f *.o *.a; cd ..
|
||||
@cd ../../../accountMgr/c_program/ftpsend; rm -f *.o *.a; cd ..
|
||||
|
||||
|
||||
1062
src/accountMgr/c_program/ftpsend/ftpsend.c
Normal file
1062
src/accountMgr/c_program/ftpsend/ftpsend.c
Normal file
File diff suppressed because it is too large
Load Diff
32
src/accountMgr/c_program/ftpsend/ftpsend.h
Normal file
32
src/accountMgr/c_program/ftpsend/ftpsend.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef ftpsend_H_
|
||||
#define ftpsend_H_
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "../../../../plat/public/src/include/pub_include.h"
|
||||
#include "../../../omcLib/c_program/omcLib/omcLib.h"
|
||||
#include "../../../../plat/snmp/src/include/snmp.h"
|
||||
|
||||
|
||||
#define MAX_FILE_TRANSFER_NUM 32
|
||||
#define WAIT_TIME 60
|
||||
#define INFO_UPDATE_TIME 60
|
||||
|
||||
|
||||
/* The information of the file transfer object */
|
||||
typedef struct FileTransfer
|
||||
{
|
||||
char srcDir[128];
|
||||
char dstDir[128];
|
||||
char dstIP[16];
|
||||
char filter[16];
|
||||
char logName[32];
|
||||
char logPass[32];
|
||||
int curFileIndex;
|
||||
int waitTime;
|
||||
}FileTransfer;
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
8
src/accountMgr/c_program/ftpsend/run
Normal file
8
src/accountMgr/c_program/ftpsend/run
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
make clean
|
||||
sleep 1
|
||||
make linuxES
|
||||
sleep 1
|
||||
./ftpSend
|
||||
|
||||
54
src/accountMgr/c_program/nrtrde/Makefile
Normal file
54
src/accountMgr/c_program/nrtrde/Makefile
Normal file
@@ -0,0 +1,54 @@
|
||||
#/bin/bash
|
||||
|
||||
CC=gcc
|
||||
CFLAGS=-g -Wall -I/usr/include/mariadb
|
||||
PROGS=nrtrde
|
||||
|
||||
|
||||
LINK.c=$(CC) $(CFLAGS)
|
||||
|
||||
LINKFLAG=-L../../../omcLib/c_program/omcLib -lomcLib \
|
||||
-L../../../../plat/snmp/lib -lsnmp \
|
||||
-L../../../../plat/sccp/lib -lsccp \
|
||||
-L../../../../plat/iptrans/lib -liptrans \
|
||||
-L../../../../plat/debug/lib -ldebug \
|
||||
-L../../../../plat/public/lib -lpublic \
|
||||
-L/usr/lib/mysql -lmariadbclient -lz \
|
||||
|
||||
NRTRDE_OBJ=nrtrde.o decodeASN.o encodeASN.o conv_prefix.o seq_num_mng.o
|
||||
|
||||
default: linuxES
|
||||
|
||||
all:
|
||||
@echo "make clean -- Delete the target files"
|
||||
@echo "make linuxES -- Generate target files for Redhat Linux ES"
|
||||
|
||||
linuxES: $(NRTRDE_OBJ)
|
||||
@$(LINK.c) -o $(PROGS) $(NRTRDE_OBJ) $(LINKFLAG) -lm
|
||||
ar r libnrtrde.a nrtrde.o decodeASN.o encodeASN.o conv_prefix.o seq_num_mng.o
|
||||
|
||||
installbin: linuxES
|
||||
cp -f $(PROGS) ../../../../bin/
|
||||
|
||||
installomc: linuxES
|
||||
cp -f $(PROGS) /usr/local/omc/bin/
|
||||
|
||||
installall: installbin installomc
|
||||
|
||||
nrtrde.o: nrtrde.c
|
||||
$(LINK.c) -c nrtrde.c
|
||||
|
||||
decodeASN.o: decodeASN.c
|
||||
$(LINK.c) -c decodeASN.c
|
||||
|
||||
encodeASN.o: encodeASN.c
|
||||
${LINK.c} -c encodeASN.c
|
||||
|
||||
conv_prefix.o: conv_prefix.c
|
||||
${LINK.c} -c conv_prefix.c
|
||||
|
||||
seq_num_mng.o: seq_num_mng.c
|
||||
${LINK.c} -c seq_num_mng.c
|
||||
|
||||
clean:
|
||||
rm -rf *.o *.a $(PROGS)
|
||||
45
src/accountMgr/c_program/nrtrde/conf/NR.conf
Normal file
45
src/accountMgr/c_program/nrtrde/conf/NR.conf
Normal file
@@ -0,0 +1,45 @@
|
||||
# NR.conf
|
||||
|
||||
# The local mcc
|
||||
MCC=262
|
||||
|
||||
# The local mnc
|
||||
MNC=09
|
||||
|
||||
# The local tag
|
||||
LOCAL_TADIG=FEAKE
|
||||
|
||||
# The time to make NRTRDE Delivery Report and Error Report
|
||||
MAKE_REPORT_TIME=23
|
||||
|
||||
# The max value of CallEventDuration of a CDR
|
||||
CallEventDurationMax=6000
|
||||
|
||||
# The version of the NRTRDE Delivery report
|
||||
ND_VERSION=1.0
|
||||
|
||||
# The version of the NRTRDE Error report
|
||||
NE_VERSION=1.0
|
||||
|
||||
# The specificationVersionNumber of the NRTRDE file
|
||||
NR_SVN=2
|
||||
|
||||
# The ReleaseVersionNumber of the NRTRDE file
|
||||
NR_RVN=1
|
||||
|
||||
# The backup directory
|
||||
NR_RECV_BAK_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/NR_RECV_BAK/
|
||||
NR_SEND_BAK_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/NR_SEND_BAK/
|
||||
ND_RECV_BAK_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/ND_RECV_BAK/
|
||||
ND_SEND_BAK_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/ND_SEND_BAK/
|
||||
NE_RECV_BAK_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/NE_RECV_BAK/
|
||||
NE_SEND_BAK_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/NE_SEND_BAK/
|
||||
LOCAL_CSV_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/LOCAL_CSV/
|
||||
|
||||
# The source directory to send the file
|
||||
SEND_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/SEND/
|
||||
|
||||
# The directory to receive the file
|
||||
RECV_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/RECV/
|
||||
|
||||
|
||||
148
src/accountMgr/c_program/nrtrde/conv_prefix.c
Normal file
148
src/accountMgr/c_program/nrtrde/conv_prefix.c
Normal file
@@ -0,0 +1,148 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "conv_prefix.h"
|
||||
|
||||
_conv_prefix conv_prefix;
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
|
||||
int readConvPrefixConf()
|
||||
{
|
||||
char filename[]="./conf/conv_prefix.conf";
|
||||
FILE *fpConf = NULL;
|
||||
int i;
|
||||
|
||||
fpConf = fopen(filename,"r");
|
||||
if(fpConf == NULL) return 0;
|
||||
fread(&conv_prefix,sizeof(_conv_prefix),1,fpConf);
|
||||
fclose(fpConf);
|
||||
|
||||
for(i=0;i<MAX_CONV_PREFIX;i++)
|
||||
{
|
||||
if(strlen(conv_prefix.conv_prefix[i].prefix))
|
||||
conv_prefix.conv_prefix[i].used_flag = 1;
|
||||
else
|
||||
conv_prefix.conv_prefix[i].used_flag = 0;
|
||||
if(strlen(conv_prefix.group_conv_prefix[i].startNumber))
|
||||
conv_prefix.group_conv_prefix[i].used_flag = 1;
|
||||
else
|
||||
conv_prefix.group_conv_prefix[i].used_flag = 0;
|
||||
|
||||
}
|
||||
for(i=0;i<MAX_CLI_PREFIX;i++)
|
||||
{
|
||||
if(strlen(conv_prefix.cli_prefix[i].prefix))
|
||||
conv_prefix.cli_prefix[i].used_flag = 1;
|
||||
else
|
||||
conv_prefix.cli_prefix[i].used_flag = 0;
|
||||
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int xappSearchGroupTable(char *msisdn_unk)
|
||||
{
|
||||
int loop=0;
|
||||
for(loop=0;loop<MAX_CONV_PREFIX;loop++)
|
||||
{
|
||||
if(conv_prefix.group_conv_prefix[loop].used_flag)
|
||||
{
|
||||
if((strcmp(msisdn_unk,conv_prefix.group_conv_prefix[loop].startNumber))>=0 &&
|
||||
(strcmp(conv_prefix.group_conv_prefix[loop].endNumber,msisdn_unk))>=0)
|
||||
return loop;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int msisdnUnkToInt(char *msisdn_unk, char *msisdn_int)
|
||||
/* return value:
|
||||
-1 = error length;
|
||||
0 = cannn't find appropriate prefix;
|
||||
1 = conv. succeed
|
||||
*/
|
||||
{
|
||||
int retval = 0, index = -1;
|
||||
int loop,len=0,max_len=0,old_len;
|
||||
int delete_len,add_len;
|
||||
|
||||
strcpy(msisdn_int,msisdn_unk);
|
||||
index = xappSearchGroupTable(msisdn_unk);
|
||||
if(index>=0)
|
||||
{
|
||||
char tmpStart[17],tmpEnd[17];
|
||||
|
||||
strcpy(tmpStart,msisdn_unk);
|
||||
tmpStart[conv_prefix.group_conv_prefix[index].repStartDigit] = 0;
|
||||
|
||||
strcpy(tmpEnd,&msisdn_unk[conv_prefix.group_conv_prefix[index].repEndDigit]);
|
||||
|
||||
sprintf(msisdn_int,"%s%s%s",
|
||||
tmpStart,
|
||||
conv_prefix.group_conv_prefix[index].repDigitWith,
|
||||
tmpEnd);
|
||||
|
||||
return 1;
|
||||
}
|
||||
for(loop=0;loop<MAX_CONV_PREFIX;loop++)
|
||||
{
|
||||
if(conv_prefix.conv_prefix[loop].used_flag)
|
||||
{
|
||||
len = strlen(conv_prefix.conv_prefix[loop].prefix);
|
||||
if(len>0)
|
||||
{
|
||||
if(len>max_len)
|
||||
if(strncasecmp(msisdn_unk,
|
||||
conv_prefix.conv_prefix[loop].prefix,
|
||||
len)==0)
|
||||
{
|
||||
max_len = len;
|
||||
index = loop;
|
||||
}//cmp
|
||||
}//len>0
|
||||
}//used
|
||||
}
|
||||
|
||||
if(index>=0 && index<MAX_CONV_PREFIX)
|
||||
{
|
||||
len = strlen(msisdn_unk);
|
||||
|
||||
if(len>24) len = 24;
|
||||
old_len = len;
|
||||
|
||||
|
||||
if(conv_prefix.conv_prefix[index].valid_length>0)
|
||||
{
|
||||
if(len != conv_prefix.conv_prefix[index].valid_length)
|
||||
{
|
||||
strcpy(msisdn_int,msisdn_unk);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
delete_len = conv_prefix.conv_prefix[index].delete_length;
|
||||
if(delete_len>len)
|
||||
{
|
||||
strcpy(msisdn_int,msisdn_unk);
|
||||
return -1;
|
||||
}
|
||||
|
||||
add_len = conv_prefix.conv_prefix[index].add_length;
|
||||
if(add_len != strlen(conv_prefix.conv_prefix[index].add_digits))
|
||||
{
|
||||
strcpy(msisdn_int,msisdn_unk);
|
||||
return -1;
|
||||
}
|
||||
strcpy(msisdn_int,
|
||||
conv_prefix.conv_prefix[index].add_digits);
|
||||
strcat(msisdn_int,
|
||||
&msisdn_unk[delete_len]);
|
||||
msisdn_int[add_len+old_len-delete_len] = 0;
|
||||
retval = 1;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
66
src/accountMgr/c_program/nrtrde/conv_prefix.h
Normal file
66
src/accountMgr/c_program/nrtrde/conv_prefix.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#ifndef _CONV_PREFIX_H
|
||||
#define _CONV_PREFIX_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#define MAX_CONV_PREFIX 128
|
||||
#define MAX_CLI_PREFIX 64
|
||||
#define MAX_PREFIX_LEN 16
|
||||
#define MAX_NAME_LEN 8
|
||||
|
||||
#define MAX_PLAT_NAME_LEN 24
|
||||
#define MAX_PLAT_NAME_INSTANCE 256
|
||||
|
||||
typedef struct conv_prefix_record
|
||||
{
|
||||
u_char used_flag;
|
||||
char prefix[MAX_PREFIX_LEN];
|
||||
char delete_length;
|
||||
char add_length;
|
||||
char add_digits[MAX_PREFIX_LEN];
|
||||
u_char valid_length;
|
||||
}_conv_prefix_record;
|
||||
|
||||
typedef struct cli_prefix
|
||||
{
|
||||
u_char in_property;
|
||||
char prefix[MAX_PREFIX_LEN];
|
||||
char delete_length;
|
||||
u_char out_property;
|
||||
char add_length;
|
||||
char add_digits[MAX_PREFIX_LEN-1];
|
||||
u_char used_flag;
|
||||
u_char valid_length;
|
||||
}_cli_prefix;
|
||||
|
||||
typedef struct xapp_group_prefix
|
||||
{
|
||||
char startNumber[MAX_PREFIX_LEN+1];
|
||||
char endNumber[MAX_PREFIX_LEN+1];
|
||||
u_char repStartDigit;
|
||||
u_char repEndDigit;
|
||||
char repDigitWith[MAX_PREFIX_LEN+1];
|
||||
u_char status; /* 0=unlock, 1=lock */
|
||||
u_char used_flag;
|
||||
char cReserved[MAX_PREFIX_LEN-1];
|
||||
}_xapp_group_prefix;
|
||||
|
||||
typedef struct conv_prefix
|
||||
{
|
||||
_conv_prefix_record conv_prefix[MAX_CONV_PREFIX];
|
||||
_cli_prefix cli_prefix[MAX_CLI_PREFIX];
|
||||
char conv_name[MAX_CONV_PREFIX][MAX_NAME_LEN];
|
||||
char cli_name[MAX_CLI_PREFIX][MAX_NAME_LEN];
|
||||
char plat_name[MAX_PLAT_NAME_INSTANCE][MAX_PLAT_NAME_LEN];
|
||||
_xapp_group_prefix group_conv_prefix[MAX_CONV_PREFIX];
|
||||
}_conv_prefix;
|
||||
|
||||
int msisdnUnkToInt(char *msisdn_unk, char *msisdn_int);
|
||||
|
||||
/* return value:
|
||||
-1 = error length;
|
||||
0 = cannn't find appropriate prefix;
|
||||
1 = conv. succeed
|
||||
*/
|
||||
|
||||
#endif
|
||||
7206
src/accountMgr/c_program/nrtrde/createCDRs
Normal file
7206
src/accountMgr/c_program/nrtrde/createCDRs
Normal file
File diff suppressed because it is too large
Load Diff
4937
src/accountMgr/c_program/nrtrde/decodeASN.c
Normal file
4937
src/accountMgr/c_program/nrtrde/decodeASN.c
Normal file
File diff suppressed because it is too large
Load Diff
1954
src/accountMgr/c_program/nrtrde/encodeASN.c
Normal file
1954
src/accountMgr/c_program/nrtrde/encodeASN.c
Normal file
File diff suppressed because it is too large
Load Diff
19
src/accountMgr/c_program/nrtrde/init
Normal file
19
src/accountMgr/c_program/nrtrde/init
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
rm -rf *.log
|
||||
rm -rf *.txt
|
||||
|
||||
rm -rf ./NR_SEND_BAK/
|
||||
rm -rf ./NR_RECV_BAK/
|
||||
|
||||
rm -rf ./ND_SEND_BAK/
|
||||
rm -rf ./ND_RECV_BAK/
|
||||
|
||||
rm -rf ./NE_SEND_BAK/
|
||||
rm -rf ./NE_RECV_BAK/
|
||||
rm -rf ./LOCAL_CSV/
|
||||
|
||||
rm -rf ./SEND/
|
||||
|
||||
rm -rf ./RECV/
|
||||
2139
src/accountMgr/c_program/nrtrde/nrtrde.c
Normal file
2139
src/accountMgr/c_program/nrtrde/nrtrde.c
Normal file
File diff suppressed because it is too large
Load Diff
130
src/accountMgr/c_program/nrtrde/nrtrde.h
Normal file
130
src/accountMgr/c_program/nrtrde/nrtrde.h
Normal file
@@ -0,0 +1,130 @@
|
||||
#ifndef nrtrde__H
|
||||
#define nrtrde__H
|
||||
|
||||
#include "../../../../plat/public/src/include/pub_include.h"
|
||||
#include "../../../omcLib/c_program/omcLib/omcLib.h"
|
||||
#include "../../../../plat/snmp/src/include/snmp.h"
|
||||
#include "./conv_prefix.h"
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#ifndef MYSQL_H
|
||||
#include "mysql.h"
|
||||
#endif
|
||||
|
||||
#ifndef NRTRDE_DEBUG
|
||||
#define NRTRDE_DEBUG 0
|
||||
#endif
|
||||
|
||||
/********************************************************/
|
||||
/****** Constant Define ******/
|
||||
/********************************************************/
|
||||
/* The hpmn servers info update timeslot (Second) */
|
||||
#define HPMN_INFO_UPDATE_TIME 60
|
||||
/* The hpmn servers count which this version to support */
|
||||
#define HPMN_SERVER_COUNT 100
|
||||
/* The max time of the file backup (day) */
|
||||
#define MAX_BAK_DAY 7
|
||||
|
||||
#define SEQ_NUM_CONF "./conf/nrtrde_seq.conf"
|
||||
|
||||
/* The return value of the function */
|
||||
#define SUCCESSFUL 1
|
||||
#define FAIL 0
|
||||
#define NO_FIND 0x7FFFFFFF
|
||||
|
||||
/********************************************************/
|
||||
/****** Struct Define ******/
|
||||
/********************************************************/
|
||||
/* The information of the hpmn servers */
|
||||
typedef struct HpmnServer
|
||||
{
|
||||
char mcc[8]; //The mcc of the HPMN server
|
||||
char mnc[8]; //The mnc of the HPMN server
|
||||
char tadig[8]; //The tadig of the HPMN server, length=5
|
||||
char serverIP[16]; //The remote IP address of the HPMN server, xxx.xxx.xxx.xxx
|
||||
char loginName[64]; //The user name to login the remote HPMN server
|
||||
char loginPass[64]; //The user password to login the remote HPMN server
|
||||
int timeSlot; //The timeslot to send the nrtrde to the remote HPMN server
|
||||
char reportDir[256]; //The directory to send the report files to the HPMN server
|
||||
char nrtrdeDir[256]; //The directory to send the nrtrde files to the HPMN server
|
||||
|
||||
int sendFileTimeout; //When the value<0, then send the nrtrde file to remote HPMN server
|
||||
}HpmnServer;
|
||||
|
||||
/* The config of the tag */
|
||||
typedef struct TagNode
|
||||
{
|
||||
char fieldName[32]; //The field name of the tag
|
||||
int tagValue; //The value of the tag, the tag is application
|
||||
int isStructed; //Whether the tag is structed or not
|
||||
int code; //How to code the field, 0-no code; 1-Integer; 2-Ascii; 3-HexString; 4-NumberString; 5-BCDString;
|
||||
int minSize; //The min size of the field
|
||||
int maxSize; //The max size of the field
|
||||
}TagNode;
|
||||
|
||||
/* Use for link struct */
|
||||
typedef struct DataNode
|
||||
{
|
||||
struct DataNode* next; //The next data link to the data
|
||||
unsigned char data; //The data in the node
|
||||
}DataNode;
|
||||
|
||||
/* Use for store the record of the NRTRDE Delivery report */
|
||||
typedef struct NDRepNode
|
||||
{
|
||||
char tadig[8]; //The tadig of this record
|
||||
char fileName[32]; //The fileName of this record
|
||||
char recvTime[32]; //The time when to receive the file
|
||||
struct NDRepNode* next; //The next node in the link
|
||||
}NDRepNode;
|
||||
|
||||
/* Use for store the record of the NRTRDE Error report */
|
||||
typedef struct NERepNode
|
||||
{
|
||||
char tadig[8]; //The tadig of this record
|
||||
char fileName[32]; //The fileName of the received NRTRDE file which is parsed
|
||||
int type; //The type of this record, 1-NRTRDE file error, 2-MOC error, 3-MTC error
|
||||
int recordNumber; //The number of this record in the NRTRDE file
|
||||
char errorCode[8]; //The error code of this record
|
||||
struct NERepNode* next; //The next node in the link
|
||||
}NERepNode;
|
||||
|
||||
/* Use for store the information of every CallEvents */
|
||||
typedef struct CallEvent
|
||||
{
|
||||
int type; //1-MOC, 2-MTC, 3-GPRS
|
||||
char imsi[32]; //Imsi
|
||||
char imei[32]; //Imei
|
||||
char startTime[32]; //CallEventStartTime
|
||||
char utcTimeOff[32]; //utcTimeOffsef
|
||||
long callDuration; //CallEventDuration
|
||||
int causeForTerm; //CauseForTermination
|
||||
char teleServCode[32]; //TeleServiceCode
|
||||
char bearerServCode[32]; //BearerServCode
|
||||
char supplServCode[32]; //SupplementaryServiceCode
|
||||
char dialledDigits[32]; //DialledDigits
|
||||
char connectedNumber[32]; //ConnectedNumber
|
||||
char thirdPartyNumber[32]; //ThirdPartyNumber
|
||||
char callingNumber[32]; //CallingNumber
|
||||
char recEntityId[32]; //RecEntityId
|
||||
long callReference; //CallReference
|
||||
long chargeAmount; //ChargeAmount
|
||||
}CallEvent;
|
||||
|
||||
typedef struct seq_object
|
||||
{
|
||||
char tadig[8];
|
||||
unsigned long nr_seq_num;
|
||||
unsigned long nd_seq_num;
|
||||
unsigned long ne_seq_num;
|
||||
}seq_object;
|
||||
|
||||
typedef struct seq_buffer
|
||||
{
|
||||
int count;
|
||||
seq_object seq_obj[HPMN_SERVER_COUNT];
|
||||
}seq_buffer;
|
||||
|
||||
#endif
|
||||
|
||||
204
src/accountMgr/c_program/nrtrde/seq_num_mng.c
Normal file
204
src/accountMgr/c_program/nrtrde/seq_num_mng.c
Normal file
@@ -0,0 +1,204 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "nrtrde.h"
|
||||
|
||||
seq_buffer seq_buf;
|
||||
|
||||
int add_seq_obj(seq_buffer *seq_buf,seq_object *add_obj);
|
||||
unsigned long find_seq_obj(seq_buffer *seq_buf,char *keyvalue);
|
||||
int get_seq_num(char *tadig,int type,char *out_seq);
|
||||
int init_seq();
|
||||
int store_seq();
|
||||
|
||||
|
||||
int add_seq_obj(seq_buffer *seq_buf,seq_object *add_obj)
|
||||
{
|
||||
int unitlen;
|
||||
int low,high,mid,last;
|
||||
char tmpvalue[24];
|
||||
char keyfield[24];
|
||||
seq_object tmp_seq_obj_list[HPMN_SERVER_COUNT];
|
||||
|
||||
if(seq_buf->count >= HPMN_SERVER_COUNT)
|
||||
return 0;
|
||||
|
||||
unitlen=sizeof(seq_object);
|
||||
mid=0;
|
||||
low=0;
|
||||
high=seq_buf->count-1;
|
||||
|
||||
memset(keyfield,0,sizeof(keyfield));
|
||||
sprintf(keyfield,"%s",add_obj->tadig);
|
||||
|
||||
memset(tmpvalue,0,sizeof(tmpvalue));
|
||||
memcpy(tmpvalue,seq_buf->seq_obj[high].tadig,8);
|
||||
if(strcmp(keyfield,tmpvalue) == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if(strcmp(keyfield,tmpvalue) > 0)
|
||||
{
|
||||
sprintf(seq_buf->seq_obj[seq_buf->count].tadig,"%s",keyfield);
|
||||
seq_buf->seq_obj[seq_buf->count].nr_seq_num=add_obj->nr_seq_num;
|
||||
seq_buf->seq_obj[seq_buf->count].nd_seq_num=add_obj->nd_seq_num;
|
||||
seq_buf->seq_obj[seq_buf->count].ne_seq_num=add_obj->ne_seq_num;
|
||||
}
|
||||
else
|
||||
{
|
||||
while(low <= high)
|
||||
{
|
||||
mid=(low+high)/2;
|
||||
memset(tmpvalue,0,sizeof(tmpvalue));
|
||||
memcpy(tmpvalue,seq_buf->seq_obj[mid].tadig,8);
|
||||
if(strcmp(keyfield,tmpvalue) == 0)
|
||||
return 0;
|
||||
else if(strcmp(keyfield,tmpvalue) < 0)
|
||||
high=mid-1;
|
||||
else
|
||||
low=mid+1;
|
||||
}
|
||||
if(low > high)
|
||||
last=low;
|
||||
else
|
||||
last=mid;
|
||||
|
||||
memcpy(tmp_seq_obj_list,seq_buf->seq_obj,sizeof(tmp_seq_obj_list));
|
||||
|
||||
memcpy(&seq_buf->seq_obj[last+1],&tmp_seq_obj_list[last],(HPMN_SERVER_COUNT-last-1)*unitlen);
|
||||
sprintf(seq_buf->seq_obj[last].tadig,"%s",keyfield);
|
||||
seq_buf->seq_obj[last].nr_seq_num=add_obj->nr_seq_num;
|
||||
seq_buf->seq_obj[last].nd_seq_num=add_obj->nd_seq_num;
|
||||
seq_buf->seq_obj[last].ne_seq_num=add_obj->ne_seq_num;
|
||||
}
|
||||
seq_buf->count++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
return NO_FIND:can not find
|
||||
*/
|
||||
unsigned long find_seq_obj(seq_buffer *seq_buf,char *keyvalue)
|
||||
{
|
||||
char tmpvalue[24];
|
||||
char keyfield[24];
|
||||
int low,high,mid;
|
||||
|
||||
mid=0;
|
||||
low=0;
|
||||
high=seq_buf->count-1;
|
||||
|
||||
memset(keyfield,0,sizeof(keyfield));
|
||||
sprintf(keyfield,"%s",keyvalue);
|
||||
|
||||
memset(tmpvalue,0,sizeof(tmpvalue));
|
||||
memcpy(tmpvalue,seq_buf->seq_obj[high].tadig,8);
|
||||
if(strcmp(keyfield,tmpvalue) == 0)
|
||||
return high;
|
||||
else if(strcmp(keyfield,tmpvalue) > 0)
|
||||
return NO_FIND;
|
||||
else
|
||||
{
|
||||
while(low <= high)
|
||||
{
|
||||
mid=(low+high)/2;
|
||||
memset(tmpvalue,0,sizeof(tmpvalue));
|
||||
memcpy(tmpvalue,seq_buf->seq_obj[mid].tadig,8);
|
||||
if(strcmp(keyfield,tmpvalue) == 0)
|
||||
return mid;
|
||||
else if(strcmp(keyfield,tmpvalue) < 0)
|
||||
high=mid-1;
|
||||
else
|
||||
low=mid+1;
|
||||
}
|
||||
}
|
||||
|
||||
return NO_FIND;
|
||||
}
|
||||
|
||||
int init_seq()
|
||||
{
|
||||
FILE *handle=NULL;
|
||||
memset(&seq_buf,0,sizeof(seq_buf));
|
||||
handle=fopen(SEQ_NUM_CONF,"r+");
|
||||
if(handle == NULL)
|
||||
{
|
||||
FILE *tmpf;
|
||||
tmpf=fopen(SEQ_NUM_CONF,"w+");
|
||||
if(tmpf == NULL)
|
||||
{
|
||||
printf("Can not create the %s\n",SEQ_NUM_CONF);
|
||||
exit(0);
|
||||
}
|
||||
fwrite(&seq_buf,sizeof(seq_buf),1,tmpf);
|
||||
fclose(tmpf);
|
||||
handle=fopen(SEQ_NUM_CONF,"r+");
|
||||
}
|
||||
fread(&seq_buf,sizeof(seq_buf),1,handle);
|
||||
printf("Load sequence number conf from %s\n",SEQ_NUM_CONF);
|
||||
fclose(handle);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int store_seq()
|
||||
{
|
||||
FILE *handle=NULL;
|
||||
|
||||
handle=fopen(SEQ_NUM_CONF,"w+");
|
||||
if(handle == NULL)
|
||||
{
|
||||
printf("Can not write the %s\n",SEQ_NUM_CONF);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
fwrite(&seq_buf,sizeof(seq_buf),1,handle);
|
||||
fclose(handle);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//type:0-NR, 1-ND, 2-NE;
|
||||
int get_seq_num(char *tadig,int type,char *out_seq)
|
||||
{
|
||||
unsigned long find_index;
|
||||
|
||||
find_index=find_seq_obj(&seq_buf,tadig);
|
||||
if(find_index == NO_FIND)
|
||||
{
|
||||
if(type == 0)
|
||||
sprintf(out_seq,"0000001");
|
||||
else
|
||||
sprintf(out_seq,"00001");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(type == 0)
|
||||
{
|
||||
if(seq_buf.seq_obj[find_index].nr_seq_num == 0)
|
||||
seq_buf.seq_obj[find_index].nr_seq_num++;
|
||||
sprintf(out_seq,"%07ld",seq_buf.seq_obj[find_index].nr_seq_num);
|
||||
seq_buf.seq_obj[find_index].nr_seq_num++;
|
||||
seq_buf.seq_obj[find_index].nr_seq_num%=10000000;
|
||||
}
|
||||
else if(type == 1)
|
||||
{
|
||||
if(seq_buf.seq_obj[find_index].nd_seq_num == 0)
|
||||
seq_buf.seq_obj[find_index].nd_seq_num++;
|
||||
sprintf(out_seq,"%05ld",seq_buf.seq_obj[find_index].nd_seq_num);
|
||||
seq_buf.seq_obj[find_index].nd_seq_num++;
|
||||
seq_buf.seq_obj[find_index].nd_seq_num%=100000;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(seq_buf.seq_obj[find_index].ne_seq_num == 0)
|
||||
seq_buf.seq_obj[find_index].ne_seq_num++;
|
||||
sprintf(out_seq,"%05ld",seq_buf.seq_obj[find_index].ne_seq_num);
|
||||
seq_buf.seq_obj[find_index].ne_seq_num++;
|
||||
seq_buf.seq_obj[find_index].ne_seq_num%=100000;
|
||||
}
|
||||
store_seq();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
52
src/accountMgr/c_program/sftpSend/Makefile
Normal file
52
src/accountMgr/c_program/sftpSend/Makefile
Normal file
@@ -0,0 +1,52 @@
|
||||
#/bin/bash
|
||||
|
||||
CC=gcc
|
||||
CFLAGS=-g -Wall -I/usr/include/mariadb
|
||||
PROGS=sftpSend
|
||||
|
||||
|
||||
LINK.c=$(CC) $(CFLAGS)
|
||||
|
||||
LINKFLAG=-L../../../omcLib/c_program/omcLib -lomcLib \
|
||||
-L../../../../plat/snmp/lib -lsnmp \
|
||||
-L../../../../plat/sccp/lib -lsccp \
|
||||
-L../../../../plat/iptrans/lib -liptrans \
|
||||
-L../../../../plat/debug/lib -ldebug \
|
||||
-L../../../../plat/public/lib -lpublic \
|
||||
-L/usr/lib/mysql -lmariadbclient -lz \
|
||||
-L/usr/lib -lpthread -lz \
|
||||
|
||||
SFTPSEND_OBJ=sftpSend.o sftp.o
|
||||
|
||||
default: linuxES
|
||||
|
||||
all:
|
||||
@echo "make clean -- Delete the target files"
|
||||
@echo "make linuxES -- Generate target files for Redhat Linux ES"
|
||||
|
||||
linuxES: $(SFTPSEND_OBJ)
|
||||
@$(LINK.c) -o $(PROGS) $(SFTPSEND_OBJ) $(LINKFLAG) -lm
|
||||
ar r libsftpSend.a sftpSend.o sftp.o
|
||||
|
||||
installbin: linuxES
|
||||
cp -f $(PROGS) ../../../../bin/
|
||||
cp -f parseResult ../../../../bin/
|
||||
cp -f initKeys ../../../../bin/
|
||||
cp -f sendfile ../../../../bin/
|
||||
|
||||
installomc: linuxES
|
||||
cp -f $(PROGS) /usr/local/omc/bin/
|
||||
cp -f parseResult /usr/local/omc/bin/
|
||||
cp -f initKeys /usr/local/omc/bin/
|
||||
cp -f sendfile /usr/local/omc/bin/
|
||||
|
||||
installall: installbin installomc
|
||||
|
||||
sftpSend.o: sftpSend.c
|
||||
$(LINK.c) -c sftpSend.c
|
||||
|
||||
sftp.o: sftp.c
|
||||
$(LINK.c) -c sftp.c
|
||||
|
||||
clean:
|
||||
rm -rf *.o *.a $(PROGS)
|
||||
45
src/accountMgr/c_program/sftpSend/conf/NR.conf
Normal file
45
src/accountMgr/c_program/sftpSend/conf/NR.conf
Normal file
@@ -0,0 +1,45 @@
|
||||
# NR.conf
|
||||
|
||||
# The local mcc
|
||||
MCC=262
|
||||
|
||||
# The local mnc
|
||||
MNC=09
|
||||
|
||||
# The local tag
|
||||
LOCAL_TADIG=FEAKE
|
||||
|
||||
# The time to make NRTRDE Delivery Report and Error Report
|
||||
MAKE_REPORT_TIME=23
|
||||
|
||||
# The max value of CallEventDuration of a CDR
|
||||
CallEventDurationMax=6000
|
||||
|
||||
# The version of the NRTRDE Delivery report
|
||||
ND_VERSION=1.0
|
||||
|
||||
# The version of the NRTRDE Error report
|
||||
NE_VERSION=1.0
|
||||
|
||||
# The specificationVersionNumber of the NRTRDE file
|
||||
NR_SVN=2
|
||||
|
||||
# The ReleaseVersionNumber of the NRTRDE file
|
||||
NR_RVN=1
|
||||
|
||||
# The backup directory
|
||||
NR_RECV_BAK_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/NR_RECV_BAK/
|
||||
NR_SEND_BAK_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/NR_SEND_BAK/
|
||||
ND_RECV_BAK_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/ND_RECV_BAK/
|
||||
ND_SEND_BAK_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/ND_SEND_BAK/
|
||||
NE_RECV_BAK_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/NE_RECV_BAK/
|
||||
NE_SEND_BAK_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/NE_SEND_BAK/
|
||||
LOCAL_CSV_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/LOCAL_CSV/
|
||||
|
||||
# The source directory to send the file
|
||||
SEND_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/SEND/
|
||||
|
||||
# The directory to receive the file
|
||||
RECV_DIR=/usr/local/omc/src/accountMgr/c_program/nrtrde/RECV/
|
||||
|
||||
|
||||
4
src/accountMgr/c_program/sftpSend/init
Normal file
4
src/accountMgr/c_program/sftpSend/init
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
rm -rf *.txt
|
||||
rm -rf *.log
|
||||
32
src/accountMgr/c_program/sftpSend/initKeys
Normal file
32
src/accountMgr/c_program/sftpSend/initKeys
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
#This script use to init the server keys, it rewrite the known_hosts config file
|
||||
|
||||
#This script have 3 parameters
|
||||
#remoteip: the ip of the remote server
|
||||
#username: the name for logging in
|
||||
#userpass: the password for logging in
|
||||
|
||||
set remoteip [lindex $argv 0]
|
||||
set username [lindex $argv 1]
|
||||
set userpass [lindex $argv 2]
|
||||
|
||||
set timeout 5
|
||||
|
||||
spawn sftp $username@$remoteip
|
||||
|
||||
expect "*(yes/no)?*"
|
||||
|
||||
send "yes\n"
|
||||
|
||||
expect "*password*"
|
||||
|
||||
send "$userpass\n"
|
||||
|
||||
expect "*sftp>*"
|
||||
|
||||
send "quit\n"
|
||||
|
||||
expect eof
|
||||
exit
|
||||
|
||||
31
src/accountMgr/c_program/sftpSend/parseResult
Normal file
31
src/accountMgr/c_program/sftpSend/parseResult
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
#This script parse the result.txt file
|
||||
#to judge whether the operation of sending file is successful
|
||||
|
||||
#The local do not have the Permission to access the remote directory
|
||||
if [ `grep -c "handle" /tmp/result$1.txt` -gt 0 ] ; then
|
||||
`echo 4 >/tmp/temp$1.txt`
|
||||
#echo "The local do not have the Permission to access the remote directory"
|
||||
exit
|
||||
fi
|
||||
|
||||
#The name or the password is not fit
|
||||
if [ `grep -c "Permission denied" /tmp/result$1.txt` -gt 0 ] ; then
|
||||
`echo 2 >/tmp/temp$1.txt`
|
||||
#echo "The name or the password is not fit"
|
||||
exit
|
||||
fi
|
||||
|
||||
#Successful
|
||||
if [ `grep -c "100%" /tmp/result$1.txt` -gt 0 ] ; then
|
||||
`echo 0 >/tmp/temp$1.txt`
|
||||
#echo "Send the file successfully"
|
||||
exit
|
||||
fi
|
||||
|
||||
#The remote server is unavailable
|
||||
`echo 1 >/tmp/temp$1.txt`
|
||||
#echo "The remote server is unavailable"
|
||||
exit
|
||||
|
||||
34
src/accountMgr/c_program/sftpSend/sendfile
Normal file
34
src/accountMgr/c_program/sftpSend/sendfile
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
#This script interative with the remote server, and send the file to it
|
||||
|
||||
#This script have 6 parameters
|
||||
#remoteip: the ip of the remote server
|
||||
#username: the name for logining in
|
||||
#userpass: the password for logining in
|
||||
#resdir: the directory to store the files
|
||||
#sendfile: the file to send to the remote server
|
||||
#desdir: the directory to send the files
|
||||
|
||||
set remoteip [lindex $argv 0]
|
||||
set username [lindex $argv 1]
|
||||
set userpass [lindex $argv 2]
|
||||
set resdir [lindex $argv 3]
|
||||
set sendfile [lindex $argv 4]
|
||||
set desdir [lindex $argv 5]
|
||||
|
||||
set timeout 120
|
||||
|
||||
spawn sftp $username@$remoteip
|
||||
|
||||
|
||||
|
||||
expect "yes/no" {send "yes\n"; expect "*assword: "} "*assword: "
|
||||
send "$userpass\n"
|
||||
expect "*sftp>*"
|
||||
send "cd $desdir\n"
|
||||
send "lcd $resdir\n"
|
||||
send "put $sendfile\n"
|
||||
|
||||
expect "*100%*"
|
||||
exit
|
||||
2032
src/accountMgr/c_program/sftpSend/sftp.c
Normal file
2032
src/accountMgr/c_program/sftpSend/sftp.c
Normal file
File diff suppressed because it is too large
Load Diff
127
src/accountMgr/c_program/sftpSend/sftp.h
Normal file
127
src/accountMgr/c_program/sftpSend/sftp.h
Normal file
@@ -0,0 +1,127 @@
|
||||
/*************************************************
|
||||
File name:sftp.h
|
||||
Author: JianHui Zheng
|
||||
Version: 9:00:00
|
||||
Date: 2007-10-9
|
||||
Description:sftp.c<><63>ͷ<EFBFBD>ļ<EFBFBD>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
History:
|
||||
No.
|
||||
Author:
|
||||
Date:
|
||||
Version:
|
||||
Description:
|
||||
*************************************************/
|
||||
#ifndef _SFTP_SEND_H_
|
||||
#define _SFTP_SEND_H_
|
||||
|
||||
#include <pthread.h>
|
||||
#include <assert.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 <stdarg.h>
|
||||
#include <syslog.h>
|
||||
#include <sys/io.h>
|
||||
#include <error.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
#ifndef _T_DWORD
|
||||
#define _T_DWORD
|
||||
typedef unsigned int DWORD;
|
||||
#endif
|
||||
|
||||
#include "mysql.h"
|
||||
|
||||
#include "../../../../plat/public/src/include/pub_include.h"
|
||||
#include "../../../omcLib/c_program/omcLib/omcLib.h"
|
||||
#include "../../../../plat/snmp/src/include/snmp.h"
|
||||
|
||||
/********************************************************/
|
||||
/****** Constant Define ******/
|
||||
/********************************************************/
|
||||
/* The hpmn servers info update timeslot (Second) */
|
||||
#define HPMN_INFO_UPDATE_TIME 60
|
||||
/* The hpmn servers count which this version to support */
|
||||
#define HPMN_SERVER_COUNT 100
|
||||
/* Wait time when the server send file fail */
|
||||
#define WAIT_TIME 10
|
||||
/* The max number of thread */
|
||||
#define MAX_THREAD_NUM 8
|
||||
|
||||
#define MAX_FAIL_TIMEOUT 300
|
||||
|
||||
/* The max number of File Transfer object */
|
||||
#define MAX_FILE_TRANSFER_NUM 32
|
||||
|
||||
|
||||
/* The return value of the function */
|
||||
#define SUCCESSFUL 1
|
||||
#define FAIL 0
|
||||
|
||||
#ifndef SFTP_DEBUG
|
||||
#define SFTP_DEBUG 0
|
||||
#endif
|
||||
|
||||
/********************************************************/
|
||||
/****** Struct Define ******/
|
||||
/********************************************************/
|
||||
/* The information of the hpmn servers */
|
||||
typedef struct HpmnServer
|
||||
{
|
||||
char mcc[8]; //The mcc of the HPMN server
|
||||
char mnc[8]; //The mnc of the HPMN server
|
||||
char tadig[8]; //The tadig of the HPMN server, length=5
|
||||
char serverIP[16]; //The remote IP address of the HPMN server, xxx.xxx.xxx.xxx
|
||||
char loginName[64]; //The user name to login the remote HPMN server
|
||||
char loginPass[64]; //The user password to login the remote HPMN server
|
||||
int timeSlot; //The timeslot to send the nrtrde to the remote HPMN server
|
||||
char reportDir[256]; //The directory to send the report files to the HPMN server
|
||||
char nrtrdeDir[256]; //The directory to send the nrtrde files to the HPMN server
|
||||
|
||||
int sendFileTimeout; //When the value<0, then send the nrtrde file to remote HPMN server
|
||||
}HpmnServer;
|
||||
|
||||
/* The information of the file transfer object */
|
||||
typedef struct FileTransfer
|
||||
{
|
||||
char srcDir[128];
|
||||
char dstDir[128];
|
||||
char dstIP[16];
|
||||
char filter[16];
|
||||
char logName[32];
|
||||
char logPass[32];
|
||||
int curFileIndex;
|
||||
int waitTime;
|
||||
int failTimeout;
|
||||
}FileTransfer;
|
||||
|
||||
#endif
|
||||
126
src/accountMgr/c_program/sftpSend/sftpSend.c
Normal file
126
src/accountMgr/c_program/sftpSend/sftpSend.c
Normal file
@@ -0,0 +1,126 @@
|
||||
/*************************************************
|
||||
File name:sftpSend.c
|
||||
Author:
|
||||
Version: 9:00:00
|
||||
Date: 2007-10-9
|
||||
Description:<3A><><EFBFBD><EFBFBD>sftpģ<70><C4A3><EFBFBD>Ķ<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
|
||||
|
||||
|
||||
|
||||
History:
|
||||
No.
|
||||
Author:
|
||||
Date:
|
||||
Version:
|
||||
Description:
|
||||
*************************************************/
|
||||
|
||||
#include "sftp.h"
|
||||
|
||||
extern void sftpsend_timer();
|
||||
extern void sftp_init();
|
||||
static struct itimerval itimer, old_itimer;
|
||||
static void On_Timer();
|
||||
static void SetTimer();
|
||||
|
||||
/*************************************************
|
||||
Function: // main
|
||||
Description: //
|
||||
Calls: //
|
||||
Called By: //
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
pid_t pid;
|
||||
|
||||
|
||||
if (argc == 2 && strstr(argv[1], "-d")) {
|
||||
if ((pid = fork()) != 0)
|
||||
exit(0);
|
||||
setsid();
|
||||
}
|
||||
|
||||
sftp_init();
|
||||
|
||||
SetTimer();
|
||||
while (1) {
|
||||
usleep(50);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // On_Timer
|
||||
Description: // <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Calls: // sftpsend_timer
|
||||
Called By: //
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void On_Timer()
|
||||
{
|
||||
//long l_time;
|
||||
//struct tm *t;
|
||||
|
||||
//l_time = time(NULL);
|
||||
//t = localtime(&l_time);
|
||||
|
||||
sftpsend_timer();
|
||||
/*****test************/
|
||||
|
||||
//printf("timer-%02d\n",t->tm_sec);
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // SetTimer
|
||||
Description: // <20><><EFBFBD>ö<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Calls: // On_Timer
|
||||
Called By: //
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void SetTimer()
|
||||
{
|
||||
struct sigaction act;
|
||||
act.sa_handler = On_Timer;
|
||||
sigemptyset(&act.sa_mask);
|
||||
act.sa_flags = 0;
|
||||
if (sigaction(SIGALRM, &act, NULL) < 0) {
|
||||
perror("Produce Sigaction");
|
||||
exitLog("sftpSend:SetTimer, sigaction function error");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// itimer.it_interval.tv_sec = 0;
|
||||
// itimer.it_interval.tv_usec = 1000 * 1000;
|
||||
// itimer.it_value.tv_sec = 0;
|
||||
// itimer.it_value.tv_usec = 20 * 1000;
|
||||
|
||||
|
||||
itimer.it_interval.tv_sec = 1;
|
||||
itimer.it_interval.tv_usec = 0;
|
||||
itimer.it_value.tv_sec = 0;
|
||||
itimer.it_value.tv_usec = 20 * 1000;
|
||||
|
||||
|
||||
if (setitimer(ITIMER_REAL, &itimer, &old_itimer) != 0) {
|
||||
printf("Setting Timer error! \n");
|
||||
exitLog("sftpSend:SetTimer, setitimer function error");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
92
src/accountMgr/c_program/smcli/Makefile
Normal file
92
src/accountMgr/c_program/smcli/Makefile
Normal file
@@ -0,0 +1,92 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Makefile for smcli module.
|
||||
|
||||
CC = gcc
|
||||
CFLAGS=-D_REENTRANT -g -Wall
|
||||
|
||||
dbINCLUDE_FLAGS = -I/usr/local/mysql/include
|
||||
dbINCLUDE_FLAGS.ES = -I/usr/include/mariadb
|
||||
|
||||
dbLib = -L/usr/local/mysql/lib -lmariadbclient -lz
|
||||
dbLib.ES = -L/usr/lib/mysql -lmariadbclient -lm
|
||||
|
||||
omcLib = -L../../../omcLib/c_program/omcLib -lomcLib
|
||||
|
||||
LIB_FLAGS = $(omcLib) $(dbLib)
|
||||
|
||||
|
||||
LIB_FLAGS.ES=-L../../../omcLib/c_program/omcLib -lomcLib \
|
||||
-L../../../../plat/snmp/lib -lsnmp \
|
||||
-L../../../../plat/sccp/lib -lsccp \
|
||||
-L../../../../plat/iptrans/lib -liptrans \
|
||||
-L../../../../plat/debug/lib -ldebug \
|
||||
-L../../../../plat/public/lib -lpublic \
|
||||
-L/usr/lib/mysql -lmariadbclient -lm
|
||||
|
||||
CHECK_INDENT=indent -kr -ts4 *.c *.h
|
||||
|
||||
LINK_SUFFIX = $(LIB_FLAGS)
|
||||
LINK_SUFFIX.ES = $(LIB_FLAGS.ES)
|
||||
|
||||
PROGS = smcli
|
||||
|
||||
PROGS_OBJ = commands.o smcli.o pmcli.o
|
||||
PROGS_OBJ.ES = commands.o.ES smcli.o.ES pmcli.o.ES
|
||||
|
||||
default: linuxES
|
||||
|
||||
all:
|
||||
@echo " **** Compiling $(PROGS) ****"
|
||||
@echo "make clean -- Delete the target files"
|
||||
@echo "make linux72 -- Generate target files for Redhat Linux 72"
|
||||
@echo "make linuxES -- Generate target files for Redhat Linux ES"
|
||||
|
||||
linux72: $(PROGS_OBJ)
|
||||
@cd ../../../omcLib/c_program/omcLib; make clean; make linux72; cd -
|
||||
@cd ../../../accountMgr/c_program/smcli;
|
||||
@echo Linking $(PROGS)
|
||||
#$(CHECK_INDENT)
|
||||
@$(CC) $(CFLAGS) -o $(PROGS) $(PROGS_OBJ) $(LINK_SUFFIX)
|
||||
rm -f *.o core *~
|
||||
cp -f $(PROGS) ../../../bin
|
||||
cp -f $(PROGS) /usr/local/omc/bin/
|
||||
|
||||
linuxES: $(PROGS_OBJ.ES)
|
||||
@cd ../../../omcLib/c_program/omcLib; make linuxES; cd -
|
||||
@cd ../../../accountMgr/c_program/smcli;
|
||||
@echo Linking $(PROGS)
|
||||
#$(CHECK_INDENT)
|
||||
@$(CC) $(CFLAGS) -o $(PROGS) $(PROGS_OBJ) $(LINK_SUFFIX.ES)
|
||||
|
||||
installbin: linuxES
|
||||
cp -f $(PROGS) ../../../../bin/
|
||||
|
||||
installomc: linuxES
|
||||
cp -f $(PROGS) /usr/local/omc/bin/
|
||||
|
||||
installall: installbin installomc
|
||||
|
||||
commands.o: commands.c smcli.h
|
||||
$(CC) $(CFLAGS) -c commands.c $(dbINCLUDE_FLAGS)
|
||||
|
||||
smcli.o: smcli.c
|
||||
$(CC) $(CFLAGS) -c smcli.c $(dbINCLUDE_FLAGS)
|
||||
|
||||
#added for the configuration of parameters
|
||||
pmcli.o: pmcli.c
|
||||
$(CC) $(CFLAGS) -c pmcli.c $(dbINCLUDE_FLAGS)
|
||||
|
||||
commands.o.ES: commands.c smcli.h
|
||||
$(CC) $(CFLAGS) -c commands.c $(dbINCLUDE_FLAGS.ES)
|
||||
|
||||
smcli.o.ES: smcli.c
|
||||
$(CC) $(CFLAGS) -c smcli.c $(dbINCLUDE_FLAGS.ES)
|
||||
|
||||
pmcli.o.ES: pmcli.c
|
||||
$(CC) $(CFLAGS) -c pmcli.c $(dbINCLUDE_FLAGS.ES)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(PROGS)
|
||||
@cd ../../../accountMgr/c_program/smcli; rm -f *.o *.a; cd ..
|
||||
|
||||
5068
src/accountMgr/c_program/smcli/commands.c
Normal file
5068
src/accountMgr/c_program/smcli/commands.c
Normal file
File diff suppressed because it is too large
Load Diff
1226
src/accountMgr/c_program/smcli/pmcli.c
Normal file
1226
src/accountMgr/c_program/smcli/pmcli.c
Normal file
File diff suppressed because it is too large
Load Diff
5203
src/accountMgr/c_program/smcli/smcli.c
Normal file
5203
src/accountMgr/c_program/smcli/smcli.c
Normal file
File diff suppressed because it is too large
Load Diff
300
src/accountMgr/c_program/smcli/smcli.h
Normal file
300
src/accountMgr/c_program/smcli/smcli.h
Normal file
@@ -0,0 +1,300 @@
|
||||
/*************************************************
|
||||
File name: smcli.h
|
||||
Author:
|
||||
Version: 9:00:00
|
||||
Date: 2007-8-4
|
||||
Description:smcli.c的头文件,定义了unitOptDef,CmdBuf,PORT_STATUS等结构
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
History:
|
||||
No.
|
||||
Author:
|
||||
Date:
|
||||
Version:
|
||||
Description:
|
||||
*************************************************/
|
||||
#ifndef _SMCLI_H_
|
||||
#define _SMCLI_H_
|
||||
|
||||
#include <assert.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 <stdarg.h>
|
||||
#include <syslog.h>
|
||||
#include <sys/io.h>
|
||||
#include <error.h>
|
||||
|
||||
|
||||
#include "mysql.h"
|
||||
#include "../../../../plat/public/src/include/pub_include.h"
|
||||
#include "../../../omcLib/c_program/omcLib/omcLib.h"
|
||||
#include "../../../../plat/snmp/src/include/snmp.h"
|
||||
|
||||
#define SMCLI_VERSION "R9V0_1"
|
||||
#define MAX_CLIENTS 48
|
||||
#define SMCLI_PORT 4999
|
||||
|
||||
#define MaxCmdTypeNum 9
|
||||
|
||||
#define delayTime 500
|
||||
|
||||
#define CmdBufSize 12
|
||||
|
||||
//Command TypeNo define
|
||||
#define CMD_READ 1
|
||||
#define CMD_MODIFY 2
|
||||
#define CMD_CREATE 3
|
||||
#define CMD_DELETE 4
|
||||
#define CMD_CONNECT 5
|
||||
#define CMD_EXPORT 6
|
||||
#define CMD_IMPORT 7
|
||||
#define CMD_DISCONNECT 8
|
||||
#define CMD_RECHARGE 9 //20041010
|
||||
#define CMD_ALIVE 90
|
||||
#define CMD_HELP 91
|
||||
|
||||
//Database table define
|
||||
#define CommandTable "OMC_PUB.subscriberComm"
|
||||
#define paramCommandTable "OMC_PUB.parameterComm"
|
||||
#define sysInfoTable "OMC_PUB.sysInfo"
|
||||
#define sysSubsConfTable "OMC_PUB.sysSubsConf" //20041101
|
||||
#define sysUserTable "OMC_PUB.sysUser" //operator table
|
||||
#define sysOperLogTable "OMC_PUB.sysOperLog"
|
||||
#define smcliIndexTable "OMC_PUB.smcliIndex" //20041119
|
||||
|
||||
#define SMCLI_DEFAULT_VALUE_FILE "/usr/local/apache/htdocs/smcliDefaultValue.txt"
|
||||
|
||||
//Error display define
|
||||
#define ERR_0000 "0000:Command successful"
|
||||
#define ERR_0001 "0001:Unknown command"
|
||||
#define ERR_0002 "0002:Invalid syntax"
|
||||
#define ERR_0003 "0003:Invalid command"
|
||||
#define ERR_0004 "0004:Incomplete command"
|
||||
#define ERR_0005 "0005:No privilege command"
|
||||
#define ERR_0010 "0010:Unknown parameter"
|
||||
#define ERR_0011 "0011:Duplicate parameter"
|
||||
#define ERR_0012 "0012:No privilege parameter"
|
||||
#define ERR_0200 "0200:Command failed(General failed)"
|
||||
#define ERR_0201 "0201:The value is too big"
|
||||
#define ERR_0202 "0202:No such field"
|
||||
#define ERR_0203 "0203:Error field value"
|
||||
#define ERR_0204 "0204:The field is read only"
|
||||
#define ERR_0205 "0205:General error (not defined error)"
|
||||
#define ERR_0206 "0206:No access to the field"
|
||||
#define ERR_0207 "0207:Wrong value type"
|
||||
#define ERR_0208 "0208:Wrong value length"
|
||||
#define ERR_0209 "0209:Wrong encoding of the value"
|
||||
#define ERR_0210 "0210:Wrong value of the field"
|
||||
#define ERR_0211 "0211:Cannot create the record"
|
||||
#define ERR_0212 "0212:The value is incosistent"
|
||||
#define ERR_0213 "0213:Resource unavailable"
|
||||
#define ERR_0214 "0214:Commit failed(try again)"
|
||||
#define ERR_0215 "0215:Undo failed"
|
||||
#define ERR_0216 "0216:Error authorization info"
|
||||
#define ERR_0217 "0217:The field is not writable"
|
||||
#define ERR_0218 "0218:Inconsistent field name"
|
||||
#define ERR_0251 "0251:Unknown error"
|
||||
#define ERR_0252 "0252:Cannot send command to one object at same time"
|
||||
#define ERR_0254 "0254:You must connect the server firstly"
|
||||
#define ERR_0255 "0255:Execute time out"
|
||||
#define ERR_0256 "0256:Cannot find this server"
|
||||
#define ERR_0257 "0257:Password error"
|
||||
#define ERR_0258 "0258:Cannot open the file"
|
||||
#define ERR_0259 "0259:The subscriber status is invalid"
|
||||
#define ERR_0260 "0260:Connection failure to"
|
||||
#define ERR_0261 "0261:You have connected a server,please disconnect the server firstly"
|
||||
#define ERR_0300 "0300:Time out,please login again"
|
||||
|
||||
//commState define (define in subsComm.h)
|
||||
#define nProcFail 0
|
||||
#define nWaitProc 1
|
||||
#define nInProc 2
|
||||
#define nOutProc 3
|
||||
|
||||
#define InputBufSize 8192
|
||||
#define OutputBufSize 8192
|
||||
#define MaxOptNum 512
|
||||
|
||||
typedef struct unitOptDef {
|
||||
unsigned char optFlag[MaxCmdTypeNum + 1];
|
||||
//[0]:usedFlag;0=no use,1=used
|
||||
//[1-8]:match to command type no;0=mandatory,1~8=privilege1..........privilege8,9=nouse
|
||||
|
||||
char optName[64]; //参数名称
|
||||
long int exMode; //参数值的转换存储模式
|
||||
//const
|
||||
char fieldName[64]; //参数在数据库里的名称
|
||||
char initFieldValue[256]; //参数的默认值
|
||||
|
||||
char optValue[256]; //参数值
|
||||
char fieldValue[256]; //参数在数据库里存储的值
|
||||
} unitOptDef;
|
||||
|
||||
typedef struct CmdBuf {
|
||||
unsigned char isConnected;
|
||||
//const
|
||||
char serverStr[64]; //设备服务器名称
|
||||
//const
|
||||
char objectStr[64]; //操作对象名称
|
||||
char ip[16]; //设备服务器IP地址
|
||||
|
||||
//const
|
||||
int sysTypeNo; //设备号
|
||||
int sysNo; //系统号
|
||||
int subSysNo; //子系统号
|
||||
//const
|
||||
int dataTypeNo; //用户数据类型号
|
||||
|
||||
char srcTable[64]; //
|
||||
char tmpTable[64]; //20041101
|
||||
|
||||
char paramStr[64];
|
||||
char paramTable[64];
|
||||
|
||||
//const
|
||||
char cmdFlag[MaxCmdTypeNum];//八种操作的权限
|
||||
//match to CmdList's sort,0=no support 1~8=privilege1............privilege8
|
||||
|
||||
unsigned int optDefNum; //命令可以操作的命令对象个数
|
||||
unitOptDef optDef[MaxOptNum]; //命令可以操作的所有参数对象
|
||||
} CmdBuf;
|
||||
/* by simon at 23/9/26 */
|
||||
// CmdBuf defCmdBuf[CmdBufSize];
|
||||
|
||||
// struct sockaddr_in cliaddr;
|
||||
|
||||
typedef struct PORT_STATUS {
|
||||
int connfd;
|
||||
DWORD peerip;
|
||||
int peerport;
|
||||
char username[64];
|
||||
char passwd[64];
|
||||
int failNo;
|
||||
unsigned char loginFlag;
|
||||
unsigned char usernameFlag;
|
||||
unsigned char isConnected[CmdBufSize];
|
||||
char serverStr[CmdBufSize][64];
|
||||
char ip[CmdBufSize][16];
|
||||
int sysNo[CmdBufSize];
|
||||
int subSysNo[CmdBufSize];
|
||||
int cmdBufNum;
|
||||
unsigned char fieldNameFlag;
|
||||
char fieldNameList[2048];
|
||||
char exportFieldsStr[1024];
|
||||
FILE *expFile;
|
||||
FILE *impFile;
|
||||
FILE *impLogFile;
|
||||
long int exportedNum;
|
||||
long int exportNum;
|
||||
long int exportMaxNum;
|
||||
long int importedNum;
|
||||
long int importNum;
|
||||
BOOL expDoingFlag;
|
||||
BOOL impDoingFlag;
|
||||
char tmpInputBuf[InputBufSize];
|
||||
unsigned char privilege;
|
||||
long time;
|
||||
int paramOperationCount;
|
||||
|
||||
int multiPacketFlag;
|
||||
char secondPacket[InputBufSize];
|
||||
} _PORT_STATUS;
|
||||
|
||||
/* by simon at 23/9/26*/
|
||||
// _PORT_STATUS port_status[MAX_CLIENTS];
|
||||
|
||||
// CmdBuf *cmdBuf;
|
||||
|
||||
//option Flag value define
|
||||
#define Op_N 0 //no use
|
||||
#define Op_M 1 //mandatory
|
||||
#define Op_O 2 //optional
|
||||
#define Op_S 3 //subjoin
|
||||
|
||||
//default option define,Everyone CmdBuf must have those option
|
||||
#define OptNo_ipaddress 0
|
||||
#define OptNo_passwd 1
|
||||
#define OptNo_expfile 2
|
||||
#define OptNo_query 3
|
||||
#define OptNo_fields 4
|
||||
#define OptNo_max 5
|
||||
#define OptNo_impfile 6
|
||||
#define OptNo_srvip 7
|
||||
//#define OptNo_index 8 //index field
|
||||
//#define OptNo_indexSec 9 //if have second index field
|
||||
/* by simon at 23/9/26 */
|
||||
// int OptNo_index;
|
||||
#define HLR_OptNo_indexSec 11 //if have second index field
|
||||
|
||||
#define OptNo_password 9
|
||||
#define OptNo_privilege 11
|
||||
|
||||
//exchange mode define
|
||||
#define exM_same 0
|
||||
#define exM_undefined 255
|
||||
#define exM_byte0_bit0 100
|
||||
#define exM_byte0_bit1 101
|
||||
#define exM_byte0_bit2 102
|
||||
#define exM_byte0_bit3 103
|
||||
#define exM_byte0_bit4 104
|
||||
#define exM_byte0_bit5 105
|
||||
#define exM_byte0_bit6 106
|
||||
#define exM_byte0_bit7 107
|
||||
#define exM_byte1_bit0 110
|
||||
#define exM_byte1_bit1 111
|
||||
#define exM_byte1_bit2 112
|
||||
#define exM_byte1_bit3 113
|
||||
#define exM_byte1_bit4 114
|
||||
#define exM_byte2_bit0 120
|
||||
#define exM_byte2_bit1 121
|
||||
#define exM_byte2_bit3 123
|
||||
#define exM_byte2_bit4 124
|
||||
#define exM_byte3_bit0 130
|
||||
#define exM_byte4_bit0 140
|
||||
#define exM_byte4_bit1 141
|
||||
#define exM_byte4_bit5 145
|
||||
/*
|
||||
if (exchange mode ==x1*10000000+x2*100000+x3*1000+x4){
|
||||
x1:the optValue type;//0:unsigned digit,1:unsigned hex,2:signed digit,3:signed hex,4:unsigned digit and bofore check the length of the optValue,the optValue need change to hex,5:signed digit and bofore check the length of the optValue,the optValue need change to hex,9:string
|
||||
x2:the min length of the value
|
||||
x3:the max length of the value
|
||||
x4:exchange mode
|
||||
}
|
||||
*/
|
||||
int exValueFieldToOpt(int optNo);
|
||||
int exValueOptToField(int optNo);
|
||||
|
||||
int getBitValue(char *hexStr, int byteOffset, int bitOffset,
|
||||
unsigned char *bitValue);
|
||||
int setBitValue(char *hexStr, int byteOffset, int bitOffset,
|
||||
unsigned char bitValue);
|
||||
void fieldSync(int optNo);
|
||||
int hex2dec(char *hexStr, char *decStr);
|
||||
|
||||
#endif
|
||||
78
src/accountMgr/c_program/subsComm/Makefile
Normal file
78
src/accountMgr/c_program/subsComm/Makefile
Normal file
@@ -0,0 +1,78 @@
|
||||
#!/bin/sh
|
||||
|
||||
#Author: Cui Ticun
|
||||
#Version: 9.00.00
|
||||
#Date: 2007-7-1
|
||||
#Description: Makefile for subsComm module.
|
||||
|
||||
CC = gcc
|
||||
CFLAGS=-D_REENTRANT -g -Wall
|
||||
|
||||
dbINCLUDEFLAG = -I/usr/local/mysql/include
|
||||
dbLINKFLAG = -L/usr/local/mysql/lib -lmariadbclient -lz
|
||||
|
||||
dbINCLUDEFLAG.ES = -I/usr/include/mariadb
|
||||
dbLINKFLAG.ES = -L/usr/lib/mysql -lmariadbclient -lz
|
||||
|
||||
LINKFLAG=-L../../../omcLib/c_program/omcLib -lomcLib \
|
||||
-L../../../../plat/snmp/lib -lsnmp \
|
||||
-L../../../../plat/sccp/lib -lsccp \
|
||||
-L../../../../plat/iptrans/lib -liptrans \
|
||||
-L../../../../plat/debug/lib -ldebug \
|
||||
-L../../../../plat/public/lib -lpublic \
|
||||
-L/usr/lib/x86_64-linux-gnu -lpthread \
|
||||
|
||||
LINK_SUFFIX = $(dbINCLUDEFLAG) $(dbLINKFLAG) $(LINKFLAG)
|
||||
LINK_SUFFIX.ES = $(dbINCLUDEFLAG.ES) $(dbLINKFLAG.ES)$(LINKFLAG)
|
||||
|
||||
PROGS = subsComm
|
||||
|
||||
SUBSCOMM_OBJ = subsCommMain.o subsComm.o
|
||||
SUBSCOMM_OBJ.ES = subsCommMain.o.ES subsComm.o.ES
|
||||
|
||||
LIB_OBJ = subsComm.o
|
||||
LIB_OBJ.ES = subsComm.o.ES
|
||||
|
||||
default: linuxES
|
||||
|
||||
all:
|
||||
@echo " **** Compiling $(PROGS) ****"
|
||||
@echo "make clean -- Delete the target files"
|
||||
@echo "make linux72 -- Generate target files for Redhat Linux 72"
|
||||
@echo "make linuxES -- Generate target files for Redhat Linux ES"
|
||||
|
||||
linux72: $(SUBSCOMM_OBJ)
|
||||
@echo Linking $(PROGS)
|
||||
@$(CC) $(CFLAGS) -o $(PROGS) $(SUBSCOMM_OBJ) $(LINK_SUFFIX) -lm
|
||||
ar r libsubsComm.a $(LIB_OBJ)
|
||||
rm -f *.o core *~
|
||||
#cp -f $(PROGS) ../../../../bin
|
||||
#cp -f $(PROGS) /usr/local/omc/bin/
|
||||
|
||||
linuxES: $(SUBSCOMM_OBJ.ES)
|
||||
@echo Linking $(PROGS)
|
||||
@$(CC) $(CFLAGS) -o $(PROGS) $(SUBSCOMM_OBJ) $(LINK_SUFFIX.ES) -lm
|
||||
ar r libsubsComm.a $(LIB_OBJ)
|
||||
|
||||
installbin: linuxES
|
||||
cp -f $(PROGS) ../../../../bin/
|
||||
|
||||
installomc: linuxES
|
||||
cp -f $(PROGS) /usr/local/omc/bin/
|
||||
|
||||
installall: installbin installomc
|
||||
|
||||
subsCommMain.o: subsCommMain.c
|
||||
$(CC) $(CFLAGS) -c subsCommMain.c $(dbINCLUDEFLAG)
|
||||
|
||||
subsComm.o: subsComm.c
|
||||
$(CC) $(CFLAGS) -c subsComm.c $(dbINCLUDEFLAG)
|
||||
|
||||
subsCommMain.o.ES: subsCommMain.c
|
||||
$(CC) $(CFLAGS) -c subsCommMain.c $(dbINCLUDEFLAG.ES)
|
||||
|
||||
subsComm.o.ES: subsComm.c
|
||||
$(CC) $(CFLAGS) -c subsComm.c $(dbINCLUDEFLAG.ES)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(PROGS)
|
||||
27
src/accountMgr/c_program/subsComm/remark.txt
Normal file
27
src/accountMgr/c_program/subsComm/remark.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
//test Sql
|
||||
INSERT INTO subscriberComm (commType, sysTypeNo, sysNo, subSysNo, bufferNo, fieldNameList, paramType, commState, totalNum, finishNum, sendTime, bgnTime, endTime, remark)
|
||||
VALUES ('5', '360', '1', '0', '1', 'ALL', '4', '1', '', '', '2003-02-21 15:57:30', '', '', '')
|
||||
|
||||
|
||||
|
||||
INSERT INTO sysSubsConf
|
||||
VALUES ( '251', '0', '1', '1.3.6.1.4.1.1373.1.3.3.6.2.2.2.1', '1.3.6.1.4.1.1373.1.3.3.6.2.3.1', 'imsi', '1000', '100', 'snDb.subscriberData');
|
||||
|
||||
INSERT INTO sysSubsConf
|
||||
VALUES ( '330', '0', '1', '1.3.6.1.4.1.1373.1.3.3.3.2.6', '1.3.6.1.4.1.1373.1.3.3.3.2.7', 'imsi', '1000', '100', 'HlrDb.subscriberData');
|
||||
|
||||
INSERT INTO sysSubsConf
|
||||
VALUES ( '340', '0', '1', '1.3.6.1.4.1.1373.1.3.3.6.2.2.2.1', '1.3.6.1.4.1.1373.1.3.3.6.2.3.1', 'key_imsi', '1000', '100', 'AUC_Para.AUC_Dyn_data');
|
||||
|
||||
INSERT INTO sysSubsConf
|
||||
VALUES ( '360', '0', '1', '1.3.6.1.4.1.1373.1.3.3.6.2.2.2.1', '1.3.6.1.4.1.1373.1.3.3.6.2.3.1', 'msisdn', '1000', '100', 'PPS_User_DB.user_info');
|
||||
|
||||
INSERT INTO sysSubsConf
|
||||
VALUES ( '380', '0', '1', '1.3.6.1.4.1.1373.1.3.3.6.2.2.2.1', '1.3.6.1.4.1.1373.1.3.3.6.2.3.1', 'imei', '1000', '100', 'EIR_Para.BlackGrayIMEI');
|
||||
|
||||
|
||||
UPDATE OBJ_330.subscriberParamConf SET level_1 = level_5,level_2 =level_6,level_3 ='0',level_4 ='0',
|
||||
level_7 ='0',level_8 ='0',level_9 ='0',level_10 ='0'
|
||||
UPDATE OBJ_330.subscriberParamConf SET level_5 = '0',level_6 = '0'
|
||||
2121
src/accountMgr/c_program/subsComm/subsComm.c
Normal file
2121
src/accountMgr/c_program/subsComm/subsComm.c
Normal file
File diff suppressed because it is too large
Load Diff
173
src/accountMgr/c_program/subsComm/subsComm.h
Normal file
173
src/accountMgr/c_program/subsComm/subsComm.h
Normal file
@@ -0,0 +1,173 @@
|
||||
/*************************************************
|
||||
File name: subsComm.h
|
||||
Author: He wan Dong
|
||||
Version: 9:00:00
|
||||
Date: 2003/02/14
|
||||
Description:subsComm.c<><63>ͷ<EFBFBD>ļ<EFBFBD>
|
||||
|
||||
|
||||
|
||||
|
||||
History:
|
||||
No.
|
||||
Author:
|
||||
Date:
|
||||
Version:
|
||||
Description:
|
||||
*************************************************/
|
||||
|
||||
#ifndef subsComm__H
|
||||
#define subsComm__H
|
||||
|
||||
#include "../../../../plat/public/src/include/pub_include.h"
|
||||
#include "../../../../plat/snmp/src/include/snmp.h"
|
||||
#include "../../../omcLib/c_program/omcLib/omcLib.h"
|
||||
|
||||
#ifndef MYSQL_H
|
||||
#include "mysql.h"
|
||||
#endif
|
||||
|
||||
#ifndef subsComm_DEBUG
|
||||
#define subsComm_DEBUG 0
|
||||
#endif
|
||||
|
||||
#define VMS_No 390
|
||||
/* fj added 2010-01-19, UDM<44><4D>AUSFҪ֧<D2AA>ַ<EFBFBD>Ƭ */
|
||||
#define UDM_No 365
|
||||
#define AUSF_No 366
|
||||
|
||||
#define subsComm_LogPath "../log"
|
||||
#define subsComm_LogFile "subsComm"
|
||||
#define subsComm_backupPath "/usr/local/apache/htdocs/db_backup/subsData"
|
||||
|
||||
#define FlagCode 1373 //snmp company code of iwv
|
||||
#define MaxCommNum 32 //max number of command can be execute as same time
|
||||
//The maxCommNum divides into 2 parts,The 0-15 is used for processing the commands in the subscriberComm table
|
||||
//The 16-31 is used for processing the loadData commands
|
||||
#define loadDataCommStartNo 16
|
||||
/* fj added 2020-01-19<31><39>UDM<44><4D>AUSF֧<46>ַ<EFBFBD>Ƭ */
|
||||
#define MaxSysConfNum 80//30
|
||||
#define MaxParamConfNum 2048 //512 -> 1024
|
||||
#define MaxIndexNumPerSeg 100
|
||||
#define MaxOidLen 20 //max number of object ID
|
||||
#define MaxSubOidLen 10 //max number of sub object ID
|
||||
//#define MaxLenOfOneVar 1024 //max len of one var_list
|
||||
#define MaxVarNum 50 //max number of var in one pdu
|
||||
#define DefPort 4959 //define port
|
||||
#define HOSTNAME "localhost"
|
||||
#define PUB_DB "OMC_PUB" //OMC's public database
|
||||
#define SysConfTable "OMC_PUB.sysConf" //system config table
|
||||
#define subsConfTable "OMC_PUB.sysSubsConf" //system config table
|
||||
#define CommTable "OMC_PUB.subscriberComm" //command table
|
||||
#define IpTable "OMC_PUB.sysInfo" //system's IP table
|
||||
#define subsDataBackupTable "OMC_PUB.subsDataBackup" //
|
||||
|
||||
//procState flag define
|
||||
#define nIdle 0 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC>nInProcʱ<63><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>״̬<D7B4><CCAC>nIdleʱ<65><CAB1><EFBFBD>Żᷢ<C5BB><E1B7A2>snmp<6D><70><EFBFBD>ݰ<EFBFBD>
|
||||
#define nWaitResponse 1 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC>nInProcʱ<63><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD>ִ<EFBFBD><D6B4>״̬<D7B4><CCAC><EFBFBD><EFBFBD>ΪnWaitResponse
|
||||
#define nWaitIdleComm 2
|
||||
|
||||
//commState flag define
|
||||
#define nProcFail 0 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>״̬<D7B4><CCAC>nWaitResponseʱ<65><CAB1><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4>ظ<EFBFBD><D8B8><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>״̬
|
||||
#define nWaitProc 1 //һ<><D2BB><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>״̬
|
||||
#define nInProc 2 //<2F><>ʱ<EFBFBD><CAB1>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>nWaitProc״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>Ѵ<EFBFBD><D1B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>״̬
|
||||
#define nOutProc 3 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>״̬<D7B4><CCAC>nWaitResponseʱ<65><CAB1><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4>ظ<EFBFBD><D8B8><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD>Ϣ<EFBFBD><CFA2>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>״̬
|
||||
|
||||
//parameter type define
|
||||
#define nSubSysParam 0
|
||||
#define nSysParam 1
|
||||
|
||||
//snmp pdu type define [define in snmp.h]
|
||||
#define nGet 0
|
||||
#define nGetNext 1
|
||||
#define nResp 2
|
||||
#define nSet 3
|
||||
|
||||
//subscriber manage command type define
|
||||
#define nReadComm 1
|
||||
#define nChangeComm 2
|
||||
#define nCreateComm 3
|
||||
#define nDeleteComm 4
|
||||
#define nLoadIndexComm 5
|
||||
#define nReplaceIndexComm 6 //for hlr replace imsi
|
||||
#define nLoadDataComm 7 //just used in program
|
||||
|
||||
//snmp var type code
|
||||
#define nInteger 0x02
|
||||
#define nOctetString 0x04
|
||||
#define nNull 0x05
|
||||
#define nObjectId 0x06
|
||||
#define nNoSuchObject 0x80
|
||||
#define nNoSuchInstance 0x81
|
||||
#define nEndOfMibView 0x82
|
||||
|
||||
typedef struct unitSysConf{
|
||||
int isEnable; //ʹ<>ܱ<EFBFBD>־λ
|
||||
int sysTypeNo; //ϵͳ<CFB5>豸<EFBFBD><E8B1B8>
|
||||
int dataTypeNo; //<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD>Щϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>ֲ<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
||||
int sysNo; //ϵͳ<CFB5>ţ<EFBFBD><C5A3>ó<EFBFBD><C3B3><EFBFBD>ֻ<EFBFBD><D6BB>VSS<53><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3>
|
||||
DWORD preObjId[20]; //<2F><>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ݵ<EFBFBD>OID<49><44><EFBFBD><EFBFBD>Ҫ<EFBFBD>ڸ<EFBFBD>OID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>OID
|
||||
int preObjIdLen; //<2F><><EFBFBD><EFBFBD>
|
||||
DWORD indexObjId[20]; //<2F><>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>OID
|
||||
int indexObjIdLen; //<2F><><EFBFBD><EFBFBD>
|
||||
int maxMsgLen; //<2F><>Ϣ<EFBFBD><CFA2><EFBFBD>
|
||||
char snmpCommunity[16]; //SNMP<4D><50>֤<EFBFBD><D6A4>
|
||||
int maxSegmentNum; //<2F><><EFBFBD>豸<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
|
||||
int maxIndexNumPerSeg; //<2F><><EFBFBD>豸ÿ<E8B1B8>ε<EFBFBD><CEB5>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
char paramTableName[128]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>
|
||||
char tmpTableName[128]; //database.table
|
||||
int paramConfArrOffset; //<2F><>ϵͳ<CFB5>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>paramConfArr<72><72><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD>ʼλ<CABC><CEBB>
|
||||
int paramConfNum; //<2F><><EFBFBD><EFBFBD><EFBFBD>ֶεĸ<CEB5><C4B8><EFBFBD>
|
||||
char indexFieldSubOid[16]; //<2F>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>subsParamConf_X<5F><58><EFBFBD>е<EFBFBD>level<65><6C><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
||||
char indexFieldName[64]; //<2F>ؼ<EFBFBD><D8BC>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
BYTE indexValueLen; //<2F>ؼ<EFBFBD><D8BC>ֶγ<D6B6><CEB3><EFBFBD>
|
||||
}unitSysConf;
|
||||
|
||||
typedef struct unitParamConf{
|
||||
int sysTypeNo; //<2F>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ϵͳ<CFB5>豸<EFBFBD><E8B1B8>
|
||||
char fieldObjIdStr[16]; //<2F><>subsParamConf_<66><5F><EFBFBD>е<EFBFBD>level<65><6C><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
||||
char fieldName[64]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int valueType; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int valueLen; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//int initValue;
|
||||
}unitParamConf;
|
||||
|
||||
typedef struct unitComm{
|
||||
//command info
|
||||
WORD commNo; //ID in command table
|
||||
WORD commType; //0:invaild,1:read,2:change,3:create,4:delete,5:get index,6:get data in indexBuffer
|
||||
int sysConfArrNo; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>sysConfArr<72><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int dataTypeNo; //<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
WORD sysTypeNo; //ϵͳ<CFB5>豸<EFBFBD><E8B1B8>
|
||||
WORD sysNo; //ϵͳ<CFB5><CDB3>
|
||||
WORD subSysNo; //<2F><>ϵͳ<CFB5><CDB3>
|
||||
char dstIP[16]; //Զ<><D4B6><EFBFBD>豸IP<49><50>ַ
|
||||
WORD dstPort; //Զ<><D4B6><EFBFBD>豸<EFBFBD>˿<EFBFBD>
|
||||
int requestId; //snmp<6D><70><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD>request ID
|
||||
|
||||
MYSQL_RES *paramSet; //<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ݼ<EFBFBD>
|
||||
|
||||
char indexBuffer[MaxIndexNumPerSeg][19]; //per Segment,MaxIndexNumPerSeg=100
|
||||
BYTE tlvTotalNum; // <20><>ǰ<EFBFBD><C7B0>Ƭ<EFBFBD><C6AC><EFBFBD>ܹ<EFBFBD><DCB9><EFBFBD><EFBFBD>͵<EFBFBD>tlv<6C><76><EFBFBD><EFBFBD>Ŀ
|
||||
BYTE tlvFinishNum; // <20><>ǰ<EFBFBD><C7B0>Ƭ<EFBFBD><C6AC><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>tlv<6C><76><EFBFBD><EFBFBD>Ŀ
|
||||
BYTE tlvInvaildNum;
|
||||
char fieldNameList[2048]; //64*32
|
||||
|
||||
//command process info
|
||||
BYTE commState; //-1:nFailed,0:nWaitProc,1:nNoFinish,2:nFinished
|
||||
BYTE procState; //command process state:0=idle,1=waitResponse
|
||||
BYTE waitTimeCount; //the times number of timeout
|
||||
BYTE timeoutCount; //the timeCount
|
||||
WORD totalNum;
|
||||
WORD finishNum;
|
||||
char desc[200]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
//var_list info
|
||||
BYTE varNum;
|
||||
}unitComm;
|
||||
|
||||
//Interface Functions Declare,define in subsComm.c
|
||||
int subsCommInit();
|
||||
int subsCommTimer();
|
||||
|
||||
#endif
|
||||
173
src/accountMgr/c_program/subsComm/subsCommMain.c
Normal file
173
src/accountMgr/c_program/subsComm/subsCommMain.c
Normal file
@@ -0,0 +1,173 @@
|
||||
/*************************************************
|
||||
File name: subsCommMain.c
|
||||
Author: He wan Dong
|
||||
Version: 9:00:00
|
||||
Date: 2003-2-14
|
||||
Description:<3A><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>subsCommģ<6D><C4A3>
|
||||
|
||||
<09><><EFBFBD><EFBFBD>snmpģ<70><C4A3><EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD>
|
||||
void snmp_init(WORD nport);
|
||||
int snmp_receive(snmp_pdu *msgbuf,snmp_addr *addr);
|
||||
int snmp_send(snmp_pdu *msgbuf,snmp_addr *addr);
|
||||
|
||||
|
||||
|
||||
History:
|
||||
No.
|
||||
Author:
|
||||
Date:
|
||||
Version:
|
||||
Description:
|
||||
*************************************************/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "subsComm.h"
|
||||
|
||||
static struct itimerval itimer, old_itimer;
|
||||
|
||||
void onTimer();
|
||||
void setTimer();
|
||||
void setup_daemon(void);
|
||||
int timerCounter = 0;
|
||||
|
||||
/*************************************************
|
||||
Function: // main
|
||||
Description: // <20><><EFBFBD><EFBFBD>subsCommģ<6D>飬<EFBFBD><E9A3AC>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Calls: // snmp_init; iptrans_init;
|
||||
Called By: //
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: // 1:successful; 0:failed;
|
||||
Others: //
|
||||
*************************************************/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char runMode;
|
||||
debug_init();
|
||||
|
||||
fprintf(stderr, "\n Calling iptrans_init()");
|
||||
iptrans_init();
|
||||
|
||||
fprintf(stderr, "\n Calling snmp_init()");
|
||||
snmp_init(4959);
|
||||
subsCommInit();
|
||||
|
||||
if (argc > 0) {
|
||||
runMode = getopt(argc, argv, "d");
|
||||
switch (runMode) {
|
||||
case 'd':
|
||||
setup_daemon();
|
||||
break;
|
||||
case '?':
|
||||
break;
|
||||
}
|
||||
//debug_init();//must do it at first
|
||||
}
|
||||
setTimer();
|
||||
while (1) {
|
||||
usleep(50);
|
||||
}
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // onTimer
|
||||
Description: // <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Calls: // subsCommTimer;
|
||||
Called By: //
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void onTimer()
|
||||
{
|
||||
//debug_rt();
|
||||
//snmp_timer();
|
||||
if (timerCounter > 3) {
|
||||
timerCounter = 0;
|
||||
subsCommTimer();
|
||||
}
|
||||
timerCounter++;
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // setTimer
|
||||
Description: // <20><><EFBFBD>ö<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Calls: // onTimer;
|
||||
Called By: //
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void setTimer()
|
||||
{
|
||||
struct sigaction act;
|
||||
act.sa_handler = onTimer;
|
||||
sigemptyset(&act.sa_mask);
|
||||
act.sa_flags = 0;
|
||||
if (sigaction(SIGALRM, &act, NULL) < 0) {
|
||||
perror("Produce Sigaction");
|
||||
exitLog("subsComm:setTimer, sigaction function error");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
itimer.it_interval.tv_sec = 0;
|
||||
itimer.it_interval.tv_usec = 20 * 1000;
|
||||
itimer.it_value.tv_sec = 0;
|
||||
itimer.it_value.tv_usec = 20 * 1000;
|
||||
|
||||
if (setitimer(ITIMER_REAL, &itimer, &old_itimer) != 0) {
|
||||
printf("Setting Timer error! \n");
|
||||
exitLog("subsComm:setTimer, setitimer function error");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void setup_daemon(void)
|
||||
{
|
||||
/*
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
close(i);
|
||||
}
|
||||
*/
|
||||
switch (fork()) {
|
||||
case -1:
|
||||
perror("setup_daemon(), 1st fork()");
|
||||
exit(2);
|
||||
default:
|
||||
exit(0);
|
||||
case 0:
|
||||
if (setsid() == -1) {
|
||||
perror("setup_daemon(), setsid()");
|
||||
exit(3);
|
||||
}
|
||||
switch (fork()) {
|
||||
case -1:
|
||||
perror("setup_daemon(), 2nd fork()");
|
||||
exit(3);
|
||||
default:
|
||||
exit(0);
|
||||
case 0:
|
||||
umask(0);
|
||||
/* and return with daemon set up */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
28
src/accountMgr/c_program/subsComm/testReport
Normal file
28
src/accountMgr/c_program/subsComm/testReport
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
logFile=$1
|
||||
|
||||
echo "============Tesst Report================="
|
||||
echo -n "Got total vaild index: "
|
||||
grep -c " tlvValue = 9" $logFile
|
||||
grep -c " tlvValue = 8" $logFile
|
||||
grep -c " tlvValue = 7" $logFile
|
||||
grep -c " tlvValue = 6" $logFile
|
||||
grep -c " tlvValue = 5" $logFile
|
||||
grep -c " tlvValue = 4" $logFile
|
||||
grep -c " tlvValue = 3" $logFile
|
||||
grep -c " tlvValue = 2" $logFile
|
||||
grep -c " tlvValue = 1" $logFile
|
||||
grep -c " tlvValue = 0" $logFile
|
||||
#grep -c " tlvValue = 0" $logFile
|
||||
echo -n "Got total Null index: "
|
||||
grep -c " tlvValue = Null" $logFile
|
||||
echo -n "Try to get: "
|
||||
grep -c "Now get -> " $logFile
|
||||
echo "============timeout================="
|
||||
echo -n "Duplicate key index: "
|
||||
grep -c " Description: Duplicate" $logFile
|
||||
grep " Description: Duplicate" $logFile
|
||||
echo "============timeout================="
|
||||
echo -n "total : "
|
||||
grep -c "data timeout" $logFile
|
||||
grep "data timeout" $logFile
|
||||
84
src/accountMgr/c_program/subsDataBackup/Makefile
Normal file
84
src/accountMgr/c_program/subsDataBackup/Makefile
Normal file
@@ -0,0 +1,84 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Makefile for test snmpComm module.
|
||||
|
||||
CC = gcc
|
||||
CFLAGS=-D_REENTRANT -g -Wall
|
||||
|
||||
dbINCLUDE_FLAGS = -I/usr/local/mysql/include
|
||||
dbINCLUDE_FLAGS.ES = -I/usr/include/mariadb
|
||||
|
||||
dbLib = -L/usr/local/mysql/lib -lmariadbclient -lz
|
||||
dbLib.ES = -L/usr/lib/mysql -lmariadbclient -lm
|
||||
|
||||
omcLib = -L../../../omcLib/c_program/omcLib -lomcLib
|
||||
|
||||
LIB_FLAGS = $(omcLib) $(dbLib)
|
||||
#LIB_FLAGS.ES = $(omcLib) $(dbLib.ES)
|
||||
|
||||
LIB_FLAGS.ES=-L../../../omcLib/c_program/omcLib -lomcLib \
|
||||
-L../../../../plat/snmp/lib -lsnmp \
|
||||
-L../../../../plat/sccp/lib -lsccp \
|
||||
-L../../../../plat/iptrans/lib -liptrans \
|
||||
-L../../../../plat/debug/lib -ldebug \
|
||||
-L../../../../plat/public/lib -lpublic \
|
||||
-L/usr/lib/mysql -lmariadbclient -lm
|
||||
|
||||
|
||||
LINK_SUFFIX = $(LIB_FLAGS)
|
||||
LINK_SUFFIX.ES = $(LIB_FLAGS.ES)
|
||||
|
||||
PROGS = subsDataBackup
|
||||
|
||||
SNMPCOMM_OBJ = subsDataBackupMain.o subsDataBackup.o
|
||||
SNMPCOMM_OBJ.ES = subsDataBackupMain.o.ES subsDataBackup.o.ES
|
||||
|
||||
LIB_OBJ = subsDataBackup.o
|
||||
LIB_OBJ.ES = subsDataBackup.o.ES
|
||||
|
||||
default: linuxES
|
||||
|
||||
all:
|
||||
@echo " **** Compiling $(PROGS) ****"
|
||||
@echo "make clean -- Delete the target files"
|
||||
@echo "make linux72 -- Generate target files for Redhat Linux 72"
|
||||
@echo "make linuxES -- Generate target files for Redhat Linux ES"
|
||||
|
||||
linux72: $(SNMPCOMM_OBJ)
|
||||
@cd ../../../omcLib/c_program/omcLib; make clean; make linux72; cd -
|
||||
@echo Linking $(PROGS)
|
||||
@$(CC) $(CFLAGS) -o $(PROGS) $(SNMPCOMM_OBJ) $(LINK_SUFFIX)
|
||||
ar r libsubsDataBackup.a $(LIB_OBJ)
|
||||
rm -f *.o core *~
|
||||
cp -f $(PROGS) ../../../bin/
|
||||
cp -f $(PROGS) /usr/local/omc/bin/
|
||||
|
||||
linuxES: $(SNMPCOMM_OBJ.ES)
|
||||
@cd ../../../omcLib/c_program/omcLib; make clean; make linuxES; cd -
|
||||
@echo Linking $(PROGS)
|
||||
@$(CC) $(CFLAGS) -o $(PROGS) $(SNMPCOMM_OBJ) $(LINK_SUFFIX.ES)
|
||||
ar r libsubsDataBackup.a $(LIB_OBJ)
|
||||
|
||||
installbin: linuxES
|
||||
cp -f $(PROGS) ../../../../bin/
|
||||
|
||||
installomc: linuxES
|
||||
cp -f $(PROGS) /usr/local/omc/bin/
|
||||
|
||||
installall: installbin installomc
|
||||
|
||||
subsDataBackupMain.o: subsDataBackupMain.c
|
||||
$(CC) $(CFLAGS) -c subsDataBackupMain.c $(dbINCLUDE_FLAGS)
|
||||
|
||||
subsDataBackup.o: subsDataBackup.c
|
||||
$(CC) $(CFLAGS) -c subsDataBackup.c $(dbINCLUDE_FLAGS)
|
||||
|
||||
subsDataBackupMain.o.ES: subsDataBackupMain.c
|
||||
$(CC) $(CFLAGS) -c subsDataBackupMain.c $(dbINCLUDE_FLAGS.ES)
|
||||
|
||||
subsDataBackup.o.ES: subsDataBackup.c
|
||||
$(CC) $(CFLAGS) -c subsDataBackup.c $(dbINCLUDE_FLAGS.ES)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(PROGS)
|
||||
@cd ../../../accountMgr/c_program/subsDataBackup; rm -f *.o *.a; cd ..
|
||||
669
src/accountMgr/c_program/subsDataBackup/subsDataBackup.c
Normal file
669
src/accountMgr/c_program/subsDataBackup/subsDataBackup.c
Normal file
@@ -0,0 +1,669 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "mysql.h"
|
||||
|
||||
#include "subsDataBackup.h"
|
||||
|
||||
/******************************************************/
|
||||
/****** Heartbeat Parameter ******/
|
||||
/******************************************************/
|
||||
DWORD PROC_HEARTBEAT_OID[12]={1,3,6,1,4,1,1373,2,4,10,7};
|
||||
int PROC_HEARTBEAT_OIDLEN=11;
|
||||
int sendHeartbeat();
|
||||
|
||||
/* by simon at 23/9/25 */
|
||||
subsData_Backup subsDataBackup[MaxSysConfNum];
|
||||
|
||||
/**************subsdata backup functions declare**********************/
|
||||
void backupTimer();
|
||||
void sendCmd(int proc);
|
||||
void scanCmd(int proc);
|
||||
void backupFile(int proc);
|
||||
void debug_log(const char *fmt,...);
|
||||
|
||||
/***********subsdata backup global var declare And init*********************/
|
||||
//static FILE *subsDataBackupLog;
|
||||
static MYSQL *dbConn;
|
||||
|
||||
int subsDataBackupFlag=0;
|
||||
int automatic_scratch_card_time=0;
|
||||
int automatic_scratch_card_flag=0;
|
||||
int cmdId=0;
|
||||
int oldDayForLog = 0; //1-31
|
||||
int oldDayForBackup = 0; //1-31
|
||||
unsigned long waitTime;
|
||||
int waitFlag;
|
||||
unsigned long inTime;
|
||||
int inFlag;
|
||||
int lastFinishNum=0;
|
||||
int finishFlag;
|
||||
unsigned long finishTime;
|
||||
|
||||
void subsDataBackupInit()
|
||||
{
|
||||
int i=0;
|
||||
char tmpSql[1024];
|
||||
MYSQL_RES *tmpResult = NULL;
|
||||
MYSQL_ROW tmpRow = NULL;
|
||||
|
||||
debug_init(1);
|
||||
iptrans_init();
|
||||
snmp_init(4957);
|
||||
//heartbeat_init(0);
|
||||
debug_log("subsDataBackup is starting......");
|
||||
dbConn = mysql_conn(HOSTNAME,PUB_DB);
|
||||
if(dbConn == NULL){
|
||||
debug_log("[ERR][subsDataBackupInit]connect OMC_PUB");
|
||||
exitLog("subsDataBackup:subsDataBackupInit, Connect OMC_PUB error");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sprintf(tmpSql,
|
||||
"SELECT pubVarValue FROM OMC_PUB.omcPubVarConf WHERE pubVarName='automatic_scratch_card_time'");
|
||||
tmpResult = (MYSQL_RES *) mysql_getres(dbConn, tmpSql);
|
||||
|
||||
if (tmpResult == NULL || mysql_num_rows(tmpResult) == 0){
|
||||
automatic_scratch_card_time = 0;
|
||||
mysql_free_result(tmpResult);
|
||||
debug_log("The automatic_scratch_card_time value is NULL");
|
||||
}else {
|
||||
tmpRow = mysql_fetch_row(tmpResult);
|
||||
automatic_scratch_card_time = atoi(tmpRow[0]);
|
||||
mysql_free_result(tmpResult);
|
||||
}
|
||||
if (automatic_scratch_card_time < 0 || automatic_scratch_card_time > 23){
|
||||
debug_log("The automatic_scratch_card_time value is %d not in range",automatic_scratch_card_time);
|
||||
automatic_scratch_card_time = 0;
|
||||
}
|
||||
debug_log("automatic_scratch_card_time=%d",automatic_scratch_card_time);
|
||||
|
||||
sprintf(tmpSql,
|
||||
"SELECT pubVarValue FROM OMC_PUB.omcPubVarConf WHERE pubVarName='automatic_scratch_card_flag'");
|
||||
tmpResult = (MYSQL_RES *) mysql_getres(dbConn, tmpSql);
|
||||
|
||||
if (tmpResult == NULL || mysql_num_rows(tmpResult) == 0){
|
||||
automatic_scratch_card_flag = 0;
|
||||
mysql_free_result(tmpResult);
|
||||
debug_log("The automatic_scratch_card_flag value is NULL");
|
||||
}else {
|
||||
tmpRow = mysql_fetch_row(tmpResult);
|
||||
automatic_scratch_card_flag = atoi(tmpRow[0]);
|
||||
mysql_free_result(tmpResult);
|
||||
}
|
||||
if (automatic_scratch_card_flag < 0 || automatic_scratch_card_flag > 1){
|
||||
debug_log("The automatic_scratch_card_time value %d is not in range",automatic_scratch_card_flag);
|
||||
automatic_scratch_card_flag = 0;
|
||||
}
|
||||
debug_log("automatic_scratch_card_flag=%d",automatic_scratch_card_flag);
|
||||
|
||||
sprintf(tmpSql, "SELECT subsDataBackup.sysTypeNo,subsDataBackup.dataTypeNo,subsDataTable,tmpDataTable"\
|
||||
" FROM subsDataBackup,sysSubsConf "\
|
||||
" WHERE sysSubsConf.sysTypeNo = subsDataBackup.sysTypeNo AND sysSubsConf.dataTypeNo = subsDataBackup.dataTypeNo AND sysSubsConf.isEnable > '0' "\
|
||||
" AND subsDataBackup.flag > '0' ORDER BY subsDataBackup.sysTypeNo AND subsDataBackup.dataTypeNo");
|
||||
tmpResult = (MYSQL_RES *) mysql_getres(dbConn, tmpSql);
|
||||
|
||||
if (tmpResult == NULL && mysql_num_rows(tmpResult) == 0) {
|
||||
subsDataBackupFlag=0;
|
||||
mysql_free_result(tmpResult);
|
||||
debug_log("No subsdata backup");
|
||||
return ;
|
||||
}
|
||||
debug_log("backup server list");
|
||||
while((tmpRow=mysql_fetch_row(tmpResult)) > 0){
|
||||
subsDataBackup[i].backupStat=nWaitBackup;
|
||||
subsDataBackup[i].sysTypeNo=atoi(tmpRow[0]);
|
||||
subsDataBackup[i].dataTypeNo=atoi(tmpRow[1]);
|
||||
strcpy(subsDataBackup[i].subsDataTable,tmpRow[2]);
|
||||
strcpy(subsDataBackup[i].tmpDataTable,tmpRow[3]);
|
||||
debug_log("%d,sysTypeNo=%d,dataTypeNo=%d,subsDataTable=%s,tmpDataTable=%s",i,subsDataBackup[i].sysTypeNo,subsDataBackup[i].dataTypeNo,subsDataBackup[i].subsDataTable,subsDataBackup[i].tmpDataTable);
|
||||
i++;
|
||||
}
|
||||
mysql_free_result(tmpResult);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // sendHeartbeat
|
||||
Description: // Send process heartbeat to beatProc
|
||||
Calls: // snmp_send
|
||||
Called By: // on_Timer
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: // 1:OK; 0:Fail
|
||||
Others: //
|
||||
*************************************************/
|
||||
int sendHeartbeat()
|
||||
{
|
||||
snmp_pdu pdu;
|
||||
snmp_addr addr;
|
||||
char proc_name[16];
|
||||
|
||||
memset(proc_name,0,16);
|
||||
sprintf(proc_name,"subsDataBackup");
|
||||
|
||||
//pdu
|
||||
memset(&pdu,0,sizeof(snmp_pdu));
|
||||
pdu.pdu_type=7;
|
||||
pdu.request_id=0;
|
||||
sprintf(pdu.community,"public");
|
||||
pdu.var_num=1;
|
||||
pdu.error_status=0;
|
||||
pdu.error_index=0;
|
||||
|
||||
//Addr
|
||||
addr.local_port = 4957;
|
||||
//addr.remote_ip = inet_addr("127.0.0.1");
|
||||
addr.remote_ip = GetLocalIP();
|
||||
addr.broadcast = 0;
|
||||
addr.remote_port = 4957;
|
||||
|
||||
//Varlist
|
||||
memcpy(pdu.var[0].oid,PROC_HEARTBEAT_OID,PROC_HEARTBEAT_OIDLEN*sizeof(DWORD));
|
||||
|
||||
pdu.var[0].oidlen=PROC_HEARTBEAT_OIDLEN;
|
||||
pdu.var[0].vartype=0x04;
|
||||
pdu.var[0].msglen=16;
|
||||
memcpy(pdu.var[0].msg,proc_name,16);
|
||||
|
||||
if(snmp_send(&pdu, &addr) <= 0)
|
||||
{
|
||||
debug_log("Send heartbeat fail");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
unsigned long heartbeat_timeout=0;
|
||||
void subsDataBackupTimer()
|
||||
{
|
||||
long l_time;
|
||||
struct tm *t;
|
||||
|
||||
|
||||
l_time=time(NULL);
|
||||
t=localtime(&l_time);
|
||||
|
||||
if(time(NULL) - heartbeat_timeout > 5)
|
||||
{
|
||||
heartbeat_timeout=time(NULL);
|
||||
sendHeartbeat();
|
||||
}
|
||||
|
||||
if(t->tm_mday != oldDayForLog){
|
||||
//init logfile,create a new log file to restore log
|
||||
oldDayForLog = t->tm_mday;
|
||||
}
|
||||
|
||||
if(automatic_scratch_card_flag==1&&t->tm_mday != oldDayForBackup&&t->tm_hour==automatic_scratch_card_time){
|
||||
debug_log("start to backup process, last backup date is %d",oldDayForBackup);
|
||||
subsDataBackupFlag=1;
|
||||
oldDayForBackup = t->tm_mday;
|
||||
}
|
||||
|
||||
//printf("subsDataBackupFlag=%d\n",subsDataBackupFlag);
|
||||
|
||||
if(subsDataBackupFlag==1){
|
||||
backupTimer();
|
||||
}
|
||||
return ;
|
||||
}
|
||||
static int start_proc_index=0;
|
||||
void backupTimer()
|
||||
{
|
||||
int i;
|
||||
int proc;
|
||||
char tmpSql[1024];
|
||||
MYSQL_RES *tmpResult = NULL;
|
||||
MYSQL_ROW tmpRow = NULL;
|
||||
|
||||
char tmpLoadoutSql[400];
|
||||
char tmpLoadoutFile[100];
|
||||
|
||||
for(proc=start_proc_index;proc<MaxSysConfNum;proc++){
|
||||
switch(subsDataBackup[proc].backupStat){
|
||||
case nNotBackup:
|
||||
break;
|
||||
case nWaitBackup:
|
||||
/*
|
||||
sprintf(tmpSql, "SELECT * FROM %s ",CommTable);
|
||||
|
||||
tmpResult = (MYSQL_RES *) mysql_getres(dbConn, tmpSql);
|
||||
|
||||
if (tmpResult != NULL && (mysql_num_rows(tmpResult) > 0)) {
|
||||
mysql_free_result(tmpResult);
|
||||
omcLog(subsDataBackupLog,"sysTypeNo=%d,dataTypeNo=%d;The database of subsComm is not NULL",subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo);
|
||||
return ;
|
||||
}
|
||||
|
||||
mysql_free_result(tmpResult);
|
||||
*/
|
||||
|
||||
//check mysql connection
|
||||
if(mysql_ping(dbConn))
|
||||
{
|
||||
debug_log("[ERR][backupTimer]mysql gone away,reconnect");
|
||||
mysql_close(dbConn);
|
||||
dbConn = mysql_conn(HOSTNAME,PUB_DB);
|
||||
if(dbConn == NULL)
|
||||
{
|
||||
debug_log("[ERR][backupTimer]reconnect mysql OMC_PUB");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sprintf(tmpSql, "SELECT sysNo,subSysNo FROM %s WHERE sysTypeNo =\'%d\' ORDER BY baseStat DESC",IpTable, subsDataBackup[proc].sysTypeNo);
|
||||
|
||||
tmpResult = (MYSQL_RES *) mysql_getres(dbConn, tmpSql);
|
||||
|
||||
if (tmpResult == NULL || mysql_num_rows(tmpResult) == 0) {
|
||||
|
||||
mysql_free_result(tmpResult);
|
||||
subsDataBackup[proc].backupStat=nOutBackup;
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,can not get the IP",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo);
|
||||
}else{
|
||||
tmpRow = mysql_fetch_row(tmpResult);
|
||||
subsDataBackup[proc].sysNo = atoi(tmpRow[0]);
|
||||
subsDataBackup[proc].subSysNo = atoi(tmpRow[1]);
|
||||
mysql_free_result(tmpResult);
|
||||
subsDataBackup[proc].backupStat=nInBackup;
|
||||
|
||||
sprintf(tmpLoadoutFile,"%s/%s_tmp.csv",subsComm_backupPath,subsDataBackup[proc].subsDataTable);
|
||||
unlink(tmpLoadoutFile);
|
||||
sprintf(tmpLoadoutSql,"SELECT * INTO OUTFILE '%s' "\
|
||||
" FIELDS TERMINATED BY ',' FROM %s",tmpLoadoutFile,subsDataBackup[proc].subsDataTable);
|
||||
if(mysql_getnores(dbConn,tmpLoadoutSql) == 0)
|
||||
{
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,execute sql success=%s",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,tmpLoadoutSql);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,execute sql fail=%s",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,tmpLoadoutSql);
|
||||
}
|
||||
|
||||
sprintf(tmpSql, "DELETE FROM %s",subsDataBackup[proc].subsDataTable);
|
||||
if(mysql_getnores(dbConn, tmpSql) == 0)
|
||||
{
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,execute sql success=%s",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,tmpSql);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,execute sql fail=%s",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,tmpSql);
|
||||
}
|
||||
sprintf(tmpSql, "DELETE FROM %s",subsDataBackup[proc].tmpDataTable);
|
||||
if(mysql_getnores(dbConn, tmpSql) == 0)
|
||||
{
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,execute sql success=%s",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,tmpSql);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,execute sql fail=%s",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,tmpSql);
|
||||
}
|
||||
sendCmd(proc);
|
||||
return ;
|
||||
}
|
||||
break;
|
||||
case nInBackup:
|
||||
if(finishFlag!=1)
|
||||
scanCmd(proc);
|
||||
else{
|
||||
//if(time(NULL)-finishTime>MAX_GETALL_TIMEOUT)
|
||||
backupFile(proc);
|
||||
}
|
||||
return ;
|
||||
break;
|
||||
case nOutBackup:
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,affair finish, start next",start_proc_index,subsDataBackup[start_proc_index].sysTypeNo,subsDataBackup[start_proc_index].dataTypeNo);
|
||||
start_proc_index++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(proc==MaxSysConfNum){
|
||||
subsDataBackupFlag=0;
|
||||
start_proc_index=0;
|
||||
for(i=0;i<MaxSysConfNum;i++){
|
||||
if(subsDataBackup[i].backupStat==nOutBackup)
|
||||
subsDataBackup[i].backupStat=nWaitBackup;
|
||||
}
|
||||
}
|
||||
return ;
|
||||
}
|
||||
|
||||
void sendCmd(int proc)
|
||||
{
|
||||
char tmpSql[2048];
|
||||
MYSQL_RES *tmpResult = NULL;
|
||||
MYSQL_ROW tmpRow = NULL;
|
||||
char tmpLoadoutFile[100];
|
||||
|
||||
if (cmdId > 50000) {
|
||||
//sprintf(tmpSql, "DROP TABLE %s", CommTable);
|
||||
sprintf(tmpSql, "TRUNCATE TABLE %s", CommTable);
|
||||
mysql_getnores(dbConn, tmpSql);
|
||||
/*
|
||||
sprintf(tmpSql, "CREATE TABLE %s"
|
||||
"(commId smallint(5) unsigned NOT NULL auto_increment,"
|
||||
"commType tinyint(1) DEFAULT '0' NOT NULL,"
|
||||
"dataTypeNo tinyint(4) DEFAULT '0' NOT NULL,"
|
||||
"sysTypeNo smallint(5) unsigned DEFAULT '0' NOT NULL,"
|
||||
"sysNo smallint(5) unsigned DEFAULT '0' NOT NULL,"
|
||||
"subSysNo smallint(5) unsigned DEFAULT '0' NOT NULL,"
|
||||
"indexValueList varchar(255) NOT NULL,"
|
||||
"fieldNameList text NOT NULL,"
|
||||
"paramType tinyint(4) DEFAULT '0' NOT NULL,"
|
||||
"commState tinyint(3) unsigned DEFAULT '0' NOT NULL,"
|
||||
"totalNum smallint(5) unsigned DEFAULT '0' NOT NULL,"
|
||||
"finishNum smallint(5) unsigned DEFAULT '0' NOT NULL,"
|
||||
"sendTime datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,"
|
||||
"bgnTime datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,"
|
||||
"endTime datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,"
|
||||
"remark varchar(200) binary NOT NULL,"
|
||||
"PRIMARY KEY (commId),"
|
||||
"KEY sysTypeNo (sysTypeNo),"
|
||||
"KEY sysNo (sysNo),"
|
||||
"KEY subSysNo (subSysNo),"
|
||||
"KEY bufferKey (indexValueList));", CommTable);
|
||||
mysql_getnores(dbConn, tmpSql);
|
||||
*/
|
||||
}
|
||||
|
||||
//insert to command table
|
||||
sprintf(tmpSql, "INSERT INTO %s "
|
||||
"(commType,dataTypeNo,sysTypeNo,sysNo,subSysNo,indexValueList,"
|
||||
"fieldNameList,paramType,commState,sendTime,remark)"
|
||||
"VALUES"
|
||||
"(\'5\',\'%d\',\'%d\',\'%d\',\'%d\',\'\',\'ALL\',"
|
||||
"\'0\',\'1\',CURRENT_TIMESTAMP,\'by subsDatabackup\')",
|
||||
CommTable,
|
||||
subsDataBackup[proc].dataTypeNo,
|
||||
subsDataBackup[proc].sysTypeNo,
|
||||
subsDataBackup[proc].sysNo,
|
||||
subsDataBackup[proc].subSysNo);
|
||||
|
||||
if(mysql_getnores(dbConn, tmpSql) == 0)
|
||||
{
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,execute sql success=%s",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,tmpSql);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,execute sql fail=%s",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,tmpSql);
|
||||
}
|
||||
|
||||
//get commId
|
||||
sprintf(tmpSql, "SELECT commId FROM %s "
|
||||
" WHERE sysTypeNo=\'%d\' "
|
||||
" AND dataTypeNo=\'%d\' "
|
||||
" AND indexValueList=\'\'",
|
||||
CommTable,
|
||||
subsDataBackup[proc].sysTypeNo,
|
||||
subsDataBackup[proc].dataTypeNo);
|
||||
|
||||
tmpResult = (MYSQL_RES *) mysql_getres(dbConn, tmpSql);
|
||||
|
||||
if (tmpResult == NULL || mysql_num_rows(tmpResult) == 0) {
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,get commId fail",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo);
|
||||
mysql_free_result(tmpResult);
|
||||
|
||||
sprintf(tmpLoadoutFile,"%s/%s_tmp.csv",subsComm_backupPath, subsDataBackup[proc].subsDataTable);
|
||||
sprintf(tmpSql, "LOAD DATA INFILE '%s' REPLACE INTO TABLE %s "\
|
||||
" FIELDS TERMINATED BY ','",tmpLoadoutFile,subsDataBackup[proc].subsDataTable);
|
||||
if(mysql_getnores(dbConn, tmpSql) == 0)
|
||||
{
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,execute sql success=%s",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,tmpSql);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,execute sql fail=%s",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,tmpSql);
|
||||
}
|
||||
unlink(tmpLoadoutFile);
|
||||
|
||||
subsDataBackup[proc].backupStat=nOutBackup;
|
||||
return ;
|
||||
}
|
||||
tmpRow = mysql_fetch_row(tmpResult);
|
||||
cmdId = atoi(tmpRow[0]);
|
||||
mysql_free_result(tmpResult);
|
||||
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,get commId=%d",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,cmdId);
|
||||
return ;
|
||||
}
|
||||
|
||||
//scan command progress
|
||||
void scanCmd(int proc)
|
||||
{
|
||||
int cmdState = 0;
|
||||
char tmpSql[1024];
|
||||
char ErrorMsg[256];
|
||||
MYSQL_RES *tmpResult = NULL;
|
||||
MYSQL_ROW tmpRow = NULL;
|
||||
|
||||
|
||||
char tmpLoadoutFile[100];
|
||||
|
||||
long l_time;
|
||||
struct tm *t;
|
||||
l_time=time(NULL);
|
||||
t=localtime(&l_time);
|
||||
|
||||
if (cmdId <= 0){
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,the commId is error when scanCmd",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo);
|
||||
sprintf(tmpLoadoutFile,"%s/%s_tmp.csv",subsComm_backupPath, subsDataBackup[proc].subsDataTable);
|
||||
sprintf(tmpSql, "LOAD DATA INFILE '%s' REPLACE INTO TABLE %s "\
|
||||
" FIELDS TERMINATED BY ','",tmpLoadoutFile,subsDataBackup[proc].subsDataTable);
|
||||
if(mysql_getnores(dbConn, tmpSql) == 0)
|
||||
{
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,execute sql success=%s",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,tmpSql);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,execute sql fail=%s",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,tmpSql);
|
||||
}
|
||||
unlink(tmpLoadoutFile);
|
||||
|
||||
subsDataBackup[proc].backupStat=nOutBackup;
|
||||
return ;
|
||||
}
|
||||
|
||||
sprintf(tmpSql, "SELECT commState,remark,finishNum "
|
||||
" FROM %s WHERE commId=\'%d\'", CommTable, cmdId);
|
||||
tmpResult = (MYSQL_RES *) mysql_getres(dbConn, tmpSql);
|
||||
|
||||
if (tmpResult == NULL || mysql_num_rows(tmpResult) == 0) {
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,the commId is lost when scanCmd",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo);
|
||||
subsDataBackup[proc].backupStat=nOutBackup;
|
||||
mysql_free_result(tmpResult);
|
||||
|
||||
sprintf(tmpLoadoutFile,"%s/%s_tmp.csv",subsComm_backupPath, subsDataBackup[proc].subsDataTable);
|
||||
sprintf(tmpSql, "LOAD DATA INFILE '%s' REPLACE INTO TABLE %s "\
|
||||
" FIELDS TERMINATED BY ','",tmpLoadoutFile,subsDataBackup[proc].subsDataTable);
|
||||
if(mysql_getnores(dbConn, tmpSql) == 0)
|
||||
{
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,execute sql success=%s",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,tmpSql);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,execute sql fail=%s",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,tmpSql);
|
||||
}
|
||||
unlink(tmpLoadoutFile);
|
||||
|
||||
return ;
|
||||
}
|
||||
tmpRow = mysql_fetch_row(tmpResult);
|
||||
cmdState = atoi(tmpRow[0]);
|
||||
strcpy(ErrorMsg, tmpRow[1]);
|
||||
mysql_free_result(tmpResult);
|
||||
|
||||
switch (cmdState) {
|
||||
case nProcFail:
|
||||
waitFlag=0;
|
||||
inFlag=0;
|
||||
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,the get all command execute fail when scanCmd,%s",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,ErrorMsg);
|
||||
sprintf(tmpLoadoutFile,"%s/%s_tmp.csv",subsComm_backupPath, subsDataBackup[proc].subsDataTable);
|
||||
sprintf(tmpSql, "LOAD DATA INFILE '%s' REPLACE INTO TABLE %s "\
|
||||
" FIELDS TERMINATED BY ','",tmpLoadoutFile,subsDataBackup[proc].subsDataTable);
|
||||
if(mysql_getnores(dbConn, tmpSql) == 0)
|
||||
{
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,execute sql success=%s",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,tmpSql);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,execute sql fail=%s",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,tmpSql);
|
||||
}
|
||||
unlink(tmpLoadoutFile);
|
||||
|
||||
sprintf(tmpSql, "DELETE FROM %s WHERE commId=\'%d\'", CommTable, cmdId);
|
||||
mysql_getnores(dbConn, tmpSql);
|
||||
subsDataBackup[proc].backupStat=nOutBackup;
|
||||
lastFinishNum=0;
|
||||
return ;
|
||||
break;
|
||||
case nWaitProc:
|
||||
inFlag=0;
|
||||
if(waitFlag==1){
|
||||
if(time(NULL)-waitTime>100){
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,wait the get all command execute timeout",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo);
|
||||
sprintf(tmpLoadoutFile,"%s/%s_tmp.csv",subsComm_backupPath, subsDataBackup[proc].subsDataTable);
|
||||
sprintf(tmpSql, "LOAD DATA INFILE '%s' REPLACE INTO TABLE %s "\
|
||||
" FIELDS TERMINATED BY ','",tmpLoadoutFile,subsDataBackup[proc].subsDataTable);
|
||||
if(mysql_getnores(dbConn, tmpSql) == 0)
|
||||
{
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,execute sql success=%s",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,tmpSql);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,execute sql fail=%s",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,tmpSql);
|
||||
}
|
||||
unlink(tmpLoadoutFile);
|
||||
|
||||
sprintf(tmpSql, "DELETE FROM %s WHERE commId=\'%d\'",CommTable, cmdId);
|
||||
mysql_getnores(dbConn, tmpSql);
|
||||
waitFlag=0;
|
||||
lastFinishNum=0;
|
||||
subsDataBackup[proc].backupStat=nOutBackup;
|
||||
return ;
|
||||
}
|
||||
}else{
|
||||
waitTime=time(NULL);
|
||||
waitFlag=1;
|
||||
}
|
||||
break;
|
||||
case nInProc:
|
||||
waitFlag=0;
|
||||
if((atoi(tmpRow[2])-lastFinishNum)>0){
|
||||
inFlag=0;
|
||||
lastFinishNum=atoi(tmpRow[2]);
|
||||
}else{
|
||||
if(inFlag==1){
|
||||
if((time(NULL)-inTime)>MAX_GETALL_TIMEOUT){
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,wait the get all command executing timeout,the lastFinishNum is %d",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,lastFinishNum);
|
||||
sprintf(tmpLoadoutFile,"%s/%s_tmp.csv",subsComm_backupPath, subsDataBackup[proc].subsDataTable);
|
||||
sprintf(tmpSql, "LOAD DATA INFILE '%s' REPLACE INTO TABLE %s "\
|
||||
" FIELDS TERMINATED BY ','",tmpLoadoutFile,subsDataBackup[proc].subsDataTable);
|
||||
if(mysql_getnores(dbConn, tmpSql) == 0)
|
||||
{
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,execute sql success=%s",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,tmpSql);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,execute sql fail=%s",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,tmpSql);
|
||||
}
|
||||
unlink(tmpLoadoutFile);
|
||||
|
||||
sprintf(tmpSql, "DELETE FROM %s WHERE commId=\'%d\'",CommTable, cmdId);
|
||||
mysql_getnores(dbConn, tmpSql);
|
||||
subsDataBackup[proc].backupStat=nOutBackup;
|
||||
|
||||
inFlag=0;
|
||||
lastFinishNum=0;
|
||||
return ;
|
||||
}
|
||||
}else{
|
||||
inFlag=1;
|
||||
inTime=time(NULL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case nOutProc:
|
||||
waitFlag=0;
|
||||
inFlag=0;
|
||||
lastFinishNum=0;
|
||||
finishFlag=1;
|
||||
sprintf(tmpSql, "DELETE FROM %s WHERE commId=\'%d\'",CommTable, cmdId);
|
||||
mysql_getnores(dbConn, tmpSql);
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,the get all command execute finish",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo);
|
||||
finishTime=time(NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
} //end of switch
|
||||
return ;
|
||||
}
|
||||
|
||||
void backupFile(int proc)
|
||||
{
|
||||
char loadoutSql[400];
|
||||
char loadoutFile[100];
|
||||
|
||||
char tmpLoadoutFile[100];
|
||||
|
||||
long l_time;
|
||||
struct tm *t;
|
||||
l_time=time(NULL);
|
||||
t=localtime(&l_time);
|
||||
|
||||
sprintf(loadoutFile,"%s/%s_%d_%d.csv",subsComm_backupPath,subsDataBackup[proc].subsDataTable,t->tm_mon + 1,t->tm_mday-1);
|
||||
unlink(loadoutFile);
|
||||
sprintf(loadoutSql,"SELECT * INTO OUTFILE '%s' "\
|
||||
" FIELDS TERMINATED BY ',' FROM %s",loadoutFile,subsDataBackup[proc].subsDataTable);
|
||||
mysql_getnores(dbConn,loadoutSql);
|
||||
if(mysql_getnores(dbConn, loadoutSql) == 0)
|
||||
{
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,execute sql success=%s",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,loadoutSql);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,execute sql fail=%s",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,loadoutSql);
|
||||
}
|
||||
|
||||
sprintf(tmpLoadoutFile,"%s/%s_tmp.csv",subsComm_backupPath, subsDataBackup[proc].subsDataTable);
|
||||
unlink(tmpLoadoutFile);
|
||||
debug_log("%d,system-%d,dataTypeNo=%d,backup %s finish",proc,subsDataBackup[proc].sysTypeNo,subsDataBackup[proc].dataTypeNo,subsDataBackup[proc].subsDataTable);
|
||||
subsDataBackup[proc].backupStat=nOutBackup;
|
||||
finishFlag=0;
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
void debug_log(const char *fmt,...)
|
||||
{
|
||||
char logFile[64];
|
||||
FILE *fp;
|
||||
time_t l_time;
|
||||
va_list ap;
|
||||
char buf[8192];
|
||||
struct tm *t;
|
||||
char timestr[64];
|
||||
|
||||
l_time=time(NULL);
|
||||
t=localtime(&l_time);
|
||||
sprintf(logFile,"../log/subsDataBackup_%04d%02d%02d.log",t->tm_year+1900,t->tm_mon+1,t->tm_mday);
|
||||
fp=fopen(logFile,"a");
|
||||
if(fp!=NULL)
|
||||
{
|
||||
va_start(ap,fmt);
|
||||
vsprintf(buf,fmt,ap);
|
||||
sprintf(timestr,"%02d:%02d:%02d: ",t->tm_hour,t->tm_min,t->tm_sec);
|
||||
fputs(timestr,fp);
|
||||
fputs(buf,fp);
|
||||
fputs("\n",fp);
|
||||
fflush(fp);
|
||||
va_end(ap);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
88
src/accountMgr/c_program/subsDataBackup/subsDataBackup.h
Normal file
88
src/accountMgr/c_program/subsDataBackup/subsDataBackup.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/* Title: subsDataBackup.h
|
||||
* Description: back up the subscriber data
|
||||
* Author: Cui Ticun
|
||||
* Date: 2005/01/15
|
||||
*/
|
||||
|
||||
#include <assert.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 <stdarg.h>
|
||||
#include <syslog.h>
|
||||
#include <sys/io.h>
|
||||
#include <error.h>
|
||||
#include <sys/stat.h>
|
||||
#include <ftw.h>
|
||||
|
||||
#include "../../../../plat/public/src/include/pub_include.h"
|
||||
#include "../../../omcLib/c_program/omcLib/omcLib.h"
|
||||
#include "../../../../plat/snmp/src/include/snmp.h"
|
||||
#include "mysql.h"
|
||||
|
||||
#define subsDataBackup_LogPath "../log"
|
||||
#define subsDataBackup_LogFile "subsDataBackup"
|
||||
#define subsComm_backupPath "/usr/local/apache/htdocs/db_backup/subsData"
|
||||
|
||||
#define MaxSysConfNum 18
|
||||
#define MAX_GETALL_TIMEOUT 7200
|
||||
|
||||
#define HOSTNAME "localhost"
|
||||
#define PUB_DB "OMC_PUB" //OMC's public database
|
||||
#define SysConfTable "OMC_PUB.sysConf" //system config table
|
||||
#define subsConfTable "OMC_PUB.sysSubsConf" //system config table
|
||||
#define CommTable "OMC_PUB.subscriberComm" //command table
|
||||
#define IpTable "OMC_PUB.sysInfo" //system's IP table
|
||||
#define subsDataBackupTable "OMC_PUB.subsDataBackup" //
|
||||
#define omcPubVarConfTable "OMC_PUB.omcPubVarConf" //
|
||||
|
||||
//commState flag define
|
||||
#define nProcFail 0
|
||||
#define nWaitProc 1
|
||||
#define nInProc 2
|
||||
#define nOutProc 3
|
||||
|
||||
//subs data backup state
|
||||
#define nNotBackup 0
|
||||
#define nWaitBackup 1
|
||||
#define nInBackup 2
|
||||
#define nOutBackup 3
|
||||
|
||||
typedef struct subsData_Backup{
|
||||
int backupStat;
|
||||
int sysTypeNo;
|
||||
int dataTypeNo;
|
||||
int sysNo;
|
||||
int subSysNo;
|
||||
char subsDataTable[128];
|
||||
char tmpDataTable[128];
|
||||
}subsData_Backup;
|
||||
|
||||
/* by simon at 23/9/25 */
|
||||
// subsData_Backup subsDataBackup[MaxSysConfNum];
|
||||
|
||||
//Interface Functions Declare,define in subsComm.c
|
||||
void subsDataBackupInit();
|
||||
void subsDataBackupTimer();
|
||||
107
src/accountMgr/c_program/subsDataBackup/subsDataBackupMain.c
Normal file
107
src/accountMgr/c_program/subsDataBackup/subsDataBackupMain.c
Normal file
@@ -0,0 +1,107 @@
|
||||
/* Title: subsDataBackupMain.c
|
||||
* Description: back up the subscriber data
|
||||
* Author: Cui Ticun
|
||||
* Date: 2003/02/14
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "subsDataBackup.h"
|
||||
|
||||
static struct itimerval itimer, old_itimer;
|
||||
|
||||
void onTimer();
|
||||
void setTimer();
|
||||
void setup_daemon(void);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char runMode;
|
||||
|
||||
subsDataBackupInit();
|
||||
|
||||
if (argc > 0) {
|
||||
runMode = getopt(argc, argv, "d");
|
||||
switch (runMode) {
|
||||
case 'd':
|
||||
setup_daemon();
|
||||
break;
|
||||
case '?':
|
||||
break;
|
||||
}
|
||||
//debug_init();//must do it at first
|
||||
}
|
||||
setTimer();
|
||||
while (1) {
|
||||
usleep(50);
|
||||
}
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
void onTimer()
|
||||
{
|
||||
subsDataBackupTimer();
|
||||
}
|
||||
|
||||
void setTimer()
|
||||
{
|
||||
struct sigaction act;
|
||||
act.sa_handler = onTimer;
|
||||
sigemptyset(&act.sa_mask);
|
||||
act.sa_flags = 0;
|
||||
if (sigaction(SIGALRM, &act, NULL) < 0) {
|
||||
exitLog("subsDataBackup:setTimer, sigaction function error");
|
||||
perror("Produce Sigaction");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
itimer.it_interval.tv_sec = 0;
|
||||
itimer.it_interval.tv_usec = 20 * 1000;
|
||||
itimer.it_value.tv_sec = 0;
|
||||
itimer.it_value.tv_usec = 20 * 1000;
|
||||
|
||||
if (setitimer(ITIMER_REAL, &itimer, &old_itimer) != 0) {
|
||||
printf("Setting Timer error! \n");
|
||||
exitLog("subsDataBackup:setTimer, setitimer function error");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void setup_daemon(void)
|
||||
{
|
||||
/*
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
close(i);
|
||||
}
|
||||
*/
|
||||
switch (fork()) {
|
||||
case -1:
|
||||
perror("setup_daemon(), 1st fork()");
|
||||
exit(2);
|
||||
default:
|
||||
exit(0);
|
||||
case 0:
|
||||
if (setsid() == -1) {
|
||||
perror("setup_daemon(), setsid()");
|
||||
exit(3);
|
||||
}
|
||||
switch (fork()) {
|
||||
case -1:
|
||||
perror("setup_daemon(), 2nd fork()");
|
||||
exit(3);
|
||||
default:
|
||||
exit(0);
|
||||
case 0:
|
||||
umask(0);
|
||||
/* and return with daemon set up */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
90
src/accountMgr/c_program/wsms/Makefile
Normal file
90
src/accountMgr/c_program/wsms/Makefile
Normal file
@@ -0,0 +1,90 @@
|
||||
#/bin/sh
|
||||
|
||||
# Makefile for CDR Module.
|
||||
|
||||
CC = gcc
|
||||
CFLAGS=-g -Wall -I/usr/local/mysql/include
|
||||
CFLAGS.ES=-g -Wall -I/usr/include/mariadb
|
||||
|
||||
COMPILE.c=$(CC) $(CFLAGS)
|
||||
COMPILE.c.ES=$(CC) $(CFLAGS.ES)
|
||||
|
||||
LINK.c=$(CC) $(CFLAGS)
|
||||
LINK.c.ES=$(CC) $(CFLAGS.ES)
|
||||
|
||||
LINKFLAG=-L../../../omcLib/c_program/omcLib -lomcLib \
|
||||
-L../../../omcLib/c_program/ftp -lftp \
|
||||
-L../../../../wxc2plat/snmp -lsnmp \
|
||||
-L../../../../wxc2plat/debug -ldebug \
|
||||
-L../../../../wxc2plat/iptrans -liptrans \
|
||||
-L../../../../wxc2plat/public -lpublic \
|
||||
-L/usr/local/mysql/lib -lmariadbclient -lz
|
||||
|
||||
LINKFLAG.ES=-L../../../omcLib/c_program/omcLib -lomcLib \
|
||||
-L../../../omcLib/c_program/ftp -lftp \
|
||||
-L../../../../plat/smpp/lib -lsmpp \
|
||||
-L../../../../plat/sccp/lib -lsccp \
|
||||
-L../../../../plat/snmp/lib -lsnmp \
|
||||
-L../../../../plat/mtp3/lib -lmtp3 \
|
||||
-L../../../../plat/m2ua/lib -lm2ua \
|
||||
-L../../../../plat/debug/lib -ldebug \
|
||||
-L../../../../plat/iptrans/lib -liptrans \
|
||||
-L../../../../plat/public/lib -lpublic \
|
||||
-L/usr/lib/mysql -lmariadbclient -lz
|
||||
|
||||
PROGS=wsms
|
||||
WSMS_OBJ = wsms.o
|
||||
WSMS_OBJ.ES = wsms.o.ES
|
||||
|
||||
default: linuxES
|
||||
|
||||
all:
|
||||
@echo " **** Compiling $(PROGS) ****"
|
||||
@echo "make clean -- Delete the target files(*.o, *.a)"
|
||||
@echo "make linux72 -- Generate target files for Redhat Linux 7.2"
|
||||
@echo "make linuxES -- Generate target files for Redhat ES 4.0"
|
||||
|
||||
linux72: $(WSMS_OBJ) wsmsmain.o
|
||||
@cd ../../../omcLib/c_program/ftp; make linux72; cd ..
|
||||
@cd ../../../accountMgr/c_program/wsms;
|
||||
@echo Linking $(PROGS)
|
||||
@$(LINK.c) -o $(PROGS) wsmsmain.o $(WSMS_OBJ) $(LINKFLAG) -lm
|
||||
ar r libwsms.a $(WSMS_OBJ)
|
||||
rm -rf *.o
|
||||
rm -rf *bak
|
||||
rm -rf *~
|
||||
cp -f $(PROGS) ../../../bin
|
||||
cp -f $(PROGS) /usr/local/omc/bin/
|
||||
|
||||
linuxES: $(WSMS_OBJ.ES) wsmsmain.o.ES
|
||||
@cd ../../../omcLib/c_program/ftp; make linuxES; cd ..
|
||||
@cd ../../../accountMgr/c_program/wsms;
|
||||
@echo Linking $(PROGS)
|
||||
@$(LINK.c.ES) -o $(PROGS) wsmsmain.o $(WSMS_OBJ) $(LINKFLAG.ES) -lm
|
||||
ar r libwsms.a $(WSMS_OBJ)
|
||||
|
||||
installbin: linuxES
|
||||
cp -f $(PROGS) ../../../../bin/
|
||||
|
||||
installomc: linuxES
|
||||
cp -f $(PROGS) /usr/local/omc/bin/
|
||||
|
||||
installall: installbin installomc
|
||||
|
||||
wsmsmain.o: wsmsmain.c
|
||||
$(COMPILE.c) -c wsmsmain.c
|
||||
|
||||
wsms.o: wsms.c wsms.h
|
||||
$(COMPILE.c) -c wsms.c
|
||||
|
||||
wsmsmain.o.ES: wsmsmain.c
|
||||
$(COMPILE.c.ES) -c wsmsmain.c
|
||||
|
||||
wsms.o.ES: wsms.c wsms.h
|
||||
$(COMPILE.c.ES) -c wsms.c
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(PROGS)
|
||||
@cd ../../../omcLib/c_program/ftp; rm -f *.o *.a; cd ..
|
||||
@cd ../../../accountMgr/c_program/wsms;rm -f *.o *.a; cd ..
|
||||
|
||||
1198
src/accountMgr/c_program/wsms/wsms.c
Normal file
1198
src/accountMgr/c_program/wsms/wsms.c
Normal file
File diff suppressed because it is too large
Load Diff
52
src/accountMgr/c_program/wsms/wsms.h
Normal file
52
src/accountMgr/c_program/wsms/wsms.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#ifndef wsms__H
|
||||
#define wsms__H
|
||||
|
||||
#ifndef MYSQL_H
|
||||
#include "mysql.h"
|
||||
#endif
|
||||
|
||||
#ifndef WSMS_DEBUG
|
||||
#define WSMS_DEBUG 0
|
||||
#endif
|
||||
|
||||
#define CDR_ALARM_FLAG 1
|
||||
|
||||
#include "mysql.h"
|
||||
#include "errmsg.h"
|
||||
#include <dirent.h>
|
||||
#include <time.h>
|
||||
#include "../../../../plat/public/src/include/pub_include.h"
|
||||
#include "../../../omcLib/c_program/omcLib/omcLib.h"
|
||||
#include "../../../../plat/public/src/include/asn1.h"
|
||||
#include "../../../../plat/iptrans/src/include/iptrans.h"
|
||||
#include "../../../../plat/snmp/src/include/snmp.h"
|
||||
#include "../../../../plat/mtp3/src/include/mtp3.h"
|
||||
#include "../../../../plat/sccp/src/include/sccp.h"
|
||||
#include "../../../../plat/smpp/src/include/smpp.h"
|
||||
|
||||
#define HPMN_MAX 100
|
||||
#define WEL_AD_MAX 32
|
||||
|
||||
/* Use for the information of every HPMN */
|
||||
typedef struct HpmnServer
|
||||
{
|
||||
char mcc[8]; //The mcc of the hpmn server
|
||||
char mnc[8]; //The mnc of the hpmn server
|
||||
int flag; //1-enable, 0-disable
|
||||
int smsEncode; //0-7 bit, 1-8 bit, 2-16 bit
|
||||
unsigned char wlContent[512]; //The welcome short message of the hpmn server
|
||||
int adCount; //The count of AD short messages
|
||||
unsigned char adContent[WEL_AD_MAX][512]; //The content of each AD short message
|
||||
int adValid[WEL_AD_MAX]; //The valid flag of each AD short message
|
||||
}HpmnServer;
|
||||
|
||||
|
||||
/**************************/
|
||||
/**** function *****/
|
||||
/**************************/
|
||||
int wsms_init(void);
|
||||
void wsms_timer(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
102
src/accountMgr/c_program/wsms/wsmsmain.c
Normal file
102
src/accountMgr/c_program/wsms/wsmsmain.c
Normal file
@@ -0,0 +1,102 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "wsms.h"
|
||||
|
||||
|
||||
static struct itimerval itimer, old_itimer;
|
||||
static void On_Timer();
|
||||
static void SetTimer();
|
||||
|
||||
|
||||
/*************************************************
|
||||
Function: // main
|
||||
Description: // The main function of the module
|
||||
Calls: //
|
||||
Called By: //
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
pid_t pid;
|
||||
|
||||
if (argc == 2 && strstr(argv[1], "-d")) {
|
||||
if ((pid = fork()) != 0)
|
||||
exit(0);
|
||||
setsid();
|
||||
}
|
||||
|
||||
wsms_init();
|
||||
|
||||
SetTimer();
|
||||
while (1) {
|
||||
usleep(50);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************
|
||||
Function: // On_Timer
|
||||
Description: // Timer function
|
||||
Calls: //
|
||||
Called By: //
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void On_Timer()
|
||||
{
|
||||
wsms_timer();
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // SetTimer
|
||||
Description: // Timer function
|
||||
Calls: // On_Timer
|
||||
Called By: //
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void SetTimer()
|
||||
{
|
||||
struct sigaction act;
|
||||
act.sa_handler = On_Timer;
|
||||
sigemptyset(&act.sa_mask);
|
||||
act.sa_flags = 0;
|
||||
if (sigaction(SIGALRM, &act, NULL) < 0)
|
||||
{
|
||||
perror("Produce Sigaction");
|
||||
exitLog("wsms:SetTimer, sigaction function error");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
itimer.it_interval.tv_sec = 0;
|
||||
itimer.it_interval.tv_usec = 20 * 1000;
|
||||
itimer.it_value.tv_sec = 0;
|
||||
itimer.it_value.tv_usec = 20 * 1000;
|
||||
|
||||
if (setitimer(ITIMER_REAL, &itimer, &old_itimer) != 0)
|
||||
{
|
||||
printf("Setting Timer error! \n");
|
||||
exitLog("wsms:SetTimer, setitimer function error");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
104
src/accountMgr/c_program/wxc1AndWxc2ConverseTools/Makefile
Normal file
104
src/accountMgr/c_program/wxc1AndWxc2ConverseTools/Makefile
Normal file
@@ -0,0 +1,104 @@
|
||||
#/bin/sh
|
||||
|
||||
# Makefile for CDR Module.
|
||||
|
||||
CC = gcc
|
||||
CFLAGS=-g -Wall -I/usr/local/mysql/include
|
||||
CFLAGS.ES=-g -Wall -I/usr/include/mariadb
|
||||
|
||||
COMPILE.c=$(CC) $(CFLAGS)
|
||||
COMPILE.c.ES=$(CC) $(CFLAGS.ES)
|
||||
|
||||
LINK.c=$(CC) $(CFLAGS)
|
||||
LINK.c.ES=$(CC) $(CFLAGS.ES)
|
||||
|
||||
LINKFLAG=-L../../../omcLib/c_program/ftp -lftp \
|
||||
-L../../../../wxc2plat/snmp -lsnmp \
|
||||
-L../../../../wxc2plat/debug -ldebug \
|
||||
-L../../../../wxc2plat/iptrans -liptrans \
|
||||
-L../../../../wxc2plat/public -lpublic \
|
||||
-L/usr/local/mysql/lib -lmariadbclient -lz
|
||||
|
||||
LINKFLAG.ES=-L../../../omcLib/c_program/omcLib -lomcLib \
|
||||
-L../../../omcLib/c_program/ftp -lftp \
|
||||
-L../../../../plat/snmp/lib -lsnmp \
|
||||
-L../../../../plat/debug/lib -ldebug \
|
||||
-L../../../../plat/sccp/lib -lsccp \
|
||||
-L../../../../plat/iptrans/lib -liptrans \
|
||||
-L../../../../plat/public/lib -lpublic \
|
||||
-L/usr/lib/mysql -lmariadbclient -lz
|
||||
|
||||
PROGS=cdrCollector
|
||||
CDR_OBJ = cdr.o cdrdebug.o cdrdb.o cdrlog.o
|
||||
CDR_OBJ.ES = cdr.o.ES cdrdebug.o.ES cdrdb.o.ES cdrlog.o.ES
|
||||
|
||||
default: linuxES
|
||||
|
||||
all:
|
||||
@echo " **** Compiling $(PROGS) ****"
|
||||
@echo "make clean -- Delete the target files(*.o, *.a)"
|
||||
@echo "make linux72 -- Generate target files for Redhat Linux 7.2"
|
||||
@echo "make linuxES -- Generate target files for Redhat ES 4.0"
|
||||
|
||||
linux72: $(CDR_OBJ) cdrmain.o
|
||||
@cd ../../../omcLib/c_program/ftp; make linux72; cd ..
|
||||
@cd ../../../accountMgr/c_program/cdrCollector;
|
||||
@echo Linking $(PROGS)
|
||||
@$(LINK.c) -o $(PROGS) cdrmain.o $(CDR_OBJ) $(LINKFLAG) -lm
|
||||
ar r libcdr.a $(CDR_OBJ)
|
||||
rm -rf *.o
|
||||
rm -rf *bak
|
||||
rm -rf *~
|
||||
#cp -f $(PROGS) ../../../bin
|
||||
#cp -f $(PROGS) /usr/local/omc/bin/
|
||||
|
||||
linuxES: $(CDR_OBJ.ES) cdrmain.o.ES
|
||||
@cd ../../../omcLib/c_program/ftp; make linuxES; cd ..
|
||||
@cd ../../../accountMgr/c_program/cdrCollector;
|
||||
@echo Linking $(PROGS)
|
||||
@$(LINK.c.ES) -o $(PROGS) cdrmain.o $(CDR_OBJ) $(LINKFLAG.ES) -lm
|
||||
ar r libcdr.a $(CDR_OBJ)
|
||||
|
||||
installbin: linuxES
|
||||
cp -f $(PROGS) ../../../../bin/
|
||||
|
||||
installomc: linuxES
|
||||
cp -f $(PROGS) /usr/local/omc/bin/
|
||||
|
||||
installall: installbin installomc
|
||||
|
||||
cdrmain.o: cdrmain.c
|
||||
$(COMPILE.c) -c cdrmain.c
|
||||
|
||||
cdr.o: cdr.c cdr.h
|
||||
$(COMPILE.c) -c cdr.c
|
||||
|
||||
cdrdebug.o: cdrdebug.c
|
||||
$(COMPILE.c) -c cdrdebug.c
|
||||
|
||||
cdrdb.o:cdrdb.c
|
||||
$(COMPILE.c) -c cdrdb.c
|
||||
|
||||
cdrlog.o: cdrlog.c
|
||||
$(COMPILE.c) -c cdrlog.c
|
||||
|
||||
cdrmain.o.ES: cdrmain.c
|
||||
$(COMPILE.c.ES) -c cdrmain.c
|
||||
|
||||
cdr.o.ES: cdr.c cdr.h
|
||||
$(COMPILE.c.ES) -c cdr.c
|
||||
|
||||
cdrdebug.o.ES: cdrdebug.c
|
||||
$(COMPILE.c.ES) -c cdrdebug.c
|
||||
|
||||
cdrdb.o.ES:cdrdb.c
|
||||
$(COMPILE.c.ES) -c cdrdb.c
|
||||
|
||||
cdrlog.o.ES: cdrlog.c
|
||||
$(COMPILE.c.ES) -c cdrlog.c
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(PROGS)
|
||||
@cd ../../../omcLib/c_program/ftp; rm -f *.o *.a; cd ..
|
||||
@cd ../../../accountMgr/c_program/cdrCollector;rm -f *.o *.a; cd ..
|
||||
|
||||
2393
src/accountMgr/c_program/wxc1AndWxc2ConverseTools/cdr.c
Normal file
2393
src/accountMgr/c_program/wxc1AndWxc2ConverseTools/cdr.c
Normal file
File diff suppressed because it is too large
Load Diff
155
src/accountMgr/c_program/wxc1AndWxc2ConverseTools/cdr.h
Normal file
155
src/accountMgr/c_program/wxc1AndWxc2ConverseTools/cdr.h
Normal file
@@ -0,0 +1,155 @@
|
||||
/*************************************************
|
||||
File name: cdr.h
|
||||
Author:
|
||||
Version: 9:00:00
|
||||
Date: 2002-5-7
|
||||
Description:<3A><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>cdrCollectorģ<72><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һЩ<D2BB><D0A9><EFBFBD><EFBFBD><EFBFBD>ͺ<EFBFBD><CDBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<09>ṹcdr_src,cdr_def,cdr_tlv
|
||||
|
||||
|
||||
|
||||
|
||||
History:
|
||||
No.
|
||||
Author:
|
||||
Date:
|
||||
Version:
|
||||
Description:
|
||||
*************************************************/
|
||||
|
||||
#ifndef __CDR_HEAD_FILE
|
||||
#define __CDR_HEAD_FILE
|
||||
|
||||
#include "mysql.h"
|
||||
#include "errmsg.h"
|
||||
#include <dirent.h>
|
||||
#include "../../../../plat/public/src/include/asn1.h"
|
||||
#include "../../../../plat/snmp/src/include/snmp.h"
|
||||
#include "../../../omcLib/c_program/omcLib/omcLib.h"
|
||||
|
||||
#ifndef _T_DWORD
|
||||
#define _T_DWORD
|
||||
typedef unsigned int DWORD;
|
||||
#endif
|
||||
|
||||
#define CDR_DEBUG 0
|
||||
|
||||
#define CDR_LINK_DEBUG 0
|
||||
#define CDR_PORT 4968
|
||||
#define CDR_SRC_NUM 32
|
||||
#define CDR_TYPE_NUM 20
|
||||
#define CDR_OBJ_MAX 128
|
||||
#define HOST_NAME "localhost"
|
||||
#define CDRDB_NAME "CDR_DB"
|
||||
#define CSV_PATH "/usr/local/cdr"
|
||||
#define CDR_LOG_PATH "../log"
|
||||
#define CDR_LOG_FILE "cdrlog"
|
||||
|
||||
#define ST_GET_TAIL 0
|
||||
#define ST_WAIT_TAIL 1
|
||||
#define ST_CDR_IDLE 2
|
||||
#define ST_GET_CDR 3
|
||||
#define ST_WAIT_CDR 4
|
||||
#define ST_TAIL_IDLE 5
|
||||
#define ST_SET_TAIL 6
|
||||
|
||||
#define CDR_TIME_UNIT 20 //ms
|
||||
|
||||
#define CDR_T_idle 250 //5s lowest speed
|
||||
#define CDR_T_getcdr 30 //60ms
|
||||
#define CDR_T_gettail 500 //300*20=6000ms=10s
|
||||
#define CDR_T_settail 100 //2s
|
||||
|
||||
#define HEAP_SIZE_MAX 256 //1024*28
|
||||
#define HEAP_TIME_MAX 50*30 //30s
|
||||
|
||||
#define OMC_SINGLE 7
|
||||
#define OMC_MASTER 5
|
||||
|
||||
char totalCdrFileName[128];
|
||||
char cdrFileName[128];
|
||||
int cdrHour;
|
||||
//<2F>˽ṹ<CBBD><E1B9B9><EFBFBD><EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ֶ<EFBFBD>
|
||||
typedef struct cdr_tlv {
|
||||
char tag_seq[17][20]; //16<31><36>tag<61><67>ֵ
|
||||
char field_name[30]; //<2F>ֶε<D6B6><CEB5><EFBFBD><EFBFBD><EFBFBD>
|
||||
BYTE type; //<2F>ֶε<D6B6><CEB5><EFBFBD><EFBFBD><EFBFBD>
|
||||
BOOL optional; //<2F>ֶ<EFBFBD><D6B6>Ƿ<EFBFBD><C7B7><EFBFBD>ѡ
|
||||
BYTE width; //<2F>ֶγ<D6B6><CEB3><EFBFBD>
|
||||
} cdr_tlv;
|
||||
|
||||
//<2F>˽ṹ<CBBD><E1B9B9><EFBFBD><EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1>Ķ<EFBFBD><C4B6>壬<EFBFBD><E5A3AC><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD>ֶζ<D6B6><CEB6><EFBFBD>
|
||||
typedef struct cdr_def {
|
||||
BOOL valid[17]; //tagλ<67><CEBB>ʶ
|
||||
char field_set[1024]; //ȫ<><C8AB><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>
|
||||
char field_select[1024];//ָ<><D6B8><EFBFBD>汾<EFBFBD><E6B1BE>ȫ<EFBFBD><C8AB><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>
|
||||
char create_sql[2048]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>sql<71><6C><EFBFBD><EFBFBD>
|
||||
BYTE field_count; //<2F>ֶεĸ<CEB5><C4B8><EFBFBD>
|
||||
cdr_tlv obj[CDR_OBJ_MAX];//<2F>ֶζ<D6B6><CEB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
} cdr_def;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ݽṹ<DDBD><E1B9B9><EFBFBD><EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>CDR<44><52><EFBFBD><EFBFBD>Դ
|
||||
typedef struct cdr_src {
|
||||
int loss; //<2F><><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3>
|
||||
int recv; //<2F><><EFBFBD>յİ<D5B5><C4B0>ĸ<EFBFBD><C4B8><EFBFBD>
|
||||
int recd; //<2F><>¼<EFBFBD>İ<EFBFBD><C4B0>ĸ<EFBFBD><C4B8><EFBFBD>
|
||||
|
||||
BYTE cdr_ver; //<2F>汾<EFBFBD><E6B1BE>
|
||||
WORD sysTypeNo; //ϵͳ<CFB5>豸<EFBFBD><E8B1B8>
|
||||
BYTE sysid; //ϵͳ<CFB5><CDB3>
|
||||
BYTE retry; //<2F><><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>
|
||||
|
||||
//informaion for getting cdr
|
||||
int get_timeout; //get<65><74><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3>ʱ<EFBFBD><CAB1>
|
||||
BOOL get_state; //get״̬
|
||||
DWORD instance; //ͷָ<CDB7><D6B8>
|
||||
DWORD head; //βָ<CEB2><D6B8>
|
||||
BYTE maxbind; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F3B6A8B1><EFBFBD><EFBFBD><EFBFBD>
|
||||
DWORD request_id; //get<65><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID
|
||||
|
||||
|
||||
//information for setting ptail
|
||||
int set_timeout; //set<65><74><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3>ʱ<EFBFBD><CAB1>
|
||||
BYTE set_fail; //setʧ<74>ܴ<EFBFBD><DCB4><EFBFBD>
|
||||
BOOL set_state; //set״̬
|
||||
BOOL move_flag; //βָ<CEB2><D6B8><EFBFBD>Ƿ<EFBFBD><C7B7>ı<EFBFBD>
|
||||
DWORD set_rid; //set<65><74><EFBFBD><EFBFBD>ID
|
||||
snmp_addr addr; //IP<49>Ͷ˿ڵ<CBBF>ַ
|
||||
DWORD oid[20]; //OID
|
||||
BYTE oid_len; //OID<49><44><EFBFBD><EFBFBD>
|
||||
DWORD head_oid[20]; //ͷָ<CDB7><D6B8>OID
|
||||
DWORD tail_oid[20]; //βָ<CEB2><D6B8>OID
|
||||
char record_table[30]; //<2F><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>
|
||||
char define_table[30]; //<2F><><EFBFBD>ݶ<EFBFBD><DDB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
char csv_path[50]; //<2F><><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
|
||||
int backup_max; //<2F><><EFBFBD>ݸ<F3B1B8B7><DDB8><EFBFBD>
|
||||
int buf_size; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
||||
cdr_def define; //<2F><>Ӧ<EFBFBD><D3A6><EFBFBD>ֶα<D6B6><CEB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
//BOOL receive_tail;
|
||||
//BOOL receive_cdr;
|
||||
//int serial;
|
||||
} cdr_src;
|
||||
|
||||
|
||||
void converseFile();
|
||||
void cdr_timer();
|
||||
void cdr_init();
|
||||
|
||||
#if CDR_LINK_DEBUG
|
||||
void cdrdebug_init();
|
||||
#endif
|
||||
|
||||
void cdrdb_init();
|
||||
void cdr_start();
|
||||
void cdr_stop();
|
||||
BOOL cdr_status();
|
||||
void cdrdb_timer();
|
||||
void cdrlog_init();
|
||||
void cdrlog_timer();
|
||||
void cdr_log(const char *fmt, ...);
|
||||
void cdr_logmsg(BYTE * buf, int len);
|
||||
void cdr_report();
|
||||
int safe_query(MYSQL * conn, char *strquery, int retry);
|
||||
|
||||
#endif
|
||||
990
src/accountMgr/c_program/wxc1AndWxc2ConverseTools/cdrdb.c
Normal file
990
src/accountMgr/c_program/wxc1AndWxc2ConverseTools/cdrdb.c
Normal file
@@ -0,0 +1,990 @@
|
||||
/*************************************************
|
||||
File name: cdrdb.c
|
||||
Author:
|
||||
Version: 9:00:00
|
||||
Date: 2002-5-7
|
||||
Description:<3A><><EFBFBD>ļ<EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>cdrCollectorģ<72><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҷ<EFBFBD>ʱ<EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD>ݽ<EFBFBD><DDBD>б<EFBFBD><D0B1>ݣ<EFBFBD>
|
||||
ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>csv<73><76><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
|
||||
|
||||
|
||||
|
||||
History:
|
||||
No.
|
||||
Author:
|
||||
Date:
|
||||
Version:
|
||||
Description:
|
||||
*************************************************/
|
||||
|
||||
#include "cdr.h"
|
||||
#include "../../../omcLib/c_program/ftp/ftp.h"
|
||||
static MYSQL *cdrdb_conn;
|
||||
static MYSQL *omcPub_conn;
|
||||
extern cdr_src CdrSet[CDR_SRC_NUM];
|
||||
extern BYTE iCdrNum;
|
||||
|
||||
static BYTE backup_flag=0;
|
||||
static char tb_name[64][48];
|
||||
static int cdr_index = 0, tb_index = 0, tb_num = 0;
|
||||
static char compress_file[64];
|
||||
static char send_file[64];
|
||||
static char sening_dir[128];
|
||||
|
||||
void enum_cdrdb();
|
||||
void backup_table(char *tb_name, char *csv_path,int flag,char *selfield,BYTE cdr_ver);
|
||||
void create_csv(char *tb_name, char *csv_path,int flag,char *selfield);
|
||||
void create_dat_for_wxc1(char *tb_name,char *csv_path,int flag,char *selfield);
|
||||
void compress_csv(char *path_name);
|
||||
//void chfilename(char *path_name, char *oldname);
|
||||
void delfile(char *path_name,char *filename);
|
||||
void clear_table(char *tb_name);
|
||||
void send_csv(char *path_name);
|
||||
|
||||
/*************************************************
|
||||
Function: // cdrdb_init
|
||||
Description: // <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ݿ⣬<DDBF><E2A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Calls: // mysql_init; mysql_real_connect; mysql_query;
|
||||
Called By: // cdrmain.c:cdr_init;
|
||||
Table Accessed: // OMC_PUB.omcPubVarConf; CDR_DB.cdrPubVarConf;
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void cdrdb_init()
|
||||
{
|
||||
char sqlstr[256];
|
||||
MYSQL_RES *res;
|
||||
MYSQL_ROW row;
|
||||
|
||||
BYTE m_state = 1;
|
||||
|
||||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>
|
||||
while ((cdrdb_conn = mysql_init(NULL)) == NULL) {
|
||||
printf("Fail to init mysql:%s\n", mysql_error(cdrdb_conn));
|
||||
sleep(2);
|
||||
}
|
||||
|
||||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>
|
||||
while (mysql_real_connect
|
||||
(cdrdb_conn, "localhost", "root", "rootaa", "CDR_DB", 0, NULL,
|
||||
0) == NULL) {
|
||||
printf("Fail to init mysql:%s\n", mysql_error(cdrdb_conn));
|
||||
sleep(2);
|
||||
}
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>sending_directory<72><79>ֵ
|
||||
sprintf(sqlstr,
|
||||
"SELECT pubVarValue FROM CDR_DB.cdrPubVarConf WHERE pubVarName='sending_directory'");
|
||||
|
||||
if (mysql_query(cdrdb_conn, sqlstr) != 0) {
|
||||
cdr_log("%s\n", mysql_error(cdrdb_conn));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((res = mysql_store_result(cdrdb_conn)) == NULL)
|
||||
return;
|
||||
|
||||
if((row = mysql_fetch_row(res)) != NULL) {
|
||||
strcpy(sening_dir,row[0]);
|
||||
}
|
||||
|
||||
mysql_free_result(res);
|
||||
|
||||
while ((omcPub_conn = mysql_init(NULL)) == NULL) {
|
||||
printf("Fail to init mysql:%s\n", mysql_error(omcPub_conn));
|
||||
sleep(2);
|
||||
}
|
||||
|
||||
while (mysql_real_connect
|
||||
(omcPub_conn, "localhost", "root", "rootaa", "OMC_PUB", 0, NULL,
|
||||
0) == NULL) {
|
||||
printf("Fail to init mysql:%s\n", mysql_error(omcPub_conn));
|
||||
sleep(2);
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD>ù<EFBFBD><C3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>cdr_store_server<65><72>ֵ
|
||||
sprintf(sqlstr,
|
||||
"SELECT pubVarValue FROM OMC_PUB.omcPubVarConf WHERE pubVarName='cdr_store_server'");
|
||||
|
||||
if (mysql_query(omcPub_conn, sqlstr) != 0) {
|
||||
cdr_log("%s\n", mysql_error(omcPub_conn));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((res = mysql_store_result(omcPub_conn)) == NULL){
|
||||
return;
|
||||
}
|
||||
|
||||
//<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>
|
||||
if((row = mysql_fetch_row(res)) != NULL) {
|
||||
if(strlen(row[0]) == 0)
|
||||
{
|
||||
backup_flag=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
backup_flag=1;
|
||||
}
|
||||
}
|
||||
|
||||
mysql_free_result(res);
|
||||
|
||||
|
||||
/*
|
||||
while (m_state != 0) {
|
||||
switch (m_state) {
|
||||
case 1: //find tables in CDR_DB
|
||||
if (cdr_index < iCdrNum) {
|
||||
enum_cdrdb();
|
||||
m_state = 2;
|
||||
} else
|
||||
m_state = 5;
|
||||
break;
|
||||
case 2: //backup table
|
||||
if (tb_index < tb_num) {
|
||||
backup_table(tb_name[tb_index],
|
||||
CdrSet[cdr_index - 1].csv_path);
|
||||
m_state = 3;
|
||||
} else
|
||||
m_state = 1;
|
||||
break;
|
||||
case 3: //delete old records
|
||||
clear_table(tb_name[tb_index]);
|
||||
tb_index++;
|
||||
m_state = 4;
|
||||
break;
|
||||
case 4: //don't compress csv files
|
||||
//compress_csv(CdrSet[cdr_index-1].csv_path);
|
||||
m_state = 2;
|
||||
break;
|
||||
case 5: //finish
|
||||
cdr_index = 0;
|
||||
tb_index = 0;
|
||||
m_state = 0;
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
cdr_index = 0;
|
||||
tb_index = 0;
|
||||
m_state = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // cdrdb_timer
|
||||
Description: // ÿСʱ<D0A1><CAB1>һЩ<D2BB>̶<EFBFBD><CCB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>籸<EFBFBD><E7B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ɾ<><C9BE><EFBFBD>ɵļ<C9B5>¼<EFBFBD><C2BC>
|
||||
Calls: // backup_table; enum_cdrdb; clear_table;
|
||||
Called By: // cdrmain.c:cdr_timer;
|
||||
Table Accessed: // <20><><EFBFBD>ݱ<EFBFBD>
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void cdrdb_timer()
|
||||
{
|
||||
unsigned long l_time;
|
||||
struct tm *t;
|
||||
static BYTE m_state = 0;
|
||||
|
||||
//for backup table per hour
|
||||
int h_cdr_index=0;
|
||||
//for backup table per hour
|
||||
char h_tb_name[64];
|
||||
int flag;
|
||||
|
||||
l_time = time(NULL);
|
||||
t = localtime(&l_time);
|
||||
|
||||
if(t->tm_min==0){
|
||||
for(h_cdr_index=0;h_cdr_index<iCdrNum;h_cdr_index++){
|
||||
if(t->tm_hour==0){
|
||||
sprintf(h_tb_name,"%s_%d",CdrSet[h_cdr_index].record_table,23);
|
||||
flag=1;
|
||||
}else{
|
||||
sprintf(h_tb_name,"%s_%02d",CdrSet[h_cdr_index].record_table,t->tm_hour-1);
|
||||
flag=0;
|
||||
}
|
||||
backup_table(h_tb_name, CdrSet[h_cdr_index].csv_path,flag,CdrSet[h_cdr_index].define.field_select,CdrSet[h_cdr_index].cdr_ver);
|
||||
// send_csv(CdrSet[h_cdr_index].csv_path);
|
||||
}
|
||||
}
|
||||
|
||||
switch (m_state) {
|
||||
//IDLE
|
||||
case 0:
|
||||
l_time = time(NULL);
|
||||
t = localtime(&l_time);
|
||||
if (t->tm_hour == 3) {
|
||||
m_state = 1;
|
||||
cdr_index = 0;
|
||||
tb_index = 0;
|
||||
}
|
||||
break;
|
||||
//find tables in CDR_DB
|
||||
case 1:
|
||||
if (cdr_index < iCdrNum) {
|
||||
enum_cdrdb();
|
||||
m_state = 2;
|
||||
} else
|
||||
m_state = 5;
|
||||
break;
|
||||
//backup table
|
||||
case 2:
|
||||
if (tb_index < tb_num) {
|
||||
//backup_table(tb_name[tb_index], CdrSet[cdr_index-1].csv_path,1,CdrSet[cdr_index-1].define.field_select,CdrSet[cdr_index-1].cdr_ver);
|
||||
m_state = 3;
|
||||
} else
|
||||
m_state = 1;
|
||||
break;
|
||||
//delete old records
|
||||
case 3:
|
||||
clear_table(tb_name[tb_index]);
|
||||
tb_index++;
|
||||
m_state = 4;
|
||||
break;
|
||||
//compress csv files
|
||||
case 4:
|
||||
//compress_csv(CdrSet[cdr_index].csv_path);
|
||||
m_state = 2;
|
||||
break;
|
||||
//finish
|
||||
case 5:
|
||||
l_time = time(NULL);
|
||||
t = localtime(&l_time);
|
||||
if (t->tm_hour != 3) {
|
||||
cdr_index = 0;
|
||||
tb_index = 0;
|
||||
m_state = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // enum_cdrdb
|
||||
Description: // <20>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Calls: // mysql_query; mysql_store_result; mysql_fetch_row;
|
||||
Called By: // cdrdb_timer;
|
||||
Table Accessed: // <20><><EFBFBD>ݱ<EFBFBD>
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void enum_cdrdb()
|
||||
{
|
||||
cdr_src *pcdr;
|
||||
char sqlstr[64];
|
||||
MYSQL_RES *res_set;
|
||||
MYSQL_ROW row;
|
||||
int i;
|
||||
|
||||
tb_index = tb_num = 0;
|
||||
|
||||
pcdr = &CdrSet[cdr_index++];
|
||||
|
||||
for (i = 0; i < cdr_index - 2; i++) {
|
||||
if (strstr(CdrSet[i].record_table, pcdr->record_table) != NULL) {
|
||||
cdr_index++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
cdr_log("Search tables like %s*\n", pcdr->record_table);
|
||||
|
||||
sprintf(sqlstr, "SHOW TABLES FROM CDR_DB LIKE '%s_%%'",
|
||||
pcdr->record_table);
|
||||
if (mysql_query(cdrdb_conn, sqlstr) != 0)
|
||||
return;
|
||||
if ((res_set = mysql_store_result(cdrdb_conn)) == NULL)
|
||||
return;
|
||||
while ((row = mysql_fetch_row(res_set)) != NULL && tb_num < 64) {
|
||||
if (row[0] != NULL)
|
||||
strcpy(tb_name[tb_num++], row[0]);
|
||||
}
|
||||
mysql_free_result(res_set);
|
||||
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // backup_table
|
||||
Description: // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>csv<73>ļ<EFBFBD><C4BC><EFBFBD>Щ<D0A9><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Calls: // mysql_query; mysql_store_result; mysql_fetch_row; create_dat_for_wxc1; create_csv;
|
||||
Called By: // cdrdb_timer;
|
||||
Table Accessed: // <20><><EFBFBD>ݱ<EFBFBD>
|
||||
Table Updated: //
|
||||
Input: // tb_name:<3A><><EFBFBD><EFBFBD>; csv_path:<3A><><EFBFBD><EFBFBD>·<EFBFBD><C2B7>; flag:<3A><>־λ; selfield; cdr_ver:<3A>汾;
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void backup_table(char *tb_name, char *csv_path,int flag,char *selfield,BYTE cdr_ver)
|
||||
{
|
||||
char sqlstr[256];
|
||||
MYSQL_RES *res_set;
|
||||
MYSQL_ROW row;
|
||||
char timestr[50];
|
||||
//char mytime[20],myday[20];
|
||||
long l_time;
|
||||
struct tm *t;
|
||||
|
||||
cdr_log("Start backup table %s\n", tb_name);
|
||||
if(flag==1)
|
||||
sprintf(sqlstr,
|
||||
"SELECT DATE_FORMAT(releaseTime,'%%Y_%%m_%%d') FROM %s WHERE TO_DAYS(releaseTime)<TO_DAYS(NOW()) LIMIT 1",
|
||||
tb_name);
|
||||
else
|
||||
sprintf(sqlstr,
|
||||
"SELECT DATE_FORMAT(releaseTime,'%%Y_%%m_%%d') FROM %s WHERE TO_DAYS(releaseTime)=TO_DAYS(NOW()) LIMIT 1",
|
||||
tb_name);
|
||||
if (mysql_query(cdrdb_conn, sqlstr) != 0) {
|
||||
cdr_log("Fail to query:%s\n", mysql_error(cdrdb_conn));
|
||||
return;
|
||||
}
|
||||
if ((res_set = mysql_store_result(cdrdb_conn)) == NULL)
|
||||
return;
|
||||
|
||||
if ((row = mysql_fetch_row(res_set)) == NULL || row[0] == NULL) {
|
||||
mysql_free_result(res_set);
|
||||
cdr_log("No old record in table\n");
|
||||
l_time = time(NULL);
|
||||
if(flag==1)
|
||||
l_time = l_time-24*3600;//for the yesterday
|
||||
t = localtime(&l_time);
|
||||
sprintf(timestr,"%04d_%02d_%02d",t->tm_year + 1900, t->tm_mon + 1,t->tm_mday);
|
||||
// return;
|
||||
}else{
|
||||
strcpy(timestr, row[0]);
|
||||
mysql_free_result(res_set);
|
||||
}
|
||||
//<2F><><EFBFBD>ݰ汾<DDB0>Ų<EFBFBD><C5B2><EFBFBD>csv<73>ļ<EFBFBD>
|
||||
/*if(cdr_ver==1)
|
||||
create_dat_for_wxc1(tb_name, timestr, csv_path,flag,selfield);
|
||||
else
|
||||
create_csv(tb_name, timestr, csv_path,flag,selfield);*/
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // create_csv
|
||||
Description: // <20><><EFBFBD><EFBFBD>csv<73>ļ<EFBFBD>
|
||||
Calls: // mysql_query;
|
||||
Called By: // backup_table;
|
||||
Table Accessed: // <20><><EFBFBD>ݱ<EFBFBD>
|
||||
Table Updated: //
|
||||
Input: // tb_name:<3A><><EFBFBD><EFBFBD>; time_str:ʱ<><CAB1>; csv_path:<3A><><EFBFBD><EFBFBD>·<EFBFBD><C2B7>; flag:<3A><>־λ; selfield;
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void create_csv(char *tb_name, char *csv_path,int flag,char *selfield)
|
||||
{
|
||||
char olddir[128], sqlstr[1024], csv_file[32], tb_prefix[32], *pchr, cmdstr[1024]; //cur_path[96],dirname[32];
|
||||
struct stat fileinfo;
|
||||
// char filestr[]
|
||||
// MYSQL_RES *res_set;
|
||||
// MYSQL_ROW row;
|
||||
|
||||
strcpy(tb_prefix, tb_name);
|
||||
if ((pchr = strchr(tb_prefix, '_')) == NULL)
|
||||
return;
|
||||
*(pchr++) = '\0';
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>Ŀ¼
|
||||
getcwd(olddir, 128);
|
||||
cdr_log("%s\n", tb_name);
|
||||
cdr_log("%s\n", csv_path);
|
||||
if (chdir(csv_path) == -1) {
|
||||
sprintf(cmdstr, "mkdir -p -m777 %s", csv_path);
|
||||
cdr_log("%s\n", cmdstr);
|
||||
system(cmdstr);
|
||||
if (chdir(csv_path) == -1)
|
||||
return;
|
||||
}
|
||||
|
||||
//<2F><>sending_dirĿ¼ȥ<C2BC><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (chdir(sening_dir) == -1) {
|
||||
sprintf(cmdstr, "mkdir -p -m777 %s", sening_dir);
|
||||
cdr_log("%s\n", cmdstr);
|
||||
system(cmdstr);
|
||||
if (chdir(sening_dir) == -1)
|
||||
return;
|
||||
}
|
||||
|
||||
//sprintf(csv_file, "%s_%s_%s.csv", tb_prefix, time_str, pchr);
|
||||
sprintf(csv_file, "%s", cdrFileName);
|
||||
//chfilename(csv_path, csv_file);
|
||||
delfile(csv_path, csv_file);
|
||||
cdr_log("%s\n", csv_path);
|
||||
cdr_log("%s\n", csv_file);
|
||||
cdr_log("%s\n", CDRDB_NAME);
|
||||
cdr_log("%s\n", tb_name);
|
||||
//*************************************************************
|
||||
//<2F><><EFBFBD><EFBFBD>csv<73>ļ<EFBFBD>
|
||||
if(flag==1)
|
||||
sprintf(sqlstr,
|
||||
"SELECT %s INTO OUTFILE '%s/%s' FROM %s.%s ",
|
||||
selfield,csv_path, csv_file, CDRDB_NAME, tb_name);
|
||||
else
|
||||
sprintf(sqlstr,
|
||||
"SELECT %s INTO OUTFILE '%s/%s' FROM %s.%s ",
|
||||
selfield,csv_path, csv_file, CDRDB_NAME, tb_name);
|
||||
//sprintf(sqlstr,"SELECT * INTO OUTFILE '%s/%s' FIELDS TERMINATED BY ',' FROM %s.%s WHERE TO_DAYS(releaseTime)<TO_DAYS(NOW())",csv_path,csv_file,CDRDB_NAME,tb_name);
|
||||
printf("%s\n", sqlstr);
|
||||
if (mysql_query(cdrdb_conn, sqlstr) != 0) {
|
||||
printf("Fail to create csv:%s\n", mysql_error(cdrdb_conn));
|
||||
{
|
||||
chdir(olddir);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
//if(backup_flag)
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD>csv<73>ļ<EFBFBD><C4BC>ƶ<EFBFBD><C6B6><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>·<EFBFBD><C2B7>
|
||||
sprintf(send_file,"%s",csv_file);
|
||||
sprintf(cmdstr, "cp %s/%s %s/%s.bak",csv_path,csv_file,csv_path,csv_file);
|
||||
system(cmdstr);
|
||||
sprintf(cmdstr, "mv %s/%s.bak %s/%s",csv_path,csv_file,sening_dir,csv_file);
|
||||
system(cmdstr);
|
||||
}
|
||||
if (stat(csv_file, &fileinfo) == 0)
|
||||
{
|
||||
/*if (fileinfo.st_size == 0) {
|
||||
cdr_log("zero size,delete file %s\n", csv_file);
|
||||
remove(csv_file);
|
||||
} else*/
|
||||
strcpy(compress_file, csv_file);
|
||||
}
|
||||
}
|
||||
|
||||
//chdir(olddir);
|
||||
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // clear_table
|
||||
Description: // ɾ<><C9BE><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD><EFBFBD>ݱ<EFBFBD>
|
||||
Calls: // mysql_query; mysql_store_result; mysql_fetch_row;
|
||||
Called By: // cdrdb_timer;
|
||||
Table Accessed: // <20><><EFBFBD>ݱ<EFBFBD>
|
||||
Table Updated: //
|
||||
Input: // tb_name:<3A><><EFBFBD><EFBFBD>;
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void clear_table(char *tb_name)
|
||||
{
|
||||
char sqlstr[256];
|
||||
MYSQL_RES *res_set;
|
||||
MYSQL_ROW row;
|
||||
cdr_log("clear table %s...", tb_name);
|
||||
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>ݱ<EFBFBD>
|
||||
sprintf(sqlstr,
|
||||
"DELETE FROM %s.%s ",
|
||||
CDRDB_NAME, tb_name);
|
||||
if (mysql_query(cdrdb_conn, sqlstr) != 0) {
|
||||
cdr_log("Fail to clear table:%s\n", mysql_error(cdrdb_conn));
|
||||
return;
|
||||
}
|
||||
/*
|
||||
cdr_log("optimizing...\n");
|
||||
sprintf(sqlstr, "OPTIMIZE TABLE %s", tb_name);
|
||||
if (mysql_query(cdrdb_conn, sqlstr) != 0) {
|
||||
cdr_log("Fail to optimizing table:%s\n", mysql_error(cdrdb_conn));
|
||||
return;
|
||||
}
|
||||
if ((res_set = mysql_store_result(cdrdb_conn)) != NULL) {
|
||||
while ((row = mysql_fetch_row(res_set))) {
|
||||
cdr_log("%s/%s/%s/%s\n", row[0], row[1], row[2], row[3]);
|
||||
}
|
||||
}
|
||||
mysql_free_result(res_set);*/
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // compress_csv
|
||||
Description: // ѹ<><D1B9>csv<73>ļ<EFBFBD>
|
||||
Calls: //
|
||||
Called By: // cdrdb_timer;
|
||||
Table Accessed: // <20><><EFBFBD>ݱ<EFBFBD>
|
||||
Table Updated: //
|
||||
Input: // path_name:·<><C2B7><EFBFBD><EFBFBD>;
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void compress_csv(char *path_name)
|
||||
{
|
||||
char olddir[128], *pchr, file_prefix[64], csv_file[64], tarfile[64],
|
||||
cmdstr[128];
|
||||
DWORD oldmask;
|
||||
|
||||
//<2F>Ƿ<EFBFBD><C7B7>ļ<EFBFBD>
|
||||
if (strlen(compress_file) < 1)
|
||||
return;
|
||||
|
||||
cdr_log("start compress file '%s' in %s\n", compress_file, path_name);
|
||||
|
||||
strcpy(csv_file, compress_file);
|
||||
strcpy(file_prefix, compress_file);
|
||||
compress_file[0] = '\0';
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>csv<73>ļ<EFBFBD>
|
||||
if ((pchr = strstr(file_prefix, ".csv")) == NULL)
|
||||
return;
|
||||
*(pchr) = '\0';
|
||||
|
||||
getcwd(olddir, 128);
|
||||
if (chdir(path_name) == -1)
|
||||
return;
|
||||
|
||||
sprintf(tarfile, "%s.tgz", file_prefix);
|
||||
//chfilename(path_name, tarfile);
|
||||
delfile(path_name, tarfile);
|
||||
|
||||
//<2F><>ʼѹ<CABC><D1B9>
|
||||
oldmask = umask(0);
|
||||
sprintf(cmdstr, "tar zvfc ./%s ./%s", tarfile, csv_file);
|
||||
system(cmdstr);
|
||||
umask(oldmask);
|
||||
|
||||
if (access(tarfile, F_OK) == 0)
|
||||
remove(csv_file);
|
||||
else {
|
||||
cdr_log("Fail to compress csv file %s\n", csv_file);
|
||||
chdir(olddir);
|
||||
return;
|
||||
}
|
||||
|
||||
chdir(olddir);
|
||||
}
|
||||
|
||||
/*
|
||||
void chfilename(char *path_name, char *oldname)
|
||||
{
|
||||
char newname[64], newpath[96];
|
||||
int n = 0;
|
||||
strcpy(newname, oldname);
|
||||
sprintf(newpath, "%s/%s", path_name, newname);
|
||||
while (access(newpath, F_OK) == 0) {
|
||||
sprintf(newname, "%s~%d", oldname, n++);
|
||||
sprintf(newpath, "%s/%s", path_name, newname);
|
||||
}
|
||||
cdr_log("File %s/%s exist.change it's name to %s\n", path_name,
|
||||
oldname, newname);
|
||||
strcpy(oldname, newname);
|
||||
}
|
||||
*/
|
||||
|
||||
/*************************************************
|
||||
Function: // delfile
|
||||
Description: // ɾ<><C9BE>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
Calls: //
|
||||
Called By: // create_csv;
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: // path_name:·<><C2B7><EFBFBD><EFBFBD>; file_name:<3A>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void delfile(char *path_name, char *filename)
|
||||
{
|
||||
char path[96];
|
||||
|
||||
sprintf(path, "%s/%s", path_name, filename);
|
||||
if(access(path, F_OK) == 0) {
|
||||
unlink(path);
|
||||
}
|
||||
cdr_log("File %s/%s exist.It has been deleted for the new file\n", path_name,
|
||||
filename);
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // safe_query
|
||||
Description: // <20><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>
|
||||
Calls: // mysql_ping<6E><67>
|
||||
Called By: //
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: // conn:<3A><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>; strquery:sql<71><6C><EFBFBD><EFBFBD>; retry:<3A><><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>
|
||||
Output: //
|
||||
Return: //
|
||||
Others: // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ݹ麯<DDB9><E9BAAF><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>ģ<EFBFBD><C4A3>û<EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>
|
||||
*************************************************/
|
||||
int safe_query(MYSQL * conn, char *strquery, int retry)
|
||||
{
|
||||
int errno;
|
||||
if (mysql_query(conn, strquery) == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
errno = mysql_errno(conn);
|
||||
if (errno == CR_SERVER_GONE_ERROR || errno == CR_SERVER_LOST) {
|
||||
retry %= 5;
|
||||
cdr_log("error NO.:%d,retry...remain %d times\n", errno,
|
||||
retry);
|
||||
if (mysql_ping(conn)) {
|
||||
cdr_log("lost connection to mysql server\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (retry-- > 0)
|
||||
return safe_query(conn, strquery, retry);
|
||||
else {
|
||||
cdr_log("%s\n", strquery);
|
||||
cdr_log("error %d:%s\n", mysql_errno(conn),
|
||||
mysql_error(conn));
|
||||
cdr_log("can't fix the error\n");
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
cdr_log("%s\n", strquery);
|
||||
cdr_log("error %d:%s\n", mysql_errno(conn), mysql_error(conn));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // send_csv
|
||||
Description: // <20><><EFBFBD><EFBFBD>csv<73>ļ<EFBFBD><C4BC><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>Ŀ¼
|
||||
Calls: // mysql_query; mysql_store_result; mysql_fetch_row;
|
||||
Called By: //
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: //
|
||||
Others: // <20>˺<EFBFBD><CBBA><EFBFBD><EFBFBD>ѷ<EFBFBD><D1B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*************************************************/
|
||||
void send_csv(char *path_name)
|
||||
{
|
||||
/*char serverinfo[128],sqlstr[256],*username,*pwd,*serverip,*remotepath, *pchr;
|
||||
char locationpath[128];
|
||||
char sendpath[128];
|
||||
char getpath[128];
|
||||
char localIP[16][16];
|
||||
|
||||
MYSQL_RES *res;
|
||||
MYSQL_ROW row;
|
||||
|
||||
int nRet,tmppathlen,count;
|
||||
|
||||
if(*send_file==0){
|
||||
return;
|
||||
}
|
||||
sprintf(sqlstr,
|
||||
"SELECT pubVarValue FROM OMC_PUB.omcPubVarConf WHERE pubVarName='cdr_store_server'");
|
||||
|
||||
if (mysql_query(omcPub_conn, sqlstr) != 0) {
|
||||
cdr_log("%s\n", mysql_error(omcPub_conn));
|
||||
return;
|
||||
}
|
||||
if ((res = mysql_store_result(omcPub_conn)) == NULL)
|
||||
return;
|
||||
|
||||
if((row = mysql_fetch_row(res)) != NULL) {
|
||||
memset(serverinfo, 0, sizeof(serverinfo));
|
||||
strcpy(serverinfo,row[0]);
|
||||
}
|
||||
|
||||
mysql_free_result(res);
|
||||
|
||||
|
||||
tmppathlen =0;
|
||||
tmppathlen = strlen(serverinfo);
|
||||
if (serverinfo[tmppathlen-1] != '/'||tmppathlen<127){
|
||||
serverinfo[tmppathlen]='/';
|
||||
serverinfo[tmppathlen+1]='\0';
|
||||
//strcat(serverinfo,"/");
|
||||
}
|
||||
|
||||
username= serverinfo;//get username
|
||||
|
||||
if((pchr = strstr(serverinfo, "@"))==NULL){
|
||||
cdr_log("send csv files error,cdr_store_server param error!\n");
|
||||
return;
|
||||
}
|
||||
*(pchr++) = '\0';
|
||||
serverip = pchr; //get server ip
|
||||
if((pchr = strstr(username, ":"))==NULL){
|
||||
cdr_log("send csv files error,cdr_store_server param error!\n");
|
||||
return;
|
||||
}
|
||||
*(pchr++) = '\0';
|
||||
pwd = pchr;//get password
|
||||
if((pchr = strstr(serverip, ">"))==NULL){
|
||||
cdr_log("send csv files error,cdr_store_server param error!\n");
|
||||
return;
|
||||
}
|
||||
*(pchr++) = '\0';
|
||||
remotepath = pchr;//get remotepath
|
||||
*/
|
||||
//****************************************
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>cdr<64><72>Ŀ¼<C4BF>ϴ<EFBFBD>
|
||||
//****************************************
|
||||
// serverip+remotepath eg:172.18.234.235/tmp/
|
||||
/*sprintf(sendpath,"%s%s",serverip,remotepath);
|
||||
|
||||
nRet=ftp_getlocalip(localIP);
|
||||
if(nRet>16) nRet=16;
|
||||
for(count=0;count<nRet;count++){
|
||||
sprintf(getpath,"%s%s/",localIP[count],path_name);
|
||||
if(strcmp(getpath,sendpath)==0){
|
||||
// printf("the same place..return\n");
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
//****************************************
|
||||
|
||||
/*if((nRet=ftp_open(serverip,21)==1)){
|
||||
cdr_log("send csv files error,%s->ftp open failed\n",ftp_retmsg);
|
||||
ftp_logout();
|
||||
return;
|
||||
}
|
||||
if((nRet=ftp_login(username,pwd)==1)){
|
||||
cdr_log("send csv files error,%s->ftp login failed\n",ftp_retmsg);
|
||||
ftp_logout();
|
||||
return;
|
||||
}
|
||||
|
||||
if((nRet = ftp_cwd(remotepath)==1)){
|
||||
cdr_log("send csv files error,%s->ftp CWD failed\n",ftp_retmsg);
|
||||
ftp_logout();
|
||||
return;
|
||||
}
|
||||
|
||||
sprintf(locationpath,"%s/",path_name);
|
||||
|
||||
|
||||
if((nRet = ftp_putfile(send_file,locationpath)==1)){
|
||||
cdr_log("send csv files error,%s->upload failed\n",ftp_retmsg);
|
||||
ftp_logout();
|
||||
return;
|
||||
}
|
||||
ftp_logout();
|
||||
memset(send_file,0,64);
|
||||
return; */
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // create_dat_for_wxc1
|
||||
Description: // <20><><EFBFBD><EFBFBD>wxc1<63><31>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>ô˺<C3B4><CBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>csv<73>ļ<EFBFBD>
|
||||
Calls: // mysql_query; mysql_store_result; mysql_fetch_row;
|
||||
Called By: // backup_table;
|
||||
Table Accessed: // <20><><EFBFBD>ݱ<EFBFBD>
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void create_dat_for_wxc1(char *tb_name,char *csv_path,int flag,char *selfield)
|
||||
{
|
||||
char olddir[128], sqlstr[1024], csv_file[32], tb_prefix[32], *pchr, cmdstr[1024]; //cur_path[96],dirname[32];
|
||||
int wcount=0;
|
||||
char dat_file[64];
|
||||
MYSQL_RES *res_set;
|
||||
MYSQL_ROW row;
|
||||
FILE *dat_fp;
|
||||
|
||||
unsigned long l_time;
|
||||
struct tm *t;
|
||||
char str[512];
|
||||
int res_num,i;
|
||||
int p_width[27]={8,18,23,23,23,23,23,11,11,16,7,7,22,23,23,23,15,9,7,23,7,7,7,23,23,11,9};
|
||||
//int p_width[28]={8,18,23,23,23,23,23,11,11,6,10,7,7,22,23,23,23,15,9,7,23,7,7,7,23,23,11,9};
|
||||
|
||||
strcpy(tb_prefix, tb_name);
|
||||
if ((pchr = strchr(tb_prefix, '_')) == NULL)
|
||||
return;
|
||||
*(pchr++) = '\0';
|
||||
|
||||
getcwd(olddir, 128);
|
||||
cdr_log("%s\n", tb_name);
|
||||
cdr_log("%s\n", csv_path);
|
||||
if (chdir(csv_path) == -1) {
|
||||
sprintf(cmdstr, "mkdir -p -m777 %s", csv_path);
|
||||
cdr_log("%s\n", cmdstr);
|
||||
system(cmdstr);
|
||||
if (chdir(csv_path) == -1)
|
||||
return;
|
||||
}
|
||||
|
||||
if (chdir(sening_dir) == -1) {
|
||||
sprintf(cmdstr, "mkdir -p -m777 %s", sening_dir);
|
||||
cdr_log("%s\n", cmdstr);
|
||||
system(cmdstr);
|
||||
if (chdir(sening_dir) == -1)
|
||||
return;
|
||||
}
|
||||
|
||||
//sprintf(csv_file, "%s_%s_%s.csv", tb_prefix, time_str, pchr);
|
||||
sprintf(csv_file, "%s", cdrFileName);
|
||||
//chfilename(csv_path, csv_file);
|
||||
delfile(csv_path, csv_file);
|
||||
cdr_log("%s\n", csv_path);
|
||||
cdr_log("%s\n", csv_file);
|
||||
cdr_log("%s\n", CDRDB_NAME);
|
||||
cdr_log("%s\n", tb_name);
|
||||
|
||||
//*************************************************************
|
||||
if(flag==1)
|
||||
sprintf(sqlstr,
|
||||
"SELECT %s FROM %s.%s WHERE TO_DAYS(releaseTime)<TO_DAYS(NOW())",
|
||||
selfield, CDRDB_NAME, tb_name);
|
||||
else
|
||||
sprintf(sqlstr,
|
||||
"SELECT %s FROM %s.%s WHERE TO_DAYS(releaseTime)=TO_DAYS(NOW())",
|
||||
// "SELECT %s FROM %s.%s",
|
||||
selfield, CDRDB_NAME, tb_name);
|
||||
|
||||
cdr_log("%s\n", sqlstr);
|
||||
|
||||
if (mysql_query(cdrdb_conn, sqlstr) != 0) {
|
||||
cdr_log("%s\n", mysql_error(cdrdb_conn));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((res_set = mysql_store_result(cdrdb_conn)) == NULL) {
|
||||
cdr_log("%s\n", mysql_error(cdrdb_conn));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
sprintf(dat_file, "%s/%s", csv_path, csv_file);
|
||||
dat_fp = fopen(dat_file, "w");
|
||||
if(dat_fp==NULL){
|
||||
cdr_log("Fail to create file\n");
|
||||
chdir(olddir);
|
||||
return;
|
||||
}
|
||||
res_num = mysql_num_rows(res_set);
|
||||
l_time = time(NULL);
|
||||
t = localtime(&l_time);
|
||||
|
||||
fprintf(dat_fp,"FILE NAME: %s NO. OF RECORDS:%-10d\n",dat_file,res_num);
|
||||
|
||||
fprintf(dat_fp,"START DATE: %02d/%02d/%d START TIME: %02d:%02d:%02d\n\n",t->tm_mon+1,t->tm_mday,t->tm_year+1900,t->tm_hour,t->tm_min,t->tm_sec);
|
||||
fprintf(dat_fp,"Type Imsi Msisdn Msrn Calling # Called # RE In.TkGp Ou.TkGp Location BS SS Mob. ClassMark Seizure Time Answer Time Release Time Duration TCos SSA SS Parm. SSR CR RCU SM Delivery Time SC Address SM Rslt MsgRf \n\n");
|
||||
|
||||
while ((row = mysql_fetch_row(res_set)) != NULL){
|
||||
if(atoi(row[0])!=6&&atoi(row[0])!=7){ //not sms
|
||||
if(row[16]==NULL||atoi(row[16])==0) //Duration=0 skip
|
||||
continue;
|
||||
}
|
||||
for(i=0;i<27;i++){
|
||||
if(row[i]==NULL){
|
||||
if(i==7||i==8){
|
||||
;//In.TkGp,Ou.TkGpr skip
|
||||
}else{
|
||||
fprintf(dat_fp,"%-*s",p_width[i],"--");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
switch (i){
|
||||
case 0: // Type
|
||||
case 10:// basicService
|
||||
case 11:// supplServicesUsed
|
||||
case 18:// SSA
|
||||
case 20:// SSR
|
||||
case 26:// MsgRf
|
||||
sprintf(str,"%03d",atoi(row[i]));
|
||||
break;
|
||||
case 7:// In.TkGp
|
||||
case 8:// Ou.TkGp
|
||||
if(atoi(row[0])==6||atoi(row[0])==7){//sms
|
||||
sprintf(str,"--");
|
||||
}else{
|
||||
sprintf(str,"00 00 00");
|
||||
}
|
||||
break;
|
||||
case 15:// releaseTime
|
||||
if(atoi(row[0])==6||atoi(row[0])==7){
|
||||
fprintf(dat_fp,"%-*s",p_width[i],"--");
|
||||
continue;
|
||||
}
|
||||
case 13:// seizureTime
|
||||
case 14:// answerTime
|
||||
case 23:// SmDeliveryTime
|
||||
// 2001-06-07 11:12:22->
|
||||
// 06/07/2001 11:12:22
|
||||
{
|
||||
int y=0,m=0,d=0;
|
||||
pchr=row[i];
|
||||
y = atoi(pchr);
|
||||
pchr = strchr(pchr,'-');
|
||||
if(pchr==NULL)
|
||||
{
|
||||
sprintf(str,"%02d/%02d/%02d %s",m,d,y,pchr);
|
||||
break;
|
||||
}
|
||||
pchr++;
|
||||
m = atoi(pchr);
|
||||
pchr = strchr(pchr,'-');
|
||||
pchr++;
|
||||
if(pchr==NULL)
|
||||
{
|
||||
sprintf(str,"%02d/%02d/%02d %s",m,d,y,pchr);
|
||||
break;
|
||||
}
|
||||
d = atoi(pchr);
|
||||
pchr = strchr(pchr,' ');
|
||||
sprintf(str,"%02d/%02d/%02d %s",m,d,y,pchr);
|
||||
break;
|
||||
}
|
||||
case 16://callDuration
|
||||
{
|
||||
int d,h,m,s,total;
|
||||
total =atoi(row[i]);
|
||||
d = total/86400;
|
||||
h = (total%86400)/3600;
|
||||
m = (total%3600)/60;
|
||||
s = total%60;
|
||||
sprintf(str,"%02d:%02d:%02d:%02d",d,h,m,s);
|
||||
break;
|
||||
}
|
||||
// case 9: // location_mscNumber
|
||||
// case 10:// location_mscNumber_2
|
||||
case 17:// TCos
|
||||
sprintf(str,"%05d",atoi(row[i]));
|
||||
break;
|
||||
case 21:// CR
|
||||
sprintf(str,"%04d",atoi(row[i]));
|
||||
break;
|
||||
sprintf(str,"%s",row[i]);
|
||||
break;
|
||||
case 12:// Mob. ClassMark
|
||||
sprintf(str,"1f %s",row[i]);
|
||||
break;
|
||||
default:
|
||||
sprintf(str,"%s",row[i]);
|
||||
break;
|
||||
}
|
||||
fprintf(dat_fp,"%-*s",p_width[i],str);
|
||||
}
|
||||
fprintf(dat_fp,"\n");
|
||||
wcount++;
|
||||
}
|
||||
fseek(dat_fp,0,SEEK_SET);
|
||||
fprintf(dat_fp,"FILE NAME: %s NO. OF RECORDS:%-10d\n",dat_file,wcount);
|
||||
mysql_free_result(res_set);
|
||||
strcpy(compress_file, csv_file);
|
||||
fclose(dat_fp);
|
||||
chdir(olddir);
|
||||
if(backup_flag)
|
||||
{
|
||||
sprintf(send_file,"%s",csv_file);
|
||||
sprintf(cmdstr, "cp %s/%s %s/%s.bak",csv_path,csv_file,csv_path,csv_file);
|
||||
system(cmdstr);
|
||||
sprintf(cmdstr, "mv %s/%s.bak %s/%s",csv_path,csv_file,sening_dir,csv_file);
|
||||
system(cmdstr);
|
||||
}
|
||||
}
|
||||
115
src/accountMgr/c_program/wxc1AndWxc2ConverseTools/cdrdebug.c
Normal file
115
src/accountMgr/c_program/wxc1AndWxc2ConverseTools/cdrdebug.c
Normal file
@@ -0,0 +1,115 @@
|
||||
/*************************************************
|
||||
File name: cdrdebug.c
|
||||
Author:
|
||||
Version: 9:00:00
|
||||
Date: 2002-5-7
|
||||
Description:<3A><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>Եĺ<D4B5><C4BA><EFBFBD>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
History:
|
||||
No.
|
||||
Author:
|
||||
Date:
|
||||
Version:
|
||||
Description:
|
||||
*************************************************/
|
||||
|
||||
#include "cdr.h"
|
||||
#if CDR_LINK_DEBUG
|
||||
extern cdr_src CdrSet[CDR_SRC_NUM];
|
||||
extern BYTE iCdrNum;
|
||||
|
||||
static char debug_buf[4096];
|
||||
//static char asc_in[256];
|
||||
void cdr_debug_info(BYTE npage, BYTE nline, BYTE * pt, BYTE len);
|
||||
|
||||
/*************************************************
|
||||
Function: // cdrdebug_init
|
||||
Description: // <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
|
||||
Calls: //
|
||||
Called By: //
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void cdrdebug_init()
|
||||
{
|
||||
DWORD asc_id[20] = { 1, 3, 6, 1, 4, 1, 1373, 1, 3, 2, 3, 1, 2, 16, 4 };
|
||||
DWORD status_id[20] =
|
||||
{ 1, 3, 6, 1, 4, 1, 1373, 1, 3, 2, 3, 1, 2, 16, 1 };
|
||||
DWORD name_id[20] =
|
||||
{ 1, 3, 6, 1, 4, 1, 1373, 1, 3, 2, 3, 1, 2, 16, 2 };
|
||||
|
||||
DWORD title_id[20] =
|
||||
{ 1, 3, 6, 1, 4, 1, 1373, 1, 3, 2, 3, 1, 2, 16, 6, 1 };
|
||||
|
||||
static char module_name[16] = "CDR";
|
||||
static BYTE debug_status = 1;
|
||||
cdr_src *pcdr;
|
||||
BYTE i;
|
||||
char title[320], info[320] = {
|
||||
"1 2\r\n"
|
||||
"IP\r\n"
|
||||
"Port\r\n"
|
||||
"receive\r\n"
|
||||
"record\r\n"
|
||||
"lost\r\n"
|
||||
"tail\r\n"
|
||||
"head\r\n"
|
||||
"bind num\r\n"
|
||||
"get state\r\n" "get timeout\r\n" "set state\r\n" "set timeout"
|
||||
};
|
||||
|
||||
debug_set_response(15, asc_id, debug_buf, 1);
|
||||
debug_set_response(15, status_id, &debug_status, 1);
|
||||
debug_set_response(15, name_id, module_name, strlen(module_name));
|
||||
|
||||
for (i = 0; i < iCdrNum; i++) {
|
||||
pcdr = &CdrSet[i];
|
||||
sprintf(title, "\tCDR Collector\tPage %02d\t\tMessage\r\n%s",
|
||||
i + 1, info);
|
||||
title_id[14] = i + 6;
|
||||
debug_set_response(15, title_id, title, strlen(title));
|
||||
cdr_debug_info(i + 1, 2, (BYTE *) & pcdr->addr.remote_ip, 4);
|
||||
cdr_debug_info(i + 1, 3, (BYTE *) & pcdr->addr.remote_port, 2);
|
||||
cdr_debug_info(i + 1, 4, (BYTE *) & pcdr->recv, 4);
|
||||
cdr_debug_info(i + 1, 5, (BYTE *) & pcdr->recd, 4);
|
||||
cdr_debug_info(i + 1, 6, (BYTE *) & pcdr->loss, 4);
|
||||
cdr_debug_info(i + 1, 7, (BYTE *) & pcdr->instance, 4);
|
||||
cdr_debug_info(i + 1, 8, (BYTE *) & pcdr->head, 4);
|
||||
cdr_debug_info(i + 1, 9, (BYTE *) & pcdr->maxbind, 4);
|
||||
cdr_debug_info(i + 1, 10, (BYTE *) & pcdr->get_state, 1);
|
||||
cdr_debug_info(i + 1, 11, (BYTE *) & pcdr->get_timeout, 4);
|
||||
cdr_debug_info(i + 1, 12, (BYTE *) & pcdr->set_state, 1);
|
||||
cdr_debug_info(i + 1, 13, (BYTE *) & pcdr->set_timeout, 4);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // cdr_debug_info
|
||||
Description: // <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
Calls: //
|
||||
Called By: //
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: // npage; nline; pt; len;
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void cdr_debug_info(BYTE npage, BYTE nline, BYTE * pt, BYTE len)
|
||||
{
|
||||
DWORD oid[20] =
|
||||
{ 1, 3, 6, 1, 4, 1, 1373, 1, 3, 2, 3, 1, 2, 16, 5, 2, 2 };
|
||||
oid[14] = 5 + npage;
|
||||
oid[15] = nline;
|
||||
debug_set_response(17, oid, pt, len);
|
||||
}
|
||||
|
||||
#endif
|
||||
194
src/accountMgr/c_program/wxc1AndWxc2ConverseTools/cdrlog.c
Normal file
194
src/accountMgr/c_program/wxc1AndWxc2ConverseTools/cdrlog.c
Normal file
@@ -0,0 +1,194 @@
|
||||
/*************************************************
|
||||
File name: cdrlog.c
|
||||
Author:
|
||||
Version: 9:00:00
|
||||
Date: 2002-7-2
|
||||
Description:<3A><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>cdrCollectorģ<72><C4A3><EFBFBD><EFBFBD>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
History:
|
||||
No.
|
||||
Author:
|
||||
Date:
|
||||
Version:
|
||||
Description:
|
||||
*************************************************/
|
||||
|
||||
#include "cdr.h"
|
||||
|
||||
static FILE *log_fp;
|
||||
|
||||
extern BYTE iCdrNum;
|
||||
|
||||
extern cdr_src CdrSet[CDR_SRC_NUM];
|
||||
|
||||
/*************************************************
|
||||
Function: // cdrlog_init
|
||||
Description: // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>Ա<EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
|
||||
Calls: //
|
||||
Called By: // cdrmain.c; cdrdb.c;
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
|
||||
|
||||
void cdrlog_init()
|
||||
{
|
||||
|
||||
char log_file[64], cmdstr[64];
|
||||
|
||||
long l_time;
|
||||
|
||||
struct tm *t;
|
||||
|
||||
l_time = time(NULL);
|
||||
|
||||
t = localtime(&l_time);
|
||||
|
||||
if (access(CDR_LOG_PATH, F_OK) != 0)
|
||||
|
||||
{
|
||||
|
||||
sprintf(cmdstr, "mkdir -p -m777 %s", CDR_LOG_PATH);
|
||||
|
||||
printf("%s\n", cmdstr);
|
||||
|
||||
system(cmdstr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
sprintf(log_file, "%s/%s_%d_%d", CDR_LOG_PATH, CDR_LOG_FILE,
|
||||
t->tm_mon + 1, t->tm_mday);
|
||||
|
||||
log_fp = fopen(log_file, "a");
|
||||
|
||||
cdr_log("CDR Module start up.%s", ctime(&l_time));
|
||||
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // cdrlog_timer
|
||||
Description: // <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>дһЩ<D2BB><D0A9>־
|
||||
Calls: // cdr_log;
|
||||
Called By: // cdr.c:cdr_timer;
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
|
||||
void cdrlog_timer()
|
||||
{
|
||||
|
||||
char log_file[64];
|
||||
|
||||
long l_time;
|
||||
|
||||
static BYTE ch = 0, ch2 = 0;
|
||||
|
||||
static short m_state;
|
||||
|
||||
struct tm *t;
|
||||
|
||||
if (m_state++ < 6)
|
||||
|
||||
return;
|
||||
|
||||
m_state = 0;
|
||||
|
||||
|
||||
l_time = time(NULL);
|
||||
|
||||
t = localtime(&l_time);
|
||||
|
||||
|
||||
if (ch2 == 0 && t->tm_min % 15 <= 3) //report per 15 minute
|
||||
{
|
||||
|
||||
cdr_report();
|
||||
|
||||
ch2 = 1;
|
||||
|
||||
}
|
||||
|
||||
else if (t->tm_min % 15 > 3)
|
||||
|
||||
ch2 = 0;
|
||||
|
||||
|
||||
if (t->tm_hour == 0 && ch == 0)
|
||||
|
||||
{
|
||||
|
||||
if (log_fp != NULL)
|
||||
|
||||
fclose(log_fp);
|
||||
|
||||
|
||||
sprintf(log_file, "%s/%s_%d_%d", CDR_LOG_PATH, CDR_LOG_FILE,
|
||||
t->tm_mon + 1, t->tm_mday);
|
||||
|
||||
if ((log_fp = fopen(log_file, "a")) != NULL)
|
||||
|
||||
ch = 1;
|
||||
|
||||
}
|
||||
|
||||
else if (t->tm_hour > 0)
|
||||
|
||||
ch = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // cdr_report
|
||||
Description: // <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>д<EFBFBD><D0B4>CDR<44><52><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4>һЩ<D2BB><D0A9>Ϣ
|
||||
Calls: // cdr_log;
|
||||
Called By: // cdrlog_timer;
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
|
||||
|
||||
void cdr_report()
|
||||
{
|
||||
|
||||
BYTE i;
|
||||
|
||||
long l_time;
|
||||
|
||||
struct tm *t;
|
||||
|
||||
cdr_src * pcdr;
|
||||
|
||||
|
||||
l_time = time(NULL);
|
||||
|
||||
t = localtime(&l_time);
|
||||
|
||||
|
||||
cdr_log("=================%02d:%02d:%02d================\n",
|
||||
t->tm_hour, t->tm_min, t->tm_sec);
|
||||
|
||||
for (i = 0; i < iCdrNum; i++)
|
||||
|
||||
{
|
||||
|
||||
pcdr = &CdrSet[i];
|
||||
|
||||
cdr_log("%-08lX(%s-%d)\n", htonl(pcdr->addr.remote_ip),
|
||||
139
src/accountMgr/c_program/wxc1AndWxc2ConverseTools/cdrmain.c
Normal file
139
src/accountMgr/c_program/wxc1AndWxc2ConverseTools/cdrmain.c
Normal file
@@ -0,0 +1,139 @@
|
||||
/*************************************************
|
||||
File name: cdr.c
|
||||
Author:
|
||||
Version: 9:00:00
|
||||
Date: 2002-5-7
|
||||
Description:cdrCollectorģ<72><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>snmp<6D><70>iptransģ<73>飬<EFBFBD><E9A3AC><EFBFBD><EFBFBD>cdr.c<><63><EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD>
|
||||
<09><><EFBFBD>嶨ʱ<E5B6A8><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD>ʱ
|
||||
|
||||
<09><><EFBFBD><EFBFBD><EFBFBD>ⲿģ<E2B2BF><C4A3><EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD>
|
||||
void snmp_init(WORD nport);
|
||||
void iptrans_init();
|
||||
|
||||
|
||||
History:
|
||||
No.
|
||||
Author:
|
||||
Date:
|
||||
Version:
|
||||
Description:
|
||||
*************************************************/
|
||||
|
||||
#include "cdr.h"
|
||||
|
||||
static struct itimerval itimer, old_itimer;
|
||||
static void On_Timer();
|
||||
static void SetTimer();
|
||||
|
||||
/*************************************************
|
||||
Function: // main
|
||||
Description: // <20><>ʼ<EFBFBD><CABC>snmp<6D><70>iptransģ<73><C4A3>,<2C><>ʼ<EFBFBD><CABC><EFBFBD>ö<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Calls: // iptrans_init; snmp_init;
|
||||
Called By: //
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
pid_t pid;
|
||||
//debug_init();
|
||||
|
||||
//fprintf(stderr, "\n Calling iptrans_init()");
|
||||
//iptrans_init();
|
||||
|
||||
//fprintf(stderr, "\n Calling snmp_init()");
|
||||
//snmp_init(CDR_PORT);
|
||||
|
||||
/*
|
||||
if (argc == 2 && strstr(argv[1], "-d")) {
|
||||
if ((pid = fork()) != 0)
|
||||
exit(0);
|
||||
setsid();
|
||||
//umask(0);
|
||||
}*/
|
||||
|
||||
if (argc != 4) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
strcpy(totalCdrFileName,argv[1]);
|
||||
strcpy(cdrFileName,argv[2]);
|
||||
cdrHour=atoi(argv[3]);
|
||||
|
||||
|
||||
cdr_init();
|
||||
|
||||
//cdr_start();
|
||||
|
||||
|
||||
converseFile();
|
||||
|
||||
/*
|
||||
SetTimer();
|
||||
while (1) {
|
||||
//cdr_loop();
|
||||
usleep(50);
|
||||
}
|
||||
return 1;
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // On_Timer
|
||||
Description: // <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Calls: // cdr_timer
|
||||
Called By: //
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void On_Timer()
|
||||
{
|
||||
//debug_rt();
|
||||
//snmp_timer();
|
||||
cdr_timer();
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // SetTimer
|
||||
Description: // <20><><EFBFBD>ö<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Calls: // On_Timer
|
||||
Called By: //
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void SetTimer()
|
||||
{
|
||||
struct sigaction act;
|
||||
act.sa_handler = On_Timer;
|
||||
sigemptyset(&act.sa_mask);
|
||||
act.sa_flags = 0;
|
||||
if (sigaction(SIGALRM, &act, NULL) < 0) {
|
||||
perror("Produce Sigaction");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
itimer.it_interval.tv_sec = 0;
|
||||
itimer.it_interval.tv_usec = 20 * 1000;
|
||||
itimer.it_value.tv_sec = 0;
|
||||
itimer.it_value.tv_usec = 20 * 1000;
|
||||
|
||||
if (setitimer(ITIMER_REAL, &itimer, &old_itimer) != 0) {
|
||||
printf("Setting Timer error! \n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
cdrFileArr=`ls /tmp/needConverseCdrFiles/*`
|
||||
|
||||
echo "Start conversing."
|
||||
for totalCdrFileName in $cdrFileArr ; do
|
||||
cdrFile=`echo $totalCdrFileName|awk -F"/" '{print $4}'`
|
||||
hour=`echo $totalCdrFileName|awk -F"_" '{print $5}'|awk -F"." '{print $1}'`
|
||||
echo $totalCdrFileName $cdrFile $hour
|
||||
./cdrCollector $totalCdrFileName $cdrFile $hour
|
||||
echo "."
|
||||
done
|
||||
|
||||
|
||||
91
src/configMgr/c_program/impmod/Makefile
Normal file
91
src/configMgr/c_program/impmod/Makefile
Normal file
@@ -0,0 +1,91 @@
|
||||
mysqlInclude=/usr/local/mysql/include
|
||||
mysqlInclude.ES=/usr/include/mysql
|
||||
|
||||
mysqlLib=/usr/local/mysql/lib
|
||||
mysqlLib.ES=/usr/lib/mysql
|
||||
|
||||
OBJ =bsscomm.o bss_hb.o nmimp.o nmtypes.o
|
||||
OBJ.ES =bsscomm.o.ES bss_hb.o.ES nmimp.o.ES nmtypes.o.ES
|
||||
|
||||
PROGS1=bsscomm
|
||||
PROGS2=alive
|
||||
|
||||
default: linuxES
|
||||
|
||||
all:
|
||||
@echo " **** Compiling $(PROGS1) and $(PROGS2) ****"
|
||||
@echo "make clean -- Delete the target files"
|
||||
@echo "make linux72 -- Generate target files for Redhat Linux 72"
|
||||
@echo "make linuxES -- Generate target files for Redhat Linux ES"
|
||||
|
||||
linux72: bsscomm alive
|
||||
make alive
|
||||
make bsscomm
|
||||
|
||||
linuxES: bsscomm.ES alive
|
||||
make alive
|
||||
make bsscomm.ES
|
||||
|
||||
bsscomm:${OBJ}
|
||||
@echo Linking $(PROGS1)
|
||||
@gcc -g -W -Wall -o $(PROGS1) ${OBJ} -L$(mysqlLib) -lmariadbclient -lz
|
||||
ar r libimp.a ${OBJ}
|
||||
# cp -f bsscomm ../../../omc83_bin/
|
||||
#cp -f bsscomm /usr/local/omc/bin/
|
||||
|
||||
bsscomm.ES:${OBJ.ES}
|
||||
@echo Linking $(PROGS1)
|
||||
@gcc -g -W -Wall -o $(PROGS1) ${OBJ} -L$(mysqlLib.ES) -lmariadbclient -lz -lm
|
||||
ar r libimp.a ${OBJ}
|
||||
|
||||
installbin: linuxES
|
||||
cp -f $(PROGS1) ../../../../bin/
|
||||
cp -f $(PROGS2) ../../../../bin/
|
||||
|
||||
installomc: linuxES
|
||||
cp -f $(PROGS1) /usr/local/omc/bin/
|
||||
cp -f $(PROGS2) /usr/local/omc/bin/
|
||||
|
||||
installall: installbin installomc
|
||||
|
||||
#imptest.o: imptest.c
|
||||
# gcc -g -O2 -W -Wall -c imptest.c \
|
||||
# -I/usr/local/mysql/include \
|
||||
|
||||
|
||||
bsscomm.o: bsscomm.c nmimp.h nmtypes.h nmstatus.h iwtypes.h
|
||||
gcc -g -W -Wall -c bsscomm.c -I$(mysqlInclude)
|
||||
|
||||
bss_hb.o: bss_hb.c bss_hb.h iwtypes.h bsscomm.h
|
||||
gcc -g -W -Wall -c bss_hb.c -I$(mysqlInclude)
|
||||
|
||||
nmimp.o: nmimp.c nmimp.h iwtypes.h nmstatus.h
|
||||
gcc -g -W -Wall -c nmimp.c
|
||||
|
||||
nmtypes.o: nmtypes.c nmtypes.h iwtypes.h
|
||||
gcc -g -W -Wall -c nmtypes.c
|
||||
|
||||
bsscomm.o.ES: bsscomm.c nmimp.h nmtypes.h nmstatus.h iwtypes.h
|
||||
gcc -g -W -Wall -c bsscomm.c -I$(mysqlInclude.ES)
|
||||
|
||||
bss_hb.o.ES: bss_hb.c bss_hb.h iwtypes.h bsscomm.h
|
||||
gcc -g -W -Wall -c bss_hb.c -I$(mysqlInclude.ES)
|
||||
|
||||
nmimp.o.ES: nmimp.c nmimp.h iwtypes.h nmstatus.h
|
||||
gcc -g -W -Wall -c nmimp.c
|
||||
|
||||
nmtypes.o.ES: nmtypes.c nmtypes.h iwtypes.h
|
||||
gcc -g -W -Wall -c nmtypes.c
|
||||
|
||||
alive: alive.c
|
||||
gcc -g -W -Wall -o alive alive.c
|
||||
#cp -f alive ../../../omc83_bin/
|
||||
#cp -f alive ../../../../bin/
|
||||
# cp -f alive /usr/local/omc/bin/
|
||||
|
||||
clean:
|
||||
rm -rf *.a *.o bsscomm alive
|
||||
|
||||
tags:
|
||||
ctags -R .
|
||||
|
||||
365
src/configMgr/c_program/impmod/alive.c
Normal file
365
src/configMgr/c_program/impmod/alive.c
Normal file
@@ -0,0 +1,365 @@
|
||||
/****************************************************
|
||||
Bsplus monitoring server:
|
||||
Incoming: (bsscomm -> monitor)
|
||||
"16clr 1 172.15.0.3" when server discover error
|
||||
"16add 1 172.15.0.3" for adding new host to array
|
||||
"03rst" to reset the host array
|
||||
"16del 2 172.15.0.3" for deleting
|
||||
Outgoing: (monitor -> bsscomm)
|
||||
"16clr 1 172.15.0.3"
|
||||
"16new 3 173.23.0.3"
|
||||
"03die" to tell BssComm when selection error
|
||||
Testing:
|
||||
Test new connection by "ping -w 2 -i 0.1 -c 5 172.18.0.3"
|
||||
|
||||
****************************************************/
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
#include<sys/time.h>
|
||||
#include<sys/types.h>
|
||||
#include<sys/socket.h>
|
||||
#include<netinet/in.h>
|
||||
#include<unistd.h>
|
||||
#include<errno.h>
|
||||
#include<ctype.h>
|
||||
#include<string.h>
|
||||
#include<time.h>
|
||||
|
||||
#define PORT 5354
|
||||
#define QUEUESIZE 10
|
||||
#define BUFMAX 4096
|
||||
|
||||
#define NO_OF_BSS 256
|
||||
#define IP_LEN 16
|
||||
|
||||
struct connection {
|
||||
char ip[IP_LEN];
|
||||
int bssid;
|
||||
int connected;
|
||||
int no_of_unreachable;
|
||||
};
|
||||
struct connection bsplus[NO_OF_BSS];
|
||||
int nbsplus=0; /* no of element in bsplus array*/
|
||||
int newsock=-1;
|
||||
|
||||
void init_connection(struct connection *conn)
|
||||
{
|
||||
conn->ip[0]='\0';
|
||||
conn->bssid=-1;
|
||||
conn->connected=0;
|
||||
conn->no_of_unreachable=0;
|
||||
}
|
||||
|
||||
int process_outgoing_msg(int socket_fd, char *cmd, int index)
|
||||
{
|
||||
char MsgBuffer[99]="\0";
|
||||
char temp[99]="\0";
|
||||
unsigned int len;
|
||||
|
||||
sprintf(temp, "%s %d %s", cmd, (bsplus[index]).bssid, (bsplus[index]).ip);
|
||||
sprintf(MsgBuffer,"%.2d%s",strlen(temp),temp);
|
||||
|
||||
len = write(socket_fd, MsgBuffer, strlen(MsgBuffer));
|
||||
if ( len != strlen(MsgBuffer) )
|
||||
{
|
||||
fprintf(stderr,"Error !!!");
|
||||
}
|
||||
|
||||
return(len);
|
||||
}
|
||||
|
||||
int process_incoming_msg(char *MsgBuffer)
|
||||
{
|
||||
int i;
|
||||
int bssid;
|
||||
char cmd[4];
|
||||
char ip[IP_LEN]="\0";
|
||||
char buffer[BUFMAX]="\0";
|
||||
int retval=1;
|
||||
char new_str[4]="new";
|
||||
|
||||
//printf("%s\n",MsgBuffer);
|
||||
if(!strncmp(MsgBuffer,"rst",3))
|
||||
{
|
||||
for(i=0;i<NO_OF_BSS;i++)
|
||||
init_connection(&bsplus[i]);
|
||||
nbsplus=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
i=sscanf(MsgBuffer,"%s %d %s",cmd,&bssid,ip);
|
||||
//printf("cmd=%s bssid=%d ip=%s i=%d\n",cmd,bssid,ip, i);
|
||||
|
||||
if ( (i!=3 ) || (bssid>=NO_OF_BSS) )
|
||||
return -1;
|
||||
|
||||
if(!strncmp(cmd,"add",3))
|
||||
{
|
||||
(bsplus[nbsplus]).bssid = bssid;
|
||||
strcpy((bsplus[nbsplus]).ip, ip);
|
||||
(bsplus[nbsplus]).connected=0;
|
||||
nbsplus++;
|
||||
|
||||
/* test connectivity immediately */
|
||||
sprintf(buffer,"ping -w 2 -i 0.1 -c 5 %s 2>/dev/null|grep time >>/dev/null",(bsplus[nbsplus-1]).ip);
|
||||
|
||||
retval=system(buffer);
|
||||
if (!retval) /* if ping succ */
|
||||
{
|
||||
process_outgoing_msg(newsock, new_str, nbsplus-1);//send "new"
|
||||
(bsplus[nbsplus-1]).connected = 1;
|
||||
}
|
||||
}
|
||||
else if(!strncmp(cmd,"del",3))
|
||||
{
|
||||
for(i=0;i<nbsplus;i++)
|
||||
{
|
||||
if( (bsplus[i]).bssid == bssid )
|
||||
{
|
||||
nbsplus--;
|
||||
(bsplus[i]).bssid = (bsplus[nbsplus]).bssid;
|
||||
strcpy((bsplus[i]).ip, (bsplus[nbsplus]).ip);
|
||||
(bsplus[i]).connected = (bsplus[nbsplus]).connected;
|
||||
init_connection(&bsplus[nbsplus]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!strncmp(cmd,"clr",3))
|
||||
{
|
||||
// find index in bsplus[]
|
||||
for(i=0;i<nbsplus;i++)
|
||||
if( (bsplus[i]).bssid == bssid )
|
||||
break;
|
||||
//process_outgoing_msg(newsock, clr_str, i);
|
||||
(bsplus[i]).connected = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"Undecoded msg: %s\n", MsgBuffer);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char runMode;
|
||||
char buffer[BUFMAX];
|
||||
char msgbuffer[BUFMAX];
|
||||
struct sockaddr_in addr, caddr;
|
||||
int sock;
|
||||
int port,caddrlen;
|
||||
int nread;
|
||||
int msglen;
|
||||
int ret;
|
||||
int i,j=0;
|
||||
time_t last_t=0;
|
||||
time_t curr_t=0;
|
||||
int pingval;
|
||||
int nlast=0;
|
||||
char clr_str[4]="clr";
|
||||
|
||||
struct timeval WaitTime;
|
||||
fd_set readfds;
|
||||
int width;
|
||||
|
||||
/*if (argc == 1)
|
||||
{
|
||||
port=PORT;
|
||||
}
|
||||
else
|
||||
{
|
||||
port=atoi(argv[1]);
|
||||
}*/
|
||||
|
||||
if (argc > 0) {
|
||||
runMode = getopt(argc, argv, "d");
|
||||
switch (runMode) {
|
||||
case 'd':
|
||||
setup_daemon();
|
||||
break;
|
||||
case '?':
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
port=PORT;
|
||||
|
||||
for (i=0;i<NO_OF_BSS;i++)
|
||||
init_connection(&bsplus[i]);
|
||||
|
||||
sock=socket(PF_INET, SOCK_STREAM, 0);
|
||||
/* set family to internet */
|
||||
addr.sin_family=AF_INET;
|
||||
addr.sin_port=htons(port);
|
||||
addr.sin_addr.s_addr=INADDR_ANY;
|
||||
|
||||
if( (bind(sock, (struct sockaddr *) &addr,sizeof(addr))) != 0)
|
||||
{
|
||||
sleep(60);
|
||||
if( (bind(sock, (struct sockaddr *) &addr,sizeof(addr))) != 0)
|
||||
{
|
||||
sprintf(buffer,"Cannot bind to socket %d",port);
|
||||
perror(buffer);
|
||||
fprintf(stderr,"Wait for one minute and try again\n");
|
||||
exit(errno);
|
||||
}
|
||||
}
|
||||
listen(sock, QUEUESIZE);
|
||||
|
||||
newsock=accept(sock, (struct sockaddr*) &caddr, &caddrlen);
|
||||
|
||||
for(;;) {
|
||||
|
||||
FD_ZERO(&readfds);
|
||||
|
||||
if (newsock != -1) {
|
||||
FD_SET(newsock, &readfds);
|
||||
width = newsock + 1;
|
||||
} else {
|
||||
FD_SET(sock, &readfds);
|
||||
width = sock + 1;
|
||||
}
|
||||
|
||||
WaitTime.tv_sec = 3;
|
||||
WaitTime.tv_usec = 0;
|
||||
ret=select(width,(fd_set*) &readfds, (fd_set*)0, (fd_set*)0, &WaitTime);
|
||||
if (ret==-1)
|
||||
{
|
||||
if(newsock != -1)
|
||||
write(newsock,"03die",5);
|
||||
perror("select() error");
|
||||
exit(errno);
|
||||
}
|
||||
if (ret == 0)
|
||||
{
|
||||
/* test BSS connectivity here */
|
||||
time(&last_t);
|
||||
for (;j<nbsplus;j++)
|
||||
{
|
||||
/* keep the poll interval be within 2 seconds */
|
||||
if (curr_t-last_t >= 2L )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
sprintf(buffer,"ping -w 2 -i 1 -c 1 %s 2>/dev/null|grep time >>/dev/null",(bsplus[j]).ip);
|
||||
pingval=system(buffer);
|
||||
|
||||
if (pingval) /* if ping failed */
|
||||
{
|
||||
(bsplus[j]).no_of_unreachable++;
|
||||
|
||||
/*
|
||||
* Too many ping failure (approx. 60 sec)
|
||||
*/
|
||||
if ( (bsplus[j]).no_of_unreachable > 20 )
|
||||
{
|
||||
process_outgoing_msg(newsock, clr_str, j);
|
||||
(bsplus[j]).connected = 0;
|
||||
}
|
||||
}
|
||||
else /* if ping succ */
|
||||
{
|
||||
(bsplus[j]).no_of_unreachable=0;
|
||||
|
||||
process_outgoing_msg(newsock, "new", j);
|
||||
(bsplus[j]).connected = 1;
|
||||
}
|
||||
time(&curr_t);
|
||||
} /* end_of_for */
|
||||
if (j>=nbsplus)
|
||||
j=0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (FD_ISSET(sock, &readfds))
|
||||
{
|
||||
if (newsock==-1)
|
||||
{
|
||||
newsock=accept(sock, (struct sockaddr*) &caddr, &caddrlen);
|
||||
width = newsock + 1;
|
||||
}
|
||||
}
|
||||
if (FD_ISSET(newsock, &readfds))
|
||||
{
|
||||
nread = read(newsock, msgbuffer+nlast, 2-nlast);
|
||||
|
||||
if (nread<=0) {
|
||||
FD_CLR(newsock, &readfds);
|
||||
|
||||
close(newsock);
|
||||
newsock=-1;
|
||||
width = sock + 1;
|
||||
for (i=0;i<nbsplus;i++)
|
||||
init_connection(&bsplus[i]);
|
||||
nbsplus=0;
|
||||
}
|
||||
else if (nread < 2-nlast) /* Message partly read */
|
||||
{
|
||||
nlast += nread;
|
||||
fprintf(stderr,"Read header failed\n");
|
||||
}
|
||||
else if (nread == 2-nlast)
|
||||
{
|
||||
nlast = 0;
|
||||
if (!isdigit(msgbuffer[0]) || !isdigit(msgbuffer[1]) )
|
||||
continue;
|
||||
|
||||
msgbuffer[2]='\0';
|
||||
msglen=atoi(msgbuffer);
|
||||
nread = read(newsock, msgbuffer, msglen);
|
||||
if ( nread == msglen )
|
||||
{
|
||||
msgbuffer[msglen]='\0';
|
||||
process_incoming_msg(msgbuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"Wrong header length %d\n",msglen);
|
||||
}
|
||||
}
|
||||
else /* Message read error */
|
||||
{
|
||||
fprintf(stderr,"Read header failed\n");
|
||||
}
|
||||
} /* End_of_if (FD_ISSET */
|
||||
} /* End_of_for(;;) */
|
||||
}
|
||||
|
||||
void setup_daemon(void)
|
||||
{
|
||||
/*
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
close(i);
|
||||
}
|
||||
*/
|
||||
switch (fork()) {
|
||||
case -1:
|
||||
perror("setup_daemon(), 1st fork()");
|
||||
exit(2);
|
||||
default:
|
||||
exit(0);
|
||||
case 0:
|
||||
if (setsid() == -1) {
|
||||
perror("setup_daemon(), setsid()");
|
||||
exit(3);
|
||||
}
|
||||
switch (fork()) {
|
||||
case -1:
|
||||
perror("setup_daemon(), 2nd fork()");
|
||||
exit(3);
|
||||
default:
|
||||
exit(0);
|
||||
case 0:
|
||||
umask(0);
|
||||
/* and return with daemon set up */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
500
src/configMgr/c_program/impmod/bss_hb.c
Normal file
500
src/configMgr/c_program/impmod/bss_hb.c
Normal file
@@ -0,0 +1,500 @@
|
||||
/* Title: bss_hb.cpp
|
||||
* Description: init and refresh BSS(BSC+BTS) status.
|
||||
* Author: Steven Wong
|
||||
* Date: 2001/09/24
|
||||
* Modified by: CTC
|
||||
*/
|
||||
|
||||
#include "bss_hb.h"
|
||||
|
||||
/*
|
||||
* UDP socket variable
|
||||
*/
|
||||
#define HEARTBEAT_PORT 4957 //snmp
|
||||
//#define BROADCAST_IP "155.226.202.63"
|
||||
char OMC_0_IP[16];
|
||||
char OMC_1_IP[16];
|
||||
|
||||
MYSQL omcDbConn,*omcDb_sock;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
char sqlstring[128];
|
||||
|
||||
static int udp_sockfd;
|
||||
static struct sockaddr_in udp_cli_addr;
|
||||
static struct sockaddr_in udp_serv_addr;
|
||||
|
||||
static BYTE sendbuf[SNMP_MSG_LEN];
|
||||
|
||||
static tHeartbeat bsc_heartbeat[NO_OF_BSS];
|
||||
static tHeartbeat bts_heartbeat[NO_OF_BSS*NO_OF_BTSMgr];
|
||||
|
||||
struct tBssLed bts_led[NO_OF_BSS*NO_OF_BTSMgr];
|
||||
struct tBssLed bsc_led[NO_OF_BSS];
|
||||
|
||||
static char snmphead[SNMP_HEADER_LEN] = {
|
||||
0x30, VAR, /* length 1 (1) */
|
||||
0x02, 0x01, 0x01, 0x04, 0x06, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63,0xa7,
|
||||
VAR, /* length 2 (14) */
|
||||
0x02, 0x01, 0x8e, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x30,
|
||||
VAR, /* length 3 (25) */
|
||||
0x30, VAR, /* length 4 (27) */
|
||||
0x06, OBJID_LEN, /* OBJID_LEN:(29) */
|
||||
0x2b, 0x06, 0x01, 0x04, 0x01,
|
||||
0x8a, 0x5d, 0x01, 0x05, VAR, 0x01,0x00, /* oid offset (39)*/
|
||||
0x04, VAR /* value length(43) */
|
||||
};
|
||||
|
||||
/*
|
||||
* Return the index for LED display.
|
||||
* signal_element is defined according to OMCR_BSSTREE MySQL table
|
||||
* return -1 if error
|
||||
*
|
||||
* LED assignment:
|
||||
* ________________________________________________________________________________________
|
||||
* LED:[0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |10 |11 |12 |13 |14 |15 ]
|
||||
* BTS --> [IWP|S1E1|TRX2|TRX3|TRX4|TRX5|TRX6|TRX7|TRX8|TRX9 |TRX10 |TRX11|TRX12|TRX13|ABIS | ]
|
||||
* BSC --> [IWP|S1E1|S2E1|S3E1|S4E1|S5E1|S6E1|S7E1|S8E1|S9E1 |S10E1 |S11E1|S12E1|S13E1|S14E1|S15E1]
|
||||
*/
|
||||
int object2LedId(int btsid,int signal_element)
|
||||
{
|
||||
int led_index;
|
||||
|
||||
if (btsid!=99)//BTS
|
||||
{
|
||||
switch (signal_element)
|
||||
{
|
||||
case 0: // IWP
|
||||
led_index = 0;break;
|
||||
case 10: // Slot1 E1
|
||||
led_index = 1;break;
|
||||
case 20: // TRX 2
|
||||
led_index = 2;break;
|
||||
case 30: // TRX 3
|
||||
led_index = 3;break;
|
||||
case 40: // TRX 4
|
||||
led_index = 4;break;
|
||||
case 50: // TRX 5
|
||||
led_index = 5;break;
|
||||
case 60: // TRX 6
|
||||
led_index = 6;break;
|
||||
case 70: // TRX 7
|
||||
led_index = 7;break;
|
||||
case 80: // TRX 8
|
||||
led_index = 8;break;
|
||||
case 90: // TRX 9
|
||||
led_index = 9;break;
|
||||
case 100: // TRX 10
|
||||
led_index = 10;break;
|
||||
case 110: // TRX 11
|
||||
led_index = 11;break;
|
||||
case 120: // TRX 12
|
||||
led_index = 12;break;
|
||||
case 130: // TRX 13
|
||||
led_index = 13;break;
|
||||
case 11: // AbisMgr
|
||||
led_index = 14;break;
|
||||
default:
|
||||
led_index = -1;break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (signal_element)
|
||||
{
|
||||
case 0: // IWP
|
||||
led_index = 0;break;
|
||||
case 10: // Slot1 E1
|
||||
led_index = 1;break;
|
||||
case 20: // Slot2 E1
|
||||
led_index = 2;break;
|
||||
case 30: // Slot3 E1
|
||||
led_index = 3;break;
|
||||
case 40: // Slot4 E1
|
||||
led_index = 4;break;
|
||||
case 50: // Slot5 E1
|
||||
led_index = 5;break;
|
||||
case 60: // Slot6 E1
|
||||
led_index = 6;break;
|
||||
case 70: // Slot7 E1
|
||||
led_index = 7;break;
|
||||
case 80: // Slot8 E1
|
||||
led_index = 8;break;
|
||||
case 90: // Slot9 E1
|
||||
led_index = 9;break;
|
||||
case 100: // Slot10 E1
|
||||
led_index = 10;break;
|
||||
case 110: // Slot11 E1
|
||||
led_index = 11;break;
|
||||
case 120: // Slot12 E1
|
||||
led_index = 12;break;
|
||||
case 130: // Slot13 E1
|
||||
led_index = 13;break;
|
||||
case 140: // Slot14 E1
|
||||
led_index = 14;break;
|
||||
case 150: // Slot15 E1
|
||||
led_index = 15;break;
|
||||
default:
|
||||
led_index = -1;break;
|
||||
}
|
||||
}
|
||||
return led_index;
|
||||
}
|
||||
void initOmcDbConn()
|
||||
{
|
||||
mysql_init(&omcDbConn);
|
||||
omcDb_sock=mysql_real_connect(&omcDbConn,NULL,"application","noitacilpPA#68*","OMC_PUB",0,NULL,0);
|
||||
if (omcDb_sock == 0)
|
||||
exit(6);
|
||||
}
|
||||
|
||||
void initHeartbeatStruct(tHeartbeat *heartbeat)
|
||||
{
|
||||
int i;
|
||||
|
||||
heartbeat->system_id=0;
|
||||
heartbeat->timestamp=0;
|
||||
for (i=0; i<HB_LED_CONTROL_LEN; i++)
|
||||
{
|
||||
heartbeat->led_control[i]=0;
|
||||
}
|
||||
heartbeat->component_id=0;
|
||||
heartbeat->alarmlevel=0;
|
||||
heartbeat->alarmcode=0;
|
||||
heartbeat->reserved=0;
|
||||
for (i=0; i<HB_EXTENDED_LEN; i++)
|
||||
{
|
||||
heartbeat->extended[i]=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//set which was is install and set all is ok
|
||||
void initBssStatusTransmitter(void)
|
||||
{
|
||||
int i,j;
|
||||
int on;
|
||||
bzero((char *) &udp_serv_addr, sizeof(udp_serv_addr));
|
||||
udp_serv_addr.sin_family = AF_INET;
|
||||
//udp_serv_addr.sin_addr.s_addr = inet_addr(BROADCAST_IP);
|
||||
udp_serv_addr.sin_port = htons(HEARTBEAT_PORT);
|
||||
|
||||
|
||||
if ((udp_sockfd = socket (AF_INET, SOCK_DGRAM, 0)) < 0 )
|
||||
{
|
||||
exit (errno);
|
||||
}
|
||||
|
||||
bzero((char *) &udp_cli_addr, sizeof(udp_cli_addr));
|
||||
udp_cli_addr.sin_family = AF_INET;
|
||||
udp_cli_addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
udp_cli_addr.sin_port = htons(0);
|
||||
|
||||
if (setsockopt(udp_sockfd, SOL_SOCKET, SO_RCVBUF, sendbuf, SNMP_MSG_LEN) < 0)
|
||||
{
|
||||
perror("setsockopt\n");
|
||||
}
|
||||
on=1;
|
||||
|
||||
if (setsockopt(udp_sockfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0)
|
||||
{
|
||||
perror("setsockopt\n");
|
||||
}
|
||||
if (fcntl(udp_sockfd, F_SETFL,O_NONBLOCK)<0)
|
||||
{
|
||||
perror("fcntl()\n");
|
||||
}
|
||||
if (setsockopt(udp_sockfd, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on)) < 0)
|
||||
{
|
||||
perror("setsockopt\n");
|
||||
}
|
||||
|
||||
|
||||
if (bind(udp_sockfd, (struct sockaddr *) &udp_cli_addr, sizeof(udp_cli_addr)) < 0)
|
||||
{
|
||||
|
||||
exit (errno);
|
||||
}
|
||||
|
||||
for (i=0; i<NO_OF_BSS; i++)
|
||||
{
|
||||
initHeartbeatStruct(&(bsc_heartbeat[i]));
|
||||
for (j=0; j<NO_OF_BTSMgr; j++)
|
||||
{
|
||||
initHeartbeatStruct(&(bts_heartbeat[NO_OF_BTSMgr*i+j]));
|
||||
}
|
||||
}
|
||||
initOmcDbConn();
|
||||
} //end of function initBscStatus()
|
||||
|
||||
|
||||
/*
|
||||
* 0xFF is group alarm clear (refer to Meng XZ's heartbeat format document
|
||||
*/
|
||||
void format_alarmcode(int *alarmcode)
|
||||
{
|
||||
|
||||
*alarmcode=0; // set it to zero anyway as it is not processed by TS_OMC
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* alarm level = component type + ID
|
||||
* For example: E1port.0.1.1,
|
||||
*
|
||||
* 0x4 -> E1
|
||||
* 0x5 -> TRX
|
||||
* 0x6 -> Clock
|
||||
* 0x7 -> Shelf
|
||||
* 0x8 -> Software
|
||||
* 0x9 -> Environment
|
||||
* 0xa -> Lapd
|
||||
* 0xb -> Bts
|
||||
* 0xc -> Bsc
|
||||
* 0xd -> Aif
|
||||
* 0xe -> Bbu
|
||||
* 0xf -> Rfd
|
||||
*
|
||||
*/
|
||||
void format_alarmlevel(int *alarmlevel)
|
||||
{
|
||||
*alarmlevel=0; // set it to zero anyway as it is not processed by TS_OMC
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void send_heartbeat(int index, struct tBssLed *pbsc_led,struct tBssLed *pbts_led, int component_id, int alarmcode, int alarmlevel,int bsType)
|
||||
{
|
||||
int retval,i,offset;
|
||||
tHeartbeat *pHeartbeat;
|
||||
BYTE *psendbuf;
|
||||
int bts_code;
|
||||
int bsc_code;
|
||||
char tmpHb[256];
|
||||
|
||||
int bssid = index / NO_OF_BTSMgr;
|
||||
int btsid = index % NO_OF_BTSMgr;
|
||||
|
||||
time_t unix_time;
|
||||
|
||||
format_alarmcode(&alarmcode);
|
||||
format_alarmlevel(&alarmlevel);
|
||||
|
||||
sprintf(OMC_0_IP,"");
|
||||
sprintf(OMC_1_IP,"");
|
||||
sprintf(sqlstring, "select sysNo,ip FROM OMC_PUB.sysInfo WHERE sysTypeNo='0'");
|
||||
mysql_query(omcDb_sock, sqlstring);
|
||||
if(mysql_errno(omcDb_sock) > 0)
|
||||
{
|
||||
printf("\n Error number:%d", mysql_errno(omcDb_sock));
|
||||
printf("\n Description: %s", mysql_error(omcDb_sock));
|
||||
exit(16);
|
||||
}
|
||||
|
||||
result = mysql_use_result(omcDb_sock);
|
||||
while((row = mysql_fetch_row(result))){
|
||||
if(atoi(row[0])==0){
|
||||
sprintf(OMC_0_IP,row[1]);
|
||||
}else if(atoi(row[0])==1){
|
||||
sprintf(OMC_1_IP,row[1]);
|
||||
}
|
||||
}
|
||||
mysql_free_result(result);
|
||||
|
||||
/*
|
||||
* Insert the length field in SNMP header
|
||||
*/
|
||||
snmphead[LENGTH1] = SNMP_MSG_LEN - LENGTH1 - 1;
|
||||
snmphead[LENGTH2] = SNMP_MSG_LEN - LENGTH2 - 1;
|
||||
snmphead[LENGTH3] = SNMP_MSG_LEN - LENGTH3 - 1;
|
||||
snmphead[LENGTH4] = SNMP_MSG_LEN - LENGTH4 - 1;
|
||||
snmphead[VALUE_LEN] = SNMP_MSG_LEN - VALUE_LEN - 1;
|
||||
|
||||
|
||||
// BSC
|
||||
psendbuf = &sendbuf[0];
|
||||
snmphead[SNMP_OBJID] = BSC_OBJID;
|
||||
pHeartbeat = &(bsc_heartbeat[bssid]);
|
||||
|
||||
unix_time = time((time_t *)0);
|
||||
pHeartbeat->timestamp = ((unix_time & 0xff000000) >> 24)
|
||||
| ((unix_time & 0xff0000) >> 8)
|
||||
| ((unix_time & 0xff00) << 8)
|
||||
| ((unix_time & 0xff) << 24);
|
||||
|
||||
if(pbsc_led->led[0] != 0xf){ //installed
|
||||
|
||||
bsc_code = bssid*256;
|
||||
pHeartbeat->system_id = ((bsc_code & 0xff00) >> 8) | ((bsc_code & 0xff) << 8);
|
||||
|
||||
for(i=0;i<8;i++){
|
||||
pHeartbeat->led_control[i]=((pbsc_led->led[2*i] & 0x0f)<<4) | (pbsc_led->led[2*i+1] & 0x0f);
|
||||
}
|
||||
|
||||
/*
|
||||
pHeartbeat->component_id = component_id;
|
||||
pHeartbeat->alarmlevel = alarmlevel;
|
||||
pHeartbeat->alarmcode = alarmcode;
|
||||
*/
|
||||
|
||||
pHeartbeat->component_id = 0;
|
||||
pHeartbeat->alarmlevel = 0;
|
||||
pHeartbeat->alarmcode = 0;
|
||||
|
||||
/*
|
||||
* Copy message to message buffer
|
||||
*/
|
||||
offset = 0;
|
||||
//memcpy(psendbuf, snmphead, SNMP_HEADER_LEN);//snmp head
|
||||
//offset += SNMP_HEADER_LEN;
|
||||
memcpy(psendbuf+offset, &pHeartbeat->system_id,HB_SYSTEM_ID_LEN);//system id
|
||||
offset += HB_SYSTEM_ID_LEN;
|
||||
memcpy(psendbuf+offset, &pHeartbeat->timestamp,HB_TIMESTAMP_LEN);//time
|
||||
offset += HB_TIMESTAMP_LEN;
|
||||
memcpy(psendbuf+offset, pHeartbeat->led_control,HB_LED_CONTROL_LEN);//len control
|
||||
offset += HB_LED_CONTROL_LEN;
|
||||
memcpy(psendbuf+offset, &pHeartbeat->component_id,HB_COMPONENT_ID_LEN);//component id
|
||||
offset += HB_COMPONENT_ID_LEN;
|
||||
memcpy(psendbuf+offset, &pHeartbeat->alarmlevel,HB_ALARMLEVEL_LEN);//alarmlevel
|
||||
offset += HB_ALARMLEVEL_LEN;
|
||||
memcpy(psendbuf+offset, &pHeartbeat->alarmcode,HB_ALARMCODE_LEN);//alarmcode
|
||||
offset += HB_ALARMCODE_LEN;
|
||||
memcpy(psendbuf+offset, &pHeartbeat->reserved,HB_RESERVED_LEN);
|
||||
offset += HB_RESERVED_LEN;
|
||||
memcpy(psendbuf+offset, pHeartbeat->extended,HB_EXTENDED_LEN);
|
||||
|
||||
omc_RbcdToAscii(tmpHb, sendbuf, (offset + HB_EXTENDED_LEN)*2);
|
||||
sprintf(sqlstring, "REPLACE INTO sysStat SET sysTypeNo='510',sysNo=%d,subSysNo='0',detailStat='%s',updateTime=CURRENT_TIMESTAMP",
|
||||
bssid,tmpHb);
|
||||
mysql_query(omcDb_sock, sqlstring);
|
||||
/*if(strlen(OMC_0_IP)>0){
|
||||
udp_serv_addr.sin_addr.s_addr = inet_addr(OMC_0_IP);
|
||||
retval = sendto(udp_sockfd, sendbuf, SNMP_MSG_LEN, 0,
|
||||
(const struct sockaddr *)&udp_serv_addr, sizeof(udp_serv_addr));
|
||||
//printf("Bsc heartbeat is sent~~~~~~~~~~~~~~~~\n\n");
|
||||
}
|
||||
|
||||
if(strlen(OMC_1_IP)>0){
|
||||
udp_serv_addr.sin_addr.s_addr = inet_addr(OMC_1_IP);
|
||||
retval = sendto(udp_sockfd, sendbuf, SNMP_MSG_LEN, 0,
|
||||
(const struct sockaddr *)&udp_serv_addr, sizeof(udp_serv_addr));
|
||||
//printf("Bsc_hb LEN=%d:",retval);
|
||||
|
||||
}*/
|
||||
//for ( n=0;n<SNMP_MSG_LEN;n++)
|
||||
// printf("%x ",(int) sendbuf[n]);
|
||||
//printf("\n");
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
perror("BSS <Bsc> heartbeat send fail!\n");
|
||||
}
|
||||
|
||||
}//end of if(installed)
|
||||
|
||||
|
||||
//check the device is BSC+BTS or BS+
|
||||
if(btsid==0&&bsType==0){
|
||||
return;
|
||||
}
|
||||
|
||||
psendbuf = &sendbuf[0];
|
||||
snmphead[SNMP_OBJID] = BTS_OBJID;
|
||||
|
||||
pHeartbeat = &(bts_heartbeat[btsid]);
|
||||
|
||||
//bts_code=bssid*256 + btsid - 1;
|
||||
bts_code=bssid*256 + btsid;
|
||||
pHeartbeat->system_id = ((bts_code & 0xff00) >> 8) | ((bts_code & 0xff) << 8);
|
||||
|
||||
unix_time = time((time_t *)0);
|
||||
pHeartbeat->timestamp = ((unix_time & 0xff000000) >> 24)
|
||||
| ((unix_time & 0xff0000) >> 8)
|
||||
| ((unix_time & 0xff00) << 8)
|
||||
| ((unix_time & 0xff) << 24);
|
||||
for(i=0;i<8;i++){
|
||||
pHeartbeat->led_control[i]=((pbts_led->led[2*i] & 0x0f)<<4) | (pbts_led->led[2*i+1] & 0x0f);
|
||||
}
|
||||
|
||||
/*
|
||||
pHeartbeat->component_id = component_id;
|
||||
pHeartbeat->alarmlevel = alarmlevel;
|
||||
pHeartbeat->alarmcode = alarmcode;
|
||||
*/
|
||||
pHeartbeat->component_id = 0;
|
||||
pHeartbeat->alarmlevel = 0;
|
||||
pHeartbeat->alarmcode = 0;
|
||||
|
||||
/*
|
||||
* Copy message to message buffer
|
||||
*/
|
||||
//memcpy(psendbuf, snmphead, SNMP_HEADER_LEN);
|
||||
//psendbuf += SNMP_HEADER_LEN;
|
||||
memcpy(psendbuf, &pHeartbeat->system_id,HB_SYSTEM_ID_LEN);
|
||||
psendbuf += HB_SYSTEM_ID_LEN;
|
||||
memcpy(psendbuf, &pHeartbeat->timestamp,HB_TIMESTAMP_LEN);
|
||||
psendbuf += HB_TIMESTAMP_LEN;
|
||||
memcpy(psendbuf, pHeartbeat->led_control,HB_LED_CONTROL_LEN);
|
||||
psendbuf += HB_LED_CONTROL_LEN;
|
||||
memcpy(psendbuf, &pHeartbeat->component_id,HB_COMPONENT_ID_LEN);
|
||||
psendbuf += HB_COMPONENT_ID_LEN;
|
||||
memcpy(psendbuf, &pHeartbeat->alarmlevel,HB_ALARMLEVEL_LEN);
|
||||
psendbuf += HB_ALARMLEVEL_LEN;
|
||||
memcpy(psendbuf, &pHeartbeat->alarmcode,HB_ALARMCODE_LEN);
|
||||
psendbuf += HB_ALARMCODE_LEN;
|
||||
memcpy(psendbuf, &pHeartbeat->reserved,HB_RESERVED_LEN);
|
||||
psendbuf += HB_RESERVED_LEN;
|
||||
memcpy(psendbuf, pHeartbeat->extended,HB_EXTENDED_LEN);
|
||||
|
||||
omc_RbcdToAscii(tmpHb, sendbuf, (psendbuf - sendbuf+ HB_EXTENDED_LEN)*2);
|
||||
sprintf(sqlstring, "REPLACE INTO sysStat SET sysTypeNo='520',sysNo=%d,subSysNo='%d',detailStat='%s',updateTime=CURRENT_TIMESTAMP",
|
||||
bssid,btsid,tmpHb);
|
||||
//printf("sqlstring=%s\n",sqlstring);
|
||||
mysql_query(omcDb_sock, sqlstring);
|
||||
|
||||
/* if(strlen(OMC_0_IP)>0){
|
||||
udp_serv_addr.sin_addr.s_addr = inet_addr(OMC_0_IP);
|
||||
retval = sendto(udp_sockfd, sendbuf, SNMP_MSG_LEN, 0,
|
||||
(const struct sockaddr *)&udp_serv_addr, sizeof(udp_serv_addr));
|
||||
}
|
||||
if(strlen(OMC_1_IP)>0){
|
||||
udp_serv_addr.sin_addr.s_addr = inet_addr(OMC_1_IP);
|
||||
retval = sendto(udp_sockfd, sendbuf, SNMP_MSG_LEN, 0,
|
||||
(const struct sockaddr *)&udp_serv_addr, sizeof(udp_serv_addr));
|
||||
//printf("\33[36m\nBts heartbeat is sent!!!!!!!!!!!!!!!!!!!\n\n");
|
||||
//printf("Bts_hb LEN=%d:",retval);
|
||||
}*/
|
||||
// for (n=0;n<SNMP_MSG_LEN;n++)
|
||||
// printf("%x ",(int) sendbuf[n]);
|
||||
// printf("\n\n");
|
||||
if (retval < 0)
|
||||
{
|
||||
perror("BSS <Bts> heartbeat send fail!\n");
|
||||
}
|
||||
|
||||
}//end of function
|
||||
|
||||
void clearBssStatus(void)
|
||||
{
|
||||
close(udp_sockfd);
|
||||
}
|
||||
|
||||
void omc_RbcdToAscii(char *ascii_buf, const unsigned char *bcd_buf,
|
||||
int len)
|
||||
{
|
||||
int i;
|
||||
char ch;
|
||||
//if(sizeof(*ascii_buf) < len*2){
|
||||
// len = sizeof(*ascii_buf)/2;
|
||||
//}
|
||||
for (i = 0; i < len; i++) {
|
||||
if ((len - i) & 1) {
|
||||
ch = *(bcd_buf++) & 0x0f;
|
||||
} else {
|
||||
//ch = (*bcd_buf & 0xf0) >> 4;
|
||||
ch = *bcd_buf >> 4;
|
||||
}
|
||||
ascii_buf[i] = ch + ((ch > 9) ? 'A' - 10 : '0');
|
||||
}
|
||||
ascii_buf[i] = '\0';
|
||||
}
|
||||
140
src/configMgr/c_program/impmod/bss_hb.h
Normal file
140
src/configMgr/c_program/impmod/bss_hb.h
Normal file
@@ -0,0 +1,140 @@
|
||||
#ifndef __BSS_HB_H__
|
||||
#define __BSS_HB_H__
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "mysql.h"
|
||||
#include "iwtypes.h"
|
||||
#include "includes.h"
|
||||
|
||||
#define BSC_BASE 9*1024
|
||||
#define BTS_BASE 10*1024
|
||||
|
||||
#define BSC_OBJID 0x01
|
||||
#define BTS_OBJID 0x02
|
||||
#define OBJID_LEN 0x0C
|
||||
#define VAR 0xff
|
||||
|
||||
#define SNMP_HEADER_LEN 44
|
||||
|
||||
#define LENGTH1 1
|
||||
#define LENGTH2 14
|
||||
#define LENGTH3 25
|
||||
#define LENGTH4 27
|
||||
#define SNMP_OBJID 39
|
||||
#define VALUE_LEN 43
|
||||
/*
|
||||
* System Type in heartbeat information
|
||||
*/
|
||||
#define BSC 9
|
||||
#define BTS 10
|
||||
|
||||
#define NO_OF_BSS 12
|
||||
#define NO_OF_BTSMgr 13
|
||||
/*
|
||||
* Heartbeat message field length
|
||||
*/
|
||||
#define HB_SYSTEM_ID_LEN 2
|
||||
#define HB_TIMESTAMP_LEN 4
|
||||
#define HB_LED_CONTROL_LEN 8
|
||||
#define HB_COMPONENT_ID_LEN 1
|
||||
#define HB_ALARMLEVEL_LEN 1
|
||||
#define HB_ALARMCODE_LEN 1
|
||||
#define HB_RESERVED_LEN 1
|
||||
#define HB_EXTENDED_LEN 48
|
||||
|
||||
#define HB_BODY_LEN ( HB_SYSTEM_ID_LEN + HB_TIMESTAMP_LEN \
|
||||
+ HB_LED_CONTROL_LEN + HB_COMPONENT_ID_LEN \
|
||||
+ HB_ALARMLEVEL_LEN + HB_ALARMCODE_LEN \
|
||||
+ HB_RESERVED_LEN + HB_EXTENDED_LEN )
|
||||
|
||||
#define SNMP_MSG_LEN (SNMP_HEADER_LEN + HB_BODY_LEN)
|
||||
#define HB_NO_OF_LED HB_LED_CONTROL_LEN * 2
|
||||
|
||||
#define def_sql_length 16384
|
||||
|
||||
/****************************************
|
||||
* BSS LED struct
|
||||
* Max 12 BSC and 12x12 BTS = 156 units
|
||||
****************************************/
|
||||
struct tBssLed
|
||||
{
|
||||
bool presence;
|
||||
int led[HB_NO_OF_LED];
|
||||
int component_id;
|
||||
int alarmcode;
|
||||
int alarmlevel;
|
||||
};
|
||||
//define the structure that store status info
|
||||
typedef struct _tHeartbeat
|
||||
{
|
||||
int system_id; /* 0-512 */
|
||||
time_t timestamp; /* 32-bit timestamp */
|
||||
BYTE led_control[HB_LED_CONTROL_LEN]; /* 16 LED, 4-bit per LED */
|
||||
/* 0 - off */
|
||||
/* 1 - green */
|
||||
/* 2 - red */
|
||||
/* 3 - blue */
|
||||
/* 4 - yellow */
|
||||
/* 5 - ambra */
|
||||
/* 6 - white */
|
||||
/* 7 - not in use */
|
||||
int component_id;
|
||||
int alarmlevel;
|
||||
int alarmcode;
|
||||
int reserved;
|
||||
BYTE extended[HB_EXTENDED_LEN]; /* application defined */
|
||||
} tHeartbeat;
|
||||
|
||||
/*
|
||||
* index = BSSID * NO_OF_BTSMgr + BTSMGR_ID
|
||||
* e.g. BSC01 -> system_id = 13
|
||||
* BTS3 of BSC01 -> system_id = 1*13+3 = 16
|
||||
*
|
||||
* Heartbeat format:
|
||||
*
|
||||
* byte 0-1: system id
|
||||
* 0 :000-003 OMC
|
||||
* 4 :004-007 HLR
|
||||
* 8 :008-00B PPS
|
||||
* 12 :00C-00F CDR
|
||||
* 16 :010-013 SMS
|
||||
* ... ... ...
|
||||
* 100:064-077 VPS
|
||||
* 120:078-0B7 CSU
|
||||
* 184:0B8-0CF BSC
|
||||
* 208:0D0-1EF BTS
|
||||
*
|
||||
* byte 2-5: timestamp (4 bytes)
|
||||
* byte 6-13: 16 led code
|
||||
* bit 3: 1=continuous, 0=blinking
|
||||
* bit 2-0: 0=off,1=green,2=yellow,3=red,4=blue,5=umbra,6=white,7=not in use
|
||||
* byte 14: Component ID (need further defined)
|
||||
* byte 15: alarm level (00 normal, 01 critical, 02 major)
|
||||
* byte 16: alarm code
|
||||
* 0 normal, 1-255 alarmcode,
|
||||
* 254(0FEH) reserved for device timeout
|
||||
* 255(0FFH) group alarm clear
|
||||
* byte 17: reserved
|
||||
* byte 18-65: extended status (not used by BSS OMC)
|
||||
*/
|
||||
#define LED_OFF (0x8)
|
||||
#define LED_GREEN (0x8 | 1)
|
||||
#define LED_YELLOW (0x8 | 2)
|
||||
#define LED_RED (0x8 | 3)
|
||||
#define LED_BLUE (0x8 | 4)
|
||||
#define LED_UMBRA (0x8 | 5)
|
||||
#define LED_WHITE (0x8 | 6)
|
||||
#define LED_NOT_IN_USE (0x8 | 7)
|
||||
|
||||
extern void initBssStatusTransmitter(void);
|
||||
extern void updateBssStatus(MYSQL *mysql_sock, int led_num, int color_ctrl);
|
||||
extern void send_heartbeat(int index, struct tBssLed *pbsc_led,struct tBssLed *pbts_led, int component_id, int alarmcode, int alarmlevel,int bsType);
|
||||
extern void clearBssStatus(void);
|
||||
extern int object2LedId(int btsid,int signal_element);
|
||||
extern struct tBssLed bts_led[NO_OF_BSS*NO_OF_BTSMgr];
|
||||
extern struct tBssLed bsc_led[NO_OF_BSS];
|
||||
|
||||
#endif /* __BSS_HB_H__ */
|
||||
4618
src/configMgr/c_program/impmod/bsscomm.c
Normal file
4618
src/configMgr/c_program/impmod/bsscomm.c
Normal file
File diff suppressed because it is too large
Load Diff
358
src/configMgr/c_program/impmod/bsscomm.h
Normal file
358
src/configMgr/c_program/impmod/bsscomm.h
Normal file
@@ -0,0 +1,358 @@
|
||||
#ifndef BSSCOMM__H
|
||||
#define BSSCOMM__H
|
||||
/*******************************************************************
|
||||
|
||||
Usage: Interwave network Management Protocol(IMP) interface for BSS OMC
|
||||
|
||||
Interface function:
|
||||
{1}imp_init() -> init IMP interface for BSS OMC
|
||||
Step 0: init MySQL database (BssOmcDb)
|
||||
->connectDB();
|
||||
->initOMCR_COMMANDTable();
|
||||
->GetBssMaxConfigFromDB();
|
||||
->GetAllTableName();
|
||||
Step 1: init ImpConn structure
|
||||
Step 2: set CmdBuffer[CMD_BUFFER_SIZE] structure is available
|
||||
Step 3: get bssid,ip from MySQL database which has been added by BSS OMC operator
|
||||
->SELECT bssid,ip,name,uploaded FROM OMCR_BSSTABLE WHERE ip<>'';
|
||||
->AddImpConn(): put pBssConn->(bssid,ip..) to bsplus_down[]
|
||||
Step 4: Synchronize the OMCR_BSSTREE.MaxSeverity with OMCR_ALARMEVENT at startup
|
||||
->syncBssTreeAlarm()
|
||||
Step 5: init BssStatus Transmitter
|
||||
->initBssStatusTransmitter():check BSS OMC(hb_port.4957) is ok and initHeartbeatStruct()
|
||||
|
||||
{2}imp_timer()-> Call ImpConnMultiplexer() to Maintain a IMP connection with all the manageable iwbox
|
||||
Part 0: connect with BSS
|
||||
Part 1: if BSS start ,upload from BSS
|
||||
Part 2: if receive no event,
|
||||
->retrieveCmdFromDatabase()
|
||||
->ProcessUserCommand(tImpConn *pBssConn, char *pCommandString, u32 TransId)
|
||||
->DispatchNmiCommand(pBssConn):Send 1 command to each BSS in one cycle if queue is not empty
|
||||
Part 3: if receive imp message,
|
||||
Step 0: Copy previous buffer content into present buffer
|
||||
Step 1: Read IMP Length Header
|
||||
Step 2: Read the remaining IMP message
|
||||
Step 3: Whole message has been read
|
||||
Step 4: Process imp message
|
||||
State 1:(if event)ProcessEventMsg(),according eventname
|
||||
"FailureReport" ->update_alarmevent_table
|
||||
"BtsMeasurements" ->update_BtsMeas_table
|
||||
"tstComplete" ->update_bootup_time
|
||||
"CardCreated" ->update_cardcreated_event
|
||||
"TrxCreated" ->update_trxcreated_event
|
||||
"Cser"or"ACN" ->update_networkevent_table
|
||||
State 2: Decode IMP Response Message,according OperatorCode
|
||||
Create or Delete ->ProcessCreateDeleteBody ->requestObjCfg
|
||||
Contents ->ProcessContentsBody
|
||||
Set or Get ->ProcessSetGetBody ->updateBssCfg
|
||||
Action ->ProcessActionBody
|
||||
Bsplus monitoring server:
|
||||
--------- ---------
|
||||
| bsscomm | | monitor |
|
||||
--------- ---------
|
||||
add
|
||||
tell monitor program according to the bsplus ip ping
|
||||
the bsplus ip/bssid list ---------------> Test connection with BSS ------------> BSS
|
||||
|
||||
new
|
||||
Calling:restoreBssConn()
|
||||
Try to restore connection <--------------- if ping successful
|
||||
If reconnect,put the
|
||||
connection in bsplus[]
|
||||
|
||||
clr
|
||||
Calling:ClearBssConn() <--------------- if ping fail(fail count >20)
|
||||
TCP connnection lost
|
||||
Move bsplus[i] to bsplus_down[]
|
||||
|
||||
|
||||
Code file list:
|
||||
|
||||
bsscomm.c,bsscomm.h: IMP(interWave Network Mannagement) interface for BSS OMC
|
||||
nmimp.c ,nmimp.h : Methods for IMP data marshaling/unmarshaling.
|
||||
nmtypes.c,nmtypes.h: Definitions of fundamental data types.
|
||||
bss_hb.c ,bss_hb.h : init and refresh BSS(BSC+BTS) status.
|
||||
alive.c monitoring the connection between Bsscomm and BSS
|
||||
|
||||
Author:XChen
|
||||
Date: 2006-09-20
|
||||
********************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <signal.h>
|
||||
#include <ctype.h>
|
||||
#include "unistd.h"
|
||||
#include <errno.h>
|
||||
/*
|
||||
* Include ModImp header files here
|
||||
*/
|
||||
#include "iwtypes.h"
|
||||
#include "nmtypes.h"
|
||||
#include "nmstatus.h"
|
||||
#include "nmimp.h"
|
||||
/*
|
||||
* For ImpConnMultiplexer
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/time.h>
|
||||
#include <netdb.h>
|
||||
#include <time.h>
|
||||
/*
|
||||
* Max 12 BSC and 12x12 BTS
|
||||
*/
|
||||
#define NO_OF_BSS 12
|
||||
#define NO_OF_BTSMgr 13
|
||||
/*
|
||||
* MySQL connection
|
||||
*/
|
||||
#include "mysql.h"
|
||||
#define DB "BssOmcDb"
|
||||
#define USERNAME "application"
|
||||
#define PASSWD "noitacilpPA#68*"
|
||||
#define SQLSTRING_LEN 16384 // 16384 = 2^14
|
||||
|
||||
MYSQL mysql,*mysql_sock;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
//MYSQL_FIELD *field;
|
||||
char sqlstring[SQLSTRING_LEN];
|
||||
|
||||
/*
|
||||
* Store the name of MYSQL tablename at program startup
|
||||
*/
|
||||
#define MAX_NUM_OF_SQL_TABLE 100
|
||||
int num_of_mysql_table;
|
||||
char **mysql_tables;
|
||||
|
||||
#define NMIPORT 2112
|
||||
#define BUFMAX 4096
|
||||
#define MSG_BODY_SIZE 1024
|
||||
#define SILENT_CODE ((u32)0x0)
|
||||
#define WAIT_TIME 120
|
||||
#define MEASUREMENT_INTERVAL 15
|
||||
//#define BSSVERSION "iw06_00.028"
|
||||
/*
|
||||
* For BSS momitor
|
||||
*/
|
||||
#define MONITOR_PORT 5354
|
||||
int monitor_fd=-1;
|
||||
|
||||
#define TIME_LEN 9
|
||||
|
||||
#define ADD 1
|
||||
#define DEL 2
|
||||
#define CLR 3
|
||||
/*
|
||||
* For processing user command
|
||||
*/
|
||||
#define READ_CMD 0
|
||||
#define READ_OBJECT 1
|
||||
#define READ_PARMS 2
|
||||
#define READ_END 3
|
||||
|
||||
#define BSSERROR (-1)
|
||||
#define ACTION 0
|
||||
#define CONTENTS 1
|
||||
#define CREATE 2
|
||||
#define DELETE 3
|
||||
#define GET 4
|
||||
#define OID 5
|
||||
#define SET 6
|
||||
#define NEWBSS 7
|
||||
#define DROPBSS 8
|
||||
#define UPLOAD 9
|
||||
/*
|
||||
* For alarm management
|
||||
*/
|
||||
#define SV_CEASED 0
|
||||
#define SV_CRITICAL 1
|
||||
#define SV_MAJOR 2
|
||||
#define SV_MINOR 3
|
||||
#define SV_WARNING 4
|
||||
#define SV_INDETERMINATE 5
|
||||
#define MAXSEVERITY SV_MAJOR // The maxseverity in number of concern
|
||||
// You have to update alarmevent.php accordingly
|
||||
#define HEARTBEAT_INTERVAL 10L
|
||||
#define SELECT_INTERVAL 2L
|
||||
/*
|
||||
* keep track the command status after PHP put the command on DB
|
||||
*/
|
||||
#define CMD_NEW 255
|
||||
#define CMD_READ_FROM_DB 254
|
||||
#define CMD_END 0
|
||||
|
||||
#define CONNECTED_STATE_MAX 255
|
||||
|
||||
#define GET_READ_ATTRIB 1
|
||||
#define GET_ATTRIB_END 2
|
||||
|
||||
#define SET_READ_ATTRIB 1
|
||||
#define SET_READ_INT 2
|
||||
#define SET_READ_STRING 3
|
||||
#define SET_READ_INTARRAY 4
|
||||
#define SET_COMMAND_END 5
|
||||
#define SET_ATTRIB_END 6
|
||||
#define SET_INT_END 7
|
||||
#define SET_STRING_END 8
|
||||
#define SET_INTARRAY_END 9
|
||||
|
||||
#define BSSID_EXIST 1
|
||||
#define BSSID_TOO_BIG 2
|
||||
#define IP_EXIST 3
|
||||
|
||||
#define READ_BSSID 1
|
||||
#define READ_BSSID_END 2
|
||||
#define READ_IP 3
|
||||
#define READ_IP_END 4
|
||||
|
||||
#define ObjectIdMaxLevel 6
|
||||
/*
|
||||
* ImpConn structure definition
|
||||
* This stores the IMP connection from BSS
|
||||
*/
|
||||
struct ImpConn {
|
||||
int bssid; // initialize to -1
|
||||
char ip[16]; // initialize to 0.0.0.0
|
||||
char bssname[80]; // initialize to BSS_<bssid>
|
||||
int port; // initialize to -1
|
||||
int sockfd; // initialize to -1
|
||||
u32 SeqNum; // initialize to 0
|
||||
tOid TheOid; // initialize to OID_INIT
|
||||
tCID TheCid; // initialize to NM_CLASS_UNDEFINED
|
||||
struct queue *pCmdQ; // initialize to NULL
|
||||
struct queue *pCmdQEnd; // initialize to NULL
|
||||
int uploaded; // initialize to 0, already uploaded when = 1
|
||||
int connected;
|
||||
int download_in_progress; // initialize to 0, connected when >= 1
|
||||
int last_Total; // no of bytes read so far for an IMP packet
|
||||
u8 lastMsgRecvBuffer[IMP_MAX_HDR_LENGTH + MSG_BODY_SIZE];
|
||||
u32 bootupTime; // initialize to 0L
|
||||
u32 last_TransId; // TransId of the command in processing
|
||||
// initialize to 0 (=not in processing)
|
||||
int upload_in_progress; // initialize to 0
|
||||
int current_upload_level; // initialize to 1
|
||||
u32 upload_TransId;
|
||||
time_t last_connected_abnormal;
|
||||
time_t this_connected_abnormal;
|
||||
};
|
||||
typedef struct ImpConn tImpConn;
|
||||
|
||||
tImpConn *BssConn;
|
||||
tImpConn **bsplus;
|
||||
tImpConn **bsplus_down;
|
||||
/*
|
||||
* ImpEvent structure definition
|
||||
* This stores the IMP event from BSS
|
||||
*/
|
||||
#define EVENTINFO_ARRAY_SIZE 512
|
||||
#define MAX_OBJECTID_LEN 40
|
||||
struct ImpEvent {
|
||||
char eventname[40];
|
||||
char objectid[MAX_OBJECTID_LEN];
|
||||
char classname[40];
|
||||
char eventtime[25];
|
||||
unsigned long eventsecond; /* no of sec from 1 Jan 1970*/
|
||||
unsigned long globaleventnumber;
|
||||
unsigned int eventcause;
|
||||
char alarmlevel[10];
|
||||
char eventinfo[EVENTINFO_ARRAY_SIZE][512]; /* Array of Evt Msg Body */
|
||||
int eventinfosize; /* Array size */
|
||||
int eventtype;
|
||||
int severity;
|
||||
};
|
||||
typedef struct ImpEvent tImpEvent;
|
||||
tImpEvent BssEvent;
|
||||
/*
|
||||
* Use link list to maintain the queue of commands for each IMP connection
|
||||
* A shared buffer(array) is used to store the commands to different BSS
|
||||
* The command buffer is indexed from 0 to CMD_BUFFER_SIZE-1
|
||||
* CmdBufferPtr points to the first available command buffer
|
||||
*/
|
||||
#define CMD_BUFFER_SIZE 16000
|
||||
#define CMD_BUFFER_FULL (-1)
|
||||
#define CMD_SIZE 2048
|
||||
|
||||
struct queue { // A FIFO Queue
|
||||
char command[CMD_SIZE];
|
||||
struct queue *nextcmd;
|
||||
u32 TransId;
|
||||
bool available;
|
||||
};
|
||||
struct queue CmdBuffer[CMD_BUFFER_SIZE];
|
||||
int CmdBufferPtr=0;
|
||||
/*
|
||||
* Function declaration
|
||||
*/
|
||||
//init imp structure
|
||||
void initImpConn(tImpConn * pBssConn);
|
||||
void initImpEvent(tImpEvent *pBssEvent);
|
||||
void AddImpConn(int bssid, char *ipaddr, char *bssname, int uploaded);
|
||||
//init Bss MySQL database
|
||||
void connectDB();
|
||||
void initOMCR_COMMANDTable();
|
||||
void GetAllTableName();
|
||||
void GetBssMaxConfigFromDB();
|
||||
void syncBssTimeWithOMC(tImpConn *pBssConn, time_t tloc);
|
||||
void syncBssTreeAlarm();
|
||||
//connection management
|
||||
void restoreBssConn(int bssid, char *ip);
|
||||
void discBssConn(int bssid, char *ip, fd_set *readfds);
|
||||
void clearBssConn(tImpConn *pBssConn,fd_set *readfds);
|
||||
int connectIwBox(char *target, int port);
|
||||
|
||||
void stopIwBoxMonitor();
|
||||
void startIwBoxMonitor(char *hostname, int port);
|
||||
void InformIwBoxMonitor(tImpConn *pBssConn, int action);
|
||||
void GetMonitorResult(char *buffer, fd_set *readfds);
|
||||
|
||||
//get command
|
||||
void addCmd2Queue(tImpConn *pBssConn,char *nmicommand,long SeqNum);
|
||||
void retrieveCmdFromDatabase();
|
||||
bool FindAvailCmdBufferPtr();
|
||||
void DispatchNmiCommand(tImpConn *pBssConn);
|
||||
//process command and encode imp message
|
||||
int OidCommand(tImpConn * pBssConn,char *pImpCmdContName, u32 *pImpCmdIndex, ix ImpCmdIndexCount, u32 TransId);
|
||||
int GetCommand(tImpConn * pBssConn, char *pImpCmd, u32 TransId);
|
||||
int SetCommand(tImpConn * pBssConn, char *pImpCmd, u32 TransId);
|
||||
int ActionCommand(tImpConn *pBssConn, char *pImpCmdContName, u32 *pImpCmdIndex,ix ImpCmdIndexCount, u32 TransId);
|
||||
int CreateCommand(tImpConn * pBssConn, char *pImpCmdContName,u32 * pImpCmdIndex, u32 TransId);
|
||||
int DeleteCommand(tImpConn * pBssConn, char *pImpCmdContName,u32 * pImpCmdIndex, u32 TransId);
|
||||
int ContentsCommand(tImpConn *pBssConn, u32 TransId);
|
||||
int AddDropBsplusCommand(char *pImpCmd, int action, u32 TransId);//Calling NewBsplus,DropBsplus
|
||||
|
||||
int ProcessCommandString(char *pCommandString,char *pObjName, u32 *pParameter, int *count);//Calling CommandType
|
||||
int ProcessUserCommand(tImpConn *pBssConn, char *pCommandString, u32 TransId);
|
||||
//decode imp message
|
||||
unsigned int imp_response(tImpConn *pBssConn, tIMPHDR *pHeader,char *response);
|
||||
|
||||
static void ProcessContentsBody(u8** ppBuf, char *response);
|
||||
static void ProcessSetGetBody(tImpConn *pBssConn, u8** ppBuf, char *response,u16 *responsecode, bool HasStatus);
|
||||
static void ProcessActionBody(tImpConn *pBssConn, u8** ppBuf,char *response);
|
||||
static void ProcessCreateDeleteBody(u8** ppBuf,char *strValue, u16 *intValue);
|
||||
static void ProcessEventBody(tImpConn *pBssConn, u8** ppBuf,tImpEvent *pBssEvent);
|
||||
bool ProcessEventMsg(tImpConn *pBssConn, u8* pMsg, tImpEvent *pBssEvent);
|
||||
bool ProcessMessage(tImpConn *pBssConn, u8* pMsg, tIMPHDR *pHeader, fd_set *readfds);
|
||||
bool CheckForMessages(tImpConn *pBssConn, tIMPHDR *pHeader, fd_set *readfds, time_t last_heartbeat_time);
|
||||
|
||||
//according to imp response,update bss database
|
||||
unsigned int update_bsstable_status(tImpConn *pBssConn);
|
||||
unsigned int update_command_status(int resultcode, char *result,int responsecode, char *response, u32 TransId);
|
||||
unsigned int update_BtsMeas_table(char *buffer, tImpConn *pBssConn,tImpEvent *pBssEvent, long *cellid);
|
||||
unsigned int update_alarmevent_table(char *buffer, tImpConn *pBssConn, tImpEvent *pBssEvent, fd_set *readfds);
|
||||
unsigned int update_acn_cser_event(char *buffer, tImpConn *pBssConn,tImpEvent *pBssEvent);
|
||||
unsigned int update_cardcreated_event(tImpConn *pBssConn, tImpEvent *pBssEvent);
|
||||
unsigned int update_trxcreated_event(tImpConn *pBssConn, tImpEvent *pBssEvent);
|
||||
unsigned int update_networkevent_table(char *buffer, tImpConn *pBssConn,tImpEvent *pBssEvent);
|
||||
void update_bootup_time(tImpConn *pBssConn, tImpEvent *pBssEvent);
|
||||
|
||||
int requestObjCfg(tImpConn *pBssConn, char *objectid,int objectidLevel);
|
||||
int requestBssCfg(tImpConn *pBssConn);
|
||||
int requestBtsCfg(tImpConn *pBssConn, char *btsmgrid);
|
||||
int updateBssCfg(tImpConn *pBssConn, tIMPHDR *pHeader, char *response);
|
||||
int checkBsType(int bssid);
|
||||
//unsigned int generateBtsStatReport();
|
||||
#endif /*BSSCOMM__H */
|
||||
90
src/configMgr/c_program/impmod/includes.h
Normal file
90
src/configMgr/c_program/impmod/includes.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Include all header files needed by shared memory project.
|
||||
* Created by Huang QL, 2315/12/12
|
||||
*/
|
||||
|
||||
#ifndef INCLUDES__H
|
||||
#define INCLUDES__H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/sem.h>
|
||||
#include <signal.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <termio.h>
|
||||
#include <syslog.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/param.h>
|
||||
#include <mntent.h>
|
||||
#include <fstab.h>
|
||||
#include <sys/statvfs.h>
|
||||
#include <linux/hdreg.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 BOOL
|
||||
typedef unsigned short 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 1024
|
||||
#define MAXBUFLEN 8196
|
||||
|
||||
#define UNDER_DEVELOP YES
|
||||
#endif
|
||||
41
src/configMgr/c_program/impmod/iwtypes.h
Normal file
41
src/configMgr/c_program/impmod/iwtypes.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef _IWTYPES_H_
|
||||
#define _IWTYPES_H_
|
||||
/*
|
||||
* iwtypes.h: Standard interWAVE type definitions and fundamental defines.
|
||||
*
|
||||
* Bruce Nelson, interWAVE, 07/28/95.
|
||||
*/
|
||||
|
||||
/* Size-significant types. Use these for structure members, for example.
|
||||
*/
|
||||
typedef unsigned char u8;
|
||||
typedef char s8;
|
||||
typedef unsigned short u16;
|
||||
typedef short s16;
|
||||
|
||||
typedef unsigned int u32;
|
||||
typedef int s32;
|
||||
|
||||
/* Efficiency-significant types: size may be 16 or 32 bits, depending on
|
||||
* compiler. These are often best for local variables and expressions.
|
||||
* These types will be signed values.
|
||||
*/
|
||||
typedef int num; /* Number (for numerical calculations). */
|
||||
typedef int ix; /* Index (for arrays, etc.). */
|
||||
|
||||
//#ifndef _T_BOOL
|
||||
typedef int bool; /* Boolean: TRUE or FALSE. */
|
||||
//#endif
|
||||
|
||||
// The classic TRUE and FALSE, for Boolean values.
|
||||
|
||||
#define TRUE 1
|
||||
#define true 1
|
||||
#define FALSE 0
|
||||
#define false 0
|
||||
|
||||
// Nulls. Note that pointers should be compared to NULLP, not NULL.
|
||||
|
||||
#define NULL 0
|
||||
|
||||
#endif /* _IWTYPES_H_ */
|
||||
2478
src/configMgr/c_program/impmod/nmimp.c
Normal file
2478
src/configMgr/c_program/impmod/nmimp.c
Normal file
File diff suppressed because it is too large
Load Diff
459
src/configMgr/c_program/impmod/nmimp.h
Normal file
459
src/configMgr/c_program/impmod/nmimp.h
Normal file
@@ -0,0 +1,459 @@
|
||||
#ifndef _NMIMP_H_
|
||||
#define _NMIMP_H_
|
||||
/*
|
||||
* nmimp.h: Definitions of IMP data marshaling/unmarshaling stuff.
|
||||
*
|
||||
* Bruce Nelson, interWAVE, 08/16/95.
|
||||
*/
|
||||
|
||||
#include "iwtypes.h"
|
||||
#include "nmtypes.h"
|
||||
#include "nmstatus.h"
|
||||
|
||||
/* IMP agent IP port number.
|
||||
*/
|
||||
#define IMP_PORT 2112
|
||||
|
||||
/* IMP message types, i.e., operation codes. Notice that response codes are
|
||||
* the same as request codes, but with the "response bit" turned on. If the
|
||||
* NOBJ bit is on, the request/response does not apply to an object, but to an
|
||||
* entire agent and/or management application.
|
||||
*/
|
||||
#define IMP_MSG_UNDEFINED 0x000
|
||||
#define IMP_MSG_RESP_BIT 0x040
|
||||
#define IMP_MSG_NOBJ_BIT 0x080
|
||||
#define IMP_MSG_GET_REQ 0x001
|
||||
#define IMP_MSG_GET_RESP 0x041
|
||||
#define IMP_MSG_SET_REQ 0x002
|
||||
#define IMP_MSG_SET_RESP 0x042
|
||||
#define IMP_MSG_ACTION_REQ 0x003
|
||||
#define IMP_MSG_ACTION_RESP 0x043
|
||||
#define IMP_MSG_CREATE_REQ 0x004
|
||||
#define IMP_MSG_CREATE_RESP 0x044
|
||||
#define IMP_MSG_DELETE_REQ 0x005
|
||||
#define IMP_MSG_DELETE_RESP 0x045
|
||||
#define IMP_MSG_CONTENTS_REQ 0x006
|
||||
#define IMP_MSG_CONTENTS_RESP 0x046
|
||||
#define IMP_MSG_VALIDATE_REQ 0x007
|
||||
#define IMP_MSG_VALIDATE_RESP 0x047
|
||||
#define IMP_MSG_GETSEEK_REQ 0x008
|
||||
#define IMP_MSG_GETSEEK_RESP 0x048
|
||||
#define IMP_MSG_UNBUSY_REQ 0x009
|
||||
#define IMP_MSG_UNBUSY_RESP 0x049
|
||||
#define IMP_MSG_EVENT_IND 0x04a
|
||||
|
||||
#define IMP_MSG_CREATE_FWD 0x03a
|
||||
#define IMP_MSG_DELETE_FWD 0x039
|
||||
|
||||
/* Definitions of IMP type masks: upper five bits of tag byte.
|
||||
*/
|
||||
#define IMP_TYPE_MASK 0x0f8
|
||||
#define IMP_TYPE_NULL 0x080
|
||||
#define IMP_TYPE_UINT 0x088
|
||||
#define IMP_TYPE_SINT 0x090
|
||||
#define IMP_TYPE_CHAR_STRING 0x098
|
||||
#define IMP_TYPE_OBJECT_ID 0x0a0
|
||||
#define IMP_TYPE_CLASS_ID 0x0a8
|
||||
#define IMP_TYPE_ATTR_ID 0x0b0
|
||||
#define IMP_TYPE_EVENT_ID 0x0b8
|
||||
#define IMP_TYPE_ACTION_ID 0x0c0
|
||||
#define IMP_TYPE_STATUS_CODE 0x0c8
|
||||
#define IMP_TYPE_END_OF_MSG 0x0d0
|
||||
#define IMP_TYPE_USER_ID 0x0d8
|
||||
#define IMP_TYPE_COMPARATOR 0x0e0
|
||||
#define IMP_TYPE_APP_ADDR 0x0e8
|
||||
#define IMP_TYPE_LENGTH 0x0f0
|
||||
#define IMP_TYPE_IX_UINT 0x008
|
||||
#define IMP_TYPE_IX_SINT 0x010
|
||||
|
||||
/* Fixed size of an IMP marshaled length field.
|
||||
*/
|
||||
#define IMP_TYPE_LENGTH_MBYTES 3
|
||||
|
||||
/* Definitions of IMP array masks: bit two of tag byte.
|
||||
*/
|
||||
#define IMP_ARRAY_MASK 0x004
|
||||
#define IMP_ARRAY_TRUE 0x004
|
||||
#define IMP_ARRAY_FALSE 0x000
|
||||
|
||||
/* Definitions of array types and a mask to select both the type field and
|
||||
* the array bit. The marshal/unmarshal functions need to check for both
|
||||
* correct type value and correct array bit.
|
||||
*/
|
||||
#define IMP_ARRAY_TYPE_MASK (IMP_TYPE_MASK | IMP_ARRAY_MASK)
|
||||
#define IMP_ARRAY_UINT (IMP_TYPE_UINT | IMP_ARRAY_TRUE)
|
||||
#define IMP_ARRAY_SINT (IMP_TYPE_SINT | IMP_ARRAY_TRUE)
|
||||
#define IMP_ARRAY_CHAR_STRING (IMP_TYPE_CHAR_STRING | IMP_ARRAY_TRUE)
|
||||
#define IMP_ARRAY_OBJECT_ID (IMP_TYPE_OBJECT_ID | IMP_ARRAY_TRUE)
|
||||
#define IMP_ARRAY_APP_ADDR (IMP_TYPE_APP_ADDR | IMP_ARRAY_TRUE)
|
||||
#define IMP_ARRAY_IX_UINT (IMP_TYPE_IX_UINT | IMP_ARRAY_TRUE)
|
||||
#define IMP_ARRAY_IX_SINT (IMP_TYPE_IX_SINT | IMP_ARRAY_TRUE)
|
||||
|
||||
/* Definitions of IMP unit masks: low two bits of tag byte.
|
||||
*/
|
||||
#define IMP_UNIT_MASK 0x003
|
||||
#define IMP_UNIT_1 0x000
|
||||
#define IMP_UNIT_2 0x001
|
||||
#define IMP_UNIT_3 0x002
|
||||
#define IMP_UNIT_4 0x003
|
||||
|
||||
/* Definitions of IMP tag byte values.
|
||||
*/
|
||||
#define IMP_TAG_NULL \
|
||||
(u8)(IMP_TYPE_NULL | IMP_ARRAY_FALSE | IMP_UNIT_1)
|
||||
#define IMP_TAG_UINT_1 \
|
||||
(u8)(IMP_TYPE_UINT | IMP_ARRAY_FALSE | IMP_UNIT_1)
|
||||
#define IMP_TAG_SINT_1 \
|
||||
(u8)(IMP_TYPE_SINT | IMP_ARRAY_FALSE | IMP_UNIT_1)
|
||||
#define IMP_TAG_UINT_2 \
|
||||
(u8)(IMP_TYPE_UINT | IMP_ARRAY_FALSE | IMP_UNIT_2)
|
||||
#define IMP_TAG_SINT_2 \
|
||||
(u8)(IMP_TYPE_SINT | IMP_ARRAY_FALSE | IMP_UNIT_2)
|
||||
#define IMP_TAG_UINT_4 \
|
||||
(u8)(IMP_TYPE_UINT | IMP_ARRAY_FALSE | IMP_UNIT_4)
|
||||
#define IMP_TAG_SINT_4 \
|
||||
(u8)(IMP_TYPE_SINT | IMP_ARRAY_FALSE | IMP_UNIT_4)
|
||||
#define IMP_TAG_UARRAY_1 \
|
||||
(u8)(IMP_TYPE_UINT | IMP_ARRAY_TRUE | IMP_UNIT_1)
|
||||
#define IMP_TAG_SARRAY_1 \
|
||||
(u8)(IMP_TYPE_SINT | IMP_ARRAY_TRUE | IMP_UNIT_1)
|
||||
#define IMP_TAG_UARRAY_2 \
|
||||
(u8)(IMP_TYPE_UINT | IMP_ARRAY_TRUE | IMP_UNIT_2)
|
||||
#define IMP_TAG_SARRAY_2 \
|
||||
(u8)(IMP_TYPE_SINT | IMP_ARRAY_TRUE | IMP_UNIT_2)
|
||||
#define IMP_TAG_UARRAY_4 \
|
||||
(u8)(IMP_TYPE_UINT | IMP_ARRAY_TRUE | IMP_UNIT_4)
|
||||
#define IMP_TAG_SARRAY_4 \
|
||||
(u8)(IMP_TYPE_SINT | IMP_ARRAY_TRUE | IMP_UNIT_4)
|
||||
#define IMP_TAG_CHAR_STRING \
|
||||
(u8)(IMP_TYPE_CHAR_STRING | IMP_ARRAY_TRUE | IMP_UNIT_1)
|
||||
#define IMP_TAG_OBJECT_ID \
|
||||
(u8)(IMP_TYPE_OBJECT_ID | IMP_ARRAY_TRUE | IMP_UNIT_2)
|
||||
#define IMP_TAG_CLASS_ID_1 \
|
||||
(u8)(IMP_TYPE_CLASS_ID | IMP_ARRAY_FALSE | IMP_UNIT_1)
|
||||
#define IMP_TAG_CLASS_ID_2 \
|
||||
(u8)(IMP_TYPE_CLASS_ID | IMP_ARRAY_FALSE | IMP_UNIT_2)
|
||||
#define IMP_TAG_ATTR_ID_2 \
|
||||
(u8)(IMP_TYPE_ATTR_ID | IMP_ARRAY_FALSE | IMP_UNIT_2)
|
||||
#define IMP_TAG_ATTR_ID_3 \
|
||||
(u8)(IMP_TYPE_ATTR_ID | IMP_ARRAY_FALSE | IMP_UNIT_3)
|
||||
#define IMP_TAG_EVENT_ID_2 \
|
||||
(u8)(IMP_TYPE_EVENT_ID | IMP_ARRAY_FALSE | IMP_UNIT_2)
|
||||
#define IMP_TAG_EVENT_ID_3 \
|
||||
(u8)(IMP_TYPE_EVENT_ID | IMP_ARRAY_FALSE | IMP_UNIT_3)
|
||||
#define IMP_TAG_ACTION_ID_2 \
|
||||
(u8)(IMP_TYPE_ACTION_ID | IMP_ARRAY_FALSE | IMP_UNIT_2)
|
||||
#define IMP_TAG_ACTION_ID_3 \
|
||||
(u8)(IMP_TYPE_ACTION_ID | IMP_ARRAY_FALSE | IMP_UNIT_3)
|
||||
#define IMP_TAG_STATUS_CODE \
|
||||
(u8)(IMP_TYPE_STATUS_CODE | IMP_ARRAY_FALSE | IMP_UNIT_2)
|
||||
#define IMP_TAG_END_OF_MSG_1 \
|
||||
(u8)(IMP_TYPE_END_OF_MSG | IMP_ARRAY_FALSE | IMP_UNIT_1)
|
||||
#define IMP_TAG_END_OF_MSG_2 \
|
||||
(u8)(IMP_TYPE_END_OF_MSG | IMP_ARRAY_FALSE | IMP_UNIT_2)
|
||||
#define IMP_TAG_END_OF_MSG_4 \
|
||||
(u8)(IMP_TYPE_END_OF_MSG | IMP_ARRAY_FALSE | IMP_UNIT_4)
|
||||
#define IMP_TAG_USER_ID \
|
||||
(u8)(IMP_TYPE_USER_ID | IMP_ARRAY_FALSE | IMP_UNIT_4)
|
||||
#define IMP_TAG_COMPARATOR \
|
||||
(u8)(IMP_TYPE_COMPARATOR | IMP_ARRAY_FALSE | IMP_UNIT_1)
|
||||
#define IMP_TAG_APP_ADDR \
|
||||
(u8)(IMP_TYPE_APP_ADDR | IMP_ARRAY_TRUE | IMP_UNIT_1)
|
||||
#define IMP_TAG_LENGTH \
|
||||
(u8)(IMP_TYPE_LENGTH | IMP_ARRAY_FALSE | IMP_UNIT_2)
|
||||
#define IMP_TAG_UARIX_1 \
|
||||
(u8)(IMP_TYPE_IX_UINT | IMP_ARRAY_TRUE | IMP_UNIT_1)
|
||||
#define IMP_TAG_SARIX_1 \
|
||||
(u8)(IMP_TYPE_IX_SINT | IMP_ARRAY_TRUE | IMP_UNIT_1)
|
||||
#define IMP_TAG_UARIX_2 \
|
||||
(u8)(IMP_TYPE_IX_UINT | IMP_ARRAY_TRUE | IMP_UNIT_2)
|
||||
#define IMP_TAG_SARIX_2 \
|
||||
(u8)(IMP_TYPE_IX_SINT | IMP_ARRAY_TRUE | IMP_UNIT_2)
|
||||
#define IMP_TAG_UARIX_4 \
|
||||
(u8)(IMP_TYPE_IX_UINT | IMP_ARRAY_TRUE | IMP_UNIT_4)
|
||||
#define IMP_TAG_SARIX_4 \
|
||||
(u8)(IMP_TYPE_IX_SINT | IMP_ARRAY_TRUE | IMP_UNIT_4)
|
||||
|
||||
/* IMP message header, unmarshaled.
|
||||
*/
|
||||
#define IMP_APP_ADDR_BUFFER_LEN 32
|
||||
struct IMPHDR
|
||||
{
|
||||
tNMLEN MsgLen;
|
||||
tNMLEN HdrLen;
|
||||
tOid ObjId;
|
||||
u16 OpCode;
|
||||
tNMSTAT StatCode;
|
||||
u32 Uid;
|
||||
u32 Seq;
|
||||
u32 TransId1;
|
||||
u32 TransId2;
|
||||
u16 Access;
|
||||
u16 Link;
|
||||
u16 AppAddrLen;
|
||||
u8 AppAddr[IMP_APP_ADDR_BUFFER_LEN];
|
||||
/*
|
||||
* The remaining fields do not get marshaled, but are very useful for
|
||||
* keeping track of request and response message data.
|
||||
*/
|
||||
u8* pReqMsg;
|
||||
u8* pRespBody;
|
||||
tMID* pMidTbl;
|
||||
void* pClone;
|
||||
tNMLEN RespBodyLen;
|
||||
tCID CrDelCid;
|
||||
u16 CrDelIx;
|
||||
u8 CrDelSave;
|
||||
u8 ContOffset;
|
||||
u8 MidTblLen;
|
||||
u8 MidTblOffset;
|
||||
u8 RespMbox;
|
||||
u8 DoAttrValidate;
|
||||
u8 DoClsValidate;
|
||||
u8 DoAttrCommit;
|
||||
u8 DoClsCommit;
|
||||
};
|
||||
typedef struct IMPHDR tIMPHDR;
|
||||
/*
|
||||
* The following definition is an estimate for the maximum size of a marshaled
|
||||
* IMP header. It uses the header structure size for the estimate of the
|
||||
* maximal data and array size info to be sent (pretty accurate). To this it
|
||||
* adds the structure size divided by four, in order to add-in at least one
|
||||
* more byte per field, for the IMP tags (over-estimated).
|
||||
*/
|
||||
#define IMP_MAX_HDR_LENGTH (sizeof(tIMPHDR) + (sizeof(tIMPHDR) >> 2))
|
||||
#define IMP_MAX_BODY_LENGTH 1024
|
||||
#define IMP_MAX_MSG_LENGTH (IMP_MAX_HDR_LENGTH + IMP_MAX_BODY_LENGTH)
|
||||
|
||||
/* IMP event header, unmarshaled. Notice that the first part of this header
|
||||
* is, and MUST BE, the same as the IMP message header.
|
||||
*/
|
||||
struct EVHDR
|
||||
{
|
||||
tNMLEN MsgLen; /* msg length */
|
||||
tNMLEN HdrLen; /* msg header length */
|
||||
tOid ObjId; /* object identifier */
|
||||
u16 OpCode; /* always "event indication" */
|
||||
tCID EvCls; /* class of event */
|
||||
u8 EvNum; /* number of event, within class */
|
||||
u8 EvCode; /* event/alarm/reply encoding */
|
||||
u32 Time; /* time of (most recent) occurrence: SSE */
|
||||
u32 GlEvNum; /* global event number */
|
||||
/*
|
||||
* The following fields are used only for alarm records.
|
||||
*/
|
||||
u32 Time1; /* time of first occurrence: SSE */
|
||||
u32 Count; /* number of occurrences: 0=cleared */
|
||||
/*
|
||||
* The following fields are used only for action replies. Their
|
||||
* values echo the values in the action request.
|
||||
*/
|
||||
u16 ActCls; /* class of action */
|
||||
u8 ActNum; /* number of action, within class */
|
||||
u32 Seq; /* requester-provided sequence number */
|
||||
u32 TransId1; /* requester-provided data */
|
||||
u32 TransId2; /* requester-provided data */
|
||||
u16 AppAddrLen; /* return address of NM application */
|
||||
u8 AppAddr[IMP_APP_ADDR_BUFFER_LEN];
|
||||
};
|
||||
typedef struct EVHDR tEVHDR;
|
||||
#define IMP_MAX_EVHDR_LENGTH (sizeof(tEVHDR) + (sizeof(tEVHDR) >> 2))
|
||||
|
||||
/* Values for event header EvCode value. This tells how to marshal and
|
||||
* unmarshal the event header.
|
||||
*/
|
||||
#define IMP_EVENT_NORMAL 0
|
||||
#define IMP_EVENT_ALARM 1
|
||||
#define IMP_EVENT_REPLY 2
|
||||
|
||||
/* The following structure is used to store information about the most recent
|
||||
* action for which a reply event has yet to be sent. It is a subset of the
|
||||
* information from the original IMP request header.
|
||||
*/
|
||||
struct ACINFO
|
||||
{
|
||||
u32 Seq;
|
||||
u32 TransId1;
|
||||
u32 TransId2;
|
||||
u16 AppAddrLen;
|
||||
u8 AppAddr[IMP_APP_ADDR_BUFFER_LEN];
|
||||
tCID ActCls;
|
||||
u8 ActNum;
|
||||
tCID EvCls;
|
||||
u8 EvNum;
|
||||
u8 RespMbox;
|
||||
};
|
||||
typedef struct ACINFO tACINFO;
|
||||
|
||||
/* Externs for Marshal/UnMarshal functions.
|
||||
*
|
||||
* NOTICE: For port of nmi to Windows 3.1, we use C++ linkage for IMP code.
|
||||
* It is NOT in a library, and we need to avoid the Visual C++ (1.51)
|
||||
* limitation of only one extern "C" per compilation (which we use up with
|
||||
* nmtypes.h).
|
||||
*/
|
||||
|
||||
extern tNMSTAT NmMarshalNull(u8** ppBuf);
|
||||
extern tNMSTAT NmUnMarshalNull(u8** ppBuf);
|
||||
extern tNMSTAT NmMarshalU8(u8** ppBuf, u8 Value);
|
||||
extern tNMSTAT NmMarshalS8(u8** ppBuf, s8 Value);
|
||||
extern tNMSTAT NmUnMarshalU8(u8** ppBuf, u8* pValue);
|
||||
#define NmUnMarshalS8(ppBuf, pValue) \
|
||||
NmUnMarshalU8((ppBuf), (u8*)(pValue))
|
||||
extern tNMSTAT NmMarshalU16(u8** ppBuf, u16 Value);
|
||||
extern tNMSTAT NmMarshalS16(u8** ppBuf, s16 Value);
|
||||
extern tNMSTAT NmUnMarshalU16(u8** ppBuf, u16* pValue);
|
||||
#define NmUnMarshalS16(ppBuf, pValue) \
|
||||
NmUnMarshalU16((ppBuf), (u16*)(pValue))
|
||||
extern tNMSTAT NmMarshalU32(u8** ppBuf, u32 Value);
|
||||
extern tNMSTAT NmMarshalS32(u8** ppBuf, s32 Value);
|
||||
extern tNMSTAT NmUnMarshalU32(u8** ppBuf, u32* pValue);
|
||||
#define NmUnMarshalS32(ppBuf, pValue) \
|
||||
NmUnMarshalU32((ppBuf), (u32*)(pValue))
|
||||
extern tNMSTAT NmMarshalByteArray(u8** ppBuf, u8* pArray, u16 ArrayLen,
|
||||
u8 Tag);
|
||||
#define NmMarshalArrayU8(ppBuf, pArray, ArrayLen) \
|
||||
NmMarshalByteArray((ppBuf), (pArray), (ArrayLen), IMP_TAG_UARRAY_1)
|
||||
#define NmMarshalArrayS8(ppBuf, pArray, ArrayLen) \
|
||||
NmMarshalByteArray((ppBuf), (u8*)(pArray), (ArrayLen), \
|
||||
IMP_TAG_SARRAY_1)
|
||||
extern tNMSTAT NmUnMarshalArrayU8(u8** ppBuf, u8* pArray, u16* pArrayLen,
|
||||
u16 BufLen);
|
||||
#define NmUnMarshalArrayS8(ppBuf, pArray, pArrayLen, BufLen) \
|
||||
NmUnMarshalArrayU8((ppBuf), (u8*)(pArray), (pArrayLen), (BufLen))
|
||||
extern tNMSTAT NmMarshalWordArray(u8** ppBuf, u16* pArray, u16 ArrayLen,
|
||||
u8 Tag);
|
||||
#define NmMarshalArrayU16(ppBuf, pArray, ArrayLen) \
|
||||
NmMarshalWordArray((ppBuf), (pArray), (ArrayLen), IMP_TAG_UARRAY_2)
|
||||
#define NmMarshalArrayS16(ppBuf, pArray, ArrayLen) \
|
||||
NmMarshalWordArray((ppBuf), (u16*)(pArray), (ArrayLen), \
|
||||
IMP_TAG_SARRAY_2)
|
||||
extern tNMSTAT NmUnMarshalArrayU16(u8** ppBuf, u16* pArray, u16* pArrayLen,
|
||||
u16 BufLen);
|
||||
#define NmUnMarshalArrayS16(ppBuf, pArray, pArrayLen, BufLen) \
|
||||
NmUnMarshalArrayU16((ppBuf), (u16*)(pArray), (pArrayLen), (BufLen))
|
||||
extern tNMSTAT NmMarshalDWordArray(u8** ppBuf, u32* pArray, u16 ArrayLen,
|
||||
u8 Tag);
|
||||
#define NmMarshalArrayU32(ppBuf, pArray, ArrayLen) \
|
||||
NmMarshalDWordArray((ppBuf), (pArray), (ArrayLen), IMP_TAG_UARRAY_4)
|
||||
#define NmMarshalArrayS32(ppBuf, pArray, ArrayLen) \
|
||||
NmMarshalDWordArray((ppBuf), (u32*)(pArray), (ArrayLen), \
|
||||
IMP_TAG_SARRAY_4)
|
||||
extern tNMSTAT NmUnMarshalArrayU32(u8** ppBuf, u32* pArray, u16* pArrayLen,
|
||||
u16 BufLen);
|
||||
#define NmUnMarshalArrayS32(ppBuf, pArray, pArrayLen, BufLen) \
|
||||
NmUnMarshalArrayU32((ppBuf), (u32*)(pArray), (pArrayLen), (BufLen))
|
||||
extern tNMSTAT NmMarshalString(u8** ppBuf, char* pChars);
|
||||
extern tNMSTAT NmUnMarshalString(u8** ppBuf, char** ppChars);
|
||||
extern tNMSTAT NmMarshalObjectId(u8** ppBuf, tOid* pOid);
|
||||
extern tNMSTAT NmUnMarshalObjectId(u8** ppBuf, tOid* pOid);
|
||||
extern tNMSTAT NmMarshalClassId(u8** ppBuf, tCID Cid);
|
||||
extern tNMSTAT NmUnMarshalClassId(u8** ppBuf, tCID* pCid);
|
||||
extern tNMSTAT NmMarshalClassMember(u8** ppBuf, tCID Cid, u8 Member, u8 Type);
|
||||
extern tNMSTAT NmUnMarshalClassMember(u8** ppBuf, tCID* pCid, u8* pMember,
|
||||
u8 Type);
|
||||
#define NmMarshalAttrId(ppBuf, Cid, AttrNumber) \
|
||||
NmMarshalClassMember((ppBuf), (Cid), (AttrNumber), IMP_TYPE_ATTR_ID)
|
||||
#define NmUnMarshalAttrId(ppBuf, pCid, pAttrNumber) \
|
||||
NmUnMarshalClassMember((ppBuf), (pCid), (pAttrNumber), \
|
||||
IMP_TYPE_ATTR_ID)
|
||||
#define NmMarshalEventId(ppBuf, Cid, EventNumber) \
|
||||
NmMarshalClassMember((ppBuf), (Cid), (EventNumber), IMP_TYPE_EVENT_ID)
|
||||
#define NmUnMarshalEventId(ppBuf, pCid, pEventNumber) \
|
||||
NmUnMarshalClassMember((ppBuf), (pCid), (pEventNumber), \
|
||||
IMP_TYPE_EVENT_ID)
|
||||
#define NmMarshalActionId(ppBuf, Cid, ActionNumber) \
|
||||
NmMarshalClassMember((ppBuf), (Cid), (ActionNumber), IMP_TYPE_ACTION_ID)
|
||||
#define NmUnMarshalActionId(ppBuf, pCid, pActionNumber) \
|
||||
NmUnMarshalClassMember((ppBuf), (pCid), (pActionNumber), \
|
||||
IMP_TYPE_ACTION_ID)
|
||||
extern tNMSTAT NmMarshalStatusCode(u8** ppBuf, tNMSTAT Code);
|
||||
extern tNMSTAT NmUnMarshalStatusCode(u8** ppBuf, tNMSTAT* pCode);
|
||||
extern tNMSTAT NmMarshalEndOfMsg(u8** ppBuf, u32 CkSum, u8 UseCkSum);
|
||||
extern tNMSTAT NmUnMarshalEndOfMsg(u8** ppBuf, u32* pCkSum, u8* pUseCkSum);
|
||||
extern tNMSTAT NmMarshalUserId(u8** ppBuf, u32 Uid);
|
||||
extern tNMSTAT NmUnMarshalUserId(u8** ppBuf, u32* pUid);
|
||||
extern tNMSTAT NmMarshalComparator(u8** ppBuf, u8 Comp);
|
||||
extern tNMSTAT NmUnMarshalComparator(u8** ppBuf, u8* pComp);
|
||||
extern tNMSTAT NmMarshalAppAddr(u8** ppBuf, u8* pAddr, u16 AddrLen);
|
||||
extern tNMSTAT NmUnMarshalAppAddr(u8** ppBuf, u8* pAddr, u16* pAddrLen,
|
||||
u16 BufLen);
|
||||
extern tNMSTAT NmMarshalLength(u8** ppBuf, tNMLEN Len);
|
||||
extern tNMSTAT NmUnMarshalLength(u8** ppBuf, tNMLEN* pLen);
|
||||
extern tNMSTAT NmMarshalImpHeader(u8** ppBuf, tIMPHDR* pImpHdr);
|
||||
extern tNMSTAT NmUnMarshalImpHeader(u8** ppBuf, tIMPHDR* pImpHdr);
|
||||
extern tNMSTAT NmUnMarshalImpHeadHead(u8** ppBuf, tIMPHDR* pImpHdr);
|
||||
extern tNMSTAT NmMarshalEventHeader(u8** ppBuf, tEVHDR* pEvHdr, tNMLEN BodyLen);
|
||||
extern tNMSTAT NmUnMarshalEventHeader(u8** ppBuf, tEVHDR* pEvHdr);
|
||||
extern tNMSTAT NmReadImpOpCode(u8* pBuf, u16* pOpCode);
|
||||
extern tNMSTAT NmWriteImpOpCode(u8* pBuf, u16 OpCode);
|
||||
extern tNMSTAT NmWriteImpOpAndStatus(u8* pBuf, u16 OpCode, u16 StatusCode);
|
||||
extern void NmSkipImpField(u8** ppBuf);
|
||||
extern void NmCopyImpField(u8** ppBuf, u8** ppDst);
|
||||
extern tNMSTAT NmSetAttrStatus(u8* pBuf, tCID Cid, u8 AttrId, tNMSTAT AttrStat);
|
||||
/*
|
||||
* The following array-oriented functions deal with partial arrays, that is,
|
||||
* index/value pairs, vs. values for every index (as above). The unmarshal
|
||||
* functions permit writing directly onto an array or into an array of index/
|
||||
* value pairs.
|
||||
*/
|
||||
extern tNMSTAT NmMarshalByteArIx(u8** ppBuf, tARu8* pArIx, u16 ArIxLen, u8 Tag);
|
||||
#define NmMarshalARu8(ppBuf, pArIx, ArIxLen) \
|
||||
NmMarshalByteArIx((ppBuf), (pArIx), (ArIxLen), IMP_TAG_UARIX_1)
|
||||
#define NmMarshalARs8(ppBuf, pArIx, ArIxLen) \
|
||||
NmMarshalByteArIx((ppBuf), (tARu8*)(pArIx), (ArIxLen), IMP_TAG_SARIX_1)
|
||||
extern tNMSTAT NmUnMarshalARu8(u8** ppBuf, tARu8* pArIx, u16* pArIxLen,
|
||||
u16 BufLen);
|
||||
#define NmUnMarshalARs8(ppBuf, pArIx, pArIxLen, BufLen) \
|
||||
NmUnMarshalARu8((ppBuf), (tARu8*)(pArIx), (pArIxLen), (BufLen))
|
||||
extern tNMSTAT NmUnMarshalArrayIxU8(u8** ppBuf, u8* pArray, u16* pArrayLen,
|
||||
u16 BufLen);
|
||||
#define NmUnMarshalArrayIxS8(ppBuf, pArray, pArrayLen, BufLen) \
|
||||
NmUnMarshalArrayIxU8((ppBuf), (u8*)(pArray), (pArrayLen), (BufLen))
|
||||
extern tNMSTAT NmMarshalWordArIx(u8** ppBuf, tARu16* pArIx, u16 ArIxLen,
|
||||
u8 Tag);
|
||||
#define NmMarshalARu16(ppBuf, pArIx, ArIxLen) \
|
||||
NmMarshalWordArIx((ppBuf), (pArIx), (ArIxLen), IMP_TAG_UARIX_2)
|
||||
#define NmMarshalARs16(ppBuf, pArIx, ArIxLen) \
|
||||
NmMarshalWordArIx((ppBuf), (tARu16*)(pArIx), (ArIxLen), IMP_TAG_SARIX_2)
|
||||
extern tNMSTAT NmUnMarshalARu16(u8** ppBuf, tARu16* pArIx, u16* pArIxLen,
|
||||
u16 BufLen);
|
||||
#define NmUnMarshalARs16(ppBuf, pArIx, pArIxLen, BufLen) \
|
||||
NmUnMarshalARu16((ppBuf), (tARu16*)(pArIx), (pArIxLen), (BufLen))
|
||||
extern tNMSTAT NmUnMarshalArrayIxU16(u8** ppBuf, u16* pArray, u16* pArrayLen,
|
||||
u16 BufLen);
|
||||
#define NmUnMarshalArrayIxS16(ppBuf, pArray, pArrayLen, BufLen) \
|
||||
NmUnMarshalArrayIxU16((ppBuf), (u16*)(pArray), (pArrayLen), (BufLen))
|
||||
extern tNMSTAT NmMarshalDWordArIx(u8** ppBuf, tARu32* pArIx, u16 ArIxLen,
|
||||
u8 Tag);
|
||||
#define NmMarshalARu32(ppBuf, pArIx, ArIxLen) \
|
||||
NmMarshalDWordArIx((ppBuf), (pArIx), (ArIxLen), IMP_TAG_UARIX_4)
|
||||
#define NmMarshalARs32(ppBuf, pArIx, ArIxLen) \
|
||||
NmMarshalDWordArIx((ppBuf), (tARu32*)(pArIx), (ArIxLen), \
|
||||
IMP_TAG_SARIX_4)
|
||||
extern tNMSTAT NmUnMarshalARu32(u8** ppBuf, tARu32* pArIx, u16* pArIxLen,
|
||||
u16 BufLen);
|
||||
#define NmUnMarshalARs32(ppBuf, pArIx, pArIxLen, BufLen) \
|
||||
NmUnMarshalARu32((ppBuf), (tARu32*)(pArIx), (pArIxLen), (BufLen))
|
||||
extern tNMSTAT NmUnMarshalArrayIxU32(u8** ppBuf, u32* pArray, u16* pArrayLen,
|
||||
u16 BufLen);
|
||||
#define NmUnMarshalArrayIxS32(ppBuf, pArray, pArrayLen, BufLen) \
|
||||
NmUnMarshalArrayIxU32((ppBuf), (u32*)(pArray), (pArrayLen), (BufLen))
|
||||
/*
|
||||
* The following array-oriented functions handle either the whole-array or
|
||||
* partial-array encoding.
|
||||
*/
|
||||
extern tNMSTAT NmUnMarshalAnyArU8(u8** ppBuf, u8* pArray, u16* pArrayLen,
|
||||
u16 BufLen);
|
||||
#define NmUnMarshalAnyArS8(ppBuf, pArray, pArrayLen, BufLen) \
|
||||
NmUnMarshalAnyArU8((ppBuf), (u8*)(pArray), (pArrayLen), (BufLen))
|
||||
extern tNMSTAT NmUnMarshalAnyArU16(u8** ppBuf, u16* pArray, u16* pArrayLen,
|
||||
u16 BufLen);
|
||||
#define NmUnMarshalAnyArS16(ppBuf, pArray, pArrayLen, BufLen) \
|
||||
NmUnMarshalAnyArU16((ppBuf), (u16*)(pArray), (pArrayLen), (BufLen))
|
||||
extern tNMSTAT NmUnMarshalAnyArU32(u8** ppBuf, u32* pArray, u16* pArrayLen,
|
||||
u16 BufLen);
|
||||
#define NmUnMarshalAnyArS16(ppBuf, pArray, pArrayLen, BufLen) \
|
||||
NmUnMarshalAnyArU16((ppBuf), (u16*)(pArray), (pArrayLen), (BufLen))
|
||||
|
||||
#endif /* _NMIMP_H_ */
|
||||
110
src/configMgr/c_program/impmod/nmstatus.h
Normal file
110
src/configMgr/c_program/impmod/nmstatus.h
Normal file
@@ -0,0 +1,110 @@
|
||||
#ifndef _NMSTATUS_H_
|
||||
#define _NMSTATUS_H_
|
||||
/*
|
||||
* nmstatus.h: Definitions of status/error codes used with NM functions.
|
||||
*
|
||||
* IMPORTANT: PLEASE READ!
|
||||
*
|
||||
* This file is special, in that it is read by network management tools in
|
||||
* order to learn the print strings for status/error codes. For this reason,
|
||||
* the file format is very rigid.
|
||||
*
|
||||
* The file must only contain #define statements with the prefixes "NMSTAT_"
|
||||
* and "NMERROR_", and all #define values must be plain numbers. Each #define
|
||||
* must have a label modifier inside the special comment field (/ *{ ... }* /,
|
||||
* with stars connected to slashes, illegal in this comment!) that immediately
|
||||
* follows it. This label gives the print string for the status/error code.
|
||||
*
|
||||
* The "NMSTAT_" codes all report a form of success. The "NMERROR_" codes
|
||||
* report error conditions that apply to an entire operation or to a
|
||||
* particular attribute or parameter involved in the operation.
|
||||
*
|
||||
* Once a value is assigned here, it may never be changed. Add new values at
|
||||
* the END of the correct category.
|
||||
*
|
||||
* Bruce Nelson, interWAVE, 08/16/95.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Non-error status codes: 0 - 9.
|
||||
*
|
||||
* Note: NMSTAT_FAILURE implies that an operation completed without error,
|
||||
* but failed none the less. For Boolean operations, NMSTAT_SUCCESS means
|
||||
* "TRUE" and NMSTAT_FAILURE means "FALSE".
|
||||
*/
|
||||
#define NMSTAT_SUCCESS 0 /*{ label("ok") }*/
|
||||
#define NMSTAT_FAILURE 1 /*{ label("failure w/o error") }*/
|
||||
#define NMSTAT_PENDING 2 /*{ label("operation pending") }*/
|
||||
|
||||
/*
|
||||
* Begin error codes: >= 10.
|
||||
*/
|
||||
#define NMERROR_BAD_MESSAGE 10 /*{ label("unreadable message") }*/
|
||||
#define NMERROR_ENCODING 11 /*{ label("data encoding error") }*/
|
||||
#define NMERROR_PROTOCOL 12 /*{ label("protocol violation") }*/
|
||||
#define NMERROR_SYSTEM 13 /*{ label("system error") }*/
|
||||
#define NMERROR_MEMORY 14 /*{ label("out of memory") }*/
|
||||
#define NMERROR_INTERNAL 15 /*{ label("internal error") }*/
|
||||
#define NMERROR_INTERNAL_PARM 16 /*{ label("internal parm error") }*/
|
||||
#define NMERROR_VTABLE 17 /*{ label("virtual table error") }*/
|
||||
#define NMERROR_CONT_TABLE 18 /*{ label("container table error") }*/
|
||||
#define NMERROR_OPERATION 19 /*{ label("no such operation") }*/
|
||||
#define NMERROR_BAD_TYPE 20 /*{ label("no such data type") }*/
|
||||
#define NMERROR_BAD_CLASS 21 /*{ label("no such class") }*/
|
||||
#define NMERROR_BAD_ATTRIBUTE 22 /*{ label("no such attribute") }*/
|
||||
#define NMERROR_BAD_ACTION 23 /*{ label("no such action") }*/
|
||||
#define NMERROR_BAD_PARAMETER 24 /*{ label("no such parameter") }*/
|
||||
#define NMERROR_BAD_COMPARATOR 25 /*{ label("no such comparator") }*/
|
||||
#define NMERROR_TYPE 26 /*{ label("improper data type") }*/
|
||||
#define NMERROR_CLASS 27 /*{ label("improper class") }*/
|
||||
#define NMERROR_ATTRIBUTE 28 /*{ label("improper attribute") }*/
|
||||
#define NMERROR_ACTION 29 /*{ label("improper action") }*/
|
||||
#define NMERROR_PARAMETER 30 /*{ label("improper parameter") }*/
|
||||
#define NMERROR_COMPARATOR 31 /*{ label("improper comparator") }*/
|
||||
#define NMERROR_INDEX 32 /*{ label("improper index") }*/
|
||||
#define NMERROR_OBJECT 33 /*{ label("no such object") }*/
|
||||
#define NMERROR_OBJECT_EXISTS 34 /*{ label("object already exists") }*/
|
||||
#define NMERROR_OBJECT_ID 35 /*{ label("bad object identifier") }*/
|
||||
#define NMERROR_RANGE 36 /*{ label("value out-of-range") }*/
|
||||
#define NMERROR_ENUM 37 /*{ label("improper enum choice") }*/
|
||||
#define NMERROR_READONLY 38 /*{ label("read-only attribute") }*/
|
||||
#define NMERROR_ARRAY_TOO_BIG 39 /*{ label("array too long") }*/
|
||||
#define NMERROR_ARRAY_MISMATCH 40 /*{ label("array length mismatch") }*/
|
||||
#define NMERROR_APP_ADDR 41 /*{ label("bad application addr") }*/
|
||||
#define NMERROR_BUSY 42 /*{ label("busy") }*/
|
||||
#define NMERROR_KILLED 43 /*{ label("killed") }*/
|
||||
#define NMERROR_CONTINUE_HEADER 44 /*{ label("continue header error") }*/
|
||||
#define NMERROR_CONTINUE_MSG 45 /*{ label("continue msg error") }*/
|
||||
#define NMERROR_CONTINUE_OPCODE 46 /*{ label("continue opcode error") }*/
|
||||
#define NMERROR_CONTINUE_DATA 47 /*{ label("continue data error") }*/
|
||||
#define NMERROR_ATTR_ERRORS 48 /*{ label("attribute error(s)") }*/
|
||||
#define NMERROR_INTERNAL_ATTR 49 /*{ label("internal attr error") }*/
|
||||
#define NMERROR_ATTR_REJECTED 50 /*{ label("attr value rejected") }*/
|
||||
#define NMERROR_REJECT_HEADER 51 /*{ label("reject header error") }*/
|
||||
#define NMERROR_REJECT_DATA 52 /*{ label("reject data error") }*/
|
||||
#define NMERROR_INTERNAL_STAT 53 /*{ label("internal status error") }*/
|
||||
#define NMERROR_ABSTRACT 54 /*{ label("abstract class") }*/
|
||||
#define NMERROR_DBM_SAVE_VARS 55 /*{ label("dbm save vars error") }*/
|
||||
#define NMERROR_DBM_SAVE_CONTS 56 /*{ label("dbm save conts error") }*/
|
||||
#define NMERROR_DBM_REST_VARS 57 /*{ label("dbm restore vars error") }*/
|
||||
#define NMERROR_DBM_REST_CONTS 58 /*{ label("dbm restore conts error") }*/
|
||||
#define NMERROR_DBM_UNINIT 59 /*{ label("dbm uninitialized") }*/
|
||||
#define NMERROR_ADSTAT_UNLOCKED 60 /*{ label("admin state unlocked") }*/
|
||||
#define NMERROR_CHANNELS_INUSE 61 /*{ label("channel(s) in use") }*/
|
||||
#define NMERROR_OBJ_UNREACHABLE 62 /*{ label("object unreachable") }*/
|
||||
#define NMERROR_BUSY_ACTION 63 /*{ label("busy with action") }*/
|
||||
#define NMERROR_PARM_ERRORS 64 /*{ label("parameter error(s)") }*/
|
||||
#define NMERROR_PARM_UFLOW 65 /*{ label("too few parameters") }*/
|
||||
#define NMERROR_PARM_OFLOW 66 /*{ label("too many parameters") }*/
|
||||
#define NMERROR_INTERNAL_ACTION 67 /*{ label("internal action error") }*/
|
||||
#define NMERROR_ACTION_REJECTED 68 /*{ label("action rejected") }*/
|
||||
#define NMERROR_NO_TRANSITION 69 /*{ label("no transition")}*/
|
||||
#define NMERROR_CONT_READONLY 70 /*{ label("read-only container") }*/
|
||||
#define NMERROR_CREATE_REJECTED 71 /*{ label("create rejected") }*/
|
||||
#define NMERROR_DELETE_REJECTED 72 /*{ label("delete rejected") }*/
|
||||
#define NMERROR_CONT_REJECTED 73 /*{ label("contents rejected") }*/
|
||||
#define NMERROR_FORWARD_HEADER 74 /*{ label("forward header error") }*/
|
||||
#define NMERROR_FORWARD_MSG 75 /*{ label("forward msg error") }*/
|
||||
#define NMERROR_FORWARD_OPCODE 76 /*{ label("forward opcode error") }*/
|
||||
|
||||
#endif /* _NMSTATUS_H_ */
|
||||
503
src/configMgr/c_program/impmod/nmtypes.c
Normal file
503
src/configMgr/c_program/impmod/nmtypes.c
Normal file
@@ -0,0 +1,503 @@
|
||||
/*
|
||||
* nmtypes.c: Methods for types in nmtypes.h.
|
||||
*
|
||||
* Bruce Nelson, interWAVE, 08/07/95.
|
||||
*
|
||||
* Modified by : XChen
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "nmtypes.h"
|
||||
|
||||
|
||||
/*
|
||||
* Methods for "class" Dva.
|
||||
*/
|
||||
void DvaCopy(tDva* pDstDva, tDva* pSrcDva)
|
||||
{
|
||||
pDstDva->NetId = pSrcDva->NetId;
|
||||
pDstDva->NodeId = pSrcDva->NodeId;
|
||||
}
|
||||
|
||||
int DvaEqual(tDva* pDva1, tDva* pDva2)
|
||||
{
|
||||
return ((pDva1->NetId == pDva2->NetId) &&
|
||||
(pDva1->NodeId == pDva2->NodeId));
|
||||
}
|
||||
|
||||
/*
|
||||
* Methods for "class" Oid.
|
||||
*/
|
||||
void OidCtor(tOid* pOid)
|
||||
{
|
||||
u16* pDst;
|
||||
u16* pDstEnd;
|
||||
|
||||
pDst = (u16*)pOid;
|
||||
pDstEnd = pDst + (sizeof(tOid) / sizeof(u16));
|
||||
do
|
||||
{
|
||||
*pDst++ = (u16)0;
|
||||
} while (++pDst < pDstEnd);
|
||||
}
|
||||
|
||||
|
||||
/* OidCopy takes advantage of the fact that an Oid structure may be treated as
|
||||
* an array of u16 elements.
|
||||
*/
|
||||
void OidCopy(tOid* pDstOid, tOid* pSrcOid)
|
||||
{
|
||||
u16* pDst;
|
||||
u16* pSrc;
|
||||
u16* pSrcEnd;
|
||||
|
||||
pDst = (u16*)pDstOid;
|
||||
pSrc = (u16*)pSrcOid;
|
||||
pSrcEnd = pSrc + (sizeof(tOid) / sizeof(u16));
|
||||
do
|
||||
{
|
||||
*pDst++ = *pSrc;
|
||||
} while (++pSrc < pSrcEnd);
|
||||
}
|
||||
|
||||
void OidMakeChild(tOid* pDstOid, tOid* pSrcOid, tCONT DstContId, u16 DstIndex)
|
||||
{
|
||||
OidCopy(pDstOid, pSrcOid);
|
||||
pDstOid->ContId = DstContId;
|
||||
pDstOid->Ix[pDstOid->IxCnt++] = DstIndex;
|
||||
}
|
||||
|
||||
bool GetMeasPara(int Cid,int Eid,int num,char *pTempPara)
|
||||
{
|
||||
bool IsEvPara = TRUE;
|
||||
|
||||
//BtsMeasurement
|
||||
if((Cid == 22)&&(Eid == 0)&&(num == 0))
|
||||
strcpy(pTempPara,"LocationAreaCode");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 1))
|
||||
strcpy(pTempPara,"CellIdentity");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 2))
|
||||
strcpy(pTempPara,"StartTime");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 3))
|
||||
strcpy(pTempPara,"BscName");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 4))
|
||||
strcpy(pTempPara,"BtsName");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 5))
|
||||
strcpy(pTempPara,"nbrOfAvailableTCHs");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 6))
|
||||
strcpy(pTempPara,"meanNbrOfBusyTCHs");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 7))
|
||||
strcpy(pTempPara,"maxNbrOfBusyTCHs");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 8))
|
||||
strcpy(pTempPara,"meanNbrOfIdleTCHsPerInterferenceBand");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 9))
|
||||
strcpy(pTempPara,"attTCHSeizures");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 10))
|
||||
strcpy(pTempPara,"succTCHSeizures");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 11))
|
||||
strcpy(pTempPara,"nbrOfAvailableSDCCHs");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 12))
|
||||
strcpy(pTempPara,"meanNbrOfBusySDCCHs");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 13))
|
||||
strcpy(pTempPara,"maxNbrOfBusySDCCHs");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 14))
|
||||
strcpy(pTempPara,"attSDCCHSeizures");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 15))
|
||||
strcpy(pTempPara,"attSDCCHSeizuresFailures");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 16))
|
||||
strcpy(pTempPara,"accAGCH");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 17))
|
||||
strcpy(pTempPara,"accPagingChannel");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 18))
|
||||
strcpy(pTempPara,"succAccProcCMReEst");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 19))
|
||||
strcpy(pTempPara,"succAccProcCMServ");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 20))
|
||||
strcpy(pTempPara,"succAccProcIMSIDet");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 21))
|
||||
strcpy(pTempPara,"succAccProcLocUpd");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 22))
|
||||
strcpy(pTempPara,"succAccProcPageRsp");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 23))
|
||||
strcpy(pTempPara,"succAccProcRACH");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 24))
|
||||
strcpy(pTempPara,"succImmediateAssingProcsEmgCall");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 25))
|
||||
strcpy(pTempPara,"succImmediateAssingProcsCMReEst");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 26))
|
||||
strcpy(pTempPara,"succImmediateAssingProcsPageRsp");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 27))
|
||||
strcpy(pTempPara,"succImmediateAssingProcsOrigCall");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 28))
|
||||
strcpy(pTempPara,"succImmediateAssingProcsLocUpd");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 29))
|
||||
strcpy(pTempPara,"succImmediateAssingProcsOthers");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 30))
|
||||
strcpy(pTempPara,"maxNbrOfBlockCH");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 31))
|
||||
strcpy(pTempPara,"chanReqMSFail");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 32))
|
||||
strcpy(pTempPara,"MinQualityUL");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 33))
|
||||
strcpy(pTempPara,"MaxQualityUL");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 34))
|
||||
strcpy(pTempPara,"MeanQualityUL");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 35))
|
||||
strcpy(pTempPara,"TotalQualityDurationUL");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 36))
|
||||
strcpy(pTempPara,"TotalQualitySamplesUL");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 37))
|
||||
strcpy(pTempPara,"CumulativeQualityDistributionUL");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 38))
|
||||
strcpy(pTempPara,"MinQualityDL");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 39))
|
||||
strcpy(pTempPara,"MaxQualityDL");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 40))
|
||||
strcpy(pTempPara,"MeanQualityDL");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 41))
|
||||
strcpy(pTempPara,"TotalQualityDurationDL");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 42))
|
||||
strcpy(pTempPara,"TotalQualitySamplesDL");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 43))
|
||||
strcpy(pTempPara,"CumulativeQualityDistributionDL");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 44))
|
||||
strcpy(pTempPara,"HoInterBSCReqToMSC");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 45))
|
||||
strcpy(pTempPara,"HoInterBSCOutAtmpt");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 46))
|
||||
strcpy(pTempPara,"HoInterBSCMSFail");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 47))
|
||||
strcpy(pTempPara,"HoInterBSCOut");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 48))
|
||||
strcpy(pTempPara,"HoInterBSCIn");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 49))
|
||||
strcpy(pTempPara,"HoIntraBSCAtmpt");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 50))
|
||||
strcpy(pTempPara,"HoIntraBSCIn");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 51))
|
||||
strcpy(pTempPara,"HoIntraBscFail");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 52))
|
||||
strcpy(pTempPara,"HoIntraBscLostMs");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 53))
|
||||
strcpy(pTempPara,"FailIncomingHDOs");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 54))
|
||||
strcpy(pTempPara,"AvgRachSlotCount");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 55))
|
||||
strcpy(pTempPara,"AvgRachBusyCount");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 56))
|
||||
strcpy(pTempPara,"AvgRachAccessCount");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 57))
|
||||
strcpy(pTempPara,"attTCHAssignments");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 58))
|
||||
strcpy(pTempPara,"ImmAssignToBts");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 59))
|
||||
strcpy(pTempPara,"meanTCHBusyTime");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 60))
|
||||
strcpy(pTempPara,"SuccTchSmsEst");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 61))
|
||||
strcpy(pTempPara,"SuccSdcchSmsEst");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 62))
|
||||
strcpy(pTempPara,"UnsuccTchSmsEst");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 63))
|
||||
strcpy(pTempPara,"UnsuccSdcchSmsEst");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 64))
|
||||
strcpy(pTempPara,"attTransOfPagingMessagesThePCH");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 65))
|
||||
strcpy(pTempPara,"PGCHLoading");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 66))
|
||||
strcpy(pTempPara,"nbrOfPagesDiscardedFromPCHQueue");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 67))
|
||||
strcpy(pTempPara,"TCHEmergencyCalls");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 68))
|
||||
strcpy(pTempPara,"SDCCHEmergencyCalls");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 69))
|
||||
strcpy(pTempPara,"SDCCHActFail");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 70))
|
||||
strcpy(pTempPara,"deleteIndMsgCount");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 71))
|
||||
strcpy(pTempPara,"UplinkAvgSignal");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 72))
|
||||
strcpy(pTempPara,"DownlinkAvgSignal");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 73))
|
||||
strcpy(pTempPara,"HoAtmpToNeighborPerTargetCell");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 74))
|
||||
strcpy(pTempPara,"HoFailToNeighborPerTargetCell");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 75))
|
||||
strcpy(pTempPara,"succOutgoingInternalInterCellHDOs");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 76))
|
||||
strcpy(pTempPara,"allAvailableTCHAllocatedTime");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 77))
|
||||
strcpy(pTempPara,"allAvailableSDCCHAllocatedTime");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 78))
|
||||
strcpy(pTempPara,"attInternalHDOsUlQual");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 79))
|
||||
strcpy(pTempPara,"attInternalHDOsDlQual");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 80))
|
||||
strcpy(pTempPara,"attInternalHDOsUlLevel");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 81))
|
||||
strcpy(pTempPara,"attInternalHDOsDlLevel");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 82))
|
||||
strcpy(pTempPara,"attInternalHDOsDistance");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 83))
|
||||
strcpy(pTempPara,"attInternalHDOsOMC");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 84))
|
||||
strcpy(pTempPara,"attInternalHDOsMSCInvoke");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 85))
|
||||
strcpy(pTempPara,"attInternalHDOsBetterCell");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 86))
|
||||
strcpy(pTempPara,"attInternalHDOsDirectedRetry");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 87))
|
||||
strcpy(pTempPara,"attInternalHDOsCallControl");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 88))
|
||||
strcpy(pTempPara,"SDCCHRadioFail");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 89))
|
||||
strcpy(pTempPara,"SDCCHAbisFail");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 90))
|
||||
strcpy(pTempPara,"SDCCHAifFail");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 91))
|
||||
strcpy(pTempPara,"SDCCHBtsFail");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 92))
|
||||
strcpy(pTempPara,"SDCCHTrxFail");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 93))
|
||||
strcpy(pTempPara,"SDCCHBssDrop");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 94))
|
||||
strcpy(pTempPara,"TCHRadioFail");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 95))
|
||||
strcpy(pTempPara,"TCHAbisFail");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 96))
|
||||
strcpy(pTempPara,"TCHAifFail");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 97))
|
||||
strcpy(pTempPara,"TCHBtsFail");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 98))
|
||||
strcpy(pTempPara,"TCHTrxFail");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 99))
|
||||
strcpy(pTempPara,"TCHBssDrop");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 100))
|
||||
strcpy(pTempPara,"succAccProcCMOrigCall");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 101))
|
||||
strcpy(pTempPara,"succAccProcCMSms");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 102))
|
||||
strcpy(pTempPara,"succAccProcCMSs");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 103))
|
||||
strcpy(pTempPara,"succAccProcCMGrpCall");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 104))
|
||||
strcpy(pTempPara,"succAccProcCMBroadCast");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 105))
|
||||
strcpy(pTempPara,"attImmediateAssingProcsEmgCall");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 106))
|
||||
strcpy(pTempPara,"attImmediateAssingProcsCMReEst");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 107))
|
||||
strcpy(pTempPara,"attImmediateAssingProcsPageRsp");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 108))
|
||||
strcpy(pTempPara,"attImmediateAssingProcsOrigCall");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 109))
|
||||
strcpy(pTempPara,"attImmediateAssingProcsLocUpd");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 110))
|
||||
strcpy(pTempPara,"attImmediateAssingProcsOthers");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 111))
|
||||
strcpy(pTempPara,"ARMtAlert");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 112))
|
||||
strcpy(pTempPara,"ARMoAlert");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 113))
|
||||
strcpy(pTempPara,"ARCallCfm");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 114))
|
||||
strcpy(pTempPara,"ARCallPro");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 115))
|
||||
strcpy(pTempPara,"ARMtConnect");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 116))
|
||||
strcpy(pTempPara,"ARMoConnect");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 117))
|
||||
strcpy(pTempPara,"ARMtConAck");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 118))
|
||||
strcpy(pTempPara,"ARMoConAck");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 119))
|
||||
strcpy(pTempPara,"ARMtSetUp");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 120))
|
||||
strcpy(pTempPara,"ARMoSetUp");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 121))
|
||||
strcpy(pTempPara,"ARAuthReq");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 122))
|
||||
strcpy(pTempPara,"ARAuthRes");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 123))
|
||||
strcpy(pTempPara,"ARIdReq");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 124))
|
||||
strcpy(pTempPara,"ARIdRes");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 125))
|
||||
strcpy(pTempPara,"ARTmsiRelocCmd");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 126))
|
||||
strcpy(pTempPara,"ARTmsiRelocCmp");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 127))
|
||||
strcpy(pTempPara,"ARCmServAcc");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 128))
|
||||
strcpy(pTempPara,"ARCmServRej");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 129))
|
||||
strcpy(pTempPara,"ARCmServAbt");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 130))
|
||||
strcpy(pTempPara,"ARLocUpdAcc");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 131))
|
||||
strcpy(pTempPara,"ARLocUpdRej");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 132))
|
||||
strcpy(pTempPara,"ARCimoCmd");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 133))
|
||||
strcpy(pTempPara,"ARCimoCmp");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 134))
|
||||
strcpy(pTempPara,"ARCimoRej");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 135))
|
||||
strcpy(pTempPara,"AifBlocking");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 136))
|
||||
strcpy(pTempPara,"TCHBlocking");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 137))
|
||||
strcpy(pTempPara,"TrauBlocking");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 138))
|
||||
strcpy(pTempPara,"HoInterBSCInAtmpt");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 139))
|
||||
strcpy(pTempPara,"succTCHAssignments");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 140))
|
||||
strcpy(pTempPara,"FailTCHAssignments");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 141))
|
||||
strcpy(pTempPara,"TCHQueuedCallAttempt");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 142))
|
||||
strcpy(pTempPara,"TCHQueuedHoAttempt");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 143))
|
||||
strcpy(pTempPara,"QFullCallAttempt");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 144))
|
||||
strcpy(pTempPara,"QFullHoAttempt");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 145))
|
||||
strcpy(pTempPara,"FailQdCallAttempt");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 146))
|
||||
strcpy(pTempPara,"FailQdHoAttempt");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 147))
|
||||
strcpy(pTempPara,"AvgQLength");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 148))
|
||||
strcpy(pTempPara,"AvgQTimeCallAttempt");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 149))
|
||||
strcpy(pTempPara,"AvgQTimeHoAttempt");
|
||||
else if((Cid == 22)&&(Eid == 0)&&(num == 150))
|
||||
strcpy(pTempPara,"succAccProcPageRspSMS");
|
||||
|
||||
/* else if((Cid == 23)&&(Eid == 0)&&(num == 0))
|
||||
strcpy(pTempPara,"startTime");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 1))
|
||||
strcpy(pTempPara,"BscName");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 2))
|
||||
strcpy(pTempPara,"attImmediateAssingProcsPerBSC");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 3))
|
||||
strcpy(pTempPara,"succImmediateAssingProcsPerBSC");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 4))
|
||||
strcpy(pTempPara,"succInternalHDOsIntraCellPerBSC");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 5))
|
||||
strcpy(pTempPara,"unsuccInternalHDOsIntraCellPerBSC");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 6))
|
||||
strcpy(pTempPara,"succInternalHDOsPerBSC");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 7))
|
||||
strcpy(pTempPara,"unsuccInternalHDOsPerBSC");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 8))
|
||||
strcpy(pTempPara,"ClrReqToMSC");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 9))
|
||||
strcpy(pTempPara,"ConReqToMSC");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 10))
|
||||
strcpy(pTempPara,"ConCfmFromMSC");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 11))
|
||||
strcpy(pTempPara,"ConRefFromMSC");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 12))
|
||||
strcpy(pTempPara,"CMServiceRejFromMSC");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 13))
|
||||
strcpy(pTempPara,"attTransOfPagingMessagesPerBSC");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 14))
|
||||
strcpy(pTempPara,"succInternalHDOsUlQual");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 15))
|
||||
strcpy(pTempPara,"succInternalHDOsDlQual");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 16))
|
||||
strcpy(pTempPara,"succInternalHDOsUlLevel");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 17))
|
||||
strcpy(pTempPara,"succInternalHDOsDlLevel");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 18))
|
||||
strcpy(pTempPara,"succInternalHDOsDistance");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 19))
|
||||
strcpy(pTempPara,"succInternalHDOsOMC");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 20))
|
||||
strcpy(pTempPara,"succInternalHDOsMSCInvoke");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 21))
|
||||
strcpy(pTempPara,"succInternalHDOsBetterCell");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 22))
|
||||
strcpy(pTempPara,"succInternalHDOsDirectedRetry");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 23))
|
||||
strcpy(pTempPara,"succInternalHDOsCallControl");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 24))
|
||||
strcpy(pTempPara,"flushReqReceived");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 25))
|
||||
strcpy(pTempPara,"pagingCSReqReceivedfromSGSN");
|
||||
else if((Cid == 23)&&(Eid == 0)&&(num == 26))
|
||||
strcpy(pTempPara,"pagingPSReqReceivedfromSGSN");
|
||||
*/
|
||||
else IsEvPara = FALSE;
|
||||
return IsEvPara;
|
||||
}
|
||||
bool GetTableName(int cid,char *pTab)
|
||||
{
|
||||
bool IsCid = TRUE;
|
||||
if(cid == 58)//NMCLASS_AIf
|
||||
strcpy(pTab,"AIf");
|
||||
else if(cid == 60)
|
||||
strcpy(pTab,"ALink");
|
||||
else if(cid == 59)
|
||||
strcpy(pTab,"ALinkSet");
|
||||
else if(cid == 5)
|
||||
strcpy(pTab,"AbisMgr");
|
||||
else if(cid == 6)
|
||||
strcpy(pTab,"AdjHand");
|
||||
else if(cid == 7)
|
||||
strcpy(pTab,"Bsc");
|
||||
else if(cid == 8)
|
||||
strcpy(pTab,"BssFunc");
|
||||
else if(cid == 9)
|
||||
strcpy(pTab,"Bts");
|
||||
else if(cid == 11)
|
||||
strcpy(pTab,"BtsMgr");
|
||||
else if(cid == 52)
|
||||
strcpy(pTab,"ClockMod");
|
||||
else if(cid == 44)
|
||||
strcpy(pTab,"E1port");
|
||||
else if(cid == 43)
|
||||
strcpy(pTab,"E1trmod");
|
||||
else if(cid == 49)
|
||||
strcpy(pTab,"TrauDsp");
|
||||
else if(cid == 19)
|
||||
strcpy(pTab,"Software");
|
||||
else if(cid == 20)
|
||||
strcpy(pTab,"Trx");
|
||||
else if(cid == 14)
|
||||
strcpy(pTab,"TrxCh");
|
||||
else if(cid == 27)
|
||||
strcpy(pTab,"Wavex");
|
||||
else if(cid == 18)
|
||||
strcpy(pTab,"RCarrier");
|
||||
else if(cid == 17)
|
||||
strcpy(pTab,"PwrCont");
|
||||
else if(cid == 15)
|
||||
strcpy(pTab,"HandCont");
|
||||
else if(cid == 111)
|
||||
strcpy(pTab,"SmsCb");
|
||||
else if(cid == 112)
|
||||
strcpy(pTab,"SmMsg");
|
||||
else if(cid == 124)
|
||||
strcpy(pTab,"Bssgp");
|
||||
else if(cid == 125)
|
||||
strcpy(pTab,"Bvc");
|
||||
else if(cid == 126)
|
||||
strcpy(pTab,"Ns");
|
||||
else if(cid == 127)
|
||||
strcpy(pTab,"Nse");
|
||||
else if(cid == 128)
|
||||
strcpy(pTab,"Nsvc");
|
||||
else if(cid == 130)
|
||||
strcpy(pTab,"FRPort");
|
||||
else if(cid == 131)
|
||||
strcpy(pTab,"pvc");
|
||||
|
||||
else
|
||||
IsCid = FALSE;
|
||||
return(IsCid);
|
||||
}
|
||||
201
src/configMgr/c_program/impmod/nmtypes.h
Normal file
201
src/configMgr/c_program/impmod/nmtypes.h
Normal file
@@ -0,0 +1,201 @@
|
||||
#ifndef _NMTYPES_H_
|
||||
#define _NMTYPES_H_
|
||||
/** Copyright (C) 1995 interWAVE Communications, Inc.: All Rights Reserved. **/
|
||||
/*
|
||||
* nmtypes.h: Definitions of fundamental data types used in NM classes.
|
||||
*
|
||||
* Bruce Nelson, interWAVE, 08/07/95.
|
||||
* Modified by: XChen
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "iwtypes.h"
|
||||
|
||||
/* Some message types for MsgId in IW message header.
|
||||
*/
|
||||
#define NM_MSGID_IMP 0
|
||||
#define NM_MSGID_IMPSRVR_REG 1
|
||||
#define NM_MSGID_IMPSRVR_UNREG 2
|
||||
|
||||
#define MAX_OID_LEVELS 12
|
||||
#define MAX_STRING_LENGTH 128
|
||||
#define MAX_ARRAY_LENGTH 128
|
||||
#define MAX_ARRAY1_LENGTH MAX_ARRAY_LENGTH
|
||||
#define MAX_ARRAY2_LENGTH MAX_ARRAY_LENGTH
|
||||
#define MAX_ARRAY4_LENGTH MAX_ARRAY_LENGTH
|
||||
#define MAX_ATTR_COUNT 256
|
||||
#define MAX_ACTION_COUNT 256
|
||||
#define MAX_EVENT_COUNT 256
|
||||
|
||||
/* Some scalar types.
|
||||
*/
|
||||
typedef u16 tCID; /* class identifier */
|
||||
typedef u16 tCONT; /* container identifier */
|
||||
typedef u16 tNMSTAT; /* NM function return code: status/error */
|
||||
typedef u16 tNMLEN; /* NM message length type: always two bytes */
|
||||
|
||||
#define NM_CLASS_UNDEFINED ((tCID)(65535))
|
||||
#define NM_CONTID_UNDEFINED ((tCONT)(65535))
|
||||
|
||||
/* Generic type for NM functions in "virtual function" table. Note that all
|
||||
* NM functions return a non-negative status code.
|
||||
*/
|
||||
typedef tNMSTAT (*tNmFnP)();
|
||||
typedef void (*tVdFnP)();
|
||||
|
||||
/* Types used to store array index/value pairs.
|
||||
*/
|
||||
struct ARs8
|
||||
{
|
||||
u8 Index;
|
||||
s8 Value;
|
||||
};
|
||||
typedef struct ARs8 tARs8;
|
||||
struct ARu8
|
||||
{
|
||||
u8 Index;
|
||||
u8 Value;
|
||||
};
|
||||
typedef struct ARu8 tARu8;
|
||||
struct ARs16
|
||||
{
|
||||
u8 Index;
|
||||
s16 Value;
|
||||
};
|
||||
typedef struct ARs16 tARs16;
|
||||
struct ARu16
|
||||
{
|
||||
u8 Index;
|
||||
u16 Value;
|
||||
};
|
||||
typedef struct ARu16 tARu16;
|
||||
struct ARs32
|
||||
{
|
||||
u8 Index;
|
||||
s32 Value;
|
||||
};
|
||||
typedef struct ARs32 tARs32;
|
||||
struct ARu32
|
||||
{
|
||||
u8 Index;
|
||||
u32 Value;
|
||||
};
|
||||
typedef struct ARu32 tARu32;
|
||||
|
||||
/* Type used to store a class member id (e.g., attribute id).
|
||||
*/
|
||||
struct MID
|
||||
{
|
||||
tCID ClassId;
|
||||
u8 MemberId;
|
||||
u8 MemberType;
|
||||
tNmFnP MemberFn;
|
||||
tVdFnP CommitFn;
|
||||
};
|
||||
typedef struct MID tMID;
|
||||
|
||||
/* Defines for MID types.
|
||||
*/
|
||||
#define MID_TYPE_UNKNOWN 0
|
||||
#define MID_TYPE_ATTR_NUM 1
|
||||
#define MID_TYPE_ATTR_ARRAY 2
|
||||
#define MID_TYPE_ATTR_STRG 3
|
||||
#define MID_TYPE_ATTR_OID 4
|
||||
#define MID_TYPE_ATTR_CID 5
|
||||
#define MID_TYPE_ACTION 14
|
||||
#define MID_TYPE_EVENT 15
|
||||
#define MID_TYPE_TYPE_MASK 0x00f
|
||||
#define MID_TYPE_NOVAL_MASK 0x010
|
||||
#define MID_TYPE_RW_MASK 0x020
|
||||
#define MID_TYPE_RO_MASK 0x030
|
||||
#define MID_TYPE_UPDATE_MASK 0x040
|
||||
#define MID_TYPE_DEBUG_MASK 0x080
|
||||
|
||||
/* Type used to store action info (alas, tMID not reusable enough).
|
||||
*/
|
||||
struct FID
|
||||
{
|
||||
tCID ActCls;
|
||||
u8 ActNum;
|
||||
u8 ParmCount;
|
||||
tCID EvCls;
|
||||
u8 EvNum;
|
||||
tNmFnP ActFn;
|
||||
u8* pParmTypes;
|
||||
};
|
||||
typedef struct FID tFID;
|
||||
|
||||
/* The Dva structure (type tDva) represents a device (node) address.
|
||||
*
|
||||
* NOTICE: This is tentative.
|
||||
*/
|
||||
struct Dva
|
||||
{
|
||||
u16 NetId; /* network number */
|
||||
u16 NodeId; /* node number */
|
||||
};
|
||||
typedef struct Dva tDva;
|
||||
|
||||
/* Methods operating on tDva. (Function externs moved to bottom of file.)
|
||||
*/
|
||||
|
||||
/* The Oid structure (type tOid) represents an object identifier. The IxCnt
|
||||
* field must be first, since it is not explicitly marshaled, but the rest of
|
||||
* the Oid is marshaled as though it were a u16 array (of length IxCnt +
|
||||
* ((sizeof(tCONT) + sizeof(tDva)) / sizeof(u16))). The ContId must come
|
||||
* second, both to pad to a 4-byte boundary before DvAddr and because the
|
||||
* offset of the ContId field is treated at the start of the marshaled Oid
|
||||
* data. The Ix array must come last, since only part of it may be marshaled.
|
||||
*/
|
||||
struct Oid
|
||||
{
|
||||
u16 IxCnt; /* number of indexes */
|
||||
tCONT ContId; /* systemwide container id */
|
||||
tDva DvAddr; /* device address */
|
||||
u16 Ix[MAX_OID_LEVELS]; /* indexes: one per containment lvl */
|
||||
};
|
||||
typedef struct Oid tOid;
|
||||
#define OID_NON_IX_U16_COUNT ((sizeof(tCONT) + sizeof(tDva)) / sizeof(u16))
|
||||
#define OID_INIT \
|
||||
{ \
|
||||
(u16)0, \
|
||||
(tCONT)0, \
|
||||
{ (u16)0, \
|
||||
(u16)0 }, \
|
||||
{ (u16)0, \
|
||||
(u16)0, \
|
||||
(u16)0, \
|
||||
(u16)0, \
|
||||
(u16)0, \
|
||||
(u16)0, \
|
||||
(u16)0, \
|
||||
(u16)0, \
|
||||
(u16)0, \
|
||||
(u16)0, \
|
||||
(u16)0, \
|
||||
(u16)0 } \
|
||||
}
|
||||
|
||||
/* Methods operating on tOid. (Function externs moved to bottom of file.)
|
||||
*/
|
||||
|
||||
/* Functions that manipulate arrays.
|
||||
*/
|
||||
#define s8copy(pDst, pSrc, Length) \
|
||||
u8copy((u8*)(pDst), (u8*)(pSrc), (Length))
|
||||
#define s16copy(pDst, pSrc, Length) \
|
||||
u16copy((u16*)(pDst), (u16*)(pSrc), (Length))
|
||||
#define s32copy(pDst, pSrc, Length) \
|
||||
u32copy((u32*)(pDst), (u32*)(pSrc), (Length))
|
||||
|
||||
extern void DvaCopy(tDva* pDstDva, tDva* pSrcDva);
|
||||
extern int DvaEqual(tDva* pDva1, tDva* pDva2);
|
||||
extern void OidCtor(tOid* pOid);
|
||||
extern void OidCopy(tOid* pDstOid, tOid* pSrcOid);
|
||||
extern void OidMakeChild(tOid* pDstOid, tOid* pSrcOid, tCONT DstContId,u16 DstIndex);
|
||||
|
||||
//extern bool GetEventName(int Cid,int Eid,char *pTempEid,char *pTempAlarmLevel);
|
||||
extern bool GetMeasPara(int Cid,int Eid,int num,char *pTempPara);
|
||||
extern bool GetTableName(int cid,char *pTab);
|
||||
|
||||
#endif /* _NMTYPES_H_ */
|
||||
84
src/configMgr/c_program/paraComm/Makefile
Normal file
84
src/configMgr/c_program/paraComm/Makefile
Normal file
@@ -0,0 +1,84 @@
|
||||
#!/bin/sh
|
||||
|
||||
#Author: Cui Ticun
|
||||
#Version: 9.00.00
|
||||
#Date: 2007-7-1
|
||||
#Description: Makefile for paraComm module.
|
||||
|
||||
CC = gcc
|
||||
CFLAGS=-D_REENTRANT -g -Wall
|
||||
|
||||
dbINCLUDEFLAG = -I/usr/local/mysql/include
|
||||
dbLINKFLAG = -L/usr/local/mysql/lib -lmariadbclient -lz
|
||||
|
||||
dbINCLUDEFLAG.ES = -I/usr/include/mariadb
|
||||
dbLINKFLAG.ES = -L/usr/lib/mysql -lmariadbclient -lz
|
||||
|
||||
LINKFLAG=-L../../../omcLib/c_program/omcLib -lomcLib \
|
||||
-L../../../../plat/snmp/lib -lsnmp \
|
||||
-L../../../../plat/sccp/lib -lsccp \
|
||||
-L../../../../plat/iptrans/lib -liptrans \
|
||||
-L../../../../plat/debug/lib -ldebug \
|
||||
-L../../../../plat/public/lib -lpublic \
|
||||
|
||||
LINK_SUFFIX = $(dbINCLUDEFLAG) $(dbLINKFLAG) $(LINKFLAG)
|
||||
LINK_SUFFIX.ES = $(dbINCLUDEFLAG.ES) $(dbLINKFLAG.ES)$(LINKFLAG)
|
||||
|
||||
PROGS = paraComm
|
||||
|
||||
PARACOMM_OBJ = paraCommMain.o paraComm.o initParaConf.o
|
||||
PARACOMM_OBJ.ES = paraCommMain.o.ES paraComm.o.ES initParaConf.o.ES
|
||||
|
||||
LIB_OBJ = paraComm.o initParaConf.o
|
||||
LIB_OBJ.ES = paraComm.o.ES initParaConf.o.ES
|
||||
|
||||
default: linuxES
|
||||
|
||||
all:
|
||||
@echo " **** Compiling $(PROGS) ****"
|
||||
@echo "make clean -- Delete the target files"
|
||||
@echo "make linux72 -- Generate target files for Redhat Linux 72"
|
||||
@echo "make linuxES -- Generate target files for Redhat Linux ES"
|
||||
|
||||
|
||||
linux72: $(PARACOMM_OBJ)
|
||||
@echo Linking $(PROGS)
|
||||
@$(CC) $(CFLAGS) -o $(PROGS) $(PARACOMM_OBJ) $(LINK_SUFFIX) -lm
|
||||
ar r libparaComm.a $(LIB_OBJ)
|
||||
rm -f *.o core *~
|
||||
#cp -f $(PROGS) ../../../../bin
|
||||
#cp -f $(PROGS) /usr/local/omc/bin/
|
||||
|
||||
linuxES: $(PARACOMM_OBJ.ES)
|
||||
@echo Linking $(PROGS)
|
||||
@$(CC) $(CFLAGS) -o $(PROGS) $(PARACOMM_OBJ) $(LINK_SUFFIX.ES) -lm
|
||||
ar r libparaComm.a $(LIB_OBJ)
|
||||
|
||||
installbin: $(PROGS)
|
||||
cp -f $(PROGS) ../../../../bin/
|
||||
|
||||
installomc: $(PROGS)
|
||||
cp -f $(PROGS) /usr/local/omc/bin/
|
||||
|
||||
installall: installbin installomc
|
||||
|
||||
paraCommMain.o: paraCommMain.c
|
||||
$(CC) $(CFLAGS) -c paraCommMain.c $(dbINCLUDEFLAG)
|
||||
|
||||
paraComm.o: paraComm.c
|
||||
$(CC) $(CFLAGS) -c paraComm.c $(dbINCLUDEFLAG)
|
||||
|
||||
initParaConf.o: initParaConf.c
|
||||
$(CC) $(CFLAGS) -c initParaConf.c $(dbINCLUDEFLAG)
|
||||
|
||||
paraCommMain.o.ES: paraCommMain.c
|
||||
$(CC) $(CFLAGS) -c paraCommMain.c $(dbINCLUDEFLAG.ES)
|
||||
|
||||
paraComm.o.ES: paraComm.c
|
||||
$(CC) $(CFLAGS) -c paraComm.c $(dbINCLUDEFLAG.ES)
|
||||
|
||||
initParaConf.o.ES: initParaConf.c
|
||||
$(CC) $(CFLAGS) -c initParaConf.c $(dbINCLUDEFLAG.ES)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(PROGS)
|
||||
478
src/configMgr/c_program/paraComm/initParaConf.c
Normal file
478
src/configMgr/c_program/paraComm/initParaConf.c
Normal file
@@ -0,0 +1,478 @@
|
||||
/*************************************************
|
||||
File name: initParaConf.c
|
||||
Author: Cui Ticun
|
||||
Version: 9.00.00
|
||||
Date: 2007-7-1
|
||||
Description:This file init every modules' paraConf table from MIB files,
|
||||
It includes the function 'int initDbFromMib()',which is called by paraCommInit.
|
||||
It calls snmp's functions:extern int init_mib();
|
||||
extern struct tree *getLGCroot();
|
||||
extern struct tree *get_tree(const int *oid, int oidlen, struct tree *subtree);
|
||||
extern void close_mib();
|
||||
|
||||
History:
|
||||
No.
|
||||
Author
|
||||
Date
|
||||
Version
|
||||
Description
|
||||
*************************************************/
|
||||
|
||||
#include "paraComm.h"
|
||||
|
||||
#define SYSTEM_TYPE 355
|
||||
|
||||
static MYSQL *dbConn;
|
||||
char indexsQuery[10240];
|
||||
extern FILE *paraCommLog;
|
||||
|
||||
void preOrderMibTree(struct tree *mibTree);
|
||||
void orderEnums(struct enum_list *enums,char *str);
|
||||
void orderIndexes(struct index_list *indexes,char *str);
|
||||
//BYTE str2oid(char *str, DWORD * array, BYTE max);
|
||||
BYTE str2oid(char *str, int * array, BYTE max);
|
||||
|
||||
#define MAX_MODULE_NUMBER 64
|
||||
int global_mod_index;
|
||||
//DWORD global_mod_oids[MAX_MODULE_NUMBER][32];
|
||||
int global_mod_oids[MAX_MODULE_NUMBER][32];
|
||||
int global_mod_systype[MAX_MODULE_NUMBER];
|
||||
/*=
|
||||
{
|
||||
{1373,2,3,3,2,2},
|
||||
{1373,2,3,3,64,2}
|
||||
};
|
||||
|
||||
int global_mod_systype[global_mod_total]={320,355};
|
||||
*/
|
||||
|
||||
|
||||
/*************************************************
|
||||
Function: // initDbFromMib
|
||||
Description: // Get oid info from MIB file and init the paramConf tables.
|
||||
Calls: // extern int init_mib();extern struct tree *getLGCroot();extern struct get_tree;extern void close_mib();
|
||||
Called By: // paraCommInit();
|
||||
Table Accessed: //
|
||||
Table Updated: // paramConf
|
||||
Input: //
|
||||
Output: //
|
||||
Return: // 1:OK,0:error
|
||||
Others: //
|
||||
*************************************************/
|
||||
int initDbFromMib()
|
||||
{
|
||||
//DWORD oidArr[32]={ 1373, 2, 3, 3, 2, 2 };
|
||||
struct tree *tmpLGCRoot;
|
||||
struct tree *mibTree;
|
||||
int i,oidlen;
|
||||
char tmpSql[10240];
|
||||
int mod_total;
|
||||
MYSQL_RES *res=NULL;
|
||||
MYSQL_ROW rows;
|
||||
|
||||
|
||||
//init db connect
|
||||
dbConn = mysql_conn(HOSTNAME, PUB_DB);
|
||||
if (dbConn == NULL) {
|
||||
omcLog(paraCommLog,"[ERR][initDbFromMib]:mysql connect OMC_PUB");
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//memset(global_mod_oids,0,sizeof(DWORD)*32*MAX_MODULE_NUMBER);
|
||||
memset(global_mod_oids,0,sizeof(int)*32*MAX_MODULE_NUMBER);
|
||||
sprintf(tmpSql, "SELECT sysTypeNo,entryOid FROM sysMibConf WHERE isEnable = '1' ");
|
||||
|
||||
res = (MYSQL_RES *) mysql_getres(dbConn, tmpSql);
|
||||
|
||||
if(res == NULL)
|
||||
{
|
||||
omcLog(paraCommLog, " Database may be stopped,when initDbFromMib");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
global_mod_index=0;
|
||||
mod_total=0;
|
||||
while ((rows = mysql_fetch_row(res)))
|
||||
{
|
||||
if(mod_total >= MAX_MODULE_NUMBER)
|
||||
{
|
||||
omcLog(paraCommLog,"The number pf mib files is too large");
|
||||
break;
|
||||
}
|
||||
|
||||
//mod_oids[mod_total]
|
||||
global_mod_systype[mod_total]=atoi(rows[0]);
|
||||
oidlen=str2oid(rows[1],global_mod_oids[mod_total],20);
|
||||
/*
|
||||
for(i=0;i<oidlen+1;i++)
|
||||
printf("%d.",global_mod_oids[mod_total][i]);
|
||||
printf("\n");
|
||||
*/
|
||||
mod_total++;
|
||||
}
|
||||
|
||||
mysql_free_result(res);
|
||||
|
||||
init_mib();
|
||||
tmpLGCRoot=getLGCroot();
|
||||
|
||||
for(global_mod_index=0;global_mod_index<mod_total;global_mod_index++)
|
||||
{
|
||||
sprintf(tmpSql,"DELETE FROM OBJ_%d.paramConf",global_mod_systype[global_mod_index]);
|
||||
mysql_getnores(dbConn,tmpSql);
|
||||
|
||||
mibTree=get_tree((int*)global_mod_oids[global_mod_index],6,tmpLGCRoot);
|
||||
|
||||
if(mibTree==tmpLGCRoot || mibTree->subid != global_mod_oids[global_mod_index][5]){
|
||||
printf("Cannot find the OID in MIB File:");
|
||||
for(i=0;i<6;i++){
|
||||
printf("%ld.",global_mod_oids[global_mod_index][i]);
|
||||
}
|
||||
printf("\n");
|
||||
exit(1);
|
||||
}
|
||||
// indexsQuery[0]=0;
|
||||
memset(&indexsQuery[0], 0x00, sizeof(indexsQuery));
|
||||
preOrderMibTree(mibTree);
|
||||
strcat(indexsQuery,")");
|
||||
|
||||
//Modify Index's access from MIB_ACCESS_READWRITE to MIB_ACCESS_CREATE
|
||||
if(strlen(indexsQuery)>3)
|
||||
{
|
||||
sprintf(tmpSql,"UPDATE OBJ_%d.paramConf SET maxAccess='%d' WHERE maxAccess='%d' AND %s",
|
||||
global_mod_systype[global_mod_index],MIB_ACCESS_CREATE,MIB_ACCESS_READWRITE,indexsQuery);
|
||||
mysql_getnores(dbConn,tmpSql);
|
||||
}
|
||||
|
||||
sprintf(tmpSql,"UPDATE OBJ_%d.paramConf SET operType='%d' WHERE name_2 LIKE '%%CreateTimeStamp'",
|
||||
global_mod_systype[global_mod_index],DO_NOT_DISPLAY);
|
||||
//printf("tmpSql=%s\n",tmpSql);
|
||||
mysql_getnores(dbConn,tmpSql);
|
||||
|
||||
sprintf(tmpSql,"UPDATE OBJ_%d.paramConf SET operType='%d' WHERE name_2 LIKE '%%AdministrationState'",
|
||||
global_mod_systype[global_mod_index],LABEL);
|
||||
//printf("tmpSql=%s\n",tmpSql);
|
||||
mysql_getnores(dbConn,tmpSql);
|
||||
}
|
||||
close_mib();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // preOrderBinTree
|
||||
Description: // Preorder traversal the mibtree(bintree)
|
||||
Calls: //
|
||||
Called By: // initDbFromMib
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: // struct tree *mibTree
|
||||
Output: //
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void preOrderMibTree(struct tree *mibTree)
|
||||
{
|
||||
int i;
|
||||
//16384
|
||||
char tmpStr[40960];
|
||||
char tmpStr1[20480];
|
||||
char tmpSql[40960];
|
||||
|
||||
char tmpEnumsList[1024];
|
||||
char tmpIndexesList[1024];
|
||||
char *onePart;
|
||||
char *anotherPart;
|
||||
int tmpLen;
|
||||
char *tempc;
|
||||
char name[128];
|
||||
char desc[2048];
|
||||
|
||||
if(mibTree){
|
||||
//printf("%s\n",mibTree->label);
|
||||
sprintf(tmpSql,"REPLACE INTO OBJ_%d.paramConf SET ",global_mod_systype[global_mod_index]);
|
||||
// name
|
||||
sprintf(tmpStr,"name_1='%s',name_2='%s'",mibTree->label,mibTree->label);
|
||||
strcat(tmpSql,tmpStr);
|
||||
|
||||
|
||||
sprintf(name,"none");
|
||||
if(mibTree->description && strstr(mibTree->description,"Name:")!=NULL)
|
||||
{
|
||||
sprintf(desc,mibTree->description);
|
||||
tempc=strstr(desc,"\n");
|
||||
if(tempc != NULL)
|
||||
*tempc=0;
|
||||
tempc=strstr(desc,"Name:");
|
||||
if(tempc == NULL)
|
||||
{
|
||||
sprintf(name,"none");
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(name,"%s",tempc+5);
|
||||
//printf("%s\n",name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Description
|
||||
if(mibTree->indexes){
|
||||
if(mibTree->description && !strstr(mibTree->description,"Description."))
|
||||
sprintf(tmpStr,",desc_1='Table Parameter, %s',desc_2='Table Parameter, %s'",mibTree->description,mibTree->description);
|
||||
else
|
||||
{
|
||||
if(strcmp(name,"none"))
|
||||
sprintf(tmpStr,",desc_1='Table Parameter, level:1, Name:%s',desc_2='Table Parameter, level:1, Name:%s'",name,name);
|
||||
else
|
||||
sprintf(tmpStr,",desc_1='Table Parameter, level:1',desc_2='Table Parameter, level:1'");
|
||||
}
|
||||
strcat(tmpSql,tmpStr);
|
||||
}else{
|
||||
char tmpdesc[4096];
|
||||
tmpdesc[0]=0;
|
||||
if(mibTree->description)
|
||||
{
|
||||
if(strstr(mibTree->description,"Hidden Flag:Yes"))
|
||||
{
|
||||
strcat(tmpdesc,"Hidden Parameter;");
|
||||
}
|
||||
else if(strstr(mibTree->description,"Key Parameter:Yes"))
|
||||
{
|
||||
strcat(tmpdesc,"Key Parameter;");
|
||||
}
|
||||
else if(strstr(mibTree->description,"PASSWORD:Visible"))
|
||||
{
|
||||
strcat(tmpdesc,"PASSWORD:Visible;");
|
||||
}
|
||||
else if(strstr(mibTree->description,"PASSWORD:Invisible"))
|
||||
{
|
||||
strcat(tmpdesc,"PASSWORD:Invisible;");
|
||||
}
|
||||
|
||||
if(strcmp(name,"none"))
|
||||
{
|
||||
sprintf(tmpStr,"Name:%s;",name);
|
||||
strcat(tmpdesc,tmpStr);
|
||||
}
|
||||
|
||||
if((tempc=strstr(mibTree->description,"RelationPoint:")))
|
||||
{
|
||||
char *tempc1=NULL;
|
||||
|
||||
tempc1=strstr(tempc,"\n");
|
||||
if(tempc1 != NULL)
|
||||
*tempc1=0;
|
||||
sprintf(tmpStr,"%s;",tempc);
|
||||
strcat(tmpdesc,tmpStr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(strlen(tmpdesc)>0)
|
||||
{
|
||||
sprintf(tmpStr,",desc_1='%s',desc_2='%s'",tmpdesc,tmpdesc);
|
||||
strcat(tmpSql,tmpStr);
|
||||
}
|
||||
/*
|
||||
|
||||
if(mibTree->description&&strstr(mibTree->description,"Hidden Flag:Yes"))
|
||||
{
|
||||
sprintf(tmpStr,",desc_1='Hidden Parameter',desc_2='Hidden Parameter'");
|
||||
strcat(tmpSql,tmpStr);
|
||||
}
|
||||
else if(mibTree->description&&
|
||||
strstr(mibTree->description,"Key Parameter:Yes")){
|
||||
if(strcmp(name,"none"))
|
||||
sprintf(tmpStr,",desc_1='Key Parameter, Name:%s',desc_2='Key Parameter, Name:%s'",name,name);
|
||||
else
|
||||
sprintf(tmpStr,",desc_1='Key Parameter',desc_2='Key Parameter'");
|
||||
strcat(tmpSql,tmpStr);
|
||||
}
|
||||
else if(strcmp(name,"none"))
|
||||
{
|
||||
sprintf(tmpStr,",desc_1='Name:%s',desc_2='Name:%s'",name,name);
|
||||
strcat(tmpSql,tmpStr);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//OPAQUE DECODE RULE:
|
||||
if(mibTree->description){
|
||||
if((onePart=strstr(mibTree->description,"OPAQUE DECODE RULE:"))){
|
||||
|
||||
strsep(&(onePart),":");
|
||||
if((anotherPart=strstr(mibTree->description,"Remark:")))
|
||||
strncpy(tmpStr1,onePart,(anotherPart-onePart));
|
||||
else
|
||||
strcpy(tmpStr1,onePart);
|
||||
sprintf(tmpStr,",setTemplate_1='%s',setTemplate_2='%s'",tmpStr1,tmpStr1);
|
||||
strcat(tmpSql,tmpStr);
|
||||
}
|
||||
}
|
||||
|
||||
if(mibTree->description){
|
||||
//Note
|
||||
if((onePart=strstr(mibTree->description,"Remark:"))){
|
||||
strsep(&(onePart),":");
|
||||
if(onePart){
|
||||
sprintf(tmpStr,",note_1=\"%s\",note_2=\"%s\"",onePart,onePart);
|
||||
strcat(tmpSql,tmpStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Max Access
|
||||
sprintf(tmpStr,",maxAccess='%d'",mibTree->access);
|
||||
strcat(tmpSql,tmpStr);
|
||||
|
||||
//operType
|
||||
if(mibTree->access==MIB_ACCESS_READONLY){
|
||||
sprintf(tmpStr,",operType='%d'",LABEL);
|
||||
strcat(tmpSql,tmpStr);
|
||||
}else if(mibTree->access==MIB_ACCESS_NOACCESS){
|
||||
sprintf(tmpStr,",operType='%d'",DO_NOT_DISPLAY);
|
||||
strcat(tmpSql,tmpStr);
|
||||
}else{
|
||||
if(mibTree->type==TYPE_INTEGER&&mibTree->enums){
|
||||
sprintf(tmpStr,",operType='%d'",PULLDOWN_MENU);
|
||||
strcat(tmpSql,tmpStr);
|
||||
}else{
|
||||
sprintf(tmpStr,",operType='%d'",TEXTBOX);
|
||||
strcat(tmpSql,tmpStr);
|
||||
}
|
||||
}
|
||||
|
||||
//valueType
|
||||
sprintf(tmpStr,",valueType='%d'",mibTree->type);
|
||||
strcat(tmpSql,tmpStr);
|
||||
|
||||
//initValue
|
||||
if(mibTree->defaultValue){
|
||||
sprintf(tmpStr,",initValue='%s'",mibTree->defaultValue);
|
||||
strcat(tmpSql,tmpStr);
|
||||
}
|
||||
|
||||
//minValue
|
||||
//maxValue
|
||||
if(mibTree->ranges){
|
||||
sprintf(tmpStr,",`minValue`='%d',`maxValue`='%d'",mibTree->ranges->low,mibTree->ranges->high);
|
||||
strcat(tmpSql,tmpStr);
|
||||
}
|
||||
|
||||
//template
|
||||
if(mibTree->enums){
|
||||
tmpEnumsList[0]=0;
|
||||
orderEnums(mibTree->enums,tmpEnumsList);
|
||||
|
||||
tmpLen=strlen(tmpEnumsList);
|
||||
tmpEnumsList[tmpLen-1]=0;
|
||||
|
||||
sprintf(tmpStr,",setTemplate_1='%s',setTemplate_2='%s'",tmpEnumsList,tmpEnumsList);
|
||||
strcat(tmpSql,tmpStr);
|
||||
}else if(mibTree->indexes){
|
||||
tmpIndexesList[0]=0;
|
||||
orderIndexes(mibTree->indexes,tmpIndexesList);
|
||||
|
||||
tmpLen=strlen(tmpIndexesList);
|
||||
tmpIndexesList[tmpLen-1]=0;
|
||||
|
||||
sprintf(tmpStr,",setTemplate_1='%s',setTemplate_2='%s'",tmpIndexesList,tmpIndexesList);
|
||||
strcat(tmpSql,tmpStr);
|
||||
}
|
||||
|
||||
//level_x
|
||||
for(i=11;i<mibTree->oid_len;i++){
|
||||
sprintf(tmpStr,",level_%d=%d",i-10,mibTree->oid[i]);
|
||||
strcat(tmpSql,tmpStr);
|
||||
}
|
||||
|
||||
if(mysql_getnores(dbConn,tmpSql)<0){
|
||||
printf("\n%s\n",tmpSql);
|
||||
}
|
||||
|
||||
/*
|
||||
for(i=0;i<mibTree->oid_len;i++){
|
||||
printf("%d.",mibTree->oid[i]);
|
||||
}
|
||||
printf("\n");
|
||||
*/
|
||||
preOrderMibTree(mibTree->child_list);
|
||||
preOrderMibTree(mibTree->next_peer);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // orderEnums
|
||||
Description: // construct the list of enumerated integers to a string
|
||||
Calls: //
|
||||
Called By: // preOrderMibTree
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: // struct enum_list *enums,
|
||||
Output: // char *str
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void orderEnums(struct enum_list *enums,char *str)
|
||||
{
|
||||
char tmpStr[64];
|
||||
if(enums){
|
||||
sprintf(tmpStr,"%s=%d;",enums->label,enums->value);
|
||||
strcat(str,tmpStr);
|
||||
orderEnums(enums->next,str);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Function: // orderIndexes
|
||||
Description: // construct the list of enumerated indexes to a string
|
||||
Calls: //
|
||||
Called By: // preOrderMibTree
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: // struct index_list *indexes
|
||||
Output: // char *str
|
||||
Return: //
|
||||
Others: //
|
||||
*************************************************/
|
||||
void orderIndexes(struct index_list *indexes,char *str)
|
||||
{
|
||||
char tmpStr[64];
|
||||
if(indexes){
|
||||
sprintf(tmpStr,"%s;",indexes->ilabel);
|
||||
strcat(str,tmpStr);
|
||||
if(strlen(indexsQuery)>0)
|
||||
sprintf(tmpStr," OR name_2='%s'",indexes->ilabel);
|
||||
else
|
||||
sprintf(tmpStr," (name_2='%s'",indexes->ilabel);
|
||||
strcat(indexsQuery,tmpStr);
|
||||
orderIndexes(indexes->next,str);
|
||||
}
|
||||
}
|
||||
|
||||
//BYTE str2oid(char *str, DWORD * array, BYTE max)
|
||||
BYTE str2oid(char *str, int * array, BYTE max)
|
||||
{
|
||||
BYTE sub = 0;
|
||||
short len, i;
|
||||
char *pvar;
|
||||
len = strlen(str);
|
||||
pvar = str;
|
||||
for (i = 0; i < len && sub < max; i++) {
|
||||
if (str[i] == '.') {
|
||||
str[i] = '\0';
|
||||
if (strlen(pvar) == 0)
|
||||
continue;
|
||||
array[sub++] = atoi(pvar);
|
||||
pvar = str + i + 1;
|
||||
}
|
||||
}
|
||||
if (strlen(pvar) == 0)
|
||||
return sub;
|
||||
array[sub++] = atoi(pvar);
|
||||
return sub;
|
||||
}
|
||||
656
src/configMgr/c_program/paraComm/mib/LGC-MIB.my
Normal file
656
src/configMgr/c_program/paraComm/mib/LGC-MIB.my
Normal file
@@ -0,0 +1,656 @@
|
||||
--
|
||||
-- LGC-MIB-070927.my
|
||||
-- MIB generated by MG-SOFT Visual MIB Builder Version 7.0 Build 209
|
||||
-- Thursday, September 27, 2007 at 09:40:50
|
||||
--
|
||||
|
||||
LGC-MIB DEFINITIONS ::= BEGIN
|
||||
|
||||
IMPORTS
|
||||
enterprises, TimeTicks, MODULE-IDENTITY
|
||||
FROM SNMPv2-SMI
|
||||
TEXTUAL-CONVENTION
|
||||
FROM SNMPv2-TC;
|
||||
|
||||
|
||||
-- 1.3.6.1.4.1.1373.2
|
||||
lgcSS MODULE-IDENTITY
|
||||
LAST-UPDATED "200706041222Z" -- June 04, 2007 at 12:22 GMT
|
||||
ORGANIZATION
|
||||
"LGC Wireless"
|
||||
CONTACT-INFO
|
||||
"lcrd
|
||||
lcrdsupport@lgcwireless.com"
|
||||
DESCRIPTION
|
||||
"The MIB module for lgcWireless's Softswitch products."
|
||||
REVISION "200706041223Z" -- June 04, 2007 at 12:23 GMT
|
||||
DESCRIPTION
|
||||
"This is the first release version of the MIB"
|
||||
::= { lgcNS 2 }
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Type definitions
|
||||
--
|
||||
|
||||
AdminStateChoices ::= INTEGER
|
||||
{
|
||||
locked(0),
|
||||
unlocked(1),
|
||||
shutDown(2)
|
||||
}
|
||||
|
||||
OperStateChoices ::= INTEGER
|
||||
{
|
||||
disable(0),
|
||||
enable(1)
|
||||
}
|
||||
|
||||
AvailStateChoices ::= INTEGER
|
||||
{
|
||||
inTest(0),
|
||||
failed(1),
|
||||
powerOff(2),
|
||||
offLine(3),
|
||||
onLine(4),
|
||||
dependency(5),
|
||||
degraded(6),
|
||||
notInstalled(7)
|
||||
}
|
||||
|
||||
|
||||
--
|
||||
-- Textual conventions
|
||||
--
|
||||
|
||||
-- TEXTUAL-CONVENTION MACRO ::=
|
||||
-- BEGIN
|
||||
-- TYPE NOTATION ::=
|
||||
-- DisplayPart
|
||||
-- "STATUS" Status
|
||||
-- "DESCRIPTION" Text
|
||||
-- ReferPart
|
||||
-- "SYNTAX" Syntax
|
||||
--
|
||||
-- VALUE NOTATION ::=
|
||||
-- value(VALUE Syntax)
|
||||
--
|
||||
-- DisplayPart ::=
|
||||
-- "DISPLAY-HINT" Text
|
||||
-- | empty
|
||||
--
|
||||
-- Status ::=
|
||||
-- "current"
|
||||
-- | "deprecated"
|
||||
-- | "obsolete"
|
||||
--
|
||||
-- ReferPart ::=
|
||||
-- "REFERENCE" Text
|
||||
-- | empty
|
||||
--
|
||||
-- -- -- uses the NVT ASCII character set
|
||||
-- Text ::= """" string """"
|
||||
--
|
||||
-- Syntax ::=
|
||||
-- type(ObjectSyntax)
|
||||
-- | "BITS" "{" Kibbles "}"
|
||||
-- Kibbles ::=
|
||||
-- Kibble
|
||||
-- | Kibbles "," Kibble
|
||||
-- Kibble ::=
|
||||
-- identifier "(" nonNegativeNumber ")"
|
||||
-- END
|
||||
DisplayString8 ::= TEXTUAL-CONVENTION
|
||||
DISPLAY-HINT
|
||||
"8a"
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"Represents textual information taken from the NVT ASCII
|
||||
character set, as defined in pages 4, 10-11 of RFC 854.
|
||||
|
||||
To summarize RFC 854, the NVT ASCII repertoire specifies:
|
||||
|
||||
- the use of character codes 0-127 (decimal)
|
||||
|
||||
- the graphics characters (32-126) are interpreted as
|
||||
US ASCII
|
||||
|
||||
- NUL, LF, CR, BEL, BS, HT, VT and FF have the special
|
||||
meanings specified in RFC 854
|
||||
|
||||
- the other 25 codes have no standard interpretation
|
||||
|
||||
- the sequence 'CR LF' means newline
|
||||
|
||||
- the sequence 'CR NUL' means carriage-return
|
||||
|
||||
- an 'LF' not preceded by a 'CR' means moving to the
|
||||
same column on the next line.
|
||||
|
||||
- the sequence 'CR x' for any x other than LF or NUL is
|
||||
illegal. (Note that this also means that a string may
|
||||
end with either 'CR LF' or 'CR NUL', but not with CR.)
|
||||
|
||||
Any object defined using this syntax may not exceed 255
|
||||
characters in length."
|
||||
SYNTAX OCTET STRING (SIZE (0..8))
|
||||
|
||||
DisplayString16 ::= TEXTUAL-CONVENTION
|
||||
DISPLAY-HINT
|
||||
"16a"
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"A version of DisplayString that contains only 16 characters most."
|
||||
SYNTAX OCTET STRING (SIZE (0..16))
|
||||
|
||||
DisplayString32 ::= TEXTUAL-CONVENTION
|
||||
DISPLAY-HINT
|
||||
"32a"
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"A version of DisplayString that contains only 32 characters most."
|
||||
SYNTAX OCTET STRING (SIZE (0..32))
|
||||
|
||||
DisplayString64 ::= TEXTUAL-CONVENTION
|
||||
DISPLAY-HINT
|
||||
"64a"
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"A version of DisplayString that contains only 64 characters most."
|
||||
SYNTAX OCTET STRING (SIZE (0..64))
|
||||
|
||||
DisplayString ::= TEXTUAL-CONVENTION
|
||||
DISPLAY-HINT
|
||||
"255a"
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"A version of DisplayString that contains only 255 characters most."
|
||||
SYNTAX OCTET STRING (SIZE (0..255))
|
||||
|
||||
RowStatus ::= TEXTUAL-CONVENTION
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"The RowStatus textual convention is used to manage the
|
||||
creation and deletion of conceptual rows, and is used as the
|
||||
value of the SYNTAX clause for the status column of a
|
||||
conceptual row (as described in Section 7.7.1 of [2].)
|
||||
|
||||
The status column has six defined values:
|
||||
|
||||
- `active', which indicates that the conceptual row is
|
||||
available for use by the managed device;
|
||||
|
||||
- `notInService', which indicates that the conceptual
|
||||
row exists in the agent, but is unavailable for use by
|
||||
the managed device (see NOTE below);
|
||||
|
||||
- `notReady', which indicates that the conceptual row
|
||||
exists in the agent, but is missing information
|
||||
necessary in order to be available for use by the
|
||||
managed device;
|
||||
|
||||
- `createAndGo', which is supplied by a management
|
||||
station wishing to create a new instance of a
|
||||
conceptual row and to have its status automatically set
|
||||
to active, making it available for use by the managed
|
||||
device;
|
||||
|
||||
- `createAndWait', which is supplied by a management
|
||||
station wishing to create a new instance of a
|
||||
conceptual row (but not make it available for use by
|
||||
the managed device); and,
|
||||
|
||||
- `destroy', which is supplied by a management station
|
||||
wishing to delete all of the instances associated with
|
||||
an existing conceptual row.
|
||||
|
||||
Whereas five of the six values (all except `notReady') may
|
||||
be specified in a management protocol set operation, only
|
||||
three values will be returned in response to a management
|
||||
protocol retrieval operation: `notReady', `notInService' or
|
||||
`active'. That is, when queried, an existing conceptual row
|
||||
has only three states: it is either available for use by
|
||||
the managed device (the status column has value `active');
|
||||
it is not available for use by the managed device, though
|
||||
the agent has sufficient information to make it so (the
|
||||
status column has value `notInService'); or, it is not
|
||||
available for use by the managed device, and an attempt to
|
||||
make it so would fail because the agent has insufficient
|
||||
information (the state column has value `notReady').
|
||||
|
||||
NOTE WELL
|
||||
|
||||
This textual convention may be used for a MIB table,
|
||||
irrespective of whether the values of that table's
|
||||
conceptual rows are able to be modified while it is
|
||||
active, or whether its conceptual rows must be taken
|
||||
out of service in order to be modified. That is, it is
|
||||
the responsibility of the DESCRIPTION clause of the
|
||||
status column to specify whether the status column must
|
||||
not be `active' in order for the value of some other
|
||||
column of the same conceptual row to be modified. If
|
||||
such a specification is made, affected columns may be
|
||||
changed by an SNMP set PDU if the RowStatus would not
|
||||
be equal to `active' either immediately before or after
|
||||
processing the PDU. In other words, if the PDU also
|
||||
contained a varbind that would change the RowStatus
|
||||
value, the column in question may be changed if the
|
||||
RowStatus was not equal to `active' as the PDU was
|
||||
received, or if the varbind sets the status to a value
|
||||
other than 'active'.
|
||||
|
||||
|
||||
Also note that whenever any elements of a row exist, the
|
||||
RowStatus column must also exist.
|
||||
|
||||
To summarize the effect of having a conceptual row with a
|
||||
status column having a SYNTAX clause value of RowStatus,
|
||||
consider the following state diagram:
|
||||
|
||||
|
||||
STATE
|
||||
+--------------+-----------+-------------+-------------
|
||||
| A | B | C | D
|
||||
| |status col.|status column|
|
||||
|status column | is | is |status column
|
||||
ACTION |does not exist| notReady | notInService| is active
|
||||
--------------+--------------+-----------+-------------+-------------
|
||||
set status |noError ->D|inconsist- |inconsistent-|inconsistent-
|
||||
column to | or | entValue| Value| Value
|
||||
createAndGo |inconsistent- | | |
|
||||
| Value| | |
|
||||
--------------+--------------+-----------+-------------+-------------
|
||||
set status |noError see 1|inconsist- |inconsistent-|inconsistent-
|
||||
column to | or | entValue| Value| Value
|
||||
createAndWait |wrongValue | | |
|
||||
--------------+--------------+-----------+-------------+-------------
|
||||
set status |inconsistent- |inconsist- |noError |noError
|
||||
column to | Value| entValue| |
|
||||
active | | | |
|
||||
| | or | |
|
||||
| | | |
|
||||
| |see 2 ->D| ->D| ->D
|
||||
--------------+--------------+-----------+-------------+-------------
|
||||
set status |inconsistent- |inconsist- |noError |noError ->C
|
||||
column to | Value| entValue| |
|
||||
notInService | | | |
|
||||
| | or | | or
|
||||
| | | |
|
||||
| |see 3 ->C| ->C|wrongValue
|
||||
--------------+--------------+-----------+-------------+-------------
|
||||
set status |noError |noError |noError |noError
|
||||
column to | | | |
|
||||
destroy | ->A| ->A| ->A| ->A
|
||||
--------------+--------------+-----------+-------------+-------------
|
||||
set any other |see 4 |noError |noError |see 5
|
||||
column to some| | | |
|
||||
value | | see 1| ->C| ->D
|
||||
--------------+--------------+-----------+-------------+-------------
|
||||
|
||||
(1) goto B or C, depending on information available to the
|
||||
agent.
|
||||
|
||||
(2) if other variable bindings included in the same PDU,
|
||||
provide values for all columns which are missing but
|
||||
required, then return noError and goto D.
|
||||
|
||||
(3) if other variable bindings included in the same PDU,
|
||||
provide values for all columns which are missing but
|
||||
required, then return noError and goto C.
|
||||
|
||||
(4) at the discretion of the agent, the return value may be
|
||||
either:
|
||||
|
||||
inconsistentName: because the agent does not choose to
|
||||
create such an instance when the corresponding
|
||||
RowStatus instance does not exist, or
|
||||
|
||||
inconsistentValue: if the supplied value is
|
||||
inconsistent with the state of some other MIB object's
|
||||
value, or
|
||||
|
||||
noError: because the agent chooses to create the
|
||||
instance.
|
||||
|
||||
If noError is returned, then the instance of the status
|
||||
column must also be created, and the new state is B or C,
|
||||
depending on the information available to the agent. If
|
||||
inconsistentName or inconsistentValue is returned, the row
|
||||
remains in state A.
|
||||
|
||||
(5) depending on the MIB definition for the column/table,
|
||||
either noError or inconsistentValue may be returned.
|
||||
|
||||
NOTE: Other processing of the set request may result in a
|
||||
response other than noError being returned, e.g.,
|
||||
wrongValue, noCreation, etc.
|
||||
|
||||
|
||||
Conceptual Row Creation
|
||||
|
||||
There are four potential interactions when creating a
|
||||
conceptual row: selecting an instance-identifier which is
|
||||
not in use; creating the conceptual row; initializing any
|
||||
objects for which the agent does not supply a default; and,
|
||||
making the conceptual row available for use by the managed
|
||||
device.
|
||||
|
||||
Interaction 1: Selecting an Instance-Identifier
|
||||
|
||||
The algorithm used to select an instance-identifier varies
|
||||
for each conceptual row. In some cases, the instance-
|
||||
identifier is semantically significant, e.g., the
|
||||
destination address of a route, and a management station
|
||||
selects the instance-identifier according to the semantics.
|
||||
|
||||
In other cases, the instance-identifier is used solely to
|
||||
distinguish conceptual rows, and a management station
|
||||
without specific knowledge of the conceptual row might
|
||||
examine the instances present in order to determine an
|
||||
unused instance-identifier. (This approach may be used, but
|
||||
it is often highly sub-optimal; however, it is also a
|
||||
questionable practice for a naive management station to
|
||||
attempt conceptual row creation.)
|
||||
|
||||
Alternately, the MIB module which defines the conceptual row
|
||||
might provide one or more objects which provide assistance
|
||||
in determining an unused instance-identifier. For example,
|
||||
if the conceptual row is indexed by an integer-value, then
|
||||
an object having an integer-valued SYNTAX clause might be
|
||||
defined for such a purpose, allowing a management station to
|
||||
issue a management protocol retrieval operation. In order
|
||||
to avoid unnecessary collisions between competing management
|
||||
stations, `adjacent' retrievals of this object should be
|
||||
different.
|
||||
|
||||
Finally, the management station could select a pseudo-random
|
||||
number to use as the index. In the event that this index
|
||||
was already in use and an inconsistentValue was returned in
|
||||
response to the management protocol set operation, the
|
||||
management station should simply select a new pseudo-random
|
||||
number and retry the operation.
|
||||
|
||||
A MIB designer should choose between the two latter
|
||||
algorithms based on the size of the table (and therefore the
|
||||
efficiency of each algorithm). For tables in which a large
|
||||
number of entries are expected, it is recommended that a MIB
|
||||
object be defined that returns an acceptable index for
|
||||
creation. For tables with small numbers of entries, it is
|
||||
recommended that the latter pseudo-random index mechanism be
|
||||
used.
|
||||
|
||||
|
||||
Interaction 2: Creating the Conceptual Row
|
||||
|
||||
Once an unused instance-identifier has been selected, the
|
||||
management station determines if it wishes to create and
|
||||
activate the conceptual row in one transaction or in a
|
||||
negotiated set of interactions.
|
||||
|
||||
Interaction 2a: Creating and Activating the Conceptual Row
|
||||
|
||||
The management station must first determine the column
|
||||
requirements, i.e., it must determine those columns for
|
||||
which it must or must not provide values. Depending on the
|
||||
complexity of the table and the management station's
|
||||
knowledge of the agent's capabilities, this determination
|
||||
can be made locally by the management station. Alternately,
|
||||
the management station issues a management protocol get
|
||||
operation to examine all columns in the conceptual row that
|
||||
it wishes to create. In response, for each column, there
|
||||
are three possible outcomes:
|
||||
|
||||
- a value is returned, indicating that some other
|
||||
management station has already created this conceptual
|
||||
row. We return to interaction 1.
|
||||
|
||||
- the exception `noSuchInstance' is returned,
|
||||
indicating that the agent implements the object-type
|
||||
associated with this column, and that this column in at
|
||||
least one conceptual row would be accessible in the MIB
|
||||
view used by the retrieval were it to exist. For those
|
||||
columns to which the agent provides read-create access,
|
||||
the `noSuchInstance' exception tells the management
|
||||
station that it should supply a value for this column
|
||||
when the conceptual row is to be created.
|
||||
|
||||
- the exception `noSuchObject' is returned, indicating
|
||||
that the agent does not implement the object-type
|
||||
associated with this column or that there is no
|
||||
conceptual row for which this column would be
|
||||
accessible in the MIB view used by the retrieval. As
|
||||
such, the management station can not issue any
|
||||
management protocol set operations to create an
|
||||
instance of this column.
|
||||
|
||||
Once the column requirements have been determined, a
|
||||
management protocol set operation is accordingly issued.
|
||||
This operation also sets the new instance of the status
|
||||
column to `createAndGo'.
|
||||
|
||||
When the agent processes the set operation, it verifies that
|
||||
it has sufficient information to make the conceptual row
|
||||
available for use by the managed device. The information
|
||||
available to the agent is provided by two sources: the
|
||||
management protocol set operation which creates the
|
||||
conceptual row, and, implementation-specific defaults
|
||||
supplied by the agent (note that an agent must provide
|
||||
implementation-specific defaults for at least those objects
|
||||
which it implements as read-only). If there is sufficient
|
||||
information available, then the conceptual row is created, a
|
||||
`noError' response is returned, the status column is set to
|
||||
`active', and no further interactions are necessary (i.e.,
|
||||
interactions 3 and 4 are skipped). If there is insufficient
|
||||
information, then the conceptual row is not created, and the
|
||||
set operation fails with an error of `inconsistentValue'.
|
||||
On this error, the management station can issue a management
|
||||
protocol retrieval operation to determine if this was
|
||||
because it failed to specify a value for a required column,
|
||||
or, because the selected instance of the status column
|
||||
already existed. In the latter case, we return to
|
||||
interaction 1. In the former case, the management station
|
||||
can re-issue the set operation with the additional
|
||||
information, or begin interaction 2 again using
|
||||
`createAndWait' in order to negotiate creation of the
|
||||
conceptual row.
|
||||
|
||||
NOTE WELL
|
||||
|
||||
Regardless of the method used to determine the column
|
||||
requirements, it is possible that the management
|
||||
station might deem a column necessary when, in fact,
|
||||
the agent will not allow that particular columnar
|
||||
instance to be created or written. In this case, the
|
||||
management protocol set operation will fail with an
|
||||
error such as `noCreation' or `notWritable'. In this
|
||||
case, the management station decides whether it needs
|
||||
to be able to set a value for that particular columnar
|
||||
instance. If not, the management station re-issues the
|
||||
management protocol set operation, but without setting
|
||||
a value for that particular columnar instance;
|
||||
otherwise, the management station aborts the row
|
||||
creation algorithm.
|
||||
|
||||
Interaction 2b: Negotiating the Creation of the Conceptual
|
||||
Row
|
||||
|
||||
The management station issues a management protocol set
|
||||
operation which sets the desired instance of the status
|
||||
column to `createAndWait'. If the agent is unwilling to
|
||||
process a request of this sort, the set operation fails with
|
||||
an error of `wrongValue'. (As a consequence, such an agent
|
||||
must be prepared to accept a single management protocol set
|
||||
operation, i.e., interaction 2a above, containing all of the
|
||||
columns indicated by its column requirements.) Otherwise,
|
||||
the conceptual row is created, a `noError' response is
|
||||
returned, and the status column is immediately set to either
|
||||
`notInService' or `notReady', depending on whether it has
|
||||
sufficient information to make the conceptual row available
|
||||
for use by the managed device. If there is sufficient
|
||||
information available, then the status column is set to
|
||||
`notInService'; otherwise, if there is insufficient
|
||||
information, then the status column is set to `notReady'.
|
||||
Regardless, we proceed to interaction 3.
|
||||
|
||||
Interaction 3: Initializing non-defaulted Objects
|
||||
|
||||
The management station must now determine the column
|
||||
requirements. It issues a management protocol get operation
|
||||
to examine all columns in the created conceptual row. In
|
||||
the response, for each column, there are three possible
|
||||
outcomes:
|
||||
|
||||
- a value is returned, indicating that the agent
|
||||
implements the object-type associated with this column
|
||||
and had sufficient information to provide a value. For
|
||||
those columns to which the agent provides read-create
|
||||
access (and for which the agent allows their values to
|
||||
be changed after their creation), a value return tells
|
||||
the management station that it may issue additional
|
||||
management protocol set operations, if it desires, in
|
||||
order to change the value associated with this column.
|
||||
|
||||
- the exception `noSuchInstance' is returned,
|
||||
indicating that the agent implements the object-type
|
||||
associated with this column, and that this column in at
|
||||
least one conceptual row would be accessible in the MIB
|
||||
view used by the retrieval were it to exist. However,
|
||||
the agent does not have sufficient information to
|
||||
provide a value, and until a value is provided, the
|
||||
conceptual row may not be made available for use by the
|
||||
managed device. For those columns to which the agent
|
||||
provides read-create access, the `noSuchInstance'
|
||||
exception tells the management station that it must
|
||||
issue additional management protocol set operations, in
|
||||
order to provide a value associated with this column.
|
||||
|
||||
- the exception `noSuchObject' is returned, indicating
|
||||
that the agent does not implement the object-type
|
||||
associated with this column or that there is no
|
||||
conceptual row for which this column would be
|
||||
accessible in the MIB view used by the retrieval. As
|
||||
such, the management station can not issue any
|
||||
management protocol set operations to create an
|
||||
instance of this column.
|
||||
|
||||
If the value associated with the status column is
|
||||
`notReady', then the management station must first deal with
|
||||
all `noSuchInstance' columns, if any. Having done so, the
|
||||
value of the status column becomes `notInService', and we
|
||||
proceed to interaction 4.
|
||||
|
||||
Interaction 4: Making the Conceptual Row Available
|
||||
|
||||
Once the management station is satisfied with the values
|
||||
associated with the columns of the conceptual row, it issues
|
||||
a management protocol set operation to set the status column
|
||||
to `active'. If the agent has sufficient information to
|
||||
make the conceptual row available for use by the managed
|
||||
device, the management protocol set operation succeeds (a
|
||||
`noError' response is returned). Otherwise, the management
|
||||
protocol set operation fails with an error of
|
||||
`inconsistentValue'.
|
||||
|
||||
|
||||
NOTE WELL
|
||||
|
||||
A conceptual row having a status column with value
|
||||
`notInService' or `notReady' is unavailable to the
|
||||
managed device. As such, it is possible for the
|
||||
managed device to create its own instances during the
|
||||
time between the management protocol set operation
|
||||
which sets the status column to `createAndWait' and the
|
||||
management protocol set operation which sets the status
|
||||
column to `active'. In this case, when the management
|
||||
protocol set operation is issued to set the status
|
||||
column to `active', the values held in the agent
|
||||
supersede those used by the managed device.
|
||||
|
||||
If the management station is prevented from setting the
|
||||
status column to `active' (e.g., due to management station
|
||||
or network failure) the conceptual row will be left in the
|
||||
`notInService' or `notReady' state, consuming resources
|
||||
indefinitely. The agent must detect conceptual rows that
|
||||
have been in either state for an abnormally long period of
|
||||
time and remove them. It is the responsibility of the
|
||||
DESCRIPTION clause of the status column to indicate what an
|
||||
abnormally long period of time would be. This period of
|
||||
time should be long enough to allow for human response time
|
||||
(including `think time') between the creation of the
|
||||
conceptual row and the setting of the status to `active'.
|
||||
In the absense of such information in the DESCRIPTION
|
||||
clause, it is suggested that this period be approximately 5
|
||||
minutes in length. This removal action applies not only to
|
||||
newly-created rows, but also to previously active rows which
|
||||
are set to, and left in, the notInService state for a
|
||||
prolonged period exceeding that which is considered normal
|
||||
for such a conceptual row.
|
||||
|
||||
|
||||
Conceptual Row Suspension
|
||||
|
||||
When a conceptual row is `active', the management station
|
||||
may issue a management protocol set operation which sets the
|
||||
instance of the status column to `notInService'. If the
|
||||
agent is unwilling to do so, the set operation fails with an
|
||||
error of `wrongValue'. Otherwise, the conceptual row is
|
||||
taken out of service, and a `noError' response is returned.
|
||||
It is the responsibility of the DESCRIPTION clause of the
|
||||
status column to indicate under what circumstances the
|
||||
status column should be taken out of service (e.g., in order
|
||||
for the value of some other column of the same conceptual
|
||||
row to be modified).
|
||||
|
||||
|
||||
Conceptual Row Deletion
|
||||
|
||||
For deletion of conceptual rows, a management protocol set
|
||||
operation is issued which sets the instance of the status
|
||||
column to `destroy'. This request may be made regardless of
|
||||
the current value of the status column (e.g., it is possible
|
||||
to delete conceptual rows which are either `notReady',
|
||||
`notInService' or `active'.) If the operation succeeds,
|
||||
then all instances associated with the conceptual row are
|
||||
immediately removed."
|
||||
SYNTAX INTEGER
|
||||
{
|
||||
active(1),
|
||||
notInService(2),
|
||||
notReady(3),
|
||||
createAndGo(4),
|
||||
createAndWait(5),
|
||||
destroy(6)
|
||||
}
|
||||
|
||||
-- the following two values are states:
|
||||
-- these values may be read or written
|
||||
-- the following value is a state:
|
||||
-- this value may be read, but not written
|
||||
-- the following three values are
|
||||
-- actions: these values may be written,
|
||||
-- but are never read
|
||||
TimeStamp ::= TEXTUAL-CONVENTION
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"The value of the sysUpTime object at which a specific
|
||||
occurrence happened. The specific occurrence must be
|
||||
defined in the description of any object defined using this
|
||||
type."
|
||||
SYNTAX TimeTicks
|
||||
|
||||
|
||||
--
|
||||
-- Node definitions
|
||||
--
|
||||
|
||||
-- 1.3.6.1.4.1.1373
|
||||
lgcNS OBJECT IDENTIFIER ::= { enterprises 1373 }
|
||||
|
||||
|
||||
|
||||
END
|
||||
|
||||
--
|
||||
-- LGC-MIB-070927.my
|
||||
--
|
||||
4191
src/configMgr/c_program/paraComm/mib/LGC-SS-MSC-MIB.my
Normal file
4191
src/configMgr/c_program/paraComm/mib/LGC-SS-MSC-MIB.my
Normal file
File diff suppressed because it is too large
Load Diff
4356
src/configMgr/c_program/paraComm/mib/LGC-SS-MSC-MIB_070824.my
Normal file
4356
src/configMgr/c_program/paraComm/mib/LGC-SS-MSC-MIB_070824.my
Normal file
File diff suppressed because it is too large
Load Diff
344
src/configMgr/c_program/paraComm/mib/SNMPv2-SMI
Normal file
344
src/configMgr/c_program/paraComm/mib/SNMPv2-SMI
Normal file
@@ -0,0 +1,344 @@
|
||||
SNMPv2-SMI DEFINITIONS ::= BEGIN
|
||||
|
||||
-- the path to the root
|
||||
|
||||
org OBJECT IDENTIFIER ::= { iso 3 } -- "iso" = 1
|
||||
dod OBJECT IDENTIFIER ::= { org 6 }
|
||||
internet OBJECT IDENTIFIER ::= { dod 1 }
|
||||
|
||||
directory OBJECT IDENTIFIER ::= { internet 1 }
|
||||
|
||||
mgmt OBJECT IDENTIFIER ::= { internet 2 }
|
||||
mib-2 OBJECT IDENTIFIER ::= { mgmt 1 }
|
||||
transmission OBJECT IDENTIFIER ::= { mib-2 10 }
|
||||
|
||||
experimental OBJECT IDENTIFIER ::= { internet 3 }
|
||||
|
||||
private OBJECT IDENTIFIER ::= { internet 4 }
|
||||
enterprises OBJECT IDENTIFIER ::= { private 1 }
|
||||
|
||||
security OBJECT IDENTIFIER ::= { internet 5 }
|
||||
|
||||
snmpV2 OBJECT IDENTIFIER ::= { internet 6 }
|
||||
|
||||
-- transport domains
|
||||
snmpDomains OBJECT IDENTIFIER ::= { snmpV2 1 }
|
||||
|
||||
-- transport proxies
|
||||
snmpProxys OBJECT IDENTIFIER ::= { snmpV2 2 }
|
||||
|
||||
-- module identities
|
||||
snmpModules OBJECT IDENTIFIER ::= { snmpV2 3 }
|
||||
|
||||
-- Extended UTCTime, to allow dates with four-digit years
|
||||
-- (Note that this definition of ExtUTCTime is not to be IMPORTed
|
||||
-- by MIB modules.)
|
||||
ExtUTCTime ::= OCTET STRING(SIZE(11 | 13))
|
||||
-- format is YYMMDDHHMMZ or YYYYMMDDHHMMZ
|
||||
|
||||
-- where: YY - last two digits of year (only years
|
||||
-- between 1900-1999)
|
||||
-- YYYY - last four digits of the year (any year)
|
||||
-- MM - month (01 through 12)
|
||||
-- DD - day of month (01 through 31)
|
||||
-- HH - hours (00 through 23)
|
||||
-- MM - minutes (00 through 59)
|
||||
-- Z - denotes GMT (the ASCII character Z)
|
||||
--
|
||||
-- For example, "9502192015Z" and "199502192015Z" represent
|
||||
-- 8:15pm GMT on 19 February 1995. Years after 1999 must use
|
||||
-- the four digit year format. Years 1900-1999 may use the
|
||||
-- two or four digit format.
|
||||
|
||||
-- definitions for information modules
|
||||
|
||||
MODULE-IDENTITY MACRO ::=
|
||||
BEGIN
|
||||
TYPE NOTATION ::=
|
||||
"LAST-UPDATED" value(Update ExtUTCTime)
|
||||
"ORGANIZATION" Text
|
||||
"CONTACT-INFO" Text
|
||||
"DESCRIPTION" Text
|
||||
RevisionPart
|
||||
|
||||
VALUE NOTATION ::=
|
||||
value(VALUE OBJECT IDENTIFIER)
|
||||
|
||||
RevisionPart ::=
|
||||
Revisions
|
||||
| empty
|
||||
Revisions ::=
|
||||
Revision
|
||||
| Revisions Revision
|
||||
Revision ::=
|
||||
"REVISION" value(Update ExtUTCTime)
|
||||
"DESCRIPTION" Text
|
||||
|
||||
-- a character string as defined in section 3.1.1
|
||||
Text ::= value(IA5String)
|
||||
END
|
||||
|
||||
OBJECT-IDENTITY MACRO ::=
|
||||
BEGIN
|
||||
TYPE NOTATION ::=
|
||||
"STATUS" Status
|
||||
"DESCRIPTION" Text
|
||||
|
||||
ReferPart
|
||||
|
||||
VALUE NOTATION ::=
|
||||
value(VALUE OBJECT IDENTIFIER)
|
||||
|
||||
Status ::=
|
||||
"current"
|
||||
| "deprecated"
|
||||
| "obsolete"
|
||||
|
||||
ReferPart ::=
|
||||
"REFERENCE" Text
|
||||
| empty
|
||||
|
||||
-- a character string as defined in section 3.1.1
|
||||
Text ::= value(IA5String)
|
||||
END
|
||||
|
||||
-- names of objects
|
||||
-- (Note that these definitions of ObjectName and NotificationName
|
||||
-- are not to be IMPORTed by MIB modules.)
|
||||
|
||||
ObjectName ::=
|
||||
OBJECT IDENTIFIER
|
||||
|
||||
NotificationName ::=
|
||||
OBJECT IDENTIFIER
|
||||
|
||||
-- syntax of objects
|
||||
|
||||
-- the "base types" defined here are:
|
||||
-- 3 built-in ASN.1 types: INTEGER, OCTET STRING, OBJECT IDENTIFIER
|
||||
-- 8 application-defined types: Integer32, IpAddress, Counter32,
|
||||
-- Gauge32, Unsigned32, TimeTicks, Opaque, and Counter64
|
||||
|
||||
ObjectSyntax ::=
|
||||
CHOICE {
|
||||
simple
|
||||
SimpleSyntax,
|
||||
-- note that SEQUENCEs for conceptual tables and
|
||||
-- rows are not mentioned here...
|
||||
|
||||
application-wide
|
||||
ApplicationSyntax
|
||||
}
|
||||
|
||||
-- built-in ASN.1 types
|
||||
|
||||
SimpleSyntax ::=
|
||||
CHOICE {
|
||||
-- INTEGERs with a more restrictive range
|
||||
-- may also be used
|
||||
integer-value -- includes Integer32
|
||||
INTEGER (-2147483648..2147483647),
|
||||
-- OCTET STRINGs with a more restrictive size
|
||||
-- may also be used
|
||||
string-value
|
||||
OCTET STRING (SIZE (0..65535)),
|
||||
objectID-value
|
||||
OBJECT IDENTIFIER
|
||||
}
|
||||
|
||||
-- indistinguishable from INTEGER, but never needs more than
|
||||
-- 32-bits for a two's complement representation
|
||||
Integer32 ::=
|
||||
INTEGER (-2147483648..2147483647)
|
||||
|
||||
-- application-wide types
|
||||
|
||||
ApplicationSyntax ::=
|
||||
CHOICE {
|
||||
ipAddress-value
|
||||
IpAddress,
|
||||
counter-value
|
||||
Counter32,
|
||||
timeticks-value
|
||||
TimeTicks,
|
||||
arbitrary-value
|
||||
Opaque,
|
||||
big-counter-value
|
||||
Counter64,
|
||||
unsigned-integer-value -- includes Gauge32
|
||||
Unsigned32
|
||||
}
|
||||
|
||||
-- in network-byte order
|
||||
|
||||
-- (this is a tagged type for historical reasons)
|
||||
IpAddress ::=
|
||||
[APPLICATION 0]
|
||||
IMPLICIT OCTET STRING (SIZE (4))
|
||||
|
||||
-- this wraps
|
||||
Counter32 ::=
|
||||
[APPLICATION 1]
|
||||
IMPLICIT INTEGER (0..4294967295)
|
||||
|
||||
-- this doesn't wrap
|
||||
Gauge32 ::=
|
||||
[APPLICATION 2]
|
||||
IMPLICIT INTEGER (0..4294967295)
|
||||
|
||||
-- an unsigned 32-bit quantity
|
||||
-- indistinguishable from Gauge32
|
||||
Unsigned32 ::=
|
||||
[APPLICATION 2]
|
||||
IMPLICIT INTEGER (0..4294967295)
|
||||
|
||||
-- hundredths of seconds since an epoch
|
||||
TimeTicks ::=
|
||||
[APPLICATION 3]
|
||||
IMPLICIT INTEGER (0..4294967295)
|
||||
|
||||
-- for backward-compatibility only
|
||||
Opaque ::=
|
||||
[APPLICATION 4]
|
||||
IMPLICIT OCTET STRING
|
||||
|
||||
-- for counters that wrap in less than one hour with only 32 bits
|
||||
Counter64 ::=
|
||||
[APPLICATION 6]
|
||||
IMPLICIT INTEGER (0..18446744073709551615)
|
||||
|
||||
-- definition for objects
|
||||
|
||||
OBJECT-TYPE MACRO ::=
|
||||
BEGIN
|
||||
TYPE NOTATION ::=
|
||||
"SYNTAX" Syntax
|
||||
UnitsPart
|
||||
"MAX-ACCESS" Access
|
||||
"STATUS" Status
|
||||
"DESCRIPTION" Text
|
||||
ReferPart
|
||||
|
||||
IndexPart
|
||||
DefValPart
|
||||
|
||||
VALUE NOTATION ::=
|
||||
value(VALUE ObjectName)
|
||||
|
||||
Syntax ::= -- Must be one of the following:
|
||||
-- a base type (or its refinement),
|
||||
-- a textual convention (or its refinement), or
|
||||
-- a BITS pseudo-type
|
||||
type
|
||||
| "BITS" "{" NamedBits "}"
|
||||
|
||||
NamedBits ::= NamedBit
|
||||
| NamedBits "," NamedBit
|
||||
|
||||
NamedBit ::= identifier "(" number ")" -- number is nonnegative
|
||||
|
||||
UnitsPart ::=
|
||||
"UNITS" Text
|
||||
| empty
|
||||
|
||||
Access ::=
|
||||
"not-accessible"
|
||||
| "accessible-for-notify"
|
||||
| "read-only"
|
||||
| "read-write"
|
||||
| "read-create"
|
||||
|
||||
Status ::=
|
||||
"current"
|
||||
| "deprecated"
|
||||
| "obsolete"
|
||||
|
||||
ReferPart ::=
|
||||
"REFERENCE" Text
|
||||
| empty
|
||||
|
||||
IndexPart ::=
|
||||
"INDEX" "{" IndexTypes "}"
|
||||
| "AUGMENTS" "{" Entry "}"
|
||||
| empty
|
||||
IndexTypes ::=
|
||||
IndexType
|
||||
| IndexTypes "," IndexType
|
||||
IndexType ::=
|
||||
"IMPLIED" Index
|
||||
| Index
|
||||
|
||||
Index ::=
|
||||
-- use the SYNTAX value of the
|
||||
-- correspondent OBJECT-TYPE invocation
|
||||
value(ObjectName)
|
||||
Entry ::=
|
||||
-- use the INDEX value of the
|
||||
-- correspondent OBJECT-TYPE invocation
|
||||
value(ObjectName)
|
||||
|
||||
DefValPart ::= "DEFVAL" "{" Defvalue "}"
|
||||
| empty
|
||||
|
||||
Defvalue ::= -- must be valid for the type specified in
|
||||
-- SYNTAX clause of same OBJECT-TYPE macro
|
||||
value(ObjectSyntax)
|
||||
| "{" BitsValue "}"
|
||||
|
||||
BitsValue ::= BitNames
|
||||
| empty
|
||||
|
||||
BitNames ::= BitName
|
||||
| BitNames "," BitName
|
||||
|
||||
BitName ::= identifier
|
||||
|
||||
-- a character string as defined in section 3.1.1
|
||||
Text ::= value(IA5String)
|
||||
END
|
||||
|
||||
-- definitions for notifications
|
||||
|
||||
NOTIFICATION-TYPE MACRO ::=
|
||||
BEGIN
|
||||
TYPE NOTATION ::=
|
||||
ObjectsPart
|
||||
"STATUS" Status
|
||||
"DESCRIPTION" Text
|
||||
ReferPart
|
||||
|
||||
VALUE NOTATION ::=
|
||||
value(VALUE NotificationName)
|
||||
|
||||
ObjectsPart ::=
|
||||
"OBJECTS" "{" Objects "}"
|
||||
| empty
|
||||
Objects ::=
|
||||
Object
|
||||
|
||||
| Objects "," Object
|
||||
Object ::=
|
||||
value(ObjectName)
|
||||
|
||||
Status ::=
|
||||
"current"
|
||||
| "deprecated"
|
||||
| "obsolete"
|
||||
|
||||
ReferPart ::=
|
||||
"REFERENCE" Text
|
||||
| empty
|
||||
|
||||
-- a character string as defined in section 3.1.1
|
||||
Text ::= value(IA5String)
|
||||
END
|
||||
|
||||
-- definitions of administrative identifiers
|
||||
|
||||
zeroDotZero OBJECT-IDENTITY
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"A value used for null identifiers."
|
||||
::= { 0 0 }
|
||||
|
||||
END
|
||||
772
src/configMgr/c_program/paraComm/mib/SNMPv2-TC
Normal file
772
src/configMgr/c_program/paraComm/mib/SNMPv2-TC
Normal file
@@ -0,0 +1,772 @@
|
||||
SNMPv2-TC DEFINITIONS ::= BEGIN
|
||||
|
||||
IMPORTS
|
||||
TimeTicks FROM SNMPv2-SMI;
|
||||
|
||||
-- definition of textual conventions
|
||||
|
||||
TEXTUAL-CONVENTION MACRO ::=
|
||||
|
||||
BEGIN
|
||||
TYPE NOTATION ::=
|
||||
DisplayPart
|
||||
"STATUS" Status
|
||||
"DESCRIPTION" Text
|
||||
ReferPart
|
||||
"SYNTAX" Syntax
|
||||
|
||||
VALUE NOTATION ::=
|
||||
value(VALUE Syntax) -- adapted ASN.1
|
||||
|
||||
DisplayPart ::=
|
||||
"DISPLAY-HINT" Text
|
||||
| empty
|
||||
|
||||
Status ::=
|
||||
"current"
|
||||
| "deprecated"
|
||||
| "obsolete"
|
||||
|
||||
ReferPart ::=
|
||||
"REFERENCE" Text
|
||||
| empty
|
||||
|
||||
-- a character string as defined in [2]
|
||||
Text ::= value(IA5String)
|
||||
|
||||
Syntax ::= -- Must be one of the following:
|
||||
-- a base type (or its refinement), or
|
||||
-- a BITS pseudo-type
|
||||
type
|
||||
| "BITS" "{" NamedBits "}"
|
||||
|
||||
NamedBits ::= NamedBit
|
||||
| NamedBits "," NamedBit
|
||||
|
||||
NamedBit ::= identifier "(" number ")" -- number is nonnegative
|
||||
|
||||
END
|
||||
|
||||
DisplayString ::= TEXTUAL-CONVENTION
|
||||
DISPLAY-HINT "255a"
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"Represents textual information taken from the NVT ASCII
|
||||
|
||||
character set, as defined in pages 4, 10-11 of RFC 854.
|
||||
|
||||
To summarize RFC 854, the NVT ASCII repertoire specifies:
|
||||
|
||||
- the use of character codes 0-127 (decimal)
|
||||
|
||||
- the graphics characters (32-126) are interpreted as
|
||||
US ASCII
|
||||
|
||||
- NUL, LF, CR, BEL, BS, HT, VT and FF have the special
|
||||
meanings specified in RFC 854
|
||||
|
||||
- the other 25 codes have no standard interpretation
|
||||
|
||||
- the sequence 'CR LF' means newline
|
||||
|
||||
- the sequence 'CR NUL' means carriage-return
|
||||
|
||||
- an 'LF' not preceded by a 'CR' means moving to the
|
||||
same column on the next line.
|
||||
|
||||
- the sequence 'CR x' for any x other than LF or NUL is
|
||||
illegal. (Note that this also means that a string may
|
||||
end with either 'CR LF' or 'CR NUL', but not with CR.)
|
||||
|
||||
Any object defined using this syntax may not exceed 255
|
||||
characters in length."
|
||||
SYNTAX OCTET STRING (SIZE (0..255))
|
||||
|
||||
PhysAddress ::= TEXTUAL-CONVENTION
|
||||
DISPLAY-HINT "1x:"
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"Represents media- or physical-level addresses."
|
||||
SYNTAX OCTET STRING
|
||||
|
||||
MacAddress ::= TEXTUAL-CONVENTION
|
||||
DISPLAY-HINT "1x:"
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"Represents an 802 MAC address represented in the
|
||||
`canonical' order defined by IEEE 802.1a, i.e., as if it
|
||||
were transmitted least significant bit first, even though
|
||||
802.5 (in contrast to other 802.x protocols) requires MAC
|
||||
addresses to be transmitted most significant bit first."
|
||||
SYNTAX OCTET STRING (SIZE (6))
|
||||
|
||||
TruthValue ::= TEXTUAL-CONVENTION
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"Represents a boolean value."
|
||||
SYNTAX INTEGER { true(1), false(2) }
|
||||
|
||||
TestAndIncr ::= TEXTUAL-CONVENTION
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"Represents integer-valued information used for atomic
|
||||
operations. When the management protocol is used to specify
|
||||
that an object instance having this syntax is to be
|
||||
modified, the new value supplied via the management protocol
|
||||
must precisely match the value presently held by the
|
||||
instance. If not, the management protocol set operation
|
||||
fails with an error of `inconsistentValue'. Otherwise, if
|
||||
the current value is the maximum value of 2^31-1 (2147483647
|
||||
decimal), then the value held by the instance is wrapped to
|
||||
zero; otherwise, the value held by the instance is
|
||||
incremented by one. (Note that regardless of whether the
|
||||
management protocol set operation succeeds, the variable-
|
||||
binding in the request and response PDUs are identical.)
|
||||
|
||||
The value of the ACCESS clause for objects having this
|
||||
syntax is either `read-write' or `read-create'. When an
|
||||
instance of a columnar object having this syntax is created,
|
||||
any value may be supplied via the management protocol.
|
||||
|
||||
When the network management portion of the system is re-
|
||||
initialized, the value of every object instance having this
|
||||
syntax must either be incremented from its value prior to
|
||||
the re-initialization, or (if the value prior to the re-
|
||||
initialization is unknown) be set to a pseudo-randomly
|
||||
generated value."
|
||||
SYNTAX INTEGER (0..2147483647)
|
||||
|
||||
AutonomousType ::= TEXTUAL-CONVENTION
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"Represents an independently extensible type identification
|
||||
value. It may, for example, indicate a particular sub-tree
|
||||
with further MIB definitions, or define a particular type of
|
||||
protocol or hardware."
|
||||
SYNTAX OBJECT IDENTIFIER
|
||||
|
||||
InstancePointer ::= TEXTUAL-CONVENTION
|
||||
STATUS obsolete
|
||||
DESCRIPTION
|
||||
"A pointer to either a specific instance of a MIB object or
|
||||
a conceptual row of a MIB table in the managed device. In
|
||||
the latter case, by convention, it is the name of the
|
||||
particular instance of the first accessible columnar object
|
||||
in the conceptual row.
|
||||
|
||||
The two uses of this textual convention are replaced by
|
||||
VariablePointer and RowPointer, respectively."
|
||||
SYNTAX OBJECT IDENTIFIER
|
||||
|
||||
VariablePointer ::= TEXTUAL-CONVENTION
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"A pointer to a specific object instance. For example,
|
||||
sysContact.0 or ifInOctets.3."
|
||||
SYNTAX OBJECT IDENTIFIER
|
||||
|
||||
RowPointer ::= TEXTUAL-CONVENTION
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"Represents a pointer to a conceptual row. The value is the
|
||||
name of the instance of the first accessible columnar object
|
||||
in the conceptual row.
|
||||
|
||||
For example, ifIndex.3 would point to the 3rd row in the
|
||||
ifTable (note that if ifIndex were not-accessible, then
|
||||
ifDescr.3 would be used instead)."
|
||||
SYNTAX OBJECT IDENTIFIER
|
||||
|
||||
RowStatus ::= TEXTUAL-CONVENTION
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"The RowStatus textual convention is used to manage the
|
||||
creation and deletion of conceptual rows, and is used as the
|
||||
value of the SYNTAX clause for the status column of a
|
||||
conceptual row (as described in Section 7.7.1 of [2].)
|
||||
|
||||
The status column has six defined values:
|
||||
|
||||
- `active', which indicates that the conceptual row is
|
||||
available for use by the managed device;
|
||||
|
||||
- `notInService', which indicates that the conceptual
|
||||
row exists in the agent, but is unavailable for use by
|
||||
the managed device (see NOTE below); 'notInService' has
|
||||
no implication regarding the internal consistency of
|
||||
the row, availability of resources, or consistency with
|
||||
the current state of the managed device;
|
||||
|
||||
- `notReady', which indicates that the conceptual row
|
||||
exists in the agent, but is missing information
|
||||
necessary in order to be available for use by the
|
||||
managed device (i.e., one or more required columns in
|
||||
the conceptual row have not been instanciated);
|
||||
|
||||
- `createAndGo', which is supplied by a management
|
||||
station wishing to create a new instance of a
|
||||
conceptual row and to have its status automatically set
|
||||
to active, making it available for use by the managed
|
||||
device;
|
||||
|
||||
- `createAndWait', which is supplied by a management
|
||||
station wishing to create a new instance of a
|
||||
conceptual row (but not make it available for use by
|
||||
the managed device); and,
|
||||
- `destroy', which is supplied by a management station
|
||||
wishing to delete all of the instances associated with
|
||||
an existing conceptual row.
|
||||
|
||||
Whereas five of the six values (all except `notReady') may
|
||||
be specified in a management protocol set operation, only
|
||||
three values will be returned in response to a management
|
||||
protocol retrieval operation: `notReady', `notInService' or
|
||||
`active'. That is, when queried, an existing conceptual row
|
||||
has only three states: it is either available for use by
|
||||
the managed device (the status column has value `active');
|
||||
it is not available for use by the managed device, though
|
||||
the agent has sufficient information to attempt to make it
|
||||
so (the status column has value `notInService'); or, it is
|
||||
not available for use by the managed device, and an attempt
|
||||
to make it so would fail because the agent has insufficient
|
||||
information (the state column has value `notReady').
|
||||
|
||||
NOTE WELL
|
||||
|
||||
This textual convention may be used for a MIB table,
|
||||
irrespective of whether the values of that table's
|
||||
conceptual rows are able to be modified while it is
|
||||
active, or whether its conceptual rows must be taken
|
||||
out of service in order to be modified. That is, it is
|
||||
the responsibility of the DESCRIPTION clause of the
|
||||
status column to specify whether the status column must
|
||||
not be `active' in order for the value of some other
|
||||
column of the same conceptual row to be modified. If
|
||||
such a specification is made, affected columns may be
|
||||
changed by an SNMP set PDU if the RowStatus would not
|
||||
be equal to `active' either immediately before or after
|
||||
processing the PDU. In other words, if the PDU also
|
||||
contained a varbind that would change the RowStatus
|
||||
value, the column in question may be changed if the
|
||||
RowStatus was not equal to `active' as the PDU was
|
||||
received, or if the varbind sets the status to a value
|
||||
other than 'active'.
|
||||
|
||||
Also note that whenever any elements of a row exist, the
|
||||
RowStatus column must also exist.
|
||||
|
||||
To summarize the effect of having a conceptual row with a
|
||||
status column having a SYNTAX clause value of RowStatus,
|
||||
consider the following state diagram:
|
||||
|
||||
STATE
|
||||
+--------------+-----------+-------------+-------------
|
||||
| A | B | C | D
|
||||
| |status col.|status column|
|
||||
|status column | is | is |status column
|
||||
ACTION |does not exist| notReady | notInService| is active
|
||||
--------------+--------------+-----------+-------------+-------------
|
||||
set status |noError ->D|inconsist- |inconsistent-|inconsistent-
|
||||
column to | or | entValue| Value| Value
|
||||
createAndGo |inconsistent- | | |
|
||||
| Value| | |
|
||||
--------------+--------------+-----------+-------------+-------------
|
||||
set status |noError see 1|inconsist- |inconsistent-|inconsistent-
|
||||
column to | or | entValue| Value| Value
|
||||
createAndWait |wrongValue | | |
|
||||
--------------+--------------+-----------+-------------+-------------
|
||||
set status |inconsistent- |inconsist- |noError |noError
|
||||
column to | Value| entValue| |
|
||||
active | | | |
|
||||
| | or | |
|
||||
| | | |
|
||||
| |see 2 ->D|see 8 ->D| ->D
|
||||
--------------+--------------+-----------+-------------+-------------
|
||||
set status |inconsistent- |inconsist- |noError |noError ->C
|
||||
column to | Value| entValue| |
|
||||
notInService | | | |
|
||||
| | or | | or
|
||||
| | | |
|
||||
| |see 3 ->C| ->C|see 6
|
||||
--------------+--------------+-----------+-------------+-------------
|
||||
set status |noError |noError |noError |noError ->A
|
||||
column to | | | | or
|
||||
destroy | ->A| ->A| ->A|see 7
|
||||
--------------+--------------+-----------+-------------+-------------
|
||||
set any other |see 4 |noError |noError |see 5
|
||||
column to some| | | |
|
||||
value | | see 1| ->C| ->D
|
||||
--------------+--------------+-----------+-------------+-------------
|
||||
|
||||
(1) goto B or C, depending on information available to the
|
||||
agent.
|
||||
|
||||
(2) if other variable bindings included in the same PDU,
|
||||
provide values for all columns which are missing but
|
||||
required, and all columns have acceptable values, then
|
||||
return noError and goto D.
|
||||
|
||||
(3) if other variable bindings included in the same PDU,
|
||||
provide legal values for all columns which are missing but
|
||||
required, then return noError and goto C.
|
||||
|
||||
(4) at the discretion of the agent, the return value may be
|
||||
either:
|
||||
|
||||
inconsistentName: because the agent does not choose to
|
||||
create such an instance when the corresponding
|
||||
RowStatus instance does not exist, or
|
||||
|
||||
inconsistentValue: if the supplied value is
|
||||
inconsistent with the state of some other MIB object's
|
||||
value, or
|
||||
|
||||
noError: because the agent chooses to create the
|
||||
instance.
|
||||
|
||||
If noError is returned, then the instance of the status
|
||||
column must also be created, and the new state is B or C,
|
||||
depending on the information available to the agent. If
|
||||
inconsistentName or inconsistentValue is returned, the row
|
||||
remains in state A.
|
||||
|
||||
(5) depending on the MIB definition for the column/table,
|
||||
either noError or inconsistentValue may be returned.
|
||||
|
||||
(6) the return value can indicate one of the following
|
||||
errors:
|
||||
|
||||
wrongValue: because the agent does not support
|
||||
notInService (e.g., an agent which does not support
|
||||
createAndWait), or
|
||||
|
||||
inconsistentValue: because the agent is unable to take
|
||||
the row out of service at this time, perhaps because it
|
||||
is in use and cannot be de-activated.
|
||||
|
||||
(7) the return value can indicate the following error:
|
||||
|
||||
inconsistentValue: because the agent is unable to
|
||||
remove the row at this time, perhaps because it is in
|
||||
use and cannot be de-activated.
|
||||
|
||||
(8) the transition to D can fail, e.g., if the values of the
|
||||
conceptual row are inconsistent, then the error code would
|
||||
be inconsistentValue.
|
||||
|
||||
NOTE: Other processing of (this and other varbinds of) the
|
||||
set request may result in a response other than noError
|
||||
being returned, e.g., wrongValue, noCreation, etc.
|
||||
|
||||
Conceptual Row Creation
|
||||
|
||||
There are four potential interactions when creating a
|
||||
conceptual row: selecting an instance-identifier which is
|
||||
not in use; creating the conceptual row; initializing any
|
||||
objects for which the agent does not supply a default; and,
|
||||
making the conceptual row available for use by the managed
|
||||
device.
|
||||
|
||||
Interaction 1: Selecting an Instance-Identifier
|
||||
|
||||
The algorithm used to select an instance-identifier varies
|
||||
for each conceptual row. In some cases, the instance-
|
||||
identifier is semantically significant, e.g., the
|
||||
destination address of a route, and a management station
|
||||
selects the instance-identifier according to the semantics.
|
||||
|
||||
In other cases, the instance-identifier is used solely to
|
||||
distinguish conceptual rows, and a management station
|
||||
without specific knowledge of the conceptual row might
|
||||
examine the instances present in order to determine an
|
||||
unused instance-identifier. (This approach may be used, but
|
||||
it is often highly sub-optimal; however, it is also a
|
||||
questionable practice for a naive management station to
|
||||
attempt conceptual row creation.)
|
||||
|
||||
Alternately, the MIB module which defines the conceptual row
|
||||
might provide one or more objects which provide assistance
|
||||
in determining an unused instance-identifier. For example,
|
||||
if the conceptual row is indexed by an integer-value, then
|
||||
an object having an integer-valued SYNTAX clause might be
|
||||
defined for such a purpose, allowing a management station to
|
||||
issue a management protocol retrieval operation. In order
|
||||
to avoid unnecessary collisions between competing management
|
||||
stations, `adjacent' retrievals of this object should be
|
||||
different.
|
||||
|
||||
Finally, the management station could select a pseudo-random
|
||||
number to use as the index. In the event that this index
|
||||
|
||||
was already in use and an inconsistentValue was returned in
|
||||
response to the management protocol set operation, the
|
||||
management station should simply select a new pseudo-random
|
||||
number and retry the operation.
|
||||
|
||||
A MIB designer should choose between the two latter
|
||||
algorithms based on the size of the table (and therefore the
|
||||
efficiency of each algorithm). For tables in which a large
|
||||
number of entries are expected, it is recommended that a MIB
|
||||
object be defined that returns an acceptable index for
|
||||
creation. For tables with small numbers of entries, it is
|
||||
recommended that the latter pseudo-random index mechanism be
|
||||
used.
|
||||
|
||||
Interaction 2: Creating the Conceptual Row
|
||||
|
||||
Once an unused instance-identifier has been selected, the
|
||||
management station determines if it wishes to create and
|
||||
activate the conceptual row in one transaction or in a
|
||||
negotiated set of interactions.
|
||||
|
||||
Interaction 2a: Creating and Activating the Conceptual Row
|
||||
|
||||
The management station must first determine the column
|
||||
requirements, i.e., it must determine those columns for
|
||||
which it must or must not provide values. Depending on the
|
||||
complexity of the table and the management station's
|
||||
knowledge of the agent's capabilities, this determination
|
||||
can be made locally by the management station. Alternately,
|
||||
the management station issues a management protocol get
|
||||
operation to examine all columns in the conceptual row that
|
||||
it wishes to create. In response, for each column, there
|
||||
are three possible outcomes:
|
||||
|
||||
- a value is returned, indicating that some other
|
||||
management station has already created this conceptual
|
||||
row. We return to interaction 1.
|
||||
|
||||
- the exception `noSuchInstance' is returned,
|
||||
indicating that the agent implements the object-type
|
||||
associated with this column, and that this column in at
|
||||
least one conceptual row would be accessible in the MIB
|
||||
view used by the retrieval were it to exist. For those
|
||||
columns to which the agent provides read-create access,
|
||||
the `noSuchInstance' exception tells the management
|
||||
station that it should supply a value for this column
|
||||
when the conceptual row is to be created.
|
||||
|
||||
- the exception `noSuchObject' is returned, indicating
|
||||
that the agent does not implement the object-type
|
||||
associated with this column or that there is no
|
||||
conceptual row for which this column would be
|
||||
accessible in the MIB view used by the retrieval. As
|
||||
such, the management station can not issue any
|
||||
management protocol set operations to create an
|
||||
instance of this column.
|
||||
|
||||
Once the column requirements have been determined, a
|
||||
management protocol set operation is accordingly issued.
|
||||
This operation also sets the new instance of the status
|
||||
column to `createAndGo'.
|
||||
|
||||
When the agent processes the set operation, it verifies that
|
||||
it has sufficient information to make the conceptual row
|
||||
available for use by the managed device. The information
|
||||
available to the agent is provided by two sources: the
|
||||
management protocol set operation which creates the
|
||||
conceptual row, and, implementation-specific defaults
|
||||
supplied by the agent (note that an agent must provide
|
||||
implementation-specific defaults for at least those objects
|
||||
which it implements as read-only). If there is sufficient
|
||||
information available, then the conceptual row is created, a
|
||||
`noError' response is returned, the status column is set to
|
||||
`active', and no further interactions are necessary (i.e.,
|
||||
interactions 3 and 4 are skipped). If there is insufficient
|
||||
information, then the conceptual row is not created, and the
|
||||
set operation fails with an error of `inconsistentValue'.
|
||||
On this error, the management station can issue a management
|
||||
protocol retrieval operation to determine if this was
|
||||
because it failed to specify a value for a required column,
|
||||
or, because the selected instance of the status column
|
||||
already existed. In the latter case, we return to
|
||||
interaction 1. In the former case, the management station
|
||||
can re-issue the set operation with the additional
|
||||
information, or begin interaction 2 again using
|
||||
`createAndWait' in order to negotiate creation of the
|
||||
conceptual row.
|
||||
|
||||
NOTE WELL
|
||||
|
||||
Regardless of the method used to determine the column
|
||||
requirements, it is possible that the management
|
||||
station might deem a column necessary when, in fact,
|
||||
the agent will not allow that particular columnar
|
||||
instance to be created or written. In this case, the
|
||||
management protocol set operation will fail with an
|
||||
error such as `noCreation' or `notWritable'. In this
|
||||
case, the management station decides whether it needs
|
||||
to be able to set a value for that particular columnar
|
||||
instance. If not, the management station re-issues the
|
||||
management protocol set operation, but without setting
|
||||
a value for that particular columnar instance;
|
||||
otherwise, the management station aborts the row
|
||||
creation algorithm.
|
||||
|
||||
Interaction 2b: Negotiating the Creation of the Conceptual
|
||||
Row
|
||||
|
||||
The management station issues a management protocol set
|
||||
operation which sets the desired instance of the status
|
||||
column to `createAndWait'. If the agent is unwilling to
|
||||
process a request of this sort, the set operation fails with
|
||||
an error of `wrongValue'. (As a consequence, such an agent
|
||||
must be prepared to accept a single management protocol set
|
||||
operation, i.e., interaction 2a above, containing all of the
|
||||
columns indicated by its column requirements.) Otherwise,
|
||||
the conceptual row is created, a `noError' response is
|
||||
returned, and the status column is immediately set to either
|
||||
`notInService' or `notReady', depending on whether it has
|
||||
sufficient information to (attempt to) make the conceptual
|
||||
row available for use by the managed device. If there is
|
||||
sufficient information available, then the status column is
|
||||
set to `notInService'; otherwise, if there is insufficient
|
||||
information, then the status column is set to `notReady'.
|
||||
Regardless, we proceed to interaction 3.
|
||||
|
||||
Interaction 3: Initializing non-defaulted Objects
|
||||
|
||||
The management station must now determine the column
|
||||
requirements. It issues a management protocol get operation
|
||||
to examine all columns in the created conceptual row. In
|
||||
the response, for each column, there are three possible
|
||||
outcomes:
|
||||
|
||||
- a value is returned, indicating that the agent
|
||||
implements the object-type associated with this column
|
||||
and had sufficient information to provide a value. For
|
||||
those columns to which the agent provides read-create
|
||||
access (and for which the agent allows their values to
|
||||
be changed after their creation), a value return tells
|
||||
the management station that it may issue additional
|
||||
management protocol set operations, if it desires, in
|
||||
order to change the value associated with this column.
|
||||
|
||||
- the exception `noSuchInstance' is returned,
|
||||
indicating that the agent implements the object-type
|
||||
associated with this column, and that this column in at
|
||||
least one conceptual row would be accessible in the MIB
|
||||
view used by the retrieval were it to exist. However,
|
||||
the agent does not have sufficient information to
|
||||
provide a value, and until a value is provided, the
|
||||
conceptual row may not be made available for use by the
|
||||
managed device. For those columns to which the agent
|
||||
provides read-create access, the `noSuchInstance'
|
||||
exception tells the management station that it must
|
||||
issue additional management protocol set operations, in
|
||||
order to provide a value associated with this column.
|
||||
|
||||
- the exception `noSuchObject' is returned, indicating
|
||||
that the agent does not implement the object-type
|
||||
associated with this column or that there is no
|
||||
conceptual row for which this column would be
|
||||
accessible in the MIB view used by the retrieval. As
|
||||
such, the management station can not issue any
|
||||
management protocol set operations to create an
|
||||
instance of this column.
|
||||
|
||||
If the value associated with the status column is
|
||||
`notReady', then the management station must first deal with
|
||||
all `noSuchInstance' columns, if any. Having done so, the
|
||||
value of the status column becomes `notInService', and we
|
||||
proceed to interaction 4.
|
||||
|
||||
Interaction 4: Making the Conceptual Row Available
|
||||
|
||||
Once the management station is satisfied with the values
|
||||
associated with the columns of the conceptual row, it issues
|
||||
a management protocol set operation to set the status column
|
||||
to `active'. If the agent has sufficient information to
|
||||
make the conceptual row available for use by the managed
|
||||
device, the management protocol set operation succeeds (a
|
||||
`noError' response is returned). Otherwise, the management
|
||||
protocol set operation fails with an error of
|
||||
`inconsistentValue'.
|
||||
|
||||
NOTE WELL
|
||||
|
||||
A conceptual row having a status column with value
|
||||
`notInService' or `notReady' is unavailable to the
|
||||
managed device. As such, it is possible for the
|
||||
managed device to create its own instances during the
|
||||
time between the management protocol set operation
|
||||
which sets the status column to `createAndWait' and the
|
||||
management protocol set operation which sets the status
|
||||
column to `active'. In this case, when the management
|
||||
protocol set operation is issued to set the status
|
||||
column to `active', the values held in the agent
|
||||
supersede those used by the managed device.
|
||||
|
||||
If the management station is prevented from setting the
|
||||
status column to `active' (e.g., due to management station
|
||||
or network failure) the conceptual row will be left in the
|
||||
`notInService' or `notReady' state, consuming resources
|
||||
indefinitely. The agent must detect conceptual rows that
|
||||
have been in either state for an abnormally long period of
|
||||
time and remove them. It is the responsibility of the
|
||||
DESCRIPTION clause of the status column to indicate what an
|
||||
abnormally long period of time would be. This period of
|
||||
time should be long enough to allow for human response time
|
||||
(including `think time') between the creation of the
|
||||
conceptual row and the setting of the status to `active'.
|
||||
In the absence of such information in the DESCRIPTION
|
||||
clause, it is suggested that this period be approximately 5
|
||||
minutes in length. This removal action applies not only to
|
||||
newly-created rows, but also to previously active rows which
|
||||
are set to, and left in, the notInService state for a
|
||||
prolonged period exceeding that which is considered normal
|
||||
for such a conceptual row.
|
||||
|
||||
Conceptual Row Suspension
|
||||
|
||||
When a conceptual row is `active', the management station
|
||||
may issue a management protocol set operation which sets the
|
||||
instance of the status column to `notInService'. If the
|
||||
agent is unwilling to do so, the set operation fails with an
|
||||
error of `wrongValue' or `inconsistentValue'. Otherwise,
|
||||
the conceptual row is taken out of service, and a `noError'
|
||||
response is returned. It is the responsibility of the
|
||||
DESCRIPTION clause of the status column to indicate under
|
||||
what circumstances the status column should be taken out of
|
||||
service (e.g., in order for the value of some other column
|
||||
of the same conceptual row to be modified).
|
||||
|
||||
Conceptual Row Deletion
|
||||
|
||||
For deletion of conceptual rows, a management protocol set
|
||||
operation is issued which sets the instance of the status
|
||||
column to `destroy'. This request may be made regardless of
|
||||
the current value of the status column (e.g., it is possible
|
||||
to delete conceptual rows which are either `notReady',
|
||||
`notInService' or `active'.) If the operation succeeds,
|
||||
then all instances associated with the conceptual row are
|
||||
immediately removed."
|
||||
SYNTAX INTEGER {
|
||||
-- the following two values are states:
|
||||
-- these values may be read or written
|
||||
active(1),
|
||||
notInService(2),
|
||||
-- the following value is a state:
|
||||
-- this value may be read, but not written
|
||||
notReady(3),
|
||||
-- the following three values are
|
||||
-- actions: these values may be written,
|
||||
-- but are never read
|
||||
createAndGo(4),
|
||||
createAndWait(5),
|
||||
destroy(6)
|
||||
}
|
||||
|
||||
TimeStamp ::= TEXTUAL-CONVENTION
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"The value of the sysUpTime object at which a specific
|
||||
occurrence happened. The specific occurrence must be
|
||||
|
||||
defined in the description of any object defined using this
|
||||
type.
|
||||
|
||||
If sysUpTime is reset to zero as a result of a re-
|
||||
initialization of the network management (sub)system, then
|
||||
the values of all TimeStamp objects are also reset.
|
||||
However, after approximately 497 days without a re-
|
||||
initialization, the sysUpTime object will reach 2^^32-1 and
|
||||
then increment around to zero; in this case, existing values
|
||||
of TimeStamp objects do not change. This can lead to
|
||||
ambiguities in the value of TimeStamp objects."
|
||||
SYNTAX TimeTicks
|
||||
|
||||
TimeInterval ::= TEXTUAL-CONVENTION
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"A period of time, measured in units of 0.01 seconds."
|
||||
SYNTAX INTEGER (0..2147483647)
|
||||
|
||||
DateAndTime ::= TEXTUAL-CONVENTION
|
||||
DISPLAY-HINT "2d-1d-1d,1d:1d:1d.1d,1a1d:1d"
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"A date-time specification.
|
||||
|
||||
field octets contents range
|
||||
----- ------ -------- -----
|
||||
1 1-2 year* 0..65536
|
||||
2 3 month 1..12
|
||||
3 4 day 1..31
|
||||
4 5 hour 0..23
|
||||
5 6 minutes 0..59
|
||||
6 7 seconds 0..60
|
||||
(use 60 for leap-second)
|
||||
7 8 deci-seconds 0..9
|
||||
8 9 direction from UTC '+' / '-'
|
||||
9 10 hours from UTC* 0..13
|
||||
10 11 minutes from UTC 0..59
|
||||
|
||||
* Notes:
|
||||
- the value of year is in network-byte order
|
||||
- daylight saving time in New Zealand is +13
|
||||
|
||||
For example, Tuesday May 26, 1992 at 1:30:15 PM EDT would be
|
||||
displayed as:
|
||||
|
||||
1992-5-26,13:30:15.0,-4:0
|
||||
|
||||
Note that if only local time is known, then timezone
|
||||
information (fields 8-10) is not present."
|
||||
SYNTAX OCTET STRING (SIZE (8 | 11))
|
||||
|
||||
StorageType ::= TEXTUAL-CONVENTION
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"Describes the memory realization of a conceptual row. A
|
||||
row which is volatile(2) is lost upon reboot. A row which
|
||||
is either nonVolatile(3), permanent(4) or readOnly(5), is
|
||||
backed up by stable storage. A row which is permanent(4)
|
||||
can be changed but not deleted. A row which is readOnly(5)
|
||||
cannot be changed nor deleted.
|
||||
|
||||
If the value of an object with this syntax is either
|
||||
permanent(4) or readOnly(5), it cannot be written.
|
||||
Conversely, if the value is either other(1), volatile(2) or
|
||||
nonVolatile(3), it cannot be modified to be permanent(4) or
|
||||
readOnly(5). (All illegal modifications result in a
|
||||
'wrongValue' error.)
|
||||
|
||||
Every usage of this textual convention is required to
|
||||
specify the columnar objects which a permanent(4) row must
|
||||
at a minimum allow to be writable."
|
||||
SYNTAX INTEGER {
|
||||
other(1), -- eh?
|
||||
volatile(2), -- e.g., in RAM
|
||||
nonVolatile(3), -- e.g., in NVRAM
|
||||
permanent(4), -- e.g., partially in ROM
|
||||
readOnly(5) -- e.g., completely in ROM
|
||||
}
|
||||
|
||||
TDomain ::= TEXTUAL-CONVENTION
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"Denotes a kind of transport service.
|
||||
|
||||
Some possible values, such as snmpUDPDomain, are defined in
|
||||
the SNMPv2-TM MIB module. Other possible values are defined
|
||||
in other MIB modules."
|
||||
REFERENCE "The SNMPv2-TM MIB module is defined in RFC 1906."
|
||||
SYNTAX OBJECT IDENTIFIER
|
||||
|
||||
TAddress ::= TEXTUAL-CONVENTION
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"Denotes a transport service address.
|
||||
|
||||
A TAddress value is always interpreted within the context of a
|
||||
TDomain value. Thus, each definition of a TDomain value must
|
||||
be accompanied by a definition of a textual convention for use
|
||||
with that TDomain. Some possible textual conventions, such as
|
||||
SnmpUDPAddress for snmpUDPDomain, are defined in the SNMPv2-TM
|
||||
MIB module. Other possible textual conventions are defined in
|
||||
other MIB modules."
|
||||
REFERENCE "The SNMPv2-TM MIB module is defined in RFC 1906."
|
||||
SYNTAX OCTET STRING (SIZE (1..255))
|
||||
|
||||
END
|
||||
5
src/configMgr/c_program/paraComm/mib/index
Normal file
5
src/configMgr/c_program/paraComm/mib/index
Normal file
@@ -0,0 +1,5 @@
|
||||
LGC-MIB.my
|
||||
LGC-SS-MSC-MIB.my
|
||||
SNMPv2-SMI
|
||||
SNMPv2-TC
|
||||
|
||||
1916
src/configMgr/c_program/paraComm/paraComm.c
Normal file
1916
src/configMgr/c_program/paraComm/paraComm.c
Normal file
File diff suppressed because it is too large
Load Diff
220
src/configMgr/c_program/paraComm/paraComm.h
Normal file
220
src/configMgr/c_program/paraComm/paraComm.h
Normal file
@@ -0,0 +1,220 @@
|
||||
/*************************************************
|
||||
File name: paraComm.h
|
||||
Author: Cui Ticun
|
||||
Version: 9.00.00
|
||||
Date: 2007-7-1
|
||||
Description:
|
||||
|
||||
History:
|
||||
No.
|
||||
Author
|
||||
Date
|
||||
Version
|
||||
Description
|
||||
*************************************************/
|
||||
|
||||
#ifndef paraComm__H
|
||||
#define paraComm__H
|
||||
|
||||
#ifndef SNMP__H
|
||||
#include "../../../../plat/snmp/src/include/snmp.h"
|
||||
#include "../../../../plat/snmp/src/mib_parser/snmp_mib_api.h"
|
||||
#include "../../../../plat/snmp/src/mib_parser/snmp_mib.h"
|
||||
#endif
|
||||
|
||||
#include "../../../omcLib/c_program/omcLib/omcLib.h"
|
||||
|
||||
#ifndef MYSQL__H
|
||||
#include "mysql.h"
|
||||
#endif
|
||||
|
||||
#ifndef paraComm_DEBUG
|
||||
#define paraComm_DEBUG 0
|
||||
#endif
|
||||
|
||||
#define paraComm_LogPath "../log"
|
||||
#define paraComm_LogFile "paraComm"
|
||||
|
||||
#define MaxCommNum 32 //max number of command can be execute at the same time
|
||||
#define MaxOidLen 20 //max number of object ID
|
||||
#define MaxColumnNum 4096 //max number of columns in one table
|
||||
#define MaxInstanceNoLevel 4 //max level of instanceNo
|
||||
#define MaxVarNum 50 //max number of var in one pdu
|
||||
#define MaxLenOfParaValue 512 //max len of One parameter value
|
||||
#define DefPort 4958 //define port
|
||||
#define HOSTNAME "localhost" //DB's adress
|
||||
#define PUB_DB "OMC_PUB" //OMC's public database
|
||||
#define ConfTable "OMC_PUB.sysConf" //system config table
|
||||
#define CommTable "OMC_PUB.parameterComm" //command table
|
||||
#define IpTable "OMC_PUB.sysInfo" //system's IP table
|
||||
#define nPubFlag 99 //if sysNo == nPubFlag this parameter is system param
|
||||
|
||||
//commState flag define
|
||||
#define nProcFail 0
|
||||
#define nWaitProc 1
|
||||
#define nInProc 2
|
||||
#define nOutProc 3
|
||||
|
||||
//procState flag define
|
||||
#define nIdle 0
|
||||
#define nWaitResponse 1
|
||||
|
||||
//parameter type define
|
||||
#define nSubSysParam 0
|
||||
#define nGlobalSubSysParam 1
|
||||
#define nGlobalSysParam 2
|
||||
|
||||
//snmp pdu type define [define in snmp.h]
|
||||
/*
|
||||
#define PDU_GET 0
|
||||
#define PDU_GETNEXT 1
|
||||
#define PDU_RSP 2
|
||||
#define PDU_SET 3
|
||||
#define PDU_GETBULK 5
|
||||
#define PDU_INFORM 6
|
||||
#define PDU_TRAP 7
|
||||
#define PDU_REPORT 8
|
||||
*/
|
||||
|
||||
//snmp var type code
|
||||
#define nInteger 0x02
|
||||
#define nOctetString 0x04
|
||||
#define nNull 0x05
|
||||
#define nObjectId 0x06
|
||||
#define nIPAddress 0x40
|
||||
#define nNoSuchObject 0x80
|
||||
#define nNoSuchInstance 0x81
|
||||
#define nEndOfMibView 0x82
|
||||
|
||||
//Operation_type
|
||||
#define DO_NOT_DISPLAY 0
|
||||
#define PULLDOWN_MENU 1
|
||||
#define TEXTBOX 2
|
||||
#define LABEL 3
|
||||
|
||||
//command type define
|
||||
#define nGetComm 0
|
||||
#define nSetComm 3
|
||||
#define nGetBulkComm 5
|
||||
#define nNewEntryComm 9
|
||||
|
||||
/***********************Error display define***************************/
|
||||
#define CONF_COMMAND_ERR_0000 "0000:Command successful"
|
||||
|
||||
//ERR_001*:should prompt the operator "Check the device's status"
|
||||
#define CONF_COMMAND_ERR_0101 "0101:OMC cannot get the device IP"
|
||||
#define CONF_COMMAND_ERR_0102 "0102:The device IP is error"
|
||||
|
||||
//ERR_002*:should prompt the operator "Check the software version of OMC and device"
|
||||
#define CONF_COMMAND_ERR_0201 "0201:OMC cannot get the object value"
|
||||
#define CONF_COMMAND_ERR_0202 "0202:OMC cannot get the instance value"
|
||||
|
||||
//ERR_003*:should prompt the operator "Check the OMC's status or send command again"
|
||||
#define CONF_COMMAND_ERR_0301 "0301:OMC send snmp message failed"
|
||||
|
||||
//ERR_004*:should prompt the operator "Check the device's status or send command again"
|
||||
#define CONF_COMMAND_ERR_0401 "0401:Invailed response message"
|
||||
#define CONF_COMMAND_ERR_0402 "0402:Error Response message"
|
||||
#define CONF_COMMAND_ERR_0403 "0403:Response timeout"
|
||||
|
||||
|
||||
#define CONF_COMMAND_ERR_9999 "9999:Unknown error"
|
||||
/******************Error display define End*******************************/
|
||||
|
||||
|
||||
typedef struct snmpInfoDef{
|
||||
/*General Info*/
|
||||
char dstIP[16];
|
||||
int needMuliObj; //can send or get more one objid in one packet
|
||||
WORD dstPort;
|
||||
WORD maxMsgLen;
|
||||
char snmpCommunity[16];
|
||||
|
||||
BYTE preOidLen; //The total OID of one system,it's defined in sysConf
|
||||
BYTE oidLen; //The oid len of the command's parameters
|
||||
int oid[MaxOidLen]; //The oid of this command's parameters
|
||||
BOOL isTablePara; //If or Not this command's parameters are table parameters
|
||||
int columnNum; //The column number of this table parameters
|
||||
int column[MaxColumnNum];//The columns of this table parameters
|
||||
BYTE instanceNoLevel; //The instanceNo level of this command's parameters
|
||||
int instanceNo[MaxInstanceNoLevel];//The instanceNo of this command's parameters
|
||||
}snmpInfoDef;
|
||||
|
||||
typedef struct unitComm {
|
||||
/*General Info*/
|
||||
WORD commId; //ID in command table,which is also SNMP's request_id
|
||||
WORD commType; //Command type get,set,get bulk,newEntry
|
||||
BYTE paramType; //0:subsys param/1:global subsys param/2:global sys param
|
||||
WORD sysTypeNo;
|
||||
WORD sysNo;
|
||||
WORD subSysNo;
|
||||
|
||||
MYSQL_RES *paramSet; //Store the infor,which is need when packeting SNMP message
|
||||
WORD totalNum;
|
||||
WORD finishNum;
|
||||
char desc[256];
|
||||
char paramTable[64];
|
||||
|
||||
snmpInfoDef snmpInfo;
|
||||
|
||||
/*command process info*/
|
||||
BYTE commState; //this command's state:0= nFailed, 1=nWaitProc, 2=nNoFinish, 3=nFinished
|
||||
BYTE procState; //command process state:0=idle,1=waitResponse
|
||||
BYTE waitTimeCount; //the times number of timeout
|
||||
BYTE timeoutCount; //the timeCount
|
||||
|
||||
//var_list info
|
||||
BYTE varNum;
|
||||
|
||||
BYTE levelWidth[MaxVarNum]; //The level(!=0) number of the parameter
|
||||
|
||||
char readValue[MaxVarNum][512];
|
||||
} unitComm;
|
||||
|
||||
/*************************************************
|
||||
Function: // initDbFromMib
|
||||
Description: // Get oid info from MIB file and init the paramConf tables.
|
||||
Calls: // extern int init_mib();extern struct tree *getLGCroot();extern struct get_tree;extern void close_mib();
|
||||
Called By: // paraCommInit();
|
||||
Table Accessed: //
|
||||
Table Updated: // paramConf
|
||||
Input: //
|
||||
Output: //
|
||||
Return: // 1:OK,0:error
|
||||
Others: //
|
||||
*************************************************/
|
||||
int initDbFromMib();
|
||||
|
||||
/*************************************************
|
||||
Function: // paraCommInit
|
||||
Description: // 1.Init OMC_PUB.parameterComm
|
||||
// 2.Init Commands Array
|
||||
// 3.Init Every module's paramConf
|
||||
Calls: // omcLogInit();initUnitComm();initDbFromMib();
|
||||
Called By: //
|
||||
Table Accessed: //
|
||||
Table Updated: // OMC_PUB.parameterComm;OBJ_xxx.paramConf
|
||||
Input: //
|
||||
Output: //
|
||||
Return: // 1:OK,0:error
|
||||
Others: //
|
||||
*************************************************/
|
||||
int paraCommInit();
|
||||
|
||||
/*************************************************
|
||||
Function: // paraCommTimer
|
||||
Description: // <20>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>顣
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD>
|
||||
|
||||
Calls: // paraCommScan();paraCommProc();omcLogInit();
|
||||
Called By: //
|
||||
Table Accessed: //
|
||||
Table Updated: //
|
||||
Input: //
|
||||
Output: //
|
||||
Return: // 1:OK,0:error
|
||||
Others: //
|
||||
*************************************************/
|
||||
int paraCommTimer();
|
||||
#endif
|
||||
137
src/configMgr/c_program/paraComm/paraCommMain.c
Normal file
137
src/configMgr/c_program/paraComm/paraCommMain.c
Normal file
@@ -0,0 +1,137 @@
|
||||
/*************************************************
|
||||
File name: paraCommMain.c
|
||||
Author: Cui Ticun
|
||||
Version: 9:00:00
|
||||
Date: 2007-7-2
|
||||
Description:
|
||||
|
||||
History:
|
||||
No.
|
||||
Author
|
||||
Date
|
||||
Version
|
||||
Description
|
||||
*************************************************/
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "paraComm.h"
|
||||
|
||||
static struct itimerval itimer, old_itimer;
|
||||
|
||||
void onParaCommTimer();
|
||||
void setParaCommTimer();
|
||||
void setup_daemon(void);
|
||||
int timerCounter = 0;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char runMode;
|
||||
|
||||
runMode = getopt(argc, argv, "d");
|
||||
switch (runMode) {
|
||||
case 'd':
|
||||
setup_daemon();
|
||||
break;
|
||||
case '?':
|
||||
break;
|
||||
}
|
||||
debug_init();
|
||||
fprintf(stderr, "\n Calling iptrans_init() \n");
|
||||
iptrans_init();
|
||||
|
||||
fprintf(stderr, "\n Calling snmp_init() \n");
|
||||
snmp_init(4957);
|
||||
|
||||
fprintf(stderr, "\n Calling paraCommInit() \n");
|
||||
if(paraCommInit()<=0)
|
||||
{
|
||||
exitLog("paraComm:main, paraCommInit function error");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
setParaCommTimer();
|
||||
|
||||
while (1) {
|
||||
usleep(50);
|
||||
}
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
void onParaCommTimer()
|
||||
{
|
||||
paraCommTimer();
|
||||
/*
|
||||
if (timerCounter > 5) {
|
||||
paraCommTimer();
|
||||
timerCounter = 0;
|
||||
}
|
||||
timerCounter++;
|
||||
*/
|
||||
}
|
||||
|
||||
void setParaCommTimer()
|
||||
{
|
||||
struct sigaction act;
|
||||
act.sa_handler = onParaCommTimer;
|
||||
sigemptyset(&act.sa_mask);
|
||||
act.sa_flags = 0;
|
||||
if (sigaction(SIGALRM, &act, NULL) < 0) {
|
||||
perror("Produce Sigaction");
|
||||
exitLog("paraComm:setParaCommTimer, sigaction function error");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
itimer.it_interval.tv_sec = 0;
|
||||
itimer.it_interval.tv_usec = 20 * 1000;
|
||||
itimer.it_value.tv_sec = 0;
|
||||
itimer.it_value.tv_usec = 20 * 1000;
|
||||
|
||||
if (setitimer(ITIMER_REAL, &itimer, &old_itimer) != 0) {
|
||||
printf("Setting Timer error! \n");
|
||||
exitLog("paraComm:setParaCommTimer, setitimer function error");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void setup_daemon(void)
|
||||
{
|
||||
/*
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i)
|
||||
close(i);
|
||||
*/
|
||||
switch (fork()) {
|
||||
case -1:
|
||||
{
|
||||
perror("setup_daemon(), 1st fork()");
|
||||
exit(2);
|
||||
}
|
||||
default:
|
||||
exit(0);
|
||||
case 0:
|
||||
if (setsid() == -1) {
|
||||
perror("setup_daemon(), setsid()");
|
||||
exit(3);
|
||||
}
|
||||
switch (fork()) {
|
||||
case -1:
|
||||
{
|
||||
perror("setup_daemon(), 2nd fork()");
|
||||
exit(3);
|
||||
}
|
||||
|
||||
default:
|
||||
exit(0);
|
||||
case 0:
|
||||
umask(0);
|
||||
/* and return with daemon set up */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
79
src/faultMgr/c_program/alarmAgent/Makefile
Normal file
79
src/faultMgr/c_program/alarmAgent/Makefile
Normal file
@@ -0,0 +1,79 @@
|
||||
#!/bin/sh
|
||||
|
||||
CC = gcc
|
||||
CFLAGS=-D_REENTRANT -g -Wall -D_TEST_
|
||||
|
||||
dbINCLUDE_FLAGS = -I/usr/local/mysql/include
|
||||
dbINCLUDE_FLAGS.ES = -I/usr/include/mariadb
|
||||
|
||||
LINKFLAG=-L../../../omcLib/c_program/omcLib -lomcLib \
|
||||
-L/usr/local/mysql/lib -lmariadbclient -lz \
|
||||
-L../../../../plat/snmp/lib -lsnmp \
|
||||
-L../../../../plat/iptrans/lib -liptrans \
|
||||
-L../../../../plat/debug/lib -ldebug \
|
||||
-L../../../../plat/public/lib -lpublic \
|
||||
|
||||
LINKFLAG.ES=-L../../../omcLib/c_program/omcLib -lomcLib \
|
||||
-L/usr/lib/mysql -lmariadbclient -lz \
|
||||
-L../../../../plat/snmp/lib -lsnmp \
|
||||
-L../../../../plat/sccp/lib -lsccp \
|
||||
-L../../../../plat/iptrans/lib -liptrans \
|
||||
-L../../../../plat/debug/lib -ldebug \
|
||||
-L../../../../plat/public/lib -lpublic \
|
||||
|
||||
LINK_SUFFIX = $(dbINCLUDE_FLAGS) $(LINKFLAG)
|
||||
LINK_SUFFIX.ES = $(dbINCLUDE_FLAGS.ES) $(LINKFLAG.ES)
|
||||
|
||||
PROGS=alarmAgent
|
||||
|
||||
ALL_OBJ = alarmSnmp.o alarmAgent.o
|
||||
ALL_OBJ.ES = alarmSnmp.o.ES alarmAgent.o.ES
|
||||
|
||||
LIB_OBJ = alarmSnmp.o
|
||||
LIB_OBJ.ES = alarmSnmp.o.ES
|
||||
|
||||
default: linuxES
|
||||
|
||||
all:
|
||||
@echo " **** Compiling $(PROGS) ****"
|
||||
@echo "make clean -- Delete the target files"
|
||||
@echo "make linux72 -- Generate target files for Redhat Linux 72"
|
||||
@echo "make linuxES -- Generate target files for Redhat Linux ES"
|
||||
|
||||
linux72: $(ALL_OBJ)
|
||||
@echo Linking $(PROGS)
|
||||
@$(CC) $(CFLAGS) -o $(PROGS) $(ALL_OBJ) $(LINK_SUFFIX) -lm
|
||||
ar r libalarmAgent.a $(LIB_OBJ)
|
||||
rm -rf *.o *~
|
||||
cp -f $(PROGS) ../../../../bin/
|
||||
cp -f $(PROGS) /usr/local/omc/bin/
|
||||
|
||||
linuxES: $(ALL_OBJ.ES)
|
||||
@echo Linking $(PROGS)
|
||||
@$(CC) $(CFLAGS) -o $(PROGS) $(ALL_OBJ) $(LINK_SUFFIX.ES) -lm
|
||||
ar r libalarmAgent.a $(LIB_OBJ)
|
||||
# rm -rf *.o *~
|
||||
|
||||
installbin: linuxES
|
||||
cp -f $(PROGS) ../../../../bin/
|
||||
|
||||
installomc: linuxES
|
||||
cp -f $(PROGS) /usr/local/omc/bin/
|
||||
|
||||
installall: installbin installomc
|
||||
|
||||
alarmSnmp.o: alarmSnmp.c alarmAgent.h
|
||||
$(CC) $(CFLAGS) -c alarmSnmp.c $(dbINCLUDE_FLAGS)
|
||||
|
||||
alarmAgent.o: alarmAgent.c alarmAgent.h
|
||||
$(CC) $(CFLAGS) -c alarmAgent.c $(dbINCLUDE_FLAGS)
|
||||
|
||||
alarmSnmp.o.ES: alarmSnmp.c alarmAgent.h
|
||||
$(CC) $(CFLAGS) -c alarmSnmp.c $(dbINCLUDE_FLAGS.ES)
|
||||
|
||||
alarmAgent.o.ES: alarmAgent.c alarmAgent.h
|
||||
$(CC) $(CFLAGS) -c alarmAgent.c $(dbINCLUDE_FLAGS.ES)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(PROGS)
|
||||
|
||||
89
src/faultMgr/c_program/alarmAgent/alarmAgent.c
Normal file
89
src/faultMgr/c_program/alarmAgent/alarmAgent.c
Normal file
@@ -0,0 +1,89 @@
|
||||
/**************************************/
|
||||
/*Title: alarmagent.c */
|
||||
/*Descr: Alarm Agent */
|
||||
/* --MIB(WXC2-ALARM) */
|
||||
/*Author: Yi zheng */
|
||||
/*Create: 2006-6-1 */
|
||||
/**************************************/
|
||||
#include "alarmAgent.h"
|
||||
static struct itimerval itimer, old_itimer;
|
||||
static void On_Timer();
|
||||
static void SetTimer();
|
||||
|
||||
extern int alarm_SnmpInit(void);
|
||||
extern int alarm_db_init(void);
|
||||
extern void alarm_Agent_timer(void);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
pid_t pid;
|
||||
debug_init();
|
||||
if (argc == 2 && strstr(argv[1], "-d"))
|
||||
{
|
||||
if ((pid = fork()) != 0)
|
||||
exit(0);
|
||||
setsid();
|
||||
}
|
||||
/*
|
||||
#ifndef __RUN_SELF
|
||||
iptrans_init();
|
||||
// debug_init(0);
|
||||
#else
|
||||
debug_init(1);
|
||||
// iptrMainInit();
|
||||
#endif
|
||||
*/
|
||||
iptrans_init();
|
||||
|
||||
alarm_SnmpInit();
|
||||
SetTimer();
|
||||
while (1)
|
||||
usleep(50);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void On_Timer()
|
||||
{
|
||||
static BYTE flag=0;
|
||||
#ifdef __RUN_SELF
|
||||
iptrans_timer();
|
||||
debug_rt();
|
||||
#endif
|
||||
if(flag==0)
|
||||
{
|
||||
flag = 1;
|
||||
snmp_timer();
|
||||
alarm_Agent_timer();
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SetTimer()
|
||||
{
|
||||
struct sigaction act;
|
||||
act.sa_handler = On_Timer;
|
||||
sigemptyset(&act.sa_mask);
|
||||
|
||||
act.sa_flags = 0;
|
||||
if (sigaction(SIGALRM, &act, NULL) < 0)
|
||||
{
|
||||
perror("Produce Sigaction");
|
||||
exitLog("alarmAgent:SetTimer, sigaction function error");
|
||||
exit(1);
|
||||
}
|
||||
itimer.it_interval.tv_sec = 0;
|
||||
itimer.it_interval.tv_usec = 20 * 1000;
|
||||
itimer.it_value.tv_sec = 0;
|
||||
itimer.it_value.tv_usec = 20 * 1000;
|
||||
|
||||
if (setitimer(ITIMER_REAL, &itimer, &old_itimer) != 0)
|
||||
{
|
||||
printf("Setting Timer error! \n");
|
||||
exitLog("alarmAgent:SetTimer, setitimer function error");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
55
src/faultMgr/c_program/alarmAgent/alarmAgent.h
Normal file
55
src/faultMgr/c_program/alarmAgent/alarmAgent.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/********************************************************/
|
||||
/*Title: alarmagent.c */
|
||||
/*Descr: Alarm Agent */
|
||||
/* --MIB(WXC2-ALARM) */
|
||||
/*Author: Yi zheng */
|
||||
/*Create: 2006-6-1 */
|
||||
/********************************************************/
|
||||
|
||||
#ifndef __ALARM_AGENT_FILE
|
||||
#define __ALARM_AGENT_FILE
|
||||
#endif
|
||||
|
||||
//#define __RUN_SELF
|
||||
#define WXC2_R8 1
|
||||
#define ALARM_SNMP_PORT 4961
|
||||
#define OMCD_CONF_FILE "./conf/omcd.conf"
|
||||
|
||||
#ifndef _LINUX_ES
|
||||
#include "mysql.h"
|
||||
// #define ALARM_TABLE_FILE "/usr/local/mysql-3.23.52-pc-linux-gnu-i686/data/OMC_PUB/sysAlarmLog.MYD"
|
||||
#define ALARM_TABLE_FILE "/var/lib/mysql/OMC_PUB/sysAlarmLog.MYD"
|
||||
#else
|
||||
#include "/usr/include/mysql/mysql.h"
|
||||
#define ALARM_TABLE_FILE "/var/lib/mysql/OMC_PUB/sysAlarmLog.MYD"
|
||||
#endif
|
||||
|
||||
#include "../../../omcLib/c_program/omcLib/omcLib.h"
|
||||
#include "../../../../plat/snmp/src/include/snmp.h"
|
||||
#include "../../../../plat/debug/src/include/debug.h"
|
||||
|
||||
int alarm_SnmpInit(void);
|
||||
void alarm_Agent_timer(void);
|
||||
|
||||
typedef struct alarm_set
|
||||
{
|
||||
DWORD sq_Num; // alarmSequenceNumber Counter32,
|
||||
char mag_ObjName[64]; // alarmManagedObjName OCTET STRING,
|
||||
WORD mag_ObjIns; // alarmManagedObjInstance INTEGER,
|
||||
char mag_ComName[64]; // alarmComponentName OCTET STRING,
|
||||
WORD mag_ComIns; // alarmComponentInstance INTEGER,
|
||||
char date_Time[64]; // alarmDateAndTime TimeTicks,
|
||||
char ip_Addr[64]; // alarmEventEngineAddress IpAddress,
|
||||
WORD event_Code; // alarmEventCode INTEGER,
|
||||
WORD severity_ID; // alarmSeverity INTEGER,
|
||||
char active_Desc[128]; // alarmActiveDescription OCTET STRING,
|
||||
WORD notifiy_ID; // alarmNotificationID OBJECT IDENTIFIER
|
||||
|
||||
|
||||
WORD sysTypeNo; //
|
||||
WORD compCode; //
|
||||
BYTE alarmCode; //
|
||||
} alarm_set;
|
||||
|
||||
|
||||
|
||||
1044
src/faultMgr/c_program/alarmAgent/alarmSnmp.c
Normal file
1044
src/faultMgr/c_program/alarmAgent/alarmSnmp.c
Normal file
File diff suppressed because it is too large
Load Diff
BIN
src/faultMgr/c_program/alarmGenerator/Alarm List.xls
Normal file
BIN
src/faultMgr/c_program/alarmGenerator/Alarm List.xls
Normal file
Binary file not shown.
77
src/faultMgr/c_program/alarmGenerator/Makefile
Normal file
77
src/faultMgr/c_program/alarmGenerator/Makefile
Normal file
@@ -0,0 +1,77 @@
|
||||
#!/bin/sh
|
||||
|
||||
CC = gcc
|
||||
CFLAGS=-D_REENTRANT -g -Wall -D_TEST_ -D__RUN_SELF
|
||||
|
||||
dbINCLUDE_FLAGS = -I/usr/local/mysql/include
|
||||
dbINCLUDE_FLAGS.ES = -I/usr/include/mariadb
|
||||
|
||||
LINKFLAG=-L../../../omcLib/c_program/omcLib -lomcLib \
|
||||
-L/usr/local/mysql/lib -lmariadbclient -lz \
|
||||
-L../../../../plat/snmp/lib -lsnmp \
|
||||
-L../../../../plat/iptrans/lib -liptrans \
|
||||
-L../../../../plat/debug/lib -ldebug \
|
||||
-L../../../../plat/public/lib -lpublic \
|
||||
|
||||
LINKFLAG.ES=-L../../../omcLib/c_program/omcLib -lomcLib \
|
||||
-L/usr/lib/mysql -lmariadbclient -lz \
|
||||
-L../../../../plat/snmp/lib -lsnmp \
|
||||
-L../../../../plat/sccp/lib -lsccp \
|
||||
-L../../../../plat/iptrans/lib -liptrans \
|
||||
-L../../../../plat/debug/lib -ldebug \
|
||||
-L../../../../plat/public/lib -lpublic \
|
||||
|
||||
LINK_SUFFIX = $(dbINCLUDE_FLAGS) $(LINKFLAG)
|
||||
LINK_SUFFIX.ES = $(dbINCLUDE_FLAGS.ES) $(LINKFLAG.ES)
|
||||
|
||||
PROGS=alarmGenerator
|
||||
|
||||
OBJ = alarmGen.o
|
||||
OBJ.ES = alarmGen.o.ES
|
||||
|
||||
default: linuxES
|
||||
|
||||
all:
|
||||
@echo " **** Compiling $(PROGS) ****"
|
||||
@echo "make clean -- Delete the target files"
|
||||
@echo "make linux72 -- Generate target files for Redhat Linux 72"
|
||||
@echo "make linuxES -- Generate target files for Redhat Linux ES"
|
||||
|
||||
linux72: $(OBJ) alarmMain.o
|
||||
@echo Linking $(PROGS)
|
||||
@$(CC) $(CFLAGS) -o $(PROGS) alarmMain.o $(OBJ) $(LINKFLAG) -lm
|
||||
ar r libalarmGen.a $(OBJ)
|
||||
rm -rf *.o *bak *~
|
||||
#cp -f $(PROGS) ../../../../bin/
|
||||
#cp -f $(PROGS) /usr/local/omc/bin/
|
||||
|
||||
linuxES: $(OBJ.ES) alarmMain.o.ES
|
||||
@echo Linking $(PROGS)
|
||||
@$(CC) $(CFLAGS) -o $(PROGS) alarmMain.o $(OBJ) $(LINKFLAG.ES) -lm
|
||||
ar r libalarmGen.a $(OBJ)
|
||||
rm -rf *.o *bak *~
|
||||
#cp -f $(PROGS) ../../../../bin/
|
||||
#cp -f $(PROGS) /usr/local/omc/bin/
|
||||
|
||||
installbin: linuxES
|
||||
cp -f $(PROGS) ../../../../bin/
|
||||
|
||||
installomc: linuxES
|
||||
cp -f $(PROGS) /usr/local/omc/bin/
|
||||
|
||||
installall: installbin installomc
|
||||
|
||||
alarmGen.o: alarmGen.c alarmGen.h
|
||||
$(CC) $(CFLAGS) -c alarmGen.c $(dbINCLUDE_FLAGS)
|
||||
|
||||
alarmMain.o: alarmMain.c alarmGen.h
|
||||
$(CC) $(CFLAGS) -c alarmMain.c $(dbINCLUDE_FLAGS)
|
||||
|
||||
alarmGen.o.ES: alarmGen.c alarmGen.h
|
||||
$(CC) $(CFLAGS) -c alarmGen.c $(dbINCLUDE_FLAGS.ES)
|
||||
|
||||
alarmMain.o.ES: alarmMain.c alarmGen.h
|
||||
$(CC) $(CFLAGS) -c alarmMain.c $(dbINCLUDE_FLAGS.ES)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(PROGS)
|
||||
Binary file not shown.
86
src/faultMgr/c_program/alarmGenerator/alarmAgent.c
Normal file
86
src/faultMgr/c_program/alarmGenerator/alarmAgent.c
Normal file
@@ -0,0 +1,86 @@
|
||||
/**************************************/
|
||||
/*Title: alarmagent.c */
|
||||
/*Descr: Alarm Agent */
|
||||
/* --MIB(WXC2-ALARM) */
|
||||
/*Author: Yi zheng */
|
||||
/*Create: 2006-6-1 */
|
||||
/**************************************/
|
||||
#include "alarmAgent.h"
|
||||
#define ALARM_SNMP_PORT 4961
|
||||
static struct itimerval itimer, old_itimer;
|
||||
static void On_Timer();
|
||||
static void SetTimer();
|
||||
|
||||
extern int alarm_SnmpInit(void);
|
||||
extern int alarm_db_init(void);
|
||||
extern void alarm_Agent_timer(void);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
pid_t pid;
|
||||
|
||||
if (argc == 2 && strstr(argv[1], "-d"))
|
||||
{
|
||||
if ((pid = fork()) != 0)
|
||||
exit(0);
|
||||
setsid();
|
||||
}
|
||||
#ifndef __RUN_SELF
|
||||
iptrans_init();
|
||||
// debug_init(0);
|
||||
#else
|
||||
debug_init(1);
|
||||
iptrMainInit();
|
||||
#endif
|
||||
snmp_init(ALARM_SNMP_PORT);
|
||||
|
||||
alarm_SnmpInit();
|
||||
SetTimer();
|
||||
while (1)
|
||||
usleep(50);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void On_Timer()
|
||||
{
|
||||
static BYTE flag=0;
|
||||
#ifdef __RUN_SELF
|
||||
iptrans_timer();
|
||||
debug_rt();
|
||||
#endif
|
||||
if(flag==0)
|
||||
{
|
||||
flag = 1;
|
||||
snmp_timer();
|
||||
alarm_Agent_timer();
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SetTimer()
|
||||
{
|
||||
struct sigaction act;
|
||||
act.sa_handler = On_Timer;
|
||||
sigemptyset(&act.sa_mask);
|
||||
|
||||
act.sa_flags = 0;
|
||||
if (sigaction(SIGALRM, &act, NULL) < 0)
|
||||
{
|
||||
perror("Produce Sigaction");
|
||||
exit(1);
|
||||
}
|
||||
itimer.it_interval.tv_sec = 0;
|
||||
itimer.it_interval.tv_usec = 20 * 1000;
|
||||
itimer.it_value.tv_sec = 0;
|
||||
itimer.it_value.tv_usec = 20 * 1000;
|
||||
|
||||
if (setitimer(ITIMER_REAL, &itimer, &old_itimer) != 0)
|
||||
{
|
||||
printf("Setting Timer error! \n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
47
src/faultMgr/c_program/alarmGenerator/alarmAgent.h
Normal file
47
src/faultMgr/c_program/alarmGenerator/alarmAgent.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/********************************************************/
|
||||
/*Title: alarmagent.c */
|
||||
/*Descr: Alarm Agent */
|
||||
/* --MIB(WXC2-ALARM) */
|
||||
/*Author: Yi zheng */
|
||||
/*Create: 2006-6-1 */
|
||||
/********************************************************/
|
||||
|
||||
#ifndef __ALARM_AGENT_FILE
|
||||
#define __ALARM_AGENT_FILE
|
||||
#endif
|
||||
|
||||
//#define __RUN_SELF
|
||||
#define WXC2_R8 1
|
||||
|
||||
|
||||
#ifndef _LINUX_ES
|
||||
#include "mysql.h"
|
||||
#define ALARM_TABLE_FILE "/usr/local/mysql-3.23.52-pc-linux-gnu-i686/data/OMC_PUB/sysAlarmLog.MYD"
|
||||
#else
|
||||
#include "/usr/include/mysql/mysql.h"
|
||||
#define ALARM_TABLE_FILE "/var/lib/mysql/OMC_PUB/sysAlarmLog.MYD"
|
||||
#endif
|
||||
|
||||
#include "../snmp_new/snmp.h"
|
||||
#include "../debug/debug.h"
|
||||
|
||||
int alarm_SnmpInit(void);
|
||||
void alarm_Agent_timer(void);
|
||||
|
||||
typedef struct alarm_set
|
||||
{
|
||||
DWORD sq_Num; // alarmSequenceNumber Counter32,
|
||||
char mag_ObjName[64]; // alarmManagedObjName OCTET STRING,
|
||||
WORD mag_ObjIns; // alarmManagedObjInstance INTEGER,
|
||||
char mag_ComName[64]; // alarmComponentName OCTET STRING,
|
||||
WORD mag_ComIns; // alarmComponentInstance INTEGER,
|
||||
char date_Time[64]; // alarmDateAndTime TimeTicks,
|
||||
char ip_Addr[64]; // alarmEventEngineAddress IpAddress,
|
||||
WORD event_Code; // alarmEventCode INTEGER,
|
||||
WORD severity_ID; // alarmSeverity INTEGER,
|
||||
char active_Desc[128]; // alarmActiveDescription OCTET STRING,
|
||||
WORD notifiy_ID; // alarmNotificationID OBJECT IDENTIFIER
|
||||
} alarm_set;
|
||||
|
||||
|
||||
|
||||
1176
src/faultMgr/c_program/alarmGenerator/alarmGen.c
Normal file
1176
src/faultMgr/c_program/alarmGenerator/alarmGen.c
Normal file
File diff suppressed because it is too large
Load Diff
30
src/faultMgr/c_program/alarmGenerator/alarmGen.h
Normal file
30
src/faultMgr/c_program/alarmGenerator/alarmGen.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/********************************************************/
|
||||
/*Title: alarmagent.c */
|
||||
/*Descr: Alarm Agent */
|
||||
/* --MIB(WXC2-ALARM) */
|
||||
/*Author: Yi zheng */
|
||||
/*Create: 2006-6-1 */
|
||||
/********************************************************/
|
||||
|
||||
#ifndef __ALARM_AGENT_FILE
|
||||
#define __ALARM_AGENT_FILE
|
||||
#endif
|
||||
|
||||
//#define __RUN_SELF
|
||||
#define WXC2_R8 1
|
||||
#define GENPORT 4957
|
||||
|
||||
|
||||
#ifndef _LINUX_ES
|
||||
#include "mysql.h"
|
||||
#else
|
||||
#include "/usr/include/mysql/mysql.h"
|
||||
#endif
|
||||
|
||||
#include "../../../../plat/snmp/src/include/snmp.h"
|
||||
|
||||
|
||||
int alarm_GenInit(void);
|
||||
void alarm_Gen_timer(void);
|
||||
|
||||
|
||||
86
src/faultMgr/c_program/alarmGenerator/alarmMain.c
Normal file
86
src/faultMgr/c_program/alarmGenerator/alarmMain.c
Normal file
@@ -0,0 +1,86 @@
|
||||
/**************************************/
|
||||
/*Title: alarmagent.c */
|
||||
/*Descr: Alarm Agent */
|
||||
/* --MIB(WXC2-ALARM) */
|
||||
/*Author: Yi zheng */
|
||||
/*Create: 2006-6-1 */
|
||||
/**************************************/
|
||||
#include "alarmGen.h"
|
||||
static struct itimerval itimer, old_itimer;
|
||||
static void On_Timer();
|
||||
static void SetTimer();
|
||||
|
||||
extern int alarm_GenInit(void);
|
||||
extern int alarm_db_init(void);
|
||||
extern void alarm_Gen_timer(void);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
pid_t pid;
|
||||
|
||||
if (argc == 2 && strstr(argv[1], "-d"))
|
||||
{
|
||||
if ((pid = fork()) != 0)
|
||||
exit(0);
|
||||
setsid();
|
||||
}
|
||||
#ifndef __RUN_SELF
|
||||
iptrans_init();
|
||||
debug_init(1);
|
||||
#else
|
||||
debug_init(1);
|
||||
iptrMainInit();
|
||||
// iptrans_init();
|
||||
#endif
|
||||
snmp_init(GENPORT);
|
||||
|
||||
alarm_GenInit();
|
||||
SetTimer();
|
||||
while (1)
|
||||
usleep(50);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void On_Timer()
|
||||
{
|
||||
static BYTE flag=0;
|
||||
#ifdef __RUN_SELF
|
||||
iptrans_timer();
|
||||
debug_rt();
|
||||
#endif
|
||||
if(flag==0)
|
||||
{
|
||||
flag = 1;
|
||||
snmp_timer();
|
||||
alarm_Gen_timer();
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SetTimer()
|
||||
{
|
||||
struct sigaction act;
|
||||
act.sa_handler = On_Timer;
|
||||
sigemptyset(&act.sa_mask);
|
||||
|
||||
act.sa_flags = 0;
|
||||
if (sigaction(SIGALRM, &act, NULL) < 0)
|
||||
{
|
||||
perror("Produce Sigaction");
|
||||
exit(1);
|
||||
}
|
||||
itimer.it_interval.tv_sec = 0;
|
||||
itimer.it_interval.tv_usec = 20 * 1000;
|
||||
itimer.it_value.tv_sec = 0;
|
||||
itimer.it_value.tv_usec = 20 * 1000;
|
||||
|
||||
if (setitimer(ITIMER_REAL, &itimer, &old_itimer) != 0)
|
||||
{
|
||||
printf("Setting Timer error! \n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BIN
src/faultMgr/c_program/alarmGenerator/conf.tgz
Normal file
BIN
src/faultMgr/c_program/alarmGenerator/conf.tgz
Normal file
Binary file not shown.
@@ -0,0 +1,40 @@
|
||||
-- *****************************************************************
|
||||
-- IWV-SMI: interWAVE Enterprise Structure of Management Information
|
||||
--
|
||||
-- draft November 2000, Huang qilong
|
||||
-- 1st November 2004, Sheng Xueqiang
|
||||
--
|
||||
-- Copyright (c) 2000 by interWAVE, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- *****************************************************************
|
||||
--
|
||||
|
||||
IWV-SMI DEFINITIONS ::= BEGIN
|
||||
|
||||
IMPORTS
|
||||
MODULE-IDENTITY,
|
||||
OBJECT-IDENTITY,
|
||||
enterprises
|
||||
FROM SNMPv2-SMI;
|
||||
|
||||
IWV MODULE-IDENTITY
|
||||
LAST-UPDATED "0411170000Z"
|
||||
ORGANIZATION "interWAVE, Inc."
|
||||
CONTACT-INFO
|
||||
"http://www.iwv.com"
|
||||
DESCRIPTION
|
||||
"The Structure of Management Information for the interWAVE enterprise."
|
||||
REVISION "200411170000Z"
|
||||
DESCRIPTION
|
||||
"1st version of this MIB module."
|
||||
::= { enterprises 1373 } -- assigned by IANA
|
||||
|
||||
|
||||
IWV_Products OBJECT-IDENTITY
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"iwvProducts is the root OBJECT IDENTIFIER from which sysObjectID values are assigned. Actual values are defined in IWV-PRODUCTS-MIB."
|
||||
::= { IWV 1 }
|
||||
|
||||
END
|
||||
@@ -0,0 +1,43 @@
|
||||
-- *****************************************************************
|
||||
-- Special_App-SMI: WXC2 Structure of Management Information
|
||||
--
|
||||
-- draft November 2004, Sheng Xueqiang
|
||||
--
|
||||
-- Copyright (c) 2004 by interWAVE, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- *****************************************************************
|
||||
--
|
||||
|
||||
Special_App-SMI DEFINITIONS ::= BEGIN
|
||||
|
||||
IMPORTS
|
||||
MODULE-IDENTITY,
|
||||
OBJECT-IDENTITY,
|
||||
FROM SNMPv2-SMI
|
||||
IWV_Products
|
||||
FROM IWV-SMI;
|
||||
|
||||
Special_App MODULE-IDENTITY
|
||||
LAST-UPDATED "0411180000Z"
|
||||
ORGANIZATION "interWAVE, Inc."
|
||||
CONTACT-INFO
|
||||
"http://www.iwv.com"
|
||||
DESCRIPTION
|
||||
"The Structure of Management Information for the Special Application of interWAVE enterprise."
|
||||
REVISION "200411180000Z"
|
||||
DESCRIPTION
|
||||
"1st version of this MIB module."
|
||||
::= { IWV_Products 2 }
|
||||
|
||||
-- CNF Center
|
||||
-- IWF
|
||||
IWF OBJECT-IDENTITY
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"IWF "
|
||||
::= { Special_App 8 }
|
||||
|
||||
-- PPP Route
|
||||
|
||||
END
|
||||
@@ -0,0 +1,60 @@
|
||||
// host ip
|
||||
// "//" is the annotation characters; ";" is the septation characters;
|
||||
8KE1_0_0 -- ; 172.18.0.1;
|
||||
8KE1_0_1 -- ; 172.18.1.1;
|
||||
8KE1_0_2 -- ; 172.18.2.1;
|
||||
8KE1_0_3 -- ; 172.18.3.1;
|
||||
8KE1_0_4 -- ; 172.18.4.1;
|
||||
8KE1_0_5 -- ; 172.18.5.1;
|
||||
8KE1_0_6 -- ; 172.18.6.1;
|
||||
8KE1_0_7 -- ; 172.18.7.1;
|
||||
8KE1_0_8 -- ; 172.18.8.1;
|
||||
8KE1_0_9 -- ; 172.18.9.1;
|
||||
8KE1_0_10 -- ; 172.18.9.1;
|
||||
8KE1_0_11 -- ; 172.18.9.1;
|
||||
8KE1_0_12 -- ; 172.18.9.1;
|
||||
8KE1_0_13 -- ; 172.18.13.1;
|
||||
8KE1_0_14 -- ; 172.18.14.1;
|
||||
8KE1_0_15 -- ; 172.18.15.1;
|
||||
8KE1_1_0 -- ; 172.18.16.1;
|
||||
8KE1_1_1 -- ; 172.18.17.1;
|
||||
8KE1_1_2 -- ; 172.18.18.1;
|
||||
8KE1_1_3 -- ; 172.18.19.1;
|
||||
8KE1_1_4 -- ; 172.18.20.1;
|
||||
8KE1_1_5 -- ; 172.18.21.1;
|
||||
8KE1_1_6 -- ; 172.18.22.1;
|
||||
8KE1_1_7 -- ; 172.18.23.1;
|
||||
8KE1_1_8 -- ; 172.18.24.1;
|
||||
8KE1_1_9 -- ; 172.18.25.1;
|
||||
8KE1_1_10 -- ; 172.18.26.1;
|
||||
8KE1_1_11 -- ; 172.18.27.1;
|
||||
8KE1_1_12 -- ; 172.18.28.1;
|
||||
8KE1_1_13 -- ; 172.18.29.1;
|
||||
8KE1_1_14 -- ; 172.18.30.1;
|
||||
8KE1_1_15 -- ; 172.18.31.1;
|
||||
PLAT_0_0 -- ; 172.18.144.1;
|
||||
PLAT_1_0 -- ; 172.18.133.1;
|
||||
MTP3_0_0 mss-0 ; 172.18.144.1;
|
||||
MTP3_1_0 mss-1 ; 172.18.133.1;
|
||||
SCCP_0_0 mss-0 ; 172.18.144.1;
|
||||
SCCP_1_0 mss-1 ; 172.18.133.1;
|
||||
XAPP_0_0 MSS-0 ; 172.18.144.1;
|
||||
XAPP_1_0 MSS-1 ; 172.18.133.1;
|
||||
SMPP_0_0 SMPP-0; 172.18.144.1;
|
||||
MSC_0_0 -- ; 172.18.234.231;
|
||||
MSC_1_0 -- ; 172.18.133.1;
|
||||
CCF(MSC)_0_0 --; 172.18.234.231;
|
||||
CCF(MSC)_1_0 --; 172.18.133.1;
|
||||
VLR_0_0 VLR-0 ; 172.18.234.231;
|
||||
VLR_1_0 VLR-1 ; 172.18..1;
|
||||
HLR_0_0 -- ; 172.18.234.231;
|
||||
HLR_1_0 -- ; 172.18.234.230;
|
||||
AUC_0_0 -- ; 172.18.234.231;
|
||||
AUC_1_0 -- ; 172.18.234.230;
|
||||
SMSC_0_0 -- ; 172.18.224.231;
|
||||
SMSC_1_0 -- ; 172.18.234.230;
|
||||
PPS_0_0 -- ; 172.18.234.230;
|
||||
PPS_1_0 -- ; 172.18.234.230;
|
||||
EIR_0_0 -- ; 172.18.234.231;
|
||||
MSS_0_0 wxc2-0 ; 172.18.234.231;
|
||||
MSS_1_0 wxc2-1 ; 172.18.133.1;
|
||||
@@ -0,0 +1,57 @@
|
||||
-- *****************************************************************
|
||||
-- WXC2-SMI: WXC2 Structure of Management Information
|
||||
--
|
||||
-- draft November 2000, Huang qilong
|
||||
-- 1st November 2004, Sheng Xueqiang
|
||||
--
|
||||
-- Copyright (c) 2004 by interWAVE, Inc.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- *****************************************************************
|
||||
--
|
||||
|
||||
WXC2-SMI DEFINITIONS ::= BEGIN
|
||||
|
||||
IMPORTS
|
||||
MODULE-IDENTITY,
|
||||
OBJECT-IDENTITY,
|
||||
FROM SNMPv2-SMI
|
||||
IWV_Products
|
||||
FROM IWV-SMI;
|
||||
|
||||
WXC2 MODULE-IDENTITY
|
||||
LAST-UPDATED "200506050000Z"
|
||||
ORGANIZATION "interWAVE, Inc."
|
||||
CONTACT-INFO
|
||||
"http://www.iwv.com"
|
||||
DESCRIPTION
|
||||
"The Structure of Management Information for the WXC2 of interWAVE enterprise."
|
||||
REVISION "200506050000Z"
|
||||
DESCRIPTION
|
||||
"1st version of this MIB module."
|
||||
::= { IWV_Products 3 }
|
||||
|
||||
-- WXC2_PCM
|
||||
PCM OBJECT-IDENTITY
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"PCM "
|
||||
::= { WXC2 1 }
|
||||
|
||||
|
||||
-- WXC2_platform
|
||||
Platform OBJECT-IDENTITY
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"Platform "
|
||||
::= { WXC2 2 }
|
||||
|
||||
-- WXC2_App
|
||||
|
||||
App OBJECT-IDENTITY
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"App platform"
|
||||
::= { WXC2 3 }
|
||||
|
||||
END
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user