MOD aaa-12 解决显示ipv6地址存储空间不够的问题,并忽略SIGPIPE信号
SOL 解决显示ipv6地址存储空间不够的问题,并忽略SIGPIPE信号 修改人:zhangliang 检视人:zhangliang
This commit is contained in:
parent
3c956f398e
commit
8309b8268f
|
@ -58,7 +58,15 @@ void cm_return(rpc_conn *conn, ret_code err_code, char* err_message)
|
|||
|
||||
snprintf(config_ret->resultCode, RET_CODE_LEN - 1, "%d", err_code);
|
||||
config_ret->message = (char *)rpc_code_format(err_code);
|
||||
config_ret->data = null_str;
|
||||
|
||||
if(err_code == RET_SYSERR)
|
||||
{
|
||||
config_ret->data = strerror(errno);
|
||||
}
|
||||
else
|
||||
{
|
||||
config_ret->data = null_str;
|
||||
}
|
||||
|
||||
s2j_create_json_obj(json_obj);
|
||||
if(json_obj == NULL)
|
||||
|
@ -425,7 +433,9 @@ void cm_config_process(rpc_conn *conn, pointer input, int input_len, void* data)
|
|||
int main(int argc, char **argv)
|
||||
{
|
||||
rpc_server *server;
|
||||
|
||||
|
||||
signal(SIGPIPE,SIG_IGN);
|
||||
|
||||
if (server= rpc_server_create_ex("ConfigManger#0"))
|
||||
{
|
||||
rpc_log_info("start server\n");
|
||||
|
|
|
@ -90,7 +90,7 @@ struct _ip_config_string {
|
|||
int config_type;
|
||||
char ifname[INTERFACE_NAMSIZ];
|
||||
int family;
|
||||
char ipaddr[DOT_IP_STR];
|
||||
char ipaddr[DOT_IPV6_STR];
|
||||
int prefixlen;
|
||||
};
|
||||
|
||||
|
|
|
@ -95,6 +95,8 @@ void ip6_save_file(ip_config_t *ip_conf, uint config_type)
|
|||
|
||||
ret_code ip_config_json_parse(pointer input, uint *conf_type, ip_config_t *config_buff)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
int err = 1;
|
||||
cJSON *json_obj;
|
||||
|
||||
json_obj = cJSON_Parse(input);
|
||||
|
@ -116,7 +118,7 @@ ret_code ip_config_json_parse(pointer input, uint *conf_type, ip_config_t *confi
|
|||
s2j_struct_get_basic_element(ip_config, json_obj, int, config_type);
|
||||
s2j_struct_get_string_element(ip_config, json_obj, ifname, INTERFACE_NAMSIZ);
|
||||
s2j_struct_get_basic_element(ip_config, json_obj, int, family);
|
||||
s2j_struct_get_string_element(ip_config, json_obj, ipaddr, DOT_IP_STR);
|
||||
s2j_struct_get_string_element(ip_config, json_obj, ipaddr, DOT_IPV6_STR);
|
||||
s2j_struct_get_basic_element(ip_config, json_obj, int, prefixlen);
|
||||
|
||||
strncpy(config_buff->ifname, ip_config->ifname, INTERFACE_NAMSIZ - 1);
|
||||
|
@ -126,11 +128,16 @@ ret_code ip_config_json_parse(pointer input, uint *conf_type, ip_config_t *confi
|
|||
|
||||
if(config_buff->family == AF_INET)
|
||||
{
|
||||
config_buff->prefix.s_addr = inet_addr(ip_config->ipaddr);
|
||||
err = inet_pton(AF_INET, ip_config->ipaddr, &(config_buff->prefix));
|
||||
}
|
||||
else if(config_buff->family == AF_INET6)
|
||||
{
|
||||
inet_pton(AF_INET6, ip_config->ipaddr, config_buff->prefix6.s6_addr);
|
||||
err = inet_pton(AF_INET6, ip_config->ipaddr, &(config_buff->prefix6));
|
||||
}
|
||||
|
||||
if(err != 1)
|
||||
{
|
||||
ret = RET_IPINVALID;
|
||||
}
|
||||
|
||||
if(ip_config->config_type)
|
||||
|
@ -141,7 +148,7 @@ ret_code ip_config_json_parse(pointer input, uint *conf_type, ip_config_t *confi
|
|||
s2j_delete_struct_obj(ip_config);
|
||||
cJSON_Delete(json_obj);
|
||||
|
||||
return RET_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -335,7 +342,6 @@ ret_code ip_config_getall_chk(uint source,uint config_type,
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
ret_code ip_config_chk(uint source,uint *config_type,
|
||||
pointer input, int *input_len,
|
||||
pointer output, int *output_len)
|
||||
|
@ -352,7 +358,7 @@ ret_code ip_config_chk(uint source,uint *config_type,
|
|||
|
||||
switch (conf_type)
|
||||
{
|
||||
case CM_CONFIG_SET:
|
||||
case CM_CONFIG_SET:
|
||||
case CM_CONFIG_DEL:
|
||||
ret = ip_config_set_chk(source, conf_type,
|
||||
&ip_config, config_len,
|
||||
|
@ -381,7 +387,7 @@ ret_code ip_config_chk(uint source,uint *config_type,
|
|||
*input_len = config_len;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
ret = RET_NOMEM;
|
||||
}
|
||||
|
||||
|
@ -400,6 +406,7 @@ ret_code ip_config_chk(uint source,uint *config_type,
|
|||
删除ipv6地址
|
||||
{"config_type":2,"ifname":"br0","family":10,"ipaddr":"2001::1","prefixlen":64}
|
||||
*/
|
||||
|
||||
ret_code ip_config_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
|
@ -545,5 +552,4 @@ ret_code ip_config_get_all(uint source, pointer output, int *output_len)
|
|||
ASSERT_RET(ret);
|
||||
|
||||
return RET_OK;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue