From 3258396176a511a463614d7a7272d4acde4cd700 Mon Sep 17 00:00:00 2001 From: Amin Ben Ramdhane Date: Tue, 26 Jan 2021 17:56:54 +0100 Subject: [PATCH] Ticket refs #4279: AddressingType and Origin parameters not IPCP when proto is PPPoE --- dmtree/tr181/ip.c | 11 +++++++++-- dmtree/tr181/routing.c | 13 ++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/dmtree/tr181/ip.c b/dmtree/tr181/ip.c index 65ffb931..7d8b71ba 100644 --- a/dmtree/tr181/ip.c +++ b/dmtree/tr181/ip.c @@ -1838,8 +1838,15 @@ static int set_IPInterfaceIPv4Address_SubnetMask(char *refparam, struct dmctx *c /*#Device.IP.Interface.{i}.IPv4Address.{i}.AddressingType!UCI:network/interface,@i-1/proto*/ static int get_IPInterfaceIPv4Address_AddressingType(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->interface_sec, "proto", value); - *value = (strcmp(*value, "static") == 0) ? "Static" : "DHCP"; + char *proto = NULL; + + dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->interface_sec, "proto", &proto); + if (proto && strcmp(proto, "static") == 0) + *value = "Static"; + else if (proto && strncmp(proto, "ppp", 3) == 0) + *value = "IPCP"; + else + *value = "DHCP"; return 0; } diff --git a/dmtree/tr181/routing.c b/dmtree/tr181/routing.c index 9fd86465..e8377f50 100644 --- a/dmtree/tr181/routing.c +++ b/dmtree/tr181/routing.c @@ -31,7 +31,6 @@ struct routingfwdargs { char *permission; struct uci_section *routefwdsection; - struct proc_routing *proute; int type; }; @@ -630,8 +629,16 @@ static int get_router_ipv4forwarding_origin(char *refparam, struct dmctx *ctx, v { if (((struct routingfwdargs *)data)->type != ROUTE_DYNAMIC) *value = "Static"; - else - *value = "DHCPv4"; + else { + json_object *res = NULL; + char *interface; + + dmuci_get_value_by_section_string(((struct routingfwdargs *)data)->routefwdsection, "interface", &interface); + dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", interface, String}}, 1, &res); + DM_ASSERT(res, *value = "DHCPv4"); + char *proto = dmjson_get_value(res, 1, "proto"); + *value = (proto && strncmp(proto, "ppp", 3) == 0) ? "IPCP" : "DHCPv4"; + } return 0; }