龙芯
git-svn-id: http://172.17.0.253/svn/soft_pkgs/sys_nicmonitor@789 09c3743a-b0dd-45d3-b506-aa74c7a2a6ef
This commit is contained in:
28
branches/sys_nicmonitor-1.4-龙芯-32/Makefile
Normal file
28
branches/sys_nicmonitor-1.4-龙芯-32/Makefile
Normal file
@@ -0,0 +1,28 @@
|
||||
#! /usr/bin/make -f
|
||||
|
||||
DEFAULTS = Makefile.config
|
||||
|
||||
include $(DEFAULTS)
|
||||
|
||||
all:sys_nicmonitor libnic_shm.so
|
||||
|
||||
CFLAGS += -Wall -Wformat=2 -Wno-format-extra-args -Wformat-security -Wformat-nonliteral #-g
|
||||
|
||||
sys_nicmonitor:mnic.o read_netcard.o send_alarm.o
|
||||
$(CC) -lman -ldotconf -lpthread -o $@ $^
|
||||
libnic_shm.so:nicinfo_shm.c
|
||||
$(CC) -fpic -shared -o $@ $^
|
||||
clean:
|
||||
$(RM) *.o
|
||||
$(RM) libnic_shm.so sys_nicmonitor
|
||||
install:
|
||||
$(MKDIR) -p $(LIBDIR)
|
||||
$(MKDIR) -p $(BINDIR)
|
||||
$(MKDIR) -p $(INCDIR)
|
||||
$(CP) libnic_shm.so $(LIBDIR)
|
||||
$(CP) sys_nicmonitor $(BINDIR)
|
||||
$(CP) nicinfo_shm.h $(INCDIR)
|
||||
uninstall:
|
||||
$(RM) -f $(LIBDIR)/libnic_shm.so
|
||||
$(RM) -f $(BINDIR)/sys_nicmonitor
|
||||
$(RM) -f $(INCDIR)/nicinfo_shm.h
|
||||
16
branches/sys_nicmonitor-1.4-龙芯-32/Makefile.config
Normal file
16
branches/sys_nicmonitor-1.4-龙芯-32/Makefile.config
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
PREFIX = $(DESTDIR)
|
||||
|
||||
BINDIR = $(PREFIX)/usr/bin
|
||||
|
||||
LIBDIR = $(PREFIX)/usr/lib64
|
||||
|
||||
INCDIR = $(PREFIX)/usr/include
|
||||
|
||||
INSTALL_SH = ./install.sh
|
||||
|
||||
CP = cp
|
||||
RM = rm
|
||||
#CC = gcc
|
||||
CC = g++
|
||||
MKDIR = mkdir
|
||||
51
branches/sys_nicmonitor-1.4-龙芯-32/const.h
Normal file
51
branches/sys_nicmonitor-1.4-龙芯-32/const.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef _RTE_CONST_H
|
||||
#define _RTE_CONST_H
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
|
||||
#define MAX_STRING_LEN 24
|
||||
#define MAX_EXECMD_LEN 200
|
||||
#define MAX_FILENAME_LEN 200
|
||||
|
||||
#define MAX_CONTEXT 8
|
||||
#define MAX_HOSTNAME_LEN 24
|
||||
#define MAX_LOCAL_MESPROC 512
|
||||
#define MAX_LOCAL_PROCESS MAX_LOCAL_MESPROC
|
||||
#define MAX_LOCAL_APP 32
|
||||
#define MAX_LOCAL_NODE 256
|
||||
|
||||
#define MAX_SET 256 //max num of event set
|
||||
#define MAX_EVENT 1300
|
||||
#define MAX_REG_PROC 20
|
||||
|
||||
#define LEN_SHMBLK_BIG 4096
|
||||
#define MAX_MSGBUF_LEN 32767
|
||||
#define FREE_PAGE_SIZE 65536
|
||||
#define MAX_PAGE_NUM 1024
|
||||
|
||||
#define MAX_QUE MAX_LOCAL_MESPROC
|
||||
#define MAX_SEMPHORE_SET MAX_LOCAL_MESPROC*2
|
||||
#define RTE_HAN 0 // queue number for event handeler0(RTE)
|
||||
#define EX_EVENT_HAN RTE_HAN // queue number for extrnal event handeler
|
||||
|
||||
#define DOMAIN_I 1
|
||||
#define DOMAIN_II 2
|
||||
#define DOMAIN_III 3
|
||||
|
||||
//Add 20090225
|
||||
const int PROC_TYPE_RPT =1;
|
||||
const int PROC_TYPE_UNRPT =0;
|
||||
//add end
|
||||
|
||||
|
||||
//status for proc and app
|
||||
const int NON_ACTIVE = 0;
|
||||
const int ACTIVE = 1;
|
||||
const int HANGUP = 2;
|
||||
const int FAILURE = 5;
|
||||
const int START = 6;
|
||||
const int STOP = 7;
|
||||
|
||||
#endif
|
||||
|
||||
264
branches/sys_nicmonitor-1.4-龙芯-32/dotconf.h
Normal file
264
branches/sys_nicmonitor-1.4-龙芯-32/dotconf.h
Normal file
@@ -0,0 +1,264 @@
|
||||
#ifndef DOTCONF_H
|
||||
#define DOTCONF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* stdio.h should be included by the application - as the manual page says */
|
||||
#ifndef _STDIO_H
|
||||
#include <stdio.h> /* needed for FILE* */
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
# ifndef R_OK
|
||||
#define R_OK 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* some buffersize definitions */
|
||||
#define CFG_BUFSIZE 4096 /* max length of one line */
|
||||
#define CFG_MAX_OPTION 32 /* max length of any option name */
|
||||
#define CFG_MAX_VALUE 4064 /* max length of any options value */
|
||||
#define CFG_MAX_FILENAME 256 /* max length of a filename */
|
||||
#define CFG_VALUES 16 /* max # of arguments an option takes */
|
||||
|
||||
#define CFG_INCLUDEPATH_ENV "DC_INCLUDEPATH"
|
||||
#define WILDCARDS "*?" /* list of supported wild-card characters */
|
||||
|
||||
/* constants for type of option */
|
||||
#define ARG_TOGGLE 0 /* TOGGLE on,off; yes,no; 1, 0; */
|
||||
#define ARG_INT 1 /* callback wants an integer */
|
||||
#define ARG_STR 2 /* callback expects a \0 terminated str */
|
||||
#define ARG_LIST 3 /* wants list of strings */
|
||||
#define ARG_NAME 4 /* wants option name plus ARG_LIST stuff */
|
||||
#define ARG_RAW 5 /* wants raw argument data */
|
||||
#define ARG_NONE 6 /* does not expect ANY args */
|
||||
|
||||
#define CTX_ALL 0 /* context: option can be used anywhere */
|
||||
|
||||
/* for convenience of terminating the dotconf_options list */
|
||||
#define LAST_OPTION { "", 0, NULL, NULL }
|
||||
#define LAST_CONTEXT_OPTION { "", 0, NULL, NULL, 0 }
|
||||
|
||||
#define DOTCONF_CB(__name) const char *__name(command_t *cmd, \
|
||||
context_t *ctx)
|
||||
#define FUNC_ERRORHANDLER(_name) int _name(configfile_t * configfile, \
|
||||
int type, long dc_errno, const char *msg)
|
||||
|
||||
|
||||
/* some flags that change the runtime behaviour of dotconf */
|
||||
#define NONE 0
|
||||
#define CASE_INSENSITIVE 1<<0 /* match option names case insensitive */
|
||||
#define DONT_SUBSTITUTE 1<<1 /* do not call substitute_env after read_arg */
|
||||
#define NO_INLINE_COMMENTS 1<<2 /* do not allow inline comments */
|
||||
#define DUPLICATE_OPTION_NAMES 1<<3 /* allow for duplicate option names */
|
||||
|
||||
/* syslog style errors as suggested by Sander Steffann <sander@steffann.nl> */
|
||||
#ifdef HAVE_SYSLOG
|
||||
#include <syslog.h>
|
||||
|
||||
#define DCLOG_EMERG LOG_EMERG /* system is unusable */
|
||||
#define DCLOG_ALERT LOG_ALERT /* action must be taken immediately */
|
||||
#define DCLOG_CRIT LOG_CRIT /* critical conditions */
|
||||
#define DCLOG_ERR LOG_ERR /* error conditions */
|
||||
#define DCLOG_WARNING LOG_WARNING /* warning conditions */
|
||||
#define DCLOG_NOTICE LOG_NOTICE /* normal but significant condition */
|
||||
#define DCLOG_INFO LOG_INFO /* informational */
|
||||
#define DCLOG_DEBUG LOG_DEBUG /* debug-level messages */
|
||||
|
||||
#define DCLOG_LEVELMASK LOG_PRIMASK /* mask off the level value */
|
||||
|
||||
#else /* HAVE_SYSLOG */
|
||||
|
||||
#define DCLOG_EMERG 0 /* system is unusable */
|
||||
#define DCLOG_ALERT 1 /* action must be taken immediately */
|
||||
#define DCLOG_CRIT 2 /* critical conditions */
|
||||
#define DCLOG_ERR 3 /* error conditions */
|
||||
#define DCLOG_WARNING 4 /* warning conditions */
|
||||
#define DCLOG_NOTICE 5 /* normal but significant condition */
|
||||
#define DCLOG_INFO 6 /* informational */
|
||||
#define DCLOG_DEBUG 7 /* debug-level messages */
|
||||
|
||||
#define DCLOG_LEVELMASK 7 /* mask off the level value */
|
||||
|
||||
#endif /* HAVE_SYSLOG */
|
||||
|
||||
/* callback types for dotconf_callback */
|
||||
|
||||
/* error constants */
|
||||
#define ERR_NOERROR 0x0000
|
||||
#define ERR_PARSE_ERROR 0x0001
|
||||
#define ERR_UNKNOWN_OPTION 0x0002
|
||||
#define ERR_WRONG_ARG_COUNT 0x0003
|
||||
#define ERR_INCLUDE_ERROR 0x0004
|
||||
#define ERR_NOACCESS 0x0005
|
||||
#define ERR_USER 0x1000 /* base for userdefined errno's */
|
||||
|
||||
/* i needed this to check an ARG_LIST entry if it's toggled in one of my apps; maybe you do too */
|
||||
#define CFG_TOGGLED(_val) ( (_val[0] == 'Y' \
|
||||
|| _val[0] == 'y') \
|
||||
|| (_val[0] == '1') \
|
||||
|| ((_val[0] == 'o' \
|
||||
|| _val[0] == 'O') \
|
||||
&& (_val[1] == 'n' \
|
||||
|| _val[1] == 'N')))
|
||||
|
||||
enum callback_types
|
||||
{
|
||||
ERROR_HANDLER = 1,
|
||||
CONTEXT_CHECKER
|
||||
};
|
||||
|
||||
typedef enum callback_types callback_types;
|
||||
typedef struct configfile_t configfile_t;
|
||||
typedef struct configoption_t configoption_t;
|
||||
typedef struct configoption_t ConfigOption;
|
||||
typedef struct command_t command_t;
|
||||
typedef void context_t;
|
||||
typedef void info_t;
|
||||
|
||||
typedef const char *(*dotconf_callback_t)(command_t *, context_t *);
|
||||
typedef int (*dotconf_errorhandler_t)(configfile_t *, int, unsigned long, const char *);
|
||||
typedef const char *(*dotconf_contextchecker_t)(command_t *, unsigned long);
|
||||
|
||||
struct configfile_t
|
||||
{
|
||||
/* ------ the fields in configfile_t are provided to the app via command_t's ; READ ONLY! --- */
|
||||
|
||||
FILE *stream;
|
||||
char eof; /* end of file reached ? */
|
||||
size_t size; /* file size; cached on-demand for here-documents */
|
||||
|
||||
context_t *context;
|
||||
|
||||
configoption_t const **config_options;
|
||||
int config_option_count;
|
||||
|
||||
/* ------ misc read-only fields ------------------------------------------------------------- */
|
||||
char *filename; /* name of file this option was found in */
|
||||
unsigned long line; /* line number we're currently at */
|
||||
unsigned long flags; /* runtime flags given to dotconf_open */
|
||||
|
||||
char *includepath;
|
||||
|
||||
/* ------ some callbacks for interactivity -------------------------------------------------- */
|
||||
dotconf_errorhandler_t errorhandler;
|
||||
dotconf_contextchecker_t contextchecker;
|
||||
|
||||
int (*cmp_func)(const char *, const char *, size_t);
|
||||
};
|
||||
|
||||
struct configoption_t
|
||||
{
|
||||
const char *name; /* name of configuration option */
|
||||
int type; /* for possible values, see above */
|
||||
dotconf_callback_t callback; /* callback function */
|
||||
info_t *info; /* additional info for multi-option callbacks */
|
||||
unsigned long context; /* context sensitivity flags */
|
||||
};
|
||||
|
||||
struct command_t
|
||||
{
|
||||
const char *name; /* name of the command */
|
||||
configoption_t *option; /* the option as given in the app; READ ONLY */
|
||||
|
||||
/* ------ argument data filled in for each line / command ----------------------------------- */
|
||||
struct {
|
||||
long value; /* ARG_INT, ARG_TOGGLE */
|
||||
char *str; /* ARG_STR */
|
||||
char **list; /* ARG_LIST */
|
||||
} data;
|
||||
int arg_count; /* number of arguments (in data.list) */
|
||||
|
||||
/* ------ misc context information ---------------------------------------------------------- */
|
||||
configfile_t *configfile;
|
||||
context_t *context;
|
||||
};
|
||||
|
||||
/* ------ dotconf_create() - create the configfile_t needed for further dot.conf fun ------------ */
|
||||
configfile_t *dotconf_create(char *, const configoption_t *, context_t *, unsigned long);
|
||||
|
||||
/* ------ dotconf_cleanup() - tidy up behind dotconf_create and the parser dust ----------------- */
|
||||
void dotconf_cleanup(configfile_t *configfile);
|
||||
|
||||
/* ------ dotconf_command_loop() - iterate through each line of file and handle the commands ---- */
|
||||
int dotconf_command_loop(configfile_t *configfile);
|
||||
|
||||
/* ------ dotconf_command_loop_until_error() - like continue_line but return on the first error - */
|
||||
const char *dotconf_command_loop_until_error(configfile_t *configfile);
|
||||
|
||||
/* ------ dotconf_continue_line() - check if line continuation is to be handled ----------------- */
|
||||
int dotconf_continue_line(char *buffer, size_t length);
|
||||
|
||||
/* ------ dotconf_get_next_line() - read in the next line of the configfile_t ------------------- */
|
||||
int dotconf_get_next_line(char *buffer, size_t bufsize, configfile_t *configfile);
|
||||
|
||||
/* ------ dotconf_get_here_document() - read the here document until delimit is found ----------- */
|
||||
char *dotconf_get_here_document(configfile_t *configfile, const char *delimit);
|
||||
|
||||
/* ------ dotconf_invoke_command() - call the callback for command_t ---------------------------- */
|
||||
const char *dotconf_invoke_command(configfile_t *configfile, command_t *cmd);
|
||||
|
||||
/* ------ dotconf_find_command() - iterate through all registered options trying to match ------- */
|
||||
configoption_t *dotconf_find_command(configfile_t *configfile, const char *command);
|
||||
|
||||
/* ------ dotconf_read_arg() - read one argument from the line handling quoting and escaping ---- */
|
||||
/*
|
||||
side effects: the char* returned by dotconf_read_arg is malloc() before, hence that pointer
|
||||
will have to be free()ed later.
|
||||
*/
|
||||
char *dotconf_read_arg(configfile_t *configfile, signed char **line);
|
||||
|
||||
/* ------ dotconf_handle_command() - parse, substitute, find, invoke the command found in buffer */
|
||||
const char *dotconf_handle_command(configfile_t *configfile, char *buffer);
|
||||
|
||||
/* ------ dotconf_register_option() - add a new option table to the list of commands ------------ */
|
||||
void dotconf_register_options(configfile_t *configfile, const configoption_t *options);
|
||||
|
||||
/* ------ dotconf_warning() - handle the dispatch of error messages of various levels ----------- */
|
||||
int dotconf_warning(configfile_t *configfile, int level, unsigned long errnum, const char *, ...);
|
||||
|
||||
/* ------ dotconf_callback() - register a special callback -------------------------------------- */
|
||||
void dotconf_callback(configfile_t *configfile, callback_types type, dotconf_callback_t);
|
||||
|
||||
/* ------ dotconf_substitute_env() - handle the substitution on environment variables ----------- */
|
||||
char *dotconf_substitute_env(configfile_t *, char *);
|
||||
|
||||
/* ------ internal utility function that verifies if a character is in the WILDCARDS list -- */
|
||||
int dotconf_is_wild_card(char value);
|
||||
|
||||
/* ------ internal utility function that calls the appropriate routine for the wildcard passed in -- */
|
||||
int dotconf_handle_wild_card(command_t* cmd, char wild_card, char* path, char* pre, char* ext);
|
||||
|
||||
/* ------ internal utility function that frees allocated memory from dotcont_find_wild_card -- */
|
||||
void dotconf_wild_card_cleanup(char* path, char* pre);
|
||||
|
||||
/* ------ internal utility function to check for wild cards in file path -- */
|
||||
/* ------ path and pre must be freed by the developer ( dotconf_wild_card_cleanup) -- */
|
||||
int dotconf_find_wild_card(char* filename, char* wildcard, char** path, char** pre, char** ext);
|
||||
|
||||
/* ------ internal utility function that compares two stings from back to front -- */
|
||||
int dotconf_strcmp_from_back(const char* s1, const char* s2);
|
||||
|
||||
/* ------ internal utility function that determins if a string matches the '?' criteria -- */
|
||||
int dotconf_question_mark_match(char* dir_name, char* pre, char* ext);
|
||||
|
||||
/* ------ internal utility function that determins if a string matches the '*' criteria -- */
|
||||
int dotconf_star_match(char* dir_name, char* pre, char* ext);
|
||||
|
||||
/* ------ internal utility function that determins matches for filenames with -- */
|
||||
/* ------ a '?' in name and calls the Internal Include function on that filename -- */
|
||||
int dotconf_handle_question_mark(command_t* cmd, char* path, char* pre, char* ext);
|
||||
|
||||
/* ------ internal utility function that determins matches for filenames with -- */
|
||||
/* ------ a '*' in name and calls the Internal Include function on that filename -- */
|
||||
int dotconf_handle_star(command_t* cmd, char* path, char* pre, char* ext);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* DOTCONF_H */
|
||||
1513
branches/sys_nicmonitor-1.4-龙芯-32/mnic.c
Normal file
1513
branches/sys_nicmonitor-1.4-龙芯-32/mnic.c
Normal file
File diff suppressed because it is too large
Load Diff
44
branches/sys_nicmonitor-1.4-龙芯-32/mnic.h
Normal file
44
branches/sys_nicmonitor-1.4-龙芯-32/mnic.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef __MNIC_H
|
||||
#define __MNIC_H
|
||||
|
||||
//#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <netinet/in.h>
|
||||
#include <net/if.h>
|
||||
#include <time.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sem.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/param.h>
|
||||
#include <linux/types.h>
|
||||
#include <glob.h>
|
||||
#include <linux/sockios.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "sys_netcard.h"
|
||||
#include <pwd.h>
|
||||
#include <sys/types.h>
|
||||
#define IPSIZE 16
|
||||
|
||||
char *get_name(char *, char *);
|
||||
int if_fetch(NETCARD_INFO *);
|
||||
int ioc_get_name(NETCARD_INFO *);
|
||||
int get_dev_fields(char *p, NETCARD_INFO *);
|
||||
int get_user_home(int , char *);
|
||||
void send_alarm(D5000_NIC_ALARM *, int , char *);
|
||||
void record_log(char *);
|
||||
|
||||
#endif
|
||||
209
branches/sys_nicmonitor-1.4-龙芯-32/nicinfo_shm.c
Normal file
209
branches/sys_nicmonitor-1.4-龙芯-32/nicinfo_shm.c
Normal file
@@ -0,0 +1,209 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/sem.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <dirent.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#include "nicinfo_shm.h"
|
||||
|
||||
#define SHM_PATH "/tmp/sys_netcard_shm_path"
|
||||
#define SEM_PATH "/tmp/sys_netcard_sem_path"
|
||||
#define LOG_PATH "/var/log/netcard/"
|
||||
|
||||
typedef struct net_info{
|
||||
NETCARD_INFO info[MAXNICNUM];
|
||||
}SHM;
|
||||
|
||||
static int semid = 0;
|
||||
static char log_path[1024];
|
||||
static char shm_path[1024];
|
||||
static char sem_path[1024];
|
||||
SHM *ptr = NULL;
|
||||
|
||||
/* write error in logfile */
|
||||
void record_log(char *str)
|
||||
{
|
||||
time_t tamp;
|
||||
char str_tm[4];
|
||||
char log_str[512];
|
||||
FILE *log_fp = NULL;
|
||||
struct tm tmptr;
|
||||
struct timeval tv;
|
||||
struct timezone tz;
|
||||
|
||||
if((log_fp = fopen(log_path, "a")) != NULL){
|
||||
tamp = time(NULL);
|
||||
memset(str_tm, 0, sizeof(str_tm));
|
||||
memset(log_str, 0, sizeof(log_str));
|
||||
localtime_r(&tamp, &tmptr);
|
||||
gettimeofday(&tv, &tz);
|
||||
snprintf(str_tm, sizeof(str_tm), "%d", (int)tv.tv_usec/1000);
|
||||
if(str_tm[1] == '\0')str_tm[1] = '0';
|
||||
if(str_tm[2] == '\0')str_tm[2] = '0';
|
||||
strftime(log_str, sizeof(log_str), "%F %T.", &tmptr);
|
||||
strcat(log_str, str_tm);
|
||||
strcat(log_str, " ");
|
||||
strcat(log_str, "get_nic_info");
|
||||
strcat(log_str, " ");
|
||||
strcat(log_str, str);
|
||||
if(fwrite(log_str, 1, strlen(log_str), log_fp) < 1){
|
||||
}
|
||||
fclose(log_fp);
|
||||
}
|
||||
}
|
||||
|
||||
void get_sem(int semid)
|
||||
{
|
||||
char err_str[200];
|
||||
struct sembuf lock[2];
|
||||
|
||||
lock[0].sem_num = 0;
|
||||
lock[0].sem_op = 0;
|
||||
lock[0].sem_flg = SEM_UNDO;
|
||||
|
||||
lock[1].sem_num = 0;
|
||||
lock[1].sem_op = 1;
|
||||
lock[1].sem_flg = SEM_UNDO;
|
||||
|
||||
while(semop(semid, lock, 2)){
|
||||
if (errno == EINTR) {
|
||||
continue;
|
||||
}
|
||||
snprintf(err_str, sizeof(err_str), "EMERG: semop():\n", strerror(errno));
|
||||
record_log(err_str);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void release_sem(int semid)
|
||||
{
|
||||
int ret;
|
||||
char err_str[200];
|
||||
struct sembuf unlock;
|
||||
|
||||
unlock.sem_num = 0;
|
||||
unlock.sem_op = -1;
|
||||
unlock.sem_flg = SEM_UNDO;
|
||||
|
||||
if((ret = semop(semid, &unlock, 1)) == -1){
|
||||
snprintf(err_str, sizeof(err_str), "EMERG: semop():\n", strerror(errno));
|
||||
record_log(err_str);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int init_nic_info(void)
|
||||
{
|
||||
int fd = -1;
|
||||
int sem_val;
|
||||
char err_str[200];
|
||||
key_t key;
|
||||
|
||||
|
||||
if ((key=ftok(sem_path, SEM_PROJ_ID)) == -1) {
|
||||
snprintf(err_str, sizeof(err_str), "EMERG: ftok():%s\n", strerror(errno));
|
||||
record_log(err_str);
|
||||
return -1;
|
||||
}
|
||||
if((semid = semget(key, 1, IPC_CREAT|0666)) == -1){
|
||||
snprintf(err_str, sizeof(err_str), "EMERG: Create semaphore error: %s\n", strerror(errno));
|
||||
record_log(err_str);
|
||||
return -1;
|
||||
}
|
||||
/*
|
||||
if((sem_val = semctl(semid, 0, GETVAL, 0)) == -1){
|
||||
snprintf(err_str, sizeof(err_str), "EMERG: semctl: %s !\n", strerror(errno));
|
||||
record_log(err_str);
|
||||
semctl(semid, 0, IPC_RMID);
|
||||
return -1;
|
||||
}
|
||||
if(!sem_val){
|
||||
if(semctl(semid, 0, SETVAL, 1) == -1){
|
||||
snprintf(err_str, sizeof(err_str), "EMERG: semctl: %s !\n", strerror(errno));
|
||||
record_log(err_str);
|
||||
semctl(semid, 0, IPC_RMID);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
*/
|
||||
if((fd = open(shm_path, O_RDONLY)) == -1){
|
||||
snprintf(err_str, sizeof(err_str), "EMERG: Error open %s: %s!\n",shm_path, strerror(errno));
|
||||
record_log(err_str);
|
||||
return -1;
|
||||
}
|
||||
ptr = (SHM*)mmap(NULL, sizeof(SHM), PROT_READ, MAP_SHARED, fd, 0);
|
||||
if(ptr == MAP_FAILED){
|
||||
snprintf(err_str, sizeof(err_str), "EMERG: mmap():%s\n", strerror(errno));
|
||||
record_log(err_str);
|
||||
return -1;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
int get_nic_info(char *nic_name, NETCARD_INFO *net_info)
|
||||
{
|
||||
int i,ret;
|
||||
time_t tamp;
|
||||
struct tm tmptr;
|
||||
DIR *dir;
|
||||
char *s;
|
||||
char buf[128];
|
||||
char err_str[200];
|
||||
struct passwd *user;
|
||||
|
||||
tamp = time(NULL);
|
||||
localtime_r(&tamp, &tmptr);
|
||||
|
||||
if((user = getpwnam("d5000"))!= NULL){
|
||||
sprintf(log_path,"%s",user->pw_dir);
|
||||
sprintf(shm_path,"%s",user->pw_dir);
|
||||
sprintf(sem_path,"%s",user->pw_dir);
|
||||
}
|
||||
strcat(log_path,LOG_PATH);
|
||||
strcat(shm_path,SHM_PATH);
|
||||
strcat(sem_path,SEM_PATH);
|
||||
|
||||
if((dir = opendir(log_path)) == NULL){
|
||||
if(errno == ENOENT){
|
||||
strcpy(log_path, "/tmp/");
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
s = strrchr(log_path, '/');
|
||||
s++;
|
||||
*s = '\0';
|
||||
memset(buf, 0, sizeof(buf));
|
||||
strftime(buf, sizeof(buf), "%Y%m%d_", &tmptr);
|
||||
strcat(buf, "sys_nicmonitor");
|
||||
strcat(buf, ".log");
|
||||
strcat(log_path, buf);
|
||||
if((ret = init_nic_info()) == -1){
|
||||
return -1;
|
||||
}
|
||||
get_sem(semid);
|
||||
for(i = 0; ptr->info[i].charname[0] != 0; i++){
|
||||
if(!strcmp(ptr->info[i].charname, nic_name)){
|
||||
// get_sem(semid);
|
||||
memcpy(net_info, &ptr->info[i], sizeof(NETCARD_INFO));
|
||||
release_sem(semid);
|
||||
munmap(ptr, sizeof(SHM));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
release_sem(semid);
|
||||
snprintf(err_str, sizeof(err_str), "NOTICE: No information of %s !\n", nic_name);
|
||||
record_log(err_str);
|
||||
munmap(ptr, sizeof(SHM));
|
||||
return -1;
|
||||
}
|
||||
52
branches/sys_nicmonitor-1.4-龙芯-32/nicinfo_shm.h
Normal file
52
branches/sys_nicmonitor-1.4-龙芯-32/nicinfo_shm.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#ifndef NIC_SHM_H
|
||||
#define NIC_SHM_H
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef NIC_NAME_LEN
|
||||
#define NIC_NAME_LEN 64
|
||||
#endif
|
||||
#define SEM_PROJ_ID 's'
|
||||
#define MAXNICNUM 32
|
||||
|
||||
typedef long KEYID;
|
||||
typedef struct _net_info
|
||||
{
|
||||
KEYID ID;
|
||||
char charname[NIC_NAME_LEN];
|
||||
char descr[128];
|
||||
struct sockaddr addr;
|
||||
struct sockaddr broadaddr;
|
||||
struct sockaddr netmask;
|
||||
struct sockaddr hwaddr;
|
||||
int time_stamp;
|
||||
short flags;
|
||||
int mtu;
|
||||
int tx_queue_len;
|
||||
unsigned long long average_flow;
|
||||
unsigned long long rx_packets;
|
||||
unsigned long long tx_packets;
|
||||
unsigned long long rx_bytes;
|
||||
unsigned long long tx_bytes;
|
||||
unsigned long rx_errors;
|
||||
unsigned long tx_errors;
|
||||
unsigned long rx_dropped;
|
||||
unsigned long tx_dropped;
|
||||
unsigned long rx_multicast;
|
||||
unsigned long collisions;
|
||||
unsigned long rx_fifo_errors;
|
||||
unsigned long tx_carrier_errors;
|
||||
unsigned long tx_fifo_errors;
|
||||
}NETCARD_INFO;
|
||||
|
||||
int get_nic_info(char *nic_name, NETCARD_INFO *net_info);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
198
branches/sys_nicmonitor-1.4-龙芯-32/proc_inv.h
Normal file
198
branches/sys_nicmonitor-1.4-龙芯-32/proc_inv.h
Normal file
@@ -0,0 +1,198 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) Comets' Grp. of Kedong Corp 2008. All Rights Reserved.
|
||||
//
|
||||
// FileName : procconf.h
|
||||
//
|
||||
// Function : this class realize some basic functions for process managerment,
|
||||
// such as initiate process, report status of process, check status of process,
|
||||
// update status of process, get information of process
|
||||
//
|
||||
// Author :
|
||||
//
|
||||
// Date :
|
||||
//
|
||||
// Modify by :
|
||||
//
|
||||
// Mod Date :
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _PROCCONF_H
|
||||
#define _PROCCONF_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
//#include <iostream.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "const.h"
|
||||
|
||||
//for alarm ................................
|
||||
typedef struct MESS_BH
|
||||
{
|
||||
unsigned char mtype;
|
||||
int length;
|
||||
};
|
||||
typedef struct PROCESS_ALM
|
||||
{
|
||||
char context_name[MAX_STRING_LEN];
|
||||
char app_name[MAX_STRING_LEN];
|
||||
char proc_name[MAX_STRING_LEN];
|
||||
unsigned char status;
|
||||
};
|
||||
//for alarm end .............................
|
||||
|
||||
//for mmi....................................
|
||||
const int MAX_BUFFER_LEN = 500;
|
||||
typedef struct MESS_BLOCK
|
||||
{
|
||||
unsigned char num;
|
||||
char buffer[MAX_BUFFER_LEN];
|
||||
};
|
||||
typedef struct MESS_PROC
|
||||
{
|
||||
char context_name[MAX_STRING_LEN];
|
||||
char app_name[MAX_STRING_LEN];
|
||||
char proc_name[MAX_STRING_LEN];
|
||||
char status;
|
||||
};
|
||||
//for mmi end ................................
|
||||
|
||||
const int DEFAULT_PERIOD = 3;
|
||||
const int COUNT_LIMIT = 2;
|
||||
const int START_DEFAULT_PERIOD = 60;
|
||||
const int START_COUNT_LIMIT = 5;
|
||||
const int APP_COUNT_LIMIT = 1;
|
||||
|
||||
//process critical level
|
||||
//const int WST_CRITICAL = 1; // Shutdown and reboot workstation when failed
|
||||
//const int SYS_CRITICAL = 2; // Shutdown and reboot the system on the wst when failed
|
||||
//const int USER_CRITICAL = 3; // Shutdown and reboot the subsystem when failed
|
||||
//const int GENERAL = 4; // reboot the process
|
||||
const int CRUCIAL = 1; // crucial process
|
||||
const int GENERAL = 0; // general process
|
||||
|
||||
|
||||
extern int srv_init(char *service,int port);
|
||||
extern int Tcp_close(int sockfd);
|
||||
extern int Tcp_read(int fd,char *ptr,int nbytes);
|
||||
extern int Tcp_write(int fd,char *ptr,int nbytes);
|
||||
extern int srv_accept(int fd,struct sockaddr *cli_addr,int *clilen);
|
||||
extern int client_tcp_open(char *host,char *service,int port);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char context_name[MAX_STRING_LEN];
|
||||
char app_name[MAX_STRING_LEN];
|
||||
char proc_name[MAX_STRING_LEN];
|
||||
pid_t proc_pid;
|
||||
}PROC_ADM_INFO;
|
||||
|
||||
//***************************************************************
|
||||
// structure name : PROC_INFO
|
||||
// function : store process informatin
|
||||
// author :
|
||||
// date :
|
||||
// modify by :
|
||||
// modification :
|
||||
// mod date :
|
||||
//***************************************************************
|
||||
typedef struct
|
||||
{
|
||||
int position;
|
||||
char node_name[MAX_STRING_LEN];
|
||||
char context_name[MAX_STRING_LEN];
|
||||
char app_name[MAX_STRING_LEN];
|
||||
char proc_name[MAX_STRING_LEN];
|
||||
|
||||
unsigned char active_flag;
|
||||
unsigned char master_flag;
|
||||
|
||||
time_t startup_time;
|
||||
time_t refresh_time;
|
||||
short refresh_peri;
|
||||
unsigned char monitor_type;
|
||||
|
||||
pid_t proc_pid;
|
||||
unsigned char auto_start;
|
||||
unsigned char act_timer;
|
||||
unsigned char start_timer;
|
||||
unsigned char critical_level;
|
||||
|
||||
char exefile_path[MAX_EXECMD_LEN];
|
||||
|
||||
}PROC_INFO;
|
||||
|
||||
//***************************************************************
|
||||
// structure name : APP_INFO
|
||||
// function : store application informatin
|
||||
// author :
|
||||
// date :
|
||||
// modify by :
|
||||
// modification :
|
||||
// mod date :
|
||||
//***************************************************************
|
||||
typedef struct
|
||||
{
|
||||
int position;
|
||||
char context_name[MAX_STRING_LEN];
|
||||
int context_id;
|
||||
char app_name[MAX_STRING_LEN];
|
||||
int app_id;
|
||||
unsigned char act_timer;
|
||||
unsigned char active_flag;
|
||||
}APP_INFO;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int no_proc;
|
||||
int semdes_cfg;
|
||||
PROC_INFO proc[MAX_LOCAL_PROCESS];
|
||||
APP_INFO app[MAX_LOCAL_APP];
|
||||
}PROCCFG;
|
||||
|
||||
class proc_invocation
|
||||
{
|
||||
public:
|
||||
int m_init;
|
||||
PROCCFG *proccfg_p;
|
||||
|
||||
public:
|
||||
proc_invocation();
|
||||
~proc_invocation();
|
||||
|
||||
int conf_create();
|
||||
//int check_proc_status();
|
||||
//int update_rtdb();
|
||||
//int kill_proc(pid_t pid);
|
||||
//int start_proc(char *cmdline);
|
||||
//int send_alarm(char *context_name, char *app_name, char *proc_name, unsigned char status);
|
||||
//int update_proc_status(char *context_name, char *app_name, char *proc_name, char status);
|
||||
|
||||
//int proc_init(char *context_name, char *app_name, char *proc_name, int critical_level);//exefile_path,auto_start
|
||||
int proc_init(char *context_name, char *app_name, char *proc_name);
|
||||
int proc_report(int pos, char status, int intertime=3);
|
||||
int proc_exit(int proc_pos);
|
||||
|
||||
int get_pos(char *context_name, char *app_name, char *proc_name);
|
||||
int is_proc_exist(char *context_name, char *app_name, char *proc_name);
|
||||
int conf_map();
|
||||
|
||||
int get_procinfo(int position, PROC_ADM_INFO *p_info);
|
||||
int get_active_pid(int &num, int *p_pidlist);
|
||||
int is_proc_run(pid_t pid);
|
||||
int is_proc_run(char *context_name, char *app_name, char *proc_name);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
133
branches/sys_nicmonitor-1.4-龙芯-32/read_netcard.c
Normal file
133
branches/sys_nicmonitor-1.4-龙芯-32/read_netcard.c
Normal file
@@ -0,0 +1,133 @@
|
||||
#include "mnic.h"
|
||||
|
||||
static char *prase_digit(char **s)
|
||||
{
|
||||
char *retp = NULL;
|
||||
char *p = *s;
|
||||
|
||||
if(!p)return NULL;
|
||||
while(!isdigit(*p)){
|
||||
p++;
|
||||
if(*p == '\0')return NULL;
|
||||
}
|
||||
retp = p;
|
||||
while(isdigit(*p)){
|
||||
p++;
|
||||
if(*p == '\0'){
|
||||
*s = NULL;
|
||||
return retp;
|
||||
}
|
||||
}
|
||||
*p = '\0';
|
||||
p++;
|
||||
*s = p;
|
||||
return retp;
|
||||
}
|
||||
|
||||
|
||||
char *get_name(char *name, char *p)
|
||||
{
|
||||
while (isspace(*p))
|
||||
p++;
|
||||
while (*p) {
|
||||
if (isspace(*p))
|
||||
break;
|
||||
if (*p == ':') { /* could be an alias */
|
||||
char *dot = p, *dotname = name;
|
||||
*name++ = *p++;
|
||||
while (isdigit(*p))
|
||||
*name++ = *p++;
|
||||
if (*p != ':') { /* it wasn't, backup */
|
||||
p = dot;
|
||||
name = dotname;
|
||||
}
|
||||
if (*p == '\0')
|
||||
return NULL;
|
||||
p++;
|
||||
break;
|
||||
}
|
||||
*name++ = *p++;
|
||||
}
|
||||
*name++ = '\0';
|
||||
return p;
|
||||
}
|
||||
|
||||
int get_dev_fields(char *str, NETCARD_INFO *ife)
|
||||
{
|
||||
int i = 0;
|
||||
char *retp[16];
|
||||
|
||||
while((retp[i] = prase_digit(&str)) != NULL){i++;if(i > 15)break;}
|
||||
ife->rx_bytes = atoll(retp[0]);
|
||||
ife->rx_packets = atoll(retp[1]);
|
||||
ife->rx_errors = atol(retp[2]);
|
||||
ife->rx_dropped = atol(retp[3]);
|
||||
ife->rx_fifo_errors = atol(retp[4]);
|
||||
ife->rx_multicast = atol(retp[7]);
|
||||
ife->tx_bytes = atoll(retp[8]);
|
||||
ife->tx_packets = atoll(retp[9]);
|
||||
ife->tx_errors = atol(retp[10]);
|
||||
ife->tx_dropped = atol(retp[11]);
|
||||
ife->tx_fifo_errors = atol(retp[12]);
|
||||
ife->collisions = atol(retp[13]);
|
||||
ife->tx_carrier_errors = atol(retp[14]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int if_fetch(NETCARD_INFO *ife)
|
||||
{
|
||||
int skfd;
|
||||
struct ifreq ifr;
|
||||
|
||||
if((skfd = socket(PF_INET, SOCK_DGRAM, 0)) == -1)return -1;
|
||||
|
||||
strcpy(ifr.ifr_name, ife->charname);
|
||||
if (!ioctl(skfd, SIOCGIFFLAGS, &ifr))
|
||||
ife->flags = ifr.ifr_flags;
|
||||
|
||||
if (!ioctl(skfd, SIOCGIFHWADDR, &ifr))
|
||||
ife->hwaddr = ifr.ifr_hwaddr;
|
||||
|
||||
if (!ioctl(skfd, SIOCGIFMTU, &ifr))
|
||||
ife->mtu = ifr.ifr_mtu;
|
||||
|
||||
if (!ioctl(skfd, SIOCGIFTXQLEN, &ifr))
|
||||
ife->tx_queue_len = ifr.ifr_qlen;
|
||||
|
||||
if (!ioctl(skfd, SIOCGIFADDR, &ifr))
|
||||
ife->addr = ifr.ifr_addr;
|
||||
|
||||
if (!ioctl(skfd, SIOCGIFBRDADDR, &ifr))
|
||||
ife->broadaddr = ifr.ifr_broadaddr;
|
||||
|
||||
if (!ioctl(skfd, SIOCGIFNETMASK, &ifr))
|
||||
ife->netmask = ifr.ifr_netmask;
|
||||
|
||||
ife->time_stamp = time(NULL);
|
||||
close(skfd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int ioc_get_name(NETCARD_INFO *name)
|
||||
{
|
||||
int skfd;
|
||||
int ifrnum;
|
||||
int i = 0;
|
||||
struct ifconf ifc;
|
||||
struct ifreq buf[MAXNICNUM];
|
||||
|
||||
if((skfd = socket(PF_INET, SOCK_DGRAM, 0)) == -1)return -1;
|
||||
memset(buf, 0, sizeof(buf));
|
||||
ifc.ifc_len = sizeof(buf);
|
||||
ifc.ifc_buf = (caddr_t) buf;
|
||||
ioctl(skfd, SIOCGIFCONF, &ifc);
|
||||
ifrnum = ifc.ifc_len / sizeof(struct ifreq);
|
||||
while(ifrnum-- > 0){
|
||||
strcpy(name[i].charname, buf[ifrnum].ifr_name);
|
||||
i++;
|
||||
}
|
||||
close(skfd);
|
||||
return i;
|
||||
}
|
||||
|
||||
37
branches/sys_nicmonitor-1.4-龙芯-32/send_alarm.c
Normal file
37
branches/sys_nicmonitor-1.4-龙芯-32/send_alarm.c
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "mnic.h"
|
||||
|
||||
void send_alarm(D5000_NIC_ALARM *mesg, int socket_port, char *ipv4)
|
||||
{
|
||||
int bytes;
|
||||
int sock_sd;
|
||||
int val;
|
||||
char error_str[200];
|
||||
struct sockaddr_in recever;
|
||||
socklen_t sock_len;
|
||||
|
||||
if((sock_sd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1){
|
||||
snprintf(error_str, sizeof(error_str), "EMERG: socket(): %s\n", strerror(errno));
|
||||
record_log(error_str);
|
||||
return;
|
||||
}
|
||||
val=1;
|
||||
if ((setsockopt(sock_sd, SOL_SOCKET, SO_BROADCAST, &val, sizeof(val))) == -1) {
|
||||
snprintf(error_str, sizeof(error_str), "EMERG: setsockopt(): %s\n", strerror(errno));
|
||||
record_log(error_str);
|
||||
return;
|
||||
}
|
||||
/* init socket*/
|
||||
recever.sin_family = AF_INET;
|
||||
recever.sin_port = htons(socket_port);
|
||||
inet_pton(AF_INET, ipv4, &recever.sin_addr);
|
||||
sock_len = sizeof(recever);
|
||||
/* send alarm*/
|
||||
if((bytes = sendto(sock_sd, mesg, sizeof(D5000_NIC_ALARM), 0, (const struct sockaddr *)&recever, sock_len)) < 1){
|
||||
snprintf(error_str, sizeof(error_str), "EMERG: sendto(): %s\n", strerror(errno));
|
||||
record_log(error_str);
|
||||
return;
|
||||
}
|
||||
//snprintf(error_str, sizeof(error_str), "NOTICE: Alarm information has already send!\n");
|
||||
//record_log(error_str);
|
||||
close(sock_sd);
|
||||
}
|
||||
88
branches/sys_nicmonitor-1.4-龙芯-32/sys_netcard.h
Normal file
88
branches/sys_nicmonitor-1.4-龙芯-32/sys_netcard.h
Normal file
@@ -0,0 +1,88 @@
|
||||
#ifndef _SYS_NETCARD_H
|
||||
#define _SYS_NETCARD_H
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
#ifndef NIC_NAME_LEN
|
||||
#define NIC_NAME_LEN 64
|
||||
#endif
|
||||
|
||||
#define SEM_PROJ_ID 's'
|
||||
#define MAXNICNUM 32
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
typedef long KEYID;
|
||||
|
||||
typedef struct _msg_frame // message frame
|
||||
{
|
||||
short len; // message length
|
||||
short seqno; // send sequence
|
||||
short serv; // services ID
|
||||
short event; // event ID
|
||||
unsigned char domain; // domain ID
|
||||
unsigned char ctxt; // Context ID
|
||||
short stid; // SOURCE task id
|
||||
short dtid; // DESTINATION task ID
|
||||
unsigned char ver_coding; // 版本号 + 编码
|
||||
unsigned char mes_type; // 帧类型
|
||||
}MSG_FRAME, *LPMSG_FRAME;
|
||||
|
||||
typedef struct _net_info
|
||||
{
|
||||
KEYID ID;
|
||||
char charname[NIC_NAME_LEN];
|
||||
char descr[128];
|
||||
struct sockaddr addr;
|
||||
struct sockaddr broadaddr;
|
||||
struct sockaddr netmask;
|
||||
struct sockaddr hwaddr;
|
||||
int time_stamp;
|
||||
short flags;
|
||||
int mtu;
|
||||
int tx_queue_len;
|
||||
unsigned long long average_flow;
|
||||
unsigned long long rx_packets;
|
||||
unsigned long long tx_packets;
|
||||
unsigned long long rx_bytes;
|
||||
unsigned long long tx_bytes;
|
||||
unsigned long rx_errors;
|
||||
unsigned long tx_errors;
|
||||
unsigned long rx_dropped;
|
||||
unsigned long tx_dropped;
|
||||
unsigned long rx_multicast;
|
||||
unsigned long collisions;
|
||||
unsigned long rx_fifo_errors;
|
||||
unsigned long tx_carrier_errors;
|
||||
unsigned long tx_fifo_errors;
|
||||
}NETCARD_INFO, *LPNETCARD_INFO;
|
||||
|
||||
#define NETCARD_ALARM_FAULT 1
|
||||
#define NETCARD_ALARM_RESUME 2
|
||||
#define NETCARD_ALARM_SWITCH 3
|
||||
#define NETCARD_ALARM_ABNORMAL 4
|
||||
#define NETCARD_ALARM_NORMAL 5
|
||||
typedef struct _sys_netcard_alarm
|
||||
{
|
||||
char fault_devname[NIC_NAME_LEN]; /*故障设备名称 */
|
||||
char switch_devname[NIC_NAME_LEN]; /*切换设备名称 */
|
||||
short flags; /* 状态标记 : 1:网卡故障。2:网卡恢复。3:网卡切换。4:流量异常。*/
|
||||
short retrytimes; //0,1,2 重发次数
|
||||
}SYS_NETCARD_ALARM, *LPSYS_NETCARD_ALARM;
|
||||
|
||||
|
||||
typedef struct _d5000_nic_alarm
|
||||
{
|
||||
MSG_FRAME tMsgFrame ;
|
||||
SYS_NETCARD_ALARM tSysNetcardAlarm ;
|
||||
}D5000_NIC_ALARM, *LPD5000_NIC_ALARM;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
BIN
branches/sys_nicmonitor-1.4-龙芯-32/sys_nicmonitor
Normal file
BIN
branches/sys_nicmonitor-1.4-龙芯-32/sys_nicmonitor
Normal file
Binary file not shown.
Reference in New Issue
Block a user