mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2026-03-11 11:38:34 +01:00
Add upnp, x_inteno_se_ice, x_inteno_se_igmp and x_inteno_se_wifi
This commit is contained in:
parent
7a4426fc80
commit
462eddb04e
11 changed files with 861 additions and 0 deletions
|
|
@ -13,6 +13,7 @@
|
|||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <dmcwmp.h>
|
||||
|
||||
char *cut_fx(char *str, char *delimiter, int occurence)
|
||||
{
|
||||
|
|
@ -24,4 +25,26 @@ char *cut_fx(char *str, char *delimiter, int occurence)
|
|||
pch = strtok(NULL, delimiter);
|
||||
}
|
||||
return pch;
|
||||
}
|
||||
|
||||
char *get_pid(char *pname)
|
||||
{
|
||||
FILE* f = NULL;
|
||||
char str[TAILLE_MAX] = "";
|
||||
char *v;
|
||||
f = popen(pname, "r");
|
||||
if (f != NULL)
|
||||
{
|
||||
fgets(str, TAILLE_MAX, f);
|
||||
if (str[0] == '\0') {
|
||||
pclose(f);
|
||||
return dmstrdup("");
|
||||
}
|
||||
pid_t pid = strtoul(str, NULL, 10);
|
||||
pclose(f);
|
||||
dmasprintf(&v, "%d", pid);
|
||||
return v;
|
||||
}
|
||||
v = dmstrdup("");
|
||||
return v;
|
||||
}
|
||||
|
|
@ -20,5 +20,6 @@ do { \
|
|||
} while(0)
|
||||
|
||||
char *cut_fx(char *str, char *delimiter, int occurence);
|
||||
char *get_pid(char *pname);
|
||||
|
||||
#endif
|
||||
|
|
@ -11,10 +11,14 @@
|
|||
#include "dmuci.h"
|
||||
#include "dmcwmp.h"
|
||||
#include "root.h"
|
||||
#include "upnp.h"
|
||||
#include "landevice.h"
|
||||
#include "wandevice.h"
|
||||
#include "deviceinfo.h"
|
||||
#include "managementserver.h"
|
||||
#include "x_inteno_se_igmp.h"
|
||||
#include "x_inteno_se_wifi.h"
|
||||
#include "x_inteno_se_ice.h"
|
||||
#include "x_inteno_se_power_mgmt.h"
|
||||
|
||||
static char *get_parameter_notification (char *param);
|
||||
|
|
@ -66,6 +70,10 @@ const struct prefix_method prefix_methods[] = {
|
|||
{ DMROOT"X_INTENO_SE_PowerManagement.", 0, &entry_method_root_X_INTENO_SE_PowerManagement },
|
||||
{ DMROOT"LANDevice.", 0, &entry_method_root_LANDevice },
|
||||
{ DMROOT"WANDevice.", 1, &entry_method_root_WANDevice },
|
||||
{ DMROOT"X_INTENO_SE_IGMP.", 0, &entry_method_root_X_INTENO_SE_IGMP },
|
||||
{ DMROOT"X_INTENO_SE_Wifi.", 0, &entry_method_root_SE_Wifi },
|
||||
{ DMROOT"X_INTENO_SE_ICE.", 0, &entry_method_root_X_INTENO_SE_Ice },
|
||||
{ DMROOT"UPnP.", 0, &entry_method_root_upnp },
|
||||
//{ DMROOT"Layer2Bridging.", &entry_method_root_Layer2Bridging },
|
||||
};
|
||||
|
||||
|
|
|
|||
79
dm/dmtree/upnp.c
Normal file
79
dm/dmtree/upnp.c
Normal 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 "upnp.h"
|
||||
|
||||
int get_upnp_enable(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string("upnpd","config","enabled", value);
|
||||
if (*value[0] == '\0') {
|
||||
dmfree(*value);
|
||||
*value = dmstrdup("1");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_upnp_enable(char *refparam, struct dmctx *ctx, int action, char *value)
|
||||
{
|
||||
bool b;
|
||||
int check;
|
||||
switch (action) {
|
||||
VALUECHECK:
|
||||
if (string_to_bool(value, &b))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
VALUESET:
|
||||
check = string_to_bool(value, &b);
|
||||
if (check == -1)
|
||||
return 0;
|
||||
if(b)
|
||||
dmuci_set_value("upnpd", "config", "enabled", "1");
|
||||
else
|
||||
dmuci_set_value("upnpd", "config", "enabled", "");
|
||||
//delay_service restart "miniupnpd" "1" //TODO
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_upnp_status(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
char *pname = dmstrdup("pidof miniupnpd");
|
||||
*value = get_pid(pname);
|
||||
|
||||
if (*value[0] == '\0') {
|
||||
*value = dmstrdup("Down");
|
||||
}
|
||||
else {
|
||||
*value = dmstrdup("Up");
|
||||
}
|
||||
dmfree(pname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int entry_method_root_upnp(struct dmctx *ctx)
|
||||
{
|
||||
IF_MATCH(ctx, DMROOT"UPnP.") {
|
||||
DMOBJECT(DMROOT"UPnP.", ctx, "0", 1, NULL, NULL, NULL);
|
||||
DMOBJECT(DMROOT"UPnP.Device.", ctx, "0", 1, NULL, NULL, NULL);
|
||||
DMPARAM("Enable", ctx, "1", get_upnp_enable, set_upnp_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
|
||||
DMPARAM("X_INTENO_SE_Status", ctx, "0", get_upnp_status, NULL, "", 0, 1, UNDEF, NULL);
|
||||
return 0;
|
||||
}
|
||||
return FAULT_9005;
|
||||
}
|
||||
9
dm/dmtree/upnp.h
Normal file
9
dm/dmtree/upnp.h
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef __UPNP_H
|
||||
#define __UPNP_H
|
||||
|
||||
int get_upnp_enable(char *refparam, struct dmctx *ctx, char **value);
|
||||
int set_upnp_enable(char *refparam, struct dmctx *ctx, int action, char *value);
|
||||
int get_upnp_status(char *refparam, struct dmctx *ctx, char **value);
|
||||
int entry_method_root_upnp(struct dmctx *ctx);
|
||||
|
||||
#endif
|
||||
94
dm/dmtree/x_inteno_se_ice.c
Normal file
94
dm/dmtree/x_inteno_se_ice.c
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* 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_inteno_se_ice.h"
|
||||
|
||||
int get_ice_cloud_enable(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string("ice", "cloud", "enabled", value);
|
||||
if (strcmp(*value, "1") == 0 || strcmp(*value, "true") == 0 || strcmp(*value, "yes") == 0 || strcmp(*value, "on") == 0) {
|
||||
dmfree(*value);
|
||||
*value = dmstrdup("true");
|
||||
}
|
||||
else if (strcmp(*value, "0") == 0 || strcmp(*value, "false") == 0 || strcmp(*value, "no") == 0 || strcmp(*value, "off") == 0) {
|
||||
dmfree(*value);
|
||||
*value = dmstrdup("false");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_ice_cloud_enable(char *refparam, struct dmctx *ctx, int action, char *value)
|
||||
{
|
||||
bool b;
|
||||
int check;
|
||||
|
||||
switch (action) {
|
||||
VALUECHECK:
|
||||
if (string_to_bool(value, &b))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
VALUESET:
|
||||
check = string_to_bool(value, &b);
|
||||
if(check == -1)
|
||||
return 0;
|
||||
if (b)
|
||||
dmuci_set_value("ice", "cloud", "enabled", "1");
|
||||
else
|
||||
dmuci_set_value("ice", "cloud", "enabled", "0");
|
||||
//check if *ice-client exit (if [ -f /etc/rc.d/*ice-client ])
|
||||
//delay_service restart "ice-client" "1" TODO
|
||||
}
|
||||
}
|
||||
|
||||
int get_ice_cloud_server(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string("ice", "cloud", "server", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_ice_cloud_server(char *refparam, struct dmctx *ctx, int action, char *value)
|
||||
{
|
||||
bool b;
|
||||
|
||||
switch (action) {
|
||||
VALUECHECK:
|
||||
if (string_to_bool(value, &b))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
VALUESET:
|
||||
if (value[0] == '\0')
|
||||
return 0;
|
||||
dmuci_set_value("ice", "cloud", "server", value);
|
||||
//check if *ice-client exit (if [ -f /etc/rc.d/*ice-client ])
|
||||
//delay_service restart "ice-client" "1" TODO
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int entry_method_root_X_INTENO_SE_Ice(struct dmctx *ctx)
|
||||
{
|
||||
IF_MATCH(ctx, DMROOT"X_INTENO_SE_ICE.") {
|
||||
DMOBJECT(DMROOT"X_INTENO_SE_ICE.", ctx, "0", 1, NULL, NULL, NULL);
|
||||
DMPARAM("Enable", ctx, "1", get_ice_cloud_enable, set_ice_cloud_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
|
||||
DMPARAM("Server", ctx, "1", get_ice_cloud_server, set_ice_cloud_server, "", 0, 1, UNDEF, NULL);
|
||||
return 0;
|
||||
}
|
||||
return FAULT_9005;
|
||||
}
|
||||
10
dm/dmtree/x_inteno_se_ice.h
Normal file
10
dm/dmtree/x_inteno_se_ice.h
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef __SE_ICE_H
|
||||
#define __SE_ICE_H
|
||||
|
||||
int get_ice_cloud_enable(char *refparam, struct dmctx *ctx, char **value);
|
||||
int set_ice_cloud_enable(char *refparam, struct dmctx *ctx, int action, char *value);
|
||||
int get_ice_cloud_server(char *refparam, struct dmctx *ctx, char **value);
|
||||
int set_ice_cloud_server(char *refparam, struct dmctx *ctx, int action, char *value);
|
||||
int entry_method_root_X_INTENO_SE_Ice(struct dmctx *ctx);
|
||||
|
||||
#endif
|
||||
491
dm/dmtree/x_inteno_se_igmp.c
Normal file
491
dm/dmtree/x_inteno_se_igmp.c
Normal file
|
|
@ -0,0 +1,491 @@
|
|||
/*
|
||||
* 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_inteno_se_igmp.h"
|
||||
|
||||
inline void compress_spaces(char *str)
|
||||
{
|
||||
char *dst = str;
|
||||
for (; *str; ++str) {
|
||||
*dst++ = *str;
|
||||
if (isspace(*str)) {
|
||||
do ++str;
|
||||
while (isspace(*str));
|
||||
--str;
|
||||
}
|
||||
}
|
||||
*dst = '\0';
|
||||
}
|
||||
|
||||
int get_igmp_dscp_mark(char *refparam, struct dmctx *ctx, 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, int action, char *value)
|
||||
{
|
||||
bool b;
|
||||
|
||||
switch (action) {
|
||||
VALUECHECK:
|
||||
if (string_to_bool(value, &b))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
VALUESET:
|
||||
dmuci_set_value("mcpd", "mcpd", "igmp_dscp_mark", value);
|
||||
//delay_service restart "mcpd" "1" TODO
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_igmp_proxy_interface(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_proxy_interfaces", value);
|
||||
//echo ${value// /,} TODO REPLACE SPACE BY ','
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_igmp_proxy_interface(char *refparam, struct dmctx *ctx, int action, char *value)
|
||||
{
|
||||
int i;
|
||||
bool b;
|
||||
|
||||
switch (action) {
|
||||
VALUECHECK:
|
||||
if (string_to_bool(value, &b))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
VALUESET:
|
||||
if (value[0] == '\0')
|
||||
return 0;
|
||||
int ln = strlen(value);
|
||||
for (i = 0; i< strlen(value); i++) {
|
||||
if (value[i] == ',') {
|
||||
value[i] = ' ';
|
||||
}
|
||||
}
|
||||
compress_spaces(value);
|
||||
dmuci_set_value("mcpd", "mcpd", "igmp_proxy_interfaces", value);
|
||||
//delay_service restart "mcpd" "1" //TODO
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_igmp_default_version(char *refparam, struct dmctx *ctx, 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, int action, char *value)
|
||||
{
|
||||
bool b;
|
||||
|
||||
switch (action) {
|
||||
VALUECHECK:
|
||||
if (string_to_bool(value, &b))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
VALUESET:
|
||||
dmuci_set_value("mcpd", "mcpd", "igmp_default_version", value);
|
||||
//delay_service restart "mcpd" "1" TODO
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_igmp_query_interval(char *refparam, struct dmctx *ctx, 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, int action, char *value)
|
||||
{
|
||||
bool b;
|
||||
|
||||
switch (action) {
|
||||
VALUECHECK:
|
||||
if (string_to_bool(value, &b))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
VALUESET:
|
||||
dmuci_set_value("mcpd", "mcpd", "igmp_query_interval", value);
|
||||
//delay_service restart "mcpd" "1" TODO
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_igmp_query_response_interval(char *refparam, struct dmctx *ctx, 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, int action, char *value)
|
||||
{
|
||||
bool b;
|
||||
|
||||
switch (action) {
|
||||
VALUECHECK:
|
||||
if (string_to_bool(value, &b))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
VALUESET:
|
||||
dmuci_set_value("mcpd", "mcpd", "igmp_query_response_interval", value);
|
||||
//delay_service restart "mcpd" "1" TODO
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_igmp_last_member_queryinterval(char *refparam, struct dmctx *ctx, 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, int action, char *value)
|
||||
{
|
||||
bool b;
|
||||
|
||||
switch (action) {
|
||||
VALUECHECK:
|
||||
if (string_to_bool(value, &b))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
VALUESET:
|
||||
dmuci_set_value("mcpd", "mcpd", "igmp_last_member_query_interval", value);
|
||||
//delay_service restart "mcpd" "1" TODO
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_igmp_robustness_value(char *refparam, struct dmctx *ctx, 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, int action, char *value)
|
||||
{
|
||||
bool b;
|
||||
|
||||
switch (action) {
|
||||
VALUECHECK:
|
||||
if (string_to_bool(value, &b))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
VALUESET:
|
||||
dmuci_set_value("mcpd", "mcpd", "igmp_robustness_value", value);
|
||||
//delay_service restart "mcpd" "1" TODO
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_igmp_multicast_enable(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_lan_to_lan_multicast", value);
|
||||
if ((*value)[0] == '\0') {
|
||||
dmfree(*value);
|
||||
*value = dmstrdup("0");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_igmp_multicast_enable(char *refparam, struct dmctx *ctx, int action, char *value)
|
||||
{
|
||||
bool b;
|
||||
int check;
|
||||
|
||||
switch (action) {
|
||||
VALUECHECK:
|
||||
if (string_to_bool(value, &b))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
VALUESET:
|
||||
if (check == -1)
|
||||
return 0;
|
||||
if (b)
|
||||
dmuci_set_value("mcpd", "mcpd", "igmp_lan_to_lan_multicast", value);
|
||||
else
|
||||
dmuci_set_value("mcpd", "mcpd", "igmp_lan_to_lan_multicast", "");
|
||||
//delay_service restart "mcpd" "1" //TODO
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_igmp_fastleave_enable(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_fast_leave", value);
|
||||
if ((*value)[0] == '\0') {
|
||||
dmfree(*value);
|
||||
*value = dmstrdup("0");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_igmp_fastleave_enable(char *refparam, struct dmctx *ctx, int action, char *value)
|
||||
{
|
||||
bool b;
|
||||
int check;
|
||||
|
||||
switch (action) {
|
||||
VALUECHECK:
|
||||
if (string_to_bool(value, &b))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
VALUESET:
|
||||
check = string_to_bool(value, &b);
|
||||
if (check == -1)
|
||||
return 0;
|
||||
if (b)
|
||||
dmuci_set_value("mcpd", "mcpd", "igmp_fast_leave", value);
|
||||
else
|
||||
dmuci_set_value("mcpd", "mcpd", "igmp_fast_leave", "");
|
||||
//delay_service restart "mcpd" "1" //TODO
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_igmp_joinimmediate_enable(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_join_immediate", value);
|
||||
if ((*value)[0] == '\0') {
|
||||
dmfree(*value);
|
||||
*value = dmstrdup("0");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_igmp_joinimmediate_enable(char *refparam, struct dmctx *ctx, int action, char *value)
|
||||
{
|
||||
bool b;
|
||||
int check;
|
||||
|
||||
switch (action) {
|
||||
VALUECHECK:
|
||||
if (string_to_bool(value, &b))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
VALUESET:
|
||||
check = string_to_bool(value, &b);
|
||||
if (check == -1)
|
||||
return 0;
|
||||
if (b)
|
||||
dmuci_set_value("mcpd", "mcpd", "igmp_join_immediate", value);
|
||||
else
|
||||
dmuci_set_value("mcpd", "mcpd", "igmp_join_immediate", "");
|
||||
//delay_service restart "mcpd" "1" //TODO
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_igmp_proxy_enable(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_proxy_enable", value);
|
||||
if ((*value)[0] == '\0') {
|
||||
dmfree(*value);
|
||||
*value = dmstrdup("0");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_igmp_proxy_enable(char *refparam, struct dmctx *ctx, int action, char *value)
|
||||
{
|
||||
bool b;
|
||||
int check;
|
||||
|
||||
switch (action) {
|
||||
VALUECHECK:
|
||||
if (string_to_bool(value, &b))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
VALUESET:
|
||||
check = string_to_bool(value, &b);
|
||||
if (check == -1)
|
||||
return 0;
|
||||
if (b)
|
||||
dmuci_set_value("mcpd", "mcpd", "igmp_proxy_enable", value);
|
||||
else
|
||||
dmuci_set_value("mcpd", "mcpd", "igmp_proxy_enable", "");
|
||||
//delay_service restart "mcpd" "1" //TODO
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_igmp_maxgroup(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_max_groups", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_igmp_maxgroup(char *refparam, struct dmctx *ctx, int action, char *value)
|
||||
{
|
||||
bool b;
|
||||
|
||||
switch (action) {
|
||||
VALUECHECK:
|
||||
if (string_to_bool(value, &b))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
VALUESET:
|
||||
dmuci_set_value("mcpd", "mcpd", "igmp_max_groups", value);
|
||||
//delay_service restart "mcpd" "1" TODO
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_igmp_maxsources(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_max_sources", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_igmp_maxsources(char *refparam, struct dmctx *ctx, int action, char *value)
|
||||
{
|
||||
bool b;
|
||||
|
||||
switch (action) {
|
||||
VALUECHECK:
|
||||
if (string_to_bool(value, &b))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
VALUESET:
|
||||
dmuci_set_value("mcpd", "mcpd", "igmp_max_sources", value);
|
||||
//delay_service restart "mcpd" "1" TODO
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_igmp_maxmembers(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_max_members", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_igmp_maxmembers(char *refparam, struct dmctx *ctx, int action, char *value)
|
||||
{
|
||||
bool b;
|
||||
|
||||
switch (action) {
|
||||
VALUECHECK:
|
||||
if (string_to_bool(value, &b))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
VALUESET:
|
||||
dmuci_set_value("mcpd", "mcpd", "igmp_max_members", value);
|
||||
//delay_service restart "mcpd" "1" TODO
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_igmp_snooping_mode(char *refparam, struct dmctx *ctx, 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, int action, char *value)
|
||||
{
|
||||
bool b;
|
||||
|
||||
switch (action) {
|
||||
VALUECHECK:
|
||||
if (string_to_bool(value, &b))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
VALUESET:
|
||||
dmuci_set_value("mcpd", "mcpd", "igmp_snooping_enable", value);
|
||||
//delay_service restart "mcpd" "1" TODO
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_igmp_snooping_interface(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_snooping_interfaces", value);
|
||||
// echo ${value// /,} TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_igmp_snooping_interface(char *refparam, struct dmctx *ctx, int action, char *value)
|
||||
{
|
||||
bool b;
|
||||
int i;
|
||||
|
||||
switch (action) {
|
||||
VALUECHECK:
|
||||
if (string_to_bool(value, &b))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
VALUESET:
|
||||
if (value[0] == '\0')
|
||||
return 0;
|
||||
int ln = strlen(value);
|
||||
for (i = 0; i< strlen(value); i++) {
|
||||
if (value[i] == ',') {
|
||||
value[i] = ' ';
|
||||
}
|
||||
}
|
||||
compress_spaces(value);
|
||||
dmuci_set_value("mcpd", "mcpd", "igmp_snooping_interfaces", value);
|
||||
//delay_service restart "mcpd" "1" //TODO
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int entry_method_root_X_INTENO_SE_IGMP(struct dmctx *ctx)
|
||||
{
|
||||
IF_MATCH(ctx, DMROOT"X_INTENO_SE_IGMP.") {
|
||||
DMOBJECT(DMROOT"X_INTENO_SE_IGMP.", ctx, "0", 1, NULL, NULL, NULL);
|
||||
DMPARAM("DifferentiateService", ctx, "1", get_igmp_dscp_mark, set_igmp_dscp_mark, "", 0, 1, UNDEF, NULL);
|
||||
DMPARAM("ProxyInterface", ctx, "1", get_igmp_proxy_interface, set_igmp_proxy_interface, "", 0, 1, UNDEF, NULL);
|
||||
DMPARAM("DefaultVersion", ctx, "1", get_igmp_default_version, set_igmp_default_version, "", 0, 1, UNDEF, NULL);
|
||||
DMPARAM("QueryInterval", ctx, "1", get_igmp_query_interval, set_igmp_query_interval, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
|
||||
DMPARAM("QueryResponseInterval", ctx, "1", get_igmp_query_response_interval, set_igmp_query_response_interval, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
|
||||
DMPARAM("LastMemberQueryInterval", ctx, "1", get_igmp_last_member_queryinterval, set_igmp_last_member_queryinterval, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
|
||||
DMPARAM("RobustnessValue", ctx, "1", get_igmp_robustness_value, set_igmp_robustness_value, "xsd:int", 0, 1, UNDEF, NULL);
|
||||
DMPARAM("LanToLanMulticastEnable", ctx, "1", get_igmp_multicast_enable, set_igmp_multicast_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
|
||||
DMPARAM("MaxGroup", ctx, "1", get_igmp_maxgroup, set_igmp_maxgroup, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
|
||||
DMPARAM("MaxSources", ctx, "1", get_igmp_maxsources, set_igmp_maxsources, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
|
||||
DMPARAM("MaxMembers", ctx, "1", get_igmp_maxmembers, set_igmp_maxmembers, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
|
||||
DMPARAM("FastLeaveEnable", ctx, "1", get_igmp_fastleave_enable, set_igmp_fastleave_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
|
||||
DMPARAM("JoinImmediateEnable", ctx, "1", get_igmp_joinimmediate_enable, set_igmp_joinimmediate_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
|
||||
DMPARAM("ProxyEnable", ctx, "1", get_igmp_proxy_enable, set_igmp_proxy_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
|
||||
DMPARAM("SnoopingMode", ctx, "1", get_igmp_snooping_mode, set_igmp_snooping_mode, "", 0, 1, UNDEF, NULL);
|
||||
DMPARAM("SnoopingInterfaces", ctx, "1", get_igmp_snooping_interface, set_igmp_snooping_interface, "", 0, 1, UNDEF, NULL);
|
||||
return 0;
|
||||
}
|
||||
return FAULT_9005;
|
||||
}
|
||||
39
dm/dmtree/x_inteno_se_igmp.h
Normal file
39
dm/dmtree/x_inteno_se_igmp.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#ifndef __SE_IGMP_H
|
||||
#define __SE_IGMP_H
|
||||
|
||||
inline void compress_spaces(char *str);
|
||||
int get_igmp_dscp_mark(char *refparam, struct dmctx *ctx, char **value);
|
||||
int set_igmp_dscp_mark(char *refparam, struct dmctx *ctx, int action, char *value);
|
||||
int get_igmp_proxy_interface(char *refparam, struct dmctx *ctx, char **value);
|
||||
int set_igmp_proxy_interface(char *refparam, struct dmctx *ctx, int action, char *value);
|
||||
int get_igmp_default_version(char *refparam, struct dmctx *ctx, char **value);
|
||||
int set_igmp_default_version(char *refparam, struct dmctx *ctx, int action, char *value);
|
||||
int get_igmp_query_interval(char *refparam, struct dmctx *ctx, char **value);
|
||||
int set_igmp_query_interval(char *refparam, struct dmctx *ctx, int action, char *value);
|
||||
int get_igmp_query_response_interval(char *refparam, struct dmctx *ctx, char **value);
|
||||
int set_igmp_query_response_interval(char *refparam, struct dmctx *ctx, int action, char *value);
|
||||
int get_igmp_last_member_queryinterval(char *refparam, struct dmctx *ctx, char **value);
|
||||
int set_igmp_last_member_queryinterval(char *refparam, struct dmctx *ctx, int action, char *value);
|
||||
int get_igmp_robustness_value(char *refparam, struct dmctx *ctx, char **value);
|
||||
int set_igmp_robustness_value(char *refparam, struct dmctx *ctx, int action, char *value);
|
||||
int get_igmp_multicast_enable(char *refparam, struct dmctx *ctx, char **value);
|
||||
int set_igmp_multicast_enable(char *refparam, struct dmctx *ctx, int action, char *value);
|
||||
int get_igmp_fastleave_enable(char *refparam, struct dmctx *ctx, char **value);
|
||||
int set_igmp_fastleave_enable(char *refparam, struct dmctx *ctx, int action, char *value);
|
||||
int get_igmp_joinimmediate_enable(char *refparam, struct dmctx *ctx, char **value);
|
||||
int set_igmp_joinimmediate_enable(char *refparam, struct dmctx *ctx, int action, char *value);
|
||||
int get_igmp_proxy_enable(char *refparam, struct dmctx *ctx, char **value);
|
||||
int set_igmp_proxy_enable(char *refparam, struct dmctx *ctx, int action, char *value);
|
||||
int get_igmp_maxgroup(char *refparam, struct dmctx *ctx, char **value);
|
||||
int set_igmp_maxgroup(char *refparam, struct dmctx *ctx, int action, char *value);
|
||||
int get_igmp_maxsources(char *refparam, struct dmctx *ctx, char **value);
|
||||
int set_igmp_maxsources(char *refparam, struct dmctx *ctx, int action, char *value);
|
||||
int get_igmp_maxmembers(char *refparam, struct dmctx *ctx, char **value);
|
||||
int set_igmp_maxmembers(char *refparam, struct dmctx *ctx, int action, char *value);
|
||||
int get_igmp_snooping_mode(char *refparam, struct dmctx *ctx, char **value);
|
||||
int set_igmp_snooping_mode(char *refparam, struct dmctx *ctx, int action, char *value);
|
||||
int get_igmp_snooping_interface(char *refparam, struct dmctx *ctx, char **value);
|
||||
int set_igmp_snooping_interface(char *refparam, struct dmctx *ctx, int action, char *value);
|
||||
int entry_method_root_X_INTENO_SE_IGMP(struct dmctx *ctx);
|
||||
|
||||
#endif
|
||||
92
dm/dmtree/x_inteno_se_wifi.c
Normal file
92
dm/dmtree/x_inteno_se_wifi.c
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* 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_inteno_se_wifi.h"
|
||||
|
||||
struct sewifiargs cur_wifiargs = {0};
|
||||
|
||||
inline int init_se_wifi(struct dmctx *ctx, struct uci_section *s)
|
||||
{
|
||||
struct sewifiargs *args = &cur_wifiargs;
|
||||
ctx->args = (void *)args;
|
||||
args->sewifisection = s;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_wifi_frequency(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
struct sewifiargs *wifiargs = (struct sewifiargs *)ctx->args;
|
||||
char *lan_name = dmstrdup(section_name(wifiargs->sewifisection));
|
||||
|
||||
*value = dmstrdup("wlctl -i lan_name status |awk '$1==\"Chanspec:\" {print$2}'");//TODO
|
||||
dmfree(lan_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_wifi_maxassoc(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
struct sewifiargs *wifiargs = (struct sewifiargs *)ctx->args;
|
||||
|
||||
dmuci_get_value_by_section_string(wifiargs->sewifisection, "maxassoc", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_wifi_maxassoc(char *refparam, struct dmctx *ctx, int action, char *value)
|
||||
{
|
||||
bool b;
|
||||
struct sewifiargs *wifiargs = (struct sewifiargs *)ctx->args;
|
||||
|
||||
switch (action) {
|
||||
VALUECHECK:
|
||||
if (string_to_bool(value, &b))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
VALUESET:
|
||||
dmuci_set_value_by_section(wifiargs->sewifisection, "maxassoc", value);
|
||||
// delay_service reload "network" "1" TODO
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int entry_method_root_SE_Wifi(struct dmctx *ctx)
|
||||
{
|
||||
char *wnum;
|
||||
struct uci_section *s = NULL;
|
||||
|
||||
IF_MATCH(ctx, DMROOT"X_INTENO_SE_Wifi.") {
|
||||
DMOBJECT(DMROOT"X_INTENO_SE_Wifi.", ctx, "0", 1, NULL, NULL, NULL);
|
||||
DMOBJECT(DMROOT"X_INTENO_SE_Wifi.Radio.", ctx, "0", 1, NULL, NULL, NULL);
|
||||
uci_foreach_sections("wireless", "wifi-device", s) {
|
||||
if (s != NULL) {
|
||||
init_se_wifi(ctx, s);
|
||||
wnum = section_name(s);
|
||||
wnum += 2;
|
||||
dmasprintf(&wnum, "%d", atoi(wnum) + 1);
|
||||
DMOBJECT(DMROOT"X_INTENO_SE_Wifi.Radio.%s.", ctx, "0", 1, NULL, NULL, NULL, wnum);
|
||||
DMPARAM("Frequency", ctx, "0", get_wifi_frequency, NULL, "", 0, 1, UNDEF, NULL);
|
||||
DMPARAM("MaxAssociations", ctx, "1", get_wifi_maxassoc, set_wifi_maxassoc, "", 0, 1, UNDEF, NULL);
|
||||
dmfree(wnum);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return FAULT_9005;
|
||||
}
|
||||
15
dm/dmtree/x_inteno_se_wifi.h
Normal file
15
dm/dmtree/x_inteno_se_wifi.h
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef __SE_WIFI_H
|
||||
#define __SE_WIFI_H
|
||||
|
||||
struct sewifiargs
|
||||
{
|
||||
struct uci_section *sewifisection;
|
||||
};
|
||||
|
||||
inline int init_se_wifi(struct dmctx *ctx, struct uci_section *s);
|
||||
int get_wifi_frequency(char *refparam, struct dmctx *ctx, char **value);
|
||||
int get_wifi_maxassoc(char *refparam, struct dmctx *ctx, char **value);
|
||||
int set_wifi_maxassoc(char *refparam, struct dmctx *ctx, int action, char *value);
|
||||
int entry_method_root_SE_Wifi(struct dmctx *ctx);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Reference in a new issue