diff --git a/Common/config_manager.h b/Common/config_manager.h index fcd26b98d..64d418177 100755 --- a/Common/config_manager.h +++ b/Common/config_manager.h @@ -53,11 +53,4 @@ /************************ config id定义 end**********************/ - -/* error no, 32位,前16位为模块ID,后16位为模块错误码 */ - -/*0x00000000 ~ 0x0000ffff 为系统预留错误码,用于一般性系统错误,例如内存不够,输入错误等*/ - -/* NETCONFIG_MODULE */ -#define NETCONFIG_IPVALID (uint)((uint)NETCONFIG_MODULE<<16|1) #endif diff --git a/Common/ret_errno.h b/Common/ret_errno.h new file mode 100644 index 000000000..f7eaf757a --- /dev/null +++ b/Common/ret_errno.h @@ -0,0 +1,56 @@ +#ifndef _RET_ERRNO_H +#define _RET_ERRNO_H + +#include "config_manager.h" + +/* error no, 32位,前16位为模块ID,后16位为模块错误码 */ +typedef uint ret_code; + + +/*0x00000000 ~ 0x0000ffff 为系统预留错误码,用于一般性系统错误,例如内存不够,输入错误等*/ + +/* RPC 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 + +/* NETCONFIG_MODULE 0x00010000 ~ 0x0001ffff*/ +#define RET_IPINVALID (uint)((uint)NETCONFIG_MODULE<<16|1) +#define RET_BRNAMEERR (uint)((uint)NETCONFIG_MODULE<<16|1) + + +/* 错误码描述 */ +#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, "NotEnoughMemery"},\ + { RET_CHKERR, "CheckError"},\ + { RET_NOTSUPPORT, "NotSupport"},\ + { RET_INPUTERR, "InputError"},\ + { RET_EXIST, "AlreadyExist"},\ + { RET_FULL, "Full"},\ + { RET_SENDERR, "SendErr"},\ + { RET_IPINVALID, "IpInvalid"},\ + { RET_BRNAMEERR, "BrNameInvalid"}\ +} + +#endif + diff --git a/Platform/common/rpc/rpc_common.h b/Platform/common/rpc/rpc_common.h index 08302bf24..7e91b2ca9 100755 --- a/Platform/common/rpc/rpc_common.h +++ b/Platform/common/rpc/rpc_common.h @@ -9,7 +9,7 @@ #define RPC_COMMON_H_ #include "rpc_types.h" - +#include "ret_errno.h" #define WORKER_LEN 4 #define BACKLOG 5 @@ -19,53 +19,6 @@ #define TIMEOUT 15 #define TIMEWARN 200 -typedef enum { - /* RPC ret code */ - RET_OK = 0, - RET_ERR = 1, - RET_UNKNOWN = 2, - RET_SYSERR = 3, - RET_NOTFOUND = 4, - RET_TIMEOUT = 5, - - RET_NULLP = 6, - RET_NOMEM = 7, - RET_CHKERR = 8, - RET_EXCEERR = 9, - RET_SOCKERR = 10, - RET_NOTSUPPORT = 11, - RET_INPUTERR = 12, - RET_IPINVALID = 13, - RET_NAMEINVAL = 14, - RET_EXIST = 15, - RET_FULL = 16, - RET_SENDERR = 17 -} ret_code; - -#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, "NotEnoughMemery"},\ - { RET_CHKERR, "CheckError"},\ - { RET_EXCEERR, "ExecutError"},\ - { RET_SOCKERR, "SockError"},\ - { RET_NOTSUPPORT, "NotSupport"},\ - { RET_INPUTERR, "InputError"},\ - { RET_IPINVALID, "IpInvalid"},\ - { RET_NAMEINVAL, "NameInvalid"},\ - { RET_EXIST, "AlreadyExist"},\ - { RET_FULL, "Full"},\ - { RET_SENDERR, "SendErr"}\ -} - -#define RET_BUFF_SIZE 256; - typedef enum { RPC_Parse_OK = 0, RPC_Parse_NeedData = 1, RPC_Parse_Error = 2 } rpc_parse_result; diff --git a/Platform/user/configm/config-server/nat_config/natconfig.c b/Platform/user/configm/config-server/nat_config/natconfig.c index 6492bc4d3..b6ba11db0 100644 --- a/Platform/user/configm/config-server/nat_config/natconfig.c +++ b/Platform/user/configm/config-server/nat_config/natconfig.c @@ -73,7 +73,7 @@ ret_code if_ioctl(unsigned long request, caddr_t ifreq, int *ret) if (sock < 0) { rpc_log_error("Cannot create UDP socket"); - return RET_SOCKERR; + return RET_SYSERR; } if ((*ret = ioctl(sock, request, ifreq)) < 0) { diff --git a/Platform/user/configm/config-server/netconfig/bridge/brconfig.c b/Platform/user/configm/config-server/netconfig/bridge/brconfig.c index 391aea344..8613879b3 100644 --- a/Platform/user/configm/config-server/netconfig/bridge/brconfig.c +++ b/Platform/user/configm/config-server/netconfig/bridge/brconfig.c @@ -127,11 +127,11 @@ ret_code br_name_chk(char *br_name) || strlen(br_name) > BR_NAMSIZ - 1 || strstr(br_name, "br-vl") != NULL) { - return RET_NAMEINVAL; + return RET_BRNAMEERR; } if(br_name[0] != 'b' || br_name[1] != 'r') { - return RET_NAMEINVAL; + return RET_BRNAMEERR; } return RET_OK; diff --git a/Platform/user/configm/config-server/netconfig/ifconfig.c b/Platform/user/configm/config-server/netconfig/ifconfig.c index d7c2a39ae..f22483d05 100644 --- a/Platform/user/configm/config-server/netconfig/ifconfig.c +++ b/Platform/user/configm/config-server/netconfig/ifconfig.c @@ -33,7 +33,7 @@ ret_code if_ioctl(unsigned long request, caddr_t ifreq, int *ret) if (sock < 0) { rpc_log_error("Cannot create UDP socket"); - return RET_SOCKERR; + return RET_SYSERR; } if ((err = ioctl(sock, request, ifreq)) < 0) {