libbbfdm : initial release

This commit is contained in:
Amin Ben Ramdhane 2019-08-26 17:02:43 +01:00
parent c56bba04ad
commit cb2dd1e4ac
137 changed files with 234370 additions and 0 deletions

0
AUTHORS Normal file
View file

312
COPYING Normal file
View file

@ -0,0 +1,312 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
cwmp is GPLv2 licensed cwmp implementation
Copyright (C) 2011-2012 Luka Perkov
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
cwmp Copyright (C) 2011-2012 Luka Perkov
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions.

0
ChangeLog Normal file
View file

3
Makefile.am Normal file
View file

@ -0,0 +1,3 @@
MAINTAINERCLEANFILES = Makefile.in
SUBDIRS = bin

0
NEWS Normal file
View file

29
README Normal file
View file

@ -0,0 +1,29 @@
configure autotools
===================
$ autoreconf -if
clean it all up
===============
$ make distclean
or
$ git clean -df
development environment
=======================
Make sure you have all the packages installed from packages-arch-tr069 git
repository.
$ ln -sf `pwd`/scripts/defaults /usr/share/icwmp/defaults
run icwmpd
=============
$ export UCI_CONFIG_DIR="`pwd`/config/"
$ export UBUS_SOCKET="/tmp/ubus.sock"
$ ./bin/icwmpd -f

109
bin/Makefile.am Normal file
View file

@ -0,0 +1,109 @@
CWMP_VERSION = 3.0.0
LIB_BBFDM_VERSION = 3:0:0
lib_LTLIBRARIES = libbbfdm.la
libbbfdm_la_SOURCES = \
../md5.c \
../dmcwmp.c \
../dmentry.c \
../dmmem.c \
../dmubus.c \
../dmjson.c \
../dmuci.c \
../dmcommon.c \
../dmoperate.c \
../dmdiagnostics.c \
../wepkey.c
if BBF_TR181
libbbfdm_la_SOURCES += \
../dmtree/tr181/device.c \
../dmtree/tr181/deviceinfo.c \
../dmtree/tr181/managementserver.c \
../dmtree/tr181/softwaremodules.c \
../dmtree/tr181/times.c \
../dmtree/tr181/upnp.c \
../dmtree/tr181/x_iopsys_eu_ice.c \
../dmtree/tr181/x_iopsys_eu_igmp.c \
../dmtree/tr181/x_iopsys_eu_ipacccfg.c \
../dmtree/tr181/x_iopsys_eu_logincfg.c \
../dmtree/tr181/x_iopsys_eu_power_mgmt.c \
../dmtree/tr181/x_iopsys_eu_syslog.c \
../dmtree/tr181/x_iopsys_eu_dropbear.c \
../dmtree/tr181/x_iopsys_eu_owsd.c \
../dmtree/tr181/x_iopsys_eu_buttons.c \
../dmtree/tr181/x_iopsys_eu_wifilife.c \
../dmtree/tr181/xmpp.c \
../dmtree/tr181/wifi.c \
../dmtree/tr181/ethernet.c \
../dmtree/tr181/atm.c \
../dmtree/tr181/ptm.c \
../dmtree/tr181/bridging.c \
../dmtree/tr181/hosts.c \
../dmtree/tr181/dhcpv4.c \
../dmtree/tr181/ip.c \
../dmtree/tr181/ppp.c \
../dmtree/tr181/nat.c \
../dmtree/tr181/routing.c \
../dmtree/tr181/userinterface.c \
../dmtree/tr181/firewall.c \
../dmtree/tr181/dns.c \
../dmtree/tr181/users.c \
../dmtree/tr181/dhcpv6.c \
../dmtree/tr181/dsl.c \
../dmtree/tr181/interfacestack.c \
../dmtree/tr181/qos.c
endif
if BBF_TR104
libbbfdm_la_SOURCES += \
../dmtree/tr104/voice_services.c
endif
if BBF_TR143
libbbfdm_la_SOURCES += \
../dmtree/tr143/diagnostics.c
endif
if BBF_TR064
libbbfdm_la_SOURCES += \
../dmtree/tr064/upnp_device.c \
../dmtree/tr064/upnp_deviceinfo.c \
../dmtree/tr064/upnp_configuration.c \
../dmtree/tr064/upnp_monitoring.c \
../dmtree/tr064/upnp_common.c
endif
libbbfdm_la_CFLAGS = \
$(AM_CFLAGS) \
$(LIBUCI_CFLAGS) \
$(LIBUBOX_CFLAGS) \
$(LIBUBUS_CFLAGS)
libbbfdm_la_LDFLAGS = \
$(AM_LDFLAGS) \
$(LIBUCI_LDFLAGS) \
$(LIBUBOX_LDFLAGS) \
$(LIBUBUS_LDFLAGS) \
-share \
-version-info $(LIB_BBFDM_VERSION)
libbbfdm_la_LIBADD = \
$(AM_LIBS) \
$(LIBUCI_LIBS) \
$(LIBUBOX_LIBS) \
$(LIBUBUS_LIBS) \
$(LIBJSON_LIBS) \
$(LIBTRACE_LIBS) \
$(LBLOBMSG_LIBS)
libbbfdm_la_CFLAGS+=-DCWMP_VERSION=\"$(CWMP_VERSION)\"
libbbfdm_la_LDFLAGS+=-DCWMP_VERSION=\"$(CWMP_VERSION)\"
libbbfdm_la_CFLAGS+=-I../
libbbfdm_la_CFLAGS+=-I../dmtree/
libbbfdm_la_CFLAGS+=-I../dmtree/tr181
libbbfdm_la_CFLAGS+=-I../dmtree/tr104
libbbfdm_la_CFLAGS+=-I../dmtree/tr143
libbbfdm_la_CFLAGS+=-I../dmtree/tr064

0
config/dmmap Normal file
View file

84
configure.ac Normal file
View file

@ -0,0 +1,84 @@
AC_INIT([libbbfdm], [0.1], [mohamed.kallel@pivasoftware.com])
AM_INIT_AUTOMAKE
AM_INIT_AUTOMAKE([subdir-objects])
AC_ARG_ENABLE(tr181, [AS_HELP_STRING([--enable-tr181], [enable tr181 device feature])], AC_DEFINE(BBF_TR181),)
AM_CONDITIONAL([BBF_TR181],[test "x$enable_tr181" = "xyes"])
AC_ARG_ENABLE(tr104, [AS_HELP_STRING([--enable-tr104], [enable tr104 voice feature])], AC_DEFINE(BBF_TR104),)
AM_CONDITIONAL([BBF_TR104],[test "x$enable_tr104" = "xyes"])
AC_ARG_ENABLE(tr143, [AS_HELP_STRING([--enable-tr143], [enable tr143 diagnostics feature])], AC_DEFINE(BBF_TR143),)
AM_CONDITIONAL([BBF_TR143],[test "x$enable_tr143" = "xyes"])
AC_ARG_ENABLE(tr064, [AS_HELP_STRING([--enable-tr064], [enable tr064 upnp feature])], AC_DEFINE(BBF_TR064),)
AM_CONDITIONAL([BBF_TR064],[test "x$enable_tr064" = "xyes"])
# checks for programs
AC_PROG_CC
AM_PROG_CC_C_O
LT_INIT
AC_ENABLE_SHARED
LIBJSON_LIBS='-ljson-c'
AC_SUBST([LIBJSON_LIBS])
AC_ARG_WITH([uci-include-path],
[AS_HELP_STRING([--with-uci-include-path],
[location of the uci library headers])],
[LIBUCI_CFLAGS="-I$withval"])
AC_SUBST([LIBUCI_CFLAGS])
AC_ARG_WITH([uci-lib-path],
[AS_HELP_STRING([--with-uci-lib-path], [location of the uci library])], [LIBUCI_LDFLAGS="-L$withval"])
AC_SUBST([LIBUCI_LDFLAGS])
LIBUCI_LIBS='-luci'
AC_SUBST([LIBUCI_LIBS])
LIBTRACE_LIBS='-ltrace'
AC_SUBST([LIBTRACE_LIBS])
AC_ARG_WITH([libubox-include-path],
[AS_HELP_STRING([--with-libubox-include-path],
[location of the libubox library headers])],
[LIBUBOX_CFLAGS="-I$withval"])
AC_SUBST([LIBUBOX_CFLAGS])
AC_ARG_WITH([libubox-lib-path],
[AS_HELP_STRING([--with-libubox-lib-path], [location of the libubox library])], [LIBUBOX_LDFLAGS="-L$withval"])
AC_SUBST([LIBUBOX_LDFLAGS])
LIBUBOX_LIBS='-lubox'
AC_SUBST([LIBUBOX_LIBS])
AC_ARG_WITH([libubus-include-path],
[AS_HELP_STRING([--with-libubus-include-path],
[location of the libubus library headers])],
[LIBUBUS_CFLAGS="-I$withval"])
AC_SUBST([LIBUBUS_CFLAGS])
AC_ARG_WITH([libubus-lib-path],
[AS_HELP_STRING([--with-libubus-lib-path], [location of the libubus library])], [LIBUBOX_LDFLAGS="-L$withval"])
AC_SUBST([LIBUBUS_LDFLAGS])
LIBUBUS_LIBS='-lubus'
AC_SUBST([LIBUBUS_LIBS])
LBLOBMSG_LIBS='-lblobmsg_json'
AC_SUBST([LBLOBMSG_LIBS])
# checks for header files
AC_CHECK_HEADERS([stdlib.h string.h])
# checks for typedefs, structures, and compiler characteristics
AC_TYPE_UINT8_T
# Makefiles
AC_CONFIG_FILES([
Makefile
bin/Makefile
])
AC_OUTPUT

1715
dmcommon.c Normal file

File diff suppressed because it is too large Load diff

213
dmcommon.h Normal file
View file

@ -0,0 +1,213 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2015 PIVA SOFTWARE (www.pivasoftware.com)
* Author: Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author: Feten Besbes <feten.besbes@pivasoftware.com>
*/
#ifndef __DM_COMMON_H
#define __DM_COMMON_H
#include <sys/types.h>
#include <libubox/blobmsg_json.h>
#include <json-c/json.h>
#include <unistd.h>
#include "dmcwmp.h"
#define NVRAM_FILE "/proc/nvram/WpaKey"
#define MAX_DHCP_LEASES 256
#define MAX_PROC_ROUTING 256
#define ROUTING_FILE "/proc/net/route"
#define ARP_FILE "/proc/net/arp"
#define DHCP_LEASES_FILE "/tmp/dhcp.leases"
#define DMMAP "dmmap"
#define DHCPSTATICADDRESS_DISABLED_CHADDR "00:00:00:00:00:01"
#define DM_ASSERT(X, Y) \
do { \
if(!(X)) { \
Y; \
return -1; \
} \
} while(0)
#define dmstrappendstr(dest, src) \
do { \
int len = strlen(src); \
memcpy(dest, src, len); \
dest += len; \
} while(0)
#define dmstrappendchr(dest, c) \
do { \
*dest = c; \
dest += 1; \
} while(0)
#define dmstrappendend(dest) \
do { \
*dest = '\0'; \
} while(0)
#define DMCMD(CMD, N, ...) \
do { \
int mpp = dmcmd(CMD, N, ## __VA_ARGS__); \
if (mpp) close (mpp); \
} while (0)
#define IPPING_PATH "/usr/share/icwmp/functions/ipping_launch"
#define IPPING_STOP DMCMD("/bin/sh", 2, IPPING_PATH, "stop");
#define DOWNLOAD_DIAGNOSTIC_PATH "/usr/share/icwmp/functions/download_launch"
#define DOWNLOAD_DUMP_FILE "/tmp/download_dump"
#define DOWNLOAD_DIAGNOSTIC_STOP DMCMD("/bin/sh", 2, DOWNLOAD_DIAGNOSTIC_PATH, "stop");
#define UPLOAD_DIAGNOSTIC_PATH "/usr/share/icwmp/functions/upload_launch"
#define UPLOAD_DUMP_FILE "/tmp/upload_dump"
#define UPLOAD_DIAGNOSTIC_STOP DMCMD("/bin/sh", 2, UPLOAD_DIAGNOSTIC_PATH, "stop");
#define NSLOOKUP_PATH "/usr/share/icwmp/functions/nslookup_launch"
#define NSLOOKUP_LOG_FILE "/tmp/nslookup.log"
#define NSLOOKUP_STOP DMCMD("/bin/sh", 2, NSLOOKUP_PATH, "stop");
#define TRACEROUTE_PATH "/usr/share/icwmp/functions/traceroute_launch"
#define TRACEROUTE_STOP DMCMD("/bin/sh", 2, TRACEROUTE_PATH, "stop");
#define UDPECHO_PATH "/usr/share/icwmp/functions/udpecho_launch"
#define UDPECHO_STOP DMCMD("/bin/sh", 2, UDPECHO_PATH, "stop");
#define SERVERSELECTION_PATH "/usr/share/icwmp/functions/serverselection_launch"
#define SERVERSELECTION_STOP DMCMD("/bin/sh", 2, SERVERSELECTION_PATH, "stop");
enum notification_enum {
notification_none,
notification_passive,
notification_active,
notification_passive_lw,
notification_ppassive_passive_lw,
notification_aactive_lw,
notification_passive_active_lw,
__MAX_notification
};
enum strstructered_enum {
STRUCTERED_SAME,
STRUCTERED_PART,
STRUCTERED_NULL
};
struct proc_routing {
char *iface;
char *flags;
char *refcnt;
char *use;
char *metric;
char *mtu;
char *window;
char *irtt;
char destination[16];
char gateway[16];
char mask[16];
};
struct routingfwdargs
{
char *permission;
struct uci_section *routefwdsection;
struct proc_routing *proute;
int type;
};
struct dmmap_dup
{
struct list_head list;
struct uci_section *config_section;
struct uci_section *dmmap_section;
void* additional_attribute;
};
struct dmmap_sect {
struct list_head list;
char *section_name;
char *instance;
};
struct dm_args
{
struct uci_section *section;
struct uci_section *dmmap_section;
char *name;
};
void compress_spaces(char *str);
char *cut_fx(char *str, char *delimiter, int occurence);
pid_t get_pid(char *pname);
int check_file(char *path);
char *cidr2netmask(int bits);
void remove_substring(char *s, const char *str_remove);
bool is_strword_in_optionvalue(char *optionvalue, char *str);
int get_interface_enable_ubus(char *iface, char *refparam, struct dmctx *ctx, char **value);
int set_interface_enable_ubus(char *iface, char *refparam, struct dmctx *ctx, int action, char *value);
int get_interface_firewall_enabled(char *iface, char *refparam, struct dmctx *ctx, char **value);
struct uci_section *create_firewall_zone_config(char *fwl, char *iface, char *input, char *forward, char *output);
int set_interface_firewall_enabled(char *iface, char *refparam, struct dmctx *ctx, int action, char *value);
int dmcmd(char *cmd, int n, ...);
int dmcmd_read(int pipe, char *buffer, int size);
void dmcmd_read_alloc(int pipe, char **value);
int dmcmd_no_wait(char *cmd, int n, ...);
int ipcalc(char *ip_str, char *mask_str, char *start_str, char *end_str, char *ipstart_str, char *ipend_str);
int ipcalc_rev_start(char *ip_str, char *mask_str, char *ipstart_str, char *start_str);
int ipcalc_rev_end(char *ip_str, char *mask_str, char *start_str, char *ipend_str, char *end_str);
int network_get_ipaddr(char **value, char *iface);
void remove_vid_interfaces_from_ifname(char *vid, char *ifname, char *new_ifname);
void update_section_option_list(char *config, char *section, char *option, char *option_2,char *val, char *val_2, char *name);
void update_section_list_icwmpd(char *config, char *section, char *option, int number, char *filter, char *option1, char *val1, char *option2, char *val2);
void update_section_list(char *config, char *section, char *option, int number, char *filter, char *option1, char *val1, char *option2, char *val2);
char *get_nvram_wpakey();
int reset_wlan(struct uci_section *s);
int get_cfg_layer2idx(char *pack, char *section_type, char *option, int shift);
int wan_remove_dev_interface(struct uci_section *interface_setion, char *dev);
int filter_lan_device_interface(struct uci_section *s);
void remove_vlan_from_bridge_interface(char *bridge_key, struct uci_section *vb);
void update_remove_vlan_from_bridge_interface(char *bridge_key, struct uci_section *vb);
int filter_lan_ip_interface(struct uci_section *ss, void *v);
void remove_interface_from_ifname(char *iface, char *ifname, char *new_ifname);
int max_array(int a[], int size);
int check_ifname_is_vlan(char *ifname);
int set_uci_dhcpserver_option(struct dmctx *ctx, struct uci_section *s, char *option, char *value);
int update_uci_dhcpserver_option(struct dmctx *ctx, struct uci_section *s, char *option, char * new_option, char *value);
void parse_proc_route_line(char *line, struct proc_routing *proute);
int strstructered(char *str1, char *str2);
int dmcommon_check_notification_value(char *value);
void hex_to_ip(char *address, char *ret);
void ip_to_hex(char *address, char *ret);
void free_dmmap_config_dup_list(struct list_head *dup_list);
void synchronize_specific_config_sections_with_dmmap(char *package, char *section_type, char *dmmap_package, struct list_head *dup_list);
void synchronize_specific_config_sections_with_dmmap_eq(char *package, char *section_type, char *dmmap_package,char* option_name, char* option_value, struct list_head *dup_list);
void synchronize_specific_config_sections_with_dmmap_eq_no_delete(char *package, char *section_type, char *dmmap_package,char* option_name, char* option_value, struct list_head *dup_list);
void synchronize_specific_config_sections_with_dmmap_cont(char *package, char *section_type, char *dmmap_package,char* option_name, char* option_value, struct list_head *dup_list);
bool synchronize_multi_config_sections_with_dmmap_eq(char *package, char *section_type, char *dmmap_package, char* dmmap_section, char* option_name, char* option_value, void* additional_attribute, struct list_head *dup_list);
bool synchronize_multi_config_sections_with_dmmap_eq_diff(char *package, char *section_type, char *dmmap_package, char* dmmap_section, char* option_name, char* option_value, char* opt_diff_name, char* opt_diff_value, void* additional_attribute, struct list_head *dup_list);
void get_dmmap_section_of_config_section(char* dmmap_package, char* section_type, char *section_name, struct uci_section **dmmap_section);
void get_dmmap_section_of_config_section_eq(char* dmmap_package, char* section_type, char *opt, char* value, struct uci_section **dmmap_section);
void get_config_section_of_dmmap_section(char* package, char* section_type, char *section_name, struct uci_section **config_section);
void check_create_dmmap_package(char *dmmap_package);
int is_section_unnamed(char *section_name);
void delete_sections_save_next_sections(char* dmmap_package, char *section_type, char *instancename, char *section_name, int instance, struct list_head *dup_list);
void update_dmmap_sections(struct list_head *dup_list, char *instancename, char* dmmap_package, char *section_type);
unsigned char isdigit_str(char *str);
char *dm_strword(char *src, char *str);
char **strsplit(const char* str, const char* delim, size_t* numtokens);
char *get_macaddr(char *ifname);
char *get_device(char *ifname);
int is_elt_exit_in_str_list(char *str_list, char *elt);
void add_elt_to_str_list(char **str_list, char *elt);
void remove_elt_from_str_list(char **iface_list, char *ifname);
struct uci_section *get_dup_section_in_dmmap_eq(char *dmmap_package, char* section_type, char*sect_name, char *opt_name, char* opt_value);
int is_array_elt_exist(char **str_array, char *str, int length);
int get_shift_time_time(int shift_time, char *local_time, int size);
int get_shift_time_shift(char *local_time, char *shift);
int get_stats_from_ifconfig_command(char *device, char *direction, char *option);
int command_exec_output_to_array(char *cmd, char **output, int *length);
char* int_period_to_date_time_format(int time);
int copy_temporary_file_to_original_file(char *f1, char *f2);
struct uci_section *is_dmmap_section_exist(char* package, char* section);
struct uci_section *is_dmmap_section_exist_eq(char* package, char* section, char* opt, char* value);
#endif

3169
dmcwmp.c Normal file

File diff suppressed because it is too large Load diff

589
dmcwmp.h Normal file
View file

@ -0,0 +1,589 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2015 Inteno Broadband Technology AB
* Author MOHAMED Kallel <mohamed.kallel@pivasoftware.com>
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author Feten Besbes <feten.besbes@pivasoftware.com>
*
*/
#ifndef __DMCWMP_H__
#define __DMCWMP_H__
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
#include <libubox/list.h>
#include "dmuci.h"
#include "dmmem.h"
#ifdef BBF_TR064
#define DMROOT_UPNP ""
#define DMDELIM_UPNP '/'
#endif
#define DMDELIM_CWMP '.'
#define DM_PROMPT "icwmp>"
#define DM_ENABLED_NOTIFY "/etc/icwmpd/.dm_enabled_notify"
#define DM_ENABLED_NOTIFY_TEMPORARY "/tmp/.dm_enabled_notify_temporary"
#ifdef BBF_TR064
#define UPNP_CFG "tr064"
#endif
#ifdef UNDEF
#undef UNDEF
#endif
#define UNDEF -1
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#endif
#ifndef FREE
#define FREE(x) do { free(x); x = NULL; } while (0)
#endif
extern struct dm_permession_s DMREAD;
extern struct dm_permession_s DMWRITE;
extern struct dm_forced_inform_s DMFINFRM;
extern struct dm_notif_s DMNONE;
extern struct dm_notif_s DMACTIVE;
extern struct dm_notif_s DMPASSIVE;
#define DMPARAM_ARGS \
struct dmctx *dmctx, \
struct dmnode *node, \
char *lastname, \
struct dm_permession_s *permission, \
int type, \
int (*get_cmd)(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value), \
int (*set_cmd)(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action), \
struct dm_forced_inform_s *forced_inform, \
struct dm_notif_s *notification, \
void *data, \
char *instance
#define DMOBJECT_ARGS \
struct dmctx *dmctx, \
struct dmnode *node, \
struct dm_permession_s *permission, \
int (*addobj)(char *refparam, struct dmctx *ctx, void *data, char **instance), \
int (*delobj)(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action), \
struct dm_forced_inform_s *forced_inform, \
struct dm_notif_s *notification, \
int (*get_linker)(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker), \
void *data, \
char *instance
#define TAILLE_MAX 1024
struct dm_forced_inform_s;
struct dm_permession_s;
struct dm_parameter;
struct dm_leaf_s;
struct dm_obj_s;
struct dmnode;
struct dmctx;
struct dm_notif_s;
struct dm_permession_s {
char *val;
char *(*get_permission)(char *refparam, struct dmctx *dmctx, void *data, char *instance);
};
struct dm_forced_inform_s {
unsigned char val;
unsigned char (*get_forced_inform)(char *refparam, struct dmctx *dmctx, void *data, char *instance);
};
struct dm_notif_s {
char *val;
char *(*get_notif)(char *refparam, struct dmctx *dmctx, void *data, char *instance);
};
typedef struct dm_leaf_s {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type(8)*/
char *parameter;
struct dm_permession_s *permission;
int type;
int (*getvalue)(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int (*setvalue)(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
struct dm_forced_inform_s *forced_inform;
struct dm_notif_s *notification;
int bbfdm_type;
} DMLEAF;
typedef struct dm_obj_s {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type(12)*/
char *obj;
struct dm_permession_s *permission;
int (*addobj)(char *refparam, struct dmctx *ctx, void *data, char **instance);
int (*delobj)(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
bool (*checkobj)(struct dmctx *dmctx, void *data);
int (*browseinstobj)(struct dmctx *dmctx, struct dmnode *node, void *data, char *instance);
struct dm_forced_inform_s *forced_inform;
struct dm_notif_s *notification;
struct dm_obj_s *nextobj;
struct dm_leaf_s *leaf;
int (*get_linker)(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
int bbfdm_type;
} DMOBJ;
#ifdef BBF_TR064
typedef struct dm_upnp_supported_dm_s {
char *location;
char *uri;
char *url;
char *description;
char *source_location;
} UPNP_SUPPORTED_DM;
#endif
struct set_tmp {
struct list_head list;
char *name;
char *value;
unsigned int flags;
};
struct param_fault {
struct list_head list;
char *name;
int fault;
};
struct dm_enabled_notify {
struct list_head list;
char *name;
char *notification;
char *value;
};
#ifdef BBF_TR064
struct dm_upnp_enabled_track {
struct list_head list;
char *name;
char *key;
char *value;
unsigned int isobj;
};
#endif
struct dm_parameter {
struct list_head list;
char *name;
char *data;
char *type;
char *version;
unsigned int flags;
};
struct dmctx
{
bool stop;
bool match;
int (*method_param)(DMPARAM_ARGS);
int (*method_obj)(DMOBJECT_ARGS);
int (*checkobj)(DMOBJECT_ARGS);
int (*checkleaf)(DMOBJECT_ARGS);
struct list_head list_parameter;
struct list_head set_list_tmp;
struct list_head list_fault_param;
DMOBJ *dm_entryobj;
bool nextlevel;
int depth;
int faultcode;
int setaction;
char *in_param;
char *in_notification;
bool notification_change;
char *in_value;
char *addobj_instance;
char *linker;
char *linker_param;
unsigned int dmparam_flags;
unsigned int alias_register;
unsigned int nbrof_instance;
unsigned int amd_version;
unsigned int instance_mode;
unsigned int dm_type;
unsigned int user_mask;
unsigned char inparam_isparam;
unsigned char findparam;
char all_instances[512];
char *inst_buf[16];
char *instance_wildchar;
};
typedef struct dmnode {
DMOBJ *obj;
struct dmnode *parent;
char *current_object;
unsigned char instance_level;
unsigned char matched;
unsigned char is_instanceobj;
} DMNODE;
struct prefix_method {
const char *prefix_name;
bool enable;
bool (*set_enable)(void);
bool forced_inform;
int (*method)(struct dmctx *ctx);
};
struct notification {
char *value;
char *type;
};
struct dm_acl {
unsigned int flag;
char *user_access;
};
typedef struct execute_end_session {
struct list_head list;
int action;
unsigned int dm_type;
unsigned int amd_version;
unsigned int instance_mode;
void *data;
void (*function)(struct execute_end_session *);
} execute_end_session;
enum set_value_action {
VALUECHECK,
VALUESET
};
enum del_action_enum {
DEL_INST,
DEL_ALL
};
enum {
CMD_GET_VALUE,
CMD_GET_NAME,
CMD_GET_NOTIFICATION,
CMD_SET_VALUE,
CMD_SET_NOTIFICATION,
CMD_ADD_OBJECT,
CMD_DEL_OBJECT,
CMD_INFORM,
CMD_USP_OPERATE,
#ifdef BBF_TR064
CMD_UPNP_GET_SUPPORTED_PARAMETERS,
CMD_UPNP_GET_INSTANCES,
CMD_UPNP_GET_SELECTED_VALUES,
CMD_UPNP_GET_VALUES,
CMD_UPNP_SET_VALUES,
CMD_UPNP_GET_ATTRIBUTES,
CMD_UPNP_SET_ATTRIBUTES,
CMD_UPNP_DEL_INSTANCE,
CMD_UPNP_ADD_INSTANCE,
CMD_UPNP_GET_ACLDATA,
CMD_UPNP_INIT_STATE_VARIABLES,
CMD_UPNP_LOAD_ENABLED_PARAMETRS_TRACK,
CMD_UPNP_GET_CONFIGURATION_UPDATE,
CMD_UPNP_GET_CURRENT_CONFIGURATION_VERSION,
CMD_UPNP_GET_SUPPORTED_DATA_MODEL_UPDATE,
CMD_UPNP_GET_SUPPORTED_PARAMETERS_UPDATE,
CMD_UPNP_GET_ATTRIBUTE_VALUES_UPDATE,
CMD_UPNP_GET_ENABLED_PARAMETRS_ALARM,
CMD_UPNP_GET_ENABLED_PARAMETRS_EVENT,
CMD_UPNP_GET_ENABLED_PARAMETRS_VERSION,
CMD_UPNP_CHECK_CHANGED_PARAMETRS_ALARM,
CMD_UPNP_CHECK_CHANGED_PARAMETRS_EVENT,
CMD_UPNP_CHECK_CHANGED_PARAMETRS_VERSION,
#endif
CMD_EXTERNAL_COMMAND
};
enum fault_code_enum {
FAULT_9000 = 9000,// Method not supported
FAULT_9001,// Request denied
FAULT_9002,// Internal error
FAULT_9003,// Invalid arguments
FAULT_9004,// Resources exceeded
FAULT_9005,// Invalid parameter name
FAULT_9006,// Invalid parameter type
FAULT_9007,// Invalid parameter value
FAULT_9008,// Attempt to set a non-writable parameter
FAULT_9009,// Notification request rejected
FAULT_9010,// Download failure
FAULT_9011,// Upload failure
FAULT_9012,// File transfer server authentication failure
FAULT_9013,// Unsupported protocol for file transfer
FAULT_9014,// Download failure: unable to join multicast group
FAULT_9015,// Download failure: unable to contact file server
FAULT_9016,// Download failure: unable to access file
FAULT_9017,// Download failure: unable to complete download
FAULT_9018,// Download failure: file corrupted
FAULT_9019,// Download failure: file authentication failure
FAULT_9020,// Download failure: unable to complete download
FAULT_9021,// Cancelation of file transfer not permitted
FAULT_9022,// Invalid UUID format
FAULT_9023,// Unknown Execution Environment
FAULT_9024,// Disabled Execution Environment
FAULT_9025,// Diployment Unit to Execution environment mismatch
FAULT_9026,// Duplicate Deployment Unit
FAULT_9027,// System Ressources Exceeded
FAULT_9028,// Unknown Deployment Unit
FAULT_9029,// Invalid Deployment Unit State
FAULT_9030,// Invalid Deployment Unit Update: Downgrade not permitted
FAULT_9031,// Invalid Deployment Unit Update: Version not specified
FAULT_9032,// Invalid Deployment Unit Update: Version already exist
__FAULT_MAX
};
#ifdef BBF_TR064
enum upnp_fault_code_enum {
FAULT_UPNP_606 = 606,// Action not authorized
FAULT_UPNP_701 = 701,// Invalid Argument Syntax
FAULT_UPNP_702,//Invalid XML Argument
FAULT_UPNP_703,// No Such Name
FAULT_UPNP_704,// Invalid Value Type
FAULT_UPNP_705,// Invalid Value
FAULT_UPNP_706,// Read Only Violation
FAULT_UPNP_707,// Multiple Set
FAULT_UPNP_708,// Resource Temporarily Unavailable
__FAULT_UPNP_MAX
};
#endif
enum {
INSTANCE_UPDATE_NUMBER,
INSTANCE_UPDATE_ALIAS
};
enum instance_mode {
INSTANCE_MODE_NUMBER,
INSTANCE_MODE_ALIAS
};
enum end_session_enum {
END_SESSION_REBOOT = 1,
END_SESSION_EXTERNAL_ACTION = 1<<1,
END_SESSION_RELOAD = 1<<2,
END_SESSION_FACTORY_RESET = 1<<3,
END_SESSION_IPPING_DIAGNOSTIC = 1<<4,
END_SESSION_DOWNLOAD_DIAGNOSTIC = 1<<5,
END_SESSION_UPLOAD_DIAGNOSTIC = 1<<6,
END_SESSION_X_FACTORY_RESET_SOFT = 1<<7,
END_SESSION_NSLOOKUP_DIAGNOSTIC = 1<<8,
END_SESSION_TRACEROUTE_DIAGNOSTIC = 1<<9,
END_SESSION_UDPECHO_DIAGNOSTIC = 1<<10,
END_SESSION_SERVERSELECTION_DIAGNOSTIC = 1<<11
};
enum dm_browse_enum {
DM_ERROR = -1,
DM_OK = 0,
DM_STOP = 1
};
enum dmt_type_enum {
DMT_STRING,
DMT_UNINT,
DMT_INT,
DMT_LONG,
DMT_BOOL,
DMT_TIME,
DMT_HEXBIN,
};
enum amd_version_enum{
AMD_1 = 1,
AMD_2,
AMD_3,
AMD_4,
AMD_5,
};
enum dm_type_enum{
DM_CWMP,
DM_UPNP,
};
enum bbfdm_type_enum{
BBFDM_BOTH,
BBFDM_CWMP,
BBFDM_USP,
};
enum dm_param_flags_enum{
/* UPNP OnChange flags flags */
DM_PARAM_ALARAM_ON_CHANGE = 1 << 0,
DM_PARAM_EVENT_ON_CHANGE = 1 << 1,
/* UPNP type flags */
NODE_DATA_ATTRIBUTE_INSTANCE = 0x0010,
NODE_DATA_ATTRIBUTE_MULTIINSTANCE = 0x0020,
NODE_DATA_ATTRIBUTE_TYPESTRING = 0x0100,
NODE_DATA_ATTRIBUTE_TYPEINT = 0x0200,
NODE_DATA_ATTRIBUTE_TYPELONG = 0x0400,
NODE_DATA_ATTRIBUTE_TYPEBOOL = 0x0800,
NODE_DATA_ATTRIBUTE_TYPEDATETIME = 0x1000,
NODE_DATA_ATTRIBUTE_TYPEBASE64 = 0x2000,
NODE_DATA_ATTRIBUTE_TYPEBIN = 0x4000,
NODE_DATA_ATTRIBUTE_TYPEPTR = 0x8000,
NODE_DATA_ATTRIBUTE_TYPEMASK = 0x0000FF00,
/*ACLRoles*/
DM_PUBLIC_LIST = 1 << 0,
DM_PUBLIC_READ = 1 << 1,
DM_PUBLIC_WRITE = 1 << 2,
DM_PUBLIC_MASK = DM_PUBLIC_LIST|DM_PUBLIC_READ|DM_PUBLIC_WRITE,
DM_BASIC_LIST = 1 << 3,
DM_BASIC_READ = 1 << 4,
DM_BASIC_WRITE = 1 << 5,
DM_BASIC_MASK = DM_PUBLIC_MASK|DM_BASIC_LIST|DM_BASIC_READ|DM_BASIC_WRITE,
DM_XXXADMIN_LIST = 1 << 6,
DM_XXXADMIN_READ = 1 << 7,
DM_XXXADMIN_WRITE = 1 << 8,
DM_XXXADMIN_MASK = DM_BASIC_MASK|DM_XXXADMIN_LIST|DM_XXXADMIN_READ|DM_XXXADMIN_WRITE,
DM_SUPERADMIN_MASK = DM_XXXADMIN_MASK | (1 << 9),
DM_LIST_MASK = DM_PUBLIC_LIST|DM_BASIC_LIST|DM_XXXADMIN_LIST,
DM_READ_MASK = DM_PUBLIC_READ|DM_BASIC_READ|DM_XXXADMIN_READ,
DM_WRITE_MASK = DM_PUBLIC_WRITE|DM_BASIC_WRITE|DM_XXXADMIN_WRITE,
DM_FACTORIZED = 1 << 31
};
extern struct list_head list_enabled_notify;
extern struct list_head list_enabled_lw_notify;
extern struct list_head list_execute_end_session;
#ifdef BBF_TR064
extern struct list_head list_upnp_enabled_onevent;
extern struct list_head list_upnp_enabled_onalarm;
extern struct list_head list_upnp_enabled_version;
extern struct list_head list_upnp_changed_onevent;
extern struct list_head list_upnp_changed_onalarm;
extern struct list_head list_upnp_changed_version;
#endif
extern int end_session_flag;
extern int ip_version;
extern char dm_delim;
extern char dmroot[64];
extern int bbfdatamodel_type;
extern unsigned int upnp_in_user_mask;
char *update_instance(struct uci_section *s, char *last_inst, char *inst_opt);
char *update_instance_icwmpd(struct uci_section *s, char *last_inst, char *inst_opt);
char *update_instance_alias_icwmpd(int action, char **last_inst , void *argv[]);
char *update_instance_alias(int action, char **last_inst , void *argv[]);
char *update_instance_without_section(int action, char **last_inst, void *argv[]);
int get_empty(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
void add_list_paramameter(struct dmctx *ctx, char *param_name, char *param_data, char *param_type, char *param_version, unsigned int flags);
void del_list_parameter(struct dm_parameter *dm_parameter);
void free_all_list_parameter(struct dmctx *ctx);
void add_set_list_tmp(struct dmctx *ctx, char *param, char *value, unsigned int flags);
void del_set_list_tmp(struct set_tmp *set_tmp);
void free_all_set_list_tmp(struct dmctx *ctx);
void add_list_fault_param(struct dmctx *ctx, char *param, int fault);
void del_list_fault_param(struct param_fault *param_fault);
void free_all_list_fault_param(struct dmctx *ctx);
int string_to_bool(char *v, bool *b);
int dm_entry_operate(struct dmctx *dmctx);
int dm_entry_get_value(struct dmctx *ctx);
int dm_entry_get_name(struct dmctx *ctx);
int dm_entry_get_notification(struct dmctx *ctx);
int dm_entry_inform(struct dmctx *ctx);
int dm_entry_add_object(struct dmctx *ctx);
int dm_entry_delete_object(struct dmctx *ctx);
int dm_entry_set_value(struct dmctx *ctx);
int dm_entry_set_notification(struct dmctx *ctx);
int dm_entry_enabled_notify(struct dmctx *ctx);
int dm_entry_enabled_notify_check_value_change(struct dmctx *dmctx);
int dm_entry_get_linker(struct dmctx *ctx);
int dm_entry_get_linker_value(struct dmctx *ctx);
#ifdef BBF_TR064
int dm_entry_upnp_get_instances(struct dmctx *ctx);
int dm_entry_upnp_get_selected_values(struct dmctx *dmctx);
int dm_entry_upnp_get_values(struct dmctx *dmctx);
int dm_entry_upnp_set_values(struct dmctx *dmctx);
int dm_entry_upnp_get_attributes(struct dmctx *dmctx);
int upnp_state_variables_init(struct dmctx *dmctx);
int dm_entry_upnp_tracked_parameters(struct dmctx *dmctx);
int dm_entry_upnp_get_instance_numbers(struct dmctx *dmctx);
char *dm_entry_get_all_instance_numbers(struct dmctx *pctx, char *param);
void free_all_list_enabled_notify();
void free_all_list_upnp_param_track(struct list_head *head);
#endif
void dm_update_enabled_notify(struct dm_enabled_notify *p, char *new_value);
int dm_update_file_enabled_notify(char *param, char *new_value);
void dm_update_enabled_notify_byname(char *name, char *new_value);
char *get_last_instance(char *package, char *section, char *opt_inst);
char *get_last_instance_icwmpd_without_update(char *package, char *section, char *opt_inst);
char *get_last_instance_icwmpd(char *package, char *section, char *opt_inst);
char *get_vlan_last_instance_icwmpd(char *package, char *section, char *opt_inst, char *vlan_method);
char *get_last_instance_lev2(char *package, char *section, char *opt_inst, char *opt_check, char *value_check);
char *get_last_instance_lev2_icwmpd_dmmap_opt(char* dmmap_package, char *section, char *opt_inst, char *opt_check, char *value_check);
char *get_last_instance_lev2_icwmpd(char *package, char *section, char* dmmap_package, char *opt_inst, char *opt_check, char *value_check);
char *handle_update_instance(int instance_ranck, struct dmctx *ctx, char **last_inst, char * (*up_instance)(int action, char **last_inst, void *argv[]), int argc, ...);
int dm_add_end_session(struct dmctx *ctx, void(*function)(struct execute_end_session *), int action, void *data);
int apply_end_session();
void cwmp_set_end_session (unsigned int flag);
char *dm_print_path(char *fpath, ...);
void free_all_list_enabled_lwnotify();
int dm_link_inst_obj(struct dmctx *dmctx, DMNODE *parent_node, void *data, char *instance);
#ifdef BBF_TR064
void dm_upnp_apply_config(void);
void add_list_upnp_param_track(struct dmctx *dmctx, struct list_head *pchead, char *param, char *key, char *value, unsigned int isobj);
int dm_link_inst_obj(struct dmctx *dmctx, DMNODE *parent_node, void *data, char *instance);
int dm_entry_upnp_get_supported_parameters(struct dmctx *dmctx);
int dm_entry_upnp_set_attributes(struct dmctx *dmctx);
int dm_entry_upnp_delete_instance(struct dmctx *dmctx);
int dm_entry_upnp_get_acl_data(struct dmctx *dmctx);
void free_all_list_enabled_lwnotify();
int dm_entry_upnp_add_instance(struct dmctx *dmctx);
#endif
static inline int DM_LINK_INST_OBJ(struct dmctx *dmctx, DMNODE *parent_node, void *data, char *instance)
{
dmctx->faultcode = dm_link_inst_obj(dmctx, parent_node, data, instance);
if (dmctx->stop)
return DM_STOP;
return DM_OK;
}
#ifndef TRACE
#define TRACE_TYPE 0
static inline void trace_empty_func()
{
}
#if TRACE_TYPE == 2
#define TRACE(MESSAGE,args...) do { \
const char *A[] = {MESSAGE}; \
fprintf(stderr, "TRACE: %s %s %d ",__FUNCTION__,__FILE__,__LINE__); \
if(sizeof(A) > 0) \
fprintf(stderr, *A,##args); \
fprintf(stderr, "\n"); \
fflush(stderr); \
} while(0)
#elif TRACE_TYPE == 1
#define TRACE(MESSAGE, ...) printf(MESSAGE, ## __VA_ARGS__)
#else
#define TRACE(MESSAGE, ...) trace_empty_func()
#endif
#endif
#ifndef DETECT_CRASH
#define DETECT_CRASH(MESSAGE,args...) { \
const char *A[] = {MESSAGE}; \
printf("DETECT_CRASH: %s %s %d\n",__FUNCTION__,__FILE__,__LINE__); fflush(stdout);\
if(sizeof(A) > 0) \
printf(*A,##args); \
sleep(1); \
}
#endif
#endif

656
dmdiagnostics.c Normal file
View file

@ -0,0 +1,656 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*
*/
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <pthread.h>
#include <signal.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <arpa/inet.h>
#include <libtrace.h>
#include <libpacketdump.h>
#include <inttypes.h>
#include <assert.h>
#include <getopt.h>
#include "dmentry.h"
#include "dmcommon.h"
#include "dmdiagnostics.h"
int read_next;
struct download_diag download_stats = {0};
struct upload_diagnostic_stats upload_stats = {0};
char *get_param_diagnostics(char *diag, char *option)
{
char buf[32], *value;
sprintf(buf, "@%s[0]", diag);
dmuci_get_varstate_string("cwmp", buf, option, &value);
return value;
}
void set_param_diagnostics(char *diag, char *option, char *value)
{
struct uci_section *curr_section = NULL;
char buf[32], *tmp;
curr_section = dmuci_walk_state_section("cwmp", diag, NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
if(!curr_section)
{
dmuci_add_state_section("cwmp", diag, &curr_section, &tmp);
}
sprintf(buf, "@%s[0]", diag);
dmuci_set_varstate_value("cwmp", buf, option, value);
}
void init_download_stats(void)
{
memset(&download_stats, 0, sizeof(download_stats));
}
void init_upload_stats(void)
{
memset(&upload_stats, 0, sizeof(upload_stats));
}
static void ftp_download_per_packet(libtrace_packet_t *packet)
{
struct tm lt;
struct timeval ts;
libtrace_tcp_t *tcp;
char tcp_flag[16] = "";
char *nexthdr;
char s_now[default_date_size];
uint8_t proto;
uint32_t remaining;
tcp = trace_get_transport(packet, &proto, &remaining);
if (tcp == NULL)
return;
else
nexthdr = trace_get_payload_from_tcp(tcp, &remaining);
if (tcp->ecn_ns) strcat(tcp_flag, "ECN_NS ");
if (tcp->cwr) strcat(tcp_flag, "CWR ");
if (tcp->ece) strcat(tcp_flag, "ECE ");
if (tcp->fin) strcat(tcp_flag, "FIN ");
if (tcp->syn) strcat(tcp_flag, "SYN ");
if (tcp->rst) strcat(tcp_flag, "RST ");
if (tcp->psh) strcat(tcp_flag, "PSH ");
if (tcp->ack) strcat(tcp_flag, "ACK ");
if (tcp->urg) strcat(tcp_flag, "URG ");
if (strcmp(tcp_flag, "PSH ACK ") == 0 && strlen(nexthdr) > strlen(FTP_SIZE_RESPONSE) && strncmp(nexthdr, FTP_SIZE_RESPONSE, strlen(FTP_SIZE_RESPONSE)) == 0)
{
char *val = strstr(nexthdr,"213");
char *pch, *pchr;
val += strlen("213 ");
pch=strtok_r(val, " \r\n\t", &pchr);
download_stats.test_bytes_received = atoi(pch);
}
if(strcmp(tcp_flag, "PSH ACK ") == 0 && strlen(nexthdr) > strlen(FTP_PASV_RESPONSE) && strncmp(nexthdr, FTP_PASV_RESPONSE, strlen(FTP_PASV_RESPONSE)) == 0)
{
download_stats.ftp_syn = 1;
return;
}
if (download_stats.random_seq == 0 && strcmp(tcp_flag, "SYN ") == 0 && download_stats.ftp_syn == 1)
{
ts = trace_get_timeval(packet);
(void) localtime_r(&(ts.tv_sec), &lt);
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", &lt);
download_stats.random_seq = ntohl(tcp->seq);
sprintf((download_stats.tcpopenrequesttime),"%s.%06ld", s_now, (long) ts.tv_usec);
}
if (strcmp(tcp_flag, "SYN ACK ") == 0 && download_stats.random_seq != 0 && (ntohl(tcp->ack_seq) - 1 ) == download_stats.random_seq)
{
ts = trace_get_timeval(packet);
(void) localtime_r(&(ts.tv_sec), &lt);
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", &lt);
sprintf((download_stats.tcpopenresponsetime),"%s.%06ld", s_now, (long) ts.tv_usec);
download_stats.random_seq = ntohl(tcp->ack_seq);
sprintf((download_stats.tcpopenresponsetime),"%s.%06ld", s_now, (long) ts.tv_usec);
}
if (strcmp(tcp_flag, "PSH ACK ") == 0 && strlen(nexthdr) > strlen(FTP_RETR_REQUEST) && strncmp(nexthdr, FTP_RETR_REQUEST, strlen(FTP_RETR_REQUEST)) == 0)
{
ts = trace_get_timeval(packet);
(void) localtime_r(&(ts.tv_sec), &lt);
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", &lt);
sprintf((download_stats.romtime),"%s.%06ld", s_now, (long) ts.tv_usec);
}
if(strcmp(tcp_flag, "ACK ") == 0 && ntohl(tcp->seq) == download_stats.random_seq && download_stats.ack_seq == 0)
{
download_stats.ack_seq = ntohl(tcp->seq);
return;
}
if(strcmp(tcp_flag, "ACK ") == 0 && ntohl(tcp->ack_seq) == download_stats.ack_seq )
{
ts = trace_get_timeval(packet);
(void) localtime_r(&(ts.tv_sec), &lt);
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", &lt);
if (download_stats.first_data == 0)
{
sprintf((download_stats.bomtime),"%s.%06ld", s_now, (long) ts.tv_usec);
}
download_stats.first_data = 1;
}
if ( (strcmp(tcp_flag, "PSH ACK ") == 0 || strcmp(tcp_flag, "FIN PSH ACK ") == 0) && ntohl(tcp->ack_seq) == download_stats.ack_seq)
{
ts = trace_get_timeval(packet);
(void) localtime_r(&(ts.tv_sec), &lt);
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", &lt);
if (download_stats.first_data == 0)
{
sprintf((download_stats.bomtime),"%s.%06ld", s_now, (long) ts.tv_usec);
download_stats.first_data = 1;
}
sprintf((download_stats.eomtime),"%s.%06ld", s_now, (long) ts.tv_usec);
}
}
static void http_download_per_packet(libtrace_packet_t *packet)
{
struct tm lt;
struct timeval ts;
libtrace_tcp_t *tcp;
uint32_t seq = 0;
char tcp_flag[16] = "";
char *nexthdr;
char s_now[default_date_size];
uint8_t proto;
uint32_t remaining;
tcp = trace_get_transport(packet, &proto, &remaining);
if (tcp == NULL)
return;
else
nexthdr = trace_get_payload_from_tcp(tcp, &remaining);
if (tcp->ecn_ns) strcat(tcp_flag, "ECN_NS ");
if (tcp->cwr) strcat(tcp_flag, "CWR ");
if (tcp->ece) strcat(tcp_flag, "ECE ");
if (tcp->fin) strcat(tcp_flag, "FIN ");
if (tcp->syn) strcat(tcp_flag, "SYN ");
if (tcp->rst) strcat(tcp_flag, "RST ");
if (tcp->psh) strcat(tcp_flag, "PSH ");
if (tcp->ack) strcat(tcp_flag, "ACK ");
if (tcp->urg) strcat(tcp_flag, "URG ");
if (strcmp(tcp_flag, "SYN ") == 0 && download_stats.random_seq == 0)
{
ts = trace_get_timeval(packet);
(void) localtime_r(&(ts.tv_sec), &lt);
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", &lt);
sprintf((download_stats.tcpopenrequesttime),"%s.%06ld", s_now, (long) ts.tv_usec);
download_stats.random_seq = ntohl(tcp->seq);
return;
}
if (strcmp(tcp_flag, "SYN ACK ") == 0 && download_stats.random_seq != 0 && (ntohl(tcp->ack_seq) - 1 ) == download_stats.random_seq)
{
ts = trace_get_timeval(packet);
(void) localtime_r(&(ts.tv_sec), &lt);
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", &lt);
sprintf((download_stats.tcpopenresponsetime),"%s.%06ld", s_now, (long) ts.tv_usec);
download_stats.random_seq = ntohl(tcp->seq);
return;
}
if (strcmp(tcp_flag, "PSH ACK ") == 0 && strncmp(nexthdr, "GET", 3) == 0)
{
ts = trace_get_timeval(packet);
(void) localtime_r(&(ts.tv_sec), &lt);
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", &lt);
sprintf((download_stats.romtime),"%s.%06ld", s_now, (long) ts.tv_usec);
download_stats.get_ack = ntohl(tcp->ack_seq);
return;
}
if(strcmp(tcp_flag, "ACK ") == 0 && ntohl(tcp->seq) == download_stats.get_ack && download_stats.ack_seq == 0)
{
download_stats.ack_seq = ntohl(tcp->ack_seq);
return;
}
if(strcmp(tcp_flag, "ACK ") == 0 && ntohl(tcp->ack_seq) == download_stats.ack_seq )
{
ts = trace_get_timeval(packet);
(void) localtime_r(&(ts.tv_sec), &lt);
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", &lt);
if (download_stats.first_data == 0)
{
sprintf((download_stats.bomtime),"%s.%06ld", s_now, (long) ts.tv_usec);
char *val = strstr(nexthdr,"Content-Length");
char *pch, *pchr;
val += strlen("Content-Length: ");
pch=strtok_r(val, " \r\n\t", &pchr);
download_stats.test_bytes_received = atoi(pch);
download_stats.first_data = 1;
}
return;
}
if ( (strcmp(tcp_flag, "PSH ACK ") == 0 || strcmp(tcp_flag, "FIN PSH ACK ") == 0) && ntohl(tcp->ack_seq) == download_stats.ack_seq)
{
ts = trace_get_timeval(packet);
(void) localtime_r(&(ts.tv_sec), &lt);
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", &lt);
if (download_stats.first_data == 0)
{
sprintf((download_stats.bomtime),"%s.%06ld", s_now, (long) ts.tv_usec);
char *val = strstr(nexthdr,"Content-Length");
char *pch, *pchr;
val += strlen("Content-Length: ");
pch=strtok_r(val, " \r\n\t", &pchr);
download_stats.test_bytes_received = atoi(pch);
download_stats.first_data = 1;
}
sprintf((download_stats.eomtime),"%s.%06ld", s_now, (long) ts.tv_usec);
return;
}
}
static void libtrace_cleanup(libtrace_t *trace, libtrace_packet_t *packet)
{
if (trace)
trace_destroy(trace);
if (packet)
trace_destroy_packet(packet);
}
static void set_download_stats(char *protocol)
{
char buf[16];
if(strcmp(protocol, "cwmp")== 0)
init_uci_varstate_ctx();
set_param_diagnostics("downloaddiagnostic", "ROMtime", download_stats.romtime);
set_param_diagnostics("downloaddiagnostic", "BOMtime", download_stats.bomtime);
set_param_diagnostics("downloaddiagnostic", "EOMtime", download_stats.eomtime);
set_param_diagnostics("downloaddiagnostic", "TCPOpenRequestTimes", download_stats.tcpopenrequesttime);
set_param_diagnostics("downloaddiagnostic", "TCPOpenResponseTime", download_stats.tcpopenresponsetime);
sprintf(buf,"%d", download_stats.test_bytes_received);
set_param_diagnostics("downloaddiagnostic", "TestBytesReceived", buf);
if(strcmp(protocol, "cwmp")== 0)
end_uci_varstate_ctx();
}
static void set_upload_stats(char *protocol)
{
if(strcmp(protocol, "cwmp")== 0)
init_uci_varstate_ctx();
set_param_diagnostics("uploaddiagnostic", "ROMtime", upload_stats.romtime);
set_param_diagnostics("uploaddiagnostic", "BOMtime", upload_stats.bomtime);
set_param_diagnostics("uploaddiagnostic", "EOMtime", upload_stats.eomtime);
set_param_diagnostics("uploaddiagnostic", "TCPOpenRequestTimes", upload_stats.tcpopenrequesttime);
set_param_diagnostics("uploaddiagnostic", "TCPOpenResponseTime", upload_stats.tcpopenresponsetime);
if(strcmp(protocol, "cwmp")== 0)
end_uci_varstate_ctx();
}
static void http_upload_per_packet(libtrace_packet_t *packet)
{
struct tm lt;
struct timeval ts;
libtrace_tcp_t *tcp;
char tcp_flag[16] = "";
char *nexthdr;
char s_now[default_date_size];
uint8_t proto;
uint32_t remaining;
tcp = trace_get_transport(packet, &proto, &remaining);
if (tcp == NULL)
return;
else
nexthdr = trace_get_payload_from_tcp(tcp, &remaining);
if (tcp->ecn_ns) strcat(tcp_flag, "ECN_NS ");
if (tcp->cwr) strcat(tcp_flag, "CWR ");
if (tcp->ece) strcat(tcp_flag, "ECE ");
if (tcp->fin) strcat(tcp_flag, "FIN ");
if (tcp->syn) strcat(tcp_flag, "SYN ");
if (tcp->rst) strcat(tcp_flag, "RST ");
if (tcp->psh) strcat(tcp_flag, "PSH ");
if (tcp->ack) strcat(tcp_flag, "ACK ");
if (tcp->urg) strcat(tcp_flag, "URG ");
if (strcmp(tcp_flag, "SYN ") == 0 && download_stats.random_seq == 0)
{
ts = trace_get_timeval(packet);
(void) localtime_r(&(ts.tv_sec), &lt);
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", &lt);
sprintf((upload_stats.tcpopenrequesttime),"%s.%06ld", s_now, (long) ts.tv_usec);
upload_stats.random_seq = ntohl(tcp->seq);
}
if (strcmp(tcp_flag, "SYN ACK ") == 0 && upload_stats.random_seq != 0 && (ntohl(tcp->ack_seq) - 1 ) == upload_stats.random_seq)
{
ts = trace_get_timeval(packet);
(void) localtime_r(&(ts.tv_sec), &lt);
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", &lt);
sprintf((upload_stats.tcpopenresponsetime),"%s.%06ld", s_now, (long) ts.tv_usec);
upload_stats.random_seq = ntohl(tcp->seq);
}
if (strcmp(tcp_flag, "PSH ACK ") == 0 && strncmp(nexthdr, "PUT", 3) == 0)
{
ts = trace_get_timeval(packet);
(void) localtime_r(&(ts.tv_sec), &lt);
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", &lt);
sprintf((upload_stats.romtime),"%s.%06ld", s_now, (long) ts.tv_usec);
if (strstr(nexthdr, "Expect: 100-continue"))
{
upload_stats.tmp=1;
upload_stats.ack_seq = ntohl(tcp->ack_seq);
}
else
upload_stats.ack_seq = ntohl(tcp->ack_seq);
return;
}
if (strcmp(tcp_flag, "PSH ACK ") == 0 && upload_stats.tmp == 1 && strstr(nexthdr, "100 Continue"))
{
upload_stats.tmp = 2;
upload_stats.ack_seq = ntohl(tcp->ack_seq);
return;
}
if (strcmp(tcp_flag, "ACK ") == 0 && upload_stats.tmp == 2 && ntohl(tcp->seq) == upload_stats.ack_seq)
{
upload_stats.tmp = 0;
upload_stats.ack_seq = ntohl(tcp->ack_seq);
return;
}
if(strcmp(tcp_flag, "ACK ") == 0 && ntohl(tcp->ack_seq) == upload_stats.ack_seq && upload_stats.tmp == 0)
{
ts = trace_get_timeval(packet);
(void) localtime_r(&(ts.tv_sec), &lt);
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", &lt);
if (upload_stats.first_data == 0)
{
sprintf((upload_stats.bomtime),"%s.%06ld", s_now, (long) ts.tv_usec);
upload_stats.first_data = 1;
}
}
if ( (strcmp(tcp_flag, "PSH ACK ") == 0 || strcmp(tcp_flag, "FIN PSH ACK ") == 0) && ntohl(tcp->ack_seq) == upload_stats.ack_seq && upload_stats.tmp == 0)
{
ts = trace_get_timeval(packet);
(void) localtime_r(&(ts.tv_sec), &lt);
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", &lt);
if (upload_stats.first_data == 0)
{
sprintf((upload_stats.bomtime),"%s.%06ld", s_now, (long) ts.tv_usec);
upload_stats.first_data = 1;
}
}
if ( (strcmp(tcp_flag, "PSH ACK ") == 0 || strcmp(tcp_flag, "FIN PSH ACK ") == 0) && ntohl(tcp->seq) == upload_stats.ack_seq && upload_stats.tmp == 0)
{
ts = trace_get_timeval(packet);
(void) localtime_r(&(ts.tv_sec), &lt);
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", &lt);
sprintf((upload_stats.eomtime),"%s.%06ld", s_now, (long) ts.tv_usec);
}
}
static void ftp_upload_per_packet(libtrace_packet_t *packet)
{
struct tm lt;
struct timeval ts;
libtrace_tcp_t *tcp;
uint8_t proto;
uint32_t remaining;
char tcp_flag[16] = "";
char *nexthdr;
char s_now[default_date_size];
tcp = trace_get_transport(packet, &proto, &remaining);
if (tcp == NULL)
return;
else
nexthdr = trace_get_payload_from_tcp(tcp, &remaining);
if (tcp->ecn_ns) strcat(tcp_flag, "ECN_NS ");
if (tcp->cwr) strcat(tcp_flag, "CWR ");
if (tcp->ece) strcat(tcp_flag, "ECE ");
if (tcp->fin) strcat(tcp_flag, "FIN ");
if (tcp->syn) strcat(tcp_flag, "SYN ");
if (tcp->rst) strcat(tcp_flag, "RST ");
if (tcp->psh) strcat(tcp_flag, "PSH ");
if (tcp->ack) strcat(tcp_flag, "ACK ");
if (tcp->urg) strcat(tcp_flag, "URG ");
if(strcmp(tcp_flag, "PSH ACK ") == 0 && strlen(nexthdr) > strlen(FTP_PASV_RESPONSE) && strncmp(nexthdr, FTP_PASV_RESPONSE, strlen(FTP_PASV_RESPONSE)) == 0)
{
upload_stats.ftp_syn = 1;
return;
}
if (strcmp(tcp_flag, "SYN ") == 0 && upload_stats.ftp_syn == 1)
{
ts = trace_get_timeval(packet);
(void) localtime_r(&(ts.tv_sec), &lt);
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", &lt);
upload_stats.random_seq = ntohl(tcp->seq);
sprintf((upload_stats.tcpopenrequesttime),"%s.%06ld", s_now, (long) ts.tv_usec);
}
if (strcmp(tcp_flag, "SYN ACK ") == 0 && upload_stats.random_seq != 0 && (ntohl(tcp->ack_seq) - 1 ) == upload_stats.random_seq)
{
ts = trace_get_timeval(packet);
(void) localtime_r(&(ts.tv_sec), &lt);
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", &lt);
sprintf((upload_stats.tcpopenresponsetime),"%s.%06ld", s_now, (long) ts.tv_usec);
upload_stats.random_seq = ntohl(tcp->ack_seq);
}
if (strcmp(tcp_flag, "PSH ACK ") == 0 && strlen(nexthdr) > strlen(FTP_STOR_REQUEST) && strncmp(nexthdr, FTP_STOR_REQUEST, strlen(FTP_STOR_REQUEST)) == 0)
{
ts = trace_get_timeval(packet);
(void) localtime_r(&(ts.tv_sec), &lt);
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", &lt);
sprintf((upload_stats.romtime),"%s.%06ld", s_now, (long) ts.tv_usec);
}
if(strcmp(tcp_flag, "ACK ") == 0 && ntohl(tcp->seq) == upload_stats.random_seq && upload_stats.ack_seq == 0)
{
upload_stats.ack_seq = ntohl(tcp->ack_seq);
return;
}
if(strcmp(tcp_flag, "ACK ") == 0 && ntohl(tcp->ack_seq) == upload_stats.ack_seq )
{
ts = trace_get_timeval(packet);
(void) localtime_r(&(ts.tv_sec), &lt);
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", &lt);
if (upload_stats.first_data == 0)
{
sprintf((upload_stats.bomtime),"%s.%06ld", s_now, (long) ts.tv_usec);
upload_stats.first_data = 1;
}
}
if ( (strcmp(tcp_flag, "PSH ACK ") == 0 || strcmp(tcp_flag, "FIN PSH ACK ") == 0) && ntohl(tcp->ack_seq) == upload_stats.ack_seq) //&& strlen(nexthdr) > 16 && strncmp(nexthdr, "HTTP/1.1 200 OK", 16) == 0
{
ts = trace_get_timeval(packet);
(void) localtime_r(&(ts.tv_sec), &lt);
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", &lt);
if (upload_stats.first_data == 0)
{
sprintf((upload_stats.bomtime),"%s.%06ld", s_now, (long) ts.tv_usec);
upload_stats.first_data = 1;
}
}
if ( (strcmp(tcp_flag, "PSH ACK ") == 0 || strcmp(tcp_flag, "FIN PSH ACK ") == 0) && strlen(nexthdr) > strlen(FTP_TRANSFERT_COMPLETE) && strncmp(nexthdr, FTP_TRANSFERT_COMPLETE, strlen(FTP_TRANSFERT_COMPLETE)) == 0) //&& strlen(nexthdr) > 16 && strncmp(nexthdr, "HTTP/1.1 200 OK", 16) == 0
{
ts = trace_get_timeval(packet);
(void) localtime_r(&(ts.tv_sec), &lt);
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", &lt);
sprintf((upload_stats.eomtime),"%s.%06ld", s_now, (long) ts.tv_usec);
read_next = 0;
}
}
int extract_stats(char *dump_file, int proto, int diagnostic_type, char *protocol)
{
libtrace_t *trace = NULL;
libtrace_packet_t *packet = NULL;
read_next = 1;
packet = trace_create_packet();
if (packet == NULL) {
perror("Creating libtrace packet");
libtrace_cleanup(trace, packet);
return 1;
}
trace = trace_create(dump_file);
if (!trace) {
return -1;
}
if (trace_is_err(trace)) {
trace_perror(trace,"Opening trace file");
libtrace_cleanup(trace, packet);
return 1;
}
if (trace_start(trace) == -1) {
trace_perror(trace,"Starting trace");
libtrace_cleanup(trace, packet);
return 1;
}
if (proto == DOWNLOAD_DIAGNOSTIC_HTTP && diagnostic_type == DOWNLOAD_DIAGNOSTIC)
{
while (trace_read_packet(trace,packet)>0 && read_next == 1) {
http_download_per_packet(packet);
continue;
}
set_download_stats(protocol);
}
else if (proto == DOWNLOAD_DIAGNOSTIC_FTP && diagnostic_type == DOWNLOAD_DIAGNOSTIC)
{
while (trace_read_packet(trace,packet)>0 && read_next == 1) {
ftp_download_per_packet(packet);
continue;
}
set_download_stats(protocol);
}
else if (proto == DOWNLOAD_DIAGNOSTIC_HTTP && diagnostic_type == UPLOAD_DIAGNOSTIC)
{
while (trace_read_packet(trace,packet)>0 && read_next == 1) {
http_upload_per_packet(packet);
continue;
}
set_upload_stats(protocol);
}
else
{
while (trace_read_packet(trace,packet)>0 && read_next == 1) {
ftp_upload_per_packet(packet);
continue;
}
set_upload_stats(protocol);
}
libtrace_cleanup(trace, packet);
return 0;
}
int get_default_gateway_device( char **gw )
{
FILE *f;
char line[100], *p, *c, *saveptr;
f = fopen("/proc/net/route" , "r");
if (f != NULL)
{
while(fgets(line , 100 , f))
{
p = strtok_r(line, " \t", &saveptr);
c = strtok_r(NULL, " \t", &saveptr);
if(p!=NULL && c!=NULL)
{
if(strcmp(c, "00000000") == 0)
{
dmasprintf(gw, "%s", p);
fclose(f);
return 0;
}
}
}
fclose(f);
}
return -1;
}
int start_upload_download_diagnostic(int diagnostic_type)
{
char *url = NULL;
char *interface = NULL;
char *size = NULL;
int error;
char *status;
if (diagnostic_type == DOWNLOAD_DIAGNOSTIC) {
dmuci_get_varstate_string("cwmp", "@downloaddiagnostic[0]", "url", &url);
dmuci_get_varstate_string("cwmp", "@downloaddiagnostic[0]", "device", &interface);
}
else {
dmuci_get_varstate_string("cwmp", "@uploaddiagnostic[0]", "url", &url);
dmuci_get_varstate_string("cwmp", "@uploaddiagnostic[0]", "TestFileLength", &size);
dmuci_get_varstate_string("cwmp", "@uploaddiagnostic[0]", "device", &interface);
}
if ( interface == NULL || interface[0] == '\0' )
{
error = get_default_gateway_device(&interface);
if (error == -1)
return -1;
}
if (diagnostic_type == DOWNLOAD_DIAGNOSTIC)
{
//Free uci_varstate_ctx
end_uci_varstate_ctx();
dmcmd("/bin/sh", 5, DOWNLOAD_DIAGNOSTIC_PATH, "run", "usp", url, interface);
//Allocate uci_varstate_ctx
init_uci_varstate_ctx();
dmuci_get_varstate_string("cwmp", "@downloaddiagnostic[0]", "url", &url);
dmuci_get_varstate_string("cwmp", "@downloaddiagnostic[0]", "DiagnosticState", &status);
if (status && strcmp(status, "Completed") == 0)
{
init_download_stats();
if(strncmp(url,DOWNLOAD_UPLOAD_PROTOCOL_HTTP,strlen(DOWNLOAD_UPLOAD_PROTOCOL_HTTP)) == 0)
extract_stats(DOWNLOAD_DUMP_FILE, DOWNLOAD_DIAGNOSTIC_HTTP, DOWNLOAD_DIAGNOSTIC, "usp");
if(strncmp(url,DOWNLOAD_UPLOAD_PROTOCOL_FTP,strlen(DOWNLOAD_UPLOAD_PROTOCOL_FTP)) == 0)
extract_stats(DOWNLOAD_DUMP_FILE, DOWNLOAD_DIAGNOSTIC_FTP, DOWNLOAD_DIAGNOSTIC, "usp");
}
else if (status && strncmp(status, "Error_", strlen("Error_")) == 0)
return -1;
}
else
{
//Free uci_varstate_ctx
end_uci_varstate_ctx();
dmcmd("/bin/sh", 6, UPLOAD_DIAGNOSTIC_PATH, "run", "usp", url, interface, size);
//Allocate uci_varstate_ctx
init_uci_varstate_ctx();
dmuci_get_varstate_string("cwmp", "@uploaddiagnostic[0]", "url", &url);
dmuci_get_varstate_string("cwmp", "@uploaddiagnostic[0]", "DiagnosticState", &status);
if (status && strcmp(status, "Completed") == 0)
{
init_upload_stats();
if(strncmp(url,DOWNLOAD_UPLOAD_PROTOCOL_HTTP,strlen(DOWNLOAD_UPLOAD_PROTOCOL_HTTP)) == 0)
extract_stats(UPLOAD_DUMP_FILE, DOWNLOAD_DIAGNOSTIC_HTTP, UPLOAD_DIAGNOSTIC, "usp");
if(strncmp(url,DOWNLOAD_UPLOAD_PROTOCOL_FTP,strlen(DOWNLOAD_UPLOAD_PROTOCOL_FTP)) == 0)
extract_stats(UPLOAD_DUMP_FILE, DOWNLOAD_DIAGNOSTIC_FTP, UPLOAD_DIAGNOSTIC, "usp");
}
else if (status && strncmp(status, "Error_", strlen("Error_")) == 0)
return -1;
}
return 0;
}

79
dmdiagnostics.h Normal file
View file

@ -0,0 +1,79 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*
*/
#ifndef __DMDIAGNOSTICS_H__
#define __DMDIAGNOSTICS_H__
#define DOWNLOAD_UPLOAD_PROTOCOL_HTTP "http://"
#define DOWNLOAD_UPLOAD_PROTOCOL_FTP "ftp://"
#define default_date_format "AAAA-MM-JJTHH:MM:SS.000000Z"
#define default_date_size sizeof(default_date_format) + 1
#define FTP_SIZE_RESPONSE "213"
#define FTP_PASV_RESPONSE "227 Entering Passive"
#define FTP_TRANSFERT_COMPLETE "226 Transfer"
#define FTP_RETR_REQUEST "RETR"
#define FTP_STOR_REQUEST "STOR"
struct download_diag
{
char romtime[default_date_size];
char bomtime[default_date_size];
char eomtime[default_date_size];
int test_bytes_received;
unsigned long total_bytes_received;
char tcpopenrequesttime[default_date_size];
char tcpopenresponsetime[default_date_size];
int tmp;
int first_data;
uint16_t ip_len;
uint32_t ack_seq;
uint32_t random_seq;
uint32_t get_ack;
uint32_t ftp_syn;
};
struct upload_diagnostic_stats
{
char romtime[default_date_size];
char bomtime[default_date_size];
char eomtime[default_date_size];
unsigned long total_bytes_sent;
char tcpopenrequesttime[default_date_size];
char tcpopenresponsetime[default_date_size];
int tmp;
int first_data;
uint16_t ip_len;
uint32_t ack_seq;
uint32_t random_seq;
uint32_t get_ack;
uint32_t ftp_syn;
};
enum download_diagnostic_protocol {
DOWNLOAD_DIAGNOSTIC_HTTP = 1,
DOWNLOAD_DIAGNOSTIC_FTP
};
enum diagnostic_type {
DOWNLOAD_DIAGNOSTIC = 1,
UPLOAD_DIAGNOSTIC
};
char *get_param_diagnostics(char *diag, char *option);
void set_param_diagnostics(char *diag, char *option, char *value);
void init_download_stats(void);
void init_upload_stats(void);
int extract_stats(char *dump_file, int proto, int diagnostic_type, char *protocol);
int get_default_gateway_device( char **gw );
int start_upload_download_diagnostic(int diagnostic_type);
#endif

1989
dmentry.c Normal file

File diff suppressed because it is too large Load diff

77
dmentry.h Normal file
View file

@ -0,0 +1,77 @@
#ifndef __DMENTRY_H__
#define __DMENTRY_H__
#include "dmcwmp.h"
extern struct list_head head_package_change;
extern unsigned char dmcli_timetrack;
extern unsigned char dmcli_evaluatetest;
enum ctx_init_enum {
CTX_INIT_ALL,
CTX_INIT_SUB
};
int dm_ctx_init(struct dmctx *ctx, unsigned int dm_type, unsigned int amd_version, unsigned int instance_mode);
int dm_ctx_init_sub(struct dmctx *ctx, unsigned int dm_type, unsigned int amd_version, unsigned int instance_mode);
int dm_entry_param_method(struct dmctx *ctx, int cmd, char *inparam, char *arg1, char *arg2);
int dm_entry_apply(struct dmctx *ctx, int cmd, char *arg1, char *arg2);
int dm_entry_load_enabled_notify(unsigned int dm_type, unsigned int amd_version, int instance_mode);
int dm_entry_reload_enabled_notify(unsigned int dm_type, unsigned int amd_version, int instance_mode);
int adm_entry_get_linker_param(struct dmctx *ctx, char *param, char *linker, char **value);
int adm_entry_get_linker_value(struct dmctx *ctx, char *param, char **value);
int dm_entry_restart_services(void);
#ifdef BBF_TR064
int dm_entry_upnp_restart_services(void);
void dm_upnp_apply_config(void);
int dm_entry_upnp_check_alarmonchange_param(struct dmctx *dmctx);
int dm_entry_upnp_check_eventonchange_param(struct dmctx *dmctx);
int dm_entry_upnp_check_versiononchange_param(struct dmctx *pctx);
int dm_entry_upnp_load_tracked_parameters(struct dmctx *dmctx);
int dm_entry_upnp_get_supported_parameters_update(struct dmctx *dmctx, char **value);
int dm_entry_upnp_get_supported_datamodel_update(struct dmctx *dmctx, char **value);
int dm_entry_upnp_get_attribute_values_update(struct dmctx *dmctx, char **value);
int dm_entry_upnp_get_configuration_update(struct dmctx *dmctx, char **value);
int dm_entry_upnp_get_current_configuration_version(struct dmctx *dmctx, char **value);
#endif
int dm_ctx_clean(struct dmctx *ctx);
int dm_ctx_clean_sub(struct dmctx *ctx);
void dm_execute_cli_shell(int argc, char** argv, unsigned int dmtype, unsigned int amd_version, unsigned int instance_mode);
void dm_execute_cli_command(char *file, unsigned int dmtype, unsigned int amd_version, unsigned int instance_mode);
void wepkey_cli(int argc, char** argv);
void dmentry_instance_lookup_inparam(struct dmctx *ctx);
#ifdef BBF_TR064
#define DM_ENTRY_UPNP_CHECK_CHANGES(ALARM, EVENT, VERSION) \
do { \
struct dmctx dmctx_chg = {0}; \
dm_ctx_init(&dmctx_chg, DM_UPNP, AMD_2, INSTANCE_MODE_NUMBER); \
ALARM = dm_entry_upnp_check_alarmonchange_param(&dmctx_chg); \
dm_ctx_clean(&dmctx_chg); \
memset(&dmctx_chg, 0, sizeof(struct dmctx)); \
dm_ctx_init(&dmctx_chg, DM_UPNP, AMD_2, INSTANCE_MODE_NUMBER); \
EVENT = dm_entry_upnp_check_eventonchange_param(&dmctx_chg); \
dm_ctx_clean(&dmctx_chg); \
memset(&dmctx_chg, 0, sizeof(struct dmctx)); \
dm_ctx_init(&dmctx_chg, DM_UPNP, AMD_2, INSTANCE_MODE_NUMBER); \
VERSION = dm_entry_upnp_check_versiononchange_param(&dmctx_chg); \
dm_ctx_clean(&dmctx_chg); \
} while(0)
#define DM_ENTRY_UPNP_FREE_ALL_CHECK_CHANGES() \
do { \
free_all_list_upnp_param_track(&list_upnp_changed_onevent); \
free_all_list_upnp_param_track(&list_upnp_changed_onalarm); \
free_all_list_upnp_param_track(&list_upnp_changed_version); \
} while(0)
#define DM_ENTRY_UPNP_LOAD_TRACKED_PARAMETERS() \
do { \
struct dmctx dmctx_trk = {0}; \
dm_ctx_init(&dmctx_trk, DM_UPNP, AMD_2, INSTANCE_MODE_NUMBER); \
dm_entry_upnp_load_tracked_parameters(&dmctx_trk); \
dm_ctx_clean(&dmctx_trk); \
} while(0)
#endif
#endif

286
dmjson.c Normal file
View file

@ -0,0 +1,286 @@
#include <stdio.h>
#include <stdlib.h>
#include <json-c/json.h>
#include <libubox/blobmsg_json.h>
#include "dmjson.h"
#include "dmmem.h"
static json_object *dmjson_jobj = NULL;
void dm_add_json_obj(json_object *json_obj_out, char *object, char *string)
{
json_object *json_obj_tmp = json_object_new_string(string);
json_object_object_add(json_obj_out, object, json_obj_tmp);
}
static void inline __dmjson_fprintf(FILE *fp, int argc, struct dmjson_arg dmarg[])
{
int i;
char *arg;
json_object *json_obj_out = json_object_new_object();
if (json_obj_out == NULL)
return;
if (argc) {
for (i = 0; i < argc; i++) {
dm_add_json_obj(json_obj_out, dmarg[i].key, dmarg[i].val);
}
arg = (char *)json_object_to_json_string(json_obj_out);
fprintf(fp, "%s\n", arg);
}
json_object_put(json_obj_out);
}
void dmjson_fprintf(FILE *fp, int argc, struct dmjson_arg dmarg[])
{
__dmjson_fprintf(fp, argc, dmarg);
}
void dmjson_parse_init(char *msg)
{
if (dmjson_jobj) {
json_object_put(dmjson_jobj);
dmjson_jobj = NULL;
}
dmjson_jobj = json_tokener_parse(msg);
}
void dmjson_parse_fini(void)
{
if (dmjson_jobj) {
json_object_put(dmjson_jobj);
dmjson_jobj = NULL;
}
}
static char *dmjson_print_value(json_object *jobj)
{
enum json_type type;
char *ret = "";
if (!jobj)
return ret;
type = json_object_get_type(jobj);
switch (type) {
case json_type_boolean:
case json_type_double:
case json_type_int:
case json_type_string:
ret = (char *)json_object_get_string(jobj);
break;
}
return ret;
}
char *____dmjson_get_value_in_obj(json_object *mainjobj, char *argv[])
{
json_object *jobj = NULL;
char *value = "";
jobj = dmjson_select_obj(mainjobj, argv);
value = dmjson_print_value(jobj);
return value;
}
char *__dmjson_get_value_in_obj(json_object *mainjobj, int argc, ...)
{
va_list arg;
char *argv[64], *v;
int i;
va_start(arg, argc);
for (i = 0; i < argc; i++)
{
argv[i] = va_arg(arg, char *);
}
argv[argc] = NULL;
va_end(arg);
v = ____dmjson_get_value_in_obj(mainjobj, argv);
return v;
}
json_object *__dmjson_get_obj(json_object *mainjobj, int argc, ...)
{
va_list arg;
char *argv[64];
int i;
va_start(arg, argc);
for (i = 0; i < argc; i++)
{
argv[i] = va_arg(arg, char *);
}
argv[argc] = NULL;
va_end(arg);
return dmjson_select_obj(mainjobj, argv);
//return v;
}
json_object *dmjson_select_obj(json_object * jobj, char *argv[])
{
int i;
for (i = 0; argv[i]; i++) {
if (jobj == NULL)
return NULL;
json_object_object_get_ex(jobj, argv[i], &jobj);
}
return jobj;
}
json_object *____dmjson_select_obj_in_array_idx(json_object *mainjobj, json_object **arrobj, int index, char *argv[])
{
json_object *jobj = NULL;
int i;
if (arrobj == NULL || *arrobj == NULL) {
jobj = dmjson_select_obj(mainjobj, argv);
if (arrobj)
*arrobj = jobj;
if (jobj && json_object_get_type(jobj) == json_type_array) {
jobj = json_object_array_get_idx(jobj, index);
return jobj;
}
else {
return NULL;
}
}
else {
jobj = json_object_array_get_idx(*arrobj, index);
return jobj;
}
return NULL;
}
json_object *__dmjson_select_obj_in_array_idx(json_object *mainjobj, json_object **arrobj, int index, int argc, ...)
{
va_list arg;
json_object *jobj;
char *argv[64];
int i;
if (mainjobj == NULL)
return NULL;
va_start(arg, argc);
for (i = 0; i < argc; i++)
{
argv[i] = va_arg(arg, char *);
}
argv[argc] = NULL;
va_end(arg);
jobj = ____dmjson_select_obj_in_array_idx(mainjobj, arrobj, index, argv);
return jobj;
}
char *____dmjson_get_value_in_array_idx(json_object *mainjobj, json_object **arrobj, int index, char *argv[])
{
json_object *jobj = NULL;
char *value = NULL;
int i;
if (arrobj == NULL || *arrobj == NULL) {
jobj = dmjson_select_obj(mainjobj, argv);
if (arrobj)
*arrobj = jobj;
if (jobj && json_object_get_type(jobj) == json_type_array) {
jobj = json_object_array_get_idx(jobj, index);
if (jobj == NULL)
return NULL;
value = dmjson_print_value(jobj);
return value;
}
}
else {
jobj = json_object_array_get_idx(*arrobj, index);
if (jobj == NULL)
return NULL;
value = dmjson_print_value(jobj);
return value;
}
return value;
}
char *__dmjson_get_value_in_array_idx(json_object *mainjobj, json_object **arrobj, char *defret, int index, int argc, ...)
{
va_list arg;
char *argv[64], *v;
int i;
if (mainjobj == NULL)
return defret;
va_start(arg, argc);
for (i = 0; i < argc; i++)
{
argv[i] = va_arg(arg, char *);
}
argv[argc] = NULL;
va_end(arg);
v = ____dmjson_get_value_in_array_idx(mainjobj, arrobj, index, argv);
return (v ? v : defret) ;
}
char *____dmjson_get_value_array_all(json_object *mainjobj, char *delim, char *argv[])
{
json_object *arrobj;
char *v, *ret = "";
int i, dlen;
delim = (delim) ? delim : ",";
dlen = strlen(delim);
for (i = 0, arrobj = NULL, v = ____dmjson_get_value_in_array_idx(mainjobj, &arrobj, i, argv);
v;
v = ____dmjson_get_value_in_array_idx(mainjobj, &arrobj, ++i, argv)) {
if (*ret == '\0') {
ret = dmstrdup(v);
}
else if (*v) {
ret = dmrealloc(ret, strlen(ret) + dlen + strlen(v) + 1);
strcat(ret, delim);
strcat(ret, v);
}
}
return ret;
}
char *__dmjson_get_value_array_all(json_object *mainjobj, char *delim, int argc, ...)
{
char *argv[64], *ret;
va_list arg;
int i;
va_start(arg, argc);
for (i = 0; i < argc; i++)
{
argv[i] = va_arg(arg, char *);
}
argv[argc] = NULL;
va_end(arg);
ret = ____dmjson_get_value_array_all(mainjobj, delim, argv);
return ret;
}
void dmjson_get_var(char *jkey, char **jval)
{
enum json_type type;
*jval = "";
if (dmjson_jobj == NULL)
return;
json_object_object_foreach(dmjson_jobj, key, val) {
if (strcmp(jkey, key) == 0) {
*jval = dmjson_print_value(val);
return;
}
}
}

50
dmjson.h Normal file
View file

@ -0,0 +1,50 @@
#ifndef __DMJSON_H
#define __DMJSON_H
#include <string.h>
#include <json-c/json.h>
#include <libubox/blobmsg_json.h>
#include "dmcwmp.h"
struct dmjson_arg {
char *key;
char *val;
};
#define DMJSON_ARGS (struct dmjson_arg[])
void dm_add_json_obj(json_object *json_obj_out, char *object, char *string);
void dmjson_printf(int argc, struct dmjson_arg dmarg[]);
void dmjson_fprintf(FILE *fp, int argc, struct dmjson_arg dmarg[]);
void dmjson_parse_init(char *msg);
void dmjson_parse_fini(void);
void dmjson_get_var(char *jkey, char **jval);
json_object *dmjson_select_obj(json_object * jobj, char *argv[]);
json_object *__dmjson_get_obj(json_object *mainjobj, int argc, ...);
char *____dmjson_get_value_in_obj(json_object *mainjobj, char *argv[]);
char *__dmjson_get_value_in_obj(json_object *mainjobj, int argc, ...);
json_object *__dmjson_select_obj_in_array_idx(json_object *mainjobj, json_object **arrobj, int index, int argc, ...);
char *____dmjson_get_value_array_all(json_object *mainjobj, char *delim, char *argv[]);
char *__dmjson_get_value_array_all(json_object *mainjobj, char *delim, int argc, ...);
#define dmjson_get_value(JOBJ,ARGC,args...) \
__dmjson_get_value_in_obj(JOBJ, ARGC, ##args)
#define dmjson_get_obj(JOBJ,ARGC,args...) \
__dmjson_get_obj(JOBJ, ARGC, ##args)
#define dmjson_get_value_in_array_idx(MAINJOBJ,INDEX,ARGC,args...) \
__dmjson_get_value_in_array_idx(MAINJOBJ, NULL, "", INDEX, ARGC, ##args)
#define dmjson_select_obj_in_array_idx(MAINJOBJ,INDEX,ARGC,args...) \
__dmjson_select_obj_in_array_idx(MAINJOBJ, NULL, INDEX, ARGC, ##args)
#define dmjson_get_value_array_all(MAINJOBJ,DELIM,ARGC,args...) \
__dmjson_get_value_array_all(MAINJOBJ, DELIM, ARGC, ##args);
#define dmjson_foreach_value_in_array(MAINJOBJ,ARROBJ,VAL,INDEX,ARGC,args...) \
for (INDEX = 0, ARROBJ = NULL, VAL = __dmjson_get_value_in_array_idx(MAINJOBJ, &(ARROBJ), NULL, INDEX, ARGC, ##args);\
VAL; \
VAL = __dmjson_get_value_in_array_idx(MAINJOBJ, &(ARROBJ), NULL, ++INDEX, 0))
#endif

152
dmmem.c Normal file
View file

@ -0,0 +1,152 @@
#include "dmmem.h"
#ifdef WITH_MEMLEACKSEC
LIST_HEAD(memhead);
inline void *__dmmalloc
(
#ifdef WITH_MEMTRACK
const char *file, const char *func, int line,
#endif /*WITH_MEMTRACK*/
size_t size
)
{
struct dmmem *m = malloc(sizeof(struct dmmem) + size);
if (m == NULL) return NULL;
list_add(&m->list, &memhead);
#ifdef WITH_MEMTRACK
m->file = (char *)file;
m->func = (char *)func;
m->line = line;
#endif /*WITH_MEMTRACK*/
return (void *)m->mem;
}
inline void *__dmcalloc
(
#ifdef WITH_MEMTRACK
const char *file, const char *func, int line,
#endif /*WITH_MEMTRACK*/
int n, size_t size
)
{
struct dmmem *m = calloc(n, sizeof(struct dmmem) + size);
if (m == NULL) return NULL;
list_add(&m->list, &memhead);
#ifdef WITH_MEMTRACK
m->file = (char *)file;
m->func = (char *)func;
m->line = line;
#endif /*WITH_MEMTRACK*/
return (void *)m->mem;
}
inline void *__dmrealloc
(
#ifdef WITH_MEMTRACK
const char *file, const char *func, int line,
#endif /*WITH_MEMTRACK*/
void *old, size_t size
)
{
struct dmmem *m = NULL;
if (old != NULL) {
m = container_of(old, struct dmmem, mem);
list_del(&m->list);
}
m = realloc(m, sizeof(struct dmmem) + size);
if (m == NULL) return NULL;
list_add(&m->list, &memhead);
#ifdef WITH_MEMTRACK
m->file = (char *)file;
m->func = (char *)func;
m->line = line;
#endif /*WITH_MEMTRACK*/
return (void *)m->mem;
}
inline void dmfree(void *m)
{
if (m == NULL) return;
struct dmmem *rm;
rm = container_of(m, struct dmmem, mem);
list_del(&rm->list);
free(rm);
}
void dmcleanmem()
{
struct dmmem *dmm;
while (memhead.next != &memhead) {
dmm = list_entry(memhead.next, struct dmmem, list);
#ifdef WITH_MEMTRACK
fprintf(stderr, "Allocated memory in {%s, %s(), line %d} is not freed\n", dmm->file, dmm->func, dmm->line);
#endif /*WITH_MEMTRACK*/
list_del(&dmm->list);
free(dmm);
}
}
char *__dmstrdup
(
#ifdef WITH_MEMTRACK
const char *file, const char *func, int line,
#endif /*WITH_MEMTRACK*/
const char *s
)
{
size_t len = strlen(s) + 1;
#ifdef WITH_MEMTRACK
void *new = __dmmalloc(file, func, line, len);
#else
void *new = __dmmalloc(len);
#endif /*WITH_MEMTRACK*/
if (new == NULL) return NULL;
return (char *) memcpy(new, s, len);
}
#endif /*WITH_MEMLEACKSEC*/
int __dmasprintf
(
#ifdef WITH_MEMTRACK
const char *file, const char *func, int line,
#endif /*WITH_MEMTRACK*/
char **s, const char *format, ...
)
{
char buf[512];
va_list arg;
int ret;
va_start(arg,format);
ret = vsprintf(buf, format, arg);
va_end(arg);
#ifdef WITH_MEMTRACK
*s = __dmstrdup(file, func, line, buf);
#else
*s = __dmstrdup(buf);
#endif /*WITH_MEMTRACK*/
if (*s == NULL) return -1;
return 0;
}
int __dmastrcat
(
#ifdef WITH_MEMTRACK
const char *file, const char *func, int line,
#endif /*WITH_MEMTRACK*/
char **s, char *obj, char *lastname
)
{
char buf[512];
int olen = strlen(obj);
memcpy(buf, obj, olen);
int llen = strlen(lastname) + 1;
memcpy(buf + olen, lastname, llen);
#ifdef WITH_MEMTRACK
*s = __dmstrdup(file, func, line, buf);
#else
*s = __dmstrdup(buf);
#endif /*WITH_MEMTRACK*/
if (*s == NULL) return -1;
return 0;
}

110
dmmem.h Normal file
View file

@ -0,0 +1,110 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <libubox/list.h>
#ifndef __DMMEM_H
#define __DMMEM_H
void dmfree(void *m);
static inline void dm_empty_func()
{
}
#define WITH_MEMLEACKSEC 1
//#define WITH_MEMTRACK 1
#ifndef WITH_MEMLEACKSEC
#undef WITH_MEMTRACK
#endif
#ifdef WITH_MEMLEACKSEC
struct dmmem {
struct list_head list;
#ifdef WITH_MEMTRACK
char *file;
char *func;
int line;
#endif /*WITH_MEMTRACK*/
char mem[0];
};
void *__dmmalloc
(
#ifdef WITH_MEMTRACK
const char *file, const char *func, int line,
#endif /*WITH_MEMTRACK*/
size_t size
);
void *__dmcalloc
(
#ifdef WITH_MEMTRACK
const char *file, const char *func, int line,
#endif /*WITH_MEMTRACK*/
int n, size_t size
);
void *__dmrealloc
(
#ifdef WITH_MEMTRACK
const char *file, const char *func, int line,
#endif /*WITH_MEMTRACK*/
void *n, size_t size
);
char *__dmstrdup
(
#ifdef WITH_MEMTRACK
const char *file, const char *func, int line,
#endif /*WITH_MEMTRACK*/
const char *s
);
void dmcleanmem();
#endif /*WITH_MEMLEACKSEC*/
int __dmasprintf
(
#ifdef WITH_MEMTRACK
const char *file, const char *func, int line,
#endif /*WITH_MEMTRACK*/
char **s, const char *format, ...
);
int __dmastrcat
(
#ifdef WITH_MEMTRACK
const char *file, const char *func, int line,
#endif /*WITH_MEMTRACK*/
char **s, char *obj, char *lastname
);
#ifdef WITH_MEMLEACKSEC
#ifdef WITH_MEMTRACK
#define dmmalloc(x) __dmmalloc(__FILE__, __func__, __LINE__, x)
#define dmcalloc(n, x) __dmcalloc(__FILE__, __func__, __LINE__, n, x)
#define dmrealloc(x, n) __dmrealloc(__FILE__, __func__, __LINE__, x, n)
#define dmstrdup(x) __dmstrdup(__FILE__, __func__, __LINE__, x)
#define dmasprintf(s, format, ...) __dmasprintf(__FILE__, __func__, __LINE__, s, format, ## __VA_ARGS__)
#define dmastrcat(s, b, m) __dmastrcat(__FILE__, __func__, __LINE__, s, b, m)
#else
#define dmmalloc(x) __dmmalloc(x)
#define dmcalloc(n, x) __dmcalloc(n, x)
#define dmrealloc(x, n) __dmrealloc(x, n)
#define dmstrdup(x) __dmstrdup(x)
#define dmasprintf(s, format, ...) __dmasprintf(s, format, ## __VA_ARGS__)
#define dmastrcat(s, b, m) __dmastrcat(s, b, m)
#endif /*WITH_MEMTRACK*/
#else
#define dmmalloc(x) malloc(x)
#define dmcalloc(n, x) calloc(n, x)
#define __dmstrdup(x) strdup(x)
#define dmstrdup(x) strdup(x)
#define dmasprintf(s, format, ...) __dmasprintf(s, format, ## __VA_ARGS__)
#define dmastrcat(s, b, m) __dmastrcat(s, b, m)
#define dmfree(x) free(x)
#define dmcleanmem() dm_empty_func()
#endif /*WITH_MEMLEACKSEC*/
#define DMFREE(x) do { dmfree(x); x = NULL; } while (0);
#endif

865
dmoperate.c Normal file
View file

@ -0,0 +1,865 @@
/*
* dmoperate.c: Operate handler for uspd
*
* Copyright (C) 2019 iopsys Software Solutions AB. All rights reserved.
*
* Author: Vivek Dutta <vivek.dutta@iopsys.eu>
* Author: Yashvardhan <y.yashvardhan@iopsys.eu>
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <regex.h>
#include "dmcwmp.h"
#include "dmubus.h"
#include "dmuci.h"
#include "dmjson.h"
#include "dmentry.h"
#include "dmcommon.h"
#include "dmoperate.h"
#include "dmdiagnostics.h"
#define GLOB_EXPR "[=><]+"
bool match(const char *string, const char *pattern)
{
regex_t re;
if (regcomp(&re, pattern, REG_EXTENDED) != 0) return 0;
int status = regexec(&re, string, 0, NULL, 0);
regfree(&re);
if (status != 0) return false;
return true;
}
bool is_str_eq(const char *s1, const char *s2)
{
if(0==strcmp(s1, s2))
return true;
return false;
}
static void cwmp_init(struct dmctx *dm_ctx, char *path)
{
char *uci_amd = NULL, *uci_instance = NULL;
int amd = AMD_2, instance = INSTANCE_MODE_ALIAS;
if(match(path, "[[]+")) {
if(!match(path, GLOB_EXPR)) {
amd = AMD_5;
}
} else {
dmuci_get_option_value_string("cwmp", "cpe", "amd_version", &uci_amd);
if(uci_amd) {
amd = atoi(uci_amd);
free(uci_amd);
}
dmuci_get_option_value_string("cwmp", "cpe", "instance_mode", &uci_instance);
if(uci_instance) {
if(!is_str_eq(uci_instance, "InstanceAlias"))
instance = INSTANCE_MODE_NUMBER;
free(uci_instance);
}
}
printf("amd |%d| instance|%d|\n", amd, instance);
dm_ctx_init(dm_ctx, DM_CWMP, amd, instance);
}
static void cwmp_cleanup(struct dmctx *dm_ctx)
{
dm_ctx_clean(dm_ctx);
}
static bool cwmp_get(int operation, char *path, struct dmctx *dm_ctx)
{
int fault = 0;
printf("Entry |%s| operation|%d| \n", path, operation);
switch(operation) {
case CMD_GET_NAME:
fault = dm_entry_param_method(dm_ctx, CMD_GET_NAME, path, "true", NULL);
break;
case CMD_GET_VALUE:
fault = dm_entry_param_method(dm_ctx, CMD_GET_VALUE, path, NULL, NULL);
break;
default:
printf("Operation not supported yet!\n");
return false;
}
if (dm_ctx->list_fault_param.next != &dm_ctx->list_fault_param) {
return false;
}
if (fault) {
return false;
}
return true;
}
static bool cwmp_set_value(char *path, char *value)
{
int fault = 0, res;
struct dmctx dm_ctx = {0};
struct dmctx *p_dmctx = &dm_ctx;
cwmp_init(&dm_ctx, path);
printf("Entry path|%s|, value|%s|", path, value);
fault = dm_entry_param_method(&dm_ctx, CMD_SET_VALUE, path, value, NULL);
if(!fault) {
fault = dm_entry_apply(&dm_ctx, CMD_SET_VALUE, "", NULL);
}
if (p_dmctx->list_fault_param.next != &p_dmctx->list_fault_param) {
res = FAIL;
}
if (fault)
res = FAIL;
else
res = SUCCESS;
cwmp_cleanup(&dm_ctx);
return res;
}
char *cwmp_get_value_by_id(char *id)
{
struct dmctx dm_ctx = {0};
struct dm_parameter *n;
char *value = NULL;
printf("Entry id |%s|", id);
cwmp_init(&dm_ctx, id);
if(cwmp_get(CMD_GET_VALUE, id, &dm_ctx)) {
list_for_each_entry(n, &dm_ctx.list_parameter, list) {
printf("value |%s| \n", n->name);
value = dmstrdup(n->data);
break;
}
}
cwmp_cleanup(&dm_ctx);
return value;
}
static char *get_param_val_from_op_cmd(char *op_cmd, const char *param)
{
char *val = NULL;
char node[256] = {'\0'};
// Trim action from operation command
// For eg: trim Reset from Device.IP.Interface.*.Reset
char *ret = strrchr(op_cmd, '.');
strncpy(node, op_cmd, ret - op_cmd +1);
// Append param name to the trimmed path
strcat(node, param);
// Get parameter value
val = cwmp_get_value_by_id(node);
return val;
}
// Operate function definitions
static opr_ret_t reboot_device(struct dmctx *dmctx, char *path, char *input)
{
if(0 == dmubus_call_set(SYSTEM_UBUS_PATH, "reboot", UBUS_ARGS{}, 0))
return SUCCESS;
else
return FAIL;
}
static opr_ret_t factory_reset(struct dmctx *dmctx, char *path, char *input)
{
if(0 == dmcmd_no_wait("/sbin/defaultreset", 0))
return SUCCESS;
else
return FAIL;
}
static opr_ret_t network_interface_reset(struct dmctx *dmctx, char *path, char *input)
{
char cmd[NAME_MAX] = NETWORK_INTERFACE_UBUS_PATH;
bool status = false;
snprintf(cmd + strlen(cmd), NAME_MAX - strlen(cmd), "%s", ".");
char *zone = NULL;
zone = get_param_val_from_op_cmd(path, "Name");
if(zone) {
strcat(cmd, zone);
dmfree(zone);
} else {
printf("Network not reachable |%s|", cmd);
return FAIL;
}
printf("cmd |%s|", cmd);
if(0 == dmubus_call_set(cmd, "down", UBUS_ARGS{}, 0))
status = true;
if(0 == dmubus_call_set(cmd, "up", UBUS_ARGS{}, 0))
status &= true;
if(status)
return SUCCESS;
else
return FAIL;
}
static opr_ret_t wireless_reset(struct dmctx *dmctx, char *path, char *input)
{
if(0 == dmcmd_no_wait("/sbin/wifi", 2, "reload", "&"))
return SUCCESS;
else
return FAIL;
}
struct wifi_security_params reset_params[] = {
{"", "ModeEnabled", ""},
{"", "PreSharedKey", ""},
{"", "KeyPassphrase", ""}
};
static opr_ret_t ap_security_reset(struct dmctx *dmctx, char *path, char *input)
{
char *wpakey = NULL;
char node[MAXNAMLEN] = {'\0'};
int i, len = 0;
char *ret = strrchr(path, '.');
strncpy(node, path, ret - path +1);
len = ARRAY_SIZE(reset_params);
for (i = 0; i < len; i++) {
strncpy(reset_params[i].node, node, MAXNAMLEN);
strcat(reset_params[i].node, reset_params[i].param);
}
const char *mode_enabled = "WPA2-Personal";
// Default mode - WPA2-Personal
strncpy(reset_params[0].value, mode_enabled, MAXNAMLEN);
// Get Default wpakey
db_get_value_string("hw", "board", "wpaKey", &wpakey);
// PreSharedKey and KeyPassphrase are kept same
strncpy(reset_params[1].value, wpakey, MAXNAMLEN);
strncpy(reset_params[2].value, wpakey, MAXNAMLEN);
for (i = 0; i < len; i++) {
cwmp_set_value(reset_params[i].node, reset_params[i].value);
}
return SUCCESS;
}
static opr_ret_t dhcp_client_renew(struct dmctx *dmctx, char *path, char *input)
{
if(SUCCESS == cwmp_set_value(path, "true"))
return SUCCESS;
else
return FAIL;
}
static opr_ret_t vendor_conf_backup(struct dmctx *dmctx, char *path, char *input)
{
struct file_server fserver = {0};
json_object *json_res = NULL;
char *vcf_name = NULL;
vcf_name = get_param_val_from_op_cmd(path, "Name");
if (vcf_name[0] == '\0')
return FAIL;
json_res = json_tokener_parse((const char *)input);
fserver.url = dmstrdup(dmjson_get_value(json_res, 1, "URL"));
if(fserver.url[0] == '\0')
return UBUS_INVALID_ARGUMENTS;
fserver.user = dmstrdup(dmjson_get_value(json_res, 1, "Username"));
if(fserver.user[0] == '\0')
return UBUS_INVALID_ARGUMENTS;
fserver.pass = dmjson_get_value(json_res, 1, "Password");
if(fserver.pass[0] == '\0')
return UBUS_INVALID_ARGUMENTS;
dmcmd("/bin/sh", 7, ICWMP_SCRIPT, "upload", fserver.url, VCF_FILE_TYPE, fserver.user, fserver.pass, vcf_name);
dmfree(vcf_name);
return SUCCESS;
}
static opr_ret_t vendor_conf_restore(struct dmctx *dmctx, char *path, char *input)
{
struct file_server fserver = {0};
json_object *json_res = NULL;
char *file_size = NULL;
json_res = json_tokener_parse((const char *)input);
fserver.url = dmjson_get_value(json_res, 1, "URL");
if(fserver.url[0] == '\0')
return UBUS_INVALID_ARGUMENTS;
fserver.user = dmjson_get_value(json_res, 1, "Username");
if(fserver.user[0] == '\0')
return UBUS_INVALID_ARGUMENTS;
fserver.pass = dmjson_get_value(json_res, 1, "Password");
if(fserver.pass[0] == '\0')
return UBUS_INVALID_ARGUMENTS;
file_size = dmjson_get_value(json_res, 1, "FileSize");
dmcmd("/bin/sh", 7, ICWMP_SCRIPT, "download", fserver.url, file_size, VCF_FILE_TYPE, fserver.user, fserver.pass);
if (0 == dmcmd_no_wait("/bin/sh", 4, ICWMP_SCRIPT, "apply", "download", VCF_FILE_TYPE))
return SUCCESS;
else
return FAIL;
}
static void fill_wireless_scan_results(struct dmctx *dmctx, char *radio)
{
json_object *res, *obj;
struct neighboring_wiFi_diagnostic neighboring = {0};
char *ssid, *bssid, *channel, *frequency, *signal_stregth, *noise;
dmubus_call(ROUTER_WIRELESS_UBUS_PATH, "scanresults", UBUS_ARGS{{"radio", radio, String}}, 1, &res);
if(!json_object_object_get_ex(res,"access_points", &obj)) {
return;
}
uint8_t len = json_object_array_length(obj);
for (uint8_t j = 0; j < len; j++ ) {
json_object *array_obj = json_object_array_get_idx(obj, j);
neighboring.ssid = dmjson_get_value(array_obj, 1, "ssid");
neighboring.bssid = dmjson_get_value(array_obj, 1, "bssid");
neighboring.channel = dmjson_get_value(array_obj, 1, "channel");
neighboring.frequency = dmjson_get_value(array_obj, 1, "frequency");
neighboring.signal_strength = dmjson_get_value(array_obj, 1, "rssi");
neighboring.noise = dmjson_get_value(array_obj, 1, "snr");
dmasprintf(&ssid, "Result.%d.SSID", j+1);
dmasprintf(&bssid, "Result.%d.BSSID", j+1);
dmasprintf(&channel, "Result.%d.Channel", j+1);
dmasprintf(&frequency, "Result.%d.OperatingFrequencyBand", j+1);
dmasprintf(&signal_stregth, "Result.%d.SignalStrength", j+1);
dmasprintf(&noise, "Result.%d.Noise", j+1);
add_list_paramameter(dmctx, ssid, neighboring.ssid, "string­", NULL, 0);
add_list_paramameter(dmctx, bssid, neighboring.bssid, "string­", NULL, 0);
add_list_paramameter(dmctx, channel, neighboring.channel, "unsignedInt­", NULL, 0);
add_list_paramameter(dmctx, frequency, neighboring.frequency, "string­", NULL, 0);
add_list_paramameter(dmctx, signal_stregth, neighboring.signal_strength, "int­", NULL, 0);
add_list_paramameter(dmctx, noise, neighboring.noise, "int­", NULL, 0);
}
}
static opr_ret_t fetch_neighboring_wifi_diagnostic(struct dmctx *dmctx, char *path, char *input)
{
json_object *res;
dmubus_call(ROUTER_WIRELESS_UBUS_PATH, "radios", UBUS_ARGS{}, 0, &res);
json_object_object_foreach(res, key, val) {
fill_wireless_scan_results(dmctx, key);
}
return SUCCESS;
}
static opr_ret_t ip_diagnostics_ipping(struct dmctx *dmctx, char *path, char *input)
{
json_object *json_res = NULL;
struct ipping_diagnostics ipping = {0};
json_res = json_tokener_parse((const char *)input);
ipping.host = dmjson_get_value(json_res, 1, "Host");
if(ipping.host[0] == '\0')
return UBUS_INVALID_ARGUMENTS;
ipping.interface = dmjson_get_value(json_res, 1, "Interface");
ipping.proto = dmjson_get_value(json_res, 1, "ProtocolVersion");
ipping.nbofrepetition = dmjson_get_value(json_res, 1, "NumberOfRepetitions");
ipping.timeout = dmjson_get_value(json_res, 1, "Timeout");
ipping.datablocksize = dmjson_get_value(json_res, 1, "DataBlockSize");
ipping.dscp = dmjson_get_value(json_res, 1, "DSCP");
set_param_diagnostics("ippingdiagnostic", "Host", ipping.host);
set_param_diagnostics("ippingdiagnostic", "interface", ipping.interface);
set_param_diagnostics("ippingdiagnostic", "ProtocolVersion", ipping.proto);
set_param_diagnostics("ippingdiagnostic", "NumberOfRepetitions", ipping.nbofrepetition);
set_param_diagnostics("ippingdiagnostic", "Timeout", ipping.timeout);
set_param_diagnostics("ippingdiagnostic", "DataBlockSize", ipping.datablocksize);
set_param_diagnostics("ippingdiagnostic", "DSCP", ipping.dscp);
//Free uci_varstate_ctx
end_uci_varstate_ctx();
dmcmd("/bin/sh", 3, IPPING_PATH, "run", "usp");
//Allocate uci_varstate_ctx
init_uci_varstate_ctx();
ipping.success_count = get_param_diagnostics("ippingdiagnostic", "SuccessCount");
ipping.failure_count = get_param_diagnostics("ippingdiagnostic", "FailureCount");
ipping.average_response_time = get_param_diagnostics("ippingdiagnostic", "AverageResponseTime");
ipping.minimum_response_time = get_param_diagnostics("ippingdiagnostic", "MinimumResponseTime");
ipping.maximum_response_time = get_param_diagnostics("ippingdiagnostic", "MaximumResponseTime");
ipping.average_response_time_detailed = get_param_diagnostics("ippingdiagnostic", "AverageResponseTimeDetailed");
ipping.minimum_response_time_detailed = get_param_diagnostics("ippingdiagnostic", "MinimumResponseTimeDetailed");
ipping.maximum_response_time_detailed = get_param_diagnostics("ippingdiagnostic", "MaximumResponseTimeDetailed");
char *param_success_count = dmstrdup("SuccessCount");
char *param_failure_count = dmstrdup("FailureCount");
char *param_average_response_time = dmstrdup("AverageResponseTime");
char *param_minimum_response_time = dmstrdup("MinimumResponseTime");
char *param_maximum_response_time = dmstrdup("MaximumResponseTime");
char *param_average_response_time_detailed = dmstrdup("AverageResponseTimeDetailed");
char *param_minimum_response_time_detailed = dmstrdup("MinimumResponseTimeDetailed");
char *param_maximum_response_time_detailed = dmstrdup("MaximumResponseTimeDetailed");
add_list_paramameter(dmctx, param_success_count, ipping.success_count, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_failure_count, ipping.failure_count, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_average_response_time, ipping.average_response_time, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_minimum_response_time, ipping.minimum_response_time, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_maximum_response_time, ipping.maximum_response_time, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_average_response_time_detailed, ipping.average_response_time_detailed, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_minimum_response_time_detailed, ipping.minimum_response_time_detailed, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_maximum_response_time_detailed, ipping.maximum_response_time_detailed, "unsignedInt", NULL, 0);
return SUCCESS;
}
static opr_ret_t ip_diagnostics_traceroute(struct dmctx *dmctx, char *path, char *input)
{
json_object *json_res = NULL;
struct traceroute_diagnostics traceroute = {0};
struct uci_section *s = NULL;
char *host, *host_address, *errorcode, *rttimes;
int i = 1;
json_res = json_tokener_parse((const char *)input);
traceroute.host = dmjson_get_value(json_res, 1, "Host");
if(traceroute.host[0] == '\0')
return UBUS_INVALID_ARGUMENTS;
traceroute.interface = dmjson_get_value(json_res, 1, "Interface");
traceroute.proto = dmjson_get_value(json_res, 1, "ProtocolVersion");
traceroute.nboftries = dmjson_get_value(json_res, 1, "NumberOfTries");
traceroute.timeout = dmjson_get_value(json_res, 1, "Timeout");
traceroute.datablocksize = dmjson_get_value(json_res, 1, "DataBlockSize");
traceroute.dscp = dmjson_get_value(json_res, 1, "DSCP");
traceroute.maxhops = dmjson_get_value(json_res, 1, "MaxHopCount");
set_param_diagnostics("traceroutediagnostic", "Host", traceroute.host);
set_param_diagnostics("traceroutediagnostic", "interface", traceroute.interface);
set_param_diagnostics("traceroutediagnostic", "ProtocolVersion", traceroute.proto);
set_param_diagnostics("traceroutediagnostic", "NumberOfTries", traceroute.nboftries);
set_param_diagnostics("traceroutediagnostic", "Timeout", traceroute.timeout);
set_param_diagnostics("traceroutediagnostic", "DataBlockSize", traceroute.datablocksize);
set_param_diagnostics("traceroutediagnostic", "DSCP", traceroute.dscp);
set_param_diagnostics("traceroutediagnostic", "MaxHops", traceroute.maxhops);
//Free uci_varstate_ctx
end_uci_varstate_ctx();
dmcmd("/bin/sh", 3, TRACEROUTE_PATH, "run", "usp");
//Allocate uci_varstate_ctx
init_uci_varstate_ctx();
traceroute.response_time = get_param_diagnostics("traceroutediagnostic", "ResponseTime");
char *param_response_time = dmstrdup("ResponseTime");
add_list_paramameter(dmctx, param_response_time, traceroute.response_time, "unsignedInt", NULL, 0);
uci_foreach_sections_state("cwmp", "RouteHops", s)
{
dmasprintf(&host, "RouteHops.%d.Host", i);
dmasprintf(&host_address, "RouteHops.%d.HostAddress", i);
dmasprintf(&errorcode, "RouteHops.%d.ErrorCode", i);
dmasprintf(&rttimes, "RouteHops.%d.RTTimes", i);
dmuci_get_value_by_section_string(s, "host", &traceroute.host_name);
dmuci_get_value_by_section_string(s, "ip", &traceroute.host_address);
dmuci_get_value_by_section_string(s, "time", &traceroute.rttimes);
add_list_paramameter(dmctx, host, traceroute.host_name, "string­", NULL, 0);
add_list_paramameter(dmctx, host_address, traceroute.host_address, "string­", NULL, 0);
add_list_paramameter(dmctx, errorcode, "0", "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, rttimes, traceroute.rttimes, "string­", NULL, 0);
i++;
}
return SUCCESS;
}
static opr_ret_t ip_diagnostics_download(struct dmctx *dmctx, char *path, char *input)
{
json_object *json_res = NULL;
struct download_diagnostics download = {0};
json_res = json_tokener_parse((const char *)input);
download.download_url = dmjson_get_value(json_res, 1, "DownloadURL");
if(download.download_url[0] == '\0')
return UBUS_INVALID_ARGUMENTS;
download.interface = dmjson_get_value(json_res, 1, "Interface");
download.dscp = dmjson_get_value(json_res, 1, "DSCP");
download.ethernet_priority = dmjson_get_value(json_res, 1, "EthernetPriority");
download.proto = dmjson_get_value(json_res, 1, "ProtocolVersion");
download.num_of_connections = dmjson_get_value(json_res, 1, "NumberOfConnections");
download.enable_per_connection_results = dmjson_get_value(json_res, 1, "EnablePerConnectionResults");
set_param_diagnostics("downloaddiagnostic", "url", download.download_url);
set_param_diagnostics("downloaddiagnostic", "device", download.interface);
set_param_diagnostics("downloaddiagnostic", "DSCP", download.dscp);
set_param_diagnostics("downloaddiagnostic", "ethernetpriority", download.ethernet_priority);
set_param_diagnostics("downloaddiagnostic", "ProtocolVersion", download.proto);
set_param_diagnostics("downloaddiagnostic", "NumberOfConnections", download.num_of_connections);
set_param_diagnostics("downloaddiagnostic", "EnablePerConnection", download.enable_per_connection_results);
if(start_upload_download_diagnostic(DOWNLOAD_DIAGNOSTIC) == -1)
return FAIL;
download.romtime = get_param_diagnostics("downloaddiagnostic", "ROMtime");
download.bomtime = get_param_diagnostics("downloaddiagnostic", "BOMtime");
download.eomtime = get_param_diagnostics("downloaddiagnostic", "EOMtime");
download.test_bytes_received = get_param_diagnostics("downloaddiagnostic", "TestBytesReceived");
download.total_bytes_received = get_param_diagnostics("downloaddiagnostic", "TotalBytesReceived");
download.total_bytes_sent = get_param_diagnostics("downloaddiagnostic", "TotalBytesSent");
download.test_bytes_received_under_full_loading = get_param_diagnostics("downloaddiagnostic", "TestBytesReceived");
download.total_bytes_received_under_full_loading = get_param_diagnostics("downloaddiagnostic", "TotalBytesReceived");
download.total_bytes_sent_under_full_loading = get_param_diagnostics("downloaddiagnostic", "TotalBytesSent");
download.period_of_full_loading = get_param_diagnostics("downloaddiagnostic", "PeriodOfFullLoading");
download.tcp_open_request_time = get_param_diagnostics("downloaddiagnostic", "TCPOpenRequestTimes");
download.tcp_open_response_time = get_param_diagnostics("downloaddiagnostic", "TCPOpenResponseTime");
char *param_rom_time = dmstrdup("ROMTime");
char *param_bom_time = dmstrdup("BOMTime");
char *param_eom_time = dmstrdup("EOMTime");
char *param_test_bytes_received = dmstrdup("TestBytesReceived");
char *param_total_bytes_received = dmstrdup("TotalBytesReceived");
char *param_total_bytes_sent = dmstrdup("TotalBytesSent");
char *param_test_bytes_received_under_full_loading = dmstrdup("TestBytesReceivedUnderFullLoading");
char *param_total_bytes_received_under_full_loading = dmstrdup("TotalBytesReceivedUnderFullLoading");
char *param_total_bytes_sent_under_full_loading = dmstrdup("TotalBytesSentUnderFullLoading");
char *param_period_of_full_loading = dmstrdup("PeriodOfFullLoading");
char *param_tcp_open_request_time = dmstrdup("TCPOpenRequestTime");
char *param_tcp_open_response_time = dmstrdup("TCPOpenResponseTime");
add_list_paramameter(dmctx, param_rom_time, download.romtime, "dateTime", NULL, 0);
add_list_paramameter(dmctx, param_bom_time, download.bomtime, "dateTime", NULL, 0);
add_list_paramameter(dmctx, param_eom_time, download.eomtime, "dateTime", NULL, 0);
add_list_paramameter(dmctx, param_test_bytes_received, download.test_bytes_received, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_total_bytes_received, download.total_bytes_received, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_total_bytes_sent, download.total_bytes_sent, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_test_bytes_received_under_full_loading, download.test_bytes_received_under_full_loading, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_total_bytes_received_under_full_loading, download.total_bytes_received_under_full_loading, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_total_bytes_sent_under_full_loading, download.total_bytes_sent_under_full_loading, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_period_of_full_loading, download.period_of_full_loading, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_tcp_open_request_time, download.tcp_open_request_time, "dateTime", NULL, 0);
add_list_paramameter(dmctx, param_tcp_open_response_time, download.tcp_open_response_time, "dateTime", NULL, 0);
return SUCCESS;
}
static opr_ret_t ip_diagnostics_upload(struct dmctx *dmctx, char *path, char *input)
{
json_object *json_res = NULL;
struct upload_diagnostics upload = {0};
json_res = json_tokener_parse((const char *)input);
upload.upload_url = dmjson_get_value(json_res, 1, "UploadURL");
if(upload.upload_url[0] == '\0')
return UBUS_INVALID_ARGUMENTS;
upload.test_file_length = dmjson_get_value(json_res, 1, "TestFileLength");
if(upload.test_file_length[0] == '\0')
return UBUS_INVALID_ARGUMENTS;
upload.interface = dmjson_get_value(json_res, 1, "Interface");
upload.dscp = dmjson_get_value(json_res, 1, "DSCP");
upload.ethernet_priority = dmjson_get_value(json_res, 1, "EthernetPriority");
upload.proto = dmjson_get_value(json_res, 1, "ProtocolVersion");
upload.num_of_connections = dmjson_get_value(json_res, 1, "NumberOfConnections");
upload.enable_per_connection_results = dmjson_get_value(json_res, 1, "EnablePerConnectionResults");
set_param_diagnostics("uploaddiagnostic", "url", upload.upload_url);
set_param_diagnostics("uploaddiagnostic", "TestFileLength", upload.test_file_length);
set_param_diagnostics("uploaddiagnostic", "device", upload.interface);
set_param_diagnostics("uploaddiagnostic", "DSCP", upload.dscp);
set_param_diagnostics("uploaddiagnostic", "ethernetpriority", upload.ethernet_priority);
set_param_diagnostics("uploaddiagnostic", "ProtocolVersion", upload.proto);
set_param_diagnostics("uploaddiagnostic", "NumberOfConnections", upload.num_of_connections);
set_param_diagnostics("uploaddiagnostic", "EnablePerConnection", upload.enable_per_connection_results);
if(start_upload_download_diagnostic(UPLOAD_DIAGNOSTIC) == -1)
return FAIL;
upload.romtime = get_param_diagnostics("uploaddiagnostic", "ROMtime");
upload.bomtime = get_param_diagnostics("uploaddiagnostic", "BOMtime");
upload.eomtime = get_param_diagnostics("uploaddiagnostic", "EOMtime");
upload.test_bytes_sent = get_param_diagnostics("uploaddiagnostic", "TestBytesSent");
upload.total_bytes_received = get_param_diagnostics("uploaddiagnostic", "TotalBytesReceived");
upload.total_bytes_sent = get_param_diagnostics("uploaddiagnostic", "TotalBytesSent");
upload.test_bytes_sent_under_full_loading = get_param_diagnostics("uploaddiagnostic", "TestBytesSent");
upload.total_bytes_received_under_full_loading = get_param_diagnostics("uploaddiagnostic", "TotalBytesReceived");
upload.total_bytes_sent_under_full_loading = get_param_diagnostics("uploaddiagnostic", "TotalBytesSent");
upload.period_of_full_loading = get_param_diagnostics("uploaddiagnostic", "PeriodOfFullLoading");
upload.tcp_open_request_time = get_param_diagnostics("uploaddiagnostic", "TCPOpenRequestTimes");
upload.tcp_open_response_time = get_param_diagnostics("uploaddiagnostic", "TCPOpenResponseTime");
char *param_rom_time = dmstrdup("ROMTime");
char *param_bom_time = dmstrdup("BOMTime");
char *param_eom_time = dmstrdup("EOMTime");
char *param_test_bytes_sent = dmstrdup("TestBytesSent");
char *param_total_bytes_received = dmstrdup("TotalBytesReceived");
char *param_total_bytes_sent = dmstrdup("TotalBytesSent");
char *param_test_bytes_sent_under_full_loading = dmstrdup("TestBytesSentUnderFullLoading");
char *param_total_bytes_received_under_full_loading = dmstrdup("TotalBytesReceivedUnderFullLoading");
char *param_total_bytes_sent_under_full_loading = dmstrdup("TotalBytesSentUnderFullLoading");
char *param_period_of_full_loading = dmstrdup("PeriodOfFullLoading");
char *param_tcp_open_request_time = dmstrdup("TCPOpenRequestTime");
char *param_tcp_open_response_time = dmstrdup("TCPOpenResponseTime");
add_list_paramameter(dmctx, param_rom_time, upload.romtime, "dateTime", NULL, 0);
add_list_paramameter(dmctx, param_bom_time, upload.bomtime, "dateTime", NULL, 0);
add_list_paramameter(dmctx, param_eom_time, upload.eomtime, "dateTime", NULL, 0);
add_list_paramameter(dmctx, param_test_bytes_sent, upload.test_bytes_sent, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_total_bytes_received, upload.total_bytes_received, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_total_bytes_sent, upload.total_bytes_sent, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_test_bytes_sent_under_full_loading, upload.test_bytes_sent_under_full_loading, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_total_bytes_received_under_full_loading, upload.total_bytes_received_under_full_loading, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_total_bytes_sent_under_full_loading, upload.total_bytes_sent_under_full_loading, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_period_of_full_loading, upload.period_of_full_loading, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_tcp_open_request_time, upload.tcp_open_request_time, "dateTime", NULL, 0);
add_list_paramameter(dmctx, param_tcp_open_response_time, upload.tcp_open_response_time, "dateTime", NULL, 0);
return SUCCESS;
}
static opr_ret_t ip_diagnostics_udpecho(struct dmctx *dmctx, char *path, char *input)
{
json_object *json_res = NULL;
struct udpecho_diagnostics udpecho = {0};
json_res = json_tokener_parse((const char *)input);
udpecho.host = dmjson_get_value(json_res, 1, "Host");
if(udpecho.host[0] == '\0')
return UBUS_INVALID_ARGUMENTS;
udpecho.port = dmjson_get_value(json_res, 1, "Port");
if(udpecho.port[0] == '\0')
return UBUS_INVALID_ARGUMENTS;
udpecho.interface = dmjson_get_value(json_res, 1, "Interface");
udpecho.proto = dmjson_get_value(json_res, 1, "ProtocolVersion");
udpecho.nbofrepetition = dmjson_get_value(json_res, 1, "NumberOfRepetitions");
udpecho.timeout = dmjson_get_value(json_res, 1, "Timeout");
udpecho.datablocksize = dmjson_get_value(json_res, 1, "DataBlockSize");
udpecho.dscp = dmjson_get_value(json_res, 1, "DSCP");
udpecho.inter_transmission_time = dmjson_get_value(json_res, 1, "InterTransmissionTime");
set_param_diagnostics("udpechodiagnostic", "Host", udpecho.host);
set_param_diagnostics("udpechodiagnostic", "port", udpecho.port);
set_param_diagnostics("udpechodiagnostic", "interface", udpecho.interface);
set_param_diagnostics("udpechodiagnostic", "ProtocolVersion", udpecho.proto);
set_param_diagnostics("udpechodiagnostic", "NumberOfRepetitions", udpecho.nbofrepetition);
set_param_diagnostics("udpechodiagnostic", "Timeout", udpecho.timeout);
set_param_diagnostics("udpechodiagnostic", "DataBlockSize", udpecho.datablocksize);
set_param_diagnostics("udpechodiagnostic", "DSCP", udpecho.dscp);
set_param_diagnostics("udpechodiagnostic", "InterTransmissionTime", udpecho.inter_transmission_time);
//Free uci_varstate_ctx
end_uci_varstate_ctx();
dmcmd("/bin/sh", 3, UDPECHO_PATH, "run", "usp");
//Allocate uci_varstate_ctx
init_uci_varstate_ctx();
udpecho.success_count = get_param_diagnostics("udpechodiagnostic", "SuccessCount");
udpecho.failure_count = get_param_diagnostics("udpechodiagnostic", "FailureCount");
udpecho.average_response_time = get_param_diagnostics("udpechodiagnostic", "AverageResponseTime");
udpecho.minimum_response_time = get_param_diagnostics("udpechodiagnostic", "MinimumResponseTime");
udpecho.maximum_response_time = get_param_diagnostics("udpechodiagnostic", "MaximumResponseTime");
char *param_success_count = dmstrdup("SuccessCount");
char *param_failure_count = dmstrdup("FailureCount");
char *param_average_response_time = dmstrdup("AverageResponseTime");
char *param_minimum_response_time = dmstrdup("MinimumResponseTime");
char *param_maximum_response_time = dmstrdup("MaximumResponseTime");
add_list_paramameter(dmctx, param_success_count, udpecho.success_count, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_failure_count, udpecho.failure_count, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_average_response_time, udpecho.average_response_time, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_minimum_response_time, udpecho.minimum_response_time, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_maximum_response_time, udpecho.maximum_response_time, "unsignedInt", NULL, 0);
return SUCCESS;
}
static opr_ret_t ip_diagnostics_serverselection(struct dmctx *dmctx, char *path, char *input)
{
json_object *json_res = NULL;
struct serverselection_diagnostics serverselection = {0};
json_res = json_tokener_parse((const char *)input);
serverselection.hostlist = dmjson_get_value(json_res, 1, "HostList");
if(serverselection.hostlist[0] == '\0')
return UBUS_INVALID_ARGUMENTS;
serverselection.port = dmjson_get_value(json_res, 1, "Port");
serverselection.proto = dmjson_get_value(json_res, 1, "Protocol");
if (strcmp(serverselection.proto, "ICMP")) {
if(serverselection.port[0] == '\0')
return UBUS_INVALID_ARGUMENTS;
}
serverselection.protocol_version = dmjson_get_value(json_res, 1, "ProtocolVersion");
serverselection.interface = dmjson_get_value(json_res, 1, "Interface");
serverselection.nbofrepetition = dmjson_get_value(json_res, 1, "NumberOfRepetitions");
serverselection.timeout = dmjson_get_value(json_res, 1, "Timeout");
set_param_diagnostics("serverselectiondiagnostic", "HostList", serverselection.hostlist);
set_param_diagnostics("serverselectiondiagnostic", "interface", serverselection.interface);
set_param_diagnostics("serverselectiondiagnostic", "ProtocolVersion", serverselection.proto);
set_param_diagnostics("serverselectiondiagnostic", "NumberOfRepetitions", serverselection.nbofrepetition);
set_param_diagnostics("serverselectiondiagnostic", "port", serverselection.port);
set_param_diagnostics("serverselectiondiagnostic", "Protocol", serverselection.proto);
//Free uci_varstate_ctx
end_uci_varstate_ctx();
dmcmd("/bin/sh", 3, SERVERSELECTION_PATH, "run", "usp");
//Allocate uci_varstate_ctx
init_uci_varstate_ctx();
serverselection.fasthost = get_param_diagnostics("serverselectiondiagnostic", "AverageResponseTimeDetailed");
serverselection.average_response_time = get_param_diagnostics("serverselectiondiagnostic", "AverageResponseTime");
serverselection.minimum_response_time = get_param_diagnostics("serverselectiondiagnostic", "MinimumResponseTime");
serverselection.maximum_response_time = get_param_diagnostics("serverselectiondiagnostic", "MaximumResponseTime");
char *param_fastest_host = dmstrdup("FastestHost");
char *param_average_response_time = dmstrdup("AverageResponseTime");
char *param_minimum_response_time = dmstrdup("MinimumResponseTime");
char *param_maximum_response_time = dmstrdup("MaximumResponseTime");
add_list_paramameter(dmctx, param_fastest_host, serverselection.fasthost, "string", NULL, 0);
add_list_paramameter(dmctx, param_average_response_time, serverselection.average_response_time, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_minimum_response_time, serverselection.minimum_response_time, "unsignedInt", NULL, 0);
add_list_paramameter(dmctx, param_maximum_response_time, serverselection.maximum_response_time, "unsignedInt", NULL, 0);
return SUCCESS;
}
static opr_ret_t ip_diagnostics_nslookup(struct dmctx *dmctx, char *path, char *input)
{
json_object *json_res = NULL;
struct nslookup_diagnostics nslookup = {0};
struct uci_section *s = NULL;
char *status, *answertype, *hostname, *ipaddress, *dnsserverip, *responsetime;
int i = 1;
json_res = json_tokener_parse((const char *)input);
nslookup.hostname = dmjson_get_value(json_res, 1, "HostName");
if(nslookup.hostname[0] == '\0')
return UBUS_INVALID_ARGUMENTS;
nslookup.interface = dmjson_get_value(json_res, 1, "Interface");
nslookup.dnsserver = dmjson_get_value(json_res, 1, "DNSServer");
nslookup.timeout = dmjson_get_value(json_res, 1, "Timeout");
nslookup.nbofrepetition = dmjson_get_value(json_res, 1, "NumberOfRepetitions");
set_param_diagnostics("nslookupdiagnostic", "HostName", nslookup.hostname);
set_param_diagnostics("nslookupdiagnostic", "interface", nslookup.interface);
set_param_diagnostics("nslookupdiagnostic", "DNSServer", nslookup.dnsserver);
set_param_diagnostics("nslookupdiagnostic", "Timeout", nslookup.timeout);
set_param_diagnostics("nslookupdiagnostic", "NumberOfRepetitions", nslookup.nbofrepetition);
//Free uci_varstate_ctx
end_uci_varstate_ctx();
dmcmd("/bin/sh", 3, NSLOOKUP_PATH, "run", "usp");
//Allocate uci_varstate_ctx
init_uci_varstate_ctx();
nslookup.success_count = get_param_diagnostics("nslookupdiagnostic", "SuccessCount");
char *param_success_count = dmstrdup("SuccessCount");
add_list_paramameter(dmctx, param_success_count, nslookup.success_count, "unsignedInt", NULL, 0);
uci_foreach_sections_state("cwmp", "NSLookupResult", s)
{
dmasprintf(&status, "Result.%d.Status", i);
dmasprintf(&answertype, "Result.%d.AnswerType", i);
dmasprintf(&hostname, "Result.%d.HostNameReturned", i);
dmasprintf(&ipaddress, "Result.%d.IPAddresses", i);
dmasprintf(&dnsserverip, "Result.%d.DNSServerIP", i);
dmasprintf(&responsetime, "Result.%d.ResponseTime", i);
dmuci_get_value_by_section_string(s, "Status", &nslookup.status);
dmuci_get_value_by_section_string(s, "AnswerType", &nslookup.answer_type);
dmuci_get_value_by_section_string(s, "HostNameReturned", &nslookup.hostname_returned);
dmuci_get_value_by_section_string(s, "IPAddresses", &nslookup.ip_addresses);
dmuci_get_value_by_section_string(s, "DNSServerIP", &nslookup.dns_server_ip);
dmuci_get_value_by_section_string(s, "ResponseTime", &nslookup.response_time);
add_list_paramameter(dmctx, status, nslookup.status, "string­", NULL, 0);
add_list_paramameter(dmctx, answertype, nslookup.answer_type, "string­", NULL, 0);
add_list_paramameter(dmctx, hostname, nslookup.hostname_returned, "string­", NULL, 0);
add_list_paramameter(dmctx, ipaddress, nslookup.ip_addresses, "string­", NULL, 0);
add_list_paramameter(dmctx, dnsserverip, nslookup.dns_server_ip, "string­", NULL, 0);
add_list_paramameter(dmctx, responsetime, nslookup.response_time, "unsignedInt", NULL, 0);
i++;
}
return SUCCESS;
}
static struct op_cmd operate_helper[] = {
{"Device.Reboot", reboot_device},
{"Device.FactoryReset", factory_reset},
{"Device.IP.Interface.*.Reset", network_interface_reset},
{"Device.PPP.Interface.*.Reset", network_interface_reset},
{"Device.WiFi.Reset", wireless_reset},
{"Device.WiFi.AccessPoint.*.Security.Reset", ap_security_reset},
{"Device.DHCPv4.Client.*.Renew", dhcp_client_renew},
{"Device.DHCPv6.Client.*.Renew", dhcp_client_renew},
{"Device.DeviceInfo.VendorConfigFile.*.Backup", vendor_conf_backup},
{"Device.DeviceInfo.VendorConfigFile.*.Restore", vendor_conf_restore},
{"Device.WiFi.NeighboringWiFiDiagnostic", fetch_neighboring_wifi_diagnostic},
//{"Device.DeviceInfo.VendorLogFile.*.Upload", blob_parser},
{"Device.IP.Diagnostics.IPPing", ip_diagnostics_ipping},
{"Device.IP.Diagnostics.TraceRoute", ip_diagnostics_traceroute},
{"Device.IP.Diagnostics.DownloadDiagnostics", ip_diagnostics_download},
{"Device.IP.Diagnostics.UploadDiagnostics", ip_diagnostics_upload},
{"Device.IP.Diagnostics.UDPEchoDiagnostics", ip_diagnostics_udpecho},
{"Device.IP.Diagnostics.ServerSelectionDiagnostics", ip_diagnostics_serverselection},
{"Device.DNS.Diagnostics.NSLookupDiagnostics", ip_diagnostics_nslookup}
};
int operate_on_node(struct dmctx *dmctx, char *path, char *input)
{
uint8_t len = 0;
len = ARRAY_SIZE(operate_helper);
for(uint8_t i=0; i<len; i++) {
if(match(path, operate_helper[i].name)) {
return(operate_helper[i].opt(dmctx, path, input));
}
}
return CMD_NOT_FOUND;
}

230
dmoperate.h Normal file
View file

@ -0,0 +1,230 @@
/*
* dmoperate.c: Operate handler for uspd
*
* Copyright (C) 2019 iopsys Software Solutions AB. All rights reserved.
*
* Author: Vivek Dutta <vivek.dutta@iopsys.eu>
* Author: Yashvardhan <y.yashvardhan@iopsys.eu>
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef __DMOPERATE_H__
#define __DMOPERATE_H__
#include <sys/param.h>
#define SYSTEM_UBUS_PATH "system"
#define NETWORK_INTERFACE_UBUS_PATH "network.interface"
#define NETWORK_WIRELESS_UBUS_PATH "network.wireless"
#define ROUTER_WIRELESS_UBUS_PATH "router.wireless"
#define ICWMP_SCRIPT "/usr/sbin/icwmp"
#define VCF_FILE_TYPE "3"
enum operate_ret_status{
UBUS_INVALID_ARGUMENTS,
SUCCESS,
FAIL,
CMD_NOT_FOUND,
__STATUS_MAX,
};
typedef enum operate_ret_status opr_ret_t;
typedef opr_ret_t (*operation) (struct dmctx *dmctx, char *p, char *input);
struct wifi_security_params {
char node[MAXNAMLEN];
char *param;
char value[MAXNAMLEN];
};
struct file_server {
char *url;
char *user;
char *pass;
};
struct neighboring_wiFi_diagnostic {
char *radio;
char *ssid;
char *bssid;
char *channel;
char *frequency;
char *encryption_mode;
char *operating_frequency_band;
char *supported_standards;
char *operating_standards;
char *operating_channel_bandwidth;
char *signal_strength;
char *noise;
};
struct ipping_diagnostics {
char *host;
char *interface;
char *proto;
char *nbofrepetition;
char *timeout;
char *datablocksize;
char *dscp;
char *success_count;
char *failure_count;
char *average_response_time;
char *minimum_response_time;
char *maximum_response_time;
char *average_response_time_detailed;
char *minimum_response_time_detailed;
char *maximum_response_time_detailed;
};
struct traceroute_diagnostics {
char *host;
char *interface;
char *proto;
char *nboftries;
char *timeout;
char *datablocksize;
char *dscp;
char *maxhops;
char *response_time;
char *host_name;
char *host_address;
char *rttimes;
};
struct download_diagnostics {
char *interface;
char *download_url;
char *dscp;
char *ethernet_priority;
char *proto;
char *num_of_connections;
char *enable_per_connection_results;
char *romtime;
char *bomtime;
char *eomtime;
char *test_bytes_received;
char *total_bytes_received;
char *total_bytes_sent;
char *test_bytes_received_under_full_loading;
char *total_bytes_received_under_full_loading;
char *total_bytes_sent_under_full_loading;
char *period_of_full_loading;
char *tcp_open_request_time;
char *tcp_open_response_time;
char *per_conn_romtime;
char *per_conn_bomtime;
char *per_conn_eomtime;
char *per_conn_test_bytes_received;
char *per_conn_total_bytes_received;
char *per_conn_total_bytes_sent;
char *per_conn_period_of_full_loading;
char *per_conn_tcp_open_request_time;
char *per_conn_tcp_open_response_time;
};
struct upload_diagnostics {
char *interface;
char *upload_url;
char *dscp;
char *ethernet_priority;
char *test_file_length;
char *proto;
char *num_of_connections;
char *enable_per_connection_results;
char *romtime;
char *bomtime;
char *eomtime;
char *test_bytes_sent;
char *total_bytes_received;
char *total_bytes_sent;
char *test_bytes_sent_under_full_loading;
char *total_bytes_received_under_full_loading;
char *total_bytes_sent_under_full_loading;
char *period_of_full_loading;
char *tcp_open_request_time;
char *tcp_open_response_time;
char *per_conn_romtime;
char *per_conn_bomtime;
char *per_conn_eomtime;
char *per_conn_test_bytes_sent;
char *per_conn_total_bytes_received;
char *per_conn_total_bytes_sent;
char *per_conn_period_of_full_loading;
char *per_conn_tcp_open_request_time;
char *per_conn_tcp_open_response_time;
};
struct udpecho_diagnostics {
char *host;
char *interface;
char *port;
char *nbofrepetition;
char *timeout;
char *datablocksize;
char *dscp;
char *inter_transmission_time;
char *response_time;
char *proto;
char *success_count;
char *failure_count;
char *average_response_time;
char *minimum_response_time;
char *maximum_response_time;
};
struct serverselection_diagnostics {
char *interface;
char *protocol_version;
char *proto;
char *hostlist;
char *port;
char *nbofrepetition;
char *timeout;
char *fasthost;
char *average_response_time;
char *minimum_response_time;
char *maximum_response_time;
};
struct nslookup_diagnostics {
char *interface;
char *hostname;
char *dnsserver;
char *timeout;
char *nbofrepetition;
char *success_count;
char *status;
char *answer_type;
char *hostname_returned;
char *ip_addresses;
char *dns_server_ip;
char *response_time;
};
struct op_cmd {
char *name;
operation opt;
};
int operate_on_node(struct dmctx *dmctx, char *path, char *input);
#endif

173
dmtree/tr064/upnp_common.c Executable file
View file

@ -0,0 +1,173 @@
#include "upnp_common.h"
#include "dmcwmp.h"
#include "dmuci.h"
#include "dmubus.h"
#include "dmjson.h"
#include "dmcommon.h"
#include <json-c/json.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int upnp_get_NetworkInterfaceNumberOfEntries(){
int n = 0;
struct uci_section *s = NULL;
uci_foreach_sections("network", "interface", s) {
n++;
}
return n;
}
int upnp_get_IPInterfaceNumberOfEntries(){
char *value1 = NULL, *value2 = NULL;
int n = 0;
struct uci_section *s = NULL;
uci_foreach_sections("network", "interface", s) {
dmuci_get_value_by_section_string(s, "ipaddr", &value1);
if(value1 !=NULL && strlen(value1)>0) {
n++;
continue;
}
dmuci_get_value_by_section_string(s, "proto", &value2);
if(value2 !=NULL && strlen(value2)>0 && strstr(value2, "dhcp") != NULL) {
n++;
continue;
}
}
return n;
}
char *upnp_get_softwareversion()
{
char *v=NULL, *tmp=NULL, *val=NULL;
db_get_value_string("hw", "board", "iopVersion", &v);
tmp = dmstrdup(v);// MEM WILL BE FREED IN DMMEMCLEAN
if(!tmp) return NULL;
val = tmp;
return val;
}
void upnp_getMacAddress(char *interfaceName, char **macAddress){
json_object *res = NULL, *res1 =NULL;
int length;
char *device = NULL;
char **devices =NULL;
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", interfaceName}}, 1, &res);
if(!(res)) goto not_found;
device = dmjson_get_value(res, 1, "device");
devices = strsplit(device, " ", &length);
dmubus_call("network.device", "status", UBUS_ARGS{{}}, 0, &res1);
if(!(res1)) goto not_found;
*macAddress = dmjson_get_value(res1, 2, devices[0], "macaddr");
not_found:
return;
}
void upnp_getInterfaceStatus(char *interfaceName, char **status){
json_object *res= NULL;
char *up= NULL;
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", interfaceName}}, 1, &res);
if (res == NULL) {
*status = NULL;
goto end_bloc;
}
up = dm_ubus_get_value(res, 1, "up");
if(up == NULL) {
*status = NULL;
goto end_bloc;
}
if(!strcmp(up,"true")) dmasprintf(status, "UP"); else dmasprintf(status, "DOWN");
end_bloc:
return;
}
int upnp_getInterfaceTotalPacketSent(char *interfaceName, char **totalPktSent){
json_object *res= NULL, *res1= NULL, *res2= NULL;
char *device = NULL, *tx_packets = NULL;
int length;
char **devices = NULL;
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", interfaceName}}, 1, &res);
if(res == NULL) {
*totalPktSent = NULL;
goto end_bloc;
}
device = dmjson_get_value(res, 1, "device");
if(device == NULL || strlen(device)<=0){
*totalPktSent = NULL;
goto end_bloc;
}
devices = strsplit(device, " ", &length);
dmubus_call("network.device", "status", UBUS_ARGS{{"name", devices[0]}}, 1, &res1);
if(res1 == NULL){
*totalPktSent = NULL;
goto end_bloc;
}
DM_ASSERT(res1, *totalPktSent = "");
*totalPktSent = dmjson_get_value(res1, 2, "statistics", "tx_packets");
end_bloc:
return 0;
}
int upnp_getInterfaceTotalPacketReceived(char *interfaceName, char **totalPktReceived){
json_object *res= NULL, *res1= NULL, *res2= NULL;
char *device = NULL, *rx_packets = NULL;
int length;
char **devices = NULL;
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", interfaceName}}, 1, &res);
if(res == NULL){
*totalPktReceived = NULL;
goto end_bloc;
}
device = dmjson_get_value(res, 1, "device");
if(device == NULL || strlen(device)<=0){
*totalPktReceived = NULL;
goto end_bloc;
}
devices = strsplit(device, " ", &length);
dmubus_call("network.device", "status", UBUS_ARGS{{"name", devices[0]}}, 1, &res1);
if(res1 == NULL){
*totalPktReceived = NULL;
goto end_bloc;
}
DM_ASSERT(res1, *totalPktReceived = "");
*totalPktReceived = dmjson_get_value(res1, 2, "statistics", "rx_packets");
end_bloc:
return 0;
}
char *upnp_get_deviceid_manufactureroui()
{
char *v = NULL;
char str[16];
char *mac = NULL;
json_object *res= NULL;
size_t ln;
dmubus_call("router.system", "info", UBUS_ARGS{{}}, 0, &res);
if(!(res)) goto not_found;
mac = dmjson_get_value(res, 2, "system", "basemac");
if(mac)
{
ln = strlen(mac);
if (ln<17) goto not_found;
sscanf (mac,"%2c:%2c:%2c",str,str+2,str+4);
str[6] = '\0';
v = dmstrdup(str); // MEM WILL BE FREED IN DMMEMCLEAN
return v;
}
not_found:
v = "";
return v;
}

11
dmtree/tr064/upnp_common.h Executable file
View file

@ -0,0 +1,11 @@
#ifndef UPNP_COMMON_H
#define UPNP_COMMON_H
char *upnp_get_softwareversion();
int upnp_get_NetworkInterfaceNumberOfEntries();
int upnp_get_IPInterfaceNumberOfEntries();
void upnp_getMacAddress(char *interfaceName, char **macAddress);
void upnp_getInterfaceStatus(char *interfaceName, char **status);
int upnp_getInterfaceTotalPacketSent(char *interfaceName, char **totalPktSent);
int upnp_getInterfaceTotalPacketReceived(char *interfaceName, char **totalPktReceived);
char *upnp_get_deviceid_manufactureroui();
#endif

307
dmtree/tr064/upnp_configuration.c Executable file
View file

@ -0,0 +1,307 @@
#include "dmcwmp.h"
#include "upnp_configuration.h"
#include "upnp_common.h"
#include "dmuci.h"
#include "dmubus.h"
#include "dmcommon.h"
#include "dmjson.h"
#include <stdio.h>
#include <stdlib.h>
#define DELIMITOR ","
/**************************************************************************
*
* /UPnP/DM/Configuration/ datamodel tree
*
***************************************************************************/
/*** /UPnP/DM/Configuration/ objects ***/
DMOBJ upnpConfigurationObj[] = {
{"Network",&DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE, upnpConfigurationNetworkObj, upnpConfigurationNetworkParams, NULL},
{0}
};
/*** /UPnP/DM/Configuration/Network objects ***/
DMOBJ upnpConfigurationNetworkObj[] = {
{"IPInterface",&DMWRITE, upnp_configuration_ipinterface_createinstance, upnp_configuration_ipinterface_deleteinstance, NULL, upnp_browseIPInterfaceInst, &DMFINFRM, &DMNONE, upnpConfigurationNetworkIPInterfaceObj, upnpConfigurationNetworkIPInterfaceParams, NULL},
{0}
};
/*** /UPnP/DM/Configuration/Network parameters ***/
DMLEAF upnpConfigurationNetworkParams[]= {
{"HostName", &DMWRITE, DMT_STRING, upnp_configuration_get_hostname, upnp_configuration_set_hostname, &DMFINFRM, NULL},
{"IPInterfaceNumberOfEntries", &DMREAD, DMT_UNINT, upnp_configuration_get_IPInterfaceNumberOfEntries, NULL, &DMFINFRM, NULL},
{0}
};
/*** /UPnP/DM/Configuration/Network/IPInterface/#/ objects ***/
DMOBJ upnpConfigurationNetworkIPInterfaceObj[]= {
{"IPv4",&DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE, NULL, upnpConfigurationNetworkIPInterfaceIpv4Params, NULL},
{0}
};
/*** /UPnP/DM/Configuration/Network/IPInterface/#/ parameters ***/
DMLEAF upnpConfigurationNetworkIPInterfaceParams[]= {
{"SystemName", &DMREAD, DMT_STRING, upnp_configuration_get_SystemName, NULL, &DMFINFRM, NULL},
{0}
};
/*** /UPnP/DM/Configuration/Network/IPInterface/#/IPv4/ parameters ***/
DMLEAF upnpConfigurationNetworkIPInterfaceIpv4Params[]= {
{"IPAddress", &DMWRITE, DMT_STRING, upnp_configuration_get_ipv4_IPAddress, upnp_configuration_set_ipv4_IPAddress, &DMFINFRM, NULL},
{"AddressingType", &DMWRITE, DMT_STRING, upnp_configuration_get_ipv4_addressingtype, upnp_configuration_set_ipv4_addressingtype, &DMFINFRM, NULL},
{"DNSServers", &DMWRITE, DMT_STRING, upnp_configuration_get_ipv4_dnssevers, upnp_configuration_set_ipv4_dnssevers, &DMFINFRM, NULL},
{"SubnetMask", &DMWRITE, DMT_STRING, upnp_configuration_get_ipv4_subnetmask, upnp_configuration_set_ipv4_subnetmask, &DMFINFRM, NULL},
{"DefaultGateway", &DMWRITE, DMT_STRING, upnp_configuration_get_ipv4_defaultgateway, upnp_configuration_set_ipv4_defaultgateway, &DMFINFRM, NULL},
{0}
};
/**************************************************************************
*
* /UPnP/DM/Configuration/* parameters functions
*
***************************************************************************/
int upnp_configuration_get_hostname(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) {
return 0;
}
int upnp_configuration_get_IPInterfaceNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
int n = upnp_get_IPInterfaceNumberOfEntries();
dmasprintf(value, "%d", n);
return 0;
}
int upnp_configuration_get_SystemName(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
struct upnp_configuration_args *upnp_configargs = (struct upnp_configuration_args *)data;
if(upnp_configargs->systemName !=NULL && strlen(upnp_configargs->systemName)>0) dmasprintf(value, "%s", upnp_configargs->systemName);
return 0;
}
int upnp_configuration_get_ipv4_IPAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
struct upnp_configuration_args *upnp_configargs = (struct upnp_configuration_args *)data;
char *ipv4addr=NULL;
dmuci_get_value_by_section_string(upnp_configargs->upnpConfiguration_sec, "ipaddr", &ipv4addr);
if(ipv4addr!=NULL && strlen(ipv4addr)> 0) dmasprintf(value, "%s", ipv4addr);
return 0;
}
int upnp_configuration_get_ipv4_addressingtype(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
char *proto=NULL;
struct upnp_configuration_args *upnp_configargs = (struct upnp_configuration_args *)data;
dmuci_get_value_by_section_string(upnp_configargs->upnpConfiguration_sec, "proto", &proto);
if(proto!=NULL && strlen(proto)>0 && strstr(proto,"dhcp")) dmasprintf(value, "%s", "DHCP");
else dmasprintf(value, "%s", "Static");
return 0;
}
int upnp_configuration_get_ipv4_dnssevers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
json_object *res= NULL;
struct upnp_configuration_args *upnp_configargs = (struct upnp_configuration_args *)data;
char *iface_name = section_name(upnp_configargs->upnpConfiguration_sec);
if(iface_name==NULL || strlen(iface_name)<=0) {
*value = NULL;
return 0;
}
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", iface_name}}, 1, &res);
if(res == NULL) {
*value = NULL;
return 0;
}
DM_ASSERT(res, *value = "");
*value = dmjson_get_value_array_all(res, DELIMITOR, 1, "dns-server");
if ((*value)[0] == '\0') {
dmuci_get_value_by_section_string(upnp_configargs->upnpConfiguration_sec, "dns", value);
*value = dmstrdup(*value); // MEM WILL BE FREED IN DMMEMCLEAN
char *p = *value;
while (*p) {
if (*p == ' ' && p != *value && *(p-1) != ',')
*p++ = ',';
else
p++;
}
}
return 0;
}
int upnp_configuration_get_ipv4_subnetmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
struct upnp_configuration_args *upnp_configargs = (struct upnp_configuration_args *)data;
char *netmask = NULL;
dmuci_get_value_by_section_string(upnp_configargs->upnpConfiguration_sec, "netmask", &netmask);
if(netmask!=NULL && strlen(netmask)>0) dmasprintf(value, "%s", netmask);
else *value =NULL;
return 0;
}
int upnp_configuration_get_ipv4_defaultgateway(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
struct upnp_configuration_args *upnp_configargs = (struct upnp_configuration_args *)data;
FILE* fp = NULL;
struct proc_routing proute = {0};
char line[MAX_PROC_ROUTING];
fp = fopen(ROUTING_FILE, "r");
if ( fp != NULL)
{
fgets(line, MAX_PROC_ROUTING, fp);
while (fgets(line, MAX_PROC_ROUTING, fp) != NULL )
{
if (line[0] == '\n')
continue;
parse_proc_route_line(line, &proute);
if(!strcmp(proute.iface, upnp_configargs->systemName)) {
if(proute.gateway!=NULL && strlen(proute.gateway)>0) dmasprintf(value, "%s", proute.gateway);
return 0;
}
else continue;
}
fclose(fp) ;
}
return 0;
}
int upnp_configuration_set_hostname(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action){
return 0;
}
int upnp_configuration_set_ipv4_IPAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action){
struct upnp_configuration_args *upnp_configargs = (struct upnp_configuration_args *)data;
char *proto= NULL;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_get_value_by_section_string(upnp_configargs->upnpConfiguration_sec, "proto", &proto);
if(proto == NULL || strlen(proto)<=0) return 0;
if(strcmp(proto, "static") == 0)
dmuci_set_value_by_section(upnp_configargs->upnpConfiguration_sec, "ipaddr", value);
return 0;
}
return 0;
}
int upnp_configuration_set_ipv4_addressingtype(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action){
struct upnp_configuration_args *upnp_configargs = (struct upnp_configuration_args *)data;
char *proto= NULL;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
if(strcasecmp(value, "static") == 0) {
dmuci_set_value_by_section(upnp_configargs->upnpConfiguration_sec, "proto", "static");
dmuci_set_value_by_section(upnp_configargs->upnpConfiguration_sec, "ipaddr", "0.0.0.0");
}
if(strcasecmp(value, "dhcp") == 0) {
dmuci_set_value_by_section(upnp_configargs->upnpConfiguration_sec, "proto", "dhcp");
dmuci_set_value_by_section(upnp_configargs->upnpConfiguration_sec, "ipaddr", "");
}
return 0;
}
return 0;
}
int upnp_configuration_set_ipv4_dnssevers(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action){
struct upnp_configuration_args *upnp_configargs = (struct upnp_configuration_args *)data;
char *dup= NULL, *p= NULL;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dup = dmstrdup(value);
p = dup;
while (*p) {
if (*p == ',')
*p++ = ' ';
else
p++;
}
dmuci_set_value_by_section(upnp_configargs->upnpConfiguration_sec, "dns", dup);
dmfree(dup);
return 0;
}
return 0;
}
int upnp_configuration_set_ipv4_subnetmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action){
struct upnp_configuration_args *upnp_configargs = (struct upnp_configuration_args *)data;
char *proto = NULL;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_get_value_by_section_string(upnp_configargs->upnpConfiguration_sec, "proto", &proto);
if(proto == NULL || strlen(proto)<=0) return 0;
if(strcmp(proto, "static") == 0)
dmuci_set_value_by_section(upnp_configargs->upnpConfiguration_sec, "netmask", value);
return 0;
}
return 0;
}
int upnp_configuration_set_ipv4_defaultgateway(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action){
struct upnp_configuration_args *upnp_configargs = (struct upnp_configuration_args *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(upnp_configargs->upnpConfiguration_sec, "gateway", value);
return 0;
}
return 0;
}
int upnp_configuration_ipinterface_createinstance(char *refparam, struct dmctx *ctx, void *data, char **instance){
char *value=NULL;
char *iface_instance=NULL, ib[8], ip_name[32];
char *p = ip_name;
struct uci_section *iface_sec = NULL;
iface_instance = get_last_instance("network","interface","upnp_ip_iface_instance");
sprintf(ib, "%d", iface_instance ? atoi(iface_instance)+1 : 1);
dmstrappendstr(p, "ip_interface_");
dmstrappendstr(p, ib);
dmstrappendend(p);
dmuci_add_section_and_rename("network", "interface", &iface_sec, &value);
dmuci_set_value("network", ip_name, "", "interface");
dmuci_set_value("network", ip_name, "proto", "dhcp");
*instance = update_instance(iface_sec, iface_instance, "upnp_ip_iface_instance");
return 0;
}
int upnp_configuration_ipinterface_deleteinstance(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action){
struct upnp_configuration_args *upnp_configargs = (struct upnp_configuration_args *)data;
switch (del_action) {
case DEL_INST:
if(upnp_configargs->upnpConfiguration_sec == NULL) return FAULT_9005;
dmuci_delete_by_section(upnp_configargs->upnpConfiguration_sec, NULL, NULL);
break;
case DEL_ALL:
return FAULT_9005;
}
return 0;
}
int upnp_browseIPInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance){
char *value1, *value2;
struct uci_section *net_sec = NULL;
char *iface_int = NULL, *iface_int_last = NULL;
struct upnp_configuration_args currUpnpConfigurationArgs = {0};
char *type=NULL, *ipv4addr = "", *ipv6addr = "", *proto, *inst;
char *value= NULL, *netmask = NULL;
json_object *res = NULL, *res1 = NULL;
uci_foreach_sections("network", "interface", net_sec) {
currUpnpConfigurationArgs.upnpConfiguration_sec = net_sec;
currUpnpConfigurationArgs.systemName = section_name(net_sec);
dmuci_get_value_by_section_string(net_sec, "netmask", &netmask);
iface_int = handle_update_instance(1, dmctx, &iface_int_last, update_instance_alias, 3, net_sec, "upnp_ip_iface_instance", "upnp_ip_iface_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&currUpnpConfigurationArgs, iface_int) == DM_STOP) break;
}
return 0;
}

View file

@ -0,0 +1,59 @@
#ifndef UPNP_CONFIGURATION_H
#define UPNP_CONFIGURATION_H
#include "dmcwmp.h"
struct upnp_configuration_args{
struct uci_section *upnpConfiguration_sec;
char *systemName;
char *ipv4address;
char *ipv6address;
char *addressingType;
char *ipAddressType;
char *prefix;
char **dnsservers;
char *netmask;
char *gateway;
int numberOfEntries;
};
int upnp_configuration_get_hostname(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_configuration_get_IPInterfaceNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_configuration_get_SystemName(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_configuration_get_ipv4_IPAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_configuration_get_ipv4_addressingtype(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_configuration_get_ipv4_dnssevers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_configuration_get_ipv4_subnetmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_configuration_get_ipv4_defaultgateway(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_configuration_get_ipv6_addressnumberofentries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_configuration_get_ipv6_dnsservers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_configuration_get_ipv6_defaultgateway(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_configuration_get_ipv6_IPAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_configuration_get_ipv6_IPAddressType(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_configuration_get_ipv6_addressingtype(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_configuration_get_ipv6_Prefix(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_configuration_set_hostname(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int upnp_configuration_set_ipv4_IPAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int upnp_configuration_set_ipv4_addressingtype(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int upnp_configuration_set_ipv4_dnssevers(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int upnp_configuration_set_ipv4_subnetmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int upnp_configuration_set_ipv4_defaultgateway(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int upnp_configuration_ipinterface_createinstance(char *refparam, struct dmctx *ctx, void *data, char **instance);
int upnp_configuration_ipinterface_deleteinstance(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int upnp_configuration_address_createinstance(char *refparam, struct dmctx *ctx, void *data, char **instance);
int upnp_configuration_address_deleteinstance(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int upnp_browseIPInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int upnp_browseIPv6Address(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
extern DMOBJ upnpConfigurationNetworkObj[];
extern DMLEAF upnpConfigurationNetworkParams[];
extern DMLEAF upnpConfigurationNetworkObjParams[];
extern DMOBJ upnpConfigurationNetworkIPInterfaceObj[];
extern DMLEAF upnpConfigurationNetworkIPInterfaceParams[];
extern DMLEAF upnpConfigurationNetworkIPInterfaceIpv4Params[];
extern DMOBJ upnpConfigurationNetworkIPInterfaceIpv6Obj[];
extern DMLEAF upnpConfigurationNetworkIPInterfaceIpv6Params[];
extern DMOBJ upnpConfigurationNetworkIPInterfaceIpv6AddressParams[];
extern DMOBJ upnpConfigurationObj[];
#endif

264
dmtree/tr064/upnp_device.c Normal file
View file

@ -0,0 +1,264 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
* Author: Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*/
#include "dmuci.h"
#include "dmcwmp.h"
#include "upnp_device.h"
#include "deviceinfo.h"
#include "managementserver.h"
#include "times.h"
#include "upnp.h"
#if BBF_TR104
#include "voice_services.h"
#endif
#include "x_iopsys_eu_ice.h"
#include "x_iopsys_eu_igmp.h"
#include "x_iopsys_eu_ipacccfg.h"
#include "x_iopsys_eu_logincfg.h"
#include "x_iopsys_eu_power_mgmt.h"
#include "x_iopsys_eu_syslog.h"
#include "softwaremodules.h"
#include "xmpp.h"
#include "x_iopsys_eu_owsd.h"
#include "x_iopsys_eu_dropbear.h"
#include "x_iopsys_eu_buttons.h"
#include "x_iopsys_eu_wifilife.h"
#include "ip.h"
#include "ethernet.h"
#include "bridging.h"
#include "wifi.h"
#include "atm.h"
#include "ptm.h"
#include "dhcpv4.h"
#include "hosts.h"
#include "nat.h"
#include "ppp.h"
#include "routing.h"
#include "userinterface.h"
#include "landevice.h"
#include "wandevice.h"
#include "ippingdiagnostics.h"
#include "lan_interfaces.h"
#include "layer_3_forwarding.h"
#include "x_iopsys_eu_wifi.h"
#include "layer_2_bridging.h"
#include "downloaddiagnostic.h"
#include "uploaddiagnostic.h"
#include "deviceconfig.h"
#include "firewall.h"
#include "dns.h"
#include "users.h"
#include "dsl.h"
#include "dhcpv6.h"
#include "interfacestack.h"
#include "qos.h"
#ifdef BBF_TR064
#include "upnp_deviceinfo.h"
#include "upnp_configuration.h"
#include "upnp_monitoring.h"
#endif
/*** UPNP ***/
#ifdef BBF_TR064
DMOBJ tEntry098ObjUPNP[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{(char *)&dmroot, &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE, tRoot098ObjUPNP, NULL, NULL, BBFDM_BOTH},
{0}
};
DMOBJ tRoot098ObjUPNP[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{"BBF", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE, tRoot098ObjUPNPBBF, NULL, NULL, BBFDM_BOTH},
{"UPnP", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE, tRoot098ObjUPNPDMROOT, NULL, NULL, BBFDM_BOTH},
{0}
};
DMOBJ tRoot098ObjUPNPDMROOT[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{"DM", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE, tRoot098ObjUPNPDM, NULL, NULL, BBFDM_BOTH},
{0}
};
DMOBJ tRoot098ObjUPNPDM[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{"DeviceInfo", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,upnpDeviceInfoObj, upnpDeviceInfoParams, NULL, BBFDM_BOTH},
{"Configuration", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,upnpConfigurationObj, NULL, NULL, BBFDM_BOTH},
{"Monitoring", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,upnpMonitoringObj, upnpMonitoringParams, NULL, BBFDM_BOTH},
{0}
};
DMOBJ tRoot098ObjUPNPBBF[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{"DeviceInfo", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,tDeviceInfoObj, tDeviceInfoParams, NULL, BBFDM_BOTH},
{"ManagementServer", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,NULL, tManagementServerParams, NULL, BBFDM_BOTH},
{"Time", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tTimeParams, NULL, BBFDM_BOTH},
{"UPnP", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,tUPnPObj, NULL, NULL, BBFDM_BOTH},
#if BBF_TR104
{"VoiceService", &DMREAD, NULL, NULL, NULL, browseVoiceServiceInst, NULL, NULL, tVoiceServiceObj, tVoiceServiceParam, NULL, BBFDM_BOTH},
#endif
{CUSTOM_PREFIX"ICE", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tSe_IceParam, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"IGMP", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tSe_IgmpParam, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"IpAccCfg", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,tSe_IpAccObj, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"LoginCfg", &DMREAD, NULL, NULL, NULL, NULL,NULL, &DMNONE,NULL, tSe_LoginCfgParam, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"PowerManagement", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tSe_PowerManagementParam, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"SyslogCfg", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tSe_SyslogCfgParam, NULL, BBFDM_BOTH},
{"SoftwareModules", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,tSoftwareModulesObj, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"Owsd", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,XIopsysEuOwsdObj, XIopsysEuOwsdParams, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"Dropbear", &DMWRITE, add_dropbear_instance, delete_dropbear_instance, NULL, browseXIopsysEuDropbear, NULL, &DMNONE, NULL, X_IOPSYS_EU_DropbearParams, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"Buttons", &DMREAD, NULL, NULL, NULL, browseXIopsysEuButton, NULL, &DMNONE, NULL, X_IOPSYS_EU_ButtonParams, NULL, BBFDM_BOTH},
{"LANDevice", &DMREAD, NULL, NULL, NULL, browselandeviceInst, &DMFINFRM, &DMNONE,tLANDeviceObj, tLANDeviceParam, NULL, BBFDM_BOTH},
{"WANDevice", &DMREAD, NULL, NULL, NULL, browsewandeviceInst, &DMFINFRM, &DMWANConnectionDevicenotif,tWANDeviceObj, tWANDeviceParam, NULL, BBFDM_BOTH},
{"LANInterfaces", &DMREAD, NULL, NULL, check_laninterfaces, NULL, &DMFINFRM, &DMNONE,tLANInterfacesObj, tLANInterfacesParam, NULL, BBFDM_BOTH},
{"IPPingDiagnostics", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,NULL, tIPPingDiagnosticsParam, NULL, BBFDM_BOTH},
{"Layer3Forwarding", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,tLayer3ForwardingObj, tLayer3ForwardingParam, NULL, BBFDM_BOTH},
{"Layer2Bridging", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,tLayer2BridgingObj, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"Wifi", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,tsewifiObj, NULL, NULL, BBFDM_BOTH},
{"DownloadDiagnostics", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,NULL, tDownloadDiagnosticsParam, NULL, BBFDM_BOTH},
{"UploadDiagnostics", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,NULL, tUploadDiagnosticsParam, NULL, BBFDM_BOTH},
{"XMPP", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL,tXMPPObj, tXMPPParams, NULL, BBFDM_BOTH},
{0}
};
DMOBJ tEntry181ObjUPNP[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{(char *)&dmroot, &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE, tRoot181ObjUPNP, NULL, NULL, BBFDM_BOTH},
{0}
};
DMOBJ tRoot181ObjUPNP[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{"BBF", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE, tRoot181ObjUPNPBBF, NULL, NULL, BBFDM_BOTH},
{"UPnP", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE, tRoot181ObjUPNPDMROOT, NULL, NULL, BBFDM_BOTH},
{0}
};
DMOBJ tRoot181ObjUPNPDMROOT[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{"DM", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE, tRoot181ObjUPNPDM, NULL, NULL, BBFDM_BOTH},
{0}
};
DMOBJ tRoot181ObjUPNPDM[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{"DeviceInfo", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,upnpDeviceInfoObj, upnpDeviceInfoParams, NULL, BBFDM_BOTH},
{"Configuration", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,upnpConfigurationObj, NULL, NULL, BBFDM_BOTH},
{"Monitoring", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,upnpMonitoringObj, upnpMonitoringParams, NULL, BBFDM_BOTH},
{0}
};
DMOBJ tRoot181ObjUPNPBBF[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{"DeviceInfo", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,tDeviceInfoObj, tDeviceInfoParams, NULL, BBFDM_BOTH},
{"ManagementServer", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,NULL, tManagementServerParams, NULL, BBFDM_BOTH},
{"Time", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tTimeParams, NULL, BBFDM_BOTH, BBFDM_BOTH},
{"UPnP", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,tUPnPObj, NULL, NULL, BBFDM_BOTH},
#if BBF_TR104
{"VoiceService", &DMREAD, NULL, NULL, NULL, browseVoiceServiceInst, NULL, NULL, tVoiceServiceObj, tVoiceServiceParam, NULL, BBFDM_BOTH},
#endif
{CUSTOM_PREFIX"ICE", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tSe_IceParam, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"IGMP", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tSe_IgmpParam, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"IpAccCfg", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,tSe_IpAccObj, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"LoginCfg", &DMREAD, NULL, NULL, NULL, NULL,NULL, &DMNONE,NULL, tSe_LoginCfgParam, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"PowerManagement", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tSe_PowerManagementParam, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"SyslogCfg", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tSe_SyslogCfgParam, NULL, BBFDM_BOTH},
{"SoftwareModules", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,tSoftwareModulesObj, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"Owsd", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,XIopsysEuOwsdObj, XIopsysEuOwsdParams, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"Dropbear", &DMWRITE, add_dropbear_instance, delete_dropbear_instance, NULL, browseXIopsysEuDropbear, NULL, &DMNONE, NULL, X_IOPSYS_EU_DropbearParams, NULL, BBFDM_BOTH, BBFDM_BOTH},
{CUSTOM_PREFIX"Buttons", &DMREAD, NULL, NULL, NULL, browseXIopsysEuButton, NULL, &DMNONE, NULL, X_IOPSYS_EU_ButtonParams, NULL, BBFDM_BOTH},
{"Bridging",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tBridgingObj, NULL, NULL, BBFDM_BOTH},
{"WiFi",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tWifiObj, NULL, NULL, BBFDM_BOTH},
{"IP",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tIPObj, NULL, NULL, BBFDM_BOTH},
{"Ethernet", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tEthernetObj, NULL, NULL, BBFDM_BOTH},
{"DSL",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDslObj, NULL, NULL, BBFDM_BOTH},
{"ATM",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tAtmObj, NULL, NULL, BBFDM_BOTH},
{"PTM", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tPtmObj, NULL, NULL, BBFDM_BOTH},
{"DHCPv4", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDhcpv4Obj, NULL, NULL, BBFDM_BOTH},
{"Hosts", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, thostsObj, thostsParam, NULL, BBFDM_BOTH},
{"NAT", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tnatObj, NULL, NULL, BBFDM_BOTH},
{"PPP", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tpppObj, NULL, NULL, BBFDM_BOTH},
{"Routing", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tRoutingObj, tRoutingParam, NULL, BBFDM_BOTH},
{"XMPP", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL,tXMPPObj, tXMPPParams, NULL, BBFDM_BOTH},
{0}
};
UPNP_SUPPORTED_DM tUPNPSupportedDM[];
UPNP_SUPPORTED_DM tUPNPSupportedDM_098[] = {
{"/UPnP/DM/DeviceInfo/", "urn:UPnP:Parent Device:1:ConfigurationManagement:2", DMROOT_URL_098, "UPnP DeviceInfo from "DMROOT_DESC_098, ""},
{"/UPnP/DM/Configuration/", "urn:UPnP:Parent Device:1:ConfigurationManagement:2", DMROOT_URL_098, "Configuration from "DMROOT_DESC_098, ""},
{"/UPnP/DM/Monitoring/", "urn:UPnP:Parent Device:1:ConfigurationManagement:2", DMROOT_URL_098, "Monitoring from "DMROOT_DESC_098, ""},
{"/BBF/DeviceInfo/", DMROOT_URI_098, DMROOT_URL_098, "DeviceInfo from "DMROOT_DESC_098, ""},
{"/BBF/ManagementServer/", DMROOT_URI_098, DMROOT_URL_098, "ManagementServer from "DMROOT_DESC_098, ""},
{"/BBF/Time/", DMROOT_URI_098, DMROOT_URL_098, "Time from "DMROOT_DESC_098, ""},
{"/BBF/UPnP/", DMROOT_URI_098, DMROOT_URL_098, "UPnP from "DMROOT_DESC_098, ""},
{"/BBF/VoiceService/", "urn:broadband-forum-org:wt-104-2-0-0", "https://www.broadband-forum.org/cwmp/tr-104-2-0-0.html", "TR-104 Voice:2 Service Object definition", ""},
{"/BBF/"CUSTOM_PREFIX"ICE/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for ICE", ""},
{"/BBF/"CUSTOM_PREFIX"IGMP/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for ICE", ""},
{"/BBF/"CUSTOM_PREFIX"IpAccCfg/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for IGMP", ""},
{"/BBF/"CUSTOM_PREFIX"LoginCfg/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for LoginCfg", ""},
{"/BBF/"CUSTOM_PREFIX"PowerManagement/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for PowerManagement", ""},
{"/BBF/"CUSTOM_PREFIX"SyslogCfg/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for SyslogCfg", ""},
{"/BBF/SoftwareModules/", DMROOT_URI_098, DMROOT_URL_098, "SoftwareModules from "DMROOT_DESC_098, ""},
{"/BBF/"CUSTOM_PREFIX"Owsd/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for Owsd", ""},
{"/BBF/"CUSTOM_PREFIX"Dropbear/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for Dropbear", ""},
{"/BBF/"CUSTOM_PREFIX"Buttons/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for Buttons", ""},
{"/BBF/LANDevice/", DMROOT_URI_098, DMROOT_URL_098, "LANDevice from "DMROOT_DESC_098, ""},
{"/BBF/WANDevice/", DMROOT_URI_098, DMROOT_URL_098, "WANDevice from "DMROOT_DESC_098, ""},
{"/BBF/LANInterfaces/", DMROOT_URI_098, DMROOT_URL_098, "LANInterfaces from "DMROOT_DESC_098, ""},
{"/BBF/IPPingDiagnostics/", DMROOT_URI_098, DMROOT_URL_098, "IPPingDiagnostics from "DMROOT_DESC_098, ""},
{"/BBF/Layer3Forwarding/", DMROOT_URI_098, DMROOT_URL_098, "Layer3Forwarding from "DMROOT_DESC_098, ""},
{"/BBF/Layer2Bridging/", DMROOT_URI_098, DMROOT_URL_098, "Layer2Bridging from "DMROOT_DESC_098, ""},
{"/BBF/"CUSTOM_PREFIX"Wifi/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for WiFi", ""},
{"/BBF/DownloadDiagnostics/", DMROOT_URI_098, DMROOT_URL_098, "DownloadDiagnostics from "DMROOT_DESC_098, ""},
{"/BBF/UploadDiagnostics/", DMROOT_URI_098, DMROOT_URL_098, "UploadDiagnostics from "DMROOT_DESC_098, ""},
{"/BBF/XMPP/", DMROOT_URI_098, DMROOT_URL_098, "XMPP from "DMROOT_DESC_098, ""},
{0}
};
UPNP_SUPPORTED_DM tUPNPSupportedDM_181[] = {
{"/UPnP/DM/DeviceInfo/", "urn:UPnP:Parent Device:1:ConfigurationManagement:2", DMROOT_URL_181, "UPnP DeviceInfo from "DMROOT_DESC_181, ""},
{"/UPnP/DM/Configuration/", "urn:UPnP:Parent Device:1:ConfigurationManagement:2", DMROOT_URL_181, "Configuration from "DMROOT_DESC_181, ""},
{"/UPnP/DM/Monitoring/", "urn:UPnP:Parent Device:1:ConfigurationManagement:2", DMROOT_URL_181, "Monitoring from "DMROOT_DESC_181, ""},
{"/BBF/DeviceInfo/", DMROOT_URI_181, DMROOT_URL_181, "DeviceInfo from "DMROOT_DESC_181, ""},
{"/BBF/ManagementServer/", DMROOT_URI_181, DMROOT_URL_181, "ManagementServer from "DMROOT_DESC_181, ""},
{"/BBF/Time/", DMROOT_URI_181, DMROOT_URL_181, "Time from "DMROOT_DESC_181, ""},
{"/BBF/UPnP/", DMROOT_URI_181, DMROOT_URL_181, "UPnP from "DMROOT_DESC_181, ""},
{"/BBF/VoiceService/", "urn:broadband-forum-org:wt-104-2-0-0", "https://www.broadband-forum.org/cwmp/tr-104-2-0-0.html", "TR-104 Voice:2 Service Object definition", ""},
{"/BBF/"CUSTOM_PREFIX"ICE/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for ICE", ""},
{"/BBF/"CUSTOM_PREFIX"IGMP/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for ICE", ""},
{"/BBF/"CUSTOM_PREFIX"IpAccCfg/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for IGMP", ""},
{"/BBF/"CUSTOM_PREFIX"LoginCfg/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for LoginCfg", ""},
{"/BBF/"CUSTOM_PREFIX"PowerManagement/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for PowerManagement", ""},
{"/BBF/"CUSTOM_PREFIX"SyslogCfg/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for SyslogCfg", ""},
{"/BBF/SoftwareModules/", DMROOT_URI_181, DMROOT_URL_181, "SoftwareModules from "DMROOT_DESC_181, ""},
{"/BBF/"CUSTOM_PREFIX"Owsd/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for Owsd", ""},
{"/BBF/"CUSTOM_PREFIX"Dropbear/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for Dropbear", ""},
{"/BBF/"CUSTOM_PREFIX"Buttons/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for Buttons", ""},
{"/BBF/Bridging/", DMROOT_URI_181, DMROOT_URL_181, "Bridging from "DMROOT_DESC_181, ""},
{"/BBF/WiFi/", DMROOT_URI_181, DMROOT_URL_181, "WiFi from "DMROOT_DESC_181, ""},
{"/BBF/IP/", DMROOT_URI_181, DMROOT_URL_181, "IP from "DMROOT_DESC_181, ""},
{"/BBF/Ethernet/", DMROOT_URI_181, DMROOT_URL_181, "Ethernet from "DMROOT_DESC_181, ""},
{"/BBF/DSL/", DMROOT_URI_181, DMROOT_URL_181, "DSL from "DMROOT_DESC_181, ""},
{"/BBF/ATM/", DMROOT_URI_181, DMROOT_URL_181, "ATM from "DMROOT_DESC_181, ""},
{"/BBF/PTM/", DMROOT_URI_181, DMROOT_URL_181, "PTM from "DMROOT_DESC_181, ""},
{"/BBF/DHCPv4/", DMROOT_URI_181, DMROOT_URL_181, "DHCPv4 from "DMROOT_DESC_181, ""},
{"/BBF/Hosts/", DMROOT_URI_181, DMROOT_URL_181, "Hosts from "DMROOT_DESC_181, ""},
{"/BBF/NAT/", DMROOT_URI_181, DMROOT_URL_181, "NAT from "DMROOT_DESC_181, ""},
{"/BBF/PPP/", DMROOT_URI_181, DMROOT_URL_181, "PPP from "DMROOT_DESC_181, ""},
{"/BBF/Routing/", DMROOT_URI_181, DMROOT_URL_181, "Routing from "DMROOT_DESC_181, ""},
{"/BBF/XMPP/", DMROOT_URI_181, DMROOT_URL_181, "XMPP from "DMROOT_DESC_181, ""},
{0}
};
size_t tr98_size = sizeof(tUPNPSupportedDM_098);
size_t tr181_size = sizeof(tUPNPSupportedDM_181);
#endif

View file

@ -0,0 +1,44 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
* Author: Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*/
#ifndef __UPNPDEVICE_H
#define __UPNPDEVICE_H
#ifdef BBF_TR064
extern DMOBJ tEntry098ObjUPNP[];
extern DMOBJ tRoot098ObjUPNP[];
extern DMOBJ tRoot098ObjUPNPDMROOT[];
extern DMOBJ tRoot098ObjUPNPDM[];
extern DMOBJ tRoot098ObjUPNPBBF[];
extern DMOBJ tEntry181ObjUPNP[];
extern DMOBJ tRoot181ObjUPNP[];
extern DMOBJ tRoot181ObjUPNPDMROOT[];
extern DMOBJ tRoot181ObjUPNPDM[];
extern DMOBJ tRoot181ObjUPNPBBF[];
extern UPNP_SUPPORTED_DM tUPNPSupportedDM[];
extern UPNP_SUPPORTED_DM tUPNPSupportedDM_098[];
extern UPNP_SUPPORTED_DM tUPNPSupportedDM_181[];
extern size_t tr98_size;
extern size_t tr181_size;
#define UPNP_SUPPORTED_PARAMETERS_VERSION 1 //Should be incremented each time the Parameters are updated
#define UPNP_SUPPORTED_DATAMODEL_VERSION 1 //Should be incremented each time the tUPNPSupportedDM array is updated
#define DMROOT_URI_098 "urn:broadband-forum-org:tr-098-1-8-0"
#define DMROOT_URL_098 "https://www.broadband-forum.org/cwmp/tr-098-1-8-0.html"
#define DMROOT_DESC_098 "TR-098 InternetGatewayDevice:1 Root Object definition"
#define DMROOT_URI_181 "urn:broadband-forum-org:tr-181-2-11-0"
#define DMROOT_URL_181 "https://www.broadband-forum.org/cwmp/tr-181-2-11-0.html"
#define DMROOT_DESC_181 "TR-181 Device:2 Root Object definition"
#endif
#endif

266
dmtree/tr064/upnp_deviceinfo.c Executable file
View file

@ -0,0 +1,266 @@
#include <stdio.h>
#include "dmcwmp.h"
#include "upnp_deviceinfo.h"
#include <sys/utsname.h>
#include "dmuci.h"
#include "dmmem.h"
#include "dmcommon.h"
#include <uci.h>
#include "upnp_common.h"
#include<stdbool.h>
int upnp_browseNetworkInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
/**************************************************************************
*
* /UPnP/DM/DeviceInfo/ datamodel tree
*
***************************************************************************/
/*** /UPnP/DM/DeviceInfo/ objects ***/
DMOBJ upnpDeviceInfoObj[] ={
{"PhysicalDevice", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,upnpPhysicalDeviceObj, upnpPhysicalDeviceParams, NULL},
{"OperatingSystem",&DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,NULL, upnpOperatingSystemParams, NULL},
{"ExecutionEnvironment",&DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,NULL, upnpExecutionEnvironmentParams, NULL},
{0}
};
/*** /UPnP/DM/DeviceInfo/ parameters ***/
DMLEAF upnpDeviceInfoParams[] = {
{"ProvisioningCode", &DMWRITE, DMT_STRING, upnp_deviceinfo_get_provisionning_code, upnp_deviceinfo_set_provisionning_code, &DMFINFRM, NULL},
{"SoftwareVersion", &DMREAD, DMT_STRING, upnp_deviceinfo_get_software_version, NULL, &DMFINFRM, NULL},
{"SoftwareDescription", &DMREAD, DMT_STRING, upnp_deviceinfo_get_software_description, NULL, &DMFINFRM, NULL},
{"UpTime", &DMREAD, DMT_UNINT, upnp_deviceinfo_get_up_time, NULL, &DMFINFRM, NULL},
{0}
};
/*** /UPnP/DM/DeviceInfo/PhysicalDevice/ objects ***/
DMOBJ upnpPhysicalDeviceObj[] = {
{"DeviceID", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,NULL, upnpDeviceIdParams, NULL},
{0}
};
/*** /UPnP/DM/DeviceInfo/PhysicalDevice/ parameters ***/
DMLEAF upnpPhysicalDeviceParams[] = {
{"HardwareVersion", &DMREAD, DMT_STRING, upnp_deviceinfo_get_hardware_version, NULL, &DMFINFRM, NULL},
{"NetworkInterfaceNumberOfEntries", &DMREAD, DMT_UNINT, upnp_deviceinfo_get_network_interface_number_entries, NULL, &DMFINFRM, NULL},
{0}
};
/*** /UPnP/DM/DeviceInfo/OperatingSystem/ parameters ***/
DMLEAF upnpOperatingSystemParams[] = {
{"SoftwareVersion", &DMREAD, DMT_STRING, upnp_deviceinfo_get_software_version, NULL, &DMFINFRM, NULL},
{"SoftwareDescription", &DMREAD, DMT_STRING, upnp_deviceinfo_get_software_description, NULL, &DMFINFRM, NULL},
{"UpTime", &DMREAD, DMT_UNINT, upnp_deviceinfo_get_up_time, NULL, &DMFINFRM, NULL},
{"WillReboot", &DMREAD, DMT_BOOL, upnp_deviceinfo_get_will_reboot, NULL, &DMFINFRM, NULL},
{"WillBaselineReset", &DMREAD, DMT_BOOL, upnp_deviceinfo_get_will_base_line_reset, NULL, &DMFINFRM, NULL},
{0}
};
/*** /UPnP/DM/DeviceInfo/ExecutionEnvironment/ parameters ***/
DMLEAF upnpExecutionEnvironmentParams[] = {
{"Status", &DMREAD, DMT_STRING, upnp_deviceinfo_get_status, NULL, &DMFINFRM, NULL},
{"Uptime", &DMREAD, DMT_UNINT, upnp_deviceinfo_get_up_time, NULL, &DMFINFRM, NULL},
{"SoftwareVersion", &DMREAD, DMT_STRING, upnp_deviceinfo_get_software_version, NULL, &DMFINFRM, NULL},
{"SoftwareDescription", &DMREAD, DMT_STRING, upnp_deviceinfo_get_software_description, NULL, &DMFINFRM, NULL},
{"WillReboot", &DMREAD, DMT_BOOL, upnp_deviceinfo_get_will_reboot, NULL, &DMFINFRM, NULL},
{"WillBaselineReset", &DMREAD, DMT_BOOL, upnp_deviceinfo_get_will_base_line_reset, NULL, &DMFINFRM, NULL},
{0}
};
/*** /UPnP/DM/DeviceInfo/DeviceID/ parameters ***/
DMLEAF upnpDeviceIdParams[] = {
{"ManufacturerOUI", &DMREAD, DMT_HEXBIN, upnp_deviceinfo_get_manufacturer_oui, NULL, &DMFINFRM, NULL},
{"ProductClass", &DMREAD, DMT_STRING, upnp_deviceinfo_get_product_class, NULL, &DMFINFRM, NULL},
{"SerialNumber", &DMREAD, DMT_STRING, upnp_deviceinfo_get_serial_number, NULL, &DMFINFRM, NULL},
{0}
};
/**************************************************************************
*
* /UPnP/DM/DeviceInfo/* parameters functions
*
***************************************************************************/
int upnp_deviceinfo_get_provisionning_code(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
dmuci_get_option_value_string("cwmp", "cpe", "provisioning_code", value);
return 0;
}
int upnp_deviceinfo_get_software_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
char *v = NULL, *tmp = NULL, *val = NULL;
db_get_value_string("hw", "board", "iopVersion", &v);
if(v == NULL || strlen(v)<=0) {
*value = NULL;
return 0;
}
tmp = dmstrdup(v);// MEM WILL BE FREED IN DMMEMCLEAN
*value = tmp;
return 0;
}
int upnp_deviceinfo_get_software_description(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
struct utsname unameData;
uname(&unameData);
dmasprintf(value, "GNU/%s",unameData.sysname);
return 0;
}
int upnp_deviceinfo_get_up_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
FILE* fp = NULL;
char *pch = NULL, *spch = NULL;
char buf[64];
*value = "0";
fp = fopen("/proc/uptime", "r");
if (fp != NULL) {
fgets(buf, 64, fp);
pch = strtok_r(buf, ".", &spch);
if (pch)
*value = dmstrdup(pch); // MEM WILL BE FREED IN DMMEMCLEAN
fclose(fp);
}
return 0;
}
int upnp_deviceinfo_get_hardware_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
db_get_value_string("hw", "board", "hardwareVersion", value);
return 0;
}
int upnp_deviceinfo_get_network_interface_number_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
int n = upnp_get_NetworkInterfaceNumberOfEntries();
dmasprintf(value, "%d",n);
return 0;
}
int upnp_deviceinfo_get_manufacturer_oui(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
dmuci_get_option_value_string("cwmp", "cpe", "override_oui", value);
if(*value == NULL || strlen(value)<=0) {
*value = NULL;
return 0;
}
if (*value[0] == '\0')
*value = upnp_get_deviceid_manufactureroui();
return 0;
}
int upnp_deviceinfo_get_product_class(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
char *v = NULL, *tmp = NULL, *val = NULL;
db_get_value_string("hw", "board", "iopVerBoard", &v);
if(v == NULL || strlen(v)<=NULL){
*value = NULL;
return 0;
}
tmp = dmstrdup(v);// MEM WILL BE FREED IN DMMEMCLEAN
val = tmp;
return 0;
}
int upnp_deviceinfo_get_serial_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
db_get_value_string("hw", "board", "serialNumber", value);
return 0;
}
int upnp_deviceinfo_get_system_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
return 0;
}
int upnp_deviceinfo_get_mac_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
return 0;
}
int upnp_deviceinfo_get_interface_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
return 0;
}
int upnp_deviceinfo_get_will_reboot(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
return 0;
}
int upnp_deviceinfo_get_will_base_line_reset(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
return 0;
}
int upnp_deviceinfo_get_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
return 0;
}
int upnp_deviceinfo_set_provisionning_code(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action){
bool b;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("cwmp", "cpe", "provisioning_code", value);
return 0;
}
return 0;
}
/*************************************************
*
* MultiInstance objects browsing functions
*
*************************************************/
int upnp_deviceinfo_networkinterface_createinstance(char *refparam, struct dmctx *ctx, void *data, char **instance){
char *value = NULL;
char *iface_instance = NULL, ib[8], ip_name[32];
char *p = ip_name;
struct uci_section *iface_sec = NULL;
iface_instance = get_last_instance("network","interface","upnp_iface_int_instance");
sprintf(ib, "%d", iface_instance ? atoi(iface_instance)+1 : 1);
dmstrappendstr(p, "ip_interface_");
dmstrappendstr(p, ib);
dmstrappendend(p);
sprintf(ib, "%d", iface_instance ? atoi(iface_instance)+1 : 1);
dmuci_add_section_and_rename("network", "interface", &iface_sec, &value);
dmuci_set_value("network", ip_name, "", "interface");
dmuci_set_value("network", ip_name, "proto", "dhcp");
*instance = update_instance(iface_sec, iface_instance, "upnp_iface_int_instance");
return 0;
}
int upnp_deviceinfo_networkinterface_deleteinstance(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action){
switch (del_action) {
case DEL_INST:
dmuci_set_value_by_section(((struct upnp_dvinf_args *)data)->upnp_deviceinfo_sec, "proto", "");
dmuci_set_value_by_section(((struct upnp_dvinf_args *)data)->upnp_deviceinfo_sec, "type", "");
dmuci_set_value_by_section(((struct upnp_dvinf_args *)data)->upnp_deviceinfo_sec, "bridge_instance", "");
dmuci_set_value_by_section(((struct upnp_dvinf_args *)data)->upnp_deviceinfo_sec, "ip_int_instance", "");
dmuci_set_value_by_section(((struct upnp_dvinf_args *)data)->upnp_deviceinfo_sec, "ipv4_instance", "");
dmuci_set_value_by_section(((struct upnp_dvinf_args *)data)->upnp_deviceinfo_sec, "ipv6_instance", "");
dmuci_set_value_by_section(((struct upnp_dvinf_args *)data)->upnp_deviceinfo_sec, "ifname", "");
dmuci_set_value_by_section(((struct upnp_dvinf_args *)data)->upnp_deviceinfo_sec, "ipaddr", "");
dmuci_set_value_by_section(((struct upnp_dvinf_args *)data)->upnp_deviceinfo_sec, "ip6addr", "");
break;
case DEL_ALL:
return FAULT_9005;
}
return 0;
}
int upnp_browseNetworkInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance){
struct uci_section *net_sec = NULL;
char *iface_int = NULL, *iface_int_last = NULL, *interfaceType = NULL, *macAddress = NULL;
struct upnp_dvinf_args curr_upnp_deviceinfo_args = {0};
uci_foreach_sections("network", "interface", net_sec) {
curr_upnp_deviceinfo_args.upnp_deviceinfo_sec = net_sec;
dmuci_get_value_by_section_string(net_sec, "type", &interfaceType);
upnp_getMacAddress(section_name(net_sec), &macAddress);
dmasprintf(&curr_upnp_deviceinfo_args.systemName, "%s", section_name(net_sec));
dmasprintf(&curr_upnp_deviceinfo_args.macAddress, "%s", macAddress);
dmasprintf(&curr_upnp_deviceinfo_args.interfaceType, "%s", interfaceType);
iface_int = handle_update_instance(1, dmctx, &iface_int_last, update_instance_alias, 3, net_sec, "upnp_iface_int_instance", "upnp_iface_int_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_upnp_deviceinfo_args, iface_int) == DM_STOP) break;
}
}

41
dmtree/tr064/upnp_deviceinfo.h Executable file
View file

@ -0,0 +1,41 @@
#ifndef UPNP_DEVICEINFO_H
#define UPNP_DEVICEINFO_H
#include "dmcwmp.h"
struct upnp_dvinf_args
{
struct uci_section *upnp_deviceinfo_sec;
char* systemName;
char* macAddress;
char* interfaceType;
};
int upnp_deviceinfo_get_provisionning_code(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_deviceinfo_get_software_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_deviceinfo_get_software_description(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_deviceinfo_get_up_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_deviceinfo_get_hardware_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_deviceinfo_get_network_interface_number_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_deviceinfo_get_manufacturer_oui(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_deviceinfo_get_product_class(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_deviceinfo_get_serial_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_deviceinfo_get_system_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_deviceinfo_get_mac_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_deviceinfo_get_interface_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_deviceinfo_get_will_reboot(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_deviceinfo_get_will_base_line_reset(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_deviceinfo_get_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_deviceinfo_set_provisionning_code(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int upnp_deviceinfo_networkinterface_createinstance(char *refparam, struct dmctx *ctx, void *data, char **instance);
int upnp_deviceinfo_networkinterface_deleteinstance(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
extern DMLEAF upnpDeviceIdParams[];
extern DMLEAF upnpNetworkInterfaceParams[];
extern DMOBJ upnpPhysicalDeviceObj[];
extern DMLEAF upnpPhysicalDeviceParams[];
extern DMLEAF upnpOperatingSystemParams[];
extern DMLEAF upnpExecutionEnvironmentParams[];
extern DMOBJ upnpDeviceInfoObj[];
extern DMLEAF upnpDeviceInfoParams[];
#endif

145
dmtree/tr064/upnp_monitoring.c Executable file
View file

@ -0,0 +1,145 @@
#include "dmcwmp.h"
#include "upnp_monitoring.h"
#include "upnp_common.h"
#include "dmubus.h"
#include "dmcommon.h"
#include "dmjson.h"
#include <time.h>
/**************************************************************************
*
* /UPnP/DM/Monitoring/ datamodel tree
*
***************************************************************************/
/*** /UPnP/DM/Monitoring/ objects ***/
DMOBJ upnpMonitoringObj[] = {
{"OperatingSystem",&DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE, NULL, upnpMonitoringOperatingSystemParams, NULL},
{"ExecutionEnvironment",&DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE, NULL, upnpMonitoringExecutionEnvironmentParams, NULL},
{"IPUsage",&DMREAD, NULL, NULL, NULL, upnp_BrowseIPUsage, &DMFINFRM, &DMNONE, NULL, upnpMonitoringIPUsageParams, NULL},
{0}
};
/*** /UPnP/DM/Monitoring/ parameters ***/
DMLEAF upnpMonitoringParams[] = {
{"IPUsageNumberOfEntries", &DMREAD, DMT_UNINT, upnp_monitoring_get_IPUsageNumberOfEntries, NULL, &DMFINFRM, NULL},
{0}
};
/*** /UPnP/DM/Monitoring/OperatingSystem parameters ***/
DMLEAF upnpMonitoringOperatingSystemParams[] = {
{"CurrentTime", &DMREAD, DMT_TIME, upnp_monitoring_get_CurrentTime, NULL, &DMFINFRM, NULL},
{"CPUUsage", &DMREAD, DMT_UNINT, upnp_monitoring_get_CPUUsage, NULL, &DMFINFRM, NULL},
{"MemoryUsage", &DMREAD, DMT_UNINT, upnp_monitoring_get_MemoryUsage, NULL, &DMFINFRM, NULL},
{0}
};
/*** /UPnP/DM/Monitoring/ExecutionEnvironement parameters ***/
DMLEAF upnpMonitoringExecutionEnvironmentParams[] = {
{"CPUUsage", &DMREAD, DMT_UNINT, upnp_monitoring_get_CPUUsage, NULL, &DMFINFRM, NULL},
{"MemoryUsage", &DMREAD, DMT_UNINT, upnp_monitoring_get_MemoryUsage, NULL, &DMFINFRM, NULL},
{0}
};
/*** /UPnP/DM/Monitoring/Usage parameters ***/
DMLEAF upnpMonitoringIPUsageParams[] = {
{"SystemName", &DMREAD, DMT_STRING, upnp_monitoring_get_SystemName, NULL, &DMFINFRM, NULL},
{"Status", &DMREAD, DMT_STRING, upnp_monitoring_get_Status, NULL, &DMFINFRM, NULL},
{"TotalPacketsSent", &DMREAD, DMT_UNINT, upnp_monitoring_get_TotalPacketsSent, NULL, &DMFINFRM, NULL},
{"TotalPacketsReceived", &DMREAD, DMT_UNINT, upnp_monitoring_get_TotalPacketsReceived, NULL, &DMFINFRM, NULL},
{0}
};
/**************************************************************************
*
* /UPnP/DM/Monitoring/* parameters functions
*
***************************************************************************/
int upnp_monitoring_get_IPUsageNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
int n = upnp_get_IPInterfaceNumberOfEntries();
dmasprintf(value, "%d", n);
return 0;
}
int upnp_monitoring_get_CurrentTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
time_t rawtime;
struct tm * timeinfo = NULL;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
dmasprintf(value, "%d:%d:%d", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
return 0;
}
int upnp_monitoring_get_CPUUsage(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
return 0;
}
int upnp_monitoring_get_MemoryUsage(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
json_object *res = NULL;
char *totalmemory = NULL, *freememory = NULL;
int total, free;
dmubus_call("system", "info", UBUS_ARGS{{}}, 0, &res);
if(res == NULL) {
*value = NULL;
return 0;
}
DM_ASSERT(res, freememory = "");
DM_ASSERT(res, totalmemory = "");
totalmemory = dmjson_get_value(res, 2, "memory", "total");
freememory = dmjson_get_value(res, 2, "memory", "freememory");
total = atoi(totalmemory);
free = atoi(freememory);
dmasprintf(value, "%d", total - free);
return 0;
}
int upnp_monitoring_get_SystemName(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
struct upnp_ip_usage_args *ipusage_args = (struct upnp_ip_usage_args *)data;
if(ipusage_args->systemName != NULL && strlen(ipusage_args->systemName)>0)
dmasprintf(value, "%s", ipusage_args->systemName);
return 0;
}
int upnp_monitoring_get_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
struct upnp_ip_usage_args *ipusage_args = (struct upnp_ip_usage_args *)data;
if(ipusage_args->status != NULL && strlen(ipusage_args->status)>0)
dmasprintf(value, "%s", ipusage_args->status);
return 0;
}
int upnp_monitoring_get_TotalPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
struct upnp_ip_usage_args *ipusage_args = (struct upnp_ip_usage_args *)data;
if(ipusage_args->totalpacketsent != NULL && strlen(ipusage_args->totalpacketsent)>0)
dmasprintf(value, "%s", ipusage_args->totalpacketsent);
return 0;
}
int upnp_monitoring_get_TotalPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
struct upnp_ip_usage_args *ipusage_args = (struct upnp_ip_usage_args *)data;
if(ipusage_args->totalpacketreceived != NULL && strlen(ipusage_args->totalpacketreceived)>0)
dmasprintf(value, "%s", ipusage_args->totalpacketreceived);
return 0;
}
int upnp_BrowseIPUsage(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance){
struct uci_section *net_sec = NULL;
struct upnp_ip_usage_args curr_ip_usage_args = {0};
char *iface_int = NULL, *iface_int_last = NULL, *totalPktSnt = NULL, *totalPktRcvd= NULL, *status = NULL;
int i = 0;
uci_foreach_sections("network", "interface", net_sec) {
dmasprintf(&curr_ip_usage_args.systemName, "%s", section_name(net_sec));
upnp_getInterfaceStatus(section_name(net_sec), &status);
if(status !=NULL) dmasprintf(&curr_ip_usage_args.status, "%s", status); else dmasprintf(&curr_ip_usage_args.status, "");
upnp_getInterfaceTotalPacketSent(section_name(net_sec), &totalPktSnt);
if(totalPktSnt != NULL) dmasprintf(&curr_ip_usage_args.totalpacketsent, "%s", totalPktSnt); else dmasprintf(&curr_ip_usage_args.totalpacketsent, "");
upnp_getInterfaceTotalPacketReceived(section_name(net_sec), &totalPktRcvd);
if(totalPktRcvd !=NULL) dmasprintf(&curr_ip_usage_args.totalpacketreceived, "%s", totalPktRcvd); else dmasprintf(&curr_ip_usage_args.totalpacketreceived, "");
iface_int = handle_update_instance(1, dmctx, &iface_int_last, update_instance_alias, 3, net_sec, "upnp_ip_usage_instance", "upnp_ip_usage_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_ip_usage_args, iface_int) == DM_STOP) break;
i++;
}
return 0;
}

34
dmtree/tr064/upnp_monitoring.h Executable file
View file

@ -0,0 +1,34 @@
#ifndef UPNP_MONITORING_H
#define UPNP_MONITORING_H
#include "dmcwmp.h"
struct upnp_ip_usage_args{
char *systemName;
char *status;
char *totalpacketsent;
char *totalpacketreceived;
};
int upnp_monitoring_get_IPUsageNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_monitoring_get_StorageNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_monitoring_get_CurrentTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_monitoring_get_CPUUsage(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_monitoring_get_MemoryUsage(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_monitoring_get_SystemName(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_monitoring_get_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_monitoring_get_TotalPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_monitoring_get_TotalPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int upnp_BrowseIPUsage(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int upnp_CreateIPUsageInstance(char *refparam, struct dmctx *ctx, void *data, char **instance);
int upnp_DeleteIPUsageInstance(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int upnp_BrowseStorage(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int upnp_CreateStorageInstance(char *refparam, struct dmctx *ctx, void *data, char **instance);
int upnp_DeleteStorageInstance(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
extern DMLEAF upnpMonitoringOperatingSystemParams[];
extern DMLEAF upnpMonitoringExecutionEnvironmentParams[];
extern DMLEAF upnpMonitoringIPUsageParams[];
extern DMLEAF upnpMonitoringStorageParams[];
extern DMOBJ upnpMonitoringObj[];
extern DMLEAF upnpMonitoringParams[];
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,262 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2012-2014 PIVA SOFTWARE (www.pivasoftware.com)
* Author: Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author: Feten Besbes <feten.besbes@pivasoftware.com>
* Author: Mohamed Kallel <mohamed.kallel@pivasoftware.com>
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
*/
#ifndef __VOICE_H
#define __VOICE_H
extern DMOBJ tServiceObj[];
extern DMOBJ tVoiceServiceObj[];
extern DMLEAF tVoiceServiceParam[];
extern DMLEAF tCapabilitiesParams[];
extern DMOBJ tCapabilitiesObj[];
extern DMLEAF tSIPParams[];
extern DMLEAF tCodecsParams[] ;
extern DMOBJ tProfileObj[] ;
extern DMLEAF tProfileSIPParams[];
extern DMLEAF tServiceProviderInfoParams[];
extern DMLEAF tProfileParam[];
extern DMOBJ tLineObj[];
extern DMOBJ tLineCodecObj[];
extern DMLEAF tLineCodecListParams[];
extern DMLEAF tLineSIPParams[];
extern DMLEAF tVoiceProcessingParams[];
extern DMLEAF tCallingFeaturesParams[];
extern DMLEAF tLineParams[];
extern DMLEAF tRTPParams[];
extern DMOBJ tRTPObj[];
extern DMLEAF tSRTPParam[];
extern DMLEAF tRTCPParams[];
extern DMLEAF tFaxT38Params[];
struct codec_args
{
char *cdc;
char *id;
int enumid;
struct uci_section *codec_section;
};
struct rtp_tos
{
char *key;
char *val;
};
struct cap_sip_codec
{
int enumid;
char *c1;
char *c2;
char *c3;
char *c4;
char *c5;
};
struct sip_args
{
struct uci_section *sip_section;
char *profile_num;
};
struct tel_args
{
struct uci_section *tel_section;
struct uci_section *sip_section;
char *profile_num;
};
struct allow_sip_codec
{
int enumid;
char *id;
char *allowed_cdc;
char *priority_cdc;
char *ptime_cdc;
};
struct line_codec_args
{
int enumid;
char *sip_id;
char *cdc;
char *id;
char *priority_cdc;
char *ptime_cdc;
struct uci_section *sip_section;
struct uci_section *codec_sec;
};
struct region
{
char *country;
char *id;
};
struct codec
{
char *cdc;
char *id;
char *priority;
};
enum enum_cap_sip_codecs {
SIP_CODEC_G723,
SIP_CODEC_GSM,
SIP_CODEC_ULAW,
SIP_CODEC_ALAW,
SIP_CODEC_G726AAL2,
SIP_CODEC_ADPCM,
SIP_CODEC_SLIN,
SIP_CODEC_LPC10,
SIP_CODEC_G729,
SIP_CODEC_SPEEX,
SIP_CODEC_ILBC,
SIP_CODEC_G726,
SIP_CODEC_G722,
SIP_CODEC_SIREN7,
SIP_CODEC_SIREN14,
SIP_CODEC_SLIN16,
SIP_CODEC_G719,
SIP_CODEC_SPEEX16,
SIP_CODEC_TESTLAW
};
bool dm_service_enable_set(void);
int browseVoiceServiceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseCodecsInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseProfileInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseLineInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseLineCodecListInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int add_profile_object(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_profile_object(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_line_object(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_line_object(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_service_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_max_profile_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_max_line_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_true_value(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_max_session_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_signal_protocols(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_regions(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_false_value(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_role(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_extension(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_transport(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_tls_auth_protocols(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_tls_enc_protocols(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_tls_key_protocols(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_cap_codec_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_entry_id(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_capabilities_sip_codec(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_capabilities_sip_bitrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_capabilities_sip_pperiod(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_signalprotocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_max_sessions(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_number_of_lines(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_sip_dtmfmethod(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_profile_region(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_sip_proxyserver(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_proxy_server_transport(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_sip_registerserver(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_sip_registerserverport(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_registrar_server_transport(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_user_agent_domain(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_user_agent_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_user_agent_transport(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_outbound_proxy(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_outbound_proxy_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_registration_period(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_re_invite_expires(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_call_lines(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_service_serviceproviderinfo_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_fax_t38_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_service_vp_rtp_portmin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_service_vp_rtp_portmax(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_service_vp_rtp_dscp(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_service_vp_rtp_rtcp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_service_vp_rtp_rtcp_txrepeatinterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_service_vp_rtp_srtp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_line_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_line_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_line_callstate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_line_profile(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_tel_line(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_confort_noise_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_voice_processing_cancellation_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_calling_features_caller_id_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_calling_features_callwaiting(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_sip_auth_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_sip_uri(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_codec_list_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_codec_entry_id(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int capabilities_sip_codecs_get_codec(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int capabilities_sip_codecs_get_bitrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_capabilities_sip_codecs_pperiod(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_codec_list_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_codec_list_priority(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_directory_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_service_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_cap_codec_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_profile_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_profile_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_profile_reset(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_profile_signaling_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_profile_sip_dtmfmethod(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_profile_sip_proxyserver(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_proxy_server_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_proxy_server_transport(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_profile_sip_registerserver(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_profile_sip_registerserverport(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_registrar_server_transport(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_user_agent_domain(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_user_agent_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_user_agent_transport(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_outbound_proxy(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_outbound_proxy_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_registration_period(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_re_invite_expires(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_call_lines(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_service_serviceproviderinfo_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_fax_t38_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_service_vp_rtp_portmin(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_profile_rtp_localportmax(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_service_vp_rtp_dscp(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_service_vp_rtp_rtcp_txrepeatinterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_service_vp_rtp_srtp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_profile_line_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_directory_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_line_profile(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_tel_line(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_confort_noise_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_calling_features_caller_id_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_voice_processing_cancellation_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_calling_features_callwaiting(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_sip_auth_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_sip_auth_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_sip_uri(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_codec_list_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_codec_list_packetization(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_codec_list_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_codec_list_priority(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_profile_region(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_voice_service_max_line();
#endif

2469
dmtree/tr143/diagnostics.c Normal file

File diff suppressed because it is too large Load diff

232
dmtree/tr143/diagnostics.h Normal file
View file

@ -0,0 +1,232 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*
*/
#ifndef __DIAGNOSTICS_H
#define __DIAGNOSTICS_H
extern DMOBJ tIPDiagnosticsObj[];
extern DMLEAF tIPDiagnosticsParams[];
extern DMLEAF tIPDiagnosticsIPPingParams[];
extern DMOBJ tIPDiagnosticsTraceRouteObj[];
extern DMLEAF tIPDiagnosticsTraceRouteParams[];
extern DMLEAF tIPDiagnosticsTraceRouteRouteHopsParams[];
extern DMOBJ tIPDiagnosticsDownloadDiagnosticsObj[];
extern DMLEAF tIPDiagnosticsDownloadDiagnosticsParams[];
extern DMLEAF tIPDiagnosticsDownloadDiagnosticsPerConnectionResultParams[];
extern DMOBJ tIPDiagnosticsUploadDiagnosticsObj[];
extern DMLEAF tIPDiagnosticsUploadDiagnosticsParams[];
extern DMLEAF tIPDiagnosticsUploadDiagnosticsPerConnectionResultParams[];
extern DMLEAF tIPDiagnosticsUDPEchoConfigParams[];
extern DMLEAF tIPDiagnosticsUDPEchoDiagnosticsParams[];
extern DMLEAF tIPDiagnosticsServerSelectionDiagnosticsParams[];
int browseIPDiagnosticsTraceRouteRouteHopsInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseIPDiagnosticsDownloadDiagnosticsPerConnectionResultInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseIPDiagnosticsUploadDiagnosticsPerConnectionResultInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int get_diag_enable_true(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_ping_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_ip_ping_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_ip_ping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_ip_ping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_ip_ping_protocolversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_ip_ping_protocolversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_ip_ping_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_ip_ping_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_ip_ping_repetition_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_ip_ping_repetition_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_ip_ping_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_ip_ping_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_ip_ping_block_size(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_ip_ping_block_size(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_ip_ping_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_ip_ping_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_ip_ping_success_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_ping_failure_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_ping_average_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_ping_min_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_ping_max_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_ping_AverageResponseTimeDetailed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_ping_MinimumResponseTimeDetailed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_ping_MaximumResponseTimeDetailed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsTraceRoute_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsTraceRoute_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsTraceRoute_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsTraceRoute_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsTraceRoute_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsTraceRoute_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsTraceRoute_Host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsTraceRoute_Host(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsTraceRoute_NumberOfTries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsTraceRoute_NumberOfTries(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsTraceRoute_Timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsTraceRoute_Timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsTraceRoute_DataBlockSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsTraceRoute_DataBlockSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsTraceRoute_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsTraceRoute_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsTraceRoute_MaxHopCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsTraceRoute_MaxHopCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsTraceRoute_ResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsTraceRoute_RouteHopsNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsTraceRouteRouteHops_Host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsTraceRouteRouteHops_HostAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsTraceRouteRouteHops_ErrorCode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsTraceRouteRouteHops_RTTimes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsDownloadDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsDownloadDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsDownloadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsDownloadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsDownloadDiagnostics_DownloadURL(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsDownloadDiagnostics_DownloadURL(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsDownloadDiagnostics_DownloadTransports(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsDownloadDiagnostics_DownloadDiagnosticMaxConnections(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsDownloadDiagnostics_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsDownloadDiagnostics_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsDownloadDiagnostics_EthernetPriority(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsDownloadDiagnostics_EthernetPriority(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsDownloadDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsDownloadDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsDownloadDiagnostics_NumberOfConnections(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsDownloadDiagnostics_NumberOfConnections(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsDownloadDiagnostics_ROMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsDownloadDiagnostics_BOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsDownloadDiagnostics_EOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsDownloadDiagnostics_TestBytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsDownloadDiagnostics_TotalBytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsDownloadDiagnostics_TotalBytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsDownloadDiagnostics_TestBytesReceivedUnderFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsDownloadDiagnostics_TotalBytesReceivedUnderFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsDownloadDiagnostics_TotalBytesSentUnderFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsDownloadDiagnostics_PeriodOfFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsDownloadDiagnostics_TCPOpenRequestTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsDownloadDiagnostics_TCPOpenResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsDownloadDiagnostics_PerConnectionResultNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsDownloadDiagnostics_EnablePerConnectionResults(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsDownloadDiagnostics_EnablePerConnectionResults(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_ROMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_BOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_EOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_TestBytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_TotalBytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_TotalBytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_TCPOpenRequestTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_TCPOpenResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUploadDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUploadDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUploadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUploadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUploadDiagnostics_UploadURL(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUploadDiagnostics_UploadURL(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUploadDiagnostics_UploadTransports(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUploadDiagnostics_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUploadDiagnostics_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUploadDiagnostics_EthernetPriority(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUploadDiagnostics_EthernetPriority(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUploadDiagnostics_TestFileLength(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUploadDiagnostics_TestFileLength(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUploadDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUploadDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUploadDiagnostics_NumberOfConnections(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUploadDiagnostics_NumberOfConnections(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUploadDiagnostics_ROMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUploadDiagnostics_BOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUploadDiagnostics_EOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUploadDiagnostics_TestBytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUploadDiagnostics_TotalBytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUploadDiagnostics_TotalBytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUploadDiagnostics_TestBytesSentUnderFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUploadDiagnostics_TotalBytesReceivedUnderFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUploadDiagnostics_TotalBytesSentUnderFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUploadDiagnostics_PeriodOfFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUploadDiagnostics_TCPOpenRequestTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUploadDiagnostics_TCPOpenResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUploadDiagnostics_PerConnectionResultNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUploadDiagnostics_EnablePerConnectionResults(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUploadDiagnostics_EnablePerConnectionResults(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_ROMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_BOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_EOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_TestBytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_TotalBytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_TotalBytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_TCPOpenRequestTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_TCPOpenResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUDPEchoConfig_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUDPEchoConfig_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUDPEchoConfig_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUDPEchoConfig_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUDPEchoConfig_SourceIPAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUDPEchoConfig_SourceIPAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUDPEchoConfig_UDPPort(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUDPEchoConfig_UDPPort(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUDPEchoConfig_EchoPlusEnabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUDPEchoConfig_EchoPlusEnabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUDPEchoConfig_EchoPlusSupported(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUDPEchoConfig_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUDPEchoConfig_PacketsResponded(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUDPEchoConfig_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUDPEchoConfig_BytesResponded(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUDPEchoConfig_TimeFirstPacketReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUDPEchoConfig_TimeLastPacketReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUDPEchoDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUDPEchoDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUDPEchoDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUDPEchoDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUDPEchoDiagnostics_Host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUDPEchoDiagnostics_Host(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUDPEchoDiagnostics_Port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUDPEchoDiagnostics_Port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUDPEchoDiagnostics_NumberOfRepetitions(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUDPEchoDiagnostics_NumberOfRepetitions(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUDPEchoDiagnostics_Timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUDPEchoDiagnostics_Timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUDPEchoDiagnostics_DataBlockSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUDPEchoDiagnostics_DataBlockSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUDPEchoDiagnostics_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUDPEchoDiagnostics_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUDPEchoDiagnostics_InterTransmissionTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUDPEchoDiagnostics_InterTransmissionTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUDPEchoDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsUDPEchoDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsUDPEchoDiagnostics_SuccessCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUDPEchoDiagnostics_FailureCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUDPEchoDiagnostics_AverageResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUDPEchoDiagnostics_MinimumResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsUDPEchoDiagnostics_MaximumResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsServerSelectionDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsServerSelectionDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsServerSelectionDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsServerSelectionDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsServerSelectionDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsServerSelectionDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsServerSelectionDiagnostics_Protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsServerSelectionDiagnostics_Protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsServerSelectionDiagnostics_Port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsServerSelectionDiagnostics_Port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsServerSelectionDiagnostics_HostList(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsServerSelectionDiagnostics_HostList(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsServerSelectionDiagnostics_NumberOfRepetitions(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsServerSelectionDiagnostics_NumberOfRepetitions(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsServerSelectionDiagnostics_Timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPDiagnosticsServerSelectionDiagnostics_Timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPDiagnosticsServerSelectionDiagnostics_FastestHost(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsServerSelectionDiagnostics_MinimumResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsServerSelectionDiagnostics_AverageResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsServerSelectionDiagnostics_MaximumResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
#endif

375
dmtree/tr181/atm.c Normal file
View file

@ -0,0 +1,375 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2016 PIVA SOFTWARE (www.pivasoftware.com)
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
*
*/
#include <ctype.h>
#include <uci.h>
#include "dmcwmp.h"
#include "dmuci.h"
#include "dmubus.h"
#include "dmcommon.h"
#include "atm.h"
#include "dmjson.h"
#include "dmentry.h"
/*** ATM. ***/
DMOBJ tATMObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{"Link", &DMWRITE, add_atm_link, delete_atm_link, NULL, browseAtmLinkInst, NULL, NULL, tATMLinkObj, tATMLinkParams, get_atm_linker, BBFDM_BOTH},
{0}
};
/*** ATM.Link. ***/
DMOBJ tATMLinkObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tATMLinkStatsParams, NULL, BBFDM_BOTH},
{0}
};
DMLEAF tATMLinkParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Alias", &DMWRITE, DMT_STRING, get_atm_alias, set_atm_alias, NULL, NULL, BBFDM_BOTH},
{"Enable", &DMREAD, DMT_BOOL, get_atm_enable, NULL, NULL, NULL, BBFDM_BOTH},
{"Name", &DMREAD, DMT_STRING, get_atm_link_name, NULL, NULL, NULL, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_atm_enable, NULL, NULL, NULL, BBFDM_BOTH},
{"LowerLayers", &DMREAD, DMT_STRING, get_atm_lower_layer, NULL, NULL, NULL, BBFDM_BOTH},
{"LinkType", &DMWRITE, DMT_STRING, get_atm_link_type, set_atm_link_type, NULL, NULL, BBFDM_BOTH},
{"DestinationAddress", &DMWRITE, DMT_STRING, get_atm_destination_address, set_atm_destination_address, NULL, NULL, BBFDM_BOTH},
{"Encapsulation", &DMWRITE, DMT_STRING, get_atm_encapsulation, set_atm_encapsulation, NULL, NULL, BBFDM_BOTH},
{0}
};
/*** ATM.Link.Stats. ***/
DMLEAF tATMLinkStatsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"BytesSent", &DMREAD, DMT_UNINT, get_atm_stats_bytes_sent, NULL, NULL, NULL, BBFDM_BOTH},
{"BytesReceived", &DMREAD, DMT_UNINT, get_atm_stats_bytes_received, NULL, NULL, NULL, BBFDM_BOTH},
{"PacketsSent", &DMREAD, DMT_UNINT, get_atm_stats_pack_sent, NULL, NULL, NULL, BBFDM_BOTH},
{"PacketsReceived", &DMREAD, DMT_UNINT, get_atm_stats_pack_received, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/**************************************************************************
* LINKER
***************************************************************************/
int get_atm_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) {
if (data && ((struct atm_args *)data)->ifname) {
*linker = ((struct atm_args *)data)->ifname;
return 0;
}
*linker = "" ;
return 0;
}
/**************************************************************************
* INIT
***************************************************************************/
inline int init_atm_link(struct atm_args *args, struct uci_section *s, char *ifname)
{
args->atm_sec = s;
args->ifname = ifname;
return 0;
}
/**************************************************************************
* SET & GET DSL LINK PARAMETERS
***************************************************************************/
/*#Device.ATM.Link.{i}.DestinationAddress!UCI:dsl/atm-device,@i-1/vpi*/
int get_atm_destination_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *vpi, *vci;
dmuci_get_value_by_section_string(((struct atm_args *)data)->atm_sec, "vpi", &vpi);
dmuci_get_value_by_section_string(((struct atm_args *)data)->atm_sec, "vci", &vci);
dmasprintf(value, "PVC: %s/%s", vpi, vci); // MEM WILL BE FREED IN DMMEMCLEAN
return 0;
}
int set_atm_destination_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *vpi = NULL, *vci = NULL, *spch, *val;
struct uci_section *s;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
if (strstr(value, "PVC: "))
value += 5;
else
return 0;
val = dmstrdup(value);
vpi = strtok_r(val, "/", &spch);
if (vpi) {
vci = strtok_r(NULL, "/", &spch);
}
if (vpi && vci) {
dmuci_set_value_by_section(((struct atm_args *)data)->atm_sec, "vpi", vpi);
dmuci_set_value_by_section(((struct atm_args *)data)->atm_sec, "vci", vci);
}
dmfree(val);
break;
return 0;
}
return 0;
}
/*#Device.ATM.Link.{i}.Name!UCI:dsl/atm-device,@i-1/name*/
int get_atm_link_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(((struct atm_args *)data)->atm_sec, "name", value);
return 0;
}
/*#Device.ATM.Link.{i}.Encapsulation!UCI:dsl/atm-device,@i-1/encapsulation*/
int get_atm_encapsulation(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *encapsulation;
dmuci_get_value_by_section_string(((struct atm_args *)data)->atm_sec, "encapsulation", &encapsulation);
if (strcasecmp(encapsulation, "vcmux") == 0) {
*value = "VCMUX";
}
else if (strcasecmp(encapsulation, "llc") == 0) {
*value = "LLC";
} else {
*value = "";
}
return 0;
}
int set_atm_encapsulation(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *encapsulation;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
if (strcmp(value, "VCMUX") == 0)
encapsulation = "vcmux";
else if (strcmp(value, "LLC") == 0)
encapsulation = "llc";
else
return 0;
dmuci_set_value_by_section(((struct atm_args *)data)->atm_sec, "encapsulation", encapsulation);
return 0;
}
return 0;
}
/*#Device.ATM.Link.{i}.LinkType!UCI:dsl/atm-device,@i-1/link_type*/
int get_atm_link_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "";
dmuci_get_value_by_section_string(((struct atm_args *)data)->atm_sec, "link_type", value);
return 0;
}
int set_atm_link_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(((struct atm_args *)data)->atm_sec, "link_type", value);
return 0;
}
return 0;
}
int get_atm_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char linker[16];
sprintf(linker, "channel_%d", atoi(instance)-1);
adm_entry_get_linker_param(ctx, dm_print_path("%s%cDSL%cChannel%c", dmroot, dm_delim, dm_delim, dm_delim), linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
if (*value == NULL)
*value = "";
return 0;
}
inline int ubus_atm_stats(json_object *res, char **value, char *stat_mod, void *data)
{
dmubus_call("network.device", "status", UBUS_ARGS{{"name", ((struct atm_args *)data)->ifname, String}}, 1, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 2, "statistics", stat_mod);
return 0;
}
/*#Device.ATM.Link.{i}.Stats.BytesReceived!UBUS:network.device/status/name,@Name/statistics.rx_bytes*/
int get_atm_stats_bytes_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
ubus_atm_stats(res, value, "rx_bytes", data);
return 0;
}
/*#Device.ATM.Link.{i}.Stats.BytesSent!UBUS:network.device/status/name,@Name/statistics.tx_bytes*/
int get_atm_stats_bytes_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
ubus_atm_stats(res, value, "tx_bytes", data);
return 0;
}
/*#Device.ATM.Link.{i}.Stats.PacketsReceived!UBUS:network.device/status/name,@Name/statistics.rx_packets*/
int get_atm_stats_pack_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
ubus_atm_stats(res, value, "rx_packets", data);
return 0;
}
/*#Device.ATM.Link.{i}.Stats.PacketsSent!UBUS:network.device/status/name,@Name/statistics.tx_packets*/
int get_atm_stats_pack_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
ubus_atm_stats(res, value, "tx_packets", data);
return 0;
}
int get_atm_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "true";
return 0;
}
/*************************************************************
* ADD OBJ
/*************************************************************/
int add_atm_link(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
{
char *instance = NULL, *atm_device = NULL, *v = NULL, *instance_update = NULL;
struct uci_section *dmmap_atm = NULL;
check_create_dmmap_package("dmmap_dsl");
instance = get_last_instance_icwmpd("dmmap_dsl", "atm-device", "atmlinkinstance");
dmasprintf(&atm_device, "atm%d", instance ? atoi(instance) : 0);
dmasprintf(&instance_update, "%d", instance ? atoi(instance)+ 1 : 1);
dmuci_set_value("dsl", atm_device, "", "atm-device");
dmuci_set_value("dsl", atm_device, "name", "ATM");
dmuci_set_value("dsl", atm_device, "vpi", "8");
dmuci_set_value("dsl", atm_device, "vci", "35");
dmuci_set_value("dsl", atm_device, "device", atm_device);
dmuci_set_value("dsl", atm_device, "link_type", "eoa");
dmuci_set_value("dsl", atm_device, "encapsulation", "llc");
dmuci_set_value("dsl", atm_device, "qos_class", "ubr");
dmuci_add_section_icwmpd("dmmap_dsl", "atm-device", &dmmap_atm, &v);
dmuci_set_value_by_section(dmmap_atm, "section_name", atm_device);
*instancepara = update_instance_icwmpd(dmmap_atm, instance, "atmlinkinstance");
return 0;
}
int delete_atm_link(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL, *ss = NULL, *ns = NULL, *nss = NULL, *dmmap_section= NULL;
char *ifname;
switch (del_action) {
case DEL_INST:
get_dmmap_section_of_config_section("dmmap_dsl", "atm-device", section_name(((struct atm_args *)data)->atm_sec), &dmmap_section);
if(dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(((struct atm_args *)data)->atm_sec, NULL, NULL);
uci_foreach_option_cont("network", "interface", "ifname", ((struct atm_args *)data)->ifname, s) {
if (ss && ifname!=NULL)
wan_remove_dev_interface(ss, ((struct atm_args *)data)->ifname);
ss = s;
}
if (ss != NULL && ifname!=NULL)
wan_remove_dev_interface(ss, ((struct atm_args *)data)->ifname);
break;
case DEL_ALL:
uci_foreach_sections("dsl", "atm-device", s) {
if (ss){
get_dmmap_section_of_config_section("dmmap_dsl", "atm-device", section_name(ss), &dmmap_section);
if(dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_get_value_by_section_string(ss, "device", &ifname);
dmuci_delete_by_section(ss, NULL, NULL);
uci_foreach_option_cont("network", "interface", "ifname", ifname, ns) {
if (nss && ifname!=NULL)
wan_remove_dev_interface(nss, ifname);
nss = ns;
}
if (nss != NULL && ifname!=NULL)
wan_remove_dev_interface(nss, ifname);
}
ss = s;
}
if (ss != NULL) {
get_dmmap_section_of_config_section("dmmap_dsl", "atm-device", section_name(ss), &dmmap_section);
if(dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_get_value_by_section_string(ss, "device", &ifname);
dmuci_delete_by_section(ss, NULL, NULL);
uci_foreach_option_cont("network", "interface", "ifname", ifname, ns) {
if (nss && ifname!=NULL)
wan_remove_dev_interface(nss, ifname);
nss = ns;
}
if (nss != NULL && ifname!=NULL)
wan_remove_dev_interface(nss, ifname);
}
break;
}
return 0;
}
/*************************************************************
* SET AND GET ALIAS
/*************************************************************/
int get_atm_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
get_dmmap_section_of_config_section("dmmap_dsl", "atm-device", section_name(((struct atm_args *)data)->atm_sec), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "atmlinkalias", value);
return 0;
}
int set_atm_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_dsl", "atm-device", section_name(((struct atm_args *)data)->atm_sec), &dmmap_section);
dmuci_set_value_by_section(dmmap_section, "atmlinkalias", value);
return 0;
}
return 0;
}
/*************************************************************
* ENTRY METHOD
/*************************************************************/
/*#Device.ATM.Link.{i}.!UCI:dsl/atm-device/dmmap_dsl*/
int browseAtmLinkInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *wnum = NULL, *channel_last = NULL, *ifname;
struct atm_args curr_atm_args = {0};
struct dmmap_dup *p;
LIST_HEAD(dup_list);
synchronize_specific_config_sections_with_dmmap("dsl", "atm-device", "dmmap_dsl", &dup_list);
list_for_each_entry(p, &dup_list, list) {
dmuci_get_value_by_section_string(p->config_section, "device", &ifname);
init_atm_link(&curr_atm_args, p->config_section, ifname);
wnum = handle_update_instance(1, dmctx, &channel_last, update_instance_alias, 3, p->dmmap_section, "atmlinkinstance", "atmlinkalias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_atm_args, wnum) == DM_STOP)
break;
}
free_dmmap_config_dup_list(&dup_list);
return 0;
}

50
dmtree/tr181/atm.h Normal file
View file

@ -0,0 +1,50 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2016 Inteno Broadband Technology AB
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
*
*/
#ifndef __ATM_H
#define __ATM_H
struct atm_args
{
struct uci_section *atm_sec;
char *ifname;
};
extern DMOBJ tATMObj[];
extern DMOBJ tATMLinkObj[];
extern DMLEAF tATMLinkParams[];
extern DMLEAF tATMLinkStatsParams[] ;
int browseAtmLinkInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int add_atm_link(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_atm_link(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_atm_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_atm_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_atm_link_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_atm_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_atm_link_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_atm_destination_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_atm_encapsulation(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_atm_stats_bytes_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_atm_stats_bytes_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_atm_stats_pack_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_atm_stats_pack_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_atm_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_atm_link_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_atm_destination_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_atm_encapsulation(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_atm_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
#endif

1848
dmtree/tr181/bridging.c Normal file

File diff suppressed because it is too large Load diff

144
dmtree/tr181/bridging.h Normal file
View file

@ -0,0 +1,144 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*
*/
#ifndef __BRIDGING_H
#define __BRIDGING_H
struct bridging_args
{
struct uci_section *bridge_sec;
char *br_key;
char *ifname;
char *br_inst;
};
struct bridging_port_args
{
struct uci_section *bridge_port_sec;
struct uci_section *bridge_sec;
bool vlan;
char *ifname;
};
struct bridging_vlan_args
{
struct uci_section *bridge_vlan_sec;
struct uci_section *bridge_sec;
char *vlan_port;
char *br_inst;
char *ifname;
};
extern DMOBJ tBridgingObj[];
extern DMLEAF tBridgingParams[];
extern DMOBJ tBridgingBridgeObj[];
extern DMLEAF tBridgingBridgeParams[];
extern DMLEAF tBridgingBridgeVLANParams[];
extern DMLEAF tBridgingBridgePortParams[];
extern DMLEAF tBridgingBridgeVLANPortParams[];
extern DMOBJ tBridgingBridgePortObj[];
extern DMLEAF tBridgingBridgePortStatsParams[];
int browseBridgeVlanPortInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseBridgeVlanInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseBridgePortInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseBridgeInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int get_linker_br_port(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
int get_linker_br_vlan(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
int add_bridge(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delete_bridge(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_br_vlan(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delete_br_vlan(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_br_port(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delete_br_port(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_Max_Bridge_Entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_Max_DBridge_Entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_Max_QBridge_Entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_Max_VLAN_Entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_Max_Provider_Bridge_Entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_Max_Filter_Entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_Bridge_Number_Of_Entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_br_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_br_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_br_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_br_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_br_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_br_port_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_vlan_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_vlan_port_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_associated_interfaces(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_br_associated_interfaces(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_br_port_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_br_port_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_br_port_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_br_port_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_br_port_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_last_change(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_management(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_br_port_management(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_br_port_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_br_port_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_br_port_default_user_priority(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_br_port_default_user_priority(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_br_port_priority_regeneration(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_br_port_priority_regeneration(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_br_port_port_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_pvid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_br_port_pvid(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_br_port_tpid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_br_port_tpid(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_port_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_port_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_br_port_stats_tx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_stats_rx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_stats_tx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_stats_rx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_stats_tx_errors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_stats_rx_errors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_stats_tx_unicast_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_stats_rx_unicast_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_stats_tx_discard_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_stats_rx_discard_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_stats_tx_multicast_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_stats_rx_multicast_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_stats_tx_broadcast_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_stats_rx_broadcast_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_stats_rx_unknown_proto_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_vlan_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_br_vlan_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_br_vlan_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_br_vlan_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_br_vlan_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_br_vlan_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_br_vlan_vid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_br_vlan_vid(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_br_vlan_priority(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_br_vlan_priority(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_vlan_port_vlan_ref(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_vlan_port_vlan_ref(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_vlan_port_port_ref(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_vlan_port_port_ref(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_br_vlan_untagged(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_br_vlan_untagged(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

109
dmtree/tr181/device.c Normal file
View file

@ -0,0 +1,109 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
* Author: Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*/
#include "dmuci.h"
#include "dmcwmp.h"
#include "device.h"
#include "deviceinfo.h"
#include "managementserver.h"
#include "times.h"
#include "upnp.h"
#include "x_iopsys_eu_ice.h"
#include "x_iopsys_eu_igmp.h"
#include "x_iopsys_eu_ipacccfg.h"
#include "x_iopsys_eu_logincfg.h"
#include "x_iopsys_eu_power_mgmt.h"
#include "x_iopsys_eu_syslog.h"
#include "softwaremodules.h"
#include "xmpp.h"
#include "x_iopsys_eu_owsd.h"
#include "x_iopsys_eu_dropbear.h"
#include "x_iopsys_eu_buttons.h"
#include "x_iopsys_eu_wifilife.h"
#include "ip.h"
#include "ethernet.h"
#include "bridging.h"
#include "wifi.h"
#include "atm.h"
#include "ptm.h"
#include "dhcpv4.h"
#include "hosts.h"
#include "nat.h"
#include "ppp.h"
#include "routing.h"
#include "userinterface.h"
#include "firewall.h"
#include "dns.h"
#include "users.h"
#include "dsl.h"
#include "dhcpv6.h"
#include "interfacestack.h"
#include "qos.h"
#ifdef BBF_TR104
#include "voice_services.h"
#endif
/* *** CWMP *** */
DMOBJ tEntry181Obj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{(char *)&dmroot, &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE, tRoot_181_Obj, tRoot_181_Params, NULL, BBFDM_BOTH},
{0}
};
DMLEAF tRoot_181_Params[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"InterfaceStackNumberOfEntries", &DMREAD, DMT_UNINT, get_Device_InterfaceStackNumberOfEntries, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
DMOBJ tRoot_181_Obj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{"DeviceInfo", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,tDeviceInfoObj, tDeviceInfoParams, NULL, BBFDM_BOTH},
{"ManagementServer", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,NULL, tManagementServerParams, NULL, BBFDM_BOTH},
{"Time", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tTimeParams, NULL, BBFDM_BOTH},
{"UPnP", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,tUPnPObj, NULL, NULL, BBFDM_BOTH},
#ifdef BBF_TR104
{"Services", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,tServiceObj, NULL, NULL, BBFDM_BOTH},
#endif
{CUSTOM_PREFIX"ICE", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tSe_IceParam, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"IGMP", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tSe_IgmpParam, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"IpAccCfg", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,tSe_IpAccObj, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"LoginCfg", &DMREAD, NULL, NULL, NULL, NULL,NULL, &DMNONE,NULL, tSe_LoginCfgParam, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"PowerManagement", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tSe_PowerManagementParam, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"SyslogCfg", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tSe_SyslogCfgParam, NULL, BBFDM_BOTH},
{"SoftwareModules", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,tSoftwareModulesObj, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"Owsd", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,XIopsysEuOwsdObj, XIopsysEuOwsdParams, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"Dropbear", &DMWRITE, add_dropbear_instance, delete_dropbear_instance, NULL, browseXIopsysEuDropbear, NULL, &DMNONE, NULL, X_IOPSYS_EU_DropbearParams, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"Buttons", &DMREAD, NULL, NULL, NULL, browseXIopsysEuButton, NULL, &DMNONE, NULL, X_IOPSYS_EU_ButtonParams, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"WiFiLife", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE, X_IOPSYS_EU_WiFiLifeObj, X_IOPSYS_EU_WiFiLifeParams, NULL, BBFDM_BOTH},
{"Bridging",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tBridgingObj, tBridgingParams, NULL, BBFDM_BOTH},
{"WiFi",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tWiFiObj, tWiFiParams, NULL, BBFDM_BOTH},
{"IP",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tIPObj, tIPParams, NULL, BBFDM_BOTH},
{"Ethernet", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tEthernetObj, tEthernetParams, NULL, BBFDM_BOTH},
{"DSL",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDSLObj, tDSLParams, NULL, BBFDM_BOTH},
{"ATM",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tATMObj, NULL, NULL, BBFDM_BOTH},
{"PTM", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tPTMObj, NULL, NULL, BBFDM_BOTH},
{"DHCPv4", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDhcpv4Obj, tDHCPv4Params, NULL, BBFDM_BOTH},
{"DHCPv6", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDHCPv6Obj, tDHCPv6Params, NULL, BBFDM_BOTH},
{"Hosts", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tHostsObj, tHostsParams, NULL, BBFDM_BOTH},
{"NAT", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tNATObj, tNATParams, NULL, BBFDM_BOTH},
{"PPP", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tPPPObj, tPPPParams, NULL, BBFDM_BOTH},
{"Routing", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tRoutingObj, tRoutingParams, NULL, BBFDM_BOTH},
{"UserInterface", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tUserInterfaceObj, NULL, NULL, BBFDM_BOTH},
{"Firewall", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tFirewallObj, tFirewallParams, NULL, BBFDM_BOTH},
{"DNS", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDNSObj, tDNSParams, NULL, BBFDM_BOTH},
{"Users", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tUsersObj, tUsersParams, NULL, BBFDM_BOTH},
{"InterfaceStack", &DMREAD, NULL, NULL, NULL, browseInterfaceStackInst, NULL, NULL, NULL, tInterfaceStackParams, NULL, BBFDM_BOTH},
//{"QoS", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tQoSObj, tQoSParams, NULL, BBFDM_BOTH},
{"XMPP", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL,tXMPPObj, tXMPPParams, NULL, BBFDM_BOTH},
{0}
};

20
dmtree/tr181/device.h Normal file
View file

@ -0,0 +1,20 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
* Author: Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*/
#ifndef __DEVICE_H
#define __DEVICE_H
extern DMOBJ tEntry181Obj[];
extern DMOBJ tRoot_181_Obj[];
extern DMLEAF tRoot_181_Params[];
#endif

797
dmtree/tr181/deviceinfo.c Normal file
View file

@ -0,0 +1,797 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2012-2014 PIVA SOFTWARE (www.pivasoftware.com)
* Author: Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author: Feten Besbes <feten.besbes@pivasoftware.com>
*/
#include <ctype.h>
#include <uci.h>
#include <stdio.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/klog.h>
#include "dmcwmp.h"
#include "dmuci.h"
#include "dmubus.h"
#include "dmcommon.h"
#include "deviceinfo.h"
#include "dmjson.h"
/* *** Device.DeviceInfo. *** */
DMOBJ tDeviceInfoObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{CUSTOM_PREFIX"CATV", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tCatTvParams, NULL, BBFDM_BOTH},
{"VendorConfigFile", &DMREAD, NULL, NULL, NULL, browseVcfInst, NULL, NULL, NULL, tDeviceInfoVendorConfigFileParams, NULL, BBFDM_BOTH},
{"VendorLogFile", &DMREAD, NULL, NULL, NULL, browseVlfInst, NULL, NULL, NULL, tDeviceInfoVendorLogFileParams, NULL, BBFDM_BOTH},
{"MemoryStatus", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tDeviceInfoMemoryStatusParams, NULL, BBFDM_BOTH},
{"ProcessStatus", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDeviceInfoProcessStatusObj, tDeviceInfoProcessStatusParams, NULL, BBFDM_BOTH},
{0}
};
DMLEAF tDeviceInfoParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Manufacturer", &DMREAD, DMT_STRING, get_device_manufacturer, NULL, &DMFINFRM, NULL, BBFDM_BOTH},
{"ManufacturerOUI", &DMREAD, DMT_STRING, get_device_manufactureroui, NULL, &DMFINFRM, NULL, BBFDM_BOTH},
{"ModelName", &DMREAD, DMT_STRING, get_device_routermodel, NULL, &DMFINFRM, NULL, BBFDM_BOTH},
{"ProductClass", &DMREAD, DMT_STRING, get_device_productclass, NULL, &DMFINFRM, NULL, BBFDM_BOTH},
{"SerialNumber", &DMREAD, DMT_STRING, get_device_serialnumber, NULL, &DMFINFRM, NULL, BBFDM_BOTH},
{"HardwareVersion", &DMREAD, DMT_STRING, get_device_hardwareversion, NULL, &DMFINFRM, NULL, BBFDM_BOTH},
{"SoftwareVersion", &DMREAD, DMT_STRING, get_device_softwareversion, NULL, &DMFINFRM, &DMACTIVE, BBFDM_BOTH},
{"UpTime", &DMREAD, DMT_UNINT, get_device_info_uptime, NULL, NULL, NULL, BBFDM_BOTH},
{"DeviceLog", &DMREAD, DMT_STRING, get_device_devicelog, NULL, NULL, NULL, BBFDM_BOTH},
{"SpecVersion", &DMREAD, DMT_STRING, get_device_specversion, NULL, &DMFINFRM, NULL, BBFDM_BOTH},
{"ProvisioningCode", &DMWRITE, DMT_STRING, get_device_provisioningcode, set_device_provisioningcode, &DMFINFRM, &DMACTIVE, BBFDM_BOTH},
{CUSTOM_PREFIX"BaseMacAddr", &DMREAD, DMT_STRING, get_base_mac_addr, NULL, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"CATVEnabled", &DMWRITE, DMT_STRING, get_catv_enabled, set_device_catvenabled, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"MemoryBank", &DMWRITE, DMT_STRING, get_device_memory_bank, set_device_memory_bank, NULL, NULL, BBFDM_BOTH},
{0}
};
/* *** Device.DeviceInfo.VendorConfigFile.{i}. *** */
DMLEAF tDeviceInfoVendorConfigFileParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Alias", &DMWRITE, DMT_STRING, get_vcf_alias, set_vcf_alias, NULL, NULL, BBFDM_BOTH},
{"Name", &DMREAD, DMT_STRING, get_vcf_name, NULL, NULL, NULL, BBFDM_BOTH},
{"Version", &DMREAD, DMT_STRING, get_vcf_version, NULL, NULL, NULL, BBFDM_BOTH},
{"Date", &DMREAD, DMT_TIME, get_vcf_date, NULL, NULL, NULL, BBFDM_BOTH},
{"Description", &DMREAD, DMT_STRING, get_vcf_desc, NULL, NULL, NULL, BBFDM_BOTH},
{"UseForBackupRestore", &DMREAD, DMT_BOOL, get_vcf_backup_restore, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/* *** Device.DeviceInfo.MemoryStatus. *** */
DMLEAF tDeviceInfoMemoryStatusParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Total", &DMREAD, DMT_UNINT, get_memory_status_total, NULL, NULL, NULL, BBFDM_BOTH},
{"Free", &DMREAD, DMT_UNINT, get_memory_status_free, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/* *** Device.DeviceInfo.ProcessStatus. *** */
DMOBJ tDeviceInfoProcessStatusObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{"Process", &DMREAD, NULL, NULL, NULL, browsePocessEntriesInst, NULL, NULL, NULL, tDeviceInfoProcessStatusProcessParams, NULL, BBFDM_BOTH},
{0}
};
DMLEAF tDeviceInfoProcessStatusParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"CPUUsage", &DMREAD, DMT_UNINT, get_process_cpu_usage, NULL, NULL, NULL, BBFDM_BOTH},
{"ProcessNumberOfEntries", &DMREAD, DMT_UNINT, get_process_number_of_entries, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/* *** Device.DeviceInfo.ProcessStatus.Process.{i}. *** */
DMLEAF tDeviceInfoProcessStatusProcessParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"PID", &DMREAD, DMT_UNINT, get_process_pid, NULL, NULL, NULL, BBFDM_BOTH},
{"Command", &DMREAD, DMT_STRING, get_process_command, NULL, NULL, NULL, BBFDM_BOTH},
{"Size", &DMREAD, DMT_UNINT, get_process_size, NULL, NULL, NULL, BBFDM_BOTH},
{"Priority", &DMREAD, DMT_UNINT, get_process_priority, NULL, NULL, NULL, BBFDM_BOTH},
{"CPUTime", &DMREAD, DMT_UNINT, get_process_cpu_time, NULL, NULL, NULL, BBFDM_BOTH},
{"State", &DMREAD, DMT_STRING, get_process_state, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/*** DeviceInfo.X_IOPSYS_EU_CATV. ***/
DMLEAF tCatTvParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Enabled", &DMWRITE, DMT_STRING, get_catv_enabled, set_device_catvenabled, NULL, NULL, BBFDM_BOTH},
{"OpticalInputLevel", &DMREAD, DMT_STRING, get_catv_optical_input_level, NULL, NULL, NULL, BBFDM_BOTH},
{"RFOutputLevel", &DMREAD, DMT_STRING, get_catv_rf_output_level, NULL, NULL, NULL, BBFDM_BOTH},
{"Temperature", &DMREAD, DMT_STRING, get_catv_temperature, NULL, NULL, NULL, BBFDM_BOTH},
{"Voltage", &DMREAD, DMT_STRING, get_catv_voltage, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/* *** Device.DeviceInfo.VendorLogFile.{i}. *** */
DMLEAF tDeviceInfoVendorLogFileParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Alias", &DMWRITE, DMT_STRING, get_vlf_alias, set_vlf_alias, NULL, NULL, BBFDM_BOTH},
{"Name", &DMREAD, DMT_STRING, get_vlf_name, NULL, NULL, NULL, BBFDM_BOTH},
{"MaximumSize", &DMREAD, DMT_UNINT, get_vlf_max_size, NULL, NULL, NULL, BBFDM_BOTH},
{"Persistent", &DMREAD, DMT_BOOL, get_vlf_persistent, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/*************************************************************
* INIT
/*************************************************************/
inline int init_process_args(struct process_args *args, char *pid, char *command, char* size, char* priority, char *cputime, char *state)
{
args->pid = pid;
args->command= command;
args->size= size;
args->priority= priority;
args->state= state;
args->cputime= cputime;
return 0;
}
/*
*DeviceInfo. functions
*/
char *get_deviceid_manufacturer()
{
char *v;
dmuci_get_option_value_string("cwmp","cpe","manufacturer", &v);
return v;
}
char *get_deviceid_manufactureroui()
{
char *v;
char str[16];
char *mac = NULL;
json_object *res;
FILE *nvrammac=NULL;
char macreadfile[18]={0};
dmuci_get_option_value_string("cwmp", "cpe", "override_oui", &v);
if (v[0] == '\0')
{
dmubus_call("router.system", "info", UBUS_ARGS{{}}, 0, &res);
if(!(res)){
db_get_value_string("hw", "board", "BaseMacAddr", &mac);
if(!mac || strlen(mac)==0 ){
if ((nvrammac = fopen("/proc/nvram/BaseMacAddr", "r")) == NULL)
{
mac = NULL;
}
else{
fscanf(nvrammac,"%[^\n]", macreadfile);
macreadfile[17]='\0';
sscanf(macreadfile,"%2c %2c %2c", str, str+2, str+4);
str[6]='\0';
v = dmstrdup(str); // MEM WILL BE FREED IN DMMEMCLEAN
fclose(nvrammac);
return v;
}
}
}
else
mac = dm_ubus_get_value(res, 2, "system", "basemac");
if(mac)
{
size_t ln = strlen(mac);
if (ln<17) goto not_found;
sscanf (mac,"%2c:%2c:%2c",str,str+2,str+4);
str[6] = '\0';
v = dmstrdup(str); // MEM WILL BE FREED IN DMMEMCLEAN
return v;
}
else
goto not_found;
}
return v;
not_found:
v = "";
return v;
}
char *get_deviceid_productclass()
{
char *v, *tmp, *val;
dmuci_get_option_value_string("cwmp", "cpe", "override_productclass", &v);
if (v[0] == '\0')
{
db_get_value_string("hw", "board", "iopVerBoard", &v);
tmp = dmstrdup(v);// MEM WILL BE FREED IN DMMEMCLEAN
val = tmp;
return val;
}
tmp = dmstrdup(v);// MEM WILL BE FREED IN DMMEMCLEAN
val = tmp;
return val;
}
char *get_deviceid_serialnumber()
{
char *v;
db_get_value_string("hw", "board", "serialNumber", &v);
return v;
}
char *get_softwareversion()
{
char *v, *tmp, *val;
db_get_value_string("hw", "board", "iopVersion", &v);
tmp = dmstrdup(v);// MEM WILL BE FREED IN DMMEMCLEAN
val = tmp;
return val;
}
/*#Device.DeviceInfo.Manufacturer!UCI:cwmp/cwmp,cpe/manufacturer*/
int get_device_manufacturer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = get_deviceid_manufacturer();
return 0;
}
/*#Device.DeviceInfo.ManufacturerOUI!UCI:cwmp/cwmp,cpe/override_oui*/
int get_device_manufactureroui(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = get_deviceid_manufactureroui();
return 0;
}
/*#Device.DeviceInfo.ProductClass!UCI:cwmp/cwmp,cpe/override_productclass*/
int get_device_productclass(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = get_deviceid_productclass();
return 0;
}
int get_device_serialnumber(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = get_deviceid_serialnumber();
return 0;
}
int get_device_softwareversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = get_softwareversion();
return 0;
}
int get_device_hardwareversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
db_get_value_string("hw", "board", "hardwareVersion", value);
return 0;
}
int get_device_routermodel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
db_get_value_string("hw", "board", "routerModel", value);
return 0;
}
int get_device_info_uptime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
FILE* fp = NULL;
char *pch, *spch;
char buf[64];
*value = "0";
fp = fopen(UPTIME, "r");
if (fp != NULL) {
fgets(buf, 64, fp);
pch = strtok_r(buf, ".", &spch);
if (pch)
*value = dmstrdup(pch); // MEM WILL BE FREED IN DMMEMCLEAN
fclose(fp);
}
return 0;
}
int get_device_devicelog(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "";
int i = 0, nbrlines = 4;
char buff[512], *msg = NULL;
int len = klogctl(3 , buff, sizeof(buff) - 1); /* read ring buffer */
if (len <= 0)
return 0;
buff[len] = '\0';
char *p = buff;
while (*p) { //TODO to optimize, we can avoid this if the '<' and '>' does not cause problem in the tests.
if (*p == '<') {
*p = '(';
if (p == buff || *(p-1) == '\n') {
if(msg == NULL) msg = p;
i++;
if (i == nbrlines) {
*(p-1) = '\0';
break;
}
}
}
else if (*p == '>')
*p = ')';
p++;
}
if(msg == NULL)
*value = "";
else
*value = dmstrdup(msg);// MEM WILL BE FREED IN DMMEMCLEAN
return 0;
}
int get_device_specversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "1.0";
return 0;
}
/*#Device.DeviceInfo.ProvisioningCode!UCI:cwmp/cwmp,cpe/provisioning_code*/
int get_device_provisioningcode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "cpe", "provisioning_code", value);
return 0;
}
int set_device_provisioningcode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("cwmp", "cpe", "provisioning_code", value);
return 0;
}
return 0;
}
int get_base_mac_addr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("router.system", "info", UBUS_ARGS{{}}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dm_ubus_get_value(res, 2, "system", "basemac");
return 0;
}
int get_device_memory_bank(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("router.system", "memory_bank", UBUS_ARGS{{}}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dm_ubus_get_value(res, 1, "code");
return 0;
}
int set_device_memory_bank(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmubus_call_set("router.system", "memory_bank", UBUS_ARGS{{"bank", value, Integer}}, 1);
return 0;
}
return 0;
}
int get_catv_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *catv;
dmuci_get_option_value_string("catv", "catv", "enable", &catv);
if (strcmp(catv, "on") == 0) {
*value = "1";
}
else
*value = "0";
return 0;
}
int set_device_catvenabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
char *stat;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if (b)
stat = "on";
else
stat = "off";
dmuci_set_value("catv", "catv", "enable", stat);
return 0;
}
return 0;
}
int get_catv_optical_input_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
char *str;
*value = "";
dmubus_call("catv", "vpd", UBUS_ARGS{}, 0, &res);
if (!res)
return 0;
*value = dm_ubus_get_value(res, 1, "VPD");
return 0;
}
int get_catv_rf_output_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
char *str;
*value = "";
dmubus_call("catv", "rf", UBUS_ARGS{}, 0, &res);
if (!res)
return 0;
*value = dm_ubus_get_value(res, 1, "RF");
return 0;
}
int get_catv_temperature(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
char *str;
*value = "";
dmubus_call("catv", "temp", UBUS_ARGS{}, 0, &res);
if (!res)
return 0;
*value = dm_ubus_get_value(res, 1, "Temperature");
return 0;
}
int get_catv_voltage(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
char *str;
*value = "";
dmubus_call("catv", "vcc", UBUS_ARGS{}, 0, &res);
if (!res)
return 0;
*value = dm_ubus_get_value(res, 1, "VCC");
return 0;
}
int get_vcf_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *vcf_sec = (struct uci_section *)data;
dmuci_get_value_by_section_string(vcf_sec, "name", value);
return 0;
}
int get_vcf_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *vcf_sec = (struct uci_section *)data;
dmuci_get_value_by_section_string(vcf_sec, "version", value);
return 0;
}
int get_vcf_date(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
DIR *dir;
struct dirent *d_file;
struct stat attr;
char path[128];
char date[sizeof "AAAA-MM-JJTHH:MM:SS.000Z"];
struct uci_section *vcf_sec = (struct uci_section *)data;
*value = "";
dmuci_get_value_by_section_string(vcf_sec, "name", value);
if ((dir = opendir (DEFAULT_CONFIG_DIR)) != NULL) {
while ((d_file = readdir (dir)) != NULL) {
if(strcmp(*value, d_file->d_name) == 0) {
sprintf(path, DEFAULT_CONFIG_DIR"%s", d_file->d_name);
stat(path, &attr);
strftime(date, sizeof date, "%Y-%m-%dT%H:%M:%S.000Z", localtime(&attr.st_mtime));
*value = dmstrdup(date);
}
}
closedir (dir);
}
return 0;
}
int get_vcf_backup_restore(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *vcf_sec = (struct uci_section *)data;
dmuci_get_value_by_section_string(vcf_sec, "backup_restore", value);
return 0;
}
int get_vcf_desc(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *vcf_sec = (struct uci_section *)data;
dmuci_get_value_by_section_string(vcf_sec, "description", value);
return 0;
}
int get_vcf_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *vcf_sec = (struct uci_section *)data;
dmuci_get_value_by_section_string(vcf_sec, "vcf_alias", value);
return 0;
}
int set_vcf_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *vcf_sec = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(vcf_sec, "vcf_alias", value);
return 0;
}
return 0;
}
int lookup_vcf_name(char *instance, char **value)
{
struct uci_section *s = NULL;
uci_path_foreach_option_eq(icwmpd, DMMAP, "vcf", "vcf_instance", instance, s) {
dmuci_get_value_by_section_string(s, "name", value);
}
return 0;
}
int check_file_dir(char *name)
{
DIR *dir;
struct dirent *d_file;
if ((dir = opendir (DEFAULT_CONFIG_DIR)) != NULL) {
while ((d_file = readdir (dir)) != NULL) {
if(strcmp(name, d_file->d_name) == 0) {
closedir(dir);
return 1;
}
}
closedir(dir);
}
return 0;
}
int get_vlf_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *sys_log_sec = (struct uci_section *)data;
dmuci_get_value_by_section_string(sys_log_sec, "vlf_alias", value);
return 0;
}
int set_vlf_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *sys_log_sec = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(sys_log_sec, "vlf_alias", value);
return 0;
}
return 0;
}
int get_vlf_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *sys_log_sec = (struct uci_section *)data;
dmuci_get_value_by_section_string(sys_log_sec, "log_file", value);
return 0;
}
int get_vlf_max_size (char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *sys_log_sec = (struct uci_section *)data;
dmuci_get_value_by_section_string(sys_log_sec, "log_size", value);
*value = (**value) ? *value : "0";
return 0;
}
int get_vlf_persistent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "0";
return 0;
}
/*#Device.DeviceInfo.MemoryStatus.Total!UBUS:router.system/info//memoryKB.total*/
int get_memory_status_total(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value){
json_object *res;
dmubus_call("router.system", "info", UBUS_ARGS{{}}, 0, &res);
*value = dm_ubus_get_value(res, 2, "memoryKB", "total");
return 0;
}
/*#Device.DeviceInfo.MemoryStatus.Free!UBUS:router.system/info//memoryKB.free*/
int get_memory_status_free(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value){
json_object *res;
dmubus_call("router.system", "info", UBUS_ARGS{{}}, 0, &res);
*value = dm_ubus_get_value(res, 2, "memoryKB", "free");
return 0;
}
/*#Device.DeviceInfo.ProcessStatus.CPUUsage!UBUS:router.system/info//system.cpu_per*/
int get_process_cpu_usage(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value){
json_object *res;
dmubus_call("router.system", "info", UBUS_ARGS{{}}, 0, &res);
*value = dm_ubus_get_value(res, 2, "system", "cpu_per");
return 0;
}
int get_process_number_of_entries(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value){
json_object *res, *processes;
int nbre_process = 0;
dmubus_call("router.system", "processes", UBUS_ARGS{{}}, 0, &res);
processes = json_object_object_get(res, "processes");
nbre_process= json_object_array_length(processes);
dmasprintf(value,"%d",nbre_process);
return 0;
}
int get_process_pid(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value){
struct process_args *proc_args= (struct process_args*) data;
*value= proc_args->pid;
return 0;
}
int get_process_command(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value){
struct process_args *proc_args= (struct process_args*) data;
*value= proc_args->command;
return 0;
}
int get_process_size(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value){
struct process_args *proc_args= (struct process_args*) data;
if(proc_args->size!=NULL) *value= proc_args->size;
else *value= "0";
return 0;
}
int get_process_priority(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value){
struct process_args *proc_args= (struct process_args*) data;
long val;
if(proc_args->priority!=NULL) {
val = atol(proc_args->priority);
if(val<0) val=0;
dmasprintf(value, "%ld", val);
}
else *value= "0";
return 0;
}
int get_process_cpu_time(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value){
struct process_args *proc_args= (struct process_args*) data;
if(proc_args->cputime!=NULL) *value= proc_args->cputime;
return 0;
}
int get_process_state(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value){
struct process_args *proc_args= (struct process_args*) data;
if(strchr(proc_args->state, 'S')!=NULL) *value="Sleeping";
else if(strchr(proc_args->state, 'R')!=NULL) *value= "Running";
else if(strchr(proc_args->state, 'T')!=NULL) *value= "Stopped";
else if(strchr(proc_args->state, 'D')!=NULL) *value= "Uninterruptible";
else if(strchr(proc_args->state, 'Z')!=NULL) *value= "Zombie";
else *value= proc_args->state;
return 0;
}
int browsePocessEntriesInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance){
json_object *res, *processes, *fields, *process;
char *pid_field, *command_field, *state_field, *mem_size_field, *cpu_time_field, *priority_field, *pid, *command, *mem_size, *state, *cpu_time, *priority, *idx, *idx_last= NULL;
int i, id=0;
struct process_args proc_args={};
dmubus_call("router.system", "processes", UBUS_ARGS{{}}, 0, &res);
fields = json_object_object_get(res, "fields");
processes = json_object_object_get(res, "processes");
size_t nbre_process = json_object_array_length(processes);
pid_field = (char *)dmjson_get_value_in_array_idx(fields, 0, 0, NULL);
command_field = (char *)dmjson_get_value_in_array_idx(fields, 7, 0, NULL);
state_field = (char *)dmjson_get_value_in_array_idx(fields, 3, 0, NULL);
mem_size_field = (char *)dmjson_get_value_in_array_idx(fields, 4, 0, NULL);
priority_field = (char *)dmjson_get_value_in_array_idx(fields, 8, 0, NULL);
cpu_time_field = (char *)dmjson_get_value_in_array_idx(fields, 9, 0, NULL);
if(nbre_process>0){
for(i=0; i<nbre_process; i++){
process= json_object_array_get_idx(processes, i);
pid = dmjson_get_value(process, 1, pid_field);
command = dmjson_get_value(process, 1, command_field);
state = dmjson_get_value(process, 1, state_field);
mem_size= dmjson_get_value(process, 1, mem_size_field);
cpu_time= dmjson_get_value(process, 1, cpu_time_field);
priority= dmjson_get_value(process, 1, priority_field);
init_process_args(&proc_args, pid, command, mem_size, priority, cpu_time, state);
idx = handle_update_instance(2, dmctx, &idx_last, update_instance_without_section, 1, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&proc_args, idx) == DM_STOP)
break;
}
}
return 0;
}
int browseVcfInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *vcf = NULL, *vcf_last = NULL, *name;
struct uci_section *s = NULL, *del_sec = NULL;
DIR *dir;
struct dirent *d_file;
if ((dir = opendir (DEFAULT_CONFIG_DIR)) != NULL) {
while ((d_file = readdir (dir)) != NULL) {
if(d_file->d_name[0] == '.')
continue;
update_section_list(DMMAP,"vcf", "name", 1, d_file->d_name, NULL, NULL, "backup_restore", "1");
}
closedir (dir);
}
uci_path_foreach_sections(icwmpd, DMMAP, "vcf", s) {
dmuci_get_value_by_section_string(s, "name", &name);
if(del_sec) {
DMUCI_DELETE_BY_SECTION(icwmpd, del_sec, NULL, NULL);
del_sec = NULL;
}
if (check_file_dir(name) == 0) {
del_sec = s;
continue;
}
vcf = handle_update_instance(1, dmctx, &vcf_last, update_instance_alias_icwmpd, 3, s, "vcf_instance", "vcf_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)s, vcf) == DM_STOP)
break;
}
if(del_sec)
DMUCI_DELETE_BY_SECTION(icwmpd, del_sec, NULL, NULL);
return 0;
}
//Browse VendorLogFile instances
int browseVlfInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
struct uci_section *sys_log_sec, *s, *dm_sec, *del_sec=NULL;
char *instance, *last_instance, *log_file,*log_size, *add_value, *lfile;
int i=1, n=0;
uci_foreach_sections("system", "system", sys_log_sec) {
if(!sys_log_sec)
break;
dmuci_get_value_by_section_string(sys_log_sec, "log_file", &log_file);
dmuci_get_value_by_section_string(sys_log_sec, "log_size", &log_size);
uci_path_foreach_sections(icwmpd, "dmmap", "vlf", dm_sec) {
if(dm_sec)
break;
}
if(!dm_sec){
update_section_list(DMMAP,"vlf", NULL, i++, NULL, "log_file", log_file, "log_size", log_size);
}
else{
DMUCI_SET_VALUE_BY_SECTION(icwmpd, dm_sec, "log_file", log_file);
DMUCI_SET_VALUE_BY_SECTION(icwmpd, dm_sec, "log_size", log_size);
}
}
uci_path_foreach_sections(icwmpd, "dmmap", "vlf", dm_sec) {
instance = handle_update_instance(1, dmctx, &last_instance, update_instance_alias_icwmpd, 3, dm_sec, "vlf_instance", "vlf_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)dm_sec, instance) == DM_STOP){
break;
}
}
return 0;
}

96
dmtree/tr181/deviceinfo.h Normal file
View file

@ -0,0 +1,96 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2012-2014 PIVA SOFTWARE (www.pivasoftware.com)
* Author: Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author: Feten Besbes <feten.besbes@pivasoftware.com>
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
*/
#ifndef __DEVICE_INFO_H
#define __DEVICE_INFO_H
#include "dmcwmp.h"
#define UPTIME "/proc/uptime"
#define DEFAULT_CONFIG_DIR "/etc/config/"
extern DMLEAF tDeviceInfoParams[];
extern DMLEAF tCatTvParams[];
extern DMLEAF tDeviceInfoVendorConfigFileParams[];
extern DMLEAF tDeviceInfoVendorLogFileParams[];
extern DMLEAF tDeviceInfoMemoryStatusParams[];
extern DMOBJ tDeviceInfoProcessStatusObj[];
extern DMLEAF tDeviceInfoProcessStatusParams[];
extern DMOBJ tDeviceInfoObj[];
extern DMLEAF tDeviceInfoProcessStatusProcessParams[];
struct process_args{
char *pid;
char *command;
char* size;
char* priority;
char *cputime;
char *state;
};
char *get_deviceid_manufacturer();
char *get_deviceid_manufactureroui();
char *get_deviceid_productclass();
char *get_deviceid_serialnumber();
char *get_softwareversion();
int lookup_vcf_name(char *instance, char **value);
int browseVcfInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseVlfInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browsePocessEntriesInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int get_device_manufacturer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_device_manufactureroui(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_device_routermodel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_device_productclass(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_device_serialnumber(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_device_hardwareversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_device_softwareversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_device_info_uptime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_device_devicelog(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_device_specversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_device_provisioningcode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_base_mac_addr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_catv_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_device_memory_bank(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_catv_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_catv_optical_input_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_catv_rf_output_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_catv_temperature(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_catv_voltage(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_vcf_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_vcf_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_vcf_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_vcf_date(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_vcf_desc(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_vcf_backup_restore(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_vlf_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_vlf_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_vlf_max_size(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_vlf_persistent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_memory_status_total(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_memory_status_free(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_process_cpu_usage(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_process_number_of_entries(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_process_pid(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_process_command(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_process_size(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_process_priority(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_process_cpu_time(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_process_state(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_device_provisioningcode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_device_catvenabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_device_memory_bank(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_device_catvenabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_vcf_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_vlf_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

3445
dmtree/tr181/dhcpv4.c Normal file

File diff suppressed because it is too large Load diff

241
dmtree/tr181/dhcpv4.h Normal file
View file

@ -0,0 +1,241 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2016 Inteno Broadband Technology AB
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
*
*/
#ifndef __DHCP_H
#define __DHCP_H
#include <json-c/json.h>
struct dhcp_args
{
struct uci_section *dhcp_sec;
char *interface;
};
struct dhcp_static_args
{
struct uci_section *dhcpsection;
};
struct client_args
{
json_object *client;
char *key;
};
struct dhcp_client_ipv4address_args {
char *mac;
char *ip;
unsigned int leasetime;
};
struct dhcp_client_args {
struct uci_section *dhcp_client_conf;
struct uci_section *dhcp_client_dm;
struct uci_section *macclassifier;
struct uci_section *vendorclassidclassifier;
struct uci_section *userclassclassifier;
char *ip;
char *mask;
};
struct dhcp_client_option_args {
struct uci_section *opt_sect;
struct uci_section *client_sect;
char *option_tag;
char *value;
};
extern DMOBJ tDhcpv4Obj[];
extern DMOBJ tDhcpv4ServerObj[];
extern DMOBJ tDhcpServerPoolObj[];
extern DMOBJ tDhcpServerPoolClientObj[];
extern DMLEAF tDhcpServerPoolParams[];
extern DMLEAF tDhcpServerPoolAddressParams[];
extern DMLEAF tDhcpServerPoolClientParams[];
extern DMLEAF tDhcpServerPoolClientIPv4AddressParams[];
extern DMLEAF tDHCPv4Params[];
extern DMOBJ tDHCPv4ClientObj[];
extern DMLEAF tDHCPv4ClientParams[];
extern DMLEAF tDHCPv4ClientSentOptionParams[];
extern DMLEAF tDHCPv4ClientReqOptionParams[];
extern DMOBJ tDHCPv4ServerObj[];
extern DMLEAF tDHCPv4ServerParams[];
extern DMLEAF tDHCPv4ServerPoolOptionParams[];
extern DMLEAF tDHCPv4ServerPoolClientIPv4AddressParams[];
extern DMLEAF tDHCPv4ServerPoolClientOptionParams[];
extern DMOBJ tDHCPv4RelayObj[];
extern DMLEAF tDHCPv4RelayParams[];
extern DMLEAF tDHCPv4RelayForwardingParams[];
int browseDhcpInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseDhcpStaticInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseDhcpClientInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseDhcpClientIPv4Inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseDHCPv4ClientInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseDHCPv4ClientSentOptionInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseDHCPv4ClientReqOptionInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseDHCPv4ServerPoolOptionInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseDHCPv4ServerPoolClientOptionInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseDHCPv4RelayForwardingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int add_dhcp_server(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_dhcp_server(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_dhcp_staticaddress(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_dhcp_staticaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int addObjDHCPv4Client(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delObjDHCPv4Client(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int addObjDHCPv4ClientSentOption(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delObjDHCPv4ClientSentOption(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int addObjDHCPv4ClientReqOption(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delObjDHCPv4ClientReqOption(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int addObjDHCPv4ServerPoolOption(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delObjDHCPv4ServerPoolOption(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int addObjDHCPv4RelayForwarding(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delObjDHCPv4RelayForwarding(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_server_pool_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dns_server(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_configurable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_interval_address_min(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_interval_address_max(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_reserved_addresses(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_subnetmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_iprouters(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_leasetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_domainname(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_static_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_staticaddress_chaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_staticaddress_yiaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_client_chaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_client_ipv4address_ip_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_client_ipv4address_leasetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_sever_pool_order(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_static_address_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_option_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_clients_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_client_active(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_server_pool_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dns_server(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_configurable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_address_min(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_address_max(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_reserved_addresses(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_subnetmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_iprouters(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_leasetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_domainname(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_interface_linker_parameter(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_static_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_staticaddress_chaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_staticaddress_yiaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_sever_pool_order(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_dhcp_client_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
int set_section_order(char *package, char *dmpackage, char* sect_type, struct uci_section *dmmap_sect, struct uci_section *conf, int set_force, char* order);
int get_DHCPv4_ClientNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv4Client_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4Client_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4Client_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4Client_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4Client_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4Client_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4Client_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv4Client_DHCPStatus(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv4Client_Renew(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4Client_Renew(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4Client_IPAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv4Client_SubnetMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv4Client_IPRouters(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv4Client_DNSServers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv4Client_LeaseTimeRemaining(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv4Client_DHCPServer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv4Client_PassthroughEnable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4Client_PassthroughEnable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4Client_PassthroughDHCPPool(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4Client_PassthroughDHCPPool(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4Client_SentOptionNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv4Client_ReqOptionNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv4ClientSentOption_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4ClientSentOption_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4ClientSentOption_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4ClientSentOption_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4ClientSentOption_Tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4ClientSentOption_Tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4ClientSentOption_Value(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4ClientSentOption_Value(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4ClientReqOption_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4ClientReqOption_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4ClientReqOption_Order(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4ClientReqOption_Order(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4ClientReqOption_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4ClientReqOption_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4ClientReqOption_Tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4ClientReqOption_Tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4ClientReqOption_Value(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv4Server_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4Server_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4ServerPoolOption_Tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4ServerPoolOption_Tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4Server_PoolNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv4ServerPoolOption_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4ServerPoolOption_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4ServerPoolOption_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4ServerPoolOption_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4ServerPoolOption_Value(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4ServerPoolOption_Value(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4ServerPoolClientOption_Tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv4RelayForwarding_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4RelayForwarding_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4RelayForwarding_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv4RelayForwarding_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4RelayForwarding_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4RelayForwarding_Order(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4RelayForwarding_Order(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4RelayForwarding_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4RelayForwarding_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4RelayForwarding_VendorClassID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4RelayForwarding_VendorClassID(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4RelayForwarding_VendorClassIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4RelayForwarding_VendorClassIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4RelayForwarding_VendorClassIDMode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4RelayForwarding_VendorClassIDMode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4RelayForwarding_ClientID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4RelayForwarding_ClientID(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4RelayForwarding_ClientIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4RelayForwarding_ClientIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4RelayForwarding_UserClassID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4RelayForwarding_UserClassID(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4RelayForwarding_UserClassIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4RelayForwarding_UserClassIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4RelayForwarding_Chaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4RelayForwarding_Chaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4RelayForwarding_ChaddrMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4RelayForwarding_ChaddrMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4RelayForwarding_ChaddrExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4RelayForwarding_ChaddrExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4RelayForwarding_LocallyServed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4RelayForwarding_LocallyServed(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4RelayForwarding_DHCPServerIPAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4RelayForwarding_DHCPServerIPAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4ServerPoolClientOption_Value(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv4Relay_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv4Relay_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv4Relay_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv4Relay_ForwardingNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
#endif

2076
dmtree/tr181/dhcpv6.c Normal file

File diff suppressed because it is too large Load diff

190
dmtree/tr181/dhcpv6.h Normal file
View file

@ -0,0 +1,190 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
* Author: Omar Kallel <omar.kallel@pivasoftware.com>
*/
#ifndef __DHCPV6_H
#define __DHCPV6_H
extern DMOBJ tDHCPv6Obj[];
extern DMLEAF tDHCPv6Params[];
extern DMOBJ tDHCPv6ClientObj[];
extern DMLEAF tDHCPv6ClientParams[];
extern DMLEAF tDHCPv6ClientServerParams[];
extern DMLEAF tDHCPv6ClientSentOptionParams[];
extern DMLEAF tDHCPv6ClientReceivedOptionParams[];
extern DMOBJ tDHCPv6ServerObj[];
extern DMLEAF tDHCPv6ServerParams[];
extern DMOBJ tDHCPv6ServerPoolObj[];
extern DMLEAF tDHCPv6ServerPoolParams[];
extern DMOBJ tDHCPv6ServerPoolClientObj[];
extern DMLEAF tDHCPv6ServerPoolClientParams[];
extern DMLEAF tDHCPv6ServerPoolClientIPv6AddressParams[];
extern DMLEAF tDHCPv6ServerPoolClientIPv6PrefixParams[];
extern DMLEAF tDHCPv6ServerPoolClientOptionParams[];
extern DMLEAF tDHCPv6ServerPoolOptionParams[];
struct dhcpv6_client_args {
struct uci_section *dhcp_client_conf;
struct uci_section *dhcp_client_dm;
char *ip;
};
struct dhcpv6_args
{
struct uci_section *dhcp_sec;
char *interface;
};
struct clientv6_args
{
json_object *client;
json_object *clientparam;
int idx;
};
struct dhcpv6_client_option_args {
struct uci_section *opt_sect;
struct uci_section *client_sect;
char *option_tag;
char *value;
};
int browseDHCPv6ClientInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseDHCPv6ClientServerInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseDHCPv6ClientSentOptionInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseDHCPv6ClientReceivedOptionInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseDHCPv6ServerPoolInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseDHCPv6ServerPoolClientInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseDHCPv6ServerPoolOptionInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseDHCPv6ServerPoolClientIPv6AddressInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseDHCPv6ServerPoolClientIPv6PrefixInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseDHCPv6ServerPoolClientOptionInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int addObjDHCPv6Client(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delObjDHCPv6Client(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int addObjDHCPv6ClientSentOption(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delObjDHCPv6ClientSentOption(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int addObjDHCPv6ServerPool(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delObjDHCPv6ServerPool(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int addObjDHCPv6ServerPoolOption(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delObjDHCPv6ServerPoolOption(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_DHCPv6_ClientNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6Client_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6Client_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6Client_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6Client_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6Client_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6Client_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6Client_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6Client_DUID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6Client_RequestAddresses(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6Client_RequestAddresses(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6Client_RequestPrefixes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6Client_RequestPrefixes(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6Client_RapidCommit(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6Client_RapidCommit(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6Client_Renew(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6Client_Renew(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6Client_SuggestedT1(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6Client_SuggestedT1(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6Client_SuggestedT2(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6Client_SuggestedT2(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6Client_SupportedOptions(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6Client_RequestedOptions(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6Client_RequestedOptions(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6Client_ServerNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6Client_SentOptionNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6Client_ReceivedOptionNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ClientServer_SourceAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ClientServer_DUID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ClientServer_InformationRefreshTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ClientSentOption_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ClientSentOption_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ClientSentOption_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ClientSentOption_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ClientSentOption_Tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ClientSentOption_Tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ClientSentOption_Value(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ClientSentOption_Value(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ClientReceivedOption_Tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ClientReceivedOption_Value(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ClientReceivedOption_Server(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6Server_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6Server_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6Server_PoolNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ServerPool_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPool_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ServerPool_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ServerPool_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPool_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ServerPool_Order(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPool_Order(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ServerPool_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPool_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ServerPool_DUID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPool_DUID(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ServerPool_DUIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPool_DUIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ServerPool_VendorClassID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPool_VendorClassID(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ServerPool_VendorClassIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPool_VendorClassIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ServerPool_UserClassID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPool_UserClassID(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ServerPool_UserClassIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPool_UserClassIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ServerPool_SourceAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPool_SourceAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ServerPool_SourceAddressMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPool_SourceAddressMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ServerPool_SourceAddressExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPool_SourceAddressExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ServerPool_IANAEnable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPool_IANAEnable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ServerPool_IANAManualPrefixes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPool_IANAManualPrefixes(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ServerPool_IANAPrefixes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ServerPool_IAPDEnable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPool_IAPDEnable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ServerPool_IAPDManualPrefixes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPool_IAPDManualPrefixes(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ServerPool_IAPDPrefixes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ServerPool_IAPDAddLength(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPool_IAPDAddLength(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ServerPool_ClientNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ServerPool_OptionNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ServerPoolClient_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPoolClient_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ServerPoolClient_SourceAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ServerPoolClient_Active(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ServerPoolClient_IPv6AddressNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ServerPoolClient_IPv6PrefixNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ServerPoolClient_OptionNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ServerPoolClientIPv6Address_IPAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ServerPoolClientIPv6Address_PreferredLifetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ServerPoolClientIPv6Address_ValidLifetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ServerPoolClientIPv6Prefix_Prefix(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ServerPoolClientIPv6Prefix_PreferredLifetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ServerPoolClientIPv6Prefix_ValidLifetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ServerPoolClientOption_Tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ServerPoolClientOption_Value(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DHCPv6ServerPoolOption_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPoolOption_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ServerPoolOption_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPoolOption_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ServerPoolOption_Tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPoolOption_Tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ServerPoolOption_Value(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPoolOption_Value(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DHCPv6ServerPoolOption_PassthroughClient(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DHCPv6ServerPoolOption_PassthroughClient(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif //__DHCPV6_H

1046
dmtree/tr181/dns.c Normal file

File diff suppressed because it is too large Load diff

98
dmtree/tr181/dns.h Normal file
View file

@ -0,0 +1,98 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*/
#ifndef _DNS_H
#define _DNS_H
extern DMOBJ tDNSObj[];
extern DMLEAF tDNSParams[];
extern DMLEAF tDNSClientParams[];
extern DMOBJ tDNSClientObj[];
extern DMLEAF tDNSClientServerParams[];
extern DMLEAF tDNSRelayParams[];
extern DMOBJ tDNSRelayObj[];
extern DMLEAF tDNSRelayForwardingParams[];
extern DMOBJ tDNSDiagnosticsObj[];
extern DMLEAF tDNSDiagnosticsNSLookupDiagnosticsParams[];
extern DMOBJ tDNSDiagnosticsNSLookupDiagnosticsObj[];
extern DMLEAF tDNSDiagnosticsNSLookupDiagnosticsResultParams[];
struct NSLookupResult
{
char *Status;
char *AnswerType;
char *HostNameReturned;
char *IPAddresses;
char *DNSServerIP;
char *ResponseTime;
};
int browseServerInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseRelayForwardingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseResultInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int add_client_server(char *refparam, struct dmctx *ctx, void *data, char **instance);
int add_relay_forwarding(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delete_client_server(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int delete_relay_forwarding(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_dns_supported_record_types(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_client_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_client_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_client_server_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_server_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_server_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_server_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_server_dns_server(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_server_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_server_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_relay_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_relay_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_relay_forward_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_forwarding_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_forwarding_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_forwarding_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_forwarding_dns_server(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_forwarding_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_forwarding_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_nslookupdiagnostics_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_nslookupdiagnostics_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_nslookupdiagnostics_host_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_nslookupdiagnostics_d_n_s_server(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_nslookupdiagnostics_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_nslookupdiagnostics_number_of_repetitions(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_nslookupdiagnostics_success_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_nslookupdiagnostics_result_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_result_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_result_answer_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_result_host_name_returned(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_result_i_p_addresses(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_result_d_n_s_server_i_p(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_result_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_client_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_server_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_server_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_server_dns_server(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_server_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_relay_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_forwarding_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_forwarding_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_forwarding_dns_server(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_forwarding_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_nslookupdiagnostics_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_nslookupdiagnostics_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_nslookupdiagnostics_host_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_nslookupdiagnostics_d_n_s_server(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_nslookupdiagnostics_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_nslookupdiagnostics_number_of_repetitions(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

1546
dmtree/tr181/dsl.c Normal file

File diff suppressed because it is too large Load diff

179
dmtree/tr181/dsl.h Normal file
View file

@ -0,0 +1,179 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
* Author: AMIN Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*/
#ifndef __DSL_H
#define __DSL_H
struct dsl_line_args
{
struct uci_section *line_sec;
char *id;
};
struct dsl_channel_args
{
struct uci_section *channel_sec;
char *id;
};
extern DMOBJ tDSLObj[];
extern DMLEAF tDSLParams[];
extern DMOBJ tDSLLineObj[];
extern DMLEAF tDSLLineParams[];
extern DMOBJ tDSLLineStatsObj[];
extern DMLEAF tDSLLineStatsParams[];
extern DMLEAF tDSLLineStatsTotalParams[];
extern DMLEAF tDSLLineStatsShowtimeParams[];
extern DMLEAF tDSLLineStatsLastShowtimeParams[];
extern DMLEAF tDSLLineStatsCurrentDayParams[];
extern DMLEAF tDSLLineStatsQuarterHourParams[];
extern DMOBJ tDSLChannelObj[];
extern DMLEAF tDSLChannelParams[];
extern DMOBJ tDSLChannelStatsObj[];
extern DMLEAF tDSLChannelStatsParams[];
extern DMLEAF tDSLChannelStatsTotalParams[];
extern DMLEAF tDSLChannelStatsShowtimeParams[];
extern DMLEAF tDSLChannelStatsLastShowtimeParams[];
extern DMLEAF tDSLChannelStatsCurrentDayParams[];
extern DMLEAF tDSLChannelStatsQuarterHourParams[];
int browseDSLLineInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseDSLChannelInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int get_dsl_line_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
int get_dsl_channel_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
int get_DSL_LineNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSL_ChannelNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DSLLine_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DSLLine_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DSLLine_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DSLLine_Name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DSLLine_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DSLLine_Upstream(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_FirmwareVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_LinkStatus(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_StandardsSupported(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_XTSE(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_StandardUsed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_XTSUsed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_LineEncoding(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_AllowedProfiles(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_CurrentProfile(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_PowerManagementState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_SuccessFailureCause(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_UPBOKLERPb(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_RXTHRSHds(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_ACTRAMODEds(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_ACTRAMODEus(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_SNRMROCus(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_LastStateTransmittedDownstream(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_LastStateTransmittedUpstream(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_US0MASK(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_TRELLISds(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_TRELLISus(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_ACTSNRMODEds(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_ACTSNRMODEus(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_LineNumber(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_UpstreamMaxBitRate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_DownstreamMaxBitRate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_UpstreamNoiseMargin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_DownstreamNoiseMargin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_SNRMpbus(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_SNRMpbds(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_UpstreamAttenuation(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_DownstreamAttenuation(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_UpstreamPower(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_DownstreamPower(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_XTURVendor(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_XTURCountry(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_XTURANSIStd(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_XTURANSIRev(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_XTUCVendor(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_XTUCCountry(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_XTUCANSIStd(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLine_XTUCANSIRev(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLineStats_TotalStart(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLineStats_ShowtimeStart(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLineStats_LastShowtimeStart(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLineStats_CurrentDayStart(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLineStats_QuarterHourStart(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLineStatsTotal_ErroredSecs(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLineStatsTotal_SeverelyErroredSecs(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLineStatsShowtime_ErroredSecs(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLineStatsShowtime_SeverelyErroredSecs(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLineStatsLastShowtime_ErroredSecs(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLineStatsLastShowtime_SeverelyErroredSecs(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLineStatsCurrentDay_ErroredSecs(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLineStatsCurrentDay_SeverelyErroredSecs(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLineStatsQuarterHour_ErroredSecs(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLLineStatsQuarterHour_SeverelyErroredSecs(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannel_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DSLChannel_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DSLChannel_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannel_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_DSLChannel_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_DSLChannel_Name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannel_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannel_LinkEncapsulationSupported(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannel_LinkEncapsulationUsed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannel_LPATH(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannel_INTLVDEPTH(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannel_INTLVBLOCK(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannel_ActualInterleavingDelay(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannel_ACTINP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannel_INPREPORT(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannel_NFEC(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannel_RFEC(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannel_LSYMB(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannel_UpstreamCurrRate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannel_DownstreamCurrRate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannel_ACTNDR(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannel_ACTINPREIN(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStats_TotalStart(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStats_ShowtimeStart(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStats_LastShowtimeStart(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStats_CurrentDayStart(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStats_QuarterHourStart(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsTotal_XTURFECErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsTotal_XTUCFECErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsTotal_XTURHECErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsTotal_XTUCHECErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsTotal_XTURCRCErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsTotal_XTUCCRCErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsShowtime_XTURFECErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsShowtime_XTUCFECErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsShowtime_XTURHECErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsShowtime_XTUCHECErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsShowtime_XTURCRCErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsShowtime_XTUCCRCErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsLastShowtime_XTURFECErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsLastShowtime_XTUCFECErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsLastShowtime_XTURHECErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsLastShowtime_XTUCHECErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsLastShowtime_XTURCRCErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsLastShowtime_XTUCCRCErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsCurrentDay_XTURFECErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsCurrentDay_XTUCFECErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsCurrentDay_XTURHECErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsCurrentDay_XTUCHECErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsCurrentDay_XTURCRCErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsCurrentDay_XTUCCRCErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsQuarterHour_XTURFECErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsQuarterHour_XTUCFECErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsQuarterHour_XTURHECErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsQuarterHour_XTUCHECErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsQuarterHour_XTURCRCErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_DSLChannelStatsQuarterHour_XTUCCRCErrors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
#endif //__DSL_H

1509
dmtree/tr181/ethernet.c Normal file

File diff suppressed because it is too large Load diff

139
dmtree/tr181/ethernet.h Normal file
View file

@ -0,0 +1,139 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*
*/
#ifndef __ETHERNET_H
#define __ETHERNET_H
struct eth_port_args
{
struct uci_section *eth_port_sec;
char *ifname;
};
extern DMOBJ tEthernetObj[];
extern DMLEAF tEthernetParams[];
extern DMOBJ tEthernetInterfaceObj[];
extern DMLEAF tEthernetInterfaceParams[];
extern DMLEAF tEthernetInterfaceStatsParams[];
extern DMOBJ tEthernetLinkObj[];
extern DMLEAF tEthernetLinkParams[];
extern DMLEAF tEthernetLinkStatsParams[];
extern DMOBJ tEthernetVLANTerminationObj[];
extern DMLEAF tEthernetVLANTerminationParams[];
extern DMLEAF tEthernetVLANTerminationStatsParams[];
int browseEthernetInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseEthernetLinkInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseEthernetVLANTerminationInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int addObjEthernetLink(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delObjEthernetLink(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int addObjEthernetVLANTermination(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delObjEthernetVLANTermination(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_linker_interface(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
int get_linker_link(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
int get_linker_vlan_term(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
int get_Ethernet_InterfaceNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_Ethernet_LinkNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_Ethernet_VLANTerminationNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetInterface_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_EthernetInterface_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_EthernetInterface_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetInterface_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_EthernetInterface_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_EthernetInterface_Name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetInterface_LastChange(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_EthernetInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_EthernetInterface_Upstream(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetInterface_MACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetInterface_MaxBitRate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_EthernetInterface_MaxBitRate(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_EthernetInterface_CurrentBitRate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetInterface_DuplexMode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_EthernetInterface_DuplexMode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_EthernetInterface_EEECapability(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetInterfaceStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetInterfaceStats_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetInterfaceStats_PacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetInterfaceStats_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetInterfaceStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetInterfaceStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetInterfaceStats_UnicastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetInterfaceStats_UnicastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetInterfaceStats_DiscardPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetInterfaceStats_DiscardPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetInterfaceStats_MulticastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetInterfaceStats_MulticastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetInterfaceStats_BroadcastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetInterfaceStats_BroadcastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetInterfaceStats_UnknownProtoPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetLink_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_EthernetLink_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_EthernetLink_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetLink_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_EthernetLink_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_EthernetLink_Name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetLink_LastChange(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_EthernetLink_MACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetLinkStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetLinkStats_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetLinkStats_PacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetLinkStats_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetLinkStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetLinkStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetLinkStats_UnicastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetLinkStats_UnicastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetLinkStats_DiscardPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetLinkStats_DiscardPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetLinkStats_MulticastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetLinkStats_MulticastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetLinkStats_BroadcastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetLinkStats_BroadcastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetLinkStats_UnknownProtoPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetVLANTermination_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_EthernetVLANTermination_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_EthernetVLANTermination_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetVLANTermination_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_EthernetVLANTermination_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_EthernetVLANTermination_Name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetVLANTermination_LastChange(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetVLANTermination_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_EthernetVLANTermination_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_EthernetVLANTermination_VLANID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_EthernetVLANTermination_VLANID(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_EthernetVLANTermination_TPID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_EthernetVLANTermination_TPID(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_EthernetVLANTerminationStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetVLANTerminationStats_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetVLANTerminationStats_PacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetVLANTerminationStats_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetVLANTerminationStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetVLANTerminationStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetVLANTerminationStats_UnicastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetVLANTerminationStats_UnicastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetVLANTerminationStats_DiscardPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetVLANTerminationStats_DiscardPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetVLANTerminationStats_MulticastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetVLANTerminationStats_MulticastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetVLANTerminationStats_BroadcastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetVLANTerminationStats_BroadcastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_EthernetVLANTerminationStats_UnknownProtoPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
#endif //__ETHERNET_H

1329
dmtree/tr181/firewall.c Normal file

File diff suppressed because it is too large Load diff

99
dmtree/tr181/firewall.h Normal file
View file

@ -0,0 +1,99 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
*
* Author: Omar Kallel <omar.kallel@pivasoftware.com>
*/
#ifndef _FIREWALL_H
#define _FIREWALL_H
extern DMOBJ tFirewallObj[];
extern DMLEAF tFirewallParams[];
extern DMLEAF tFirewallLevelParams[];
extern DMLEAF tFirewallChainParams[];
extern DMOBJ tFirewallChainObj[];
extern DMLEAF tFirewallChainRuleParams[];
extern DMOBJ tFirewallChainRuleObj[];
extern DMLEAF tTimeSpanParams[];
int browseLevelInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseChainInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseRuleInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int add_firewall_rule(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delete_firewall_rule(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_firewall_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_firewall_config(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_firewall_advanced_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_firewall_level_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_firewall_chain_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_level_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_level_description(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_level_chain(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_level_port_mapping_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_level_default_log_policy(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_chain_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_chain_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_chain_creator(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_chain_rule_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_order(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_description(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_target(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_target_chain(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_source_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_dest_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_i_p_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_dest_ip(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_dest_mask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_source_ip(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_source_mask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_dest_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_dest_port_range_max(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_source_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_source_port_range_max(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_icmp_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_source_mac(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_time_span_supported_days(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_time_span_days(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_time_span_start_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_time_span_stop_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_firewall_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_firewall_config(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_firewall_advanced_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_level_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_level_description(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_level_port_mapping_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_level_default_log_policy(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_chain_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_chain_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_order(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_description(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_target(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_target_chain(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_source_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_dest_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_i_p_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_dest_ip(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_dest_mask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_source_ip(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_source_mask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_dest_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_dest_port_range_max(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_source_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_source_port_range_max(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_icmp_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_source_mac(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_time_span_supported_days(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_time_span_days(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_time_span_start_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_time_span_stop_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

311
dmtree/tr181/hosts.c Normal file
View file

@ -0,0 +1,311 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2016 Inteno Broadband Technology AB
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
*
*/
#include <uci.h>
#include <stdio.h>
#include <ctype.h>
#include "dmuci.h"
#include "dmubus.h"
#include "dmcwmp.h"
#include "dmcommon.h"
#include "hosts.h"
#include "dmjson.h"
#include "dmentry.h"
/* *** Device.Hosts. *** */
DMOBJ tHostsObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{"Host", &DMREAD, NULL, NULL, NULL, browsehostInst, NULL, NULL, NULL, tHostsHostParams, NULL, BBFDM_BOTH},
{0}
};
DMLEAF tHostsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"HostNumberOfEntries", &DMREAD, DMT_UNINT, get_host_nbr_entries, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/* *** Device.Hosts.Host.{i}. *** */
DMLEAF tHostsHostParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"AssociatedDevice", &DMREAD, DMT_STRING, get_host_associateddevice, NULL, NULL, NULL, BBFDM_BOTH},
{"Layer3Interface", &DMREAD, DMT_STRING, get_host_layer3interface, NULL, NULL, NULL, BBFDM_BOTH},
{"IPAddress", &DMREAD, DMT_STRING, get_host_ipaddress, NULL, NULL, NULL, BBFDM_BOTH},
{"HostName", &DMREAD, DMT_STRING, get_host_hostname, NULL, NULL, NULL, BBFDM_BOTH},
{"Active", &DMREAD, DMT_BOOL, get_host_active, NULL, NULL, NULL, BBFDM_BOTH},
{"PhysAddress", &DMREAD, DMT_STRING, get_host_phy_address, NULL, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"LinkType", &DMREAD, DMT_STRING, get_host_interfacetype, NULL, NULL, NULL, BBFDM_BOTH},
{"AddressSource", &DMREAD, DMT_STRING, get_host_address_source, NULL, NULL, NULL, BBFDM_BOTH},
{"LeaseTimeRemaining", &DMREAD, DMT_INT, get_host_leasetime_remaining, NULL, NULL, NULL, BBFDM_BOTH},
{"DHCPClient", &DMREAD, DMT_STRING, get_host_dhcp_client, NULL, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"InterfaceType", &DMREAD, DMT_STRING, get_host_interface_type, NULL, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"ifname", &DMREAD, DMT_STRING, get_host_interfacename, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/*************************************************************
* INIT
/*************************************************************/
inline int init_host_args(struct host_args *args, json_object *clients, char *key)
{
args->client = clients;
args->key = key;
return 0;
}
/*************************************************************
* GET & SET PARAM
/*************************************************************/
int get_host_associateddevice(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *ss;
char *macaddr_linker = dmjson_get_value(((struct host_args *)data)->client, 1, "macaddr");
char *accesspointInstance = NULL, *wifiAssociativeDeviecPath;
uci_path_foreach_sections(icwmpd, "dmmap_wireless", "wifi-iface", ss) {
dmuci_get_value_by_section_string(ss, "accesspointinstance", &accesspointInstance);
if(accesspointInstance[0] != '\0')
dmasprintf(&wifiAssociativeDeviecPath, "Device.WiFi.AccessPoint.%s.AssociatedDevice.", accesspointInstance);
accesspointInstance = NULL;
adm_entry_get_linker_param(ctx, wifiAssociativeDeviecPath, macaddr_linker, value);
if(*value != NULL)
break;
}
if (*value == NULL)
*value = "";
return 0;
}
int get_host_layer3interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *ip_linker=dmjson_get_value(((struct host_args *)data)->client, 1, "network");
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", ip_linker, value);
if (*value == NULL)
*value = "";
return 0;
}
int get_host_interface_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *type= NULL;
char *ifname = dmjson_get_value(((struct host_args *)data)->client, 1, "network");
struct uci_section *ss = NULL;
uci_foreach_sections("network", "interface", ss) {
if(!strcmp(ifname, section_name(ss))){
dmuci_get_value_by_section_string(ss, "type", &type);
if(type!=NULL){
if(!strcmp(type, "bridge")) *value="Bridge";else *value= "Normal";
break;
}
}
}
return 0;
}
int get_host_interfacename(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *frequency, *wireless;
frequency = dmjson_get_value(((struct host_args *)data)->client, 1, "frequency");
wireless = dmjson_get_value(((struct host_args *)data)->client, 1, "wireless");
if( (*frequency != '\0') && (strcmp(wireless, "true")==0) )
{
if(strcmp(frequency,"5GHz")==0)
*value = "WiFi@5GHz";
else
*value = "WiFi@2.4GHz";
}
else
{
*value = dmjson_get_value(((struct host_args *)data)->client, 1, "ethport");
if (*value == NULL)
*value = "";
}
return 0;
}
int get_host_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value(((struct host_args *)data)->client, 1, "ipaddr");
return 0;
}
int get_host_hostname(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value(((struct host_args *)data)->client, 1, "hostname");
return 0;
}
int get_host_active(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value(((struct host_args *)data)->client, 1, "connected");
return 0;
}
int get_host_phy_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value(((struct host_args *)data)->client, 1, "macaddr");
return 0;
}
int get_host_address_source(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *dhcp;
dhcp = dmjson_get_value(((struct host_args *)data)->client, 1, "dhcp");
if (strcasecmp(dhcp, "true") == 0)
*value = "DHCP";
else
*value = "Static";
return 0;
}
int get_host_leasetime_remaining(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char buf[80], *dhcp;
FILE *fp;
char line[MAX_DHCP_LEASES];
struct tm ts;
char *leasetime, *mac_f, *mac, *line1;
char delimiter[] = " \t";
dhcp = dmjson_get_value(((struct host_args *)data)->client, 1, "dhcp");
if (strcmp(dhcp, "false") == 0) {
*value = "0";
}
else {
mac = dmjson_get_value(((struct host_args *)data)->client, 1, "macaddr");
fp = fopen(DHCP_LEASES_FILE, "r");
if ( fp != NULL)
{
while (fgets(line, MAX_DHCP_LEASES, fp) != NULL )
{
if (line[0] == '\n')
continue;
line1 = dmstrdup(line);
leasetime = cut_fx(line, delimiter, 1);
mac_f = cut_fx(line1, delimiter, 2);
if (strcasecmp(mac, mac_f) == 0) {
int rem_lease = atoi(leasetime) - time(NULL);
if (rem_lease < 0)
*value = "-1";
else
dmasprintf(value, "%d", rem_lease); // MEM WILL BE FREED IN DMMEMCLEAN
fclose(fp) ;
return 0;
}
}
fclose(fp);
*value = "0";
}
}
return 0;
}
int get_host_dhcp_client(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *linker;
dmasprintf(&linker, "%s", ((struct host_args *)data)->key);
adm_entry_get_linker_param(ctx, dm_print_path("%s%cDHCPv4%c", dmroot, dm_delim, dm_delim), linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
if (*value == NULL) {
*value = "";
}
dmfree(linker);
return 0;
}
static char *get_interface_type(char *mac, char *ndev)
{
json_object *res;
int wlctl_num;
struct uci_section *s, *d;
char *network, *device, *value, *wunit;
char buf[8], *p;
uci_foreach_sections("wireless", "wifi-device", d) {
wlctl_num = 0;
wunit = section_name(d);
uci_foreach_option_eq("wireless", "wifi-iface", "device", wunit, s) {
dmuci_get_value_by_section_string(s, "network", &network);
if (strcmp(network, ndev) == 0) {
if (wlctl_num != 0) {
sprintf(buf, "%s.%d", wunit, wlctl_num);
p = buf;
}
else {
p = wunit;
}
dmubus_call("router.wireless", "stas", UBUS_ARGS{{"vif", p, String}}, 1, &res);
if(res) {
json_object_object_foreach(res, key, val) {
value = dmjson_get_value(val, 1, "macaddr");
if (strcasecmp(value, mac) == 0)
return "802.11";
}
}
wlctl_num++;
}
}
}
return "Ethernet";
}
int get_host_interfacetype(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *mac, *network;
mac = dmjson_get_value(((struct host_args *)data)->client, 1, "macaddr");
network = dmjson_get_value(((struct host_args *)data)->client, 1, "network");
*value = get_interface_type(mac, network);
return 0;
}
int get_host_nbr_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
int entries = 0;
json_object *res;
dmubus_call("router.network", "clients", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "0");
json_object_object_foreach(res, key, client_obj) {
entries++;
}
dmasprintf(value, "%d", entries); // MEM WILL BE FREED IN DMMEMCLEAN
return 0;
}
/*************************************************************
* ENTRY METHOD
/*************************************************************/
int browsehostInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
json_object *res, *client_obj;
char *idx, *idx_last = NULL, *connected;
int id = 0;
struct host_args curr_host_args = {0};
dmubus_call("router.network", "clients", UBUS_ARGS{}, 0, &res);
if (res) {
json_object_object_foreach(res, key, client_obj) {
connected = dmjson_get_value(client_obj, 1, "connected");
if(strcmp(connected, "false") == 0)
continue;
init_host_args(&curr_host_args, client_obj, key);
idx = handle_update_instance(2, dmctx, &idx_last, update_instance_without_section, 1, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_host_args, idx) == DM_STOP)
break;
}
}
return 0;
}

41
dmtree/tr181/hosts.h Normal file
View file

@ -0,0 +1,41 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2016 Inteno Broadband Technology AB
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
*
*/
#ifndef __HOSTS_H
#define __HOSTS_H
struct host_args
{
json_object *client;
char *key;
};
extern DMOBJ tHostsObj[];
extern DMLEAF tHostsParams[];
extern DMLEAF tHostsHostParams[];
int browsehostInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int get_host_nbr_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_host_associateddevice(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_host_layer3interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_host_interface_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_host_interfacename(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_host_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_host_hostname(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_host_active(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_host_phy_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_host_interfacetype(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_host_address_source(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_host_leasetime_remaining(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_host_dhcp_client(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
#endif

View file

@ -0,0 +1,534 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*/
#include "dmcwmp.h"
#include "dmcommon.h"
#include "dmubus.h"
#include "dmjson.h"
#include "dmentry.h"
#include "interfacestack.h"
/* *** Device.InterfaceStack.{i}. *** */
DMLEAF tInterfaceStackParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Alias", &DMWRITE, DMT_STRING, get_InterfaceStack_Alias, set_InterfaceStack_Alias, NULL, NULL, BBFDM_BOTH},
{"HigherLayer", &DMREAD, DMT_STRING, get_InterfaceStack_HigherLayer, NULL, NULL, NULL, BBFDM_BOTH},
{"LowerLayer", &DMREAD, DMT_STRING, get_InterfaceStack_LowerLayer, NULL, NULL, NULL, BBFDM_BOTH},
{"HigherAlias", &DMREAD, DMT_STRING, get_InterfaceStack_HigherAlias, NULL, NULL, NULL, BBFDM_BOTH},
{"LowerAlias", &DMREAD, DMT_STRING, get_InterfaceStack_LowerAlias, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/*************************************************************
* ENTRY METHOD
/*************************************************************/
static char *get_instance_by_section(struct dmctx *dmctx, int mode, char *dmmap_config, char *section, struct uci_section *s, char *instance_option, char *alias_option)
{
struct uci_section *dmmap_section;
char *instance;
get_dmmap_section_of_config_section(dmmap_config, section, section_name(s), &dmmap_section);
if(dmmap_section == NULL) {
return "";
}
if (mode == INSTANCE_MODE_NUMBER) {
dmuci_get_value_by_section_string(dmmap_section, instance_option, &instance);
}
else {
dmuci_get_value_by_section_string(dmmap_section, alias_option, &instance);
}
return instance;
}
static char *get_alias_by_section(char *dmmap_config, char *section, struct uci_section *s, char *alias_option)
{
struct uci_section *dmmap_section;
char *alias;
get_dmmap_section_of_config_section(dmmap_config, section, section_name(s), &dmmap_section);
if(dmmap_section == NULL) {
return "";
}
dmuci_get_value_by_section_string(dmmap_section, alias_option, &alias);
return alias;
}
static struct uci_section *create_dmmap_interface_stack_section(char *curr_inst)
{
struct uci_section *s = NULL;
char *name;
check_create_dmmap_package("dmmap_interface_stack");
uci_path_foreach_option_eq(icwmpd, "dmmap_interface_stack", "interface_stack", "interface_stack_instance", curr_inst, s) {
return s;
}
if (!s) {
DMUCI_ADD_SECTION(icwmpd, "dmmap_interface_stack", "interface_stack", &s, &name);
DMUCI_SET_VALUE_BY_SECTION(icwmpd, s, "interface_stack_instance", curr_inst);
}
return s;
}
int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
struct interfacestack_data ifdata = {0};
struct uci_section *s = NULL, *sd = NULL, *port, *port_s, *ss, *dmmap_s = NULL;
char *proto, *type, *pch, *spch, *layer_inst, *v, *vb, *higheralias, *loweralias, *ifname, *br_inst, *mg, *value, *p, *device, *name;
char *interface_stack_int = NULL, *interface_stack_int_last = NULL, *wanifname, *wanlinker, *mac, *vlan_method, *sectionname, *package, *section;
char buf_lowerlayer[128] = "";
char buf_higherlayer[128] = "";
char buf_higheralias[64] = "";
char buf_loweralias[64] = "";
char buf_instance[32] = "";
char linker[64] = "";
char buf_tmp[64] = "";
int instance = 0, found = 0;
json_object *jobj;
/* Higher layers are Device.IP.Interface.{i}. */
uci_foreach_sections("network", "interface", s) {
dmuci_get_value_by_section_string(s, "type", &type);
if (strcmp(type, "alias") == 0 || strcmp(section_name(s), "loopback")==0)
continue;
layer_inst = get_instance_by_section(dmctx, dmctx->instance_mode, "dmmap_network", "interface", s, "ip_int_instance", "ip_int_alias");
if (*layer_inst == '\0')
continue;
sprintf(buf_higherlayer, "Device.IP.Interface.%s.", layer_inst);
higheralias = get_alias_by_section("dmmap_network", "interface", s, "ip_int_alias");
sprintf(buf_higheralias, "%s", higheralias);
dmuci_get_value_by_section_string(s, "proto", &proto);
if (strstr(proto, "ppp")) {
layer_inst = get_instance_by_section(dmctx, dmctx->instance_mode, "dmmap_network", "interface", s, "ppp_int_instance", "ppp_int_alias");
if (*layer_inst == '\0')
continue;
sprintf(buf_lowerlayer, "Device.PPP.Interface.%s.", layer_inst);
loweralias = get_alias_by_section("dmmap_network", "interface", s, "ppp_int_alias");
sprintf(buf_loweralias, "%s", loweralias);
}
else {
device = get_device(section_name(s));
if (device[0] != '\0') {
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cVLANTermination%c", dmroot, dm_delim, dm_delim, dm_delim), device, &v);
dmuci_get_option_value_string("cwmp", "cpe", "vlan_method", &vlan_method);
if(strcmp(vlan_method, "2") == 0)
loweralias = get_alias_by_section("dmmap_network", "device", s, "all_vlan_term_alias");
else
loweralias = get_alias_by_section("dmmap_network", "device", s, "vlan_term_alias");
if (v != NULL)
found = 1;
}
mac = get_macaddr(section_name(s));
if (mac[0] != '\0' && found == 0) {
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cLink%c", dmroot, dm_delim, dm_delim, dm_delim), mac, &v);
loweralias = get_alias_by_section("dmmap", "link", s, "link_alias");
if (v == NULL)
v = "";
}
sprintf(buf_lowerlayer, "%s", v);
sprintf(buf_loweralias, "%s", loweralias);
}
ifdata.higherlayer = buf_higherlayer;
ifdata.lowerlayer = buf_lowerlayer;
ifdata.higheralias = buf_higheralias;
ifdata.loweralias = buf_loweralias;
sprintf(buf_instance, "%d", ++instance);
dmmap_s = create_dmmap_interface_stack_section(buf_instance);
interface_stack_int = handle_update_instance(1, dmctx, &interface_stack_int_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&ifdata, interface_stack_int) == DM_STOP)
goto end;
}
/* Higher layers are Device.PPP.Interface.{i}. */
uci_foreach_sections("network", "interface", s) {
dmuci_get_value_by_section_string(s, "proto", &proto);
if (!strstr(proto, "ppp"))
continue;
layer_inst = get_instance_by_section(dmctx, dmctx->instance_mode, "dmmap_network", "interface", s, "ppp_int_instance", "ppp_int_alias");
if (*layer_inst == '\0')
continue;
sprintf(buf_higherlayer, "Device.PPP.Interface.%s.", layer_inst);
higheralias = get_alias_by_section("dmmap_network", "interface", s, "ppp_int_alias");
sprintf(buf_higheralias, "%s", higheralias);
found = 0;
device = get_device(section_name(s));
if (device[0] != '\0') {
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cVLANTermination%c", dmroot, dm_delim, dm_delim, dm_delim), device, &v);
dmuci_get_option_value_string("cwmp", "cpe", "vlan_method", &vlan_method);
if(strcmp(vlan_method, "2") == 0)
loweralias = get_alias_by_section("dmmap_network", "device", s, "all_vlan_term_alias");
else
loweralias = get_alias_by_section("dmmap_network", "device", s, "vlan_term_alias");
if (v != NULL)
found = 1;
}
mac = get_macaddr(section_name(s));
if (mac[0] != '\0' && found == 0) {
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cLink%c", dmroot, dm_delim, dm_delim, dm_delim), mac, &v);
loweralias = get_alias_by_section("dmmap", "link", s, "link_alias");
if (v == NULL)
v = "";
}
sprintf(buf_lowerlayer, "%s", v);
sprintf(buf_loweralias, "%s", loweralias);
ifdata.higherlayer = buf_higherlayer;
ifdata.lowerlayer = buf_lowerlayer;
ifdata.higheralias = buf_higheralias;
ifdata.loweralias = buf_loweralias;
sprintf(buf_instance, "%d", ++instance);
dmmap_s = create_dmmap_interface_stack_section(buf_instance);
interface_stack_int = handle_update_instance(1, dmctx, &interface_stack_int_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&ifdata, interface_stack_int) == DM_STOP)
goto end;
}
/* Higher layers are Device.Ethernet.VLANTermination.{i}. */
uci_foreach_sections("network", "device", s) {
dmuci_get_value_by_section_string(s, "type", &type);
dmuci_get_option_value_string("cwmp", "cpe", "vlan_method", &vlan_method);
if ((strcmp(vlan_method, "2") != 0 && strcmp(vlan_method, "1") != 0) || (strcmp(vlan_method, "1") == 0 && strcmp(type, "untagged") == 0) )
continue;
if(strcmp(vlan_method, "2") == 0)
layer_inst = get_instance_by_section(dmctx, dmctx->instance_mode, "dmmap_network", "device", s, "all_vlan_term_instance", "all_vlan_term_alias");
else
layer_inst = get_instance_by_section(dmctx, dmctx->instance_mode, "dmmap_network", "device", s, "only_tagged_vlan_term_instance", "vlan_term_alias");
if (*layer_inst == '\0')
continue;
sprintf(buf_higherlayer, "Device.Ethernet.VLANTermination.%s.", layer_inst);
if(strcmp(vlan_method, "2") == 0)
higheralias = get_alias_by_section("dmmap_network", "device", s, "all_vlan_term_alias");
else
higheralias = get_alias_by_section("dmmap_network", "device", s, "vlan_term_alias");
sprintf(buf_higheralias, "%s", higheralias);
dmuci_get_value_by_section_string(s, "name", &value);
uci_foreach_sections("network", "interface", ss) {
dmuci_get_value_by_section_string(ss, "ifname", &ifname);
for (pch = strtok_r(ifname, " ", &spch); pch != NULL; pch = strtok_r(NULL, " ", &spch)) {
if(strcmp(pch, value) == 0) {
mac = get_macaddr(section_name(ss));
if (mac[0] != '\0') {
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cLink%c", dmroot, dm_delim, dm_delim, dm_delim), mac, &v);
loweralias = get_alias_by_section("dmmap", "link", ss, "link_alias");
if (v == NULL)
v = "";
break;
}
}
}
}
sprintf(buf_lowerlayer, "%s", v);
sprintf(buf_loweralias, "%s", loweralias);
ifdata.higherlayer = buf_higherlayer;
ifdata.lowerlayer = buf_lowerlayer;
ifdata.higheralias = buf_higheralias;
ifdata.loweralias = buf_loweralias;
sprintf(buf_instance, "%d", ++instance);
dmmap_s = create_dmmap_interface_stack_section(buf_instance);
interface_stack_int = handle_update_instance(1, dmctx, &interface_stack_int_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&ifdata, interface_stack_int) == DM_STOP)
goto end;
}
/* Higher layers are Device.Ethernet.Link.{i}. */
uci_foreach_sections("network", "interface", s) {
dmuci_get_value_by_section_string(s, "type", &type);
if (strcmp(type, "alias") == 0 || strcmp(section_name(s), "loopback")==0)
continue;
dmuci_get_value_by_section_string(s, "ifname", &ifname);
if (*ifname == '\0' || *ifname == '@')
continue;
layer_inst = get_instance_by_section(dmctx, dmctx->instance_mode, "dmmap", "link", s, "link_instance", "link_alias");
if (*layer_inst == '\0')
continue;
sprintf(buf_higherlayer, "Device.Ethernet.Link.%s.", layer_inst);
higheralias = get_alias_by_section("dmmap", "link", s, "link_alias");
sprintf(buf_higheralias, "%s", higheralias);
if (strcmp(type, "bridge") == 0) {
br_inst = get_alias_by_section("dmmap_network", "interface", s, "bridge_instance");
uci_path_foreach_option_eq(icwmpd, "dmmap_bridge_port", "bridge_port", "bridge_key", br_inst, port) {
dmuci_get_value_by_section_string(port, "mg_port", &mg);
if (strcmp(mg, "true") == 0) {
sprintf(linker, "%s+", section_name(port));
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cBridging%cBridge%c", dmroot, dm_delim, dm_delim, dm_delim), linker, &v);
dmuci_get_value_by_section_string(port, "bridge_port_alias", &loweralias);
break;
}
}
} else {
uci_foreach_option_eq("ports", "ethport", "name", "WAN", port_s) {
dmuci_get_value_by_section_string(port_s, "ifname", &wanifname);
if(strstr(ifname, wanifname)) {
dmasprintf(&wanlinker, "%s.1", wanifname);
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), wanlinker, &v);
dmfree(wanlinker);
loweralias = get_alias_by_section("dmmap_ports", "ethport", port_s, "eth_port_alias");
break;
}
}
}
if (v == NULL)
v = "";
sprintf(buf_loweralias, "%s", loweralias);
ifdata.higherlayer = buf_higherlayer;
ifdata.lowerlayer = v;
ifdata.higheralias = buf_higheralias;
ifdata.loweralias = buf_loweralias;
sprintf(buf_instance, "%d", ++instance);
dmmap_s = create_dmmap_interface_stack_section(buf_instance);
interface_stack_int = handle_update_instance(1, dmctx, &interface_stack_int_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&ifdata, interface_stack_int) == DM_STOP)
goto end;
}
/* Higher layers are Device.Bridging.Bridge.{i}.Port.{i}.*/
uci_foreach_sections("network", "interface", s) {
dmuci_get_value_by_section_string(s, "type", &type);
if (strcmp(type, "bridge") != 0)
continue;
br_inst = get_instance_by_section(dmctx, dmctx->instance_mode, "dmmap_network", "interface", s, "bridge_instance", "bridge_alias");
if (*br_inst == '\0')
continue;
uci_path_foreach_option_eq(icwmpd, "dmmap_bridge_port", "bridge_port", "bridge_key", br_inst, port) {
dmuci_get_value_by_section_string(port, "mg_port", &mg);
if (strcmp(mg, "true") == 0) {
sprintf(linker, "%s+", section_name(port));
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cBridging%cBridge%c", dmroot, dm_delim, dm_delim, dm_delim), linker, &pch);
dmuci_get_value_by_section_string(port, "bridge_port_alias", &higheralias);
sprintf(buf_tmp, "%s", higheralias);
if (pch == NULL)
pch = "";
break;
}
}
uci_path_foreach_option_eq(icwmpd, "dmmap_bridge_port", "bridge_port", "bridge_key", br_inst, sd) {
dmuci_get_value_by_section_string(sd, "mg_port", &mg);
if (strcmp(mg, "true") == 0)
continue;
dmuci_get_value_by_section_string(sd, "section_name", &sectionname);
dmuci_get_value_by_section_string(sd, "package", &package);
dmuci_get_value_by_section_string(sd, "section", &section);
uci_foreach_sections(package, section, port_s) {
if(strcmp(section_name(port_s), sectionname) == 0) {
dmuci_get_value_by_section_string(port_s, "ifname", &ifname);
dmuci_get_value_by_section_string(port_s, "name", &name);
break;
}
}
if(strcmp(package, "network") == 0 && strcmp(section, "device") == 0)
sprintf(linker, "%s+%s", sectionname, name);
else
sprintf(linker, "%s+%s", sectionname, ifname);
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cBridging%cBridge%c", dmroot, dm_delim, dm_delim, dm_delim), linker, &vb);
if (vb == NULL)
vb = "";
dmuci_get_value_by_section_string(sd, "bridge_port_alias", &loweralias);
sprintf(buf_loweralias, "%s", loweralias);
ifdata.higherlayer = pch;
ifdata.lowerlayer = vb;
ifdata.higheralias = buf_tmp;
ifdata.loweralias = buf_loweralias;
sprintf(buf_instance, "%d", ++instance);
dmmap_s = create_dmmap_interface_stack_section(buf_instance);
interface_stack_int = handle_update_instance(1, dmctx, &interface_stack_int_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&ifdata, interface_stack_int) == DM_STOP)
goto end;
sprintf(buf_higheralias, "%s", loweralias);
if(strcmp(package, "ports") == 0) {
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), ifname, &v);
loweralias = get_alias_by_section("dmmap_ports", "ethport", port_s, "eth_port_alias");
} else if(strcmp(package, "wireless") == 0) {
adm_entry_get_linker_param(dmctx,dm_print_path("%s%cWiFi%cSSID%c", dmroot, dm_delim, dm_delim, dm_delim), ifname, &v);
loweralias = get_alias_by_section("dmmap_wireless", "wifi-iface", port_s, "ssidalias");
} else if(strcmp(package, "network") == 0) {
if(strstr(ifname, "atm")) {
adm_entry_get_linker_param(dmctx,dm_print_path("%s%cATM%cLink%c", dmroot, dm_delim, dm_delim, dm_delim), ifname, &v);
uci_foreach_sections("dsl", "atm-device", ss) {
if(strcmp(section_name(ss), ifname) == 0) {
loweralias = get_alias_by_section("dmmap_dsl", "atm-device", ss, "atmlinkalias");
break;
}
}
} else if(strstr(ifname, "ptm")) {
adm_entry_get_linker_param(dmctx,dm_print_path("%s%cPTM%cLink%c", dmroot, dm_delim, dm_delim, dm_delim), ifname, &v);
uci_foreach_sections("dsl", "ptm-device", ss) {
if(strcmp(section_name(ss), ifname) == 0) {
loweralias = get_alias_by_section("dmmap_dsl", "ptm-device", ss, "ptmlinkalias");
break;
}
}
} else {
sprintf(linker, "%s.1", ifname);
adm_entry_get_linker_param(dmctx,dm_print_path("%s%cEthernet%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), linker, &v);
loweralias = get_alias_by_section("dmmap_ports", "ethport", port_s, "eth_port_alias");
}
}
sprintf(buf_loweralias, "%s", loweralias);
if (v == NULL)
v = "";
ifdata.higherlayer = vb;
ifdata.lowerlayer = v;
ifdata.higheralias = buf_higheralias;
ifdata.loweralias = buf_loweralias;
sprintf(buf_instance, "%d", ++instance);
dmmap_s = create_dmmap_interface_stack_section(buf_instance);
interface_stack_int = handle_update_instance(1, dmctx, &interface_stack_int_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&ifdata, interface_stack_int) == DM_STOP)
goto end;
if(strcmp(package, "wireless") == 0) {
sprintf(buf_higheralias, "%s", loweralias);
uci_foreach_option_eq("wireless", "wifi-iface", "ifname", ifname, ss) {
dmuci_get_value_by_section_string(ss, "device", &device);
}
if (device[0] != '\0') {
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cWiFi%cRadio%c", dmroot, dm_delim, dm_delim, dm_delim), device, &vb);
uci_foreach_sections("wireless", "wifi-device", ss) {
if(strcmp(section_name(ss), device) == 0) {
loweralias = get_alias_by_section("dmmap_wireless", "wifi-device", ss, "radioalias");
break;
}
}
}
if (vb == NULL)
vb = "";
sprintf(buf_loweralias, "%s", loweralias);
ifdata.higherlayer = v;
ifdata.lowerlayer = vb;
ifdata.higheralias = buf_higheralias;
ifdata.loweralias = buf_loweralias;
sprintf(buf_instance, "%d", ++instance);
dmmap_s = create_dmmap_interface_stack_section(buf_instance);
interface_stack_int = handle_update_instance(1, dmctx, &interface_stack_int_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&ifdata, interface_stack_int) == DM_STOP)
goto end;
}
if(strcmp(package, "network") == 0) {
if(strstr(ifname, "atm") || strstr(ifname, "ptm")) {
sprintf(buf_higheralias, "%s", loweralias);
char *link_channel = "channel_0";
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cDSL%cChannel%c", dmroot, dm_delim, dm_delim, dm_delim), link_channel, &vb);
if (vb == NULL)
vb = "";
uci_path_foreach_sections(icwmpd, "dmmap", "dsl_channel", ss) {
dmuci_get_value_by_section_string(ss, "dsl_channel_alias", &loweralias);
}
sprintf(buf_loweralias, "%s", loweralias);
ifdata.higherlayer = v;
ifdata.lowerlayer = vb;
ifdata.higheralias = buf_higheralias;
ifdata.loweralias = buf_loweralias;
sprintf(buf_instance, "%d", ++instance);
dmmap_s = create_dmmap_interface_stack_section(buf_instance);
interface_stack_int = handle_update_instance(1, dmctx, &interface_stack_int_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&ifdata, interface_stack_int) == DM_STOP)
goto end;
sprintf(buf_higheralias, "%s", loweralias);
char *link_line = "line_0";
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cDSL%cLine%c", dmroot, dm_delim, dm_delim, dm_delim), link_line, &value);
if (value == NULL)
value = "";
uci_path_foreach_sections(icwmpd, "dmmap", "dsl_line", ss) {
dmuci_get_value_by_section_string(ss, "dsl_line_alias", &loweralias);
}
sprintf(buf_loweralias, "%s", loweralias);
ifdata.higherlayer = vb;
ifdata.lowerlayer = value;
ifdata.higheralias = buf_higheralias;
ifdata.loweralias = buf_loweralias;
sprintf(buf_instance, "%d", ++instance);
dmmap_s = create_dmmap_interface_stack_section(buf_instance);
interface_stack_int = handle_update_instance(1, dmctx, &interface_stack_int_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&ifdata, interface_stack_int) == DM_STOP)
goto end;
}
}
}
}
end:
return 0;
}
/*************************************************************
* GET & SET PARAM
/*************************************************************/
int get_Device_InterfaceStackNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *s = NULL;
int cnt = 0;
uci_path_foreach_sections(icwmpd, "dmmap_interface_stack", "interface_stack", s)
{
cnt++;
}
dmasprintf(value, "%d", cnt);
return 0;
}
int get_InterfaceStack_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *s = NULL;
uci_path_foreach_option_eq(icwmpd, "dmmap_interface_stack", "interface_stack", "interface_stack_instance", instance, s) {
dmuci_get_value_by_section_string(s, "interface_stack_alias", value);
}
return 0;
}
int set_InterfaceStack_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *s = NULL;
switch (action) {
case VALUECHECK:
break;
case VALUESET:
uci_path_foreach_option_eq(icwmpd, "dmmap_interface_stack", "interface_stack", "interface_stack_instance", instance, s) {
dmuci_set_value_by_section(s, "interface_stack_alias", value);
}
break;
}
return 0;
}
int get_InterfaceStack_HigherLayer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct interfacestack_data *ifdata = (struct interfacestack_data *) data;
*value = dmstrdup(ifdata->higherlayer);
return 0;
}
int get_InterfaceStack_LowerLayer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct interfacestack_data *ifdata = (struct interfacestack_data *) data;
*value = dmstrdup(ifdata->lowerlayer);
return 0;
}
int get_InterfaceStack_HigherAlias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct interfacestack_data *ifdata = (struct interfacestack_data *) data;
*value = dmstrdup(ifdata->higheralias);
return 0;
}
int get_InterfaceStack_LowerAlias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct interfacestack_data *ifdata = (struct interfacestack_data *) data;
*value = dmstrdup(ifdata->loweralias);
return 0;
}

View file

@ -0,0 +1,34 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*/
#ifndef __INTERFACESTACK_H
#define __INTERFACESTACK_H
extern DMLEAF tInterfaceStackParams[];
struct interfacestack_data {
char *lowerlayer;
char *higherlayer;
char *loweralias;
char *higheralias;
};
int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int get_Device_InterfaceStackNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_InterfaceStack_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_InterfaceStack_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_InterfaceStack_HigherLayer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_InterfaceStack_LowerLayer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_InterfaceStack_HigherAlias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_InterfaceStack_LowerAlias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
#endif //__INTERFACESTACK_H

2017
dmtree/tr181/ip.c Normal file

File diff suppressed because it is too large Load diff

189
dmtree/tr181/ip.h Normal file
View file

@ -0,0 +1,189 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*
*/
#ifndef __IP_H
#define __IP_H
struct ip_args
{
struct uci_section *ip_sec;
char *ip_4address;
};
struct ipv6_args
{
struct uci_section *ip_sec;
char *ip_6address;
char *ip_6mask;
char *ip_6preferred;
char *ip_6valid;
};
struct ipv6prefix_args
{
struct uci_section *ip_sec;
char *ip_6prefixaddress;
char *ip_6prefixmask;
char *ip_6prefixpreferred;
char *ip_6prefixvalid;
};
extern DMOBJ tIPObj[];
extern DMLEAF tIPParams[];
extern DMOBJ tInterfaceObj[];
extern DMLEAF tIPintParams[];
extern DMLEAF tIPv4Params[];
extern DMLEAF tIPv6Params[];
extern DMLEAF tIPv6PrefixParams[];
extern DMLEAF tIPInterfaceStatsParams[];
extern DMLEAF tIPInterfaceTWAMPReflectorParams[];
unsigned char get_ipv4_finform(char *refparam, struct dmctx *dmctx, void *data, char *instance);
unsigned char get_ipv6_finform(char *refparam, struct dmctx *dmctx, void *data, char *instance);
int get_linker_ip_interface(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
int get_linker_ipv6_prefix(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
int browseIPIfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseIfaceIPv4Inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseIfaceIPv6Inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseIfaceIPv6PrefixInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseIPInterfaceTWAMPReflectorInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int add_ip_interface(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_ip_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_ipv4(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_ipv4(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_ipv6(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_ipv6(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_ipv6_prefix(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delete_ipv6_prefix(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int addObjIPInterfaceTWAMPReflector(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delObjIPInterfaceTWAMPReflector(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_IP_IPv4Capable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IP_IPv4Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IP_IPv4Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IP_IPv4Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IP_IPv6Capable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IP_IPv6Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IP_IPv6Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IP_IPv6Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IP_ULAPrefix(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IP_ULAPrefix(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IP_InterfaceNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ipv4_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_ipv4_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_firewall_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_firewall_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_ipv4_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_ipv4_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_ipv4_netmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_ipv4_netmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_ipv4_addressing_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_ipv4_addressing_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterface_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterface_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterface_IPv4Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterface_IPv4Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterface_IPv6Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterface_IPv6Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterface_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPInterface_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterface_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterface_Name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPInterface_LastChange(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterface_Router(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterface_Router(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterface_Reset(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterface_Reset(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterface_MaxMTUSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterface_MaxMTUSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterface_Type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPInterface_Loopback(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterface_Loopback(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterface_IPv4AddressNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPInterface_IPv6AddressNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPInterface_IPv6PrefixNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPInterface_TWAMPReflectorNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPInterfaceIPv6Address_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterfaceIPv6Address_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterfaceIPv6Address_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPInterfaceIPv6Address_IPAddressStatus(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPInterfaceIPv6Address_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterfaceIPv6Address_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterfaceIPv6Address_IPAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterfaceIPv6Address_IPAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterfaceIPv6Address_Origin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPInterfaceIPv6Address_Prefix(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterfaceIPv6Address_Prefix(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterfaceIPv6Address_PreferredLifetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterfaceIPv6Address_PreferredLifetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterfaceIPv6Address_ValidLifetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterfaceIPv6Address_ValidLifetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterfaceIPv6Prefix_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterfaceIPv6Prefix_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterfaceIPv6Prefix_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPInterfaceIPv6Prefix_PrefixStatus(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPInterfaceIPv6Prefix_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterfaceIPv6Prefix_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterfaceIPv6Prefix_Prefix(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterfaceIPv6Prefix_Prefix(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterfaceIPv6Prefix_Origin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPInterfaceIPv6Prefix_StaticType(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterfaceIPv6Prefix_StaticType(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterfaceIPv6Prefix_ParentPrefix(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterfaceIPv6Prefix_ParentPrefix(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterfaceIPv6Prefix_ChildPrefixBits(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterfaceIPv6Prefix_ChildPrefixBits(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterfaceIPv6Prefix_PreferredLifetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterfaceIPv6Prefix_PreferredLifetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterfaceIPv6Prefix_ValidLifetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterfaceIPv6Prefix_ValidLifetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterfaceTWAMPReflector_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterfaceTWAMPReflector_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterfaceTWAMPReflector_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPInterfaceTWAMPReflector_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterfaceTWAMPReflector_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterfaceTWAMPReflector_Port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterfaceTWAMPReflector_Port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterfaceTWAMPReflector_MaximumTTL(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterfaceTWAMPReflector_MaximumTTL(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterfaceTWAMPReflector_IPAllowedList(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterfaceTWAMPReflector_IPAllowedList(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterfaceTWAMPReflector_PortAllowedList(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterfaceTWAMPReflector_PortAllowedList(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_ip_interface_statistics_tx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_interface_statistics_rx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_interface_statistics_tx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_interface_statistics_rx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_interface_statistics_tx_errors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_interface_statistics_rx_errors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_interface_statistics_tx_discardpackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_interface_statistics_rx_discardpackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_interface_statistics_tx_unicastpackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_interface_statistics_rx_unicastpackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_interface_statistics_tx_multicastpackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_interface_statistics_rx_multicastpackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_interface_statistics_tx_broadcastpackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_interface_statistics_rx_broadcastpackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_interface_statistics_rx_unknownprotopackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
#endif

View file

@ -0,0 +1,717 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2012-2014 PIVA SOFTWARE (www.pivasoftware.com)
* Author: Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author: Feten Besbes <feten.besbes@pivasoftware.com>
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*/
#include <ctype.h>
#include <uci.h>
#include <stdio.h>
#include <time.h>
#include "dmmem.h"
#include "dmcwmp.h"
#include "dmuci.h"
#include "dmubus.h"
#include "dmcommon.h"
#include "managementserver.h"
#include "dmjson.h"
#define DEFAULT_ACSURL "http://192.168.1.1:8080/openacs/acs"
/*** ManagementServer. ***/
DMLEAF tManagementServerParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"URL", &DMWRITE, DMT_STRING, get_management_server_url, set_management_server_url, NULL, NULL, BBFDM_CWMP},
{"Username", &DMWRITE, DMT_STRING, get_management_server_username, set_management_server_username, NULL, NULL, BBFDM_CWMP},
{"Password", &DMWRITE, DMT_STRING, get_empty, set_management_server_passwd, NULL, NULL, BBFDM_CWMP},
{"ParameterKey", &DMREAD, DMT_STRING, get_management_server_key, NULL, &DMFINFRM, &DMNONE, BBFDM_CWMP},
{"PeriodicInformEnable", &DMWRITE, DMT_BOOL, get_management_server_periodic_inform_enable, set_management_server_periodic_inform_enable, NULL, NULL, BBFDM_CWMP},
{"PeriodicInformInterval", &DMWRITE, DMT_UNINT, get_management_server_periodic_inform_interval, set_management_server_periodic_inform_interval, NULL, NULL, BBFDM_CWMP},
{"PeriodicInformTime", &DMWRITE, DMT_TIME, get_management_server_periodic_inform_time, set_management_server_periodic_inform_time, NULL, NULL, BBFDM_CWMP},
{"ConnectionRequestURL", &DMREAD, DMT_STRING, get_management_server_connection_request_url, NULL, &DMFINFRM, &DMACTIVE, BBFDM_CWMP},
{"ConnectionRequestUsername", &DMWRITE, DMT_STRING, get_management_server_connection_request_username, set_management_server_connection_request_username, NULL, NULL, BBFDM_CWMP},
{"ConnectionRequestPassword", &DMWRITE, DMT_STRING, get_empty, set_management_server_connection_request_passwd, NULL, NULL, BBFDM_CWMP},
{"HTTPCompressionSupported", &DMREAD, DMT_STRING, get_management_server_http_compression_supportted, NULL, NULL, NULL, BBFDM_CWMP},
{"HTTPCompression", &DMWRITE, DMT_STRING, get_management_server_http_compression, set_management_server_http_compression, NULL, NULL, BBFDM_CWMP},
{"LightweightNotificationProtocolsSupported", &DMREAD, DMT_STRING, get_lwn_protocol_supported, NULL, NULL, NULL, BBFDM_CWMP},
{"LightweightNotificationProtocolsUsed", &DMWRITE, DMT_STRING, get_lwn_protocol_used, set_lwn_protocol_used, NULL, NULL, BBFDM_CWMP},
{"UDPLightweightNotificationHost", &DMWRITE, DMT_STRING, get_lwn_host, set_lwn_host, NULL, NULL, BBFDM_CWMP},
{"UDPLightweightNotificationPort", &DMWRITE, DMT_UNINT, get_lwn_port, set_lwn_port, NULL, NULL, BBFDM_CWMP},
{"CWMPRetryMinimumWaitInterval", &DMWRITE, DMT_UNINT, get_management_server_retry_min_wait_interval, set_management_server_retry_min_wait_interval, NULL, NULL, BBFDM_CWMP},
{"CWMPRetryIntervalMultiplier", &DMWRITE, DMT_UNINT, get_management_server_retry_interval_multiplier, set_management_server_retry_interval_multiplier, NULL, NULL, BBFDM_CWMP},
{"AliasBasedAddressing", &DMREAD, DMT_BOOL, get_alias_based_addressing, NULL, &DMFINFRM, NULL, BBFDM_CWMP},
{"InstanceMode", &DMWRITE, DMT_STRING, get_instance_mode, set_instance_mode, NULL, NULL, BBFDM_CWMP},
{"ConnReqAllowedJabberIDs", &DMWRITE, DMT_STRING, get_management_server_conn_rep_allowed_jabber_id, set_management_server_conn_rep_allowed_jabber_id, NULL, NULL, BBFDM_CWMP},
{"ConnReqJabberID", &DMREAD, DMT_STRING, get_management_server_conn_req_jabber_id, NULL, &DMFINFRM, &DMACTIVE, BBFDM_CWMP},
{"ConnReqXMPPConnection", &DMWRITE, DMT_STRING, get_management_server_conn_req_xmpp_connection, set_management_server_conn_req_xmpp_connection, &DMFINFRM, NULL, BBFDM_CWMP},
{"SupportedConnReqMethods", &DMREAD, DMT_STRING, get_management_server_supported_conn_req_methods, NULL, NULL, NULL, BBFDM_CWMP},
{"UDPConnectionRequestAddress", &DMREAD, DMT_STRING, get_upd_cr_address, NULL, NULL, &DMACTIVE, BBFDM_CWMP},
{"STUNEnable", &DMWRITE, DMT_BOOL, get_stun_enable, set_stun_enable, NULL, NULL, BBFDM_CWMP},
{"STUNServerAddress", &DMWRITE, DMT_STRING, get_stun_server_address, set_stun_server_address, NULL, NULL, BBFDM_CWMP},
{"STUNServerPort", &DMWRITE, DMT_UNINT, get_stun_server_port, set_stun_server_port, NULL, NULL, BBFDM_CWMP},
{"STUNUsername", &DMWRITE, DMT_STRING, get_stun_username, set_stun_username, NULL, NULL, BBFDM_CWMP},
{"STUNPassword", &DMWRITE, DMT_STRING, get_stun_password, set_stun_password, NULL, NULL, BBFDM_CWMP},
{"STUNMaximumKeepAlivePeriod", &DMWRITE, DMT_INT, get_stun_maximum_keepalive_period, set_stun_maximum_keepalive_period, NULL, NULL, BBFDM_CWMP},
{"STUNMinimumKeepAlivePeriod", &DMWRITE, DMT_UNINT, get_stun_minimum_keepalive_period, set_stun_minimum_keepalive_period, NULL, NULL, BBFDM_CWMP},
{"NATDetected", &DMREAD, DMT_BOOL, get_nat_detected, NULL, NULL, NULL, BBFDM_CWMP},
{0}
};
/*#Device.ManagementServer.URL!UCI:cwmp/cwmp,acs/url*/
int get_management_server_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
int i = 1;
char *dhcp = NULL, *pch = NULL, *spch = NULL;
char *url = NULL;
char *provisioning_value = NULL;
char package[64] = "", section[64] = "", option[64] = "";
dmuci_get_option_value_string("cwmp", "acs", "dhcp_discovery", &dhcp);
dmuci_get_option_value_string("cwmp", "acs", "url", &url);
dmuci_get_varstate_string("cwmp", "acs", "dhcp_url", &provisioning_value);
if ( ((dhcp && strcmp(dhcp, "enable") == 0 ) || ((url == NULL) || (url[0] == '\0'))) && ((provisioning_value != NULL) && (provisioning_value[0] != '\0')) )
{
*value = provisioning_value;
}
else if ((url != NULL) && (url[0] != '\0'))
*value = url;
else
*value = dmstrdup(DEFAULT_ACSURL);
return 0;
}
int set_management_server_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("cwmp", "acs", "dhcp_discovery", "disable");
dmuci_set_value("cwmp", "acs", "url", value);
cwmp_set_end_session(END_SESSION_RELOAD);
return 0;
}
return 0;
}
/*#Device.ManagementServer.Username!UCI:cwmp/cwmp,acs/userid*/
int get_management_server_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "acs", "userid", value);
return 0;
}
int set_management_server_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("cwmp", "acs", "userid", value);
cwmp_set_end_session(END_SESSION_RELOAD);
return 0;
}
return 0;
}
/*#Device.ManagementServer.Password!UCI:cwmp/cwmp,acs/passwd*/
int set_management_server_passwd(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("cwmp", "acs", "passwd", value);
cwmp_set_end_session(END_SESSION_RELOAD);
return 0;
}
return 0;
}
/*#Device.ManagementServer.ParameterKey!UCI:cwmp/cwmp,acs/ParameterKey*/
int get_management_server_key(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "acs", "ParameterKey", value);
return 0;
}
/*#Device.ManagementServer.PeriodicInformEnable!UCI:cwmp/cwmp,acs/periodic_inform_enable*/
int get_management_server_periodic_inform_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "acs", "periodic_inform_enable", value);
return 0;
}
int set_management_server_periodic_inform_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if (b)
dmuci_set_value("cwmp", "acs", "periodic_inform_enable", "1");
else
dmuci_set_value("cwmp", "acs", "periodic_inform_enable", "0");
cwmp_set_end_session(END_SESSION_RELOAD);
return 0;
}
return 0;
}
/*#Device.ManagementServer.PeriodicInformInterval!UCI:cwmp/cwmp,acs/periodic_inform_interval*/
int get_management_server_periodic_inform_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "acs", "periodic_inform_interval", value);
return 0;
}
int set_management_server_periodic_inform_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("cwmp", "acs", "periodic_inform_interval", value);
cwmp_set_end_session(END_SESSION_RELOAD);
return 0;
}
return 0;
}
/*#Device.ManagementServer.PeriodicInformTime!UCI:cwmp/cwmp,acs/periodic_inform_time*/
int get_management_server_periodic_inform_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
time_t time_value;
dmuci_get_option_value_string("cwmp", "acs", "periodic_inform_time", value);
if ((*value)[0] != '0' && (*value)[0] != '\0') {
time_value = atoi(*value);
char s_now[sizeof "AAAA-MM-JJTHH:MM:SS.000Z"];
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S.000Z", localtime(&time_value));
*value = dmstrdup(s_now); // MEM WILL BE FREED IN DMMEMCLEAN
}
else {
*value = "0001-01-01T00:00:00Z";
}
return 0;
}
int set_management_server_periodic_inform_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct tm tm;
char *p, buf[16];
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
if (!(strptime(value, "%Y-%m-%dT%H:%M:%S", &tm))) {
return 0;
}
sprintf(buf, "%ld", mktime(&tm));
dmuci_set_value("cwmp", "acs", "periodic_inform_time", buf);
cwmp_set_end_session(END_SESSION_RELOAD);
return 0;
}
return 0;
}
/*#Device.ManagementServer.ConnectionRequestURL!UCI:cwmp/cwmp,cpe/port*/
int get_management_server_connection_request_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *ip, *port, *iface;
*value = "";
dmuci_get_option_value_string("cwmp", "cpe", "default_wan_interface", &iface);
network_get_ipaddr(&ip, iface);
dmuci_get_option_value_string("cwmp", "cpe", "port", &port);
if (ip[0] != '\0' && port[0] != '\0') {
char buf[64];
sprintf(buf,"http://%s:%s/", ip, port);
*value = dmstrdup(buf); // MEM WILL BE FREED IN DMMEMCLEAN
}
return 0;
}
/*#Device.ManagementServer.ConnectionRequestUsername!UCI:cwmp/cwmp,cpe/userid*/
int get_management_server_connection_request_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "cpe", "userid", value);
return 0;
}
int set_management_server_connection_request_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("cwmp", "cpe", "userid", value);
cwmp_set_end_session(END_SESSION_RELOAD);
return 0;
}
return 0;
}
/*#Device.ManagementServer.ConnectionRequestPassword!UCI:cwmp/cwmp,cpe/passwd*/
int set_management_server_connection_request_passwd(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("cwmp", "cpe", "passwd", value);
cwmp_set_end_session(END_SESSION_RELOAD);
return 0;
}
return 0;
}
int get_lwn_protocol_supported(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "UDP";
return 0;
}
/*#Device.ManagementServer.LightweightNotificationProtocolsUsed!UCI:cwmp/cwmp,lwn/enable*/
int get_lwn_protocol_used(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
bool b;
char *tmp;
dmuci_get_option_value_string("cwmp", "lwn", "enable", &tmp);
string_to_bool(tmp, &b);
if (b)
*value = "UDP";
else
*value = "";
return 0;
}
int set_lwn_protocol_used(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
if (strcmp(value,"UDP") ==0) {
dmuci_set_value("cwmp", "lwn", "enable", "1");
cwmp_set_end_session(END_SESSION_RELOAD);
}
else {
dmuci_set_value("cwmp", "lwn", "enable", "0");
cwmp_set_end_session(END_SESSION_RELOAD);
}
return 0;
}
return 0;
}
/*#Device.ManagementServer.UDPLightweightNotificationHost!UCI:cwmp/cwmp,lwn/hostname*/
int get_lwn_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "lwn", "hostname", value);
return 0;
}
int set_lwn_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("cwmp", "lwn", "hostname", value);
cwmp_set_end_session(END_SESSION_RELOAD);
return 0;
}
return 0;
}
/*#Device.ManagementServer.UDPLightweightNotificationPort!UCI:cwmp/cwmp,lwn/port*/
int get_lwn_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "lwn", "port", value);
return 0;
}
int set_lwn_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("cwmp", "lwn", "port", value);
cwmp_set_end_session(END_SESSION_RELOAD);
return 0;
}
return 0;
}
int get_management_server_http_compression_supportted(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "GZIP,Deflate";
return 0;
}
/*#Device.ManagementServer.HTTPCompression!UCI:cwmp/cwmp,acs/compression*/
int get_management_server_http_compression(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "acs", "compression", value);
return 0;
}
int set_management_server_http_compression(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
if (0 == strcasecmp(value, "gzip") || 0 == strcasecmp(value, "deflate") || 0 == strncasecmp(value, "disable", 7)) {
return 0;
}
return FAULT_9007;
case VALUESET:
dmuci_set_value("cwmp", "acs", "compression", value);
cwmp_set_end_session(END_SESSION_RELOAD);
return 0;
}
return 0;
}
/*#Device.ManagementServer.CWMPRetryMinimumWaitInterval!UCI:cwmp/cwmp,acs/retry_min_wait_interval*/
int get_management_server_retry_min_wait_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "acs", "retry_min_wait_interval", value);
return 0;
}
int set_management_server_retry_min_wait_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
int a;
switch (action) {
case VALUECHECK:
a = atoi(value);
if (a <= 65535 && a >= 1) {
return 0;
}
return FAULT_9007;
case VALUESET:
dmuci_set_value("cwmp", "acs", "retry_min_wait_interval", value);
cwmp_set_end_session(END_SESSION_RELOAD);
return 0;
}
return 0;
}
/*#Device.ManagementServer.CWMPRetryIntervalMultiplier!UCI:cwmp/cwmp,acs/retry_interval_multiplier*/
int get_management_server_retry_interval_multiplier(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "acs", "retry_interval_multiplier", value);
return 0;
}
int set_management_server_retry_interval_multiplier(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
int a;
switch (action) {
case VALUECHECK:
a = atoi(value);
if (a <= 65535 && a >= 1000) {
return 0;
}
return FAULT_9007;
case VALUESET:
dmuci_set_value("cwmp", "acs", "retry_interval_multiplier", value);
cwmp_set_end_session(END_SESSION_RELOAD);
return 0;
}
return 0;
}
/*#Device.ManagementServer.AliasBasedAddressing!UCI:cwmp/cwmp,cpe/amd_version*/
int get_alias_based_addressing(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "cpe", "amd_version", value);
if((*value)[0] == '\0'|| atoi(*value) <= AMD_4) {
*value = "false";
}
else {
*value = "true";
}
return 0;
}
/*#Device.ManagementServer.InstanceMode!UCI:cwmp/cwmp,cpe/instance_mode*/
int get_instance_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "cpe", "instance_mode", value);
return 0;
}
int set_instance_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
if (0 == strcmp(value, "InstanceNumber") || 0 == strcmp(value, "InstanceAlias") ) {
return 0;
}
return FAULT_9007;
case VALUESET:
dmuci_set_value("cwmp", "cpe", "instance_mode", value);
cwmp_set_end_session(END_SESSION_RELOAD);
return 0;
}
return 0;
}
/*
* STUN parameters
*/
/*#Device.ManagementServer.UDPConnectionRequestAddress!UCI:cwmp_stun/stun,stun/crudp_address*/
int get_upd_cr_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
dmuci_get_varstate_string("cwmp_stun", "stun", "crudp_address", value);
return 0;
}
int get_stun_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
char *path = "/etc/rc.d/*icwmp_stund";
if (check_file(path))
*value = "1";
else
*value = "0";
return 0;
}
int set_stun_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action){
bool b;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b) {
DMCMD("/etc/rc.common", 2, "/etc/init.d/icwmp_stund", "enable");
DMCMD("/etc/rc.common", 2, "/etc/init.d/icwmp_stund", "start");
}
else {
DMCMD("/etc/rc.common", 2, "/etc/init.d/icwmp_stund", "disable");
DMCMD("/etc/rc.common", 2, "/etc/init.d/icwmp_stund", "stop");
}
return 0;
}
return 0;
}
/*#Device.ManagementServer.STUNServerAddress!UCI:cwmp_stun/stun,stun/server_address*/
int get_stun_server_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
dmuci_get_option_value_string("cwmp_stun", "stun", "server_address", value);
return 0;
}
int set_stun_server_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action){
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("cwmp_stun", "stun", "server_address", value);
return 0;
}
return 0;
}
/*#Device.ManagementServer.STUNServerPort!UCI:cwmp_stun/stun,stun/server_port*/
int get_stun_server_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
dmuci_get_option_value_string("cwmp_stun", "stun", "server_port", value);
return 0;
}
int set_stun_server_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action){
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("cwmp_stun", "stun", "server_port", value);
return 0;
}
return 0;
}
/*#Device.ManagementServer.STUNUsername!UCI:cwmp_stun/stun,stun/username*/
int get_stun_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
dmuci_get_option_value_string("cwmp_stun", "stun", "username", value);
return 0;
}
int set_stun_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action){
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("cwmp_stun", "stun", "username", value);
return 0;
}
return 0;
}
/*#Device.ManagementServer.STUNPassword!UCI:cwmp_stun/stun,stun/password*/
int get_stun_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
dmuci_get_option_value_string("cwmp_stun", "stun", "password", value);
return 0;
}
int set_stun_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action){
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("cwmp_stun", "stun", "password", value);
return 0;
}
return 0;
}
/*#Device.ManagementServer.STUNMaximumKeepAlivePeriod!UCI:cwmp_stun/stun,stun/max_keepalive*/
int get_stun_maximum_keepalive_period(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
dmuci_get_option_value_string("cwmp_stun", "stun", "max_keepalive", value);
return 0;
}
int set_stun_maximum_keepalive_period(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action){
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("cwmp_stun", "stun", "max_keepalive", value);
return 0;
}
return 0;
}
/*#Device.ManagementServer.STUNMinimumKeepAlivePeriod!UCI:cwmp_stun/stun,stun/min_keepalive*/
int get_stun_minimum_keepalive_period(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
dmuci_get_option_value_string("cwmp_stun", "stun", "min_keepalive", value);
return 0;
}
int set_stun_minimum_keepalive_period(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action){
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("cwmp_stun", "stun", "min_keepalive", value);
return 0;
}
return 0;
}
/*#Device.ManagementServer.NATDetected!UCI:cwmp_stun/stun,stun/nat_detected*/
int get_nat_detected(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
char *path = "/etc/rc.d/*icwmp_stund";
char *v;
if (check_file(path)) { //stun is enabled
dmuci_get_varstate_string("cwmp_stun", "stun", "nat_detected", &v);
*value = (*v == '1') ? "true" : "false";
}
else {
*value = "false";
}
return 0;
}
/*
* XMPP parameters
*/
/*#Device.ManagementServer.ConnReqAllowedJabberIDs!UCI:cwmp_xmpp/cwmp,xmpp/allowed_jid*/
int get_management_server_conn_rep_allowed_jabber_id(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp_xmpp", "xmpp", "allowed_jid", value);
return 0;
}
int set_management_server_conn_rep_allowed_jabber_id(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("cwmp_xmpp", "xmpp", "allowed_jid", value);
return 0;
}
return 0;
}
int get_management_server_conn_req_jabber_id(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *s;
char *username, *domain, *resource, *tmpPtr, *strResponse = "";
*value = "";
uci_foreach_sections("cwmp_xmpp", "xmpp_connection", s) {
dmuci_get_value_by_section_string(s, "username", &username);
dmuci_get_value_by_section_string(s, "domain", &domain);
dmuci_get_value_by_section_string(s, "resource", &resource);
if(*username != '\0' || *domain != '\0' || *resource != '\0') {
if(*strResponse == '\0')
dmasprintf(&strResponse, "%s@%s/%s", username, domain, resource);
else {
tmpPtr = dmstrdup(strResponse);
dmasprintf(&strResponse, "%s, %s@%s/%s", tmpPtr, username, domain, resource);
}
}
}
*value = dmstrdup(strResponse);
return 0;
}
int get_management_server_conn_req_xmpp_connection(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *id;
dmuci_get_option_value_string("cwmp_xmpp", "xmpp", "id", &id);
dmasprintf(value, "Device.XMPP.Connection.%s", id);
return 0;
}
int set_management_server_conn_req_xmpp_connection(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *str, *connection_instance;
struct uci_section *s = NULL;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
if (str = strstr(value, "Device.XMPP.Connection.")) {
value = dmstrdup(str + sizeof("Device.XMPP.Connection.") - 1); //MEM WILL BE FREED IN DMMEMCLEAN
}
uci_foreach_sections("cwmp_xmpp", "xmpp_connection", s) {
dmuci_get_value_by_section_string(s, "connection_instance", &connection_instance);
if(strcmp(value, connection_instance) == 0) {
dmuci_set_value("cwmp_xmpp", "xmpp", "id", value);
break;
}
}
cwmp_set_end_session(END_SESSION_RELOAD);
return 0;
}
return 0;
}
int get_management_server_supported_conn_req_methods(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "HTTP,XMPP,STUN";
return 0;
}

View file

@ -0,0 +1,79 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2012-2014 PIVA SOFTWARE (www.pivasoftware.com)
* Author: Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author: Feten Besbes <feten.besbes@pivasoftware.com>
*/
#ifndef __MANAGEMENT_SERVER_H
#define __MANAGEMENT_SERVER_H
#include "dmcwmp.h"
extern DMLEAF tManagementServerParams[];
int get_management_server_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_empty(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_key(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_periodic_inform_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_periodic_inform_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_periodic_inform_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_connection_request_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_connection_request_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_http_compression_supportted(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_http_compression(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lwn_protocol_supported(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lwn_protocol_used(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lwn_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lwn_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_retry_min_wait_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_retry_interval_multiplier(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_alias_based_addressing(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_instance_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_conn_rep_allowed_jabber_id(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_conn_req_jabber_id(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_conn_req_xmpp_connection(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_supported_conn_req_methods(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_upd_cr_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_upd_cr_address_notification_limit(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_stun_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_stun_server_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_stun_server_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_stun_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_stun_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_stun_maximum_keepalive_period(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_stun_minimum_keepalive_period(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_nat_detected(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_management_server_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_management_server_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_management_server_passwd(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_management_server_periodic_inform_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_management_server_periodic_inform_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_management_server_periodic_inform_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_management_server_connection_request_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_management_server_connection_request_passwd(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_management_server_http_compression(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_lwn_protocol_used(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_lwn_protocol_used(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_lwn_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_lwn_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_management_server_retry_min_wait_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_management_server_retry_interval_multiplier(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_instance_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_management_server_conn_rep_allowed_jabber_id(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_management_server_conn_req_xmpp_connection(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_upd_cr_address_notification_limit(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_stun_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_stun_server_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_stun_server_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_stun_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_stun_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_stun_maximum_keepalive_period(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_stun_minimum_keepalive_period(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

686
dmtree/tr181/nat.c Normal file
View file

@ -0,0 +1,686 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*
*/
#include <uci.h>
#include <stdio.h>
#include <ctype.h>
#include "dmuci.h"
#include "dmubus.h"
#include "dmcwmp.h"
#include "dmcommon.h"
#include "dmentry.h"
#include "nat.h"
/* *** Device.NAT. *** */
DMOBJ tNATObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{"InterfaceSetting", &DMWRITE, add_NAT_InterfaceSetting, delete_NAT_InterfaceSetting, NULL, browseInterfaceSettingInst, NULL, NULL, NULL, tNATInterfaceSettingParams, NULL, BBFDM_BOTH},
{"PortMapping", &DMWRITE, add_NAT_PortMapping, delete_NAT_PortMapping, NULL, browsePortMappingInst, NULL, NULL, NULL, tNATPortMappingParams, NULL, BBFDM_BOTH},
{0}
};
DMLEAF tNATParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"InterfaceSettingNumberOfEntries", &DMREAD, DMT_UNINT, get_nat_interface_setting_number_of_entries, NULL, NULL, NULL, BBFDM_BOTH},
{"PortMappingNumberOfEntries", &DMREAD, DMT_UNINT, get_nat_port_mapping_number_of_entries, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/* *** Device.NAT.InterfaceSetting.{i}. *** */
DMLEAF tNATInterfaceSettingParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_nat_interface_setting_enable, set_nat_interface_setting_enable, NULL, NULL, BBFDM_BOTH},
{"Status", &DMWRITE, DMT_STRING, get_nat_interface_setting_status, NULL, NULL, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_nat_interface_setting_alias, set_nat_interface_setting_alias, NULL, NULL, BBFDM_BOTH},
{"Interface", &DMWRITE, DMT_STRING, get_nat_interface_setting_interface, set_nat_interface_setting_interface, NULL, NULL, BBFDM_BOTH},
{0}
};
/* *** Device.NAT.PortMapping.{i}. *** */
DMLEAF tNATPortMappingParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_nat_port_mapping_enable, set_nat_port_mapping_enable, NULL, NULL, BBFDM_BOTH},
{"Status", &DMWRITE, DMT_STRING, get_nat_port_mapping_status, NULL, NULL, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_nat_port_mapping_alias, set_nat_port_mapping_alias, NULL, NULL, BBFDM_BOTH},
{"Interface", &DMWRITE, DMT_STRING, get_nat_port_mapping_interface, set_nat_port_mapping_interface, NULL, NULL, BBFDM_BOTH},
{"AllInterfaces", &DMWRITE, DMT_BOOL, get_nat_port_mapping_all_interface, set_nat_port_mapping_all_interface, NULL, NULL, BBFDM_BOTH},
{"LeaseDuration", &DMWRITE, DMT_UNINT, get_nat_port_mapping_lease_duration, set_nat_port_mapping_lease_duration, NULL, NULL, BBFDM_BOTH},
{"RemoteHost", &DMWRITE, DMT_STRING, get_nat_port_mapping_remote_host, set_nat_port_mapping_remote_host, NULL, NULL, BBFDM_BOTH},
{"ExternalPort", &DMWRITE, DMT_UNINT, get_nat_port_mapping_external_port, set_nat_port_mapping_external_port, NULL, NULL, BBFDM_BOTH},
{"ExternalPortEndRange", &DMWRITE, DMT_UNINT, get_nat_port_mapping_external_port_end_range, set_nat_port_mapping_external_port_end_range, NULL, NULL, BBFDM_BOTH},
{"InternalPort", &DMWRITE, DMT_UNINT, get_nat_port_mapping_internal_port, set_nat_port_mapping_internal_port, NULL, NULL, BBFDM_BOTH},
{"Protocol", &DMWRITE, DMT_STRING, get_nat_port_mapping_protocol, set_nat_port_mapping_protocol, NULL, NULL, BBFDM_BOTH},
{"InternalClient", &DMWRITE, DMT_STRING, get_nat_port_mapping_internal_client, set_nat_port_mapping_internal_client, NULL, NULL, BBFDM_BOTH},
{"Description", &DMWRITE, DMT_STRING, get_nat_port_mapping_description, set_nat_port_mapping_description, NULL, NULL, BBFDM_BOTH},
{0}
};
/*************************************************************
* ADD DEL OBJ
/*************************************************************/
int add_NAT_InterfaceSetting(char *refparam, struct dmctx *ctx, void *data, char **instance)
{
char *value, *v, *inst, name[16];
struct uci_section *s = NULL, *dmmap_firewall = NULL;
check_create_dmmap_package("dmmap_firewall");
inst = get_last_instance_icwmpd("dmmap_firewall", "zone", "interface_setting_instance");
sprintf(name, "iface_set_%d", inst ? (atoi(inst)+1) : 1);
dmuci_add_section_and_rename("firewall", "zone", &s, &value);
dmuci_set_value_by_section(s, "input", "REJECT");
dmuci_set_value_by_section(s, "output", "ACCEPT");
dmuci_set_value_by_section(s, "forward", "REJECT");
dmuci_set_value_by_section(s, "name", name);
dmuci_add_section_icwmpd("dmmap_firewall", "zone", &dmmap_firewall, &v);
dmuci_set_value_by_section(dmmap_firewall, "section_name", section_name(s));
*instance = update_instance_icwmpd(dmmap_firewall, inst, "interface_setting_instance");
return 0;
}
int delete_NAT_InterfaceSetting(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
int found = 0;
char *lan_name;
struct uci_section *s = NULL, *ss = NULL, *dmmap_firewall= NULL;
switch (del_action) {
case DEL_INST:
get_dmmap_section_of_config_section("dmmap_firewall", "zone", section_name((struct uci_section *)data), &dmmap_firewall);
if(dmmap_firewall != NULL)
dmuci_delete_by_section(dmmap_firewall, NULL, NULL);
dmuci_delete_by_section((struct uci_section *)data, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_sections("firewall", "zone", s) {
if (found != 0){
get_dmmap_section_of_config_section("dmmap_firewall", "zone", section_name(ss), &dmmap_firewall);
if(dmmap_firewall != NULL)
dmuci_delete_by_section(dmmap_firewall, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
ss = s;
found++;
}
if (ss != NULL){
get_dmmap_section_of_config_section("dmmap_firewall", "zone", section_name(ss), &dmmap_firewall);
if(dmmap_firewall != NULL)
dmuci_delete_by_section(dmmap_firewall, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
return 0;
}
return 0;
}
int add_NAT_PortMapping(char *refparam, struct dmctx *ctx, void *data, char **instance)
{
char *value, *v, *inst, name[16];
struct uci_section *s = NULL, *dmmap_firewall = NULL;
check_create_dmmap_package("dmmap_firewall");
inst = get_last_instance_icwmpd("dmmap_firewall", "redirect", "port_mapping_instance");
sprintf(name, "port_map_%d", inst ? (atoi(inst)+1) : 1);
dmuci_add_section_and_rename("firewall", "redirect", &s, &value);
dmuci_set_value_by_section(s, "name", name);
dmuci_set_value_by_section(s, "src", "wan");
dmuci_set_value_by_section(s, "target", "DNAT");
dmuci_set_value_by_section(s, "dest", "lan");
dmuci_add_section_icwmpd("dmmap_firewall", "redirect", &dmmap_firewall, &v);
dmuci_set_value_by_section(dmmap_firewall, "section_name", section_name(s));
*instance = update_instance_icwmpd(dmmap_firewall, inst, "port_mapping_instance");
return 0;
}
int delete_NAT_PortMapping(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
int found = 0;
char *lan_name;
struct uci_section *s = NULL, *ss = NULL, *dmmap_firewall= NULL;
switch (del_action) {
case DEL_INST:
get_dmmap_section_of_config_section("dmmap_firewall", "redirect", section_name((struct uci_section *)data), &dmmap_firewall);
if(dmmap_firewall != NULL)
dmuci_delete_by_section(dmmap_firewall, NULL, NULL);
dmuci_delete_by_section((struct uci_section *)data, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_sections("firewall", "redirect", s) {
if (found != 0){
get_dmmap_section_of_config_section("dmmap_firewall", "redirect", section_name(ss), &dmmap_firewall);
if(dmmap_firewall != NULL)
dmuci_delete_by_section(dmmap_firewall, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
ss = s;
found++;
}
if (ss != NULL){
get_dmmap_section_of_config_section("dmmap_firewall", "redirect", section_name(ss), &dmmap_firewall);
if(dmmap_firewall != NULL)
dmuci_delete_by_section(dmmap_firewall, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
return 0;
}
return 0;
}
/**************************************************************************
* SET & GET VALUE
***************************************************************************/
/*#Device.NAT.InterfaceSettingNumberOfEntries!UCI:firewall/zone/*/
int get_nat_interface_setting_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *s = NULL;
int cnt = 0;
uci_foreach_sections("firewall", "zone", s)
{
cnt++;
}
dmasprintf(value, "%d", cnt);
return 0;
}
/*#Device.NAT.PortMappingNumberOfEntries!UCI:firewall/redirect/*/
int get_nat_port_mapping_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *s = NULL;
int cnt = 0;
uci_foreach_sections("firewall", "redirect", s)
{
cnt++;
}
dmasprintf(value, "%d", cnt);
return 0;
}
/*#Device.NAT.InterfaceSetting.{i}.Enable!UCI:firewall/zone,@i-1/masq*/
int get_nat_interface_setting_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *val;
dmuci_get_value_by_section_string((struct uci_section *)data, "masq", &val);
*value = (*val == '1') ? "1" : "0";
return 0;
}
int set_nat_interface_setting_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
dmuci_set_value_by_section((struct uci_section *)data, "masq", b ? "1" : "0");
return 0;
}
return 0;
}
/*#Device.NAT.InterfaceSetting.{i}.Status!UCI:firewall/zone,@i-1/masq*/
int get_nat_interface_setting_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *val;
dmuci_get_value_by_section_string((struct uci_section *)data, "masq", &val);
*value = (*val == '1') ? "Enabled" : "Disabled";
return 0;
}
int get_nat_interface_setting_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
get_dmmap_section_of_config_section("dmmap_firewall", "zone", section_name((struct uci_section *)data), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "interface_setting_alias", value);
return 0;
}
int set_nat_interface_setting_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
get_dmmap_section_of_config_section("dmmap_firewall", "zone", section_name((struct uci_section *)data), &dmmap_section);
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(dmmap_section, "interface_setting_alias", value);
return 0;
}
return 0;
}
int get_nat_interface_setting_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_list *v;
struct uci_element *e;
char *ifaceobj, buf[256] = "";
*value = "";
dmuci_get_value_by_section_list((struct uci_section *)data, "network", &v);
if (v == NULL)
return 0;
uci_foreach_element(v, e) {
adm_entry_get_linker_param(ctx, dm_print_path("%s%cIP%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), e->name, &ifaceobj); // MEM WILL BE FREED IN DMMEMCLEAN
if (ifaceobj == NULL)
continue;
if (*buf != '\0')
strcat(buf, ",");
strcat(buf, ifaceobj);
}
*value = dmstrdup(buf);
return 0;
}
int set_nat_interface_setting_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *iface, *pch, *pchr, buf[256] = "";
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
strcpy(buf, value);
dmuci_set_value_by_section((struct uci_section *)data, "network", "");
for(pch = strtok_r(buf, ",", &pchr); pch != NULL; pch = strtok_r(NULL, ",", &pchr)) {
adm_entry_get_linker_value(ctx, pch, &iface);
if (iface) {
dmuci_add_list_value_by_section((struct uci_section *)data, "network", iface);
free(iface);
}
}
return 0;
}
return 0;
}
/*#Device.NAT.PortMapping.{i}.Enable!UCI:firewall/redirect,@i-1/enabled*/
int get_nat_port_mapping_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *val;
dmuci_get_value_by_section_string((struct uci_section *)data, "enabled", &val);
*value = (*val == '1') ? "1" : "0";
return 0;
}
int set_nat_port_mapping_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
dmuci_set_value_by_section((struct uci_section *)data, "enabled", b ? "1" : "0");
return 0;
}
return 0;
}
/*#Device.NAT.PortMapping.{i}.Status!UCI:firewall/redirect,@i-1/enabled*/
int get_nat_port_mapping_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *val;
dmuci_get_value_by_section_string((struct uci_section *)data, "enabled", &val);
*value = (*val == '1') ? "Enabled" : "Disabled";
return 0;
}
int get_nat_port_mapping_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
get_dmmap_section_of_config_section("dmmap_firewall", "redirect", section_name((struct uci_section *)data), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "port_mapping_alias", value);
return 0;
}
int set_nat_port_mapping_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
get_dmmap_section_of_config_section("dmmap_firewall", "redirect", section_name((struct uci_section *)data), &dmmap_section);
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(dmmap_section, "port_mapping_alias", value);
return 0;
}
return 0;
}
int get_nat_port_mapping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *s = NULL;
struct uci_list *v;
struct uci_element *e;
char *zone, *name, *ifaceobj, buf[256] = "";
dmuci_get_value_by_section_string((struct uci_section *)data, "src", &zone);
uci_foreach_sections("firewall", "zone", s) {
dmuci_get_value_by_section_string(s, "name", &name);
if (strcmp(zone, name) == 0) {
dmuci_get_value_by_section_list(s, "network", &v);
break;
}
}
if (v == NULL)
return 0;
uci_foreach_element(v, e) {
adm_entry_get_linker_param(ctx, dm_print_path("%s%cIP%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), e->name, &ifaceobj); // MEM WILL BE FREED IN DMMEMCLEAN
if (ifaceobj == NULL)
continue;
if (*buf != '\0')
strcat(buf, ",");
strcat(buf, ifaceobj);
}
*value = dmstrdup(buf);
return 0;
}
int set_nat_port_mapping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *iface, *network, *zone;
struct uci_section *s = NULL;
switch (action) {
case VALUECHECK:
break;
case VALUESET:
adm_entry_get_linker_value(ctx, value, &iface);
if (iface[0] != '\0') {
uci_foreach_sections("firewall", "zone", s)
{
dmuci_get_value_by_section_string(s, "network", &network);
if (is_strword_in_optionvalue(network, iface)){
dmuci_get_value_by_section_string(s, "name", &zone);
dmuci_set_value_by_section((struct uci_section *)data, "src", zone);
break;
}
}
}
break;
}
return 0;
}
int get_nat_port_mapping_all_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "0";
return 0;
}
int set_nat_port_mapping_all_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
return 0;
}
return 0;
}
int get_nat_port_mapping_lease_duration(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
// CPE only supports static port forwards
*value = "0";
return 0;
}
int set_nat_port_mapping_lease_duration(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
// CPE only supports static port forwards
if (strcmp(value, "0") != 0)
return FAULT_9007;
return 0;
case VALUESET:
// Nothing to set for static port forwards
return 0;
}
return 0;
}
/*#Device.NAT.PortMapping.{i}.RemoteHost!UCI:firewall/redirect,@i-1/src_dip*/
int get_nat_port_mapping_remote_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "src_dip", value);
return 0;
}
int set_nat_port_mapping_remote_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "src_dip", value);
return 0;
}
return 0;
}
/*#Device.NAT.PortMapping.{i}.ExternalPort!UCI:firewall/redirect,@i-1/src_dport*/
int get_nat_port_mapping_external_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *dport, *tmp;
dmuci_get_value_by_section_string((struct uci_section *)data, "src_dport", &dport);
if (*dport == '\0') {
*value = "0";
return 0;
}
tmp = strchr(dport, ':');
if (tmp)
*tmp = '\0';
*value = dport;
return 0;
}
int set_nat_port_mapping_external_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *dport, buffer[64];
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_get_value_by_section_string((struct uci_section *)data, "src_dport", &dport);
dport = strchr(dport, ':');
if (dport == NULL)
sprintf(buffer, "%s", value);
else
sprintf(buffer, "%s%s", value, dport);
dmuci_set_value_by_section((struct uci_section *)data, "src_dport", buffer);
return 0;
}
return 0;
}
/*#Device.NAT.PortMapping.{i}.ExternalPortEndRange!UCI:firewall/redirect,@i-1/src_dport*/
int get_nat_port_mapping_external_port_end_range(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *dport, *tmp;
dmuci_get_value_by_section_string((struct uci_section *)data, "src_dport", &dport);
tmp = strchr(dport, ':');
*value = (tmp) ? tmp+1 : "0";
return 0;
}
int set_nat_port_mapping_external_port_end_range(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *dport, *tmp, buffer[64];
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_get_value_by_section_string((struct uci_section *)data, "src_dport", &dport);
tmp = strchr(dport, ':');
if (tmp)
*tmp = '\0';
if (*value == '0')
sprintf(buffer, "%s", dport);
else
sprintf(buffer, "%s:%s", dport, value);
dmuci_set_value_by_section((struct uci_section *)data, "src_dport", buffer);
return 0;
}
return 0;
}
/*#Device.NAT.PortMapping.{i}.InternalPort!UCI:firewall/redirect,@i-1/dest_port*/
int get_nat_port_mapping_internal_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "dest_port", value);
return 0;
}
int set_nat_port_mapping_internal_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "dest_port", value);
return 0;
}
return 0;
}
/*#Device.NAT.PortMapping.{i}.Protocol!UCI:firewall/redirect,@i-1/proto*/
int get_nat_port_mapping_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *proto;
dmuci_get_value_by_section_string((struct uci_section *)data, "proto", &proto);
if (strcasecmp(proto, "tcp") == 0)
*value = "TCP";
else if (strcasecmp(proto, "udp") == 0)
*value = "UDP";
else
*value = "TCP/UDP";
return 0;
return 0;
}
int set_nat_port_mapping_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *v;
switch (action) {
case VALUECHECK:
if (strcasecmp("TCP", value) != 0 && strcasecmp("UDP", value) != 0 && strcasecmp("TCP/UDP", value) != 0)
return FAULT_9007;
return 0;
case VALUESET:
if (strcasecmp("TCP", value) == 0)
v = "tcp";
else if (strcasecmp("UDP", value) == 0)
v = "udp";
else
v = "tcpudp";
dmuci_set_value_by_section((struct uci_section *)data, "proto", v);
return 0;
}
return 0;
}
/*#Device.NAT.PortMapping.{i}.InternalClient!UCI:firewall/redirect,@i-1/dest_ip*/
int get_nat_port_mapping_internal_client(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "dest_ip", value);
return 0;
}
int set_nat_port_mapping_internal_client(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "dest_ip", value);
return 0;
}
return 0;
}
/*#Device.NAT.PortMapping.{i}.Description!UCI:firewall/redirect,@i-1/name*/
int get_nat_port_mapping_description(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "name", value);
return 0;
}
int set_nat_port_mapping_description(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "name", value);
return 0;
}
return 0;
}
/*************************************************************
* ENTRY METHOD
/*************************************************************/
/*#Device.NAT.InterfaceSetting.{i}.!UCI:firewall/zone/dmmap_firewall*/
int browseInterfaceSettingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *nati, *nati_last = NULL;
struct dmmap_dup *p;
LIST_HEAD(dup_list);
synchronize_specific_config_sections_with_dmmap("firewall", "zone", "dmmap_firewall", &dup_list);
list_for_each_entry(p, &dup_list, list) {
nati = handle_update_instance(1, dmctx, &nati_last, update_instance_alias, 3, p->dmmap_section, "interface_setting_instance", "interface_setting_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p->config_section, nati) == DM_STOP)
break;
}
free_dmmap_config_dup_list(&dup_list);
return 0;
}
/*#Device.NAT.PortMapping.{i}.!UCI:firewall/redirect/dmmap_firewall*/
int browsePortMappingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *natp, *natp_last = NULL, *target;
struct dmmap_dup *p;
LIST_HEAD(dup_list);
synchronize_specific_config_sections_with_dmmap("firewall", "redirect", "dmmap_firewall", &dup_list);
list_for_each_entry(p, &dup_list, list) {
dmuci_get_value_by_section_string(p->config_section, "target", &target);
if (*target != '\0' && strcmp(target, "DNAT") != 0)
continue;
natp = handle_update_instance(1, dmctx, &natp_last, update_instance_alias, 3, p->dmmap_section, "port_mapping_instance", "port_mapping_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p->config_section, natp) == DM_STOP)
break;
}
free_dmmap_config_dup_list(&dup_list);
return 0;
}

66
dmtree/tr181/nat.h Normal file
View file

@ -0,0 +1,66 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
* Author: Imen BHIRI <imen.bhiri@pivasoftware.com>
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*
*/
#ifndef __NAT_H
#define __NAT_H
extern DMOBJ tNATObj[];
extern DMLEAF tNATParams[];
extern DMLEAF tNATInterfaceSettingParams[];
extern DMLEAF tNATPortMappingParams[];
int browseInterfaceSettingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browsePortMappingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int add_NAT_InterfaceSetting(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delete_NAT_InterfaceSetting(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_NAT_PortMapping(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delete_NAT_PortMapping(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_nat_interface_setting_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_nat_port_mapping_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_nat_interface_setting_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_nat_interface_setting_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_nat_interface_setting_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_nat_interface_setting_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_nat_interface_setting_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_nat_interface_setting_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_nat_interface_setting_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_nat_port_mapping_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_nat_port_mapping_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_nat_port_mapping_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_nat_port_mapping_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_nat_port_mapping_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_nat_port_mapping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_nat_port_mapping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_nat_port_mapping_all_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_nat_port_mapping_all_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_nat_port_mapping_lease_duration(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_nat_port_mapping_lease_duration(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_nat_port_mapping_remote_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_nat_port_mapping_remote_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_nat_port_mapping_external_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_nat_port_mapping_external_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_nat_port_mapping_external_port_end_range(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_nat_port_mapping_external_port_end_range(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_nat_port_mapping_internal_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_nat_port_mapping_internal_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_nat_port_mapping_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_nat_port_mapping_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_nat_port_mapping_internal_client(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_nat_port_mapping_internal_client(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_nat_port_mapping_description(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_nat_port_mapping_description(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

600
dmtree/tr181/ppp.c Normal file
View file

@ -0,0 +1,600 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2016 Inteno Broadband Technology AB
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
*
*/
#include <uci.h>
#include <stdio.h>
#include <ctype.h>
#include "dmuci.h"
#include "dmubus.h"
#include "dmcwmp.h"
#include "dmjson.h"
#include "dmcommon.h"
#include "dmentry.h"
#include "ppp.h"
/* *** Device.PPP. *** */
DMOBJ tPPPObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{"Interface", &DMWRITE, add_ppp_interface, delete_ppp_interface, NULL, browseInterfaceInst, NULL, NULL, tPPPInterfaceObj, tPPPInterfaceParams, get_linker_ppp_interface, BBFDM_BOTH},
{0}
};
DMLEAF tPPPParams[] = {
/* PARAM, permission, type, getvlue, setvalue, forced_inform, notification*/
{"InterfaceNumberOfEntries", &DMREAD, DMT_UNINT, get_PPP_InterfaceNumberOfEntries, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/* *** Device.PPP.Interface.{i}. *** */
DMOBJ tPPPInterfaceObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{"PPPoE", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tPPPInterfacePPPoEParams, NULL, BBFDM_BOTH},
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tPPPInterfaceStatsParams, NULL, BBFDM_BOTH},
{0}
};
DMLEAF tPPPInterfaceParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Alias", &DMWRITE, DMT_STRING, get_ppp_alias, set_ppp_alias, NULL, NULL, BBFDM_BOTH},
{"Enable", &DMWRITE, DMT_BOOL, get_ppp_enable, set_ppp_enable, NULL, NULL, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_PPPInterface_Status, NULL, NULL, NULL, BBFDM_BOTH},
{"LastChange", &DMREAD, DMT_UNINT, get_PPPInterface_LastChange, NULL, NULL, NULL, BBFDM_BOTH},
{"Reset", &DMWRITE, DMT_BOOL, get_PPPInterface_Reset, set_PPPInterface_Reset, NULL, NULL, BBFDM_BOTH},
{"Name", &DMREAD, DMT_STRING, get_ppp_name, NULL, NULL, NULL, BBFDM_BOTH},
{"LowerLayers", &DMWRITE, DMT_STRING, get_ppp_lower_layer, set_ppp_lower_layer, NULL, NULL, BBFDM_BOTH},
{"ConnectionStatus", &DMREAD, DMT_STRING, get_ppp_status, NULL, NULL, NULL, BBFDM_BOTH},
{"Username", &DMWRITE, DMT_STRING, get_ppp_username, set_ppp_username, NULL, NULL, BBFDM_BOTH},
{"Password", &DMWRITE, DMT_STRING, get_empty, set_ppp_password, NULL, NULL, BBFDM_BOTH},
{0}
};
/* *** Device.PPP.Interface.{i}.PPPoE. *** */
DMLEAF tPPPInterfacePPPoEParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"SessionID", &DMREAD, DMT_UNINT, get_PPPInterfacePPPoE_SessionID, NULL, NULL, NULL, BBFDM_BOTH},
{"ACName", &DMWRITE, DMT_STRING, get_PPPInterfacePPPoE_ACName, set_PPPInterfacePPPoE_ACName, NULL, NULL, BBFDM_BOTH},
{"ServiceName", &DMWRITE, DMT_STRING, get_PPPInterfacePPPoE_ServiceName, set_PPPInterfacePPPoE_ServiceName, NULL, NULL, BBFDM_BOTH},
{0}
};
/* *** Device.PPP.Interface.{i}.Stats. *** */
DMLEAF tPPPInterfaceStatsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"BytesReceived", &DMREAD, DMT_UNINT, get_ppp_eth_bytes_received, NULL, NULL, NULL, BBFDM_BOTH},
{"BytesSent", &DMREAD, DMT_UNINT, get_ppp_eth_bytes_sent, NULL, NULL, NULL, BBFDM_BOTH},
{"PacketsReceived", &DMREAD, DMT_UNINT, get_ppp_eth_pack_received, NULL, NULL, NULL, BBFDM_BOTH},
{"PacketsSent", &DMREAD, DMT_UNINT, get_ppp_eth_pack_sent, NULL, NULL, NULL, BBFDM_BOTH},
{"ErrorsSent", &DMREAD, DMT_UNINT, get_PPPInterfaceStats_ErrorsSent, NULL, NULL, NULL, BBFDM_BOTH},
{"ErrorsReceived", &DMREAD, DMT_UNINT, get_PPPInterfaceStats_ErrorsReceived, NULL, NULL, NULL, BBFDM_BOTH},
{"UnicastPacketsSent", &DMREAD, DMT_UNINT, get_PPPInterfaceStats_UnicastPacketsSent, NULL, NULL, NULL, BBFDM_BOTH},
{"UnicastPacketsReceived", &DMREAD, DMT_UNINT, get_PPPInterfaceStats_UnicastPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH},
{"DiscardPacketsSent", &DMREAD, DMT_UNINT, get_PPPInterfaceStats_DiscardPacketsSent, NULL, NULL, NULL, BBFDM_BOTH},
{"DiscardPacketsReceived", &DMREAD, DMT_UNINT, get_PPPInterfaceStats_DiscardPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH},
{"MulticastPacketsSent", &DMREAD, DMT_UNINT, get_PPPInterfaceStats_MulticastPacketsSent, NULL, NULL, NULL, BBFDM_BOTH},
{"MulticastPacketsReceived", &DMREAD, DMT_UNINT, get_PPPInterfaceStats_MulticastPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH},
{"BroadcastPacketsSent", &DMREAD, DMT_UNINT, get_PPPInterfaceStats_BroadcastPacketsSent, NULL, NULL, NULL, BBFDM_BOTH},
{"BroadcastPacketsReceived", &DMREAD, DMT_UNINT, get_PPPInterfaceStats_BroadcastPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH},
{"UnknownProtoPacketsReceived", &DMREAD, DMT_UNINT, get_PPPInterfaceStats_UnknownProtoPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/*************************************************************
* GET SET ALIAS
/*************************************************************/
int get_ppp_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name((struct uci_section *)data), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "ppp_int_alias", value);
return 0;
}
int set_ppp_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name((struct uci_section *)data), &dmmap_section);
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(dmmap_section, "ppp_int_alias", value);
return 0;
}
return 0;
}
/**************************************************************************
* GET & SET PARAMETERS
***************************************************************************/
/*#Device.PPP.Interface.{i}.Enable!UBUS:network.interface/status/interface,@Name/up*/
int get_ppp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return get_interface_enable_ubus(section_name(((struct uci_section *)data)), refparam, ctx, value);
}
int set_ppp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
return set_interface_enable_ubus(section_name(((struct uci_section *)data)), refparam, ctx, action, value);
}
/*#Device.PPP.Interface.{i}.Status!UBUS:network.interface/status/interface,@Name/up*/
int get_PPPInterface_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *status;
get_interface_enable_ubus(section_name(((struct uci_section *)data)), refparam, ctx, &status);
if(strcmp(status, "true") == 0)
*value= "Up";
else
*value= "Down";
return 0;
}
/*#Device.PPP.Interface.{i}.LastChange!UBUS:network.interface/status/interface,@Name/uptime*/
int get_PPPInterface_LastChange(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name((struct uci_section *)data), String}}, 1, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 1, "uptime");
return 0;
}
int get_PPPInterface_Reset(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "false";
return 0;
}
int set_PPPInterface_Reset(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
unsigned char b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
break;
case VALUESET:
string_to_bool(value, &b);
if(b) {
set_interface_enable_ubus(section_name((struct uci_section *)data), refparam, ctx, action, "0");
set_interface_enable_ubus(section_name((struct uci_section *)data), refparam, ctx, action, "1");
}
break;
}
return 0;
}
int get_ppp_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmstrdup(section_name(((struct uci_section *)data)));
return 0;
}
/*#Device.PPP.Interface.{i}.ConnectionStatus!UBUS:network.interface/status/interface,@Name/up*/
int get_ppp_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *status = NULL;
char *uptime = NULL;
char *pending = NULL;
json_object *res = NULL, *jobj = NULL;
bool bstatus = false, bpend = false;
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(((struct uci_section *)data)), String}}, 1, &res);
DM_ASSERT(res, *value = "");
jobj = dmjson_get_obj(res, 1, "up");
if(jobj)
{
status = dmjson_get_value(res, 1, "up");
string_to_bool(status, &bstatus);
if (bstatus) {
uptime = dmjson_get_value(res, 1, "uptime");
pending = dmjson_get_value(res, 1, "pending");
string_to_bool(pending, &bpend);
}
}
if (uptime && atoi(uptime) > 0)
*value = "Connected";
else if (pending && bpend)
*value = "Pending Disconnect";
else
*value = "Disconnected";
return 0;
}
/*#Device.PPP.Interface.{i}.Username!UCI:network/interface,@i-1/username*/
int get_ppp_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(((struct uci_section *)data), "username", value);
return 0;
}
int set_ppp_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(((struct uci_section *)data), "username", value);
return 0;
}
return 0;
}
/*#Device.PPP.Interface.{i}.Password!UCI:network/interface,@i-1/password*/
int set_ppp_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(((struct uci_section *)data), "password", value);
return 0;
}
return 0;
}
inline int ubus_get_wan_stats(void *data, char *instance, json_object *res, char **value, char *stat_mod)
{
char *ifname, *proto;
dmuci_get_value_by_section_string(((struct uci_section *)data), "ifname", &ifname);
dmuci_get_value_by_section_string(((struct uci_section *)data), "proto", &proto);
if (strcmp(proto, "pppoe") == 0) {
dmubus_call("network.device", "status", UBUS_ARGS{{"name", ifname, String}}, 1, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 2, "statistics", stat_mod);
}
return 0;
}
/*#Device.PPP.Interface.{i}.Stats.BytesReceived!UBUS:network.device/status/name,@Name/statistics.rx_bytes*/
int get_ppp_eth_bytes_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
ubus_get_wan_stats(data, instance, res, value, "rx_bytes");
return 0;
}
/*#Device.PPP.Interface.{i}.Stats.BytesSent!UBUS:network.device/status/name,@Name/statistics.tx_bytes*/
int get_ppp_eth_bytes_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
ubus_get_wan_stats(data, instance, res, value, "tx_bytes");
return 0;
}
/*#Device.PPP.Interface.{i}.Stats.PacketsReceived!UBUS:network.device/status/name,@Name/statistics.rx_packets*/
int get_ppp_eth_pack_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
ubus_get_wan_stats(data, instance, res, value, "rx_packets");
return 0;
}
/*#Device.PPP.Interface.{i}.Stats.PacketsSent!UBUS:network.device/status/name,@Name/statistics.tx_packets*/
int get_ppp_eth_pack_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
ubus_get_wan_stats(data, instance, res, value, "tx_packets");
return 0;
}
/*#Device.PPP.Interface.{i}.Stats.ErrorsSent!UBUS:network.device/status/name,@Name/statistics.tx_errors*/
int get_PPPInterfaceStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
ubus_get_wan_stats(data, instance, res, value, "tx_errors");
return 0;
}
/*#Device.PPP.Interface.{i}.Stats.ErrorsReceived!UBUS:network.device/status/name,@Name/statistics.rx_errors*/
int get_PPPInterfaceStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
ubus_get_wan_stats(data, instance, res, value, "rx_errors");
return 0;
}
int get_PPPInterfaceStats_UnicastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "0";
char *device = get_device(section_name((struct uci_section *)data));
if(device[0] != '\0')
dmasprintf(value, "%d", get_stats_from_ifconfig_command(device, "TX", "unicast"));
return 0;
}
int get_PPPInterfaceStats_UnicastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "0";
char *device = get_device(section_name((struct uci_section *)data));
if(device[0] != '\0')
dmasprintf(value, "%d", get_stats_from_ifconfig_command(device, "RX", "unicast"));
return 0;
}
/*#Device.PPP.Interface.{i}.Stats.DiscardPacketsSent!UBUS:network.device/status/name,@Name/statistics.tx_dropped*/
int get_PPPInterfaceStats_DiscardPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
ubus_get_wan_stats(data, instance, res, value, "tx_dropped");
return 0;
}
/*#Device.PPP.Interface.{i}.Stats.DiscardPacketsReceived!UBUS:network.device/status/name,@Name/statistics.rx_dropped*/
int get_PPPInterfaceStats_DiscardPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
ubus_get_wan_stats(data, instance, res, value, "rx_dropped");
return 0;
}
int get_PPPInterfaceStats_MulticastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "0";
char *device = get_device(section_name((struct uci_section *)data));
if(device[0] != '\0')
dmasprintf(value, "%d", get_stats_from_ifconfig_command(device, "TX", "multicast"));
return 0;
}
int get_PPPInterfaceStats_MulticastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "0";
char *device = get_device(section_name((struct uci_section *)data));
if(device[0] != '\0')
dmasprintf(value, "%d", get_stats_from_ifconfig_command(device, "RX", "multicast"));
return 0;
}
int get_PPPInterfaceStats_BroadcastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "0";
char *device = get_device(section_name((struct uci_section *)data));
if(device[0] != '\0')
dmasprintf(value, "%d", get_stats_from_ifconfig_command(device, "TX", "broadcast"));
return 0;
}
int get_PPPInterfaceStats_BroadcastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "0";
char *device = get_device(section_name((struct uci_section *)data));
if(device[0] != '\0')
dmasprintf(value, "%d", get_stats_from_ifconfig_command(device, "RX", "broadcast"));
return 0;
}
/*#Device.PPP.Interface.{i}.Stats.UnknownProtoPacketsReceived!UBUS:network.device/status/name,@Name/statistics.rx_over_errors*/
int get_PPPInterfaceStats_UnknownProtoPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
ubus_get_wan_stats(data, instance, res, value, "rx_over_errors");
return 0;
}
int get_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *linker;
dmuci_get_value_by_section_string(((struct uci_section *)data), "ifname", &linker);
adm_entry_get_linker_param(ctx, dm_print_path("%s%cATM%cLink%c", dmroot, dm_delim, dm_delim, dm_delim), linker, value);
if (*value == NULL) {
adm_entry_get_linker_param(ctx, dm_print_path("%s%cPTM%cLink%c", dmroot, dm_delim, dm_delim, dm_delim), linker, value);
}
if (*value == NULL) {
adm_entry_get_linker_param(ctx, dm_print_path("%s%cEthernet%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), linker, value);
}
if (*value == NULL) {
adm_entry_get_linker_param(ctx, dm_print_path("%s%cWiFi%cSSID%c", dmroot, dm_delim, dm_delim, dm_delim), linker, value);
}
if (*value == NULL)
*value = "";
return 0;
}
int set_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *linker;
char *newvalue= NULL;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
if (value[strlen(value)-1]!='.') {
dmasprintf(&newvalue, "%s.", value);
adm_entry_get_linker_value(ctx, newvalue, &linker);
} else
adm_entry_get_linker_value(ctx, value, &linker);
if(linker) dmuci_set_value_by_section(((struct uci_section *)data), "ifname", linker);
else return FAULT_9005;
return 0;
}
return 0;
}
int get_PPP_InterfaceNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *s;
char *proto;
int nbre= 0;
uci_foreach_sections("network", "interface", s) {
dmuci_get_value_by_section_string(s, "proto", &proto);
if (!strstr(proto, "ppp"))
continue;
nbre++;
}
dmasprintf(value, "%d", nbre);
return 0;
}
int get_PPPInterfacePPPoE_SessionID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
//TODO
return 0;
}
/*#Device.PPP.Interface.{i}.PPPoE.ACName!UCI:network/interface,@i-1/ac*/
int get_PPPInterfacePPPoE_ACName(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *proto;
dmuci_get_value_by_section_string(((struct uci_section *)data), "proto", &proto);
if (strcmp(proto, "pppoe") == 0) {
dmuci_get_value_by_section_string(((struct uci_section *)data), "ac", value);
return 0;
}
*value= "";
return 0;
}
int set_PPPInterfacePPPoE_ACName(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *proto;
switch (action) {
case VALUECHECK:
dmuci_get_value_by_section_string(((struct uci_section *)data), "proto", &proto);
if (strcmp(proto, "pppoe") != 0)
return FAULT_9001;
break;
case VALUESET:
dmuci_set_value_by_section(((struct uci_section *)data), "ac", value);
break;
}
return 0;
}
/*#Device.PPP.Interface.{i}.PPPoE.ServiceName!UCI:network/interface,@i-1/service*/
int get_PPPInterfacePPPoE_ServiceName(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *proto;
dmuci_get_value_by_section_string(((struct uci_section *)data), "proto", &proto);
if (strcmp(proto, "pppoe") == 0) {
dmuci_get_value_by_section_string(((struct uci_section *)data), "service", value);
return 0;
}
*value= "";
return 0;
}
int set_PPPInterfacePPPoE_ServiceName(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *proto;
switch (action) {
case VALUECHECK:
dmuci_get_value_by_section_string(((struct uci_section *)data), "proto", &proto);
if (strcmp(proto, "pppoe") != 0)
return FAULT_9001;
break;
case VALUESET:
dmuci_set_value_by_section(((struct uci_section *)data), "service", value);
break;
}
return 0;
}
/**************************************************************************
* LINKER
***************************************************************************/
int get_linker_ppp_interface(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) {
if(((struct uci_section *)data)) {
dmasprintf(linker,"%s", section_name(((struct uci_section *)data)));
return 0;
}
*linker = "";
return 0;
}
/*************************************************************
* ADD DEL OBJ
/*************************************************************/
int add_ppp_interface(char *refparam, struct dmctx *ctx, void *data, char **instance)
{
char name[16] = {0};
char *inst, *v;
struct uci_section *s = NULL;
struct uci_section *dmmap_ppp = NULL;
check_create_dmmap_package("dmmap_network");
inst = get_last_instance_lev2_icwmpd("network", "interface", "dmmap_network", "ppp_int_instance", "proto", "ppp");
sprintf(name, "ppp_%d", inst ? (atoi(inst)+1) : 1);
dmuci_set_value("network", name, "", "interface");
dmuci_set_value("network", name, "proto", "ppp");
dmuci_set_value("network", name, "username", name);
dmuci_set_value("network", name, "password", name);
dmuci_add_section_icwmpd("dmmap_network", "interface", &dmmap_ppp, &v);
dmuci_set_value_by_section(dmmap_ppp, "section_name", name);
*instance = update_instance_icwmpd(dmmap_ppp, inst, "ppp_int_instance");
return 0;
}
int delete_ppp_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
int found = 0;
struct uci_section *ppp_s = NULL;
struct uci_section *ss = NULL, *dmmap_section = NULL;
switch (del_action) {
case DEL_INST:
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct uci_section *)data)), &dmmap_section);
if(dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(((struct uci_section *)data), NULL, NULL);
break;
case DEL_ALL:
uci_foreach_option_eq("network", "interface", "proto", "ppp", ppp_s) {
if (found != 0) {
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(ss), &dmmap_section);
if(dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
ss = ppp_s;
found++;
}
if (ss != NULL) {
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(ss), &dmmap_section);
if(dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
return 0;
}
return 0;
}
/*************************************************************
* ENTRY METHOD
/*************************************************************/
/*#Device.PPP.Interface.{i}.!UCI:network/interface/dmmap_network*/
int browseInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
struct uci_section *net_sec = NULL;
char *ppp_int = NULL, *ppp_int_last = NULL;
char *proto;
struct dmmap_dup *p;
LIST_HEAD(dup_list);
synchronize_specific_config_sections_with_dmmap("network", "interface", "dmmap_network", &dup_list);
list_for_each_entry(p, &dup_list, list) {
dmuci_get_value_by_section_string(p->config_section, "proto", &proto);
if (!strstr(proto, "ppp"))
continue;
ppp_int = handle_update_instance(1, dmctx, &ppp_int_last, update_instance_alias, 3, p->dmmap_section, "ppp_int_instance", "ppp_int_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p->config_section, ppp_int) == DM_STOP)
break;
}
free_dmmap_config_dup_list(&dup_list);
return 0;
}

68
dmtree/tr181/ppp.h Normal file
View file

@ -0,0 +1,68 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2016 Inteno Broadband Technology AB
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
*
*/
#ifndef __PPP_H
#define __PPP_H
extern DMOBJ tPPPObj[];
extern DMLEAF tPPPParams[];
extern DMOBJ tPPPInterfaceObj[];
extern DMLEAF tPPPInterfaceParams[];
extern DMLEAF tPPPInterfacePPPoEParams[];
extern DMLEAF tPPPInterfaceStatsParams[];
int browseInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int get_ppp_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ppp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ppp_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ppp_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ppp_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ppp_eth_bytes_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ppp_eth_bytes_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ppp_eth_pack_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ppp_eth_pack_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_PPPInterfaceStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_PPPInterfaceStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_PPPInterfaceStats_UnicastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_PPPInterfaceStats_UnicastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_PPPInterfaceStats_DiscardPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_PPPInterfaceStats_DiscardPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_PPPInterfaceStats_MulticastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_PPPInterfaceStats_MulticastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_PPPInterfaceStats_BroadcastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_PPPInterfaceStats_BroadcastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_PPPInterfaceStats_UnknownProtoPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_ppp_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ppp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ppp_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ppp_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_linker_ppp_interface(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
int get_PPP_InterfaceNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_PPPInterface_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_PPPInterface_LastChange(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_PPPInterface_Reset(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_PPPInterface_Reset(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int add_ppp_interface(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delete_ppp_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_PPPInterfacePPPoE_SessionID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_PPPInterfacePPPoE_ACName(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_PPPInterfacePPPoE_ACName(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_PPPInterfacePPPoE_ServiceName(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_PPPInterfacePPPoE_ServiceName(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

272
dmtree/tr181/ptm.c Normal file
View file

@ -0,0 +1,272 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2016 PIVA SOFTWARE (www.pivasoftware.com)
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
*
*/
#include <ctype.h>
#include <uci.h>
#include "dmcwmp.h"
#include "dmuci.h"
#include "dmubus.h"
#include "dmcommon.h"
#include "ptm.h"
#include "dmjson.h"
#include "dmentry.h"
/* *** Device.PTM. *** */
DMOBJ tPTMObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{"Link", &DMWRITE, add_ptm_link, delete_ptm_link, NULL, browsePtmLinkInst, NULL, NULL, tPTMLinkObj, tPTMLinkParams, get_ptm_linker, BBFDM_BOTH},
{0}
};
/* *** Device.PTM.Link.{i}. *** */
DMOBJ tPTMLinkObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tPTMLinkStatsParams, NULL, BBFDM_BOTH},
{0}
};
DMLEAF tPTMLinkParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Alias", &DMWRITE, DMT_STRING, get_ptm_alias, set_ptm_alias, NULL, NULL, BBFDM_BOTH},
{"Enable", &DMREAD, DMT_BOOL, get_ptm_enable, NULL, NULL, NULL, BBFDM_BOTH},
{"Name", &DMREAD, DMT_STRING, get_ptm_link_name, NULL, NULL, NULL, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_ptm_enable, NULL, NULL, NULL, BBFDM_BOTH},
{"LowerLayers", &DMREAD, DMT_STRING, get_ptm_lower_layer, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/* *** Device.PTM.Link.{i}.Stats. *** */
DMLEAF tPTMLinkStatsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"BytesSent", &DMREAD, DMT_UNINT, get_ptm_stats_bytes_sent, NULL, NULL, NULL, BBFDM_BOTH},
{"BytesReceived", &DMREAD, DMT_UNINT, get_ptm_stats_bytes_received, NULL, NULL, NULL, BBFDM_BOTH},
{"PacketsSent", &DMREAD, DMT_UNINT, get_ptm_stats_pack_sent, NULL, NULL, NULL, BBFDM_BOTH},
{"PacketsReceived", &DMREAD, DMT_UNINT, get_ptm_stats_pack_received, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/**************************************************************************
* LINKER
***************************************************************************/
int get_ptm_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) {
if (data && ((struct ptm_args *)data)->ifname){
*linker = ((struct ptm_args *)data)->ifname;
return 0;
}
*linker = "" ;
return 0;
}
/**************************************************************************
* INIT
***************************************************************************/
inline int init_ptm_link(struct ptm_args *args, struct uci_section *s, char *ifname)
{
args->ptm_sec = s;
args->ifname = ifname;
return 0;
}
/**************************************************************************
* SET & GET DSL LINK PARAMETERS
***************************************************************************/
/*#Device.PTM.Link.{i}.Name!UCI:dsl/ptm-device,@i-1/name*/
int get_ptm_link_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(((struct ptm_args *)data)->ptm_sec, "name", value);
return 0;
}
int get_ptm_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char linker[16];
sprintf(linker, "channel_%d", atoi(instance)-1);
adm_entry_get_linker_param(ctx, dm_print_path("%s%cDSL%cChannel%c", dmroot, dm_delim, dm_delim, dm_delim), linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
if (*value == NULL)
*value = "";
return 0;
}
inline int ubus_ptm_stats(json_object *res, char **value, char *stat_mod, void *data)
{
dmubus_call("network.device", "status", UBUS_ARGS{{"name", ((struct ptm_args *)data)->ifname, String}}, 1, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 2, "statistics", stat_mod);
return 0;
}
/*#Device.PTM.Link.{i}.Stats.BytesReceived!UBUS:network.device/status/name,@Name/statistics.rx_bytes*/
int get_ptm_stats_bytes_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
ubus_ptm_stats(res, value, "rx_bytes", data);
return 0;
}
/*#Device.PTM.Link.{i}.Stats.BytesSent!UBUS:network.device/status/name,@Name/statistics.tx_bytes*/
int get_ptm_stats_bytes_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
ubus_ptm_stats(res, value, "tx_bytes", data);
return 0;
}
/*#Device.PTM.Link.{i}.Stats.PacketsReceived!UBUS:network.device/status/name,@Name/statistics.rx_packets*/
int get_ptm_stats_pack_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
ubus_ptm_stats(res, value, "rx_packets", data);
return 0;
}
/*#Device.PTM.Link.{i}.Stats.PacketsSent!UBUS:network.device/status/name,@Name/statistics.tx_packets*/
int get_ptm_stats_pack_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
ubus_ptm_stats(res, value, "tx_packets", data);
return 0;
}
int get_ptm_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "true";
return 0;
}
/*************************************************************
* ADD OBJ
/*************************************************************/
int add_ptm_link(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
{
char *instance = NULL, *ptm_device = NULL, *v = NULL, *instance_update = NULL;
struct uci_section *dmmap_ptm = NULL;
check_create_dmmap_package("dmmap_dsl");
instance = get_last_instance_icwmpd("dmmap_dsl", "ptm-device", "ptmlinkinstance");
dmasprintf(&ptm_device, "ptm%d", instance ? atoi(instance) : 0);
dmasprintf(&instance_update, "%d", instance ? atoi(instance)+ 1 : 1);
dmuci_set_value("dsl", ptm_device, "", "ptm-device");
dmuci_set_value("dsl", ptm_device, "name", "PTM");
dmuci_set_value("dsl", ptm_device, "device", ptm_device);
dmuci_set_value("dsl", ptm_device, "priority", "1");
dmuci_set_value("dsl", ptm_device, "portid", "1");
dmuci_add_section_icwmpd("dmmap_dsl", "ptm-device", &dmmap_ptm, &v);
dmuci_set_value_by_section(dmmap_ptm, "section_name", ptm_device);
*instancepara = update_instance_icwmpd(dmmap_ptm, instance, "ptmlinkinstance");
return 0;
}
int delete_ptm_link(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
char *ifname;
struct uci_section *s = NULL, *ss = NULL, *ns = NULL, *nss = NULL, *dmmap_section= NULL;
switch (del_action) {
case DEL_INST:
get_dmmap_section_of_config_section("dmmap_dsl", "ptm-device", section_name(((struct ptm_args *)data)->ptm_sec), &dmmap_section);
if(dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(((struct ptm_args *)data)->ptm_sec, NULL, NULL);
uci_foreach_option_cont("network", "interface", "ifname", ((struct ptm_args *)data)->ifname, s) {
if (ss && ifname!=NULL)
wan_remove_dev_interface(ss, ((struct ptm_args *)data)->ifname);
ss = s;
}
if (ss != NULL && ifname!=NULL)
wan_remove_dev_interface(ss, ((struct ptm_args *)data)->ifname);
break;
case DEL_ALL:
uci_foreach_sections("dsl", "ptm-device", s) {
if (ss){
get_dmmap_section_of_config_section("dmmap_dsl", "ptm-device", section_name(ss), &dmmap_section);
if(dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_get_value_by_section_string(ss, "device", &ifname);
dmuci_delete_by_section(ss, NULL, NULL);
uci_foreach_option_cont("network", "interface", "ifname", ifname, ns) {
if (nss)
wan_remove_dev_interface(nss, ifname);
nss = ns;
}
if (nss != NULL && ifname!=NULL)
wan_remove_dev_interface(nss, ifname);
}
ss = s;
}
if (ss != NULL) {
get_dmmap_section_of_config_section("dmmap_dsl", "ptm-device", section_name(ss), &dmmap_section);
if(dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_get_value_by_section_string(ss, "device", &ifname);
dmuci_delete_by_section(ss, NULL, NULL);
uci_foreach_option_cont("network", "interface", "ifname", ifname, ns) {
if (nss && ifname!=NULL)
wan_remove_dev_interface(nss, ifname);
nss = ns;
}
if (nss != NULL && ifname!=NULL)
wan_remove_dev_interface(nss, ifname);
}
break;
}
return 0;
}
/*************************************************************
* SET AND GET ALIAS
/*************************************************************/
int get_ptm_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
get_dmmap_section_of_config_section("dmmap_dsl", "ptm-device", section_name(((struct ptm_args *)data)->ptm_sec), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "ptmlinkalias", value);
return 0;
}
int set_ptm_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_dsl", "ptm-device", section_name(((struct ptm_args *)data)->ptm_sec), &dmmap_section);
dmuci_set_value_by_section(dmmap_section, "ptmlinkalias", value);
return 0;
}
return 0;
}
/*************************************************************
* ENTRY METHOD
/*************************************************************/
/*#Device.PTM.Link.{i}.!UCI:dsl/ptm-device/dmmap_dsl*/
int browsePtmLinkInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *wnum = NULL, *channel_last = NULL, *ifname;
struct ptm_args curr_ptm_args = {0};
struct dmmap_dup *p;
LIST_HEAD(dup_list);
synchronize_specific_config_sections_with_dmmap("dsl", "ptm-device", "dmmap_dsl", &dup_list);
list_for_each_entry(p, &dup_list, list) {
dmuci_get_value_by_section_string(p->config_section, "device", &ifname);
init_ptm_link(&curr_ptm_args, p->config_section, ifname);
wnum = handle_update_instance(1, dmctx, &channel_last, update_instance_alias, 3, p->dmmap_section, "ptmlinkinstance", "ptmlinkalias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_ptm_args, wnum) == DM_STOP)
break;
}
free_dmmap_config_dup_list(&dup_list);
return 0;
}

43
dmtree/tr181/ptm.h Normal file
View file

@ -0,0 +1,43 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2016 Inteno Broadband Technology AB
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
*
*/
#ifndef __PTM_H
#define __PTM_H
struct ptm_args
{
struct uci_section *ptm_sec;
char *ifname;
};
extern DMOBJ tPTMObj[];
extern DMOBJ tPTMLinkObj[];
extern DMLEAF tPTMLinkStatsParams[];
extern DMLEAF tPTMLinkParams[];
int browsePtmLinkInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int add_ptm_link(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_ptm_link(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_ptm_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ptm_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ptm_link_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ptm_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ptm_stats_bytes_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ptm_stats_bytes_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ptm_stats_pack_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ptm_stats_pack_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_ptm_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_ptm_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
#endif

3709
dmtree/tr181/qos.c Normal file

File diff suppressed because it is too large Load diff

403
dmtree/tr181/qos.h Normal file
View file

@ -0,0 +1,403 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
* Author: Omar Kallel <omar.kallel@pivasoftware.com>
*/
#ifndef __QOS_H
#define __QOS_H
extern DMOBJ tQoSObj[];
extern DMLEAF tQoSParams[];
extern DMLEAF tQoSClassificationParams[];
extern DMLEAF tQoSAppParams[];
extern DMLEAF tQoSFlowParams[];
extern DMLEAF tQoSPolicerParams[];
extern DMLEAF tQoSQueueParams[];
extern DMLEAF tQoSQueueStatsParams[];
extern DMLEAF tQoSShaperParams[];
#define queuessts1 "^qdisc noqueue [0-9]*: dev [[:alnum:]]* [[:alnum:]]* refcnt [0-9]*"
#define queuessts2 "^qdisc pfifo_fast [0-9]*: dev [[:alnum:]]* [[:alnum:]]* refcnt [0-9]*"
//#define queuessts3 "^[ ]*Sent [0-9]* bytes [0-9]* pkt (dropped [0-9]*, overlimits [0-9]* requeues [0-9]*)"
//#define queuessts4 "^[ ]*backlog [0-9]*b [0-9]*p requeues [0-9]*"
struct queuestats {
struct uci_section *dmsect;
char dev[50];
char user[50];
char priomap[50];
int noqueue;
int pfifo_fast;
int refcnt;
int bands;
int bytes_sent;
int pkt_sent;
int pkt_dropped;
int pkt_overlimits;
int pkt_requeues;
int backlog_b;
int backlog_p;
int backlog_requeues;
};
int get_linker_qos_queue(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
int browseQoSClassificationInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseQoSAppInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseQoSFlowInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseQoSPolicerInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseQoSQueueInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseQoSQueueStatsInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseQoSShaperInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int addObjQoSClassification(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delObjQoSClassification(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int addObjQoSApp(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delObjQoSApp(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int addObjQoSFlow(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delObjQoSFlow(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int addObjQoSPolicer(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delObjQoSPolicer(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int addObjQoSQueue(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delObjQoSQueue(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int addObjQoSQueueStats(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delObjQoSQueueStats(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int addObjQoSShaper(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delObjQoSShaper(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_QoS_MaxClassificationEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoS_ClassificationNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoS_MaxAppEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoS_AppNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoS_MaxFlowEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoS_FlowNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoS_MaxPolicerEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoS_PolicerNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoS_MaxQueueEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoS_QueueNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoS_QueueStatsNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoS_MaxShaperEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoS_ShaperNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoS_DefaultForwardingPolicy(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoS_DefaultForwardingPolicy(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoS_DefaultTrafficClass(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoS_DefaultTrafficClass(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoS_DefaultPolicer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoS_DefaultPolicer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoS_DefaultQueue(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoS_DefaultQueue(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoS_DefaultDSCPMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoS_DefaultDSCPMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoS_DefaultEthernetPriorityMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoS_DefaultEthernetPriorityMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoS_DefaultInnerEthernetPriorityMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoS_DefaultInnerEthernetPriorityMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoS_AvailableAppList(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSClassification_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSClassification_Order(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_Order(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DHCPType(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DHCPType(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_AllInterfaces(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_AllInterfaces(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DestIP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DestIP(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DestMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DestMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DestIPExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DestIPExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SourceIP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SourceIP(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SourceMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SourceMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SourceIPExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SourceIPExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_Protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_Protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_ProtocolExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_ProtocolExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DestPort(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DestPort(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DestPortRangeMax(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DestPortRangeMax(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DestPortExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DestPortExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SourcePort(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SourcePort(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SourcePortRangeMax(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SourcePortRangeMax(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SourcePortExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SourcePortExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SourceMACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SourceMACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SourceMACMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SourceMACMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SourceMACExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SourceMACExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DestMACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DestMACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DestMACMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DestMACMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DestMACExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DestMACExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_Ethertype(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_Ethertype(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_EthertypeExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_EthertypeExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SSAP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SSAP(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SSAPExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SSAPExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DSAP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DSAP(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DSAPExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DSAPExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_LLCControl(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_LLCControl(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_LLCControlExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_LLCControlExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SNAPOUI(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SNAPOUI(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SNAPOUIExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SNAPOUIExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SourceVendorClassID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SourceVendorClassID(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SourceVendorClassIDv6(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SourceVendorClassIDv6(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SourceVendorClassIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SourceVendorClassIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SourceVendorClassIDMode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SourceVendorClassIDMode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DestVendorClassID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DestVendorClassID(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DestVendorClassIDv6(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DestVendorClassIDv6(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DestVendorClassIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DestVendorClassIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DestVendorClassIDMode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DestVendorClassIDMode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SourceClientID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SourceClientID(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SourceClientIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SourceClientIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DestClientID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DestClientID(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DestClientIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DestClientIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SourceUserClassID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SourceUserClassID(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SourceUserClassIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SourceUserClassIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DestUserClassID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DestUserClassID(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DestUserClassIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DestUserClassIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SourceVendorSpecificInfo(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SourceVendorSpecificInfo(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SourceVendorSpecificInfoExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SourceVendorSpecificInfoExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SourceVendorSpecificInfoEnterprise(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SourceVendorSpecificInfoEnterprise(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_SourceVendorSpecificInfoSubOption(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_SourceVendorSpecificInfoSubOption(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DestVendorSpecificInfo(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DestVendorSpecificInfo(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DestVendorSpecificInfoExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DestVendorSpecificInfoExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DestVendorSpecificInfoEnterprise(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DestVendorSpecificInfoEnterprise(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DestVendorSpecificInfoSubOption(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DestVendorSpecificInfoSubOption(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_TCPACK(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_TCPACK(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_TCPACKExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_TCPACKExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_IPLengthMin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_IPLengthMin(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_IPLengthMax(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_IPLengthMax(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_IPLengthExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_IPLengthExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DSCPCheck(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DSCPCheck(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DSCPExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DSCPExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_DSCPMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_DSCPMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_EthernetPriorityCheck(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_EthernetPriorityCheck(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_EthernetPriorityExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_EthernetPriorityExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_EthernetPriorityMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_EthernetPriorityMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_InnerEthernetPriorityCheck(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_InnerEthernetPriorityCheck(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_InnerEthernetPriorityExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_InnerEthernetPriorityExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_InnerEthernetPriorityMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_InnerEthernetPriorityMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_EthernetDEICheck(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_EthernetDEICheck(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_EthernetDEIExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_EthernetDEIExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_VLANIDCheck(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_VLANIDCheck(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_VLANIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_VLANIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_OutOfBandInfo(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_OutOfBandInfo(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_ForwardingPolicy(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_ForwardingPolicy(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_TrafficClass(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_TrafficClass(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_Policer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_Policer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSClassification_App(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSClassification_App(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSApp_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSApp_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSApp_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSApp_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSApp_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSApp_ProtocolIdentifier(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSApp_ProtocolIdentifier(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSApp_Name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSApp_Name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSApp_DefaultForwardingPolicy(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSApp_DefaultForwardingPolicy(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSApp_DefaultTrafficClass(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSApp_DefaultTrafficClass(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSApp_DefaultPolicer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSApp_DefaultPolicer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSApp_DefaultDSCPMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSApp_DefaultDSCPMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSApp_DefaultEthernetPriorityMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSApp_DefaultEthernetPriorityMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSApp_DefaultInnerEthernetPriorityMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSApp_DefaultInnerEthernetPriorityMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSFlow_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSFlow_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSFlow_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSFlow_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSFlow_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSFlow_Type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSFlow_Type(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSFlow_TypeParameters(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSFlow_TypeParameters(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSFlow_Name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSFlow_Name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSFlow_App(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSFlow_App(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSFlow_ForwardingPolicy(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSFlow_ForwardingPolicy(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSFlow_TrafficClass(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSFlow_TrafficClass(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSFlow_Policer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSFlow_Policer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSFlow_DSCPMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSFlow_DSCPMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSFlow_EthernetPriorityMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSFlow_EthernetPriorityMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSFlow_InnerEthernetPriorityMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSFlow_InnerEthernetPriorityMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSPolicer_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSPolicer_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSPolicer_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSPolicer_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSPolicer_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSPolicer_CommittedRate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSPolicer_CommittedRate(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSPolicer_CommittedBurstSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSPolicer_CommittedBurstSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSPolicer_ExcessBurstSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSPolicer_ExcessBurstSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSPolicer_PeakRate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSPolicer_PeakRate(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSPolicer_PeakBurstSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSPolicer_PeakBurstSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSPolicer_MeterType(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSPolicer_MeterType(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSPolicer_PossibleMeterTypes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSPolicer_ConformingAction(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSPolicer_ConformingAction(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSPolicer_PartialConformingAction(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSPolicer_PartialConformingAction(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSPolicer_NonConformingAction(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSPolicer_NonConformingAction(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSPolicer_TotalCountedPackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSPolicer_TotalCountedBytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSPolicer_ConformingCountedPackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSPolicer_ConformingCountedBytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSPolicer_PartiallyConformingCountedPackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSPolicer_PartiallyConformingCountedBytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSPolicer_NonConformingCountedPackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSPolicer_NonConformingCountedBytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSQueue_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSQueue_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSQueue_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSQueue_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSQueue_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSQueue_TrafficClasses(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSQueue_TrafficClasses(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSQueue_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSQueue_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSQueue_AllInterfaces(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSQueue_AllInterfaces(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSQueue_HardwareAssisted(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSQueue_BufferLength(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSQueue_Weight(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSQueue_Weight(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSQueue_Precedence(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSQueue_Precedence(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSQueue_REDThreshold(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSQueue_REDThreshold(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSQueue_REDPercentage(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSQueue_REDPercentage(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSQueue_DropAlgorithm(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSQueue_DropAlgorithm(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSQueue_SchedulerAlgorithm(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSQueue_SchedulerAlgorithm(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSQueue_ShapingRate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSQueue_ShapingRate(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSQueue_ShapingBurstSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSQueue_ShapingBurstSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSQueueStats_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSQueueStats_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSQueueStats_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSQueueStats_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSQueueStats_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSQueueStats_Queue(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSQueueStats_Queue(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSQueueStats_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSQueueStats_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSQueueStats_OutputPackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSQueueStats_OutputBytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSQueueStats_DroppedPackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSQueueStats_DroppedBytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSQueueStats_QueueOccupancyPackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSQueueStats_QueueOccupancyPercentage(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSShaper_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSShaper_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSShaper_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_QoSShaper_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSShaper_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSShaper_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSShaper_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSShaper_ShapingRate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSShaper_ShapingRate(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_QoSShaper_ShapingBurstSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_QoSShaper_ShapingBurstSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif //__QOS_H

1403
dmtree/tr181/routing.c Normal file

File diff suppressed because it is too large Load diff

93
dmtree/tr181/routing.h Normal file
View file

@ -0,0 +1,93 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*
*/
#ifndef __ROUTING_H
#define __ROUTING_H
#define PROC_ROUTE6 "/proc/net/ipv6_route"
extern struct dm_permession_s DMRouting;
extern DMOBJ tRoutingObj[];
extern DMLEAF tRoutingParams[];
extern DMOBJ tRoutingRouterObj[];
extern DMLEAF tRoutingRouterParams[];
extern DMLEAF tRoutingRouterIPv4ForwardingParams[];
extern DMLEAF tRoutingRouterIPv6ForwardingParams[];
extern DMOBJ tRoutingRouteInformationObj[];
extern DMLEAF tRoutingRouteInformationParams[];
extern DMLEAF tRoutingRouteInformationInterfaceSettingParams[];
int browseRouterInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseIPv4ForwardingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseIPv6ForwardingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseRoutingRouteInformationInterfaceSettingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int add_ipv4forwarding(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_ipv4forwarding(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_ipv6Forwarding(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delete_ipv6Forwarding(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_router_nbr_entry(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_RoutingRouter_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_RoutingRouter_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_RoutingRouter_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_RoutingRouter_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_RoutingRouter_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_RoutingRouter_IPv4ForwardingNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_RoutingRouter_IPv6ForwardingNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_router_ipv4forwarding_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_router_ipv4forwarding_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_router_ipv4forwarding_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_router_ipv4forwarding_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_router_ipv4forwarding_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_router_ipv4forwarding_destip(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_router_ipv4forwarding_destip(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_router_ipv4forwarding_destmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_router_ipv4forwarding_destmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_router_ipv4forwarding_static_route(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_router_ipv4forwarding_forwarding_policy(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_router_ipv4forwarding_origin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_router_ipv4forwarding_gatewayip(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_router_ipv4forwarding_gatewayip(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_router_ipv4forwarding_interface_linker_parameter(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_router_ipv4forwarding_interface_linker_parameter(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_router_ipv4forwarding_metric(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_router_ipv4forwarding_metric(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_RoutingRouterIPv6Forwarding_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_RoutingRouterIPv6Forwarding_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_RoutingRouterIPv6Forwarding_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_RoutingRouterIPv6Forwarding_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_RoutingRouterIPv6Forwarding_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_RoutingRouterIPv6Forwarding_DestIPPrefix(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_RoutingRouterIPv6Forwarding_DestIPPrefix(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_RoutingRouterIPv6Forwarding_ForwardingPolicy(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_RoutingRouterIPv6Forwarding_ForwardingPolicy(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_RoutingRouterIPv6Forwarding_NextHop(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_RoutingRouterIPv6Forwarding_NextHop(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_RoutingRouterIPv6Forwarding_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_RoutingRouterIPv6Forwarding_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_RoutingRouterIPv6Forwarding_Origin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_RoutingRouterIPv6Forwarding_ForwardingMetric(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_RoutingRouterIPv6Forwarding_ForwardingMetric(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_RoutingRouterIPv6Forwarding_ExpirationTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_RoutingRouteInformation_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_RoutingRouteInformation_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_RoutingRouteInformation_InterfaceSettingNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_RoutingRouteInformationInterfaceSetting_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_RoutingRouteInformationInterfaceSetting_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_RoutingRouteInformationInterfaceSetting_SourceRouter(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_RoutingRouteInformationInterfaceSetting_RouteLifetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
#endif

View file

@ -0,0 +1,244 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2012-2014 PIVA SOFTWARE (www.pivasoftware.com)
* Author: Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author: Feten Besbes <feten.besbes@pivasoftware.com>
*/
#include <ctype.h>
#include <uci.h>
#include <stdio.h>
#include "dmcwmp.h"
#include "dmuci.h"
#include "dmubus.h"
#include "dmcommon.h"
#include "softwaremodules.h"
/* *** Device.SoftwareModules. *** */
DMOBJ tSoftwareModulesObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{"DeploymentUnit", &DMREAD, NULL, NULL, NULL, browsesoftwaremodules_deploymentunitInst, NULL, NULL, NULL, tSoftwareModulesDeploymentUnitParams, NULL, BBFDM_BOTH},
{0}
};
/* *** Device.SoftwareModules.DeploymentUnit.{i}. *** */
DMLEAF tSoftwareModulesDeploymentUnitParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"UUID", &DMREAD, DMT_STRING, get_deploymentunit_uuid, NULL, NULL, NULL, BBFDM_BOTH},
{"Name", &DMREAD, DMT_STRING, get_deploymentunit_name, NULL, NULL, NULL, BBFDM_BOTH},
{"Resolved", &DMREAD, DMT_BOOL, get_deploymentunit_resolved, NULL, NULL, NULL, BBFDM_BOTH},
{"URL", &DMREAD, DMT_STRING, get_deploymentunit_url, NULL, NULL, NULL, BBFDM_BOTH},
{"Vendor", &DMREAD, DMT_STRING, get_deploymentunit_vendor, NULL, NULL, NULL, BBFDM_BOTH},
{"Version", &DMREAD, DMT_STRING, get_deploymentunit_version, NULL, NULL, NULL, BBFDM_BOTH},
{"ExecutionEnvRef", &DMREAD, DMT_STRING, get_deploymentunit_execution_env_ref, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
int get_deploymentunit_uuid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *softsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(softsection, "uuid", value);
return 0;
}
int get_deploymentunit_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *softsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(softsection, "name", value);
return 0;
}
int get_deploymentunit_resolved(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *softsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(softsection, "resolved", value);
return 0;
}
int get_deploymentunit_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *softsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(softsection, "url", value);
return 0;
}
int get_deploymentunit_vendor(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *softsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(softsection, "vendor", value);
return 0;
}
int get_deploymentunit_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *softsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(softsection, "version", value);
return 0;
}
int get_deploymentunit_execution_env_ref(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *softsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(softsection, "execution_env_ref", value);
return 0;
}
char *add_softwaremodules_deploymentunit(char *uuid, char*url, char *username, char *password, char *name, char *version)
{
char *value;
char *instance;
struct uci_section *deploymentsection = NULL;
char duname[16];
uci_path_foreach_option_eq(icwmpd, "dmmap", "deploymentunit", "UUID", uuid, deploymentsection) {
DMUCI_SET_VALUE_BY_SECTION(icwmpd, deploymentsection, "URL", url);
DMUCI_SET_VALUE_BY_SECTION(icwmpd,deploymentsection, "URL", url);
DMUCI_SET_VALUE_BY_SECTION(icwmpd,deploymentsection, "Name", name);
DMUCI_SET_VALUE_BY_SECTION(icwmpd,deploymentsection, "Version", version);
DMUCI_SET_VALUE_BY_SECTION(icwmpd,deploymentsection, "username", username);
DMUCI_SET_VALUE_BY_SECTION(icwmpd,deploymentsection, "password", password);
DMUCI_SET_VALUE_BY_SECTION(icwmpd,deploymentsection, "Resolved", "1");
dmuci_get_value_by_section_string(deploymentsection, "duinstance", &instance);
goto end;
}
instance = get_last_instance(DMMAP, "deploymentunit", "duinstance");
if (!instance)
sprintf(duname, "du%d", 0);
else
sprintf(duname, "du%s", instance);
DMUCI_SET_VALUE(icwmpd, "dmmap", duname, NULL, "deploymentunit");
DMUCI_SET_VALUE(icwmpd, "dmmap", duname, "UUID", uuid);
DMUCI_SET_VALUE(icwmpd, "dmmap", duname, "URL", url);
DMUCI_SET_VALUE(icwmpd, "dmmap", duname, "Name", name);
DMUCI_SET_VALUE(icwmpd, "dmmap", duname, "Version", version);
DMUCI_SET_VALUE(icwmpd, "dmmap", duname, "username", username);
DMUCI_SET_VALUE(icwmpd, "dmmap", duname, "password", password);
DMUCI_SET_VALUE(icwmpd, "dmmap", duname, "Resolved", "1");
instance = get_last_instance(DMMAP, "deploymentunit", "duinstance");
return instance;
end:
return instance;
}
int update_softwaremodules_url(char *uuid, char *url)
{
struct uci_section *s = NULL;
uci_path_foreach_option_eq(icwmpd, "dmmap", "deploymentunit", "UUID", uuid, s) {
DMUCI_SET_VALUE_BY_SECTION(icwmpd, s, "URL", url);
return 1;
}
return 0;
}
char *get_softwaremodules_uuid(char *url)
{
char *uuid;
struct uci_section *s = NULL;
uci_path_foreach_option_eq(icwmpd, "dmmap", "deploymentunit", "url", url, s) {
dmuci_get_value_by_section_string(s, "UUID", &uuid);
return uuid;
}
return "";
}
char *get_softwaremodules_url(char *uuid)
{
char *url;
struct uci_section *s = NULL;
uci_path_foreach_option_eq(icwmpd, "dmmap", "deploymentunit", "uuid", uuid, s) {
dmuci_get_value_by_section_string(s, "URL", &url);
return url;
}
return "";
}
char *get_softwaremodules_username(char *uuid)
{
char *url;
struct uci_section *s = NULL;
uci_path_foreach_option_eq(icwmpd, "dmmap", "deploymentunit", "uuid", uuid, s) {
dmuci_get_value_by_section_string(s, "username", &url);
return url;
}
return "";
}
char *get_softwaremodules_pass(char *uuid)
{
char *url;
struct uci_section *s = NULL;
uci_path_foreach_option_eq(icwmpd, "dmmap", "deploymentunit", "uuid", uuid, s) {
dmuci_get_value_by_section_string(s, "password", &url);
return url;
}
return "";
}
char *get_softwaremodules_instance(char *uuid)
{
char *url;
struct uci_section *s = NULL;
uci_path_foreach_option_eq(icwmpd, "dmmap", "deploymentunit", "uuid", uuid, s) {
dmuci_get_value_by_section_string(s, "duinstance", &url);
return url;
}
return "";
}
char *get_softwaremodules_name(char *uuid)
{
char *name;
struct uci_section *s = NULL;
uci_path_foreach_option_eq(icwmpd, "dmmap", "deploymentunit", "uuid", uuid, s) {
dmuci_get_value_by_section_string(s, "Name", &name);
return name;
}
return "";
}
char *get_softwaremodules_version(char *uuid)
{
char *version;
struct uci_section *s = NULL;
uci_path_foreach_option_eq(icwmpd, "dmmap", "deploymentunit", "uuid", uuid, s) {
dmuci_get_value_by_section_string(s, "Version", &version);
return version;
}
return "";
}
int browsesoftwaremodules_deploymentunitInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *idu = NULL, *idu_last = NULL;
char *permission = "1";
struct uci_section *s = NULL;
uci_path_foreach_sections(icwmpd, "dmmap", "deploymentunit", s) {
idu = handle_update_instance(1, dmctx, &idu_last, update_instance_alias_icwmpd, 3, s, "duinstance", "duinstance_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)s, idu) == DM_STOP)
break;
}
return 0;
}

View file

@ -0,0 +1,37 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2012-2014 PIVA SOFTWARE (www.pivasoftware.com)
* Author: Imen Bhiri <imen.bhiri@pivasoftware.com>
*/
#ifndef __SOFTWARE_MODULE_H
#define __SOFTWARE_MODULE_H
extern DMOBJ tSoftwareModulesObj[];
extern DMLEAF tSoftwareModulesDeploymentUnitParams[];
int browsesoftwaremodules_deploymentunitInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int update_softwaremodules_url(char *uuid, char *url);
char *get_softwaremodules_uuid(char *url);
char *get_softwaremodules_username(char *uuid);
char *get_softwaremodules_pass(char *uuid);
char *get_softwaremodules_instance(char *uuid);
char *get_softwaremodules_version(char *uuid);
char *add_softwaremodules_deploymentunit(char *uuid, char*url, char *username, char *password, char *name, char *version);
char *get_softwaremodules_name(char *uuid);
char *get_softwaremodules_url(char *uuid);
int get_deploymentunit_uuid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_deploymentunit_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_deploymentunit_resolved(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_deploymentunit_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_deploymentunit_vendor(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_deploymentunit_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_deploymentunit_execution_env_ref(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
#endif

291
dmtree/tr181/times.c Normal file
View file

@ -0,0 +1,291 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2015 Inteno Broadband Technology AB
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
*
*/
#include <uci.h>
#include <ctype.h>
#include "dmuci.h"
#include "dmcwmp.h"
#include "dmubus.h"
#include "dmcommon.h"
#include "dmentry.h"
#include "times.h"
/* *** Device.Time. *** */
DMLEAF tTimeParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_time_enable, set_time_enable, NULL, NULL, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_time_status, NULL, NULL, NULL, BBFDM_BOTH},
{"NTPServer1", &DMWRITE, DMT_STRING, get_time_ntpserver1, set_time_ntpserver1, NULL, NULL, BBFDM_BOTH},
{"NTPServer2", &DMWRITE, DMT_STRING, get_time_ntpserver2, set_time_ntpserver2, NULL, NULL, BBFDM_BOTH},
{"NTPServer3", &DMWRITE, DMT_STRING, get_time_ntpserver3, set_time_ntpserver3, NULL, NULL, BBFDM_BOTH},
{"NTPServer4", &DMWRITE, DMT_STRING, get_time_ntpserver4, set_time_ntpserver4, NULL, NULL, BBFDM_BOTH},
{"NTPServer5", &DMWRITE, DMT_STRING, get_time_ntpserver5, set_time_ntpserver5, NULL, NULL, BBFDM_BOTH},
{"CurrentLocalTime", &DMREAD, DMT_TIME, get_time_CurrentLocalTime, NULL, NULL, NULL, BBFDM_BOTH},
{"LocalTimeZone", &DMWRITE, DMT_STRING, get_time_LocalTimeZone, set_time_LocalTimeZone, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"LocalTimeZoneOlson", &DMREAD, DMT_STRING, get_local_time_zone_olson, NULL, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"SourceInterface", &DMWRITE, DMT_STRING, get_time_source_interface, set_time_source_interface, NULL, NULL, BBFDM_BOTH},
{0}
};
int get_time_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *path = "/etc/rc.d/*ntpd";
if (check_file(path))
*value = "1";
else
*value = "0";
return 0;
}
int set_time_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
int check;
pid_t pid;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b) {
DMCMD("/etc/rc.common", 2, "/etc/init.d/ntpd", "enable"); //TODO wait ubus command
pid = get_pid("ntpd");
if (pid < 0) {
DMCMD("/etc/rc.common", 2, "/etc/init.d/ntpd", "start"); //TODO wait ubus command
}
}
else {
DMCMD("/etc/rc.common", 2, "/etc/init.d/ntpd", "disable"); //TODO wait ubus command
pid = get_pid("ntpd");
if (pid > 0) {
DMCMD("/etc/rc.common", 2, "/etc/init.d/ntpd", "stop"); //TODO may be should be updated with ubus call uci
}
}
return 0;
}
return 0;
}
int get_time_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
char *path = "/etc/rc.d/*ntpd";
if (check_file(path))
*value = "Synchronized";
else
*value = "Disabled";
return 0;
}
int get_time_CurrentLocalTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char time_buf[26] = {0};
struct tm *t_tm;
*value = "0001-01-01T00:00:00Z";
time_t t_time = time(NULL);
t_tm = localtime(&t_time);
if (t_tm == NULL)
return 0;
if(strftime(time_buf, sizeof(time_buf), "%FT%T%z", t_tm) == 0)
return 0;
time_buf[25] = time_buf[24];
time_buf[24] = time_buf[23];
time_buf[22] = ':';
time_buf[26] = '\0';
*value = dmstrdup(time_buf);
return 0;
}
/*#Device.Time.LocalTimeZone!UCI:system/system,@system[0]/timezone*/
int get_time_LocalTimeZone(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("system", "@system[0]", "timezone", value);
return 0;
}
int set_time_LocalTimeZone(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
break;
case VALUESET:
dmuci_set_value("system", "@system[0]", "timezone", value);
break;
}
return 0;
}
int get_local_time_zone_olson(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
dmuci_get_option_value_string("system", "@system[0]", "zonename", value);
}
int get_time_ntpserver(char *refparam, struct dmctx *ctx, char **value, int index)
{
char *pch;
bool found = 0;
int element = 0;
struct uci_list *v;
struct uci_element *e;
dmuci_get_option_value_list("system","ntp","server", &v);
if (v) {
uci_foreach_element(v, e) {
element++;
if (element == index) {
*value = dmstrdup(e->name); // MEM WILL BE FREED IN DMMEMCLEAN
found = 1;
break;
}
}
}
if (!found) {
*value = "";
return 0;
}
if (strcmp(*value, "none") == 0) {
*value = "";
}
return 0;
}
int get_time_source_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
char *iface= NULL, *interface= NULL;
*value= "";
dmuci_get_option_value_string("system", "ntp", "interface", &iface);
if (*iface == '\0' || strlen(iface)== 0)
return 0;
adm_entry_get_linker_param(ctx, dm_print_path("%s%cIP%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), iface, &interface);
if (*interface == '\0')
return 0;
*value= dmstrdup(interface);
return 0;
}
int get_time_ntpserver1(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return get_time_ntpserver(refparam, ctx, value, 1);
}
int get_time_ntpserver2(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return get_time_ntpserver(refparam, ctx, value, 2);
}
int get_time_ntpserver3(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return get_time_ntpserver(refparam, ctx, value, 3);
}
int get_time_ntpserver4(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return get_time_ntpserver(refparam, ctx, value, 4);
}
int get_time_ntpserver5(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return get_time_ntpserver(refparam, ctx, value, 5);
}
int set_time_source_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *iface= NULL;
switch (action) {
case VALUECHECK:
adm_entry_get_linker_value(ctx, value, &iface);
if(iface == NULL || iface[0] == '\0')
return FAULT_9007;
break;
case VALUESET:
adm_entry_get_linker_value(ctx, value, &iface);
dmuci_set_value("system", "ntp", "interface", iface);
return 0;
}
return 0;
}
int set_time_ntpserver(char *refparam, struct dmctx *ctx, int action, char *value, int index)
{
char *pch, *path;
int check;
struct uci_list *v;
struct uci_element *e;
int count = 0;
int i = 0;
char *ntp[5] = {0};
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_get_option_value_list("system", "ntp", "server", &v);
if (v) {
uci_foreach_element(v, e) {
if ((count+1) == index) {
ntp[count] = dmstrdup(value);
}
else {
ntp[count] = dmstrdup(e->name);
}
count++;
if (count > 4)
break;
}
}
if (index > count) {
ntp[index-1] = dmstrdup(value);
count = index;
}
for (i = 0; i < 5; i++) {
if (ntp[i] && (*ntp[i]) != '\0')
count = i+1;
}
dmuci_delete("system", "ntp", "server", NULL);
for (i = 0; i < count; i++) {
dmuci_add_list_value("system", "ntp", "server", ntp[i] ? ntp[i] : "");
dmfree(ntp[i]);
}
return 0;
}
return 0;
}
int set_time_ntpserver1(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
return set_time_ntpserver(refparam, ctx, action, value, 1);
}
int set_time_ntpserver2(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
return set_time_ntpserver(refparam, ctx, action, value, 2);
}
int set_time_ntpserver3(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
return set_time_ntpserver(refparam, ctx, action, value, 3);
}
int set_time_ntpserver4(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
return set_time_ntpserver(refparam, ctx, action, value, 4);
}
int set_time_ntpserver5(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
return set_time_ntpserver(refparam, ctx, action, value, 5);
}

39
dmtree/tr181/times.h Normal file
View file

@ -0,0 +1,39 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2015 Inteno Broadband Technology AB
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
*
*/
#ifndef __TIMES_H
#define __TIMES_H
#include "dmcwmp.h"
extern DMLEAF tTimeParams[];
int get_time_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_time_ntpserver1(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_time_ntpserver2(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_time_ntpserver3(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_time_ntpserver4(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_time_ntpserver5(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_time_CurrentLocalTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_time_LocalTimeZone(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_time_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_time_source_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_local_time_zone_olson(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_time_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_time_ntpserver1(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_time_ntpserver2(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_time_ntpserver3(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_time_ntpserver4(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_time_ntpserver5(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_time_LocalTimeZone(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_time_source_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

77
dmtree/tr181/upnp.c Normal file
View file

@ -0,0 +1,77 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2015 Inteno Broadband Technology AB
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
*
*/
#include <uci.h>
#include <stdio.h>
#include <ctype.h>
#include "dmuci.h"
#include "dmubus.h"
#include "dmcwmp.h"
#include "dmcommon.h"
#include "upnp.h"
/* *** Device.UPnP. *** */
DMOBJ tUPnPObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{"Device", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tUPnPDeviceParams, NULL, BBFDM_BOTH},
{0}
};
/* *** Device.UPnP.Device. *** */
DMLEAF tUPnPDeviceParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_upnp_enable, set_upnp_enable, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"Status", &DMREAD, DMT_STRING, get_upnp_status, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/*#Device.UPnP.Device.Enable!UCI:upnpd/upnpd,config/enabled*/
int get_upnp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("upnpd","config","enabled", value);
if ((*value)[0] == '\0') {
*value = "1";
}
return 0;
}
int set_upnp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
int check;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value("upnpd", "config", "enabled", "");
else
dmuci_set_value("upnpd", "config", "enabled", "0");
return 0;
}
return 0;
}
int get_upnp_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
pid_t pid = get_pid("miniupnpd");
if (pid < 0) {
*value = "Down";
}
else {
*value = "Up";
}
return 0;
}

23
dmtree/tr181/upnp.h Normal file
View file

@ -0,0 +1,23 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2015 Inteno Broadband Technology AB
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
*
*/
#ifndef __UPNP_H
#define __UPNP_H
extern DMLEAF tUPnPDeviceParams[];
extern DMOBJ tUPnPObj[];
int get_upnp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_upnp_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_upnp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

View file

@ -0,0 +1,250 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2018 Inteno Broadband Technology AB
* Author: Omar Kallel <omar.kallel@pivasoftware.com>
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*
*/
#include <uci.h>
#include <stdio.h>
#include <ctype.h>
#include "dmuci.h"
#include "dmubus.h"
#include "dmcwmp.h"
#include "dmjson.h"
#include "dmcommon.h"
#include "userinterface.h"
/* *** Device.UserInterface. *** */
DMOBJ tUserInterfaceObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{"RemoteAccess", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tUserInterfaceRemoteAccessParams, NULL, BBFDM_BOTH},
{0}
};
/* *** Device.UserInterface.RemoteAccess. *** */
DMLEAF tUserInterfaceRemoteAccessParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_userint_remoteaccesss_enable, set_userint_remoteaccesss_enable, NULL, NULL, BBFDM_BOTH},
{"Port", &DMWRITE, DMT_UNINT, get_userint_remoteaccesss_port, set_userint_remoteaccesss_port, NULL, NULL, BBFDM_BOTH},
{"SupportedProtocols", &DMREAD, DMT_STRING, get_userint_remoteaccesss_supportedprotocols, NULL, NULL, NULL, BBFDM_BOTH},
{"Protocol", &DMWRITE, DMT_STRING, get_userint_remoteaccesss_protocol, set_userint_remoteaccesss_protocol, NULL, NULL, BBFDM_BOTH},
{0}
};
/**************************************************************************
* GET & SET PARAMETERS
***************************************************************************/
static void add_default_rule(char *port, char *enable, char *owsd)
{
struct uci_section *ss;
char *ret;
dmuci_add_section_and_rename("firewall", "rule", &ss, &ret);
dmuci_set_value_by_section(ss, "name", "juci-remote-access");
dmuci_set_value_by_section(ss, "src", "wan");
dmuci_set_value_by_section(ss, "proto", "tcp");
dmuci_set_value_by_section(ss, "target", "ACCEPT");
dmuci_set_value_by_section(ss, "dest_port", port);
dmuci_set_value_by_section(ss, "owsd", owsd);
dmuci_set_value_by_section(ss, "enabled", enable);
}
int get_userint_remoteaccesss_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *ss;
char *rule_name, *rule_enabled;
uci_foreach_sections("firewall", "rule", ss)
{
dmuci_get_value_by_section_string(ss, "name", &rule_name);
if(strcmp(rule_name, "juci-remote-access") == 0)
{
dmuci_get_value_by_section_string(ss, "enabled", &rule_enabled);
*value= (strcmp(rule_enabled, "0") == 0) ? "0": "1";
return 0;
}
}
*value = "0";
return 0;
}
int set_userint_remoteaccesss_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *ss;
char *rule_name;
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
uci_foreach_sections("firewall", "rule", ss)
{
dmuci_get_value_by_section_string(ss, "name", &rule_name);
if(strcmp(rule_name, "juci-remote-access") == 0)
{
dmuci_set_value_by_section(ss, "enabled", b ? "" : "0");
return 0;
}
}
add_default_rule("80", value, "wan");
return 0;
}
return 0;
}
int get_userint_remoteaccesss_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *ss;
char *rule_name, *dest_port;
uci_foreach_sections("firewall", "rule", ss) {
dmuci_get_value_by_section_string(ss, "name", &rule_name);
if(strcmp(rule_name, "juci-remote-access") == 0){
dmuci_get_value_by_section_string(ss, "dest_port", &dest_port);
*value= dest_port;
return 0;
}
}
*value = "80";
return 0;
}
int set_userint_remoteaccesss_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *ss;
char *rule_name, *owsd;
char *ret;
switch (action)
{
case VALUECHECK:
return 0;
case VALUESET:
uci_foreach_sections("firewall", "rule", ss)
{
dmuci_get_value_by_section_string(ss, "name", &rule_name);
if(strcmp(rule_name, "juci-remote-access") == 0)
{
dmuci_set_value_by_section(ss, "dest_port", value);
dmuci_get_value_by_section_string(ss, "owsd", &owsd);
dmuci_set_value("owsd", owsd, "port", value);
return 0;
}
}
add_default_rule(value, "0", "wan");
dmuci_set_value("owsd", "wan", "port", value);
return 0;
}
return 0;
}
static int get_supportedprotocols(void)
{
char *cert, *key, *ca;
int found_https = 0;
if ((dmuci_get_option_value_string("owsd", "wan_https", "cert", &cert) == 0 && *cert != '\0' && access(cert, F_OK) != -1) ||
(dmuci_get_option_value_string("owsd", "wan_https", "key", &key) == 0 && *key != '\0' && access(key, F_OK) != -1) ||
(dmuci_get_option_value_string("owsd", "wan_https", "ca", &ca) == 0 && *ca != '\0' && access(ca, F_OK) != -1))
found_https = 1;
return found_https;
}
int get_userint_remoteaccesss_supportedprotocols(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
int found;
found = get_supportedprotocols();
if (found)
{
*value = "HTTP, HTTPS";
return 0;
}
*value = "HTTP";
return 0;
}
int get_userint_remoteaccesss_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *ss;
char *rule_name, *rule_owsd;
uci_foreach_sections("firewall", "rule", ss)
{
dmuci_get_value_by_section_string(ss, "name", &rule_name);
if(strcmp(rule_name, "juci-remote-access") == 0)
{
dmuci_get_value_by_section_string(ss, "owsd", &rule_owsd);
if (strcmp(rule_owsd, "wan") == 0)
*value = "HTTP";
else
*value = "HTTPS";
return 0;
}
}
*value = "HTTP";
return 0;
}
int set_userint_remoteaccesss_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *ss;
char *rule_name, *name_http;
int found;
switch (action)
{
case VALUECHECK:
found = get_supportedprotocols();
if (found)
{
if ((strcmp(value, "HTTP") != 0) && (strcmp(value, "HTTPS") != 0))
return FAULT_9007;
}
else
{
if (strcmp(value, "HTTP") != 0)
return FAULT_9007;
}
return 0;
case VALUESET:
uci_foreach_sections("firewall", "rule", ss)
{
dmuci_get_value_by_section_string(ss, "name", &rule_name);
if(strcmp(rule_name, "juci-remote-access") == 0)
{
if(strcmp(value, "HTTPS") == 0)
dmuci_set_value_by_section(ss, "owsd", "wan_https");
else
dmuci_set_value_by_section(ss, "owsd", "wan");
return 0;
}
}
if(strcmp(value, "HTTPS") == 0)
name_http = "wan_https";
else
name_http = "wan";
add_default_rule("80", "0", name_http);
return 0;
}
return 0;
}

View file

@ -0,0 +1,26 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2016 Inteno Broadband Technology AB
* Author: Omar Kallel <omar.kallel@pivasoftware.com>
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*
*/
#ifndef __USER_INTERFACE_H
#define __USER_INTERFACE_H
extern DMLEAF tUserInterfaceRemoteAccessParams[];
extern DMOBJ tUserInterfaceObj[];
int get_userint_remoteaccesss_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_userint_remoteaccesss_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_userint_remoteaccesss_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_userint_remoteaccesss_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_userint_remoteaccesss_supportedprotocols(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_userint_remoteaccesss_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_userint_remoteaccesss_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

254
dmtree/tr181/users.c Normal file
View file

@ -0,0 +1,254 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
*
* Author: Omar Kallel <omar.kallel@pivasoftware.com>
*/
#include "dmcwmp.h"
#include "users.h"
#include "dmcommon.h"
/* *** Device.Users. *** */
DMOBJ tUsersObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{"User", &DMWRITE, add_users_user, delete_users_user, NULL, browseUserInst, NULL, NULL, NULL, tUsersUserParams, NULL, BBFDM_BOTH},
{0}
};
DMLEAF tUsersParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"UserNumberOfEntries", &DMREAD, DMT_UNINT, get_users_user_number_of_entries, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/* *** Device.Users.User.{i}. *** */
DMLEAF tUsersUserParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Alias", &DMWRITE, DMT_STRING, get_user_alias, set_user_alias, NULL, NULL, BBFDM_BOTH},
{"Enable", &DMWRITE, DMT_BOOL, get_user_enable, set_user_enable, NULL, NULL, BBFDM_BOTH},
{"Username", &DMWRITE, DMT_STRING, get_user_username, set_user_username, NULL, NULL, BBFDM_BOTH},
{"Password", &DMWRITE, DMT_STRING, get_user_password, set_user_password, NULL, NULL, BBFDM_BOTH},
{"RemoteAccessCapable", &DMWRITE, DMT_BOOL, get_user_remote_accessable, set_user_remote_accessable, NULL, NULL, BBFDM_BOTH},
{"Language", &DMWRITE, DMT_STRING, get_user_language, set_user_language, NULL, NULL, BBFDM_BOTH},
{0}
};
/***************************** Browse Functions ***********************************/
/*#Device.Users.User.{i}.!UCI:users/user/dmmap_users*/
int browseUserInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *instance, *instnbr = NULL;
struct dmmap_dup *p;
LIST_HEAD(dup_list);
synchronize_specific_config_sections_with_dmmap("users", "user", "dmmap_users", &dup_list);
list_for_each_entry(p, &dup_list, list) {
instance = handle_update_instance(1, dmctx, &instnbr, update_instance_alias, 3, p->dmmap_section, "user_instance", "user_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p->config_section, instance) == DM_STOP)
break;
}
free_dmmap_config_dup_list(&dup_list);
return 0;
}
int add_users_user(char *refparam, struct dmctx *ctx, void *data, char **instance){
struct uci_section *s, *dmmap_user;
char *last_inst= NULL, *sect_name= NULL, *username, *v;
char ib[8];
last_inst= get_last_instance_icwmpd("dmmap_users", "user", "user_instance");
if (last_inst)
sprintf(ib, "%s", last_inst);
else
sprintf(ib, "%s", "1");
dmasprintf(&username, "user_%d", atoi(ib)+1);
dmuci_add_section("users", "user", &s, &sect_name);
dmuci_rename_section_by_section(s, username);
dmuci_set_value_by_section(s, "enabled", "1");
dmuci_set_value_by_section(s, "password", username);
dmuci_add_section_icwmpd("dmmap_users", "user", &dmmap_user, &v);
dmuci_set_value_by_section(dmmap_user, "section_name", sect_name);
*instance = update_instance_icwmpd(dmmap_user, last_inst, "user_instance");
return 0;
}
int delete_users_user(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL;
struct uci_section *ss = NULL;
struct uci_section *dmmap_section;
int found = 0;
switch (del_action) {
case DEL_INST:
if(is_section_unnamed(section_name((struct uci_section *)data))){
LIST_HEAD(dup_list);
delete_sections_save_next_sections("dmmap_users", "user", "user_instance", section_name((struct uci_section *)data), atoi(instance), &dup_list);
update_dmmap_sections(&dup_list, "user_instance", "dmmap_users", "user");
dmuci_delete_by_section_unnamed((struct uci_section *)data, NULL, NULL);
} else {
get_dmmap_section_of_config_section("dmmap_users", "user", section_name((struct uci_section *)data), &dmmap_section);
dmuci_delete_by_section_unnamed_icwmpd(dmmap_section, NULL, NULL);
dmuci_delete_by_section((struct uci_section *)data, NULL, NULL);
}
break;
case DEL_ALL:
uci_foreach_sections("users", "user", s) {
if (found != 0){
get_dmmap_section_of_config_section("dmmap_users", "user", section_name(ss), &dmmap_section);
if(dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
ss = s;
found++;
}
if (ss != NULL){
get_dmmap_section_of_config_section("dmmap_users", "user", section_name(ss), &dmmap_section);
if(dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
break;
}
return 0;
}
/***************************************** Set/Get Parameter functions ***********************/
/*#Device.Users.UserNumberOfEntries!UCI:users/user/*/
int get_users_user_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *s = NULL;
int cnt = 0;
uci_foreach_sections("users", "user", s) {
cnt++;
}
dmasprintf(value, "%d", cnt);
return 0;
}
int get_user_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
get_dmmap_section_of_config_section("dmmap_users", "user", section_name((struct uci_section *)data), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "user_alias", value);
return 0;
}
/*#Device.Users.User.{i}.Enable!UCI:users/user,@i-1/enabled*/
int get_user_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "enabled", value);
return 0;
}
int get_user_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value= dmstrdup(section_name((struct uci_section *)data));
return 0;
}
/*#Device.Users.User.{i}.Password!UCI:users/user,@i-1/password*/
int get_user_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "password", value);
return 0;
}
/*#Device.Users.User.{i}.RemoteAccessCapable!UCI:users/user,@i-1/remote_access*/
int get_user_remote_accessable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "remote_access", value);
return 0;
}
/*#Device.Users.User.{i}.Language!UCI:users/user,@i-1/language*/
int get_user_language(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "language", value);
return 0;
}
int set_user_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
switch (action) {
case VALUECHECK:
break;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_users", "user", section_name((struct uci_section *)data), &dmmap_section);
dmuci_set_value_by_section(dmmap_section, "user_alias", value);
return 0;
}
return 0;
}
int set_user_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "enabled", value);
break;
}
return 0;
}
int set_user_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
break;
case VALUESET:
dmuci_rename_section_by_section((struct uci_section *)data, value);
break;
}
return 0;
}
int set_user_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "password", value);
break;
}
return 0;
}
int set_user_remote_accessable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "remote_access", value);
break;
}
return 0;
}
int set_user_language(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "language", value);
break;
}
return 0;
}

39
dmtree/tr181/users.h Normal file
View file

@ -0,0 +1,39 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
*
* Author: Omar Kallel <omar.kallel@pivasoftware.com>
*/
#ifndef _USERS_H
#define _USERS_H
#include "dmcwmp.h"
extern DMOBJ tUsersObj[];
extern DMLEAF tUsersParams[];
extern DMLEAF tUsersUserParams[];
int browseUserInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int add_users_user(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delete_users_user(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_users_user_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_user_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_user_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_user_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_user_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_user_remote_accessable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_user_language(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_user_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_user_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_user_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_user_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_user_remote_accessable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_user_language(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

3538
dmtree/tr181/wifi.c Normal file

File diff suppressed because it is too large Load diff

337
dmtree/tr181/wifi.h Normal file
View file

@ -0,0 +1,337 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2016 Inteno Broadband Technology AB
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*
*/
#ifndef __WIFI_H
#define __WIFI_H
struct wifi_radio_args
{
struct uci_section *wifi_radio_sec;
};
struct wifi_ssid_args
{
struct uci_section *wifi_ssid_sec;
char *ifname;
char *linker;
};
struct wifi_enp_args
{
struct uci_section *wifi_enp_sec;
char *ifname;
};
struct wifi_acp_args
{
struct uci_section *wifi_acp_sec;
char *ifname;
};
struct wifi_associative_device_args
{
int active;
int lastdatadownloadlinkrate;
int lastdatauplinkrate;
int signalstrength;
char *macaddress;
char *wdev;
int noise;
int retransmissions;
int assoctime;
};
struct wifi_neighboring_diagnostic_args
{
char *ssid;
char *bssid;
char *operatingfrequencyband;
int channel;
int signalstrength;
int noise;
};
extern DMOBJ tWiFiObj[];
extern DMLEAF tWiFiParams[];
extern DMOBJ tWiFiRadioObj[];
extern DMOBJ tWiFiAccessPointObj[];
extern DMOBJ tWiFiSSIDObj[];
extern DMLEAF tWiFiAccessPointParams[];
extern DMLEAF tWiFiSSIDParams[];
extern DMLEAF tWiFiRadioParams[];
extern DMLEAF tWiFiAccessPointSecurityParams[];
extern DMLEAF tWiFiAccessPointAssociatedDeviceParams[];
extern DMLEAF tWiFiAcessPointIEEE80211rParams[];
extern DMOBJ tWiFiAccessPointAssociatedDeviceObj[];
extern DMLEAF tWiFiAccessPointAssociatedDeviceStatsParams[];
extern DMLEAF tWiFiRadioStatsParams[];
extern DMLEAF tWiFiSSIDStatsParams[];
extern DMOBJ tWiFiNeighboringWiFiDiagnosticObj[];
extern DMLEAF tWiFiNeighboringWiFiDiagnosticParams[];
extern DMLEAF tWiFiNeighboringWiFiDiagnosticResultParams[];
extern DMLEAF tWiFiAccessPointWPSParams[];
extern DMLEAF tWiFiAccessPointAccountingParams[];
extern DMOBJ tWiFiEndPointObj[];
extern DMLEAF tWiFiEndPointParams[];
extern DMLEAF tWiFiEndPointStatsParams[];
extern DMLEAF tWiFiEndPointSecurityParams[];
extern DMLEAF tWiFiEndPointWPSParams[];
extern DMOBJ tWiFiEndPointProfileObj[];
extern DMLEAF tWiFiEndPointProfileParams[];
extern DMLEAF tWiFiEndPointProfileSecurityParams[];
int browseWifiSsidInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseWifiAccessPointInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseWifiRadioInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browse_wifi_associated_device(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseWifiNeighboringWiFiDiagnosticResultInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseWiFiEndPointInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseWiFiEndPointProfileInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int add_wifi_ssid(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_wifi_ssid(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int addObjWiFiEndPoint(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delObjWiFiEndPoint(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_WiFi_RadioNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFi_SSIDNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFi_AccessPointNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFi_EndPointNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wifi_bandsteering_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_wifi_bandsteering_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
static int get_radio_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiRadio_Name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_max_bit_rate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_frequency(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_supported_frequency_bands(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_operating_channel_bandwidth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_maxassoc(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_dfsenable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_supported_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_operating_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_channel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_auto_channel_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_possible_channels(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiRadio_AutoChannelSupported(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiRadio_AutoChannelRefreshPeriod(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_statistics_tx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_statistics_rx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_statistics_tx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_statistics_rx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_statistics_tx_errors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_statistics_rx_errors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_statistics_tx_discardpackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_statistics_rx_discardpackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ssid_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wifi_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wifi_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
static int get_wlan_ssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ssid_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
static int get_wlan_bssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ssid_statistics_tx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ssid_statistics_rx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ssid_statistics_tx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ssid_statistics_rx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wifi_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wifi_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ap_ssid_ref(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
static int get_wlan_ssid_advertisement_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
static int get_wmm_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_total_associations(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_maxassoc(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_control_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_security_supported_modes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_security_modes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_security_wepkey_index(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_security_rekey_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_security_radius_ip_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_security_radius_server_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_ieee80211r_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_associative_device_lastdatadownlinkrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_associative_device_lastdatauplinkrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_associative_device_signalstrength(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_associative_device_mac(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_associative_device_active(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_associative_device_statistics_tx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_associative_device_statistics_rx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_associative_device_statistics_tx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_associative_device_statistics_rx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_associative_device_statistics_tx_errors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_associative_device_statistics_retrans_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_associative_device_statistics_failed_retrans_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_associative_device_statistics_retry_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_associative_device_statistics_multiple_retry_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_neighboring_wifi_diagnostics_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_neighboring_wifi_diagnostics_result_number_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_neighboring_wifi_diagnostics_result_ssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_neighboring_wifi_diagnostics_result_bssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_neighboring_wifi_diagnostics_result_channel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_neighboring_wifi_diagnostics_result_signal_strength(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_neighboring_wifi_diagnostics_result_operating_frequency_band(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_neighboring_wifi_diagnostics_result_noise(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_linker_Wifi_Radio(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_linker_Wifi_Ssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_linker_associated_device(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
int get_WiFiRadio_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiRadio_MaxSupportedAssociations(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiRadio_FragmentationThreshold(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiRadio_RTSThreshold(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiRadio_SupportedOperatingChannelBandwidths(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiRadio_OperatingChannelBandwidth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiRadio_CurrentOperatingChannelBandwidth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiRadio_BeaconPeriod(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiRadio_DTIMPeriod(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPointWPS_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPointWPS_ConfigMethodsSupported(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPointWPS_ConfigMethodsEnabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPointWPS_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPointWPS_Version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPointWPS_PIN(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPointAssociatedDevice_Noise(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPointAccounting_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPointAccounting_ServerIPAddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPointAccounting_SecondaryServerIPAddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPointAccounting_ServerPort(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPointAccounting_SecondaryServerPort(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPointAccounting_Secret(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPointAccounting_SecondarySecret(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPointAccounting_InterimInterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiSSID_MACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiSSIDStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiSSIDStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiSSIDStats_DiscardPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiSSIDStats_DiscardPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPoint_UAPSDCapability(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPoint_WMMCapability(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPoint_UAPSDCapability(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPoint_UAPSDEnable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPointAssociatedDevice_Retransmissions(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPointSecurity_MFPConfig(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPoint_MaxAllowedAssociations(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiSSIDStats_MulticastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiSSIDStats_MulticastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiSSIDStats_BroadcastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiSSIDStats_BroadcastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiRadio_PreambleType(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiRadio_IEEE80211hSupported(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiRadio_IEEE80211hEnabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiRadio_TransmitPower(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiRadio_RegulatoryDomain(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiRadioStats_Noise(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiSSIDStats_UnicastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiSSIDStats_UnicastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPoint_IsolationEnable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPointAssociatedDevice_AssociationTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPoint_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPoint_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPoint_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPoint_ProfileReference(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPoint_SSIDReference(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPointStats_LastDataDownlinkRate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPointStats_LastDataUplinkRate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPointStats_SignalStrength(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPointStats_Retransmissions(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPointSecurity_ModesSupported(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPointWPS_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPointWPS_ConfigMethodsSupported(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPointWPS_ConfigMethodsEnabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPointWPS_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPointWPS_Version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPointWPS_PIN(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiAccessPoint_AllowedMACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPointProfile_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPointProfile_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPointProfile_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPointProfile_SSID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPointProfile_Location(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPointProfile_Priority(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPointProfileSecurity_ModeEnabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_WiFiEndPointProfileSecurity_MFPConfig(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
static int set_radio_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_radio_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_radio_operating_channel_bandwidth(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_radio_maxassoc(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_radio_dfsenable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_radio_operating_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_radio_channel(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_radio_auto_channel_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiRadio_AutoChannelRefreshPeriod(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ssid_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wifi_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
static int set_wlan_ssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ssid_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wifi_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
static int set_wlan_ssid_advertisement_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_maxassoc(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_control_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_security_modes(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_security_wepkey(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_security_wepkey_index(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_security_shared_key(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_security_passphrase(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_security_rekey_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_security_radius_ip_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_security_radius_server_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_security_radius_secret(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_ieee80211r_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_neighboring_wifi_diagnostics_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
static int set_wmm_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiRadio_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiRadio_FragmentationThreshold(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiRadio_RTSThreshold(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiRadio_OperatingChannelBandwidth(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiRadio_BeaconPeriod(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiRadio_DTIMPeriod(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiAccessPointWPS_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiAccessPointWPS_ConfigMethodsEnabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiAccessPointWPS_PIN(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiAccessPointAccounting_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiAccessPointAccounting_ServerIPAddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiAccessPointAccounting_SecondaryServerIPAddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiAccessPointAccounting_ServerPort(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiAccessPointAccounting_SecondaryServerPort(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiAccessPointAccounting_Secret(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiAccessPointAccounting_SecondarySecret(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiAccessPointAccounting_InterimInterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiAccessPoint_UAPSDEnable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiAccessPointSecurity_MFPConfig(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiAccessPoint_MaxAllowedAssociations(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiRadio_PreambleType(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiRadio_IEEE80211hEnabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiRadio_TransmitPower(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiRadio_RegulatoryDomain(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiAccessPoint_IsolationEnable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiEndPointWPS_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiEndPoint_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiEndPoint_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiEndPoint_ProfileReference(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiEndPointWPS_ConfigMethodsEnabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiEndPointWPS_PIN(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiAccessPoint_AllowedMACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiEndPointProfile_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiEndPointProfile_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiEndPointProfile_SSID(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiEndPointProfile_Location(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiEndPointProfile_Priority(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiEndPointProfileSecurity_ModeEnabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiEndPointProfileSecurity_WEPKey(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiEndPointProfileSecurity_PreSharedKey(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiEndPointProfileSecurity_KeyPassphrase(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_WiFiEndPointProfileSecurity_MFPConfig(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

View file

@ -0,0 +1,170 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2015 Inteno Broadband Technology AB
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author Omar Kallel <omar.kallel@pivasoftware.com>
*
*/
#include <uci.h>
#include <ctype.h>
#include "dmcwmp.h"
#include "dmuci.h"
#include "dmubus.h"
#include "dmcommon.h"
#include "x_iopsys_eu_buttons.h"
/*** DMROOT.X_IOPSYS_EU_Buttons.{i}. ****/
DMLEAF X_IOPSYS_EU_ButtonParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Alias", &DMWRITE, DMT_STRING, get_x_iopsys_eu_button_alias, set_x_iopsys_eu_button_alias, NULL, NULL, BBFDM_BOTH},
{"button", &DMREAD, DMT_STRING, get_x_iopsys_eu_button_name, NULL, NULL, NULL, BBFDM_BOTH},
{"hotplug", &DMREAD, DMT_STRING, get_x_iopsys_eu_button_hotplug, NULL, NULL, NULL, BBFDM_BOTH},
{"hotplug_long", &DMREAD, DMT_STRING, get_x_iopsys_eu_button_hotplug_long, NULL, NULL, NULL, BBFDM_BOTH},
{"minpress", &DMWRITE, DMT_UNINT, get_x_iopsys_eu_button_minpress, set_x_iopsys_eu_button_minpress, NULL, NULL, BBFDM_BOTH},
{"longpress", &DMWRITE, DMT_UNINT, get_x_iopsys_eu_button_longpress, set_x_iopsys_eu_button_longpress, NULL, NULL, BBFDM_BOTH},
{"enable", &DMWRITE, DMT_BOOL, get_x_iopsys_eu_button_enable, set_x_iopsys_eu_button_enable, NULL, NULL, BBFDM_BOTH},
{0}
};
int browseXIopsysEuButton(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *ibutton = NULL, *ibutton_last = NULL;
struct uci_section *s = NULL;
struct dmmap_dup *p;
LIST_HEAD(dup_list);
synchronize_specific_config_sections_with_dmmap("buttons", "button", "dmmap_buttons", &dup_list);
list_for_each_entry(p, &dup_list, list) {
ibutton = handle_update_instance(1, dmctx, &ibutton_last, update_instance_alias, 3, p->dmmap_section, "buttoninstance", "buttonalias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p->config_section, ibutton) == DM_STOP)
break;
}
free_dmmap_config_dup_list(&dup_list);
return 0;
}
/*************************************************************************************
**** function related to button ****
**************************************************************************************/
int get_x_iopsys_eu_button_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_list *val;
dmuci_get_value_by_section_list((struct uci_section *)data, "button", &val);
if (val)
*value = dmuci_list_to_string(val, " ");
else
*value = "";
return 0;
}
int get_x_iopsys_eu_button_hotplug(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "hotplug", value);
return 0;
}
int get_x_iopsys_eu_button_hotplug_long(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "hotplug_long", value);
return 0;
}
int get_x_iopsys_eu_button_minpress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "minpress", value);
return 0;
}
int set_x_iopsys_eu_button_minpress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "minpress", value);
return 0;
}
return 0;
}
int get_x_iopsys_eu_button_longpress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "longpress", value);
return 0;
}
int set_x_iopsys_eu_button_longpress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "longpress", value);
return 0;
}
return 0;
}
int get_x_iopsys_eu_button_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "enable", value);
if ((*value)[0] == '\0') {
*value = "1";
}
return 0;
}
int set_x_iopsys_eu_button_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section((struct uci_section *)data, "enable", "");
else
dmuci_set_value_by_section((struct uci_section *)data, "enable", "0");
return 0;
}
return 0;
}
////////////////////////SET AND GET ALIAS/////////////////////////////////
int get_x_iopsys_eu_button_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
get_dmmap_section_of_config_section("dmmap_buttons", "button", section_name((struct uci_section *)data), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "buttonalias", value);
return 0;
}
int set_x_iopsys_eu_button_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
get_dmmap_section_of_config_section("dmmap_buttons", "button", section_name((struct uci_section *)data), &dmmap_section);
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(dmmap_section, "buttonalias", value);
return 0;
}
return 0;
}

View file

@ -0,0 +1,30 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2015 Inteno Broadband Technology AB
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author Omar Kallel <omar.kallel@pivasoftware.com>
*
*/
#ifndef __SE_BUTTONS_H
#define __SE_BUTTONS_H
extern DMLEAF X_IOPSYS_EU_ButtonParams[];
int browseXIopsysEuButton(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int get_x_iopsys_eu_button_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_iopsys_eu_button_hotplug(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_iopsys_eu_button_hotplug_long(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_iopsys_eu_button_minpress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_iopsys_eu_button_minpress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_iopsys_eu_button_longpress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_iopsys_eu_button_longpress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_iopsys_eu_button_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_iopsys_eu_button_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_iopsys_eu_button_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_iopsys_eu_button_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

View file

@ -0,0 +1,455 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2015 Inteno Broadband Technology AB
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
*
*/
#include <uci.h>
#include <ctype.h>
#include "dmcwmp.h"
#include "dmuci.h"
#include "dmubus.h"
#include "dmcommon.h"
#include "x_iopsys_eu_dropbear.h"
/*** DMROOT.X_IOPSYS_EU_Dropbear.{i}. ****/
DMLEAF X_IOPSYS_EU_DropbearParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Alias", &DMWRITE, DMT_STRING, get_x_iopsys_eu_dropbear_alias, set_x_iopsys_eu_dropbear_alias, NULL, NULL, BBFDM_BOTH},
{"PasswordAuth", &DMWRITE, DMT_BOOL, get_x_iopsys_eu_dropbear_password_auth, set_x_iopsys_eu_dropbear_password_auth, NULL, NULL, BBFDM_BOTH},
{"RootPasswordAuth", &DMWRITE, DMT_BOOL, get_x_iopsys_eu_dropbear_root_password_auth, set_x_iopsys_eu_dropbear_root_password_auth, NULL, NULL, BBFDM_BOTH},
{"Port", &DMWRITE, DMT_UNINT, get_x_iopsys_eu_dropbear_port, set_x_iopsys_eu_dropbear_port, NULL, NULL, BBFDM_BOTH},
{"RootLogin", &DMWRITE, DMT_BOOL, get_x_iopsys_eu_dropbear_root_login, set_x_iopsys_eu_dropbear_root_login, NULL, NULL, BBFDM_BOTH},
{"GatewayPorts", &DMWRITE, DMT_BOOL, get_x_iopsys_eu_dropbear_gateway_ports, set_x_iopsys_eu_dropbear_gateway_ports, NULL, NULL, BBFDM_BOTH},
{"Interface", &DMWRITE, DMT_STRING, get_x_iopsys_eu_dropbear_interface, set_x_iopsys_eu_dropbear_interface, NULL, NULL, BBFDM_BOTH},
{"rsakeyfile", &DMWRITE, DMT_STRING, get_x_iopsys_eu_dropbear_rsakeyfile, set_x_iopsys_eu_dropbear_rsakeyfile, NULL, NULL, BBFDM_BOTH},
{"dsskeyfile", &DMWRITE, DMT_STRING, get_x_iopsys_eu_dropbear_dsskeyfile, set_x_iopsys_eu_dropbear_dsskeyfile, NULL, NULL, BBFDM_BOTH},
{"SSHKeepAlive", &DMWRITE, DMT_UNINT, get_x_iopsys_eu_dropbear_ssh_keepalive, set_x_iopsys_eu_dropbear_ssh_keepalive, NULL, NULL, BBFDM_BOTH},
{"IdleTimeout", &DMWRITE, DMT_UNINT, get_x_iopsys_eu_dropbear_idle_timeout, set_x_iopsys_eu_dropbear_idle_timeout, NULL, NULL, BBFDM_BOTH},
{"verbose", &DMWRITE, DMT_BOOL, get_x_iopsys_eu_dropbear_verbose, set_x_iopsys_eu_dropbear_verbose, NULL, NULL, BBFDM_BOTH},
{"BannerFile", &DMWRITE, DMT_STRING, get_x_iopsys_eu_dropbear_banner_file, set_x_iopsys_eu_dropbear_banner_file, NULL, NULL, BBFDM_BOTH},
{0}
};
int browseXIopsysEuDropbear(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *idropbear = NULL, *idropbear_last = NULL;
struct uci_section *s = NULL;
struct dmmap_dup *p;
LIST_HEAD(dup_list);
synchronize_specific_config_sections_with_dmmap("dropbear", "dropbear", "dmmap_dropbear", &dup_list);
list_for_each_entry(p, &dup_list, list) {
idropbear = handle_update_instance(1, dmctx, &idropbear_last, update_instance_alias_icwmpd, 3, p->dmmap_section, "dropbearinstance", "dropbearalias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p->config_section, idropbear) == DM_STOP)
break;
}
return 0;
}
/*************************************************************************************
**** function ****
**************************************************************************************/
int get_x_iopsys_eu_dropbear_password_auth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "PasswordAuth", value);
if ((*value)[0] == '\0' || ((*value)[0] == 'o' && (*value)[1] == 'n') || (*value)[0] == '1') {
*value = "1";
}
else
*value = "0";
return 0;
}
int set_x_iopsys_eu_dropbear_password_auth(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section((struct uci_section *)data, "PasswordAuth", "1");
else
dmuci_set_value_by_section((struct uci_section *)data, "PasswordAuth", "0");
return 0;
}
return 0;
}
int get_x_iopsys_eu_dropbear_root_password_auth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "RootPasswordAuth", value);
if ((*value)[0] == '\0' || ((*value)[0] == 'o' && (*value)[1] == 'n') || (*value)[0] == '1') {
*value = "1";
}
else
*value = "0";
return 0;
}
int set_x_iopsys_eu_dropbear_root_password_auth(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section((struct uci_section *)data, "RootPasswordAuth", "1");
else
dmuci_set_value_by_section((struct uci_section *)data, "RootPasswordAuth", "0");
return 0;
}
return 0;
}
int get_x_iopsys_eu_dropbear_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "Port", value);
if ((*value)[0] == '\0') {
*value = "22";
}
return 0;
}
int set_x_iopsys_eu_dropbear_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
if (value[0] == '\0')
dmuci_set_value_by_section((struct uci_section *)data, "Port", "22");
else
dmuci_set_value_by_section((struct uci_section *)data, "Port", value);
return 0;
}
return 0;
}
int get_x_iopsys_eu_dropbear_root_login(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "RootLogin", value);
if ((*value)[0] == '\0' || ((*value)[0] == 'o' && (*value)[1] == 'n') || (*value)[0] == '1' ) {
*value = "1";
}
else
*value = "0";
return 0;
}
int set_x_iopsys_eu_dropbear_root_login(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section((struct uci_section *)data, "RootLogin", "1");
else
dmuci_set_value_by_section((struct uci_section *)data, "RootLogin", "0");
return 0;
}
return 0;
}
int get_x_iopsys_eu_dropbear_verbose(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "verbose", value);
if ((*value)[0] == '\0' || (*value)[0] == '0' ) {
*value = "0";
}
else
*value = "1";
return 0;
}
int set_x_iopsys_eu_dropbear_verbose(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section((struct uci_section *)data, "verbose", "1");
else
dmuci_set_value_by_section((struct uci_section *)data, "verbose", "0");
return 0;
}
return 0;
}
int get_x_iopsys_eu_dropbear_gateway_ports(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "GatewayPorts", value);
if ((*value)[0] == '\0' || (*value)[0] == '0' ) {
*value = "0";
}
else
*value = "1";
return 0;
}
int set_x_iopsys_eu_dropbear_gateway_ports(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section((struct uci_section *)data, "GatewayPorts", "1");
else
dmuci_set_value_by_section((struct uci_section *)data, "GatewayPorts", "");
return 0;
}
return 0;
}
int get_x_iopsys_eu_dropbear_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "Interface", value);
return 0;
}
int set_x_iopsys_eu_dropbear_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "Interface", value);
return 0;
}
return 0;
}
int get_x_iopsys_eu_dropbear_rsakeyfile(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "rsakeyfile", value);
return 0;
}
int set_x_iopsys_eu_dropbear_rsakeyfile(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "rsakeyfile", value);
return 0;
}
return 0;
}
int get_x_iopsys_eu_dropbear_dsskeyfile(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "dsskeyfile", value);
return 0;
}
int set_x_iopsys_eu_dropbear_dsskeyfile(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "dsskeyfile", value);
return 0;
}
return 0;
}
int get_x_iopsys_eu_dropbear_ssh_keepalive(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "SSHKeepAlive", value);
if ((*value)[0] == '\0') {
*value = "300";
}
return 0;
}
int set_x_iopsys_eu_dropbear_ssh_keepalive(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
if (strcmp(value, "300") == 0)
dmuci_set_value_by_section((struct uci_section *)data, "SSHKeepAlive", "");
else
dmuci_set_value_by_section((struct uci_section *)data, "SSHKeepAlive", value);
return 0;
}
return 0;
}
int get_x_iopsys_eu_dropbear_idle_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "IdleTimeout", value);
if ((*value)[0] == '\0') {
*value = "300";
}
return 0;
}
int set_x_iopsys_eu_dropbear_idle_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
if (value[0] == '0')
dmuci_set_value_by_section((struct uci_section *)data, "IdleTimeout", "");
else
dmuci_set_value_by_section((struct uci_section *)data, "IdleTimeout", value);
return 0;
}
return 0;
}
int get_x_iopsys_eu_dropbear_banner_file(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "BannerFile", value);
return 0;
}
int set_x_iopsys_eu_dropbear_banner_file(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "BannerFile", value);
return 0;
}
return 0;
}
////////////////////////SET AND GET ALIAS/////////////////////////////////
int get_x_iopsys_eu_dropbear_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
get_dmmap_section_of_config_section("dmmap_dropbear", "dropbear", section_name((struct uci_section *)data), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "dropbearalias", value);
return 0;
}
int set_x_iopsys_eu_dropbear_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
get_dmmap_section_of_config_section("dmmap_dropbear", "dropbear", section_name((struct uci_section *)data), &dmmap_section);
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(dmmap_section, "dropbearalias", value);
return 0;
}
return 0;
}
/***** ADD DEL OBJ *******/
int add_dropbear_instance(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
{
char *value, *v;
char *instance;
struct uci_section *dropbear_sec = NULL, *dmmap_sec= NULL;
check_create_dmmap_package("dmmap_dropbear");
instance = get_last_instance_icwmpd("dmmap_dropbear", "dropbear", "dropbearinstance");
dmuci_add_section("dropbear", "dropbear", &dropbear_sec, &value);
dmuci_set_value_by_section(dropbear_sec, "verbose", "0");
dmuci_set_value_by_section(dropbear_sec, "Port", "22");
dmuci_set_value_by_section(dropbear_sec, "RootLogin", "1");
dmuci_set_value_by_section(dropbear_sec, "GatewayPorts", "0");
dmuci_set_value_by_section(dropbear_sec, "SSHKeepAlive", "300");
dmuci_set_value_by_section(dropbear_sec, "IdleTimeout", "0");
dmuci_add_section_icwmpd("dmmap_dropbear", "dropbear", &dmmap_sec, &v);
dmuci_set_value_by_section(dmmap_sec, "section_name", section_name(dropbear_sec));
*instancepara = update_instance_icwmpd(dmmap_sec, instance, "dropbearinstance");
return 0;
}
int delete_dropbear_instance(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL;
struct uci_section *ss = NULL;
struct uci_section *dmmap_section;
int found = 0;
switch (del_action) {
case DEL_INST:
if(is_section_unnamed(section_name((struct uci_section *)data))){
LIST_HEAD(dup_list);
delete_sections_save_next_sections("dmmap_dropbear", "dropbear", "dropbearinstance", section_name((struct uci_section *)data), atoi(instance), &dup_list);
update_dmmap_sections(&dup_list, "dropbearinstance", "dmmap_dropbear", "dropbear");
dmuci_delete_by_section_unnamed((struct uci_section *)data, NULL, NULL);
} else {
get_dmmap_section_of_config_section("dmmap_dropbear", "dropbear", section_name((struct uci_section *)data), &dmmap_section);
dmuci_delete_by_section_unnamed_icwmpd(dmmap_section, NULL, NULL);
dmuci_delete_by_section((struct uci_section *)data, NULL, NULL);
}
break;
case DEL_ALL:
uci_foreach_sections("dropbear", "dropbear", s) {
if (found != 0){
get_dmmap_section_of_config_section("dmmap_dropbear", "dropbear", section_name(ss), &dmmap_section);
if(dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
ss = s;
found++;
}
if (ss != NULL){
get_dmmap_section_of_config_section("dmmap_dropbear", "dropbear", section_name(ss), &dmmap_section);
if(dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
return 0;
}
return 0;
}

View file

@ -0,0 +1,46 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2015 Inteno Broadband Technology AB
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
*
*/
#ifndef __SE_DROPBEAR_H
#define __SE_DROPBEAR_H
extern DMLEAF X_IOPSYS_EU_DropbearParams[];
int browseXIopsysEuDropbear(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int get_x_iopsys_eu_dropbear_password_auth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_iopsys_eu_dropbear_password_auth(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_iopsys_eu_dropbear_root_password_auth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_iopsys_eu_dropbear_root_password_auth(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_iopsys_eu_dropbear_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_iopsys_eu_dropbear_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_iopsys_eu_dropbear_root_login(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_iopsys_eu_dropbear_root_login(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_iopsys_eu_dropbear_verbose(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_iopsys_eu_dropbear_verbose(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_iopsys_eu_dropbear_gateway_ports(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_iopsys_eu_dropbear_gateway_ports(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_iopsys_eu_dropbear_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_iopsys_eu_dropbear_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_iopsys_eu_dropbear_rsakeyfile(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_iopsys_eu_dropbear_rsakeyfile(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_iopsys_eu_dropbear_dsskeyfile(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_iopsys_eu_dropbear_dsskeyfile(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_iopsys_eu_dropbear_ssh_keepalive(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_iopsys_eu_dropbear_ssh_keepalive(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_iopsys_eu_dropbear_idle_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_iopsys_eu_dropbear_idle_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_iopsys_eu_dropbear_banner_file(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_iopsys_eu_dropbear_banner_file(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_iopsys_eu_dropbear_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_iopsys_eu_dropbear_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int add_dropbear_instance(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_dropbear_instance(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
#endif

View file

@ -0,0 +1,79 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2015 Inteno Broadband Technology AB
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
*
*/
#include <uci.h>
#include <stdio.h>
#include <ctype.h>
#include "dmuci.h"
#include "dmubus.h"
#include "dmcwmp.h"
#include "dmcommon.h"
#include "x_iopsys_eu_ice.h"
/*** DMROOT.X_IOPSYS_EU_ICE. ***/
DMLEAF tSe_IceParam[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_ice_cloud_enable, set_ice_cloud_enable, NULL, NULL, BBFDM_BOTH},
{"Server", &DMWRITE, DMT_STRING, get_ice_cloud_server, set_ice_cloud_server, NULL, NULL, BBFDM_BOTH},
{0}
};
int get_ice_cloud_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
bool b;
dmuci_get_option_value_string("ice", "cloud", "enabled", value);
string_to_bool(*value, &b);
if (b)
*value = "1";
else
*value = "0";
return 0;
}
int set_ice_cloud_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if (b)
dmuci_set_value("ice", "cloud", "enabled", "1");
else
dmuci_set_value("ice", "cloud", "enabled", "0");
return 0;
}
}
int get_ice_cloud_server(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("ice", "cloud", "server", value);
return 0;
}
int set_ice_cloud_server(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
if (value[0] == '\0')
return 0;
dmuci_set_value("ice", "cloud", "server", value);
return 0;
}
return 0;
}

View file

@ -0,0 +1,23 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2015 Inteno Broadband Technology AB
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
*
*/
#ifndef __SE_ICE_H
#define __SE_ICE_H
extern DMLEAF tSe_IceParam[];
int get_ice_cloud_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ice_cloud_server(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_ice_cloud_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ice_cloud_server(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

View file

@ -0,0 +1,410 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2015 Inteno Broadband Technology AB
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
*
*/
#include <uci.h>
#include <stdio.h>
#include <ctype.h>
#include "dmuci.h"
#include "dmubus.h"
#include "dmcwmp.h"
#include "dmcommon.h"
#include "x_iopsys_eu_igmp.h"
DMLEAF tSe_IgmpParam[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"DifferentiateService", &DMWRITE, DMT_STRING, get_igmp_dscp_mark, set_igmp_dscp_mark, NULL, NULL, BBFDM_BOTH},
{"ProxyInterface", &DMWRITE, DMT_STRING, get_igmp_proxy_interface, set_igmp_proxy_interface, NULL, NULL, BBFDM_BOTH},
{"DefaultVersion", &DMWRITE, DMT_STRING, get_igmp_default_version, set_igmp_default_version, NULL, NULL, BBFDM_BOTH},
{"QueryInterval", &DMWRITE, DMT_UNINT, get_igmp_query_interval, set_igmp_query_interval, NULL, NULL, BBFDM_BOTH},
{"QueryResponseInterval", &DMWRITE, DMT_UNINT, get_igmp_query_response_interval, set_igmp_query_response_interval, NULL, NULL, BBFDM_BOTH},
{"LastMemberQueryInterval", &DMWRITE, DMT_UNINT, get_igmp_last_member_queryinterval, set_igmp_last_member_queryinterval, NULL, NULL, BBFDM_BOTH},
{"RobustnessValue", &DMWRITE, DMT_INT, get_igmp_robustness_value, set_igmp_robustness_value, NULL, NULL, BBFDM_BOTH},
{"LanToLanMulticastEnable", &DMWRITE, DMT_BOOL, get_igmp_multicast_enable, set_igmp_multicast_enable, NULL, NULL, BBFDM_BOTH, BBFDM_BOTH},
{"MaxGroup", &DMWRITE, DMT_UNINT, get_igmp_maxgroup, set_igmp_maxgroup, NULL, NULL, BBFDM_BOTH},
{"MaxSources", &DMWRITE, DMT_UNINT, get_igmp_maxsources, set_igmp_maxsources, NULL, NULL, BBFDM_BOTH},
{"MaxMembers", &DMWRITE, DMT_UNINT, get_igmp_maxmembers, set_igmp_maxmembers, NULL, NULL, BBFDM_BOTH},
{"FastLeaveEnable", &DMWRITE, DMT_BOOL, get_igmp_fastleave_enable, set_igmp_fastleave_enable, NULL, NULL, BBFDM_BOTH},
{"JoinImmediateEnable", &DMWRITE, DMT_BOOL, get_igmp_joinimmediate_enable, set_igmp_joinimmediate_enable, NULL, NULL, BBFDM_BOTH},
{"ProxyEnable", &DMWRITE, DMT_BOOL, get_igmp_proxy_enable, set_igmp_proxy_enable, NULL, NULL, BBFDM_BOTH},
{"SnoopingMode", &DMWRITE, DMT_STRING, get_igmp_snooping_mode, set_igmp_snooping_mode, NULL, NULL, BBFDM_BOTH},
{"SnoopingInterfaces", &DMWRITE, DMT_STRING, get_igmp_snooping_interface, set_igmp_snooping_interface, NULL, NULL, BBFDM_BOTH},
{0}
};
int get_igmp_dscp_mark(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_dscp_mark", value);
return 0;
}
int set_igmp_dscp_mark(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("mcpd", "mcpd", "igmp_dscp_mark", value);
return 0;
}
return 0;
}
int get_igmp_proxy_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *p;
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_proxy_interfaces", value);
*value = dmstrdup(*value); // MEM WILL BE FREED IN DMMEMCLEAN
p = *value;
while (*p++) {
if (*p == ' ') *p = ',';
}
return 0;
}
int set_igmp_proxy_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
int i;
char *p;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
if (value[0] == '\0')
return 0;
value = dmstrdup(value);
p = value;
while (*p++) {
if (*p == ',') *p = ' ';
}
compress_spaces(value);
dmuci_set_value("mcpd", "mcpd", "igmp_proxy_interfaces", value);
dmfree(value);
return 0;
}
return 0;
}
int get_igmp_default_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_default_version", value);
return 0;
}
int set_igmp_default_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("mcpd", "mcpd", "igmp_default_version", value);
return 0;
}
return 0;
}
int get_igmp_query_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_query_interval", value);
return 0;
}
int set_igmp_query_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("mcpd", "mcpd", "igmp_query_interval", value);
return 0;
}
return 0;
}
int get_igmp_query_response_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_query_response_interval", value);
return 0;
}
int set_igmp_query_response_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("mcpd", "mcpd", "igmp_query_response_interval", value);
return 0;
}
return 0;
}
int get_igmp_last_member_queryinterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_last_member_query_interval", value);
return 0;
}
int set_igmp_last_member_queryinterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("mcpd", "mcpd", "igmp_last_member_query_interval", value);
return 0;
}
return 0;
}
int get_igmp_robustness_value(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_robustness_value", value);
return 0;
}
int set_igmp_robustness_value(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("mcpd", "mcpd", "igmp_robustness_value", value);
return 0;
}
return 0;
}
int get_igmp_multicast_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_lan_to_lan_multicast", value);
if ((*value)[0] == '\0') {
*value = "0";
}
return 0;
}
int set_igmp_multicast_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if (b)
dmuci_set_value("mcpd", "mcpd", "igmp_lan_to_lan_multicast", "1");
else
dmuci_set_value("mcpd", "mcpd", "igmp_lan_to_lan_multicast", "");
return 0;
}
return 0;
}
int get_igmp_fastleave_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_fast_leave", value);
if ((*value)[0] == '\0') {
*value = "0";
}
return 0;
}
int set_igmp_fastleave_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if (b)
dmuci_set_value("mcpd", "mcpd", "igmp_fast_leave", "1");
else
dmuci_set_value("mcpd", "mcpd", "igmp_fast_leave", "");
return 0;
}
return 0;
}
int get_igmp_joinimmediate_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_join_immediate", value);
if ((*value)[0] == '\0') {
*value = "0";
}
return 0;
}
int set_igmp_joinimmediate_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if (b)
dmuci_set_value("mcpd", "mcpd", "igmp_join_immediate", "1");
else
dmuci_set_value("mcpd", "mcpd", "igmp_join_immediate", "");
return 0;
}
return 0;
}
int get_igmp_proxy_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_proxy_enable", value);
if ((*value)[0] == '\0') {
*value = "0";
}
return 0;
}
int set_igmp_proxy_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if (b)
dmuci_set_value("mcpd", "mcpd", "igmp_proxy_enable", "1");
else
dmuci_set_value("mcpd", "mcpd", "igmp_proxy_enable", "");
return 0;
}
return 0;
}
int get_igmp_maxgroup(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_max_groups", value);
return 0;
}
int set_igmp_maxgroup(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("mcpd", "mcpd", "igmp_max_groups", value);
return 0;
}
return 0;
}
int get_igmp_maxsources(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_max_sources", value);
return 0;
}
int set_igmp_maxsources(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("mcpd", "mcpd", "igmp_max_sources", value);
return 0;
}
return 0;
}
int get_igmp_maxmembers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_max_members", value);
return 0;
}
int set_igmp_maxmembers(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("mcpd", "mcpd", "igmp_max_members", value);
return 0;
}
return 0;
}
int get_igmp_snooping_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_snooping_enable", value);
return 0;
}
int set_igmp_snooping_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("mcpd", "mcpd", "igmp_snooping_enable", value);
return 0;
}
return 0;
}
int get_igmp_snooping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *p;
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_snooping_interfaces", value);
*value = dmstrdup(*value); // MEM WILL BE FREED IN DMMEMCLEAN
p = *value;
while (*p++) {
if (*p == ' ') *p = ',';
}
return 0;
}
int set_igmp_snooping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
int i;
char *p;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
if (value[0] == '\0')
return 0;
value = dmstrdup(value);
p = value;
while (*p++) {
if (*p == ',') *p = ' ';
}
compress_spaces(value);
dmuci_set_value("mcpd", "mcpd", "igmp_snooping_interfaces", value);
dmfree(value);
return 0;
}
return 0;
}

View file

@ -0,0 +1,50 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2015 Inteno Broadband Technology AB
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
*
*/
#ifndef __SE_IGMP_H
#define __SE_IGMP_H
extern DMLEAF tSe_IgmpParam[];
int get_igmp_dscp_mark(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_igmp_dscp_mark(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_igmp_proxy_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_igmp_proxy_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_igmp_default_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_igmp_default_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_igmp_query_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_igmp_query_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_igmp_query_response_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_igmp_query_response_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_igmp_last_member_queryinterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_igmp_last_member_queryinterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_igmp_robustness_value(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_igmp_robustness_value(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_igmp_multicast_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_igmp_multicast_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_igmp_fastleave_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_igmp_fastleave_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_igmp_joinimmediate_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_igmp_joinimmediate_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_igmp_proxy_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_igmp_proxy_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_igmp_maxgroup(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_igmp_maxgroup(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_igmp_maxsources(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_igmp_maxsources(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_igmp_maxmembers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_igmp_maxmembers(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_igmp_snooping_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_igmp_snooping_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_igmp_snooping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_igmp_snooping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

View file

@ -0,0 +1,825 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2015 Inteno Broadband Technology AB
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author Omar Kallel <omar.kallel@pivasoftware.com>
*
*/
#include <uci.h>
#include <ctype.h>
#include "dmcwmp.h"
#include "dmuci.h"
#include "dmubus.h"
#include "dmcommon.h"
#include "x_iopsys_eu_ipacccfg.h"
/*** DMROOT.X_IOPSYS_EU_IpAccCfg. ***/
DMOBJ tSe_IpAccObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{CUSTOM_PREFIX"IpAccListCfgObj", &DMWRITE, add_ipacccfg_rule, delete_ipacccfg_rule, NULL, browseAccListInst, NULL, NULL, NULL, tSe_IpAccCfgParam, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"PortForwarding", &DMWRITE, add_ipacccfg_port_forwarding, delete_ipacccfg_port_forwarding, NULL, browseport_forwardingInst, NULL, NULL, NULL, tSe_PortForwardingParam, NULL, BBFDM_BOTH},
{0}
};
DMLEAF tSe_PortForwardingParam[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Alias", &DMWRITE, DMT_STRING, get_port_forwarding_alias, set_port_forwarding_alias, NULL, NULL, BBFDM_BOTH},
{"Name", &DMWRITE, DMT_STRING, get_port_forwarding_name, set_port_forwarding_name, NULL, NULL, BBFDM_BOTH},
{"Enable", &DMWRITE, DMT_BOOL, get_port_forwarding_enable, set_port_forwarding_enable, NULL, NULL, BBFDM_BOTH},
{"EnalbeNatLoopback", &DMWRITE, DMT_BOOL, get_port_forwarding_loopback, set_port_forwarding_loopback, NULL, NULL, BBFDM_BOTH},
{"Protocol", &DMWRITE, DMT_STRING, get_port_forwarding_protocol, set_port_forwarding_protocol, NULL, NULL, BBFDM_BOTH},
{"ExternalZone", &DMWRITE, DMT_STRING, get_port_forwarding_external_zone, set_port_forwarding_external_zone, NULL, NULL, BBFDM_BOTH},
{"InternalZone", &DMWRITE, DMT_STRING, get_port_forwarding_internal_zone, set_port_forwarding_internal_zone, NULL, NULL, BBFDM_BOTH},
{"ExternalPort", &DMWRITE, DMT_STRING, get_port_forwarding_external_port, set_port_forwarding_external_port, NULL, NULL, BBFDM_BOTH},
{"InternalPort", &DMWRITE, DMT_STRING, get_port_forwarding_internal_port, set_port_forwarding_internal_port, NULL, NULL, BBFDM_BOTH},
{"SourcePort", &DMWRITE, DMT_STRING, get_port_forwarding_source_port, set_port_forwarding_source_port, NULL, NULL, BBFDM_BOTH},
{"InternalIpAddress", &DMWRITE, DMT_STRING, get_port_forwarding_internal_ipaddress, set_port_forwarding_internal_ipaddress, NULL, NULL, BBFDM_BOTH},
{"ExternalIpAddress", &DMWRITE, DMT_STRING, get_port_forwarding_external_ipaddress, set_port_forwarding_external_ipaddress, NULL, NULL, BBFDM_BOTH},
{"SourceIpAddress", &DMWRITE, DMT_STRING, get_port_forwarding_source_ipaddress, set_port_forwarding_source_ipaddress, NULL, NULL, BBFDM_BOTH},
{"SourceMacAddress", &DMWRITE, DMT_STRING, get_port_forwarding_src_mac, set_port_forwarding_src_mac, NULL, NULL, BBFDM_BOTH},
{0}
};
DMLEAF tSe_IpAccCfgParam[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Alias", &DMWRITE, DMT_STRING, get_x_iopsys_eu_cfgobj_address_alias, set_x_iopsys_eu_cfgobj_address_alias, NULL, NULL, BBFDM_BOTH},
{"Enable", &DMWRITE, DMT_BOOL, get_x_bcm_com_ip_acc_list_cfgobj_enable, set_x_bcm_com_ip_acc_list_cfgobj_enable, NULL, NULL, BBFDM_BOTH},
{"IPVersion", &DMWRITE, DMT_STRING, get_x_bcm_com_ip_acc_list_cfgobj_ipversion, set_x_bcm_com_ip_acc_list_cfgobj_ipversion, NULL, NULL, BBFDM_BOTH},
{"Protocol", &DMWRITE, DMT_STRING, get_x_bcm_com_ip_acc_list_cfgobj_protocol, set_x_bcm_com_ip_acc_list_cfgobj_protocol, NULL, NULL, BBFDM_BOTH},
{"FilterName", &DMWRITE, DMT_STRING, get_x_bcm_com_ip_acc_list_cfgobj_name, set_x_bcm_com_ip_acc_list_cfgobj_name, NULL, NULL, BBFDM_BOTH},
{"AccAddressAndNetMask", &DMWRITE, DMT_STRING, get_x_iopsys_eu_cfgobj_address_netmask, set_x_iopsys_eu_cfgobj_address_netmask, NULL, NULL, BBFDM_BOTH},
{"AccPort", &DMWRITE, DMT_STRING, get_x_bcm_com_ip_acc_list_cfgobj_acc_port, set_x_bcm_com_ip_acc_list_cfgobj_acc_port, NULL, NULL, BBFDM_BOTH},
{"Target", &DMWRITE, DMT_STRING, get_x_bcm_com_ip_acc_list_cfgobj_target, set_x_bcm_com_ip_acc_list_cfgobj_target, NULL, NULL, BBFDM_BOTH},
{0}
};
/*************************************************************************************
**** function related to get_object_ip_acc_list_cfgobj ****
**************************************************************************************/
int get_x_bcm_com_ip_acc_list_cfgobj_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *ipaccsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(ipaccsection, "enabled", value);
if ((*value)[0] == '\0') {
*value = "1";
}
return 0;
}
int set_x_bcm_com_ip_acc_list_cfgobj_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
int check;
struct uci_section *ipaccsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b) {
value = "";
}
else {
value = "0";
}
dmuci_set_value_by_section(ipaccsection, "enabled", value);
return 0;
}
return 0;
}
int get_x_bcm_com_ip_acc_list_cfgobj_ipversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *ipaccsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(ipaccsection, "family", value);
return 0;
}
int set_x_bcm_com_ip_acc_list_cfgobj_ipversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *ipaccsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(ipaccsection, "family", value);
return 0;
}
return 0;
}
int get_x_bcm_com_ip_acc_list_cfgobj_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *ipaccsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(ipaccsection, "proto", value);
return 0;
}
int set_x_bcm_com_ip_acc_list_cfgobj_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *ipaccsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(ipaccsection, "proto", value);
return 0;
}
return 0;
}
int get_x_bcm_com_ip_acc_list_cfgobj_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *ipaccsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(ipaccsection, "name", value);
return 0;
}
int set_x_bcm_com_ip_acc_list_cfgobj_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *ipaccsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(ipaccsection, "name", value);
return 0;
}
return 0;
}
int get_x_iopsys_eu_cfgobj_address_netmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_list *val;
struct uci_element *e = NULL;
struct uci_section *ipaccsection = (struct uci_section *)data;
struct uci_list *list = NULL;
dmuci_get_value_by_section_list(ipaccsection, "src_ip", &val);
if (val) {
*value = dmuci_list_to_string(val, ",");
}
else
*value = "";
if ((*value)[0] == '\0') {
*value = "0.0.0.0/0";
return 0;
}
return 0;
}
int set_x_iopsys_eu_cfgobj_address_netmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch, *spch, *val;
struct uci_section *ipaccsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_delete_by_section(ipaccsection, "src_ip", "");
val = dmstrdup(value);
pch = strtok_r(val, " ,", &spch);
while (pch != NULL) {
dmuci_add_list_value_by_section(ipaccsection, "src_ip", pch);
pch = strtok_r(NULL, " ,", &spch);
}
dmfree(val);
return 0;
}
return 0;
}
int get_x_bcm_com_ip_acc_list_cfgobj_acc_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *ipaccsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(ipaccsection, "dest_port", value);
return 0;
}
int set_x_bcm_com_ip_acc_list_cfgobj_acc_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *ipaccsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(ipaccsection, "dest_port", value);
return 0;
}
return 0;
}
int get_x_bcm_com_ip_acc_list_cfgobj_target(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *ipaccsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(ipaccsection, "target", value);
return 0;
}
int set_x_bcm_com_ip_acc_list_cfgobj_target(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *ipaccsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(ipaccsection, "target", value);
return 0;
}
return 0;
}
/*************************************************************************************
**** function related to get_cache_object_port_forwarding ****
**************************************************************************************/
int get_port_forwarding_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(forwardsection, "name", value);
return 0;
}
int set_port_forwarding_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(forwardsection, "name", value);
return 0;
}
return 0;
}
int get_port_forwarding_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(forwardsection, "enabled", value);
return 0;
}
int set_port_forwarding_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
int check;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section(forwardsection, "enabled", "1");
else
dmuci_set_value_by_section(forwardsection, "enabled", "0");
return 0;
}
return 0;
}
int get_port_forwarding_loopback(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(forwardsection, "reflection", value);
if((*value)[0] == '\0') {
*value = "1";
}
return 0;
}
int set_port_forwarding_loopback(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section(forwardsection, "reflection", "1");
else
dmuci_set_value_by_section(forwardsection, "reflection", "0");
return 0;
}
return 0;
}
int get_port_forwarding_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(forwardsection, "proto", value);
return 0;
}
int set_port_forwarding_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(forwardsection, "proto", value);
return 0;
}
return 0;
}
int get_port_forwarding_external_zone(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(forwardsection, "src", value);
return 0;
}
int set_port_forwarding_external_zone(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(forwardsection, "src", value);
return 0;
}
return 0;
}
int get_port_forwarding_internal_zone(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(forwardsection, "dest", value);
return 0;
}
int set_port_forwarding_internal_zone(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(forwardsection, "dest", value);
return 0;
}
return 0;
}
int get_port_forwarding_external_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(forwardsection, "src_dport", value);
return 0;
}
int set_port_forwarding_external_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(forwardsection, "src_dport", value);
return 0;
}
return 0;
}
int get_port_forwarding_internal_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(forwardsection, "dest_port", value);
if ((*value)[0] == '\0') {
*value = "any";
}
return 0;
}
int set_port_forwarding_internal_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
if (strcasecmp(value, "any") == 0) {
value = "";
}
dmuci_set_value_by_section(forwardsection, "dest_port", value);
return 0;
}
return 0;
}
int get_port_forwarding_source_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(forwardsection, "src_port", value);
if ((*value)[0] == '\0') {
*value = "any";
}
return 0;
}
int set_port_forwarding_source_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
if (strcasecmp(value, "any") == 0) {
value = "";
}
dmuci_set_value_by_section(forwardsection, "src_port", value);
return 0;
}
return 0;
}
int get_port_forwarding_internal_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(forwardsection, "dest_ip", value);
return 0;
}
int set_port_forwarding_internal_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(forwardsection, "dest_ip", value);
return 0;
}
return 0;
}
int get_port_forwarding_external_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(forwardsection, "src_dip", value);
if ((*value)[0] == '\0') {
*value = "any";
}
return 0;
}
int set_port_forwarding_external_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
if (strcasecmp(value, "any") == 0) {
value = "";
}
dmuci_set_value_by_section(forwardsection, "src_dip", value);
return 0;
}
return 0;
}
int get_port_forwarding_source_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_list *val;
struct uci_element *e = NULL;
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_list(forwardsection, "src_ip", &val);
if (val) {
*value = dmuci_list_to_string(val, ",");
}
else {
*value = "";
}
if ((*value)[0] == '\0') {
*value = "any";
}
return 0;
}
int set_port_forwarding_source_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch, *val, *spch;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
if (strcasecmp(value, "any") == 0) {
dmuci_delete_by_section(forwardsection, "src_ip", "");
}
else {
dmuci_delete_by_section(forwardsection, "src_ip", "");
val = dmstrdup(value);
pch = strtok_r(val, " ,", &spch);
while (pch != NULL) {
dmuci_add_list_value_by_section(forwardsection, "src_ip", pch);
pch = strtok_r(NULL, " ,", &spch);
}
dmfree(val);
}
return 0;
}
return 0;
}
int get_port_forwarding_src_mac(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_list *list = NULL;
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_list(forwardsection, "src_mac", &list);
*value = dmuci_list_to_string(list, " ");
return 0;
}
int set_port_forwarding_src_mac(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch, *spch;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_delete_by_section(forwardsection, "src_mac", NULL);
value = dmstrdup(value);
pch = strtok_r(value, " ", &spch);
while (pch != NULL) {
dmuci_add_list_value_by_section(forwardsection, "src_mac", pch);
pch = strtok_r(NULL, " ", &spch);
}
dmfree(value);
return 0;
}
return 0;
}
/***** ADD DEL OBJ *******/
int add_ipacccfg_rule(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
{
char *value, *v;
char *instance;
struct uci_section *rule = NULL, *dmmap_rule= NULL;
check_create_dmmap_package("dmmap_firewall");
instance = get_last_instance_icwmpd("dmmap_firewall", "rule", "fruleinstance");
dmuci_add_section_and_rename("firewall", "rule", &rule, &value);
dmuci_set_value_by_section(rule, "type", "generic");
dmuci_set_value_by_section(rule, "name", "new_rule");
dmuci_set_value_by_section(rule, "proto", "all");
dmuci_set_value_by_section(rule, "target", "ACCPET");
dmuci_set_value_by_section(rule, "family", "ipv4");
dmuci_set_value_by_section(rule, "enabled", "1");
dmuci_set_value_by_section(rule, "hidden", "1");
dmuci_set_value_by_section(rule, "parental", "0");
dmuci_add_section_icwmpd("dmmap_firewall", "rule", &dmmap_rule, &v);
dmuci_set_value_by_section(dmmap_rule, "section_name", section_name(rule));
*instancepara = update_instance_icwmpd(dmmap_rule, instance, "fruleinstance");
return 0;
}
int delete_ipacccfg_rule(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL;
struct uci_section *ss = NULL;
int found = 0;
struct uci_section *ipaccsection = (struct uci_section *)data;
struct uci_section *dmmap_section;
switch (del_action) {
case DEL_INST:
get_dmmap_section_of_config_section("dmmap_firewall", "rule", section_name(ipaccsection), &dmmap_section);
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ipaccsection, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_sections("firewall", "rule", s) {
if (found != 0){
get_dmmap_section_of_config_section("dmmap_firewall", "rule", section_name(s), &dmmap_section);
if(dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
ss = s;
found++;
}
if (ss != NULL){
get_dmmap_section_of_config_section("dmmap_firewall", "rule", section_name(ss), &dmmap_section);
if(dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
break;
}
return 0;
}
int add_ipacccfg_port_forwarding(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
{
char *value, *v;
char *instance;
struct uci_section *redirect = NULL, *dmmap_redirect= NULL;
check_create_dmmap_package("dmmap_firewall");
instance = get_last_instance_icwmpd("dmmap_firewall", "redirect", "forwardinstance");
dmuci_add_section_and_rename("firewall", "redirect", &redirect, &value);
dmuci_set_value_by_section(redirect, "enabled", "0");
dmuci_set_value_by_section(redirect, "target", "DNAT");
dmuci_set_value_by_section(redirect, "proto", "tcp udp");
dmuci_add_section_icwmpd("dmmap_firewall", "redirect", &dmmap_redirect, &v);
dmuci_set_value_by_section(dmmap_redirect, "section_name", section_name(redirect));
*instancepara = update_instance_icwmpd(dmmap_redirect, instance, "forwardinstance");
return 0;
}
int delete_ipacccfg_port_forwarding(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
int found = 0;
struct pforwardrgs *forwardargs;
struct uci_section *s = NULL;
struct uci_section *ss = NULL;
struct uci_section *forwardsection = (struct uci_section *)data;
struct uci_section *dmmap_section;
switch (del_action) {
case DEL_INST:
get_dmmap_section_of_config_section("dmmap_firewall", "redirect", section_name(forwardsection), &dmmap_section);
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(forwardsection, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_option_eq("firewall", "redirect", "target", "DNAT", s) {
if (found != 0){
get_dmmap_section_of_config_section("dmmap_firewall", "redirect", section_name(s), &dmmap_section);
if(dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
ss = s;
found++;
}
if (ss != NULL){
get_dmmap_section_of_config_section("dmmap_firewall", "redirect", section_name(ss), &dmmap_section);
if(dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
break;
}
return 0;
}
////////////////////////SET AND GET ALIAS/////////////////////////////////
int get_x_iopsys_eu_cfgobj_address_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *ipaccsection = (struct uci_section *)data;
struct uci_section *dmmap_section;
get_dmmap_section_of_config_section("dmmap_firewall", "rule", section_name(ipaccsection), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "frulealias", value);
return 0;
}
int set_x_iopsys_eu_cfgobj_address_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *ipaccsection = (struct uci_section *)data;
struct uci_section *dmmap_section;
get_dmmap_section_of_config_section("dmmap_firewall", "rule", section_name(ipaccsection), &dmmap_section);
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(dmmap_section, "frulealias", value);
return 0;
}
return 0;
}
int get_port_forwarding_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *forwardsection = (struct uci_section *)data;
struct uci_section *dmmap_section;
get_dmmap_section_of_config_section("dmmap_firewall", "redirect", section_name(forwardsection), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "forwardalias", value);
return 0;
}
int set_port_forwarding_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *forwardsection = (struct uci_section *)data;
struct uci_section *dmmap_section;
get_dmmap_section_of_config_section("dmmap_firewall", "redirect", section_name(forwardsection), &dmmap_section);
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(dmmap_section, "forwardalias", value);
return 0;
}
return 0;
}
int browseAccListInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *irule = NULL, *irule_last = NULL;
struct uci_section *s = NULL;
struct dmmap_dup *p;
LIST_HEAD(dup_list);
synchronize_specific_config_sections_with_dmmap("firewall", "rule", "dmmap_firewall", &dup_list);
list_for_each_entry(p, &dup_list, list) {
irule = handle_update_instance(1, dmctx, &irule_last, update_instance_alias_icwmpd, 3, p->dmmap_section, "fruleinstance", "frulealias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p->config_section, irule) == DM_STOP)
return 0;
}
free_dmmap_config_dup_list(&dup_list);
return 0;
}
int browseport_forwardingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *iforward = NULL, *iforward_last = NULL;
struct uci_section *s = NULL;
struct dmmap_dup *p;
LIST_HEAD(dup_list);
synchronize_specific_config_sections_with_dmmap_eq("firewall", "redirect", "dmmap_firewall", "target", "DNAT", &dup_list);
list_for_each_entry(p, &dup_list, list) {
iforward = handle_update_instance(1, dmctx, &iforward_last, update_instance_alias, 3, p->dmmap_section, "forwardinstance", "forwardalias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p->config_section, iforward) == DM_STOP)
break;
}
free_dmmap_config_dup_list(&dup_list);
return 0;
}

View file

@ -0,0 +1,76 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2015 Inteno Broadband Technology AB
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author Omar Kallel <omar.kallel@pivasoftware.com>
*
*/
#ifndef __SE_IPACCCFG_H
#define __SE_IPACCCFG_H
extern DMOBJ tSe_IpAccObj[];
extern DMLEAF tSe_IpAccCfgParam[];
extern DMLEAF tSe_PortForwardingParam[];
int browseport_forwardingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseAccListInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int add_ipacccfg_port_forwarding(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_ipacccfg_port_forwarding(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_ipacccfg_rule(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_ipacccfg_rule(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_port_forwarding_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_loopback(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_external_zone(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_internal_zone(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_external_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_internal_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_source_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_internal_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_external_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_source_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_src_mac(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_iopsys_eu_cfgobj_address_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_bcm_com_ip_acc_list_cfgobj_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_bcm_com_ip_acc_list_cfgobj_ipversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_bcm_com_ip_acc_list_cfgobj_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_bcm_com_ip_acc_list_cfgobj_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_iopsys_eu_cfgobj_address_netmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_bcm_com_ip_acc_list_cfgobj_acc_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_bcm_com_ip_acc_list_cfgobj_target(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_port_forwarding_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_loopback(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_external_zone(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_internal_zone(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_external_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_internal_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_source_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_internal_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_external_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_source_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_src_mac(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_iopsys_eu_cfgobj_address_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_bcm_com_ip_acc_list_cfgobj_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_bcm_com_ip_acc_list_cfgobj_ipversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_bcm_com_ip_acc_list_cfgobj_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_bcm_com_ip_acc_list_cfgobj_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_iopsys_eu_cfgobj_address_netmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_bcm_com_ip_acc_list_cfgobj_acc_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_bcm_com_ip_acc_list_cfgobj_target(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

View file

@ -0,0 +1,63 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2015 Inteno Broadband Technology AB
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
*
*/
#include <uci.h>
#include "dmcwmp.h"
#include "dmuci.h"
#include "dmubus.h"
#include "dmcommon.h"
#include "x_iopsys_eu_logincfg.h"
/*** DMROOT.X_IOPSYS_EU_LoginCfg. ***/
DMLEAF tSe_LoginCfgParam[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"AdminPassword", &DMWRITE, DMT_STRING, get_empty, set_x_bcm_admin_password, NULL, NULL, BBFDM_BOTH},
{"SupportPassword", &DMWRITE, DMT_STRING, get_empty, set_x_bcm_support_password, NULL, NULL, BBFDM_BOTH},
{"UserPassword", &DMWRITE, DMT_STRING, get_empty, set_x_bcm_user_password, NULL, NULL, BBFDM_BOTH},
{"RootPassword", &DMWRITE, DMT_STRING, get_empty, set_x_bcm_root_password, NULL, NULL, BBFDM_BOTH},
{0}
};
int set_x_bcm_password(char *refparam, struct dmctx *ctx, int action, char *value, char *user_type)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("passwords", user_type, "password", value);
return 0;
}
return 0;
}
int set_x_bcm_admin_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
set_x_bcm_password(refparam, ctx, action, value, "admin");
return 0;
}
int set_x_bcm_support_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
set_x_bcm_password(refparam, ctx, action, value, "support");
return 0;
}
int set_x_bcm_user_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
set_x_bcm_password(refparam, ctx, action, value, "user");
return 0;
}
int set_x_bcm_root_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
set_x_bcm_password(refparam, ctx, action, value, "root");
return 0;
}

View file

@ -0,0 +1,22 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2015 Inteno Broadband Technology AB
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
*
*/
#ifndef __SE_LOGINCFG_H
#define __SE_LOGINCFG_H
extern DMLEAF tSe_LoginCfgParam[];
int set_x_bcm_admin_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_bcm_support_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_bcm_user_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_bcm_root_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

View file

@ -0,0 +1,562 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2015 Inteno Broadband Technology AB
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author Omar Kallel <omar.kallel@pivasoftware.com>
*
*/
#include <uci.h>
#include <ctype.h>
#include "dmcwmp.h"
#include "dmuci.h"
#include "dmubus.h"
#include "dmcommon.h"
#include "dmentry.h"
#include "x_iopsys_eu_owsd.h"
/*** DMROOT.X_IOPSYS_EU_Owsd. ***/
DMLEAF XIopsysEuOwsdParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Socket", &DMWRITE, DMT_STRING, get_x_iopsys_eu_owsd_global_sock, set_x_iopsys_eu_owsd_global_sock, NULL, NULL, BBFDM_BOTH},
{"Redirect", &DMWRITE, DMT_STRING, get_x_iopsys_eu_owsd_global_redirect, set_x_iopsys_eu_owsd_global_redirect, NULL, NULL, BBFDM_BOTH},
{0}
};
DMOBJ XIopsysEuOwsdObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{CUSTOM_PREFIX"UbusProxy", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, UbusProxyParams, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"ListenObj", &DMWRITE, add_owsd_listen, delete_owsd_listen_instance, NULL, browseXIopsysEuOwsdListenObj, NULL, NULL, NULL, X_IOPSYS_EU_ListenObjParams, NULL, BBFDM_BOTH},
{0}
};
DMLEAF UbusProxyParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_x_iopsys_eu_owsd_ubus_proxy_enable, set_x_iopsys_eu_owsd_ubus_proxy_enable, NULL, NULL, BBFDM_BOTH},
{"UbusProxyCert", &DMWRITE, DMT_STRING, get_x_iopsys_eu_owsd_ubus_proxy_cert, set_x_iopsys_eu_owsd_ubus_proxy_cert, NULL, NULL, BBFDM_BOTH},
{"UbusProxyKey", &DMWRITE, DMT_STRING, get_x_iopsys_eu_owsd_ubus_proxy_key, set_x_iopsys_eu_owsd_ubus_proxy_key, NULL, NULL, BBFDM_BOTH},
{"UbusProxyCa", &DMWRITE, DMT_STRING, get_x_iopsys_eu_owsd_ubus_proxy_ca, set_x_iopsys_eu_owsd_ubus_proxy_ca, NULL, NULL, BBFDM_BOTH},
{0}
};
DMLEAF X_IOPSYS_EU_ListenObjParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Alias", &DMWRITE, DMT_STRING, get_x_iopsys_eu_owsd_listenobj_alias, set_x_iopsys_eu_owsd_listenobj_alias, NULL, NULL, BBFDM_BOTH},
{"Port", &DMWRITE, DMT_UNINT, get_x_iopsys_eu_owsd_listenobj_port, set_x_iopsys_eu_owsd_listenobj_port, NULL, NULL, BBFDM_BOTH},
{"Interface", &DMWRITE, DMT_STRING, get_x_iopsys_eu_owsd_listenobj_interface, set_x_iopsys_eu_owsd_listenobj_interface, NULL, NULL, BBFDM_BOTH},
{"Ipv6", &DMWRITE, DMT_BOOL, get_x_iopsys_eu_owsd_listenobj_ipv6_enable, set_x_iopsys_eu_owsd_listenobj_ipv6_enable, NULL, NULL, BBFDM_BOTH},
{"Whitelist_interface", &DMWRITE, DMT_BOOL, get_x_iopsys_eu_owsd_listenobj_whitelist_interface, set_x_iopsys_eu_owsd_listenobj_whitelist_interface, NULL, NULL, BBFDM_BOTH},
{"Whitelist_dhcp", &DMWRITE, DMT_BOOL, get_x_iopsys_eu_owsd_listenobj_whitelist_dhcp, set_x_iopsys_eu_owsd_listenobj_whitelist_dhcp, NULL, NULL, BBFDM_BOTH},
{"Origin", &DMWRITE, DMT_STRING, get_x_iopsys_eu_owsd_listenobj_origin, set_x_iopsys_eu_owsd_listenobj_origin, NULL, NULL, BBFDM_BOTH},
{"UbusCert", &DMWRITE, DMT_STRING, get_x_iopsys_eu_owsd_ubus_cert, set_x_iopsys_eu_owsd_ubus_cert, NULL, NULL, BBFDM_BOTH},
{"UbusKey", &DMWRITE, DMT_STRING, get_x_iopsys_eu_owsd_ubus_key, set_x_iopsys_eu_owsd_ubus_key, NULL, NULL, BBFDM_BOTH},
{"UbusCa", &DMWRITE, DMT_STRING, get_x_iopsys_eu_owsd_ubus_ca, set_x_iopsys_eu_owsd_ubus_ca, NULL, NULL, BBFDM_BOTH},
{0}
};
int browseXIopsysEuOwsdListenObj(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *iowsd_listen = NULL, *iowsd_listen_last = NULL;
struct uci_section *s = NULL;
struct dmmap_dup *p;
LIST_HEAD(dup_list);
synchronize_specific_config_sections_with_dmmap("owsd", "owsd-listen", "dmmap_owsd", &dup_list);
list_for_each_entry(p, &dup_list, list) {
iowsd_listen = handle_update_instance(1, dmctx, &iowsd_listen_last, update_instance_alias_icwmpd, 3, p->dmmap_section, "olisteninstance", "olistenalias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p->config_section, iowsd_listen) == DM_STOP)
break;
}
free_dmmap_config_dup_list(&dup_list);
return 0;
}
/*************************************************************************************
**** function related to owsd_origin ****
**************************************************************************************/
int get_x_iopsys_eu_owsd_global_sock(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("owsd", "global", "sock", value);
return 0;
}
int set_x_iopsys_eu_owsd_global_sock(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("owsd", "global", "sock", value);
return 0;
}
return 0;
}
int get_x_iopsys_eu_owsd_global_redirect(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("owsd", "global", "redirect", value);
return 0;
}
int set_x_iopsys_eu_owsd_global_redirect(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("owsd", "global", "redirect", value);
return 0;
}
return 0;
}
/*************************************************************************************
**** function related to owsd_listenobj ****
**************************************************************************************/
int get_x_iopsys_eu_owsd_listenobj_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *owsd_listensection = (struct uci_section *)data;
dmuci_get_value_by_section_string(owsd_listensection, "port", value);
if ((*value)[0] == '\0') {
*value = "";
}
return 0;
}
int set_x_iopsys_eu_owsd_listenobj_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *owsd_listensection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(owsd_listensection, "port", value);
return 0;
}
return 0;
}
int get_x_iopsys_eu_owsd_listenobj_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *iface;
struct uci_section *owsd_listensection = (struct uci_section *)data;
dmuci_get_value_by_section_string(owsd_listensection, "interface", &iface);
if (iface[0] != '\0') {
adm_entry_get_linker_param(ctx, dm_print_path("%s%cIP%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), iface, value); // MEM WILL BE FREED IN DMMEMCLEAN
if (*value == NULL)
*value = "";
}
return 0;
}
int set_x_iopsys_eu_owsd_listenobj_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *linker;
struct uci_section *owsd_listensection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
adm_entry_get_linker_value(ctx, value, &linker);
if (linker) {
dmuci_set_value_by_section(owsd_listensection, "interface", linker);
dmfree(linker);
}
return 0;
}
return 0;
}
int get_x_iopsys_eu_owsd_listenobj_ipv6_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *owsd_listensection = (struct uci_section *)data;
dmuci_get_value_by_section_string(owsd_listensection, "ipv6", value);
if ((*value)[0] != '\0' && (*value)[0] == 'o' && (*value)[1] == 'n' ) {
*value = "1";
}
else
*value = "0";
return 0;
}
int set_x_iopsys_eu_owsd_listenobj_ipv6_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
struct uci_section *owsd_listensection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section(owsd_listensection, "ipv6", "on");
else
dmuci_set_value_by_section(owsd_listensection, "ipv6", "off");
return 0;
}
return 0;
}
int get_x_iopsys_eu_owsd_listenobj_whitelist_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *owsd_listensection = (struct uci_section *)data;
dmuci_get_value_by_section_string(owsd_listensection, "whitelist_interface_as_origin", value);
if ((*value)[0] == '\0' ) {
*value = "0";
}
return 0;
}
int set_x_iopsys_eu_owsd_listenobj_whitelist_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
struct uci_section *owsd_listensection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section(owsd_listensection, "whitelist_interface_as_origin", "1");
else
dmuci_set_value_by_section(owsd_listensection, "whitelist_interface_as_origin", "0");
return 0;
}
return 0;
}
int get_x_iopsys_eu_owsd_listenobj_whitelist_dhcp(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *owsd_listensection = (struct uci_section *)data;
dmuci_get_value_by_section_string(owsd_listensection, "whitelist_dhcp_domains", value);
if ((*value)[0] == '\0') {
*value = "0";
}
return 0;
}
int set_x_iopsys_eu_owsd_listenobj_whitelist_dhcp(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
struct uci_section *owsd_listensection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section(owsd_listensection, "whitelist_dhcp_domains", "1");
else
dmuci_set_value_by_section(owsd_listensection, "whitelist_dhcp_domains", "0");
return 0;
}
return 0;
}
int get_x_iopsys_eu_owsd_listenobj_origin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_list *val;
struct uci_section *owsd_listensection = (struct uci_section *)data;
dmuci_get_value_by_section_list(owsd_listensection, "origin", &val);
if (val)
*value = dmuci_list_to_string(val, " ");
else
*value = "";
return 0;
}
int set_x_iopsys_eu_owsd_listenobj_origin(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch, *spch;
struct uci_section *owsd_listensection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_delete_by_section(owsd_listensection, "origin", NULL);
value = dmstrdup(value);
pch = strtok_r(value, " ", &spch);
while (pch != NULL) {
dmuci_add_list_value_by_section(owsd_listensection, "origin", pch);
pch = strtok_r(NULL, " ", &spch);
}
dmfree(value);
return 0;
}
return 0;
}
////////////////////////SET AND GET ALIAS/////////////////////////////////
int get_x_iopsys_eu_owsd_listenobj_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *owsd_listensection = (struct uci_section *)data;
struct uci_section *dmmap_section;
get_dmmap_section_of_config_section("dmmap_owsd", "owsd-listen", section_name(owsd_listensection), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "olistenalias", value);
return 0;
}
int set_x_iopsys_eu_owsd_listenobj_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *owsd_listensection = (struct uci_section *)data;
struct uci_section *dmmap_section;
get_dmmap_section_of_config_section("dmmap_owsd", "owsd-listen", section_name(owsd_listensection), &dmmap_section);
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(dmmap_section, "olistenalias", value);
return 0;
}
return 0;
}
int get_x_iopsys_eu_owsd_ubus_proxy_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("owsd","ubusproxy","enable", value);
return 0;
}
int set_x_iopsys_eu_owsd_ubus_proxy_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("owsd", "ubusproxy", "enable", value);
return 0;
}
return 0;
}
int get_x_iopsys_eu_owsd_ubus_proxy_cert(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("owsd","ubusproxy","peer_cert", value);
return 0;
}
int set_x_iopsys_eu_owsd_ubus_proxy_cert(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("owsd", "ubusproxy", "peer_cert", value);
return 0;
}
return 0;
}
int get_x_iopsys_eu_owsd_ubus_proxy_key(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("owsd","ubusproxy","peer_key", value);
return 0;
}
int set_x_iopsys_eu_owsd_ubus_proxy_key(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("owsd", "ubusproxy", "peer_key", value);
return 0;
}
return 0;
}
int get_x_iopsys_eu_owsd_ubus_proxy_ca(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("owsd","ubusproxy","peer_ca", value);
return 0;
}
int set_x_iopsys_eu_owsd_ubus_proxy_ca(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("owsd", "ubusproxy", "peer_ca", value);
return 0;
}
return 0;
}
int get_x_iopsys_eu_owsd_ubus_cert(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *owsd_listensection = (struct uci_section *)data;
char *net_cur_mode = NULL;
dmuci_get_option_value_string("netmode", "setup", "curmode", &net_cur_mode);
if(strstr(net_cur_mode, "repeater") || strstr(net_cur_mode, "extender")) {
dmuci_get_value_by_section_string(owsd_listensection, "cert", value);
}
return 0;
}
int set_x_iopsys_eu_owsd_ubus_cert(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *owsd_listensection = (struct uci_section *)data;
char *net_cur_mode = NULL;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_get_option_value_string("netmode", "setup", "curmode", &net_cur_mode);
if(strstr(net_cur_mode, "repeater") || strstr(net_cur_mode, "extender")){
if(strcmp(section_name(owsd_listensection), "wan_https")== 0)
dmuci_set_value_by_section(owsd_listensection, "cert", value);
}
return 0;
}
return 0;
}
int get_x_iopsys_eu_owsd_ubus_key(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *owsd_listensection = (struct uci_section *)data;
char *net_cur_mode= NULL;
dmuci_get_option_value_string("netmode", "setup", "curmode", &net_cur_mode);
if(strstr(net_cur_mode, "repeater") || strstr(net_cur_mode, "extender")) {
dmuci_get_value_by_section_string(owsd_listensection, "key", value);
}
return 0;
}
int set_x_iopsys_eu_owsd_ubus_key(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *owsd_listensection = (struct uci_section *)data;
char *net_cur_mode = NULL;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_get_option_value_string("netmode", "setup", "curmode", &net_cur_mode);
if(strstr(net_cur_mode, "repeater") || strstr(net_cur_mode, "extender")) {
if(strcmp(section_name(owsd_listensection), "wan_https")== 0)
dmuci_set_value_by_section(owsd_listensection, "key", value);
}
return 0;
}
return 0;
}
int get_x_iopsys_eu_owsd_ubus_ca(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *owsd_listensection = (struct uci_section *)data;
char *net_cur_mode = NULL;
dmuci_get_option_value_string("netmode", "setup", "curmode", &net_cur_mode);
if(strstr(net_cur_mode, "repeater") || strstr(net_cur_mode, "extender")){
dmuci_get_value_by_section_string(owsd_listensection, "ca", value);
}
return 0;
}
int set_x_iopsys_eu_owsd_ubus_ca(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *owsd_listensection = (struct uci_section *)data;
char *net_cur_mode = NULL;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_get_option_value_string("netmode", "setup", "curmode", &net_cur_mode);
if(strstr(net_cur_mode, "repeater") || strstr(net_cur_mode, "extender")) {
if(strcmp(section_name(owsd_listensection), "wan_https")== 0)
dmuci_set_value_by_section(owsd_listensection, "ca", value);
}
return 0;
}
return 0;
}
/***** ADD DEL OBJ *******/
int add_owsd_listen(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
{
char *value, *v;
char *instance;
struct uci_section *listen_sec = NULL, *dmmap_sec= NULL;
check_create_dmmap_package("dmmap_owsd");
instance = get_last_instance_icwmpd("dmmap_owsd", "owsd-listen", "olisteninstance");
dmuci_add_section("owsd", "owsd-listen", &listen_sec, &value);
dmuci_set_value_by_section(listen_sec, "ipv6", "on");
dmuci_set_value_by_section(listen_sec, "whitelist_interface_as_origin", "1");
dmuci_add_list_value_by_section(listen_sec, "origin", "*");
dmuci_add_section_icwmpd("dmmap_owsd", "owsd-listen", &dmmap_sec, &v);
dmuci_set_value_by_section(dmmap_sec, "section_name", section_name(listen_sec));
*instancepara = update_instance_icwmpd(dmmap_sec, instance, "olisteninstance");
return 0;
}
int delete_owsd_listen_instance(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL;
struct uci_section *ss = NULL;
struct uci_section *owsd_listensection = (struct uci_section *)data;
struct uci_section *dmmap_section;
int found = 0;
switch (del_action) {
case DEL_INST:
if(is_section_unnamed(section_name(owsd_listensection))){
LIST_HEAD(dup_list);
delete_sections_save_next_sections("dmmap_owsd", "owsd-listen", "olisteninstance", section_name(owsd_listensection), atoi(instance), &dup_list);
update_dmmap_sections(&dup_list, "olisteninstance", "dmmap_owsd", "owsd-listen");
dmuci_delete_by_section_unnamed(owsd_listensection, NULL, NULL);
} else {
get_dmmap_section_of_config_section("dmmap_owsd", "owsd-listen", section_name(owsd_listensection), &dmmap_section);
dmuci_delete_by_section_unnamed_icwmpd(dmmap_section, NULL, NULL);
dmuci_delete_by_section(owsd_listensection, NULL, NULL);
}
break;
case DEL_ALL:
uci_foreach_sections("owsd", "owsd-listen", s) {
if (found != 0){
get_dmmap_section_of_config_section("dmmap_owsd", "listen", section_name(s), &dmmap_section);
if(dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
ss = s;
found++;
}
if (ss != NULL){
get_dmmap_section_of_config_section("dmmap_owsd", "listen", section_name(ss), &dmmap_section);
if(dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
return 0;
}
return 0;
}

Some files were not shown because too many files have changed in this diff Show more