Skip to content
Snippets Groups Projects
Commit 539c2369 authored by Vivek Dutta's avatar Vivek Dutta
Browse files

Updated logic for IP Interface status

parent f7ac5f96
Branches
No related tags found
1 merge request!12Updated logic for IP Interface status
Pipeline #184019 passed
......@@ -1257,10 +1257,34 @@ static int set_IPInterface_ULAEnable(char *refparam, struct dmctx *ctx, void *da
return 0;
}
// ifstatus = Down and devstatus = Down => Status=Down
// ifstatus = Down and devstatus = Up => Status=Dormant
// ifstatus = Up and devstatus = Up => Status=Up
// ifstatus not available => Status=Unknown
// devstatus != Up => Status=LowerLayerDown
static int get_IPInterface_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *device = get_device(section_name(((struct dm_data *)data)->config_section));
return get_net_device_status(device, value);
json_object *res = NULL;
char *if_name = section_name(((struct dm_data *)data)->config_section);
char *device = get_device(if_name);
char *devstatus = NULL;
bool ifstatus = false;
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
DM_ASSERT(res, *value = dmstrdup("Unknown"));
string_to_bool(dmjson_get_value(res, 1, "up"), &ifstatus);
get_net_device_status(device, &devstatus);
if ((ifstatus == false) && (DM_STRNCMP(devstatus, "Up", 2) == 0)) {
*value = dmstrdup("Dormant");
} else if (DM_STRNCMP(devstatus, "Up", 2) != 0) {
*value = dmstrdup("LowerLayerDown");
} else {
*value = devstatus;
}
return 0;
}
/*#Device.IP.Interface.{i}.Alias!UCI:dmmap_network/interface,@i-1/ip_int_alias*/
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment