secgateway/Common/ret_errno.h

109 lines
3.3 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef _RET_ERRNO_H
#define _RET_ERRNO_H
#include "config_manager.h"
/* error no, 32位前16位为模块ID后16位为模块错误码 */
typedef uint ret_code;
/*0x00000000 ~ 0x0000ffff 为系统预留错误码,用于一般性系统错误,
例如内存不够,输入错误等*/
/*ret code 0x00000000 ~ 0x0000ffff*/
#define RET_OK 0
#define RET_ERR 1
#define RET_UNKNOWN 2
#define RET_SYSERR 3
#define RET_NOTFOUND 4
#define RET_TIMEOUT 5
#define RET_NULLP 6
#define RET_NOMEM 7
#define RET_CHKERR 8
#define RET_NOTSUPPORT 9
#define RET_INPUTERR 10
#define RET_EXIST 11
#define RET_FULL 12
#define RET_SENDERR 13
#define RET_NOCMID 14
#define RET_SRCERR 15
/* NETCONFIG_MODULE 0x00010000 ~ 0x0001ffff*/
#define RET_IPINVALID (uint)((uint)NETCONFIG_MODULE<<16|1)
#define RET_BRNAMEERR (uint)((uint)NETCONFIG_MODULE<<16|1)
/* VLANCONFIG_MODULE 0x00050000 ~ 0x0005ffff*/
#define RET_VIDNUM_INVALID (uint)((uint)VLAN_CONFIG_MODULE<<16|1)
#define RET_VID_INVALID (uint)((uint)VLAN_CONFIG_MODULE<<16|1)
#define RET_VID_EXIST (uint)((uint)VLAN_CONFIG_MODULE<<16|1)
#define RET_VID_NOT_EXIST (uint)((uint)VLAN_CONFIG_MODULE<<16|1)
#define RET_INTERFACE_NOT_EXIST (uint)((uint)VLAN_CONFIG_MODULE<<16|1)
#define RET_ATTR_INVALID (uint)((uint)VLAN_CONFIG_MODULE<<16|1)
#define RET_OPTYPE_ERR (uint)((uint)VLAN_CONFIG_MODULE<<16|1)
#define RET_SYS_VCONFIG_ERR (uint)((uint)VLAN_CONFIG_MODULE<<16|1)
#define RET_SYS_IFCONFIG_ERR (uint)((uint)VLAN_CONFIG_MODULE<<16|1)
#define RET_SYS_FILEOP_ERR (uint)((uint)VLAN_CONFIG_MODULE<<16|1)
#define ERR_STR_LEN 64
/* 错误码描述 */
#define RET_ERROR_DISC \
{ \
{ RET_OK, "OK" }, \
{ RET_ERR, "Error" },\
{ RET_UNKNOWN, "Unkown" },\
{ RET_SYSERR, "SystemError" },\
{ RET_NOTFOUND, "NotFound" }, \
{ RET_TIMEOUT, "Timeout" }, \
{ RET_NULLP, "NullPointer" } ,\
{ RET_NOMEM, "NotEnoughMemory"},\
{ RET_CHKERR, "CheckError"},\
{ RET_NOTSUPPORT, "NotSupport"},\
{ RET_INPUTERR, "InputError"},\
{ RET_EXIST, "AlreadyExist"},\
{ RET_FULL, "Full"},\
{ RET_SENDERR, "SendErr"},\
{ RET_NOCMID, "CanNotFindConfig"},\
{ RET_SRCERR, "ConfigSourceErr"},\
\
{ RET_IPINVALID, "IpInvalid"},\
{ RET_BRNAMEERR, "BrNameInvalid"},\
\
{ RET_VIDNUM_INVALID, "VidNumInvalid"},\
{ RET_VID_INVALID, "VidValueInvalid"},\
{ RET_VID_EXIST, "VidHasExist"},\
{ RET_VID_NOT_EXIST, "VidHasNotExist"},\
{ RET_INTERFACE_NOT_EXIST, "InterfaceHasNotExist"},\
{ RET_ATTR_INVALID, "AttrInvalid"},\
{ RET_OPTYPE_ERR, "OperationTypeError"},\
{ RET_SYS_VCONFIG_ERR, "SystemVconfigError"},\
{ RET_SYS_IFCONFIG_ERR, "SystemIfconfigError"},\
{ RET_SYS_FILEOP_ERR, "SystemFileOperationError"}\
}
struct err_disc {
int code;
const char *name;
} ;
static inline char* ret_code_format(ret_code code, char* str) {
struct err_disc ret_err[] = RET_ERROR_DISC;
int len = sizeof(ret_err) / sizeof(struct err_disc);
int i;
for(i = 0; i < len; i++){
if(code == ret_err[i].code){
strcpy(str, ret_err[i].name);
return str;
}
}
return str;
}
#endif