mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
Ticket refs #3539: bbf: the setting of Interface param has no effect on diagnostic objects
This commit is contained in:
parent
8ba74d624b
commit
a83984d914
15 changed files with 252 additions and 208 deletions
|
|
@ -46,7 +46,7 @@ void apply_end_session()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bbf_set_end_session_flag (struct dmctx *ctx, unsigned int flag)
|
void bbf_set_end_session_flag(struct dmctx *ctx, unsigned int flag)
|
||||||
{
|
{
|
||||||
ctx->end_session_flag |= flag;
|
ctx->end_session_flag |= flag;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
124
dmdiagnostics.c
124
dmdiagnostics.c
|
|
@ -10,6 +10,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <libtrace.h>
|
#include <libtrace.h>
|
||||||
|
#include "dmentry.h"
|
||||||
#include "dmdiagnostics.h"
|
#include "dmdiagnostics.h"
|
||||||
|
|
||||||
int read_next;
|
int read_next;
|
||||||
|
|
@ -41,12 +42,44 @@ void set_diagnostics_option(char *sec_name, char *option, char *value)
|
||||||
dmuci_set_value_bbfdm(DMMAP_DIAGNOSTIGS, sec_name, option, value);
|
dmuci_set_value_bbfdm(DMMAP_DIAGNOSTIGS, sec_name, option, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_download_stats(void)
|
void init_diagnostics_operation(char *sec_name, char *operation_path)
|
||||||
|
{
|
||||||
|
struct uci_section *section = NULL;
|
||||||
|
|
||||||
|
check_create_dmmap_package(DMMAP_DIAGNOSTIGS);
|
||||||
|
section = dmuci_walk_section_bbfdm(DMMAP_DIAGNOSTIGS, sec_name, NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
|
||||||
|
if (section)
|
||||||
|
dmuci_delete_by_section_bbfdm(section, NULL, NULL);
|
||||||
|
|
||||||
|
DMCMD("/bin/sh", 2, operation_path, "stop");
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_diagnostics_interface_option(struct dmctx *ctx, char *sec_name, char *value)
|
||||||
|
{
|
||||||
|
char interface[64] = {0}, *linker = NULL;
|
||||||
|
|
||||||
|
if (value[0] == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
append_dot_to_string(interface, value, sizeof(interface));
|
||||||
|
|
||||||
|
if (strncmp(interface, "Device.IP.Interface.", 20) != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
adm_entry_get_linker_value(ctx, interface, &linker);
|
||||||
|
|
||||||
|
if (linker && *linker) {
|
||||||
|
set_diagnostics_option(sec_name, "interface", linker);
|
||||||
|
dmfree(linker);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void init_download_stats(void)
|
||||||
{
|
{
|
||||||
memset(&download_stats, 0, sizeof(download_stats));
|
memset(&download_stats, 0, sizeof(download_stats));
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_upload_stats(void)
|
static void init_upload_stats(void)
|
||||||
{
|
{
|
||||||
memset(&upload_stats, 0, sizeof(upload_stats));
|
memset(&upload_stats, 0, sizeof(upload_stats));
|
||||||
}
|
}
|
||||||
|
|
@ -249,34 +282,22 @@ static void set_download_stats(char *protocol)
|
||||||
{
|
{
|
||||||
char buf[16] = {0};
|
char buf[16] = {0};
|
||||||
|
|
||||||
if (strcmp(protocol, "cwmp")== 0)
|
set_diagnostics_option("download", "ROMtime", ((download_stats.romtime)[0] != 0) ? download_stats.romtime : "0001-01-01T00:00:00.000000Z");
|
||||||
alloc_uci_ctx_bbfdm();
|
set_diagnostics_option("download", "BOMtime", ((download_stats.bomtime)[0] != 0) ? download_stats.bomtime : "0001-01-01T00:00:00.000000Z");
|
||||||
|
set_diagnostics_option("download", "EOMtime", ((download_stats.eomtime)[0] != 0) ? download_stats.eomtime : "0001-01-01T00:00:00.000000Z");
|
||||||
set_diagnostics_option("download", "ROMtime", download_stats.romtime);
|
set_diagnostics_option("download", "TCPOpenRequestTime", ((download_stats.tcpopenrequesttime)[0] != 0) ? download_stats.tcpopenrequesttime : "0001-01-01T00:00:00.000000Z");
|
||||||
set_diagnostics_option("download", "BOMtime", download_stats.bomtime);
|
set_diagnostics_option("download", "TCPOpenResponseTime",((download_stats.tcpopenresponsetime)[0] != 0) ? download_stats.tcpopenresponsetime : "0001-01-01T00:00:00.000000Z");
|
||||||
set_diagnostics_option("download", "EOMtime", download_stats.eomtime);
|
|
||||||
set_diagnostics_option("download", "TCPOpenRequestTime", download_stats.tcpopenrequesttime);
|
|
||||||
set_diagnostics_option("download", "TCPOpenResponseTime", download_stats.tcpopenresponsetime);
|
|
||||||
snprintf(buf, sizeof(buf), "%d", download_stats.test_bytes_received);
|
snprintf(buf, sizeof(buf), "%d", download_stats.test_bytes_received);
|
||||||
set_diagnostics_option("download", "TestBytesReceived", buf);
|
set_diagnostics_option("download", "TestBytesReceived", buf);
|
||||||
|
|
||||||
if (strcmp(protocol, "cwmp")== 0)
|
|
||||||
commit_and_free_uci_ctx_bbfdm(DMMAP_DIAGNOSTIGS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_upload_stats(char *protocol)
|
static void set_upload_stats(char *protocol)
|
||||||
{
|
{
|
||||||
if (strcmp(protocol, "cwmp")== 0)
|
set_diagnostics_option("upload", "ROMtime", ((upload_stats.romtime)[0] != 0) ? upload_stats.romtime : "0001-01-01T00:00:00.000000Z");
|
||||||
alloc_uci_ctx_bbfdm();
|
set_diagnostics_option("upload", "BOMtime", ((upload_stats.bomtime)[0] != 0) ? upload_stats.bomtime : "0001-01-01T00:00:00.000000Z");
|
||||||
|
set_diagnostics_option("upload", "EOMtime", ((upload_stats.eomtime)[0] != 0) ? upload_stats.eomtime : "0001-01-01T00:00:00.000000Z");
|
||||||
set_diagnostics_option("upload", "ROMtime", upload_stats.romtime);
|
set_diagnostics_option("upload", "TCPOpenRequestTime", ((upload_stats.tcpopenrequesttime)[0] != 0) ? upload_stats.tcpopenrequesttime : "0001-01-01T00:00:00.000000Z");
|
||||||
set_diagnostics_option("upload", "BOMtime", upload_stats.bomtime);
|
set_diagnostics_option("upload", "TCPOpenResponseTime", ((upload_stats.tcpopenresponsetime)[0] != 0) ? upload_stats.tcpopenresponsetime : "0001-01-01T00:00:00.000000Z");
|
||||||
set_diagnostics_option("upload", "EOMtime", upload_stats.eomtime);
|
|
||||||
set_diagnostics_option("upload", "TCPOpenRequestTime", upload_stats.tcpopenrequesttime);
|
|
||||||
set_diagnostics_option("upload", "TCPOpenResponseTime", upload_stats.tcpopenresponsetime);
|
|
||||||
|
|
||||||
if (strcmp(protocol, "cwmp")== 0)
|
|
||||||
commit_and_free_uci_ctx_bbfdm(DMMAP_DIAGNOSTIGS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void http_upload_per_packet(libtrace_packet_t *packet)
|
static void http_upload_per_packet(libtrace_packet_t *packet)
|
||||||
|
|
@ -472,7 +493,7 @@ static void ftp_upload_per_packet(libtrace_packet_t *packet)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int extract_stats(char *dump_file, int proto, int diagnostic_type, char *protocol)
|
static int extract_stats(char *dump_file, int proto, int diagnostic_type, char *protocol)
|
||||||
{
|
{
|
||||||
libtrace_t *trace = NULL;
|
libtrace_t *trace = NULL;
|
||||||
libtrace_packet_t *packet = NULL;
|
libtrace_packet_t *packet = NULL;
|
||||||
|
|
@ -536,52 +557,55 @@ int extract_stats(char *dump_file, int proto, int diagnostic_type, char *protoco
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_default_gateway_device(char **gw)
|
static char *get_default_gateway_device(void)
|
||||||
{
|
{
|
||||||
FILE *f = fopen("/proc/net/route" , "r");
|
char *device = "";
|
||||||
|
|
||||||
|
FILE *f = fopen(ROUTING_FILE, "r");
|
||||||
if (f != NULL) {
|
if (f != NULL) {
|
||||||
char line[100], *p, *c, *saveptr;
|
char line[100], *p, *c, *saveptr;
|
||||||
while(fgets(line , 100 , f)) {
|
while(fgets(line , 100 , f)) {
|
||||||
p = strtok_r(line, " \t", &saveptr);
|
p = strtok_r(line, " \t", &saveptr);
|
||||||
c = strtok_r(NULL, " \t", &saveptr);
|
c = strtok_r(NULL, " \t", &saveptr);
|
||||||
if (p!=NULL && c!=NULL) {
|
if (p && c && strcmp(c, "00000000") == 0) {
|
||||||
if (strcmp(c, "00000000") == 0) {
|
device = dmstrdup(p);
|
||||||
dmasprintf(gw, "%s", p);
|
break;
|
||||||
fclose(f);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
return -1;
|
|
||||||
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
int start_upload_download_diagnostic(int diagnostic_type)
|
int start_upload_download_diagnostic(int diagnostic_type, char *proto)
|
||||||
{
|
{
|
||||||
char *url, *interface, *size, *status;
|
char *url, *interface, *device, *size, *status;
|
||||||
int error;
|
|
||||||
|
|
||||||
if (diagnostic_type == DOWNLOAD_DIAGNOSTIC) {
|
if (diagnostic_type == DOWNLOAD_DIAGNOSTIC) {
|
||||||
url = get_diagnostics_option("download", "url");
|
url = get_diagnostics_option("download", "url");
|
||||||
interface = get_diagnostics_option("download", "device");
|
interface = get_diagnostics_option("download", "interface");
|
||||||
} else {
|
} else {
|
||||||
url = get_diagnostics_option("upload", "url");
|
url = get_diagnostics_option("upload", "url");
|
||||||
size = get_diagnostics_option("upload", "TestFileLength");
|
size = get_diagnostics_option("upload", "TestFileLength");
|
||||||
interface = get_diagnostics_option("upload", "device");
|
interface = get_diagnostics_option("upload", "interface");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interface[0] == '\0') {
|
if ((url[0] == '\0') ||
|
||||||
error = get_default_gateway_device(&interface);
|
(strncmp(url, DOWNLOAD_UPLOAD_PROTOCOL_HTTP, strlen(DOWNLOAD_UPLOAD_PROTOCOL_HTTP)) != 0 &&
|
||||||
if (error == -1)
|
strncmp(url, DOWNLOAD_UPLOAD_PROTOCOL_FTP, strlen(DOWNLOAD_UPLOAD_PROTOCOL_FTP)) != 0 &&
|
||||||
return -1;
|
strstr(url,"@") != NULL))
|
||||||
}
|
return -1;
|
||||||
|
|
||||||
|
device = (interface && *interface) ? get_device(interface) : get_default_gateway_device();
|
||||||
|
if (device[0] == '\0')
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (diagnostic_type == DOWNLOAD_DIAGNOSTIC) {
|
if (diagnostic_type == DOWNLOAD_DIAGNOSTIC) {
|
||||||
// Commit and Free uci_ctx_bbfdm
|
// Commit and Free uci_ctx_bbfdm
|
||||||
commit_and_free_uci_ctx_bbfdm(DMMAP_DIAGNOSTIGS);
|
commit_and_free_uci_ctx_bbfdm(DMMAP_DIAGNOSTIGS);
|
||||||
|
|
||||||
dmcmd("/bin/sh", 5, DOWNLOAD_DIAGNOSTIC_PATH, "run", "usp", url, interface);
|
dmcmd("/bin/sh", 5, DOWNLOAD_DIAGNOSTIC_PATH, "run", proto, url, device);
|
||||||
|
|
||||||
// Allocate uci_ctx_bbfdm
|
// Allocate uci_ctx_bbfdm
|
||||||
alloc_uci_ctx_bbfdm();
|
alloc_uci_ctx_bbfdm();
|
||||||
|
|
@ -591,16 +615,16 @@ int start_upload_download_diagnostic(int diagnostic_type)
|
||||||
if (status && strcmp(status, "Complete") == 0) {
|
if (status && strcmp(status, "Complete") == 0) {
|
||||||
init_download_stats();
|
init_download_stats();
|
||||||
if (strncmp(url, DOWNLOAD_UPLOAD_PROTOCOL_HTTP, strlen(DOWNLOAD_UPLOAD_PROTOCOL_HTTP)) == 0)
|
if (strncmp(url, DOWNLOAD_UPLOAD_PROTOCOL_HTTP, strlen(DOWNLOAD_UPLOAD_PROTOCOL_HTTP)) == 0)
|
||||||
extract_stats(DOWNLOAD_DUMP_FILE, DOWNLOAD_DIAGNOSTIC_HTTP, DOWNLOAD_DIAGNOSTIC, "usp");
|
extract_stats(DOWNLOAD_DUMP_FILE, DOWNLOAD_DIAGNOSTIC_HTTP, DOWNLOAD_DIAGNOSTIC, proto);
|
||||||
if (strncmp(url, DOWNLOAD_UPLOAD_PROTOCOL_FTP, strlen(DOWNLOAD_UPLOAD_PROTOCOL_FTP)) == 0)
|
if (strncmp(url, DOWNLOAD_UPLOAD_PROTOCOL_FTP, strlen(DOWNLOAD_UPLOAD_PROTOCOL_FTP)) == 0)
|
||||||
extract_stats(DOWNLOAD_DUMP_FILE, DOWNLOAD_DIAGNOSTIC_FTP, DOWNLOAD_DIAGNOSTIC, "usp");
|
extract_stats(DOWNLOAD_DUMP_FILE, DOWNLOAD_DIAGNOSTIC_FTP, DOWNLOAD_DIAGNOSTIC, proto);
|
||||||
} else if (status && strncmp(status, "Error_", strlen("Error_")) == 0)
|
} else if (status && strncmp(status, "Error_", strlen("Error_")) == 0)
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
// Commit and Free uci_ctx_bbfdm
|
// Commit and Free uci_ctx_bbfdm
|
||||||
commit_and_free_uci_ctx_bbfdm(DMMAP_DIAGNOSTIGS);
|
commit_and_free_uci_ctx_bbfdm(DMMAP_DIAGNOSTIGS);
|
||||||
|
|
||||||
dmcmd("/bin/sh", 6, UPLOAD_DIAGNOSTIC_PATH, "run", "usp", url, interface, size);
|
dmcmd("/bin/sh", 6, UPLOAD_DIAGNOSTIC_PATH, "run", proto, url, device, size);
|
||||||
|
|
||||||
// Allocate uci_ctx_bbfdm
|
// Allocate uci_ctx_bbfdm
|
||||||
alloc_uci_ctx_bbfdm();
|
alloc_uci_ctx_bbfdm();
|
||||||
|
|
@ -610,9 +634,9 @@ int start_upload_download_diagnostic(int diagnostic_type)
|
||||||
if (status && strcmp(status, "Complete") == 0) {
|
if (status && strcmp(status, "Complete") == 0) {
|
||||||
init_upload_stats();
|
init_upload_stats();
|
||||||
if (strncmp(url, DOWNLOAD_UPLOAD_PROTOCOL_HTTP, strlen(DOWNLOAD_UPLOAD_PROTOCOL_HTTP)) == 0)
|
if (strncmp(url, DOWNLOAD_UPLOAD_PROTOCOL_HTTP, strlen(DOWNLOAD_UPLOAD_PROTOCOL_HTTP)) == 0)
|
||||||
extract_stats(UPLOAD_DUMP_FILE, DOWNLOAD_DIAGNOSTIC_HTTP, UPLOAD_DIAGNOSTIC, "usp");
|
extract_stats(UPLOAD_DUMP_FILE, DOWNLOAD_DIAGNOSTIC_HTTP, UPLOAD_DIAGNOSTIC, proto);
|
||||||
if (strncmp(url, DOWNLOAD_UPLOAD_PROTOCOL_FTP, strlen(DOWNLOAD_UPLOAD_PROTOCOL_FTP)) == 0)
|
if (strncmp(url, DOWNLOAD_UPLOAD_PROTOCOL_FTP, strlen(DOWNLOAD_UPLOAD_PROTOCOL_FTP)) == 0)
|
||||||
extract_stats(UPLOAD_DUMP_FILE, DOWNLOAD_DIAGNOSTIC_FTP, UPLOAD_DIAGNOSTIC, "usp");
|
extract_stats(UPLOAD_DUMP_FILE, DOWNLOAD_DIAGNOSTIC_FTP, UPLOAD_DIAGNOSTIC, proto);
|
||||||
} else if (status && strncmp(status, "Error_", strlen("Error_")) == 0)
|
} else if (status && strncmp(status, "Error_", strlen("Error_")) == 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include <libbbf_api/dmcommon.h>
|
#include <libbbf_api/dmcommon.h>
|
||||||
|
|
||||||
#define DOWNLOAD_UPLOAD_PROTOCOL_HTTP "http://"
|
#define DOWNLOAD_UPLOAD_PROTOCOL_HTTP "http://"
|
||||||
#define DOWNLOAD_UPLOAD_PROTOCOL_FTP "ftp://"
|
#define DOWNLOAD_UPLOAD_PROTOCOL_FTP "ftp://"
|
||||||
#define default_date_format "AAAA-MM-JJTHH:MM:SS.000000Z"
|
#define default_date_format "AAAA-MM-JJTHH:MM:SS.000000Z"
|
||||||
#define default_date_size sizeof(default_date_format) + 1
|
#define default_date_size sizeof(default_date_format) + 1
|
||||||
#define FTP_SIZE_RESPONSE "213"
|
#define FTP_SIZE_RESPONSE "213"
|
||||||
|
|
@ -74,10 +74,8 @@ enum diagnostic_type {
|
||||||
char *get_diagnostics_option(char *sec_name, char *option);
|
char *get_diagnostics_option(char *sec_name, char *option);
|
||||||
char *get_diagnostics_option_fallback_def(char *sec_name, char *option, char *default_value);
|
char *get_diagnostics_option_fallback_def(char *sec_name, char *option, char *default_value);
|
||||||
void set_diagnostics_option(char *sec_name, char *option, char *value);
|
void set_diagnostics_option(char *sec_name, char *option, char *value);
|
||||||
void init_download_stats(void);
|
void init_diagnostics_operation(char *sec_name, char *operation_path);
|
||||||
void init_upload_stats(void);
|
void set_diagnostics_interface_option(struct dmctx *ctx, char *sec_name, char *value);
|
||||||
int extract_stats(char *dump_file, int proto, int diagnostic_type, char *protocol);
|
int start_upload_download_diagnostic(int diagnostic_type, char *proto);
|
||||||
int get_default_gateway_device( char **gw );
|
|
||||||
int start_upload_download_diagnostic(int diagnostic_type);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
37
dmoperate.c
37
dmoperate.c
|
|
@ -325,6 +325,8 @@ static opr_ret_t ip_diagnostics_ipping(struct dmctx *dmctx, char *path, json_obj
|
||||||
{
|
{
|
||||||
struct ipping_diagnostics ipping = {0};
|
struct ipping_diagnostics ipping = {0};
|
||||||
|
|
||||||
|
init_diagnostics_operation("ipping", IPPING_PATH);
|
||||||
|
|
||||||
ipping.host = dmjson_get_value(input, 1, "Host");
|
ipping.host = dmjson_get_value(input, 1, "Host");
|
||||||
if (ipping.host[0] == '\0')
|
if (ipping.host[0] == '\0')
|
||||||
return UBUS_INVALID_ARGUMENTS;
|
return UBUS_INVALID_ARGUMENTS;
|
||||||
|
|
@ -336,7 +338,7 @@ static opr_ret_t ip_diagnostics_ipping(struct dmctx *dmctx, char *path, json_obj
|
||||||
ipping.dscp = dmjson_get_value(input, 1, "DSCP");
|
ipping.dscp = dmjson_get_value(input, 1, "DSCP");
|
||||||
|
|
||||||
set_diagnostics_option("ipping", "Host", ipping.host);
|
set_diagnostics_option("ipping", "Host", ipping.host);
|
||||||
set_diagnostics_option("ipping", "interface", ipping.interface);
|
set_diagnostics_interface_option(dmctx, "ipping", ipping.interface);
|
||||||
set_diagnostics_option("ipping", "ProtocolVersion", ipping.proto);
|
set_diagnostics_option("ipping", "ProtocolVersion", ipping.proto);
|
||||||
set_diagnostics_option("ipping", "NumberOfRepetitions", ipping.nbofrepetition);
|
set_diagnostics_option("ipping", "NumberOfRepetitions", ipping.nbofrepetition);
|
||||||
set_diagnostics_option("ipping", "Timeout", ipping.timeout);
|
set_diagnostics_option("ipping", "Timeout", ipping.timeout);
|
||||||
|
|
@ -379,6 +381,8 @@ static opr_ret_t ip_diagnostics_traceroute(struct dmctx *dmctx, char *path, json
|
||||||
char *host, *host_address, *errorcode, *rttimes;
|
char *host, *host_address, *errorcode, *rttimes;
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
|
init_diagnostics_operation("traceroute", TRACEROUTE_PATH);
|
||||||
|
|
||||||
traceroute.host = dmjson_get_value(input, 1, "Host");
|
traceroute.host = dmjson_get_value(input, 1, "Host");
|
||||||
if (traceroute.host[0] == '\0')
|
if (traceroute.host[0] == '\0')
|
||||||
return UBUS_INVALID_ARGUMENTS;
|
return UBUS_INVALID_ARGUMENTS;
|
||||||
|
|
@ -391,7 +395,7 @@ static opr_ret_t ip_diagnostics_traceroute(struct dmctx *dmctx, char *path, json
|
||||||
traceroute.maxhops = dmjson_get_value(input, 1, "MaxHopCount");
|
traceroute.maxhops = dmjson_get_value(input, 1, "MaxHopCount");
|
||||||
|
|
||||||
set_diagnostics_option("traceroute", "Host", traceroute.host);
|
set_diagnostics_option("traceroute", "Host", traceroute.host);
|
||||||
set_diagnostics_option("traceroute", "interface", traceroute.interface);
|
set_diagnostics_interface_option(dmctx, "traceroute", traceroute.interface);
|
||||||
set_diagnostics_option("traceroute", "ProtocolVersion", traceroute.proto);
|
set_diagnostics_option("traceroute", "ProtocolVersion", traceroute.proto);
|
||||||
set_diagnostics_option("traceroute", "NumberOfTries", traceroute.nboftries);
|
set_diagnostics_option("traceroute", "NumberOfTries", traceroute.nboftries);
|
||||||
set_diagnostics_option("traceroute", "Timeout", traceroute.timeout);
|
set_diagnostics_option("traceroute", "Timeout", traceroute.timeout);
|
||||||
|
|
@ -434,6 +438,8 @@ static opr_ret_t ip_diagnostics_download(struct dmctx *dmctx, char *path, json_o
|
||||||
{
|
{
|
||||||
struct download_diagnostics download = {0};
|
struct download_diagnostics download = {0};
|
||||||
|
|
||||||
|
init_diagnostics_operation("download", DOWNLOAD_DIAGNOSTIC_PATH);
|
||||||
|
|
||||||
download.download_url = dmjson_get_value(input, 1, "DownloadURL");
|
download.download_url = dmjson_get_value(input, 1, "DownloadURL");
|
||||||
if (download.download_url[0] == '\0')
|
if (download.download_url[0] == '\0')
|
||||||
return UBUS_INVALID_ARGUMENTS;
|
return UBUS_INVALID_ARGUMENTS;
|
||||||
|
|
@ -445,14 +451,14 @@ static opr_ret_t ip_diagnostics_download(struct dmctx *dmctx, char *path, json_o
|
||||||
download.enable_per_connection_results = dmjson_get_value(input, 1, "EnablePerConnectionResults");
|
download.enable_per_connection_results = dmjson_get_value(input, 1, "EnablePerConnectionResults");
|
||||||
|
|
||||||
set_diagnostics_option("download", "url", download.download_url);
|
set_diagnostics_option("download", "url", download.download_url);
|
||||||
set_diagnostics_option("download", "device", download.interface);
|
set_diagnostics_interface_option(dmctx, "download", download.interface);
|
||||||
set_diagnostics_option("download", "DSCP", download.dscp);
|
set_diagnostics_option("download", "DSCP", download.dscp);
|
||||||
set_diagnostics_option("download", "ethernetpriority", download.ethernet_priority);
|
set_diagnostics_option("download", "ethernetpriority", download.ethernet_priority);
|
||||||
set_diagnostics_option("download", "ProtocolVersion", download.proto);
|
set_diagnostics_option("download", "ProtocolVersion", download.proto);
|
||||||
set_diagnostics_option("download", "NumberOfConnections", download.num_of_connections);
|
set_diagnostics_option("download", "NumberOfConnections", download.num_of_connections);
|
||||||
set_diagnostics_option("download", "EnablePerConnection", download.enable_per_connection_results);
|
set_diagnostics_option("download", "EnablePerConnection", download.enable_per_connection_results);
|
||||||
|
|
||||||
if (start_upload_download_diagnostic(DOWNLOAD_DIAGNOSTIC) == -1)
|
if (start_upload_download_diagnostic(DOWNLOAD_DIAGNOSTIC, "usp") == -1)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
download.romtime = get_diagnostics_option("download", "ROMtime");
|
download.romtime = get_diagnostics_option("download", "ROMtime");
|
||||||
|
|
@ -465,7 +471,7 @@ static opr_ret_t ip_diagnostics_download(struct dmctx *dmctx, char *path, json_o
|
||||||
download.total_bytes_received_under_full_loading = get_diagnostics_option("download", "TotalBytesReceived");
|
download.total_bytes_received_under_full_loading = get_diagnostics_option("download", "TotalBytesReceived");
|
||||||
download.total_bytes_sent_under_full_loading = get_diagnostics_option("download", "TotalBytesSent");
|
download.total_bytes_sent_under_full_loading = get_diagnostics_option("download", "TotalBytesSent");
|
||||||
download.period_of_full_loading = get_diagnostics_option("download", "PeriodOfFullLoading");
|
download.period_of_full_loading = get_diagnostics_option("download", "PeriodOfFullLoading");
|
||||||
download.tcp_open_request_time = get_diagnostics_option("download", "TCPOpenRequestTimes");
|
download.tcp_open_request_time = get_diagnostics_option("download", "TCPOpenRequestTime");
|
||||||
download.tcp_open_response_time = get_diagnostics_option("download", "TCPOpenResponseTime");
|
download.tcp_open_response_time = get_diagnostics_option("download", "TCPOpenResponseTime");
|
||||||
|
|
||||||
add_list_paramameter(dmctx, dmstrdup("ROMTime"), download.romtime, DMT_TYPE[DMT_TIME], NULL, 0);
|
add_list_paramameter(dmctx, dmstrdup("ROMTime"), download.romtime, DMT_TYPE[DMT_TIME], NULL, 0);
|
||||||
|
|
@ -488,6 +494,8 @@ static opr_ret_t ip_diagnostics_upload(struct dmctx *dmctx, char *path, json_obj
|
||||||
{
|
{
|
||||||
struct upload_diagnostics upload = {0};
|
struct upload_diagnostics upload = {0};
|
||||||
|
|
||||||
|
init_diagnostics_operation("upload", UPLOAD_DIAGNOSTIC_PATH);
|
||||||
|
|
||||||
upload.upload_url = dmjson_get_value(input, 1, "UploadURL");
|
upload.upload_url = dmjson_get_value(input, 1, "UploadURL");
|
||||||
if (upload.upload_url[0] == '\0')
|
if (upload.upload_url[0] == '\0')
|
||||||
return UBUS_INVALID_ARGUMENTS;
|
return UBUS_INVALID_ARGUMENTS;
|
||||||
|
|
@ -503,14 +511,14 @@ static opr_ret_t ip_diagnostics_upload(struct dmctx *dmctx, char *path, json_obj
|
||||||
|
|
||||||
set_diagnostics_option("upload", "url", upload.upload_url);
|
set_diagnostics_option("upload", "url", upload.upload_url);
|
||||||
set_diagnostics_option("upload", "TestFileLength", upload.test_file_length);
|
set_diagnostics_option("upload", "TestFileLength", upload.test_file_length);
|
||||||
set_diagnostics_option("upload", "device", upload.interface);
|
set_diagnostics_interface_option(dmctx, "upload", upload.interface);
|
||||||
set_diagnostics_option("upload", "DSCP", upload.dscp);
|
set_diagnostics_option("upload", "DSCP", upload.dscp);
|
||||||
set_diagnostics_option("upload", "ethernetpriority", upload.ethernet_priority);
|
set_diagnostics_option("upload", "ethernetpriority", upload.ethernet_priority);
|
||||||
set_diagnostics_option("upload", "ProtocolVersion", upload.proto);
|
set_diagnostics_option("upload", "ProtocolVersion", upload.proto);
|
||||||
set_diagnostics_option("upload", "NumberOfConnections", upload.num_of_connections);
|
set_diagnostics_option("upload", "NumberOfConnections", upload.num_of_connections);
|
||||||
set_diagnostics_option("upload", "EnablePerConnection", upload.enable_per_connection_results);
|
set_diagnostics_option("upload", "EnablePerConnection", upload.enable_per_connection_results);
|
||||||
|
|
||||||
if (start_upload_download_diagnostic(UPLOAD_DIAGNOSTIC) == -1)
|
if (start_upload_download_diagnostic(UPLOAD_DIAGNOSTIC, "usp") == -1)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
upload.romtime = get_diagnostics_option("upload", "ROMtime");
|
upload.romtime = get_diagnostics_option("upload", "ROMtime");
|
||||||
|
|
@ -523,7 +531,7 @@ static opr_ret_t ip_diagnostics_upload(struct dmctx *dmctx, char *path, json_obj
|
||||||
upload.total_bytes_received_under_full_loading = get_diagnostics_option("upload", "TotalBytesReceived");
|
upload.total_bytes_received_under_full_loading = get_diagnostics_option("upload", "TotalBytesReceived");
|
||||||
upload.total_bytes_sent_under_full_loading = get_diagnostics_option("upload", "TotalBytesSent");
|
upload.total_bytes_sent_under_full_loading = get_diagnostics_option("upload", "TotalBytesSent");
|
||||||
upload.period_of_full_loading = get_diagnostics_option("upload", "PeriodOfFullLoading");
|
upload.period_of_full_loading = get_diagnostics_option("upload", "PeriodOfFullLoading");
|
||||||
upload.tcp_open_request_time = get_diagnostics_option("upload", "TCPOpenRequestTimes");
|
upload.tcp_open_request_time = get_diagnostics_option("upload", "TCPOpenRequestTime");
|
||||||
upload.tcp_open_response_time = get_diagnostics_option("upload", "TCPOpenResponseTime");
|
upload.tcp_open_response_time = get_diagnostics_option("upload", "TCPOpenResponseTime");
|
||||||
|
|
||||||
add_list_paramameter(dmctx, dmstrdup("ROMTime"), upload.romtime, DMT_TYPE[DMT_TIME], NULL, 0);
|
add_list_paramameter(dmctx, dmstrdup("ROMTime"), upload.romtime, DMT_TYPE[DMT_TIME], NULL, 0);
|
||||||
|
|
@ -546,9 +554,12 @@ static opr_ret_t ip_diagnostics_udpecho(struct dmctx *dmctx, char *path, json_ob
|
||||||
{
|
{
|
||||||
struct udpecho_diagnostics udpecho = {0};
|
struct udpecho_diagnostics udpecho = {0};
|
||||||
|
|
||||||
|
init_diagnostics_operation("udpechodiag", UDPECHO_PATH);
|
||||||
|
|
||||||
udpecho.host = dmjson_get_value(input, 1, "Host");
|
udpecho.host = dmjson_get_value(input, 1, "Host");
|
||||||
if (udpecho.host[0] == '\0')
|
if (udpecho.host[0] == '\0')
|
||||||
return UBUS_INVALID_ARGUMENTS;
|
return UBUS_INVALID_ARGUMENTS;
|
||||||
|
|
||||||
udpecho.port = dmjson_get_value(input, 1, "Port");
|
udpecho.port = dmjson_get_value(input, 1, "Port");
|
||||||
if (udpecho.port[0] == '\0')
|
if (udpecho.port[0] == '\0')
|
||||||
return UBUS_INVALID_ARGUMENTS;
|
return UBUS_INVALID_ARGUMENTS;
|
||||||
|
|
@ -563,7 +574,7 @@ static opr_ret_t ip_diagnostics_udpecho(struct dmctx *dmctx, char *path, json_ob
|
||||||
|
|
||||||
set_diagnostics_option("udpechodiag", "Host", udpecho.host);
|
set_diagnostics_option("udpechodiag", "Host", udpecho.host);
|
||||||
set_diagnostics_option("udpechodiag", "port", udpecho.port);
|
set_diagnostics_option("udpechodiag", "port", udpecho.port);
|
||||||
set_diagnostics_option("udpechodiag", "interface", udpecho.interface);
|
set_diagnostics_interface_option(dmctx, "udpechodiag", udpecho.interface);
|
||||||
set_diagnostics_option("udpechodiag", "ProtocolVersion", udpecho.proto);
|
set_diagnostics_option("udpechodiag", "ProtocolVersion", udpecho.proto);
|
||||||
set_diagnostics_option("udpechodiag", "NumberOfRepetitions", udpecho.nbofrepetition);
|
set_diagnostics_option("udpechodiag", "NumberOfRepetitions", udpecho.nbofrepetition);
|
||||||
set_diagnostics_option("udpechodiag", "Timeout", udpecho.timeout);
|
set_diagnostics_option("udpechodiag", "Timeout", udpecho.timeout);
|
||||||
|
|
@ -598,6 +609,8 @@ static opr_ret_t ip_diagnostics_serverselection(struct dmctx *dmctx, char *path,
|
||||||
{
|
{
|
||||||
struct serverselection_diagnostics serverselection = {0};
|
struct serverselection_diagnostics serverselection = {0};
|
||||||
|
|
||||||
|
init_diagnostics_operation("serverselection", SERVERSELECTION_PATH);
|
||||||
|
|
||||||
serverselection.hostlist = dmjson_get_value(input, 1, "HostList");
|
serverselection.hostlist = dmjson_get_value(input, 1, "HostList");
|
||||||
if (serverselection.hostlist[0] == '\0')
|
if (serverselection.hostlist[0] == '\0')
|
||||||
return UBUS_INVALID_ARGUMENTS;
|
return UBUS_INVALID_ARGUMENTS;
|
||||||
|
|
@ -613,7 +626,7 @@ static opr_ret_t ip_diagnostics_serverselection(struct dmctx *dmctx, char *path,
|
||||||
serverselection.timeout = dmjson_get_value(input, 1, "Timeout");
|
serverselection.timeout = dmjson_get_value(input, 1, "Timeout");
|
||||||
|
|
||||||
set_diagnostics_option("serverselection", "HostList", serverselection.hostlist);
|
set_diagnostics_option("serverselection", "HostList", serverselection.hostlist);
|
||||||
set_diagnostics_option("serverselection", "interface", serverselection.interface);
|
set_diagnostics_interface_option(dmctx, "serverselection", serverselection.interface);
|
||||||
set_diagnostics_option("serverselection", "ProtocolVersion", serverselection.protocol_version);
|
set_diagnostics_option("serverselection", "ProtocolVersion", serverselection.protocol_version);
|
||||||
set_diagnostics_option("serverselection", "NumberOfRepetitions", serverselection.nbofrepetition);
|
set_diagnostics_option("serverselection", "NumberOfRepetitions", serverselection.nbofrepetition);
|
||||||
set_diagnostics_option("serverselection", "port", serverselection.port);
|
set_diagnostics_option("serverselection", "port", serverselection.port);
|
||||||
|
|
@ -648,6 +661,8 @@ static opr_ret_t ip_diagnostics_nslookup(struct dmctx *dmctx, char *path, json_o
|
||||||
char *status, *answertype, *hostname, *ipaddress, *dnsserverip, *responsetime;
|
char *status, *answertype, *hostname, *ipaddress, *dnsserverip, *responsetime;
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
|
init_diagnostics_operation("nslookup", NSLOOKUP_PATH);
|
||||||
|
|
||||||
nslookup.hostname = dmjson_get_value(input, 1, "HostName");
|
nslookup.hostname = dmjson_get_value(input, 1, "HostName");
|
||||||
if (nslookup.hostname[0] == '\0')
|
if (nslookup.hostname[0] == '\0')
|
||||||
return UBUS_INVALID_ARGUMENTS;
|
return UBUS_INVALID_ARGUMENTS;
|
||||||
|
|
@ -657,7 +672,7 @@ static opr_ret_t ip_diagnostics_nslookup(struct dmctx *dmctx, char *path, json_o
|
||||||
nslookup.nbofrepetition = dmjson_get_value(input, 1, "NumberOfRepetitions");
|
nslookup.nbofrepetition = dmjson_get_value(input, 1, "NumberOfRepetitions");
|
||||||
|
|
||||||
set_diagnostics_option("nslookup", "HostName", nslookup.hostname);
|
set_diagnostics_option("nslookup", "HostName", nslookup.hostname);
|
||||||
set_diagnostics_option("nslookup", "interface", nslookup.interface);
|
set_diagnostics_interface_option(dmctx, "nslookup", nslookup.interface);
|
||||||
set_diagnostics_option("nslookup", "DNSServer", nslookup.dnsserver);
|
set_diagnostics_option("nslookup", "DNSServer", nslookup.dnsserver);
|
||||||
set_diagnostics_option("nslookup", "Timeout", nslookup.timeout);
|
set_diagnostics_option("nslookup", "Timeout", nslookup.timeout);
|
||||||
set_diagnostics_option("nslookup", "NumberOfRepetitions", nslookup.nbofrepetition);
|
set_diagnostics_option("nslookup", "NumberOfRepetitions", nslookup.nbofrepetition);
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,10 @@ static int set_ip_ping_diagnostics_state(char *refparam, struct dmctx *ctx, void
|
||||||
|
|
||||||
static int get_ip_ping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
static int get_ip_ping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||||
{
|
{
|
||||||
*value = get_diagnostics_option("ipping", "interface");
|
char *linker = get_diagnostics_option("ipping", "interface");
|
||||||
|
adm_entry_get_linker_param(ctx, dm_print_path("%s%cIP%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), linker, value);
|
||||||
|
if (*value == NULL)
|
||||||
|
*value = "";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,7 +66,7 @@ static int set_ip_ping_interface(char *refparam, struct dmctx *ctx, void *data,
|
||||||
return 0;
|
return 0;
|
||||||
case VALUESET:
|
case VALUESET:
|
||||||
IPPING_STOP
|
IPPING_STOP
|
||||||
set_diagnostics_option("ipping", "interface", value);
|
set_diagnostics_interface_option(ctx, "ipping", value);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -273,7 +276,10 @@ static int set_IPDiagnosticsTraceRoute_DiagnosticsState(char *refparam, struct d
|
||||||
|
|
||||||
static int get_IPDiagnosticsTraceRoute_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
static int get_IPDiagnosticsTraceRoute_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||||
{
|
{
|
||||||
*value = get_diagnostics_option("traceroute", "interface");
|
char *linker = get_diagnostics_option("traceroute", "interface");
|
||||||
|
adm_entry_get_linker_param(ctx, dm_print_path("%s%cIP%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), linker, value);
|
||||||
|
if (*value == NULL)
|
||||||
|
*value = "";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -286,7 +292,7 @@ static int set_IPDiagnosticsTraceRoute_Interface(char *refparam, struct dmctx *c
|
||||||
return 0;
|
return 0;
|
||||||
case VALUESET:
|
case VALUESET:
|
||||||
TRACEROUTE_STOP
|
TRACEROUTE_STOP
|
||||||
set_diagnostics_option("traceroute", "interface", value);
|
set_diagnostics_interface_option(ctx, "traceroute", value);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -514,28 +520,14 @@ static int get_IPDiagnosticsDownloadDiagnostics_Interface(char *refparam, struct
|
||||||
|
|
||||||
static int set_IPDiagnosticsDownloadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
static int set_IPDiagnosticsDownloadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||||
{
|
{
|
||||||
char interface[256] = {0}, *linker = NULL;
|
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case VALUECHECK:
|
case VALUECHECK:
|
||||||
if (dm_validate_string(value, -1, 256, NULL, 0, NULL, 0))
|
if (dm_validate_string(value, -1, 256, NULL, 0, NULL, 0))
|
||||||
return FAULT_9007;
|
return FAULT_9007;
|
||||||
return 0;
|
return 0;
|
||||||
case VALUESET:
|
case VALUESET:
|
||||||
append_dot_to_string(interface, value, sizeof(interface));
|
DOWNLOAD_DIAGNOSTIC_STOP
|
||||||
adm_entry_get_linker_value(ctx, interface, &linker);
|
set_diagnostics_interface_option(ctx, "download", value);
|
||||||
if (linker) {
|
|
||||||
json_object *res = NULL;
|
|
||||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", linker, String}}, 1, &res);
|
|
||||||
if (!res) return 0;
|
|
||||||
char *device = dmjson_get_value(res, 1, "device");
|
|
||||||
if (device && *device) {
|
|
||||||
DOWNLOAD_DIAGNOSTIC_STOP
|
|
||||||
set_diagnostics_option("download", "interface", linker);
|
|
||||||
set_diagnostics_option("download", "device", device);
|
|
||||||
}
|
|
||||||
dmfree(linker);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -847,28 +839,14 @@ static int get_IPDiagnosticsUploadDiagnostics_Interface(char *refparam, struct d
|
||||||
|
|
||||||
static int set_IPDiagnosticsUploadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
static int set_IPDiagnosticsUploadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||||
{
|
{
|
||||||
char interface[256] = {0}, *linker = NULL;
|
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case VALUECHECK:
|
case VALUECHECK:
|
||||||
if (dm_validate_string(value, -1, 256, NULL, 0, NULL, 0))
|
if (dm_validate_string(value, -1, 256, NULL, 0, NULL, 0))
|
||||||
return FAULT_9007;
|
return FAULT_9007;
|
||||||
return 0;
|
return 0;
|
||||||
case VALUESET:
|
case VALUESET:
|
||||||
append_dot_to_string(interface, value, sizeof(interface));
|
UPLOAD_DIAGNOSTIC_STOP
|
||||||
adm_entry_get_linker_value(ctx, interface, &linker);
|
set_diagnostics_interface_option(ctx, "upload", value);
|
||||||
if (linker) {
|
|
||||||
json_object *res = NULL;
|
|
||||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", linker, String}}, 1, &res);
|
|
||||||
if (!res) return 0;
|
|
||||||
char *device = dmjson_get_value(res, 1, "device");
|
|
||||||
if (device && *device) {
|
|
||||||
UPLOAD_DIAGNOSTIC_STOP
|
|
||||||
set_diagnostics_option("upload", "interface", linker);
|
|
||||||
set_diagnostics_option("upload", "device", device);
|
|
||||||
}
|
|
||||||
dmfree(linker);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -1187,7 +1165,10 @@ static int set_IPDiagnosticsUDPEchoDiagnostics_DiagnosticsState(char *refparam,
|
||||||
|
|
||||||
static int get_IPDiagnosticsUDPEchoDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
static int get_IPDiagnosticsUDPEchoDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||||
{
|
{
|
||||||
*value = get_diagnostics_option("udpechodiag", "Interface");
|
char *linker = get_diagnostics_option("udpechodiag", "interface");
|
||||||
|
adm_entry_get_linker_param(ctx, dm_print_path("%s%cIP%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), linker, value);
|
||||||
|
if (*value == NULL)
|
||||||
|
*value = "";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1200,7 +1181,7 @@ static int set_IPDiagnosticsUDPEchoDiagnostics_Interface(char *refparam, struct
|
||||||
return 0;
|
return 0;
|
||||||
case VALUESET:
|
case VALUESET:
|
||||||
UDPECHO_STOP;
|
UDPECHO_STOP;
|
||||||
set_diagnostics_option("udpechodiag", "Interface", value);
|
set_diagnostics_interface_option(ctx, "udpechodiag", value);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -1434,7 +1415,10 @@ static int set_IPDiagnosticsServerSelectionDiagnostics_DiagnosticsState(char *re
|
||||||
|
|
||||||
static int get_IPDiagnosticsServerSelectionDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
static int get_IPDiagnosticsServerSelectionDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||||
{
|
{
|
||||||
*value = get_diagnostics_option("serverselection", "interface");
|
char *linker = get_diagnostics_option("serverselection", "interface");
|
||||||
|
adm_entry_get_linker_param(ctx, dm_print_path("%s%cIP%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), linker, value);
|
||||||
|
if (*value == NULL)
|
||||||
|
*value = "";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1447,7 +1431,7 @@ static int set_IPDiagnosticsServerSelectionDiagnostics_Interface(char *refparam,
|
||||||
return 0;
|
return 0;
|
||||||
case VALUESET:
|
case VALUESET:
|
||||||
SERVERSELECTION_STOP
|
SERVERSELECTION_STOP
|
||||||
set_diagnostics_option("serverselection", "interface", value);
|
set_diagnostics_interface_option(ctx, "serverselection", value);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -220,7 +220,7 @@ static int get_vcf_date(char *refparam, struct dmctx *ctx, void *data, char *ins
|
||||||
if ((dir = opendir (DEFAULT_CONFIG_DIR)) != NULL) {
|
if ((dir = opendir (DEFAULT_CONFIG_DIR)) != NULL) {
|
||||||
while ((d_file = readdir (dir)) != NULL) {
|
while ((d_file = readdir (dir)) != NULL) {
|
||||||
if (strcmp(config_name, d_file->d_name) == 0) {
|
if (strcmp(config_name, d_file->d_name) == 0) {
|
||||||
char date[sizeof("AAAA-MM-JJTHH:MM:SSZ")], path[128] = {0};
|
char date[sizeof("AAAA-MM-JJTHH:MM:SSZ")], path[280] = {0};
|
||||||
struct stat attr;
|
struct stat attr;
|
||||||
|
|
||||||
snprintf(path, sizeof(path), DEFAULT_CONFIG_DIR"%s", d_file->d_name);
|
snprintf(path, sizeof(path), DEFAULT_CONFIG_DIR"%s", d_file->d_name);
|
||||||
|
|
|
||||||
|
|
@ -442,7 +442,10 @@ static int get_nslookupdiagnostics_diagnostics_state(char *refparam, struct dmct
|
||||||
|
|
||||||
static int get_nslookupdiagnostics_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
static int get_nslookupdiagnostics_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||||
{
|
{
|
||||||
*value = get_diagnostics_option("nslookup", "interface");
|
char *linker = get_diagnostics_option("nslookup", "interface");
|
||||||
|
adm_entry_get_linker_param(ctx, dm_print_path("%s%cIP%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), linker, value);
|
||||||
|
if (*value == NULL)
|
||||||
|
*value = "";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -821,7 +824,7 @@ static int set_nslookupdiagnostics_interface(char *refparam, struct dmctx *ctx,
|
||||||
return 0;
|
return 0;
|
||||||
case VALUESET:
|
case VALUESET:
|
||||||
NSLOOKUP_STOP
|
NSLOOKUP_STOP
|
||||||
set_diagnostics_option("nslookup", "interface", value);
|
set_diagnostics_interface_option(ctx, "nslookup", value);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -622,16 +622,13 @@ static inline int DM_LINK_INST_OBJ(struct dmctx *dmctx, DMNODE *parent_node, voi
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TRACE
|
#ifndef TRACE
|
||||||
#define TRACE_TYPE 0
|
#define TRACE_TYPE 2
|
||||||
static inline void trace_empty_func()
|
static inline void trace_empty_func()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
#if TRACE_TYPE == 2
|
#if TRACE_TYPE == 2
|
||||||
#define TRACE(MESSAGE,args...) do { \
|
#define TRACE(MESSAGE, ...) do { \
|
||||||
const char *A[] = {MESSAGE}; \
|
fprintf(stderr, "TRACE: %s@%s:%d " MESSAGE, __FUNCTION__,__FILE__,__LINE__, ##__VA_ARGS__); \
|
||||||
fprintf(stderr, "TRACE: %s %s %d ",__FUNCTION__,__FILE__,__LINE__); \
|
|
||||||
if(sizeof(A) > 0) \
|
|
||||||
fprintf(stderr, *A,##args); \
|
|
||||||
fprintf(stderr, "\n"); \
|
fprintf(stderr, "\n"); \
|
||||||
fflush(stderr); \
|
fflush(stderr); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@
|
||||||
UCI_GET_BBFDM="/sbin/uci -q -c /etc/bbfdm get"
|
UCI_GET_BBFDM="/sbin/uci -q -c /etc/bbfdm get"
|
||||||
UCI_SET_BBFDM="/sbin/uci -q -c /etc/bbfdm set"
|
UCI_SET_BBFDM="/sbin/uci -q -c /etc/bbfdm set"
|
||||||
UCI_ADD_BBFDM="/sbin/uci -q -c /etc/bbfdm add"
|
UCI_ADD_BBFDM="/sbin/uci -q -c /etc/bbfdm add"
|
||||||
UCI_DELETE_BBFDM="/sbin/uci -c /etc/bbfdm delete"
|
UCI_DELETE_BBFDM="/sbin/uci -q -c /etc/bbfdm delete"
|
||||||
|
UCI_COMMIT_BBFDM="/sbin/uci -q -c /etc/bbfdm commit"
|
||||||
CAPTURE_FILE="/tmp/download_dump"
|
CAPTURE_FILE="/tmp/download_dump"
|
||||||
DOWNLOAD_DIAGNOSTIC_FILE="/tmp/bbfdm_download_diagnostic"
|
DOWNLOAD_DIAGNOSTIC_FILE="/tmp/bbfdm_download_diagnostic"
|
||||||
DOWNLOAD_DIAGNOSTIC_LOG_FILE="/tmp/bbfdm_download_diagnostic_log"
|
DOWNLOAD_DIAGNOSTIC_LOG_FILE="/tmp/bbfdm_download_diagnostic_log"
|
||||||
|
|
@ -18,35 +19,34 @@ download_get() {
|
||||||
}
|
}
|
||||||
|
|
||||||
download_launch() {
|
download_launch() {
|
||||||
local tx_bytes_before rx_bytes_before time1 tx_bytes_after rx_bytes_after time2 res rh ba stc periodtime
|
local proto tx_bytes_before rx_bytes_before time1 tx_bytes_after rx_bytes_after time2 res rh ba stc periodtime
|
||||||
local url=$2
|
local url=$2
|
||||||
local interface=$3
|
local device=$3
|
||||||
[ "$1" == "cwmp" ] && [ "`$UCI_GET_BBFDM dmmap_diagnostics.download.DiagnosticState`" != "Requested" ] && return
|
[ "$1" == "cwmp" ] && [ "`$UCI_GET_BBFDM dmmap_diagnostics.download.DiagnosticState`" != "Requested" ] && return
|
||||||
[ "$url" = "" ] && { $UCI_SET_BBFDM dmmap_diagnostics.download.DiagnosticState=Error_InitConnectionFailed; return; }
|
[ "$url" = "" ] && { $UCI_SET_BBFDM dmmap_diagnostics.download.DiagnosticState=Error_InitConnectionFailed; $UCI_COMMIT_BBFDM; return; }
|
||||||
local proto=`download_get dmmap_diagnostics.download.ProtocolVersion Any`
|
local protocol=`download_get dmmap_diagnostics.download.ProtocolVersion Any`
|
||||||
|
if [ "$protocol" == "IPv4" ]; then proto="-4"; elif [ "$protocol" == "IPv6" ]; then proto="-6"; else proto=""; fi
|
||||||
# Disable acceleration on Broadcom devices to capture all packets with tcpdump
|
# Disable acceleration on Broadcom devices to capture all packets with tcpdump
|
||||||
[ -e /usr/sbin/fcctl ] && { fcctl disable >/dev/null 2>&1; fcctl flush >/dev/null 2>&1; }
|
[ -e /usr/sbin/fcctl ] && { fcctl disable >/dev/null 2>&1; fcctl flush >/dev/null 2>&1; }
|
||||||
tcpdump -i $interface tcp -w ${CAPTURE_FILE} > /dev/null 2>&1 &
|
tcpdump -i $device tcp -w ${CAPTURE_FILE} > /dev/null 2>&1 &
|
||||||
PID=$!
|
PID=$!
|
||||||
sleep 1
|
sleep 1
|
||||||
if [ ${url:0:7} = http:// -o ${url:0:6} = ftp:// ]; then
|
if [ ${url:0:7} = http:// -o ${url:0:6} = ftp:// ]; then
|
||||||
tx_bytes_before=`ubus call network.device status "{'name':'$interface'}" | jsonfilter -e @.statistics.tx_bytes`
|
tx_bytes_before=`ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.tx_bytes`
|
||||||
rx_bytes_before=`ubus call network.device status "{'name':'$interface'}" | jsonfilter -e @.statistics.rx_bytes`
|
rx_bytes_before=`ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.rx_bytes`
|
||||||
time1=`date +%s`
|
time1=`date +%s`
|
||||||
[ "$proto" = "Any" ] && res=$(wget -t 1 --timeout=${CONNECTION_TIMEOUT} -O ${DOWNLOAD_DIAGNOSTIC_FILE} -o ${DOWNLOAD_DIAGNOSTIC_LOG_FILE} $url 2>&1)
|
res=$(wget $proto -t 1 --timeout=${CONNECTION_TIMEOUT} -O ${DOWNLOAD_DIAGNOSTIC_FILE} -o ${DOWNLOAD_DIAGNOSTIC_LOG_FILE} $url 2>&1)
|
||||||
[ "$proto" = "IPv4" ] && res=$(wget -4 -t 1 --timeout=${CONNECTION_TIMEOUT} -O ${DOWNLOAD_DIAGNOSTIC_FILE} -o ${DOWNLOAD_DIAGNOSTIC_LOG_FILE} $url 2>&1)
|
|
||||||
[ "$proto" = "IPv6" ] && res=$(wget -6 -t 1 --timeout=${CONNECTION_TIMEOUT} -O ${DOWNLOAD_DIAGNOSTIC_FILE} -o ${DOWNLOAD_DIAGNOSTIC_LOG_FILE} $url 2>&1)
|
|
||||||
time2=`date +%s`
|
time2=`date +%s`
|
||||||
tx_bytes_after=`ubus call network.device status "{'name':'$interface'}" | jsonfilter -e @.statistics.tx_bytes`
|
tx_bytes_after=`ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.tx_bytes`
|
||||||
rx_bytes_after=`ubus call network.device status "{'name':'$interface'}" | jsonfilter -e @.statistics.rx_bytes`
|
rx_bytes_after=`ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.rx_bytes`
|
||||||
rh=`cat ${DOWNLOAD_DIAGNOSTIC_LOG_FILE} | grep "resolve host"`
|
rh=`cat ${DOWNLOAD_DIAGNOSTIC_LOG_FILE} | grep "resolve host"`
|
||||||
[ -n "$ba" ] && { $UCI_SET_BBFDM dmmap_diagnostics.download.DiagnosticState=Error_CannotResolveHostName; kill $PID 2> /dev/null; return; }
|
[ -n "$ba" ] && { $UCI_SET_BBFDM dmmap_diagnostics.download.DiagnosticState=Error_CannotResolveHostName; $UCI_COMMIT_BBFDM; kill $PID 2> /dev/null; return; }
|
||||||
ba=`echo "$res" | grep "bad address"`
|
ba=`echo "$res" | grep "bad address"`
|
||||||
[ -n "$ba" ] && { $UCI_SET_BBFDM dmmap_diagnostics.download.DiagnosticState=Error_InitConnectionFailed; kill $PID 2> /dev/null; return; }
|
[ -n "$ba" ] && { $UCI_SET_BBFDM dmmap_diagnostics.download.DiagnosticState=Error_InitConnectionFailed; $UCI_COMMIT_BBFDM; kill $PID 2> /dev/null; return; }
|
||||||
stc=`cat ${DOWNLOAD_DIAGNOSTIC_LOG_FILE} | grep "404 Not Found"`
|
stc=`cat ${DOWNLOAD_DIAGNOSTIC_LOG_FILE} | grep "404 Not Found"`
|
||||||
[ -n "$stc" ] && { $UCI_SET_BBFDM dmmap_diagnostics.download.DiagnosticState=Error_NoResponse; kill $PID 2> /dev/null; return; }
|
[ -n "$stc" ] && { $UCI_SET_BBFDM dmmap_diagnostics.download.DiagnosticState=Error_NoResponse; $UCI_COMMIT_BBFDM; kill $PID 2> /dev/null; return; }
|
||||||
stc=`cat ${DOWNLOAD_DIAGNOSTIC_LOG_FILE} | grep "100%"`
|
stc=`cat ${DOWNLOAD_DIAGNOSTIC_LOG_FILE} | grep "100%"`
|
||||||
[ -z "$stc" ] && { $UCI_SET_BBFDM dmmap_diagnostics.download.DiagnosticState=Error_TransferFailed; kill $PID 2> /dev/null; return; }
|
[ -z "$stc" ] && { $UCI_SET_BBFDM dmmap_diagnostics.download.DiagnosticState=Error_TransferFailed; $UCI_COMMIT_BBFDM; kill $PID 2> /dev/null; return; }
|
||||||
fi
|
fi
|
||||||
tx_bytes=$((tx_bytes_after-tx_bytes_before))
|
tx_bytes=$((tx_bytes_after-tx_bytes_before))
|
||||||
rx_bytes=$((rx_bytes_after-rx_bytes_before))
|
rx_bytes=$((rx_bytes_after-rx_bytes_before))
|
||||||
|
|
@ -63,6 +63,7 @@ download_launch() {
|
||||||
else
|
else
|
||||||
$UCI_DELETE_BBFDM dmmap_diagnostics.@DownloadPerConnection[0]
|
$UCI_DELETE_BBFDM dmmap_diagnostics.@DownloadPerConnection[0]
|
||||||
fi
|
fi
|
||||||
|
$UCI_COMMIT_BBFDM
|
||||||
rm ${DOWNLOAD_DIAGNOSTIC_FILE} 2>/dev/null
|
rm ${DOWNLOAD_DIAGNOSTIC_FILE} 2>/dev/null
|
||||||
rm ${DOWNLOAD_DIAGNOSTIC_LOG_FILE} 2>/dev/null
|
rm ${DOWNLOAD_DIAGNOSTIC_LOG_FILE} 2>/dev/null
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
@ -79,15 +80,16 @@ download_stop_diagnostic() {
|
||||||
kill -9 $pids &>/dev/null
|
kill -9 $pids &>/dev/null
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.download.DiagnosticState=None
|
$UCI_SET_BBFDM dmmap_diagnostics.download.DiagnosticState=None
|
||||||
fi
|
fi
|
||||||
local pids=`ps | grep download_launch.*run | grep -v grep | awk '{print $1}'`
|
local pids=`ps | grep download_launch.*run | grep -v grep | awk '{print $1}'`
|
||||||
if [ -n "$pids" ]; then
|
if [ -n "$pids" ]; then
|
||||||
kids=$(grep -l "PPid.*$pids" /proc/*/task/*/status | grep -o "[0-9]*")
|
kids=$(grep -l "PPid.*$pids" /proc/*/task/*/status | grep -o "[0-9]*")
|
||||||
for kid in $kids; do
|
for kid in $kids; do
|
||||||
kill -9 $kid &>/dev/null
|
kill -9 $kid &>/dev/null
|
||||||
done
|
done
|
||||||
kill -9 $pids &>/dev/null
|
kill -9 $pids &>/dev/null
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.download.DiagnosticState=None
|
$UCI_SET_BBFDM dmmap_diagnostics.download.DiagnosticState=None
|
||||||
fi
|
fi
|
||||||
|
$UCI_COMMIT_BBFDM
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$1" == "run" ] ; then
|
if [ "$1" == "run" ] ; then
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
UCI_GET_BBFDM="/sbin/uci -q -c /etc/bbfdm get"
|
UCI_GET_BBFDM="/sbin/uci -q -c /etc/bbfdm get"
|
||||||
UCI_SET_BBFDM="/sbin/uci -q -c /etc/bbfdm set"
|
UCI_SET_BBFDM="/sbin/uci -q -c /etc/bbfdm set"
|
||||||
|
UCI_COMMIT_BBFDM="/sbin/uci -q -c /etc/bbfdm commit"
|
||||||
|
|
||||||
ipping_get() {
|
ipping_get() {
|
||||||
local val=`$UCI_GET_BBFDM $1`
|
local val=`$UCI_GET_BBFDM $1`
|
||||||
|
|
@ -21,17 +22,21 @@ ipping_error()
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.ipping.MaximumResponseTime=0
|
$UCI_SET_BBFDM dmmap_diagnostics.ipping.MaximumResponseTime=0
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.ipping.AverageResponseTimeDetailed=0
|
$UCI_SET_BBFDM dmmap_diagnostics.ipping.AverageResponseTimeDetailed=0
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.ipping.MinimumResponseTimeDetailed=999999999
|
$UCI_SET_BBFDM dmmap_diagnostics.ipping.MinimumResponseTimeDetailed=999999999
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.ipping.MaximumResponseTimeDetailed=0
|
$UCI_SET_BBFDM dmmap_diagnostics.ipping.MaximumResponseTimeDetailed=0
|
||||||
|
$UCI_COMMIT_BBFDM
|
||||||
}
|
}
|
||||||
|
|
||||||
ipping_launch() {
|
ipping_launch() {
|
||||||
local i res ba stc times sc1 success_count failure_count min_time avg_time max_time avg_time_sum min max micros avg_time_det min_time_det max_time_det avg_time_sum_det min_det max_det
|
local i proto device res ba stc times sc1 success_count failure_count min_time avg_time max_time avg_time_sum min max micros avg_time_det min_time_det max_time_det avg_time_sum_det min_det max_det
|
||||||
[ "$1" == "cwmp" ] && [ "`$UCI_GET_BBFDM dmmap_diagnostics.ipping.DiagnosticState`" != "Requested" ] && return
|
[ "$1" == "cwmp" ] && [ "`$UCI_GET_BBFDM dmmap_diagnostics.ipping.DiagnosticState`" != "Requested" ] && return
|
||||||
local host=`ipping_get dmmap_diagnostics.ipping.Host`
|
local host=`ipping_get dmmap_diagnostics.ipping.Host`
|
||||||
local cnt=`ipping_get dmmap_diagnostics.ipping.NumberOfRepetitions 3`
|
local cnt=`ipping_get dmmap_diagnostics.ipping.NumberOfRepetitions 3`
|
||||||
local dsize=`ipping_get dmmap_diagnostics.ipping.DataBlockSize 64`
|
local dsize=`ipping_get dmmap_diagnostics.ipping.DataBlockSize 64`
|
||||||
local timeout=`ipping_get dmmap_diagnostics.ipping.Timeout 1000`
|
local timeout=`ipping_get dmmap_diagnostics.ipping.Timeout 1000`
|
||||||
local proto=`ipping_get dmmap_diagnostics.ipping.ProtocolVersion Any`
|
local interface=`ipping_get dmmap_diagnostics.ipping.interface`
|
||||||
|
local protocol=`ipping_get dmmap_diagnostics.ipping.ProtocolVersion Any`
|
||||||
|
[ ! -z "$interface" ] && device=`ifstatus $interface | jsonfilter -e @.device` && device="-I $device" || device=""
|
||||||
|
if [ "$protocol" == "IPv4" ]; then proto="-4"; elif [ "$protocol" == "IPv6" ]; then proto="-6"; else proto=""; fi
|
||||||
[ "$host" = "" ] && return
|
[ "$host" = "" ] && return
|
||||||
timeout=$((timeout/1000))
|
timeout=$((timeout/1000))
|
||||||
[ "$timeout" = "0" ] && timeout="1"
|
[ "$timeout" = "0" ] && timeout="1"
|
||||||
|
|
@ -47,9 +52,7 @@ ipping_launch() {
|
||||||
|
|
||||||
while [ $i -lt $cnt ]; do
|
while [ $i -lt $cnt ]; do
|
||||||
let i++
|
let i++
|
||||||
[ "$proto" = "Any" ] && res=$(ping -q -c 1 -s $dsize -W $timeout $host 2>&1)
|
res=$(ping -q $proto -c 1 -s $dsize -W $timeout $device $host 2>&1)
|
||||||
[ "$proto" = "IPv4" ] && res=$(ping -q -4 -c 1 -s $dsize -W $timeout $host 2>&1)
|
|
||||||
[ "$proto" = "IPv6" ] && res=$(ping -q -6 -c 1 -s $dsize -W $timeout $host 2>&1)
|
|
||||||
ba=`echo "$res" | grep "bad address"`
|
ba=`echo "$res" | grep "bad address"`
|
||||||
[ -n "$ba" ] && { $UCI_SET_BBFDM dmmap_diagnostics.ipping.DiagnosticState=Error_CannotResolveHostName; ipping_error; return; }
|
[ -n "$ba" ] && { $UCI_SET_BBFDM dmmap_diagnostics.ipping.DiagnosticState=Error_CannotResolveHostName; ipping_error; return; }
|
||||||
ba=`echo "$res" | grep "unknown host"`
|
ba=`echo "$res" | grep "unknown host"`
|
||||||
|
|
@ -98,6 +101,7 @@ ipping_launch() {
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.ipping.AverageResponseTimeDetailed=$avg_time_det
|
$UCI_SET_BBFDM dmmap_diagnostics.ipping.AverageResponseTimeDetailed=$avg_time_det
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.ipping.MinimumResponseTimeDetailed=$min_time_det
|
$UCI_SET_BBFDM dmmap_diagnostics.ipping.MinimumResponseTimeDetailed=$min_time_det
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.ipping.MaximumResponseTimeDetailed=$max_time_det
|
$UCI_SET_BBFDM dmmap_diagnostics.ipping.MaximumResponseTimeDetailed=$max_time_det
|
||||||
|
$UCI_COMMIT_BBFDM
|
||||||
[ "$1" == "cwmp" ] && event_dignostic
|
[ "$1" == "cwmp" ] && event_dignostic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -117,6 +121,7 @@ ipping_stop_diagnostic() {
|
||||||
if [ -n "$pids" ]; then
|
if [ -n "$pids" ]; then
|
||||||
kill -9 $pids &>/dev/null
|
kill -9 $pids &>/dev/null
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.ipping.DiagnosticState=None
|
$UCI_SET_BBFDM dmmap_diagnostics.ipping.DiagnosticState=None
|
||||||
|
$UCI_COMMIT_BBFDM
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ UCI_GET_BBFDM="/sbin/uci -q -c /etc/bbfdm get"
|
||||||
UCI_SET_BBFDM="/sbin/uci -q -c /etc/bbfdm set"
|
UCI_SET_BBFDM="/sbin/uci -q -c /etc/bbfdm set"
|
||||||
UCI_ADD_BBFDM="/sbin/uci -q -c /etc/bbfdm add"
|
UCI_ADD_BBFDM="/sbin/uci -q -c /etc/bbfdm add"
|
||||||
UCI_DELETE_BBFDM="/sbin/uci -q -c /etc/bbfdm delete"
|
UCI_DELETE_BBFDM="/sbin/uci -q -c /etc/bbfdm delete"
|
||||||
|
UCI_COMMIT_BBFDM="/sbin/uci -q -c /etc/bbfdm commit"
|
||||||
UCI_SHOW_BBFDM="/sbin/uci -q -c /etc/bbfdm show"
|
UCI_SHOW_BBFDM="/sbin/uci -q -c /etc/bbfdm show"
|
||||||
LOG_FILE="/tmp/nslookup.log"
|
LOG_FILE="/tmp/nslookup.log"
|
||||||
|
|
||||||
|
|
@ -81,6 +82,7 @@ nslookup_launch() {
|
||||||
rm -f ${LOG_FILE}
|
rm -f ${LOG_FILE}
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.nslookup.SuccessCount=$success_count
|
$UCI_SET_BBFDM dmmap_diagnostics.nslookup.SuccessCount=$success_count
|
||||||
[ "$1" == "cwmp" ] && $UCI_SET_BBFDM dmmap_diagnostics.nslookup.DiagnosticState=Complete
|
[ "$1" == "cwmp" ] && $UCI_SET_BBFDM dmmap_diagnostics.nslookup.DiagnosticState=Complete
|
||||||
|
$UCI_COMMIT_BBFDM
|
||||||
[ "$1" == "cwmp" ] && event_dignostic
|
[ "$1" == "cwmp" ] && event_dignostic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,6 +91,7 @@ delete_all_results() {
|
||||||
for j in $($UCI_SHOW_BBFDM dmmap_diagnostics | grep "dmmap_diagnostics.@NSLookupResult.*=NSLookupResult"); do
|
for j in $($UCI_SHOW_BBFDM dmmap_diagnostics | grep "dmmap_diagnostics.@NSLookupResult.*=NSLookupResult"); do
|
||||||
$UCI_DELETE_BBFDM dmmap_diagnostics.@NSLookupResult[-1]
|
$UCI_DELETE_BBFDM dmmap_diagnostics.@NSLookupResult[-1]
|
||||||
done
|
done
|
||||||
|
$UCI_COMMIT_BBFDM
|
||||||
}
|
}
|
||||||
|
|
||||||
event_dignostic() {
|
event_dignostic() {
|
||||||
|
|
@ -108,6 +111,7 @@ nslookup_stop_diagnostic() {
|
||||||
if [ -n "$pids" ]; then
|
if [ -n "$pids" ]; then
|
||||||
kill -9 $pids &>/dev/null
|
kill -9 $pids &>/dev/null
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.nslookup.DiagnosticState=None
|
$UCI_SET_BBFDM dmmap_diagnostics.nslookup.DiagnosticState=None
|
||||||
|
$UCI_COMMIT_BBFDM
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
UCI_GET_BBFDM="/sbin/uci -q -c /etc/bbfdm get"
|
UCI_GET_BBFDM="/sbin/uci -q -c /etc/bbfdm get"
|
||||||
UCI_SET_BBFDM="/sbin/uci -q -c /etc/bbfdm set"
|
UCI_SET_BBFDM="/sbin/uci -q -c /etc/bbfdm set"
|
||||||
|
UCI_COMMIT_BBFDM="/sbin/uci -q -c /etc/bbfdm commit"
|
||||||
|
|
||||||
serverselection_get() {
|
serverselection_get() {
|
||||||
local val=`$UCI_GET_BBFDM $1`
|
local val=`$UCI_GET_BBFDM $1`
|
||||||
|
|
@ -11,15 +12,17 @@ serverselection_get() {
|
||||||
}
|
}
|
||||||
|
|
||||||
serverselection_launch() {
|
serverselection_launch() {
|
||||||
local i res ba stc times sc1 success_count min_time avg_time max_time avg_time_sum min max micros
|
local i proto device res ba stc times sc1 success_count min_time avg_time max_time avg_time_sum min max micros
|
||||||
local fasthost avg_time_host min_time_host max_time_host
|
local fasthost avg_time_host min_time_host max_time_host
|
||||||
[ "$1" == "cwmp" ] && [ "`$UCI_GET_BBFDM dmmap_diagnostics.serverselection.DiagnosticState`" != "Requested" ] && return
|
[ "$1" == "cwmp" ] && [ "`$UCI_GET_BBFDM dmmap_diagnostics.serverselection.DiagnosticState`" != "Requested" ] && return
|
||||||
local hostlist=`serverselection_get dmmap_diagnostics.serverselection.HostList`
|
local hostlist=`serverselection_get dmmap_diagnostics.serverselection.HostList`
|
||||||
local cnt=`serverselection_get dmmap_diagnostics.serverselection.NumberOfRepetitions 3`
|
local cnt=`serverselection_get dmmap_diagnostics.serverselection.NumberOfRepetitions 3`
|
||||||
local timeout=`serverselection_get dmmap_diagnostics.serverselection.Timeout 1000`
|
local timeout=`serverselection_get dmmap_diagnostics.serverselection.Timeout 1000`
|
||||||
local port=`serverselection_get dmmap_diagnostics.serverselection.port`
|
local port=`serverselection_get dmmap_diagnostics.serverselection.port`
|
||||||
|
local interface=`serverselection_get dmmap_diagnostics.serverselection.interface`
|
||||||
local protoversion=`serverselection_get dmmap_diagnostics.serverselection.ProtocolVersion Any`
|
local protoversion=`serverselection_get dmmap_diagnostics.serverselection.ProtocolVersion Any`
|
||||||
local proto=`serverselection_get dmmap_diagnostics.serverselection.Protocol ICMP`
|
local protocol=`serverselection_get dmmap_diagnostics.serverselection.Protocol ICMP`
|
||||||
|
if [ "$protoversion" == "IPv4" ]; then proto="-4"; elif [ "$protoversion" == "IPv6" ]; then proto="-6"; else proto=""; fi
|
||||||
[ "$hostlist" = "" ] && return
|
[ "$hostlist" = "" ] && return
|
||||||
timeout=$((timeout/1000))
|
timeout=$((timeout/1000))
|
||||||
[ "$timeout" = "0" ] && timeout="1"
|
[ "$timeout" = "0" ] && timeout="1"
|
||||||
|
|
@ -32,18 +35,17 @@ serverselection_launch() {
|
||||||
i=0
|
i=0
|
||||||
|
|
||||||
for host in $(echo $hostlist | tr "," "\n"); do
|
for host in $(echo $hostlist | tr "," "\n"); do
|
||||||
if [ "$proto" == "ICMP" ]; then
|
if [ "$protocol" == "ICMP" ]; then
|
||||||
|
[ ! -z "$interface" ] && device=`ifstatus $interface | jsonfilter -e @.device` && device="-I $device" || device=""
|
||||||
while [ $i -lt $cnt ]; do
|
while [ $i -lt $cnt ]; do
|
||||||
let i++
|
let i++
|
||||||
[ "$protoversion" = "Any" ] && res=$(ping -q -c 1 -W $timeout $host 2>&1)
|
res=$(ping -q $proto -c 1 -W $timeout $device $host 2>&1)
|
||||||
[ "$protoversion" = "IPv4" ] && res=$(ping -q -4 -c 1 -W $timeout $host 2>&1)
|
|
||||||
[ "$protoversion" = "IPv6" ] && res=$(ping -q -6 -c 1 -W $timeout $host 2>&1)
|
|
||||||
ba=`echo "$res" | grep "bad address"`
|
ba=`echo "$res" | grep "bad address"`
|
||||||
[ -n "$ba" ] && { $UCI_SET_BBFDM dmmap_diagnostics.serverselection.DiagnosticState=Error_CannotResolveHostName; break; }
|
[ -n "$ba" ] && { $UCI_SET_BBFDM dmmap_diagnostics.serverselection.DiagnosticState=Error_CannotResolveHostName; $UCI_COMMIT_BBFDM; break; }
|
||||||
ba=`echo "$res" | grep "unknown host"`
|
ba=`echo "$res" | grep "unknown host"`
|
||||||
[ -n "$ba" ] && { $UCI_SET_BBFDM dmmap_diagnostics.serverselection.DiagnosticState=Error_CannotResolveHostName; break; }
|
[ -n "$ba" ] && { $UCI_SET_BBFDM dmmap_diagnostics.serverselection.DiagnosticState=Error_CannotResolveHostName; $UCI_COMMIT_BBFDM; break; }
|
||||||
stc=`echo "$res" | grep "received"`
|
stc=`echo "$res" | grep "received"`
|
||||||
[ -z "$stc" ] && { $UCI_SET_BBFDM dmmap_diagnostics.serverselection.DiagnosticState=Error_Other; break; }
|
[ -z "$stc" ] && { $UCI_SET_BBFDM dmmap_diagnostics.serverselection.DiagnosticState=Error_Other; $UCI_COMMIT_BBFDM; break; }
|
||||||
times=`echo "$res" | grep "min/avg/max"`
|
times=`echo "$res" | grep "min/avg/max"`
|
||||||
[ -z "$times" ] && break
|
[ -z "$times" ] && break
|
||||||
sc1=`echo $stc | awk '{print $4}'`
|
sc1=`echo $stc | awk '{print $4}'`
|
||||||
|
|
@ -64,16 +66,15 @@ serverselection_launch() {
|
||||||
avg_time_sum=$((avg_time_sum+avg_time))
|
avg_time_sum=$((avg_time_sum+avg_time))
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
|
[ "$port" = "" ] && return
|
||||||
|
[ ! -z "$interface" ] && device=`ifstatus $interface | jsonfilter -e @.device` && device="-e $device" || device=""
|
||||||
while [ $i -lt $cnt ]; do
|
while [ $i -lt $cnt ]; do
|
||||||
[ "$port" = "" ] && return
|
|
||||||
let i++
|
let i++
|
||||||
[ "$protoversion" = "Any" ] && res=$(nping -c 1 --udp --dest-port $port --data-length 24 $host 2>&1)
|
res=$(nping $proto -c 1 --udp --dest-port $port --data-length 24 $device $host 2>&1)
|
||||||
[ "$protoversion" = "IPv4" ] && res=$(nping -4 -c 1 --udp --dest-port $port --data-length 24 $host 2>&1)
|
|
||||||
[ "$protoversion" = "IPv6" ] && res=$(nping -6 -c 1 --udp --dest-port $port --data-length 24 $host 2>&1)
|
|
||||||
ba=`echo "$res" | grep "RCVD"`
|
ba=`echo "$res" | grep "RCVD"`
|
||||||
[ -z "$ba" ] && { $UCI_SET_BBFDM dmmap_diagnostics.serverselection.DiagnosticState=Error_CannotResolveHostName; return; }
|
[ -z "$ba" ] && { $UCI_SET_BBFDM dmmap_diagnostics.serverselection.DiagnosticState=Error_CannotResolveHostName; $UCI_COMMIT_BBFDM; return; }
|
||||||
stc=`echo "$res" | grep "RCVD" | grep "unreachable"`
|
stc=`echo "$res" | grep "RCVD" | grep "unreachable"`
|
||||||
[ -n "$stc" ] && { $UCI_SET_BBFDM dmmap_diagnostics.serverselection.DiagnosticState=Error_Other; return; }
|
[ -n "$stc" ] && { $UCI_SET_BBFDM dmmap_diagnostics.serverselection.DiagnosticState=Error_Other; $UCI_COMMIT_BBFDM; return; }
|
||||||
times=`echo "$res" | grep "rtt"`
|
times=`echo "$res" | grep "rtt"`
|
||||||
[ -z "$times" ] && continue
|
[ -z "$times" ] && continue
|
||||||
sc1=`echo "$res" | grep "Rcvd" | awk -F': ' '{print $3}' | awk -F'(' '{ print $1 }'`
|
sc1=`echo "$res" | grep "Rcvd" | awk -F': ' '{print $3}' | awk -F'(' '{ print $1 }'`
|
||||||
|
|
@ -106,6 +107,7 @@ serverselection_launch() {
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.serverselection.AverageResponseTime=$avg_time_host
|
$UCI_SET_BBFDM dmmap_diagnostics.serverselection.AverageResponseTime=$avg_time_host
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.serverselection.MinimumResponseTime=$min_time_host
|
$UCI_SET_BBFDM dmmap_diagnostics.serverselection.MinimumResponseTime=$min_time_host
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.serverselection.MaximumResponseTime=$max_time_host
|
$UCI_SET_BBFDM dmmap_diagnostics.serverselection.MaximumResponseTime=$max_time_host
|
||||||
|
$UCI_COMMIT_BBFDM
|
||||||
[ "$1" == "cwmp" ] && event_dignostic
|
[ "$1" == "cwmp" ] && event_dignostic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -125,6 +127,7 @@ serverselection_stop_diagnostic() {
|
||||||
if [ -n "$pids" ]; then
|
if [ -n "$pids" ]; then
|
||||||
kill -9 $pids &>/dev/null
|
kill -9 $pids &>/dev/null
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.serverselection.DiagnosticState=None
|
$UCI_SET_BBFDM dmmap_diagnostics.serverselection.DiagnosticState=None
|
||||||
|
$UCI_COMMIT_BBFDM
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ UCI_GET_BBFDM="/sbin/uci -q -c /etc/bbfdm get"
|
||||||
UCI_SET_BBFDM="/sbin/uci -q -c /etc/bbfdm set"
|
UCI_SET_BBFDM="/sbin/uci -q -c /etc/bbfdm set"
|
||||||
UCI_ADD_BBFDM="/sbin/uci -q -c /etc/bbfdm add"
|
UCI_ADD_BBFDM="/sbin/uci -q -c /etc/bbfdm add"
|
||||||
UCI_DELETE_BBFDM="/sbin/uci -q -c /etc/bbfdm delete"
|
UCI_DELETE_BBFDM="/sbin/uci -q -c /etc/bbfdm delete"
|
||||||
|
UCI_COMMIT_BBFDM="/sbin/uci -q -c /etc/bbfdm commit"
|
||||||
UCI_SHOW_BBFDM="/sbin/uci -q -c /etc/bbfdm show"
|
UCI_SHOW_BBFDM="/sbin/uci -q -c /etc/bbfdm show"
|
||||||
|
|
||||||
traceroute_get() {
|
traceroute_get() {
|
||||||
|
|
@ -14,23 +15,24 @@ traceroute_get() {
|
||||||
}
|
}
|
||||||
|
|
||||||
traceroute_launch() {
|
traceroute_launch() {
|
||||||
local i res host ip time=0
|
local i proto device res host ip time=0
|
||||||
[ "$1" == "cwmp" ] && [ "`$UCI_GET_BBFDM dmmap_diagnostics.traceroute.DiagnosticState`" != "Requested" ] && return
|
[ "$1" == "cwmp" ] && [ "`$UCI_GET_BBFDM dmmap_diagnostics.traceroute.DiagnosticState`" != "Requested" ] && return
|
||||||
local host=`traceroute_get dmmap_diagnostics.traceroute.Host`
|
local host=`traceroute_get dmmap_diagnostics.traceroute.Host`
|
||||||
local cnt=`traceroute_get dmmap_diagnostics.traceroute.NumberOfTries 3`
|
local cnt=`traceroute_get dmmap_diagnostics.traceroute.NumberOfTries 3`
|
||||||
local dsize=`traceroute_get dmmap_diagnostics.traceroute.DataBlockSize 38`
|
local dsize=`traceroute_get dmmap_diagnostics.traceroute.DataBlockSize 38`
|
||||||
local timeout=`traceroute_get dmmap_diagnostics.traceroute.Timeout 5000`
|
local timeout=`traceroute_get dmmap_diagnostics.traceroute.Timeout 5000`
|
||||||
local maxhop=`traceroute_get dmmap_diagnostics.traceroute.MaxHops 30`
|
local maxhop=`traceroute_get dmmap_diagnostics.traceroute.MaxHops 30`
|
||||||
local proto=`traceroute_get dmmap_diagnostics.traceroute.ProtocolVersion Any`
|
local interface=`traceroute_get dmmap_diagnostics.traceroute.interface`
|
||||||
|
local protocol=`traceroute_get dmmap_diagnostics.traceroute.ProtocolVersion Any`
|
||||||
|
[ ! -z "$interface" ] && device=`ifstatus $interface | jsonfilter -e @.device` && device="-i $device" || device=""
|
||||||
|
if [ "$protocol" == "IPv4" ]; then proto="-4"; elif [ "$protocol" == "IPv6" ]; then proto="-6"; else proto=""; fi
|
||||||
[ "$host" = "" ] && return
|
[ "$host" = "" ] && return
|
||||||
timeout=$((timeout/1000))
|
timeout=$((timeout/1000))
|
||||||
[ "$timeout" = "0" ] && timeout = "1"
|
[ "$timeout" = "0" ] && timeout = "1"
|
||||||
i=-2
|
i=-2
|
||||||
delete_all_route_hops
|
delete_all_route_hops
|
||||||
rm -f /tmp/traceres
|
rm -f /tmp/traceres
|
||||||
[ "$proto" = "Any" ] && traceroute -m $maxhop -w $timeout -q $cnt $host $dsize 2>&1 >/tmp/traceres
|
traceroute -m $maxhop -w $timeout -q $cnt $proto $device $host $dsize 2>&1 >/tmp/traceres
|
||||||
[ "$proto" = "IPv4" ] && traceroute -m $maxhop -w $timeout -q $cnt -4 $host $dsize 2>&1 >/tmp/traceres
|
|
||||||
[ "$proto" = "IPv6" ] && traceroute -m $maxhop -w $timeout -q $cnt -6 $host $dsize 2>&1 >/tmp/traceres
|
|
||||||
while read _ host ip time _; do
|
while read _ host ip time _; do
|
||||||
[ "$host" = "*" -a "$ip" = "*" ] && continue
|
[ "$host" = "*" -a "$ip" = "*" ] && continue
|
||||||
let i++
|
let i++
|
||||||
|
|
@ -48,6 +50,7 @@ traceroute_launch() {
|
||||||
[ "$1" == "cwmp" ] && $UCI_SET_BBFDM dmmap_diagnostics.traceroute.DiagnosticState=Complete
|
[ "$1" == "cwmp" ] && $UCI_SET_BBFDM dmmap_diagnostics.traceroute.DiagnosticState=Complete
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.traceroute.NumberOfHops=$i
|
$UCI_SET_BBFDM dmmap_diagnostics.traceroute.NumberOfHops=$i
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.traceroute.ResponseTime=$($UCI_GET_BBFDM dmmap_diagnostics.@RouteHops[-1].time)
|
$UCI_SET_BBFDM dmmap_diagnostics.traceroute.ResponseTime=$($UCI_GET_BBFDM dmmap_diagnostics.@RouteHops[-1].time)
|
||||||
|
$UCI_COMMIT_BBFDM
|
||||||
[ "$1" == "cwmp" ] && event_diagnostic
|
[ "$1" == "cwmp" ] && event_diagnostic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,6 +58,7 @@ delete_all_route_hops() {
|
||||||
local j
|
local j
|
||||||
for j in $($UCI_SHOW_BBFDM dmmap_diagnostics | grep "dmmap_diagnostics.@RouteHops.*=RouteHops"); do
|
for j in $($UCI_SHOW_BBFDM dmmap_diagnostics | grep "dmmap_diagnostics.@RouteHops.*=RouteHops"); do
|
||||||
$UCI_DELETE_BBFDM dmmap_diagnostics.@RouteHops[-1]
|
$UCI_DELETE_BBFDM dmmap_diagnostics.@RouteHops[-1]
|
||||||
|
$UCI_COMMIT_BBFDM
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,6 +80,7 @@ traceroute_stop() {
|
||||||
if [ -n "$pids" ]; then
|
if [ -n "$pids" ]; then
|
||||||
kill -9 $pids 2>/dev/null
|
kill -9 $pids 2>/dev/null
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.traceroute.DiagnosticState=None
|
$UCI_SET_BBFDM dmmap_diagnostics.traceroute.DiagnosticState=None
|
||||||
|
$UCI_COMMIT_BBFDM
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
UCI_GET_BBFDM="/sbin/uci -q -c /etc/bbfdm get"
|
UCI_GET_BBFDM="/sbin/uci -q -c /etc/bbfdm get"
|
||||||
UCI_SET_BBFDM="/sbin/uci -q -c /etc/bbfdm set"
|
UCI_SET_BBFDM="/sbin/uci -q -c /etc/bbfdm set"
|
||||||
|
UCI_COMMIT_BBFDM="/sbin/uci -q -c /etc/bbfdm commit"
|
||||||
|
|
||||||
udpecho_get() {
|
udpecho_get() {
|
||||||
local val=`$UCI_GET_BBFDM $1`
|
local val=`$UCI_GET_BBFDM $1`
|
||||||
|
|
@ -11,15 +12,18 @@ udpecho_get() {
|
||||||
}
|
}
|
||||||
|
|
||||||
udpecho_launch() {
|
udpecho_launch() {
|
||||||
local i res ba stc times sc1 success_count failure_count min_time avg_time max_time avg_time_sum min max micros
|
local i proto device res ba stc times sc1 success_count failure_count min_time avg_time max_time avg_time_sum min max micros
|
||||||
[ "$1" == "cwmp" ] && [ "`$UCI_GET_BBFDM dmmap_diagnostics.udpechodiag.DiagnosticState`" != "Requested" ] && return
|
[ "$1" == "cwmp" ] && [ "`$UCI_GET_BBFDM dmmap_diagnostics.udpechodiag.DiagnosticState`" != "Requested" ] && return
|
||||||
local host=`udpecho_get dmmap_diagnostics.udpechodiag.Host`
|
local host=`udpecho_get dmmap_diagnostics.udpechodiag.Host`
|
||||||
local port=`udpecho_get dmmap_diagnostics.udpechodiag.port`
|
local port=`udpecho_get dmmap_diagnostics.udpechodiag.port`
|
||||||
local cnt=`udpecho_get dmmap_diagnostics.udpechodiag.NumberOfRepetitions 1`
|
local cnt=`udpecho_get dmmap_diagnostics.udpechodiag.NumberOfRepetitions 1`
|
||||||
local dsize=`udpecho_get dmmap_diagnostics.udpechodiag.DataBlockSize 24`
|
local dsize=`udpecho_get dmmap_diagnostics.udpechodiag.DataBlockSize 24`
|
||||||
local dscp=`udpecho_get dmmap_diagnostics.udpechodiag.DSCP 0`
|
local dscp=`udpecho_get dmmap_diagnostics.udpechodiag.DSCP 0`
|
||||||
local proto=`udpecho_get dmmap_diagnostics.udpechodiag.ProtocolVersion Any`
|
local interface=`udpecho_get dmmap_diagnostics.udpechodiag.interface`
|
||||||
|
local protocol=`udpecho_get dmmap_diagnostics.udpechodiag.ProtocolVersion Any`
|
||||||
local inter_time=`udpecho_get dmmap_diagnostics.udpechodiag.InterTransmissionTime 1000`
|
local inter_time=`udpecho_get dmmap_diagnostics.udpechodiag.InterTransmissionTime 1000`
|
||||||
|
[ ! -z "$interface" ] && device=`ifstatus $interface | jsonfilter -e @.device` && device="-e $device" || device=""
|
||||||
|
if [ "$protocol" == "IPv4" ]; then proto="-4"; elif [ "$protocol" == "IPv6" ]; then proto="-6"; else proto=""; fi
|
||||||
local tos=$((dscp<<2))
|
local tos=$((dscp<<2))
|
||||||
inter_time=$((inter_time/1000))
|
inter_time=$((inter_time/1000))
|
||||||
[ "$inter_time" = "0" ] && inter_time="1"
|
[ "$inter_time" = "0" ] && inter_time="1"
|
||||||
|
|
@ -34,13 +38,11 @@ udpecho_launch() {
|
||||||
|
|
||||||
while [ $i -lt $cnt ]; do
|
while [ $i -lt $cnt ]; do
|
||||||
let i++
|
let i++
|
||||||
[ "$proto" = "Any" ] && res=$(nping -c 1 --tos $tos --udp --dest-port $port --data-length $dsize $host 2>&1)
|
res=$(nping $proto -c 1 --tos $tos --udp --dest-port $port --data-length $dsize $device $host 2>&1)
|
||||||
[ "$proto" = "IPv4" ] && res=$(nping -4 -c 1 --tos $tos --udp --dest-port $port --data-length $dsize $host 2>&1)
|
|
||||||
[ "$proto" = "IPv6" ] && res=$(nping -6 -c 1 --tos $tos --udp --dest-port $port --data-length $dsize $host 2>&1)
|
|
||||||
ba=`echo "$res" | grep "RCVD"`
|
ba=`echo "$res" | grep "RCVD"`
|
||||||
[ -z "$ba" ] && { $UCI_SET_BBFDM dmmap_diagnostics.udpechodiag.DiagnosticState=Error_CannotResolveHostName; return; }
|
[ -z "$ba" ] && { $UCI_SET_BBFDM dmmap_diagnostics.udpechodiag.DiagnosticState=Error_CannotResolveHostName; $UCI_COMMIT_BBFDM; return; }
|
||||||
stc=`echo "$res" | grep "RCVD" | grep "unreachable"`
|
stc=`echo "$res" | grep "RCVD" | grep "unreachable"`
|
||||||
[ -n "$stc" ] && { $UCI_SET_BBFDM dmmap_diagnostics.udpechodiag.DiagnosticState=Error_Other; return; }
|
[ -n "$stc" ] && { $UCI_SET_BBFDM dmmap_diagnostics.udpechodiag.DiagnosticState=Error_Other; $UCI_COMMIT_BBFDM; return; }
|
||||||
times=`echo "$res" | grep "rtt"`
|
times=`echo "$res" | grep "rtt"`
|
||||||
[ -z "$times" ] && continue
|
[ -z "$times" ] && continue
|
||||||
sc1=`echo "$res" | grep "Rcvd" | awk -F': ' '{print $3}' | awk -F'(' '{ print $1 }'`
|
sc1=`echo "$res" | grep "Rcvd" | awk -F': ' '{print $3}' | awk -F'(' '{ print $1 }'`
|
||||||
|
|
@ -70,6 +72,7 @@ udpecho_launch() {
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.udpechodiag.AverageResponseTime=$avg_time
|
$UCI_SET_BBFDM dmmap_diagnostics.udpechodiag.AverageResponseTime=$avg_time
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.udpechodiag.MinimumResponseTime=$min_time
|
$UCI_SET_BBFDM dmmap_diagnostics.udpechodiag.MinimumResponseTime=$min_time
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.udpechodiag.MaximumResponseTime=$max_time
|
$UCI_SET_BBFDM dmmap_diagnostics.udpechodiag.MaximumResponseTime=$max_time
|
||||||
|
$UCI_COMMIT_BBFDM
|
||||||
[ "$1" == "cwmp" ] && event_dignostic
|
[ "$1" == "cwmp" ] && event_dignostic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,6 +92,7 @@ udpecho_stop_diagnostic() {
|
||||||
if [ -n "$pids" ]; then
|
if [ -n "$pids" ]; then
|
||||||
kill -9 $pids &>/dev/null
|
kill -9 $pids &>/dev/null
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.udpechodiag.DiagnosticState=None
|
$UCI_SET_BBFDM dmmap_diagnostics.udpechodiag.DiagnosticState=None
|
||||||
|
$UCI_COMMIT_BBFDM
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ UCI_GET_BBFDM="/sbin/uci -q -c /etc/bbfdm get"
|
||||||
UCI_SET_BBFDM="/sbin/uci -q -c /etc/bbfdm set"
|
UCI_SET_BBFDM="/sbin/uci -q -c /etc/bbfdm set"
|
||||||
UCI_ADD_BBFDM="/sbin/uci -q -c /etc/bbfdm add"
|
UCI_ADD_BBFDM="/sbin/uci -q -c /etc/bbfdm add"
|
||||||
UCI_DELETE_BBFDM="/sbin/uci -q -c /etc/bbfdm delete"
|
UCI_DELETE_BBFDM="/sbin/uci -q -c /etc/bbfdm delete"
|
||||||
|
UCI_COMMIT_BBFDM="/sbin/uci -q -c /etc/bbfdm commit"
|
||||||
CAPTURE_FILE="/tmp/upload_dump"
|
CAPTURE_FILE="/tmp/upload_dump"
|
||||||
UPLOAD_DIAGNOSTIC_FILE="/tmp/bbfdm_upload_diagnostic"
|
UPLOAD_DIAGNOSTIC_FILE="/tmp/bbfdm_upload_diagnostic"
|
||||||
CONNECTION_TIMEOUT=20
|
CONNECTION_TIMEOUT=20
|
||||||
|
|
@ -17,58 +18,55 @@ upload_get() {
|
||||||
}
|
}
|
||||||
|
|
||||||
upload_launch() {
|
upload_launch() {
|
||||||
local tx_bytes_before rx_bytes_before time1 tx_bytes_after rx_bytes_after time2 res ba stc periodtime
|
local proto tx_bytes_before rx_bytes_before time1 tx_bytes_after rx_bytes_after time2 res ba stc periodtime
|
||||||
local url=$2
|
local url=$2
|
||||||
local interface=$3
|
local device=$3
|
||||||
local size=$4
|
local size=$4
|
||||||
[ "$1" == "cwmp" ] && [ "`$UCI_GET_BBFDM dmmap_diagnostics.upload.DiagnosticState`" != "Requested" ] && return
|
[ "$1" == "cwmp" ] && [ "`$UCI_GET_BBFDM dmmap_diagnostics.upload.DiagnosticState`" != "Requested" ] && return
|
||||||
[ "$url" = "" ] && { $UCI_SET_BBFDM dmmap_diagnostics.upload.DiagnosticState=Error_InitConnectionFailed; return; }
|
[ "$url" = "" ] && { $UCI_SET_BBFDM dmmap_diagnostics.upload.DiagnosticState=Error_InitConnectionFailed; $UCI_COMMIT_BBFDM; return; }
|
||||||
local proto=`upload_get dmmap_diagnostics.upload.ProtocolVersion Any`
|
local protocol=`upload_get dmmap_diagnostics.upload.ProtocolVersion Any`
|
||||||
|
if [ "$protocol" == "IPv4" ]; then proto="-4"; elif [ "$protocol" == "IPv6" ]; then proto="-6"; else proto=""; fi
|
||||||
# Disable acceleration on Broadcom devices to capture all packets with tcpdump
|
# Disable acceleration on Broadcom devices to capture all packets with tcpdump
|
||||||
[ -e /usr/sbin/fcctl ] && { fcctl disable >/dev/null 2>&1; fcctl flush >/dev/null 2>&1; }
|
[ -e /usr/sbin/fcctl ] && { fcctl disable >/dev/null 2>&1; fcctl flush >/dev/null 2>&1; }
|
||||||
tcpdump -i $interface tcp -w ${CAPTURE_FILE} > /dev/null 2>&1 &
|
tcpdump -i $device tcp -w ${CAPTURE_FILE} > /dev/null 2>&1 &
|
||||||
PID=$!
|
PID=$!
|
||||||
sleep 1
|
sleep 1
|
||||||
dd if=/dev/zero of=${UPLOAD_DIAGNOSTIC_FILE} bs=${size} count=1 2>/dev/null
|
dd if=/dev/zero of=${UPLOAD_DIAGNOSTIC_FILE} bs=${size} count=1 2>/dev/null
|
||||||
if [ ${url:0:7} = http:// ]; then
|
if [ ${url:0:7} = http:// ]; then
|
||||||
tx_bytes_before=`ubus call network.device status "{'name':'$interface'}" | jsonfilter -e @.statistics.tx_bytes`
|
tx_bytes_before=`ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.tx_bytes`
|
||||||
rx_bytes_before=`ubus call network.device status "{'name':'$interface'}" | jsonfilter -e @.statistics.rx_bytes`
|
rx_bytes_before=`ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.rx_bytes`
|
||||||
time1=`date +%s`
|
time1=`date +%s`
|
||||||
[ "$proto" = "Any" ] && res=$(curl --fail --connect-timeout ${CONNECTION_TIMEOUT} -T ${UPLOAD_DIAGNOSTIC_FILE} $url 2>&1)
|
res=$(curl $proto --fail --connect-timeout ${CONNECTION_TIMEOUT} -T ${UPLOAD_DIAGNOSTIC_FILE} $url 2>&1)
|
||||||
[ "$proto" = "IPv4" ] && res=$(curl -4 --fail --connect-timeout ${CONNECTION_TIMEOUT} -T ${UPLOAD_DIAGNOSTIC_FILE} $url 2>&1)
|
|
||||||
[ "$proto" = "IPv6" ] && res=$(curl -6 --fail --connect-timeout ${CONNECTION_TIMEOUT} -T ${UPLOAD_DIAGNOSTIC_FILE} $url 2>&1)
|
|
||||||
time2=`date +%s`
|
time2=`date +%s`
|
||||||
tx_bytes_after=`ubus call network.device status "{'name':'$interface'}" | jsonfilter -e @.statistics.tx_bytes`
|
tx_bytes_after=`ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.tx_bytes`
|
||||||
rx_bytes_after=`ubus call network.device status "{'name':'$interface'}" | jsonfilter -e @.statistics.rx_bytes`
|
rx_bytes_after=`ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.rx_bytes`
|
||||||
ba=`echo "$res" | grep "bad address"`
|
ba=`echo "$res" | grep "bad address"`
|
||||||
[ -n "$ba" ] && { $UCI_SET_BBFDM dmmap_diagnostics.upload.DiagnosticState=Error_InitConnectionFailed; kill $PID &> /dev/null; return; }
|
[ -n "$ba" ] && { $UCI_SET_BBFDM dmmap_diagnostics.upload.DiagnosticState=Error_InitConnectionFailed; $UCI_COMMIT_BBFDM; kill $PID &> /dev/null; return; }
|
||||||
stc=`echo "$res" | grep "404 Not Found"`
|
stc=`echo "$res" | grep "404 Not Found"`
|
||||||
[ -n "$stc" ] && { $UCI_SET_BBFDM dmmap_diagnostics.upload.DiagnosticState=Error_NoResponse; kill $PID &> /dev/null; return; }
|
[ -n "$stc" ] && { $UCI_SET_BBFDM dmmap_diagnostics.upload.DiagnosticState=Error_NoResponse; $UCI_COMMIT_BBFDM; kill $PID &> /dev/null; return; }
|
||||||
stc=`echo "$res" |sed -n 3p|awk '{print $13}'`
|
stc=`echo "$res" |sed -n 3p|awk '{print $13}'`
|
||||||
[ "$stc" != "100" ] && { $UCI_SET_BBFDM dmmap_diagnostics.upload.DiagnosticState=Error_TransferFailed; kill $PID &> /dev/null; return; }
|
[ "$stc" != "100" ] && { $UCI_SET_BBFDM dmmap_diagnostics.upload.DiagnosticState=Error_TransferFailed; $UCI_COMMIT_BBFDM; kill $PID &> /dev/null; return; }
|
||||||
elif [ ${url:0:6} = ftp:// ]; then
|
elif [ ${url:0:6} = ftp:// ]; then
|
||||||
#add user and pass if they exist
|
#add user and pass if they exist
|
||||||
substr="@"
|
substr="@"
|
||||||
if [ -z "${url##*$substr*}" ] ;then
|
if [ -z "${url##*$substr*}" ] ;then
|
||||||
url=`echo $url |sed -e "s/ftp:\/\/\([^:]*\):\([^:]*\)@\(.*\)/-u \1:\2 ftp:\/\/\3/"`
|
url=`echo $url |sed -e "s/ftp:\/\/\([^:]*\):\([^:]*\)@\(.*\)/-u \1:\2 ftp:\/\/\3/"`
|
||||||
fi
|
fi
|
||||||
tx_bytes_before=`ubus call network.device status "{'name':'$interface'}" | jsonfilter -e @.statistics.tx_bytes`
|
tx_bytes_before=`ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.tx_bytes`
|
||||||
rx_bytes_before=`ubus call network.device status "{'name':'$interface'}" | jsonfilter -e @.statistics.rx_bytes`
|
rx_bytes_before=`ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.rx_bytes`
|
||||||
time1=`date +%s`
|
time1=`date +%s`
|
||||||
[ "$proto" = "Any" ] && res=$(curl --fail --disable-epsv --ftp-pasv --connect-timeout ${CONNECTION_TIMEOUT} -T ${UPLOAD_DIAGNOSTIC_FILE} $url 2>&1)
|
res=$(curl $proto --fail --disable-epsv --ftp-pasv --connect-timeout ${CONNECTION_TIMEOUT} -T ${UPLOAD_DIAGNOSTIC_FILE} $url 2>&1)
|
||||||
[ "$proto" = "IPv4" ] && res=$(curl -4 --fail --disable-epsv --ftp-pasv --connect-timeout ${CONNECTION_TIMEOUT} -T ${UPLOAD_DIAGNOSTIC_FILE} $url 2>&1)
|
|
||||||
[ "$proto" = "IPv6" ] && res=$(curl -6 --fail --disable-epsv --ftp-pasv --connect-timeout ${CONNECTION_TIMEOUT} -T ${UPLOAD_DIAGNOSTIC_FILE} $url 2>&1)
|
|
||||||
time2=`date +%s`
|
time2=`date +%s`
|
||||||
tx_bytes_after=`ubus call network.device status "{'name':'$interface'}" | jsonfilter -e @.statistics.tx_bytes`
|
tx_bytes_after=`ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.tx_bytes`
|
||||||
rx_bytes_after=`ubus call network.device status "{'name':'$interface'}" | jsonfilter -e @.statistics.rx_bytes`
|
rx_bytes_after=`ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.rx_bytes`
|
||||||
ba=`echo "$res" | grep "Couldn't resolve host"`
|
ba=`echo "$res" | grep "Couldn't resolve host"`
|
||||||
[ -n "$ba" ] && { $UCI_SET_BBFDM dmmap_diagnostics.upload.DiagnosticState=Error_InitConnectionFailed; kill $PID 2> /dev/null; return; }
|
[ -n "$ba" ] && { $UCI_SET_BBFDM dmmap_diagnostics.upload.DiagnosticState=Error_InitConnectionFailed; $UCI_COMMIT_BBFDM; kill $PID 2> /dev/null; return; }
|
||||||
stc=`echo "$res" | grep "Access denied"`
|
stc=`echo "$res" | grep "Access denied"`
|
||||||
[ -n "$stc" ] && { $UCI_SET_BBFDM dmmap_diagnostics.upload.DiagnosticState=Error_LoginFailed; kill $PID 2> /dev/null; return; }
|
[ -n "$stc" ] && { $UCI_SET_BBFDM dmmap_diagnostics.upload.DiagnosticState=Error_LoginFailed; $UCI_COMMIT_BBFDM; kill $PID 2> /dev/null; return; }
|
||||||
stc=`echo "$res" | grep "Failed FTP upload"`
|
stc=`echo "$res" | grep "Failed FTP upload"`
|
||||||
[ -n "$stc" ] && { $UCI_SET_BBFDM dmmap_diagnostics.upload.DiagnosticState=Error_NoResponse; kill $PID 2> /dev/null; return; }
|
[ -n "$stc" ] && { $UCI_SET_BBFDM dmmap_diagnostics.upload.DiagnosticState=Error_NoResponse; $UCI_COMMIT_BBFDM; kill $PID 2> /dev/null; return; }
|
||||||
stc=`echo "$res" |tail -n 1 |awk '{print $(NF-11)}'`
|
stc=`echo "$res" |tail -n 1 |awk '{print $(NF-11)}'`
|
||||||
[ "$stc" != "100" ] && { $UCI_SET_BBFDM dmmap_diagnostics.upload.DiagnosticState=Error_TransferFailed; kill $PID 2> /dev/null; return; }
|
[ "$stc" != "100" ] && { $UCI_SET_BBFDM dmmap_diagnostics.upload.DiagnosticState=Error_TransferFailed; $UCI_COMMIT_BBFDM; kill $PID 2> /dev/null; return; }
|
||||||
fi
|
fi
|
||||||
tx_bytes=$((tx_bytes_after-tx_bytes_before))
|
tx_bytes=$((tx_bytes_after-tx_bytes_before))
|
||||||
rx_bytes=$((rx_bytes_after-rx_bytes_before))
|
rx_bytes=$((rx_bytes_after-rx_bytes_before))
|
||||||
|
|
@ -87,12 +85,13 @@ upload_launch() {
|
||||||
else
|
else
|
||||||
$UCI_DELETE_BBFDM dmmap_diagnostics.@UploadPerConnection[0]
|
$UCI_DELETE_BBFDM dmmap_diagnostics.@UploadPerConnection[0]
|
||||||
fi
|
fi
|
||||||
|
$UCI_COMMIT_BBFDM
|
||||||
rm ${UPLOAD_DIAGNOSTIC_FILE} &>/dev/null
|
rm ${UPLOAD_DIAGNOSTIC_FILE} &>/dev/null
|
||||||
sleep 3
|
sleep 3
|
||||||
local pids=`ps | grep $PID`
|
local pids=`ps | grep $PID`
|
||||||
kill $PID &>/dev/null
|
kill $PID &>/dev/null
|
||||||
# Enable acceleration on Broadcom devices after killing the tcpdump pid
|
# Enable acceleration on Broadcom devices after killing the tcpdump pid
|
||||||
[ -e /usr/sbin/fcctl ] && { fcctl enable >/dev/null 2>&1; fcctl flush >/dev/null 2>&1; }
|
[ -e /usr/sbin/fcctl ] && { fcctl enable >/dev/null 2>&1; fcctl flush >/dev/null 2>&1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
upload_stop_diagnostic() {
|
upload_stop_diagnostic() {
|
||||||
|
|
@ -102,15 +101,16 @@ upload_stop_diagnostic() {
|
||||||
kill -9 $pids &>/dev/null
|
kill -9 $pids &>/dev/null
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.upload.DiagnosticState=None
|
$UCI_SET_BBFDM dmmap_diagnostics.upload.DiagnosticState=None
|
||||||
fi
|
fi
|
||||||
local pids=`ps | grep upload_launch.*run | grep -v grep | awk '{print $1}'`
|
local pids=`ps | grep upload_launch.*run | grep -v grep | awk '{print $1}'`
|
||||||
if [ -n "$pids" ]; then
|
if [ -n "$pids" ]; then
|
||||||
kids=$(grep -l "PPid.*$pids" /proc/*/task/*/status | grep -o "[0-9]*")
|
kids=$(grep -l "PPid.*$pids" /proc/*/task/*/status | grep -o "[0-9]*")
|
||||||
for kid in $kids; do
|
for kid in $kids; do
|
||||||
kill -9 $kid &>/dev/null
|
kill -9 $kid &>/dev/null
|
||||||
done
|
done
|
||||||
kill -9 $pids &>/dev/null
|
kill -9 $pids &>/dev/null
|
||||||
$UCI_SET_BBFDM dmmap_diagnostics.upload.DiagnosticState=None
|
$UCI_SET_BBFDM dmmap_diagnostics.upload.DiagnosticState=None
|
||||||
fi
|
fi
|
||||||
|
$UCI_COMMIT_BBFDM
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$1" == "run" ] ; then
|
if [ "$1" == "run" ] ; then
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue