mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2026-02-20 03:01:26 +01:00
Ticket refs #378: TR-181: Device.IP.Diagnostics
This commit is contained in:
parent
a335f0f50d
commit
db9e48dbfb
31 changed files with 3707 additions and 243 deletions
|
|
@ -239,4 +239,25 @@ icwmp_xmppd_LDADD = \
|
|||
$(LIBUBOX_LIBS) \
|
||||
$(LIBSTROPHE_LIBS)
|
||||
endif
|
||||
|
||||
|
||||
bin_PROGRAMS += icwmp_udpechoserverd
|
||||
|
||||
icwmp_udpechoserverd_SOURCES = \
|
||||
../udpechoserver/udpechoserver.c \
|
||||
../udpechoserver/udpechoserver.h \
|
||||
../udpechoserver/udpechoserveruci.c \
|
||||
../udpechoserver/udpechoserveruci.h \
|
||||
../udpechoserver/udpechoserverlog.c \
|
||||
../udpechoserver/udpechoserverlog.h
|
||||
|
||||
icwmp_udpechoserverd_CFLAGS = \
|
||||
$(AM_CFLAGS) \
|
||||
$(LIBUCI_CFLAGS)
|
||||
|
||||
icwmp_udpechoserverd_LDFLAGS = \
|
||||
$(AM_LDFLAGS) \
|
||||
$(LIBUCI_LDFLAGS)
|
||||
|
||||
icwmp_udpechoserverd_LDADD = \
|
||||
$(AM_LIBS) \
|
||||
$(LIBUCI_LIBS)
|
||||
|
|
|
|||
8
config/cwmp_udpechoserver
Normal file
8
config/cwmp_udpechoserver
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
config udpechoserver 'udpechoserver'
|
||||
option enable '0'
|
||||
option interface ''
|
||||
option address ''
|
||||
option server_port ''
|
||||
option plus '0'
|
||||
#Log levels: Critical=0, Warning=1, Notice=2, Info=3, Debug=4
|
||||
option log_level '3'
|
||||
18
cwmp.c
18
cwmp.c
|
|
@ -563,6 +563,24 @@ int run_session_end_func (struct session *session)
|
|||
cwmp_nslookup_diagnostic();
|
||||
}
|
||||
|
||||
if (end_session_flag & END_SESSION_TRACEROUTE_DIAGNOSTIC)
|
||||
{
|
||||
CWMP_LOG (INFO,"Executing traceroutediagnostic: end session request");
|
||||
cwmp_traceroute_diagnostic();
|
||||
}
|
||||
|
||||
if (end_session_flag & END_SESSION_UDPECHO_DIAGNOSTIC)
|
||||
{
|
||||
CWMP_LOG (INFO,"Executing udpechodiagnostic: end session request");
|
||||
cwmp_udp_echo_diagnostic();
|
||||
}
|
||||
|
||||
if (end_session_flag & END_SESSION_SERVERSELECTION_DIAGNOSTIC)
|
||||
{
|
||||
CWMP_LOG (INFO,"Executing serverselectiondiagnostic: end session request");
|
||||
cwmp_serverselection_diagnostic();
|
||||
}
|
||||
|
||||
dm_entry_restart_services();
|
||||
|
||||
end_session_flag = 0;
|
||||
|
|
|
|||
169
diagnostic.c
169
diagnostic.c
|
|
@ -4,8 +4,9 @@
|
|||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2013 Inteno Broadband Technology AB
|
||||
* Author Imen Bhiri <imen.bhiri@pivasoftware.com> *
|
||||
* Copyright (C) 2019 iopsys Software Solutions AB
|
||||
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
@ -34,7 +35,6 @@
|
|||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
int read_next;
|
||||
struct download_diag download_stats = {0};
|
||||
struct upload_diagnostic_stats upload_stats = {0};
|
||||
|
|
@ -43,37 +43,34 @@ static void http_upload_per_packet(libtrace_packet_t *packet);
|
|||
static void libtrace_cleanup(libtrace_t *trace, libtrace_packet_t *packet);
|
||||
static void set_download_stats();
|
||||
static void set_upload_stats();
|
||||
int init_download_stats()
|
||||
|
||||
void init_download_stats(void)
|
||||
{
|
||||
memset(&download_stats, 0, sizeof(download_stats));
|
||||
}
|
||||
|
||||
int init_upload_stats()
|
||||
void init_upload_stats(void)
|
||||
{
|
||||
memset(&upload_stats, 0, sizeof(upload_stats));
|
||||
}
|
||||
|
||||
static void ftp_download_per_packet(libtrace_packet_t *packet, int first_packet)
|
||||
static void ftp_download_per_packet(libtrace_packet_t *packet)
|
||||
{
|
||||
struct tm lt;
|
||||
struct timeval ts;
|
||||
libtrace_tcp_t *tcp;
|
||||
char tcp_flag[16] = "";
|
||||
char *nexthdr;
|
||||
libtrace_ip_t *ip;
|
||||
char s_now[default_date_size];
|
||||
uint8_t proto;
|
||||
uint32_t remaining;
|
||||
tcp = trace_get_transport(packet, &proto, &remaining);
|
||||
|
||||
tcp = trace_get_transport(packet, &proto, &remaining);
|
||||
if (tcp == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
nexthdr = trace_get_payload_from_tcp(tcp, &remaining);
|
||||
}
|
||||
|
||||
if (tcp->ecn_ns) strcat(tcp_flag, "ECN_NS ");
|
||||
if (tcp->cwr) strcat(tcp_flag, "CWR ");
|
||||
if (tcp->ece) strcat(tcp_flag, "ECE ");
|
||||
|
|
@ -83,6 +80,7 @@ static void ftp_download_per_packet(libtrace_packet_t *packet, int first_packet)
|
|||
if (tcp->psh) strcat(tcp_flag, "PSH ");
|
||||
if (tcp->ack) strcat(tcp_flag, "ACK ");
|
||||
if (tcp->urg) strcat(tcp_flag, "URG ");
|
||||
|
||||
if (strcmp(tcp_flag, "PSH ACK ") == 0 && strlen(nexthdr) > strlen(FTP_SIZE_RESPONSE) && strncmp(nexthdr, FTP_SIZE_RESPONSE, strlen(FTP_SIZE_RESPONSE)) == 0)
|
||||
{
|
||||
char *val = strstr(nexthdr,"213");
|
||||
|
|
@ -113,7 +111,6 @@ static void ftp_download_per_packet(libtrace_packet_t *packet, int first_packet)
|
|||
download_stats.random_seq = ntohl(tcp->ack_seq);
|
||||
sprintf((download_stats.tcpopenresponsetime),"%s.%06ld", s_now, (long) ts.tv_usec);
|
||||
}
|
||||
|
||||
if (strcmp(tcp_flag, "PSH ACK ") == 0 && strlen(nexthdr) > strlen(FTP_RETR_REQUEST) && strncmp(nexthdr, FTP_RETR_REQUEST, strlen(FTP_RETR_REQUEST)) == 0)
|
||||
{
|
||||
ts = trace_get_timeval(packet);
|
||||
|
|
@ -123,9 +120,6 @@ static void ftp_download_per_packet(libtrace_packet_t *packet, int first_packet)
|
|||
}
|
||||
if(strcmp(tcp_flag, "ACK ") == 0 && ntohl(tcp->seq) == download_stats.random_seq && download_stats.ack_seq == 0)
|
||||
{
|
||||
ts = trace_get_timeval(packet);
|
||||
(void) localtime_r(&(ts.tv_sec), <);
|
||||
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", <);
|
||||
download_stats.ack_seq = ntohl(tcp->seq);
|
||||
return;
|
||||
}
|
||||
|
|
@ -139,9 +133,6 @@ static void ftp_download_per_packet(libtrace_packet_t *packet, int first_packet)
|
|||
sprintf((download_stats.bomtime),"%s.%06ld", s_now, (long) ts.tv_usec);
|
||||
}
|
||||
download_stats.first_data = 1;
|
||||
ip = trace_get_ip(packet);
|
||||
if (ip != NULL)
|
||||
download_stats.total_bytes_received += ntohs(ip->ip_len);
|
||||
}
|
||||
if ( (strcmp(tcp_flag, "PSH ACK ") == 0 || strcmp(tcp_flag, "FIN PSH ACK ") == 0) && ntohl(tcp->ack_seq) == download_stats.ack_seq)
|
||||
{
|
||||
|
|
@ -154,14 +145,11 @@ static void ftp_download_per_packet(libtrace_packet_t *packet, int first_packet)
|
|||
download_stats.first_data = 1;
|
||||
}
|
||||
sprintf((download_stats.eomtime),"%s.%06ld", s_now, (long) ts.tv_usec);
|
||||
ip = trace_get_ip(packet);
|
||||
if (ip != NULL)
|
||||
download_stats.total_bytes_received += ntohs(ip->ip_len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void http_download_per_packet(libtrace_packet_t *packet, int first_packet)
|
||||
static void http_download_per_packet(libtrace_packet_t *packet)
|
||||
{
|
||||
struct tm lt;
|
||||
struct timeval ts;
|
||||
|
|
@ -169,21 +157,16 @@ static void http_download_per_packet(libtrace_packet_t *packet, int first_packet
|
|||
uint32_t seq = 0;
|
||||
char tcp_flag[16] = "";
|
||||
char *nexthdr;
|
||||
libtrace_ip_t *ip;
|
||||
char s_now[default_date_size];
|
||||
|
||||
uint8_t proto;
|
||||
uint32_t remaining;
|
||||
tcp = trace_get_transport(packet, &proto, &remaining);
|
||||
|
||||
tcp = trace_get_transport(packet, &proto, &remaining);
|
||||
if (tcp == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
nexthdr = trace_get_payload_from_tcp(tcp, &remaining);
|
||||
}
|
||||
|
||||
if (tcp->ecn_ns) strcat(tcp_flag, "ECN_NS ");
|
||||
if (tcp->cwr) strcat(tcp_flag, "CWR ");
|
||||
if (tcp->ece) strcat(tcp_flag, "ECE ");
|
||||
|
|
@ -193,7 +176,8 @@ static void http_download_per_packet(libtrace_packet_t *packet, int first_packet
|
|||
if (tcp->psh) strcat(tcp_flag, "PSH ");
|
||||
if (tcp->ack) strcat(tcp_flag, "ACK ");
|
||||
if (tcp->urg) strcat(tcp_flag, "URG ");
|
||||
if (strcmp(tcp_flag, "SYN ") == 0 && download_stats.random_seq == 0)
|
||||
|
||||
if (strcmp(tcp_flag, "SYN ") == 0 && download_stats.random_seq == 0)
|
||||
{
|
||||
ts = trace_get_timeval(packet);
|
||||
(void) localtime_r(&(ts.tv_sec), <);
|
||||
|
|
@ -211,7 +195,6 @@ static void http_download_per_packet(libtrace_packet_t *packet, int first_packet
|
|||
download_stats.random_seq = ntohl(tcp->seq);
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(tcp_flag, "PSH ACK ") == 0 && strncmp(nexthdr, "GET", 3) == 0)
|
||||
{
|
||||
ts = trace_get_timeval(packet);
|
||||
|
|
@ -223,9 +206,6 @@ static void http_download_per_packet(libtrace_packet_t *packet, int first_packet
|
|||
}
|
||||
if(strcmp(tcp_flag, "ACK ") == 0 && ntohl(tcp->seq) == download_stats.get_ack && download_stats.ack_seq == 0)
|
||||
{
|
||||
ts = trace_get_timeval(packet);
|
||||
(void) localtime_r(&(ts.tv_sec), <);
|
||||
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", <);
|
||||
download_stats.ack_seq = ntohl(tcp->ack_seq);
|
||||
return;
|
||||
}
|
||||
|
|
@ -244,11 +224,6 @@ static void http_download_per_packet(libtrace_packet_t *packet, int first_packet
|
|||
download_stats.test_bytes_received = atoi(pch);
|
||||
download_stats.first_data = 1;
|
||||
}
|
||||
ip = trace_get_ip(packet);
|
||||
if (ip != NULL)
|
||||
{
|
||||
download_stats.total_bytes_received += ntohs(ip->ip_len);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ( (strcmp(tcp_flag, "PSH ACK ") == 0 || strcmp(tcp_flag, "FIN PSH ACK ") == 0) && ntohl(tcp->ack_seq) == download_stats.ack_seq)
|
||||
|
|
@ -266,13 +241,7 @@ static void http_download_per_packet(libtrace_packet_t *packet, int first_packet
|
|||
download_stats.test_bytes_received = atoi(pch);
|
||||
download_stats.first_data = 1;
|
||||
}
|
||||
|
||||
sprintf((download_stats.eomtime),"%s.%06ld", s_now, (long) ts.tv_usec);
|
||||
ip = trace_get_ip(packet);
|
||||
if (ip != NULL)
|
||||
{
|
||||
download_stats.total_bytes_received += ntohs(ip->ip_len);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -301,13 +270,10 @@ static void set_download_stats()
|
|||
uci_set_state_value(buf);
|
||||
sprintf(buf,"cwmp.@downloaddiagnostic[0].TestBytesReceived=%d", download_stats.test_bytes_received);
|
||||
uci_set_state_value(buf);
|
||||
sprintf(buf,"cwmp.@downloaddiagnostic[0].TotalBytesReceived=%lu", download_stats.total_bytes_received);
|
||||
uci_set_state_value(buf);
|
||||
}
|
||||
|
||||
static void set_upload_stats()
|
||||
{
|
||||
|
||||
char buf[128];
|
||||
sprintf(buf,"cwmp.@uploaddiagnostic[0].ROMtime=%s", upload_stats.romtime);
|
||||
uci_set_state_value(buf);
|
||||
|
|
@ -319,8 +285,6 @@ static void set_upload_stats()
|
|||
uci_set_state_value(buf);
|
||||
sprintf(buf,"cwmp.@uploaddiagnostic[0].TCPOpenResponseTime=%s", upload_stats.tcpopenresponsetime);
|
||||
uci_set_state_value(buf);
|
||||
sprintf(buf,"cwmp.@uploaddiagnostic[0].TotalBytesSent=%lu", upload_stats.total_bytes_sent);
|
||||
uci_set_state_value(buf);
|
||||
}
|
||||
|
||||
static void http_upload_per_packet(libtrace_packet_t *packet)
|
||||
|
|
@ -328,23 +292,18 @@ static void http_upload_per_packet(libtrace_packet_t *packet)
|
|||
struct tm lt;
|
||||
struct timeval ts;
|
||||
libtrace_tcp_t *tcp;
|
||||
//uint32_t remaining;
|
||||
char tcp_flag[16] = "";
|
||||
char *nexthdr;
|
||||
|
||||
libtrace_ip_t *ip;
|
||||
char s_now[default_date_size];
|
||||
uint8_t proto;
|
||||
uint32_t remaining;
|
||||
|
||||
tcp = trace_get_transport(packet, &proto, &remaining);
|
||||
if (tcp == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
nexthdr = trace_get_payload_from_tcp(tcp, &remaining);
|
||||
}
|
||||
|
||||
if (tcp->ecn_ns) strcat(tcp_flag, "ECN_NS ");
|
||||
if (tcp->cwr) strcat(tcp_flag, "CWR ");
|
||||
if (tcp->ece) strcat(tcp_flag, "ECE ");
|
||||
|
|
@ -354,6 +313,7 @@ static void http_upload_per_packet(libtrace_packet_t *packet)
|
|||
if (tcp->psh) strcat(tcp_flag, "PSH ");
|
||||
if (tcp->ack) strcat(tcp_flag, "ACK ");
|
||||
if (tcp->urg) strcat(tcp_flag, "URG ");
|
||||
|
||||
if (strcmp(tcp_flag, "SYN ") == 0 && download_stats.random_seq == 0)
|
||||
{
|
||||
ts = trace_get_timeval(packet);
|
||||
|
|
@ -391,14 +351,12 @@ static void http_upload_per_packet(libtrace_packet_t *packet)
|
|||
upload_stats.ack_seq = ntohl(tcp->ack_seq);
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(tcp_flag, "ACK ") == 0 && upload_stats.tmp == 2 && ntohl(tcp->seq) == upload_stats.ack_seq)
|
||||
{
|
||||
upload_stats.tmp = 0;
|
||||
upload_stats.ack_seq = ntohl(tcp->ack_seq);
|
||||
return;
|
||||
}
|
||||
|
||||
if(strcmp(tcp_flag, "ACK ") == 0 && ntohl(tcp->ack_seq) == upload_stats.ack_seq && upload_stats.tmp == 0)
|
||||
{
|
||||
ts = trace_get_timeval(packet);
|
||||
|
|
@ -409,9 +367,6 @@ static void http_upload_per_packet(libtrace_packet_t *packet)
|
|||
sprintf((upload_stats.bomtime),"%s.%06ld", s_now, (long) ts.tv_usec);
|
||||
upload_stats.first_data = 1;
|
||||
}
|
||||
ip = trace_get_ip(packet);
|
||||
if (ip != NULL)
|
||||
upload_stats.total_bytes_sent += ntohs(ip->ip_len);
|
||||
}
|
||||
if ( (strcmp(tcp_flag, "PSH ACK ") == 0 || strcmp(tcp_flag, "FIN PSH ACK ") == 0) && ntohl(tcp->ack_seq) == upload_stats.ack_seq && upload_stats.tmp == 0)
|
||||
{
|
||||
|
|
@ -420,13 +375,9 @@ static void http_upload_per_packet(libtrace_packet_t *packet)
|
|||
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", <);
|
||||
if (upload_stats.first_data == 0)
|
||||
{
|
||||
|
||||
sprintf((upload_stats.bomtime),"%s.%06ld", s_now, (long) ts.tv_usec);
|
||||
upload_stats.first_data = 1;
|
||||
}
|
||||
ip = trace_get_ip(packet);
|
||||
if (ip != NULL)
|
||||
upload_stats.total_bytes_sent += ntohs(ip->ip_len);
|
||||
}
|
||||
if ( (strcmp(tcp_flag, "PSH ACK ") == 0 || strcmp(tcp_flag, "FIN PSH ACK ") == 0) && ntohl(tcp->seq) == upload_stats.ack_seq && upload_stats.tmp == 0)
|
||||
{
|
||||
|
|
@ -434,7 +385,6 @@ static void http_upload_per_packet(libtrace_packet_t *packet)
|
|||
(void) localtime_r(&(ts.tv_sec), <);
|
||||
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", <);
|
||||
sprintf((upload_stats.eomtime),"%s.%06ld", s_now, (long) ts.tv_usec);
|
||||
ip = trace_get_ip(packet);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -447,17 +397,13 @@ struct tm lt;
|
|||
uint32_t remaining;
|
||||
char tcp_flag[16] = "";
|
||||
char *nexthdr;
|
||||
libtrace_ip_t *ip;
|
||||
char s_now[default_date_size];
|
||||
|
||||
tcp = trace_get_transport(packet, &proto, &remaining);
|
||||
if (tcp == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
nexthdr = trace_get_payload_from_tcp(tcp, &remaining);
|
||||
}
|
||||
|
||||
if (tcp->ecn_ns) strcat(tcp_flag, "ECN_NS ");
|
||||
if (tcp->cwr) strcat(tcp_flag, "CWR ");
|
||||
|
|
@ -468,8 +414,8 @@ struct tm lt;
|
|||
if (tcp->psh) strcat(tcp_flag, "PSH ");
|
||||
if (tcp->ack) strcat(tcp_flag, "ACK ");
|
||||
if (tcp->urg) strcat(tcp_flag, "URG ");
|
||||
if(strcmp(tcp_flag, "PSH ACK ") == 0 && strlen(nexthdr) > strlen(FTP_PASV_RESPONSE)
|
||||
&& strncmp(nexthdr, FTP_PASV_RESPONSE, strlen(FTP_PASV_RESPONSE)) == 0)
|
||||
|
||||
if(strcmp(tcp_flag, "PSH ACK ") == 0 && strlen(nexthdr) > strlen(FTP_PASV_RESPONSE) && strncmp(nexthdr, FTP_PASV_RESPONSE, strlen(FTP_PASV_RESPONSE)) == 0)
|
||||
{
|
||||
upload_stats.ftp_syn = 1;
|
||||
return;
|
||||
|
|
@ -490,7 +436,6 @@ struct tm lt;
|
|||
sprintf((upload_stats.tcpopenresponsetime),"%s.%06ld", s_now, (long) ts.tv_usec);
|
||||
upload_stats.random_seq = ntohl(tcp->ack_seq);
|
||||
}
|
||||
|
||||
if (strcmp(tcp_flag, "PSH ACK ") == 0 && strlen(nexthdr) > strlen(FTP_STOR_REQUEST) && strncmp(nexthdr, FTP_STOR_REQUEST, strlen(FTP_STOR_REQUEST)) == 0)
|
||||
{
|
||||
ts = trace_get_timeval(packet);
|
||||
|
|
@ -500,9 +445,6 @@ struct tm lt;
|
|||
}
|
||||
if(strcmp(tcp_flag, "ACK ") == 0 && ntohl(tcp->seq) == upload_stats.random_seq && upload_stats.ack_seq == 0)
|
||||
{
|
||||
ts = trace_get_timeval(packet);
|
||||
(void) localtime_r(&(ts.tv_sec), <);
|
||||
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", <);
|
||||
upload_stats.ack_seq = ntohl(tcp->ack_seq);
|
||||
return;
|
||||
}
|
||||
|
|
@ -516,10 +458,6 @@ struct tm lt;
|
|||
sprintf((upload_stats.bomtime),"%s.%06ld", s_now, (long) ts.tv_usec);
|
||||
upload_stats.first_data = 1;
|
||||
}
|
||||
|
||||
ip = trace_get_ip(packet);
|
||||
if (ip != NULL)
|
||||
upload_stats.total_bytes_sent += ntohs(ip->ip_len);
|
||||
}
|
||||
if ( (strcmp(tcp_flag, "PSH ACK ") == 0 || strcmp(tcp_flag, "FIN PSH ACK ") == 0) && ntohl(tcp->ack_seq) == upload_stats.ack_seq) //&& strlen(nexthdr) > 16 && strncmp(nexthdr, "HTTP/1.1 200 OK", 16) == 0
|
||||
{
|
||||
|
|
@ -531,9 +469,6 @@ struct tm lt;
|
|||
sprintf((upload_stats.bomtime),"%s.%06ld", s_now, (long) ts.tv_usec);
|
||||
upload_stats.first_data = 1;
|
||||
}
|
||||
ip = trace_get_ip(packet);
|
||||
if (ip != NULL)
|
||||
upload_stats.total_bytes_sent += ntohs(ip->ip_len);
|
||||
}
|
||||
if ( (strcmp(tcp_flag, "PSH ACK ") == 0 || strcmp(tcp_flag, "FIN PSH ACK ") == 0) && strlen(nexthdr) > strlen(FTP_TRANSFERT_COMPLETE) && strncmp(nexthdr, FTP_TRANSFERT_COMPLETE, strlen(FTP_TRANSFERT_COMPLETE)) == 0) //&& strlen(nexthdr) > 16 && strncmp(nexthdr, "HTTP/1.1 200 OK", 16) == 0
|
||||
{
|
||||
|
|
@ -550,7 +485,6 @@ int extract_stats(char *dump_file, int proto, int diagnostic_type)
|
|||
libtrace_t *trace = NULL;
|
||||
libtrace_packet_t *packet = NULL;
|
||||
read_next = 1;
|
||||
int first_packet = 1;
|
||||
packet = trace_create_packet();
|
||||
if (packet == NULL) {
|
||||
perror("Creating libtrace packet");
|
||||
|
|
@ -574,8 +508,7 @@ int extract_stats(char *dump_file, int proto, int diagnostic_type)
|
|||
if (proto == DOWNLOAD_DIAGNOSTIC_HTTP && diagnostic_type == DOWNLOAD_DIAGNOSTIC)
|
||||
{
|
||||
while (trace_read_packet(trace,packet)>0 && read_next == 1) {
|
||||
http_download_per_packet(packet, first_packet);
|
||||
first_packet = 0;
|
||||
http_download_per_packet(packet);
|
||||
continue;
|
||||
}
|
||||
set_download_stats();
|
||||
|
|
@ -583,8 +516,7 @@ int extract_stats(char *dump_file, int proto, int diagnostic_type)
|
|||
else if (proto == DOWNLOAD_DIAGNOSTIC_FTP && diagnostic_type == DOWNLOAD_DIAGNOSTIC)
|
||||
{
|
||||
while (trace_read_packet(trace,packet)>0 && read_next == 1) {
|
||||
ftp_download_per_packet(packet, first_packet);
|
||||
first_packet = 0;
|
||||
ftp_download_per_packet(packet);
|
||||
continue;
|
||||
}
|
||||
set_download_stats();
|
||||
|
|
@ -593,7 +525,6 @@ int extract_stats(char *dump_file, int proto, int diagnostic_type)
|
|||
{
|
||||
while (trace_read_packet(trace,packet)>0 && read_next == 1) {
|
||||
http_upload_per_packet(packet);
|
||||
first_packet = 0;
|
||||
continue;
|
||||
}
|
||||
set_upload_stats();
|
||||
|
|
@ -602,7 +533,6 @@ int extract_stats(char *dump_file, int proto, int diagnostic_type)
|
|||
{
|
||||
while (trace_read_packet(trace,packet)>0 && read_next == 1) {
|
||||
ftp_upload_per_packet(packet);
|
||||
first_packet = 0;
|
||||
continue;
|
||||
}
|
||||
set_upload_stats();
|
||||
|
|
@ -614,18 +544,18 @@ int extract_stats(char *dump_file, int proto, int diagnostic_type)
|
|||
int get_default_gateway_device( char **gw )
|
||||
{
|
||||
FILE *f;
|
||||
char line[100] , *p , *c, *saveptr;
|
||||
char line[100], *p, *c, *saveptr;
|
||||
|
||||
f = fopen("/proc/net/route" , "r");
|
||||
if (f != NULL)
|
||||
{
|
||||
while(fgets(line , 100 , f))
|
||||
{
|
||||
p = strtok_r(line , " \t", &saveptr);
|
||||
c = strtok_r(NULL , " \t", &saveptr);
|
||||
p = strtok_r(line, " \t", &saveptr);
|
||||
c = strtok_r(NULL, " \t", &saveptr);
|
||||
if(p!=NULL && c!=NULL)
|
||||
{
|
||||
if(strcmp(c , "00000000") == 0)
|
||||
if(strcmp(c, "00000000") == 0)
|
||||
{
|
||||
asprintf(gw, "%s", p);
|
||||
fclose(f);
|
||||
|
|
@ -638,12 +568,6 @@ int get_default_gateway_device( char **gw )
|
|||
return -1;
|
||||
}
|
||||
|
||||
int cwmp_ip_ping_diagnostic()
|
||||
{
|
||||
dmcmd_no_wait("/bin/sh", 2, FUNCTION_PATH, "run");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cwmp_start_diagnostic(int diagnostic_type)
|
||||
{
|
||||
char *url = NULL;
|
||||
|
|
@ -651,6 +575,7 @@ int cwmp_start_diagnostic(int diagnostic_type)
|
|||
char *size = NULL;
|
||||
int error;
|
||||
char *status;
|
||||
|
||||
if (diagnostic_type == DOWNLOAD_DIAGNOSTIC)
|
||||
uci_get_state_value("cwmp.@downloaddiagnostic[0].url", &url);
|
||||
else
|
||||
|
|
@ -658,18 +583,16 @@ int cwmp_start_diagnostic(int diagnostic_type)
|
|||
uci_get_state_value("cwmp.@uploaddiagnostic[0].url", &url);
|
||||
uci_get_state_value("cwmp.@uploaddiagnostic[0].TestFileLength", &size);
|
||||
}
|
||||
|
||||
CWMP_LOG(DEBUG,"diagnostic url %s", url);
|
||||
uci_get_state_value("cwmp.@downloaddiagnostic[0].interface", &interface);
|
||||
if( url == NULL || ((url != NULL) && (strcmp(url,"")==0))
|
||||
|| (strncmp(url,DOWNLOAD_PROTOCOL_FTP,strlen(DOWNLOAD_PROTOCOL_FTP))!=0) &&
|
||||
(strstr(url,"@") != NULL && strncmp(url,DOWNLOAD_PROTOCOL_HTTP,strlen(DOWNLOAD_PROTOCOL_HTTP)) == 0)
|
||||
|| ((strncmp(url,DOWNLOAD_PROTOCOL_FTP,strlen(DOWNLOAD_PROTOCOL_FTP))!=0) &&
|
||||
(strstr(url,"@") != NULL && strncmp(url,DOWNLOAD_PROTOCOL_HTTP,strlen(DOWNLOAD_PROTOCOL_HTTP)) == 0))
|
||||
)
|
||||
{
|
||||
CWMP_LOG(ERROR,"Invalid URL %s", url);
|
||||
free(url);
|
||||
return -1;
|
||||
}
|
||||
uci_get_state_value("cwmp.@downloaddiagnostic[0].device", &interface);
|
||||
if ( interface == NULL || interface[0] == '\0' )
|
||||
{
|
||||
error = get_default_gateway_device(&interface);
|
||||
|
|
@ -682,12 +605,13 @@ int cwmp_start_diagnostic(int diagnostic_type)
|
|||
}
|
||||
if (diagnostic_type == DOWNLOAD_DIAGNOSTIC)
|
||||
{
|
||||
CWMP_LOG(INFO,"Launch Download diagnostic with url %s", url);
|
||||
dmcmd("/bin/sh", 4, DOWNLOAD_DIAGNOSTIC_PATH, "run", url, interface);
|
||||
uci_get_state_value("cwmp.@downloaddiagnostic[0].DiagnosticState", &status);
|
||||
if (status && strcmp(status, "Completed") == 0)
|
||||
{
|
||||
init_download_stats();
|
||||
CWMP_LOG(INFO,"Extract download stats");
|
||||
CWMP_LOG(INFO,"Extract Download stats");
|
||||
if(strncmp(url,DOWNLOAD_PROTOCOL_HTTP,strlen(DOWNLOAD_PROTOCOL_HTTP)) == 0)
|
||||
extract_stats(DOWNLOAD_DUMP_FILE, DOWNLOAD_DIAGNOSTIC_HTTP, DOWNLOAD_DIAGNOSTIC);
|
||||
if(strncmp(url,DOWNLOAD_PROTOCOL_FTP,strlen(DOWNLOAD_PROTOCOL_FTP)) == 0)
|
||||
|
|
@ -700,12 +624,13 @@ int cwmp_start_diagnostic(int diagnostic_type)
|
|||
}
|
||||
else
|
||||
{
|
||||
CWMP_LOG(INFO,"Launch Upload diagnostic with url %s", url);
|
||||
dmcmd("/bin/sh", 5, UPLOAD_DIAGNOSTIC_PATH, "run", url, interface, size);
|
||||
uci_get_state_value("cwmp.@uploaddiagnostic[0].DiagnosticState", &status);
|
||||
if (status && strcmp(status, "Completed") == 0)
|
||||
{
|
||||
init_upload_stats();
|
||||
CWMP_LOG(INFO,"Extract upload stats");
|
||||
CWMP_LOG(INFO,"Extract Upload stats");
|
||||
if(strncmp(url,DOWNLOAD_PROTOCOL_HTTP,strlen(DOWNLOAD_PROTOCOL_HTTP)) == 0)
|
||||
extract_stats(UPLOAD_DUMP_FILE, DOWNLOAD_DIAGNOSTIC_HTTP, UPLOAD_DIAGNOSTIC);
|
||||
if(strncmp(url,DOWNLOAD_PROTOCOL_FTP,strlen(DOWNLOAD_PROTOCOL_FTP)) == 0)
|
||||
|
|
@ -722,8 +647,32 @@ int cwmp_start_diagnostic(int diagnostic_type)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int cwmp_ip_ping_diagnostic()
|
||||
{
|
||||
dmcmd_no_wait("/bin/sh", 2, IPPING_PATH, "run");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cwmp_nslookup_diagnostic()
|
||||
{
|
||||
dmcmd_no_wait("/bin/sh", 2, NSLOOKUP_PATH, "run");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cwmp_traceroute_diagnostic()
|
||||
{
|
||||
dmcmd_no_wait("/bin/sh", 2, TRACEROUTE_PATH, "run");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cwmp_udp_echo_diagnostic()
|
||||
{
|
||||
dmcmd_no_wait("/bin/sh", 2, UDPECHO_PATH, "run");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cwmp_serverselection_diagnostic()
|
||||
{
|
||||
dmcmd_no_wait("/bin/sh", 2, SERVERSELECTION_PATH, "run");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,17 +57,23 @@ do { \
|
|||
if (mpp) close (mpp); \
|
||||
} while (0)
|
||||
|
||||
#define IPPING_STOP DMCMD("/bin/sh", 2, FUNCTION_PATH, "stop");
|
||||
#define FUNCTION_PATH "/usr/share/icwmp/functions/ipping_launch"
|
||||
#define IPPING_PATH "/usr/share/icwmp/functions/ipping_launch"
|
||||
#define IPPING_STOP DMCMD("/bin/sh", 2, IPPING_PATH, "stop");
|
||||
#define DOWNLOAD_DIAGNOSTIC_PATH "/usr/share/icwmp/functions/download_launch"
|
||||
#define DOWNLOAD_DUMP_FILE "/tmp/download_dump"
|
||||
#define DOWNLOAD_DIAGNOSTIC_STOP DMCMD("/bin/sh", 2, DOWNLOAD_DIAGNOSTIC_PATH, "stop");
|
||||
#define UPLOAD_DIAGNOSTIC_PATH "/usr/share/icwmp/functions/upload_launch"
|
||||
#define UPLOAD_DUMP_FILE "/tmp/upload_dump"
|
||||
#define UPLOAD_DIAGNOSTIC_STOP DMCMD("/bin/sh", 2, UPLOAD_DIAGNOSTIC_PATH, "stop");
|
||||
#define NSLOOKUP_STOP DMCMD("/bin/sh", 2, NSLOOKUP_PATH, "stop");
|
||||
#define NSLOOKUP_PATH "/usr/share/icwmp/functions/nslookup_launch"
|
||||
#define NSLOOKUP_LOG_FILE "/tmp/nslookup.log"
|
||||
#define NSLOOKUP_STOP DMCMD("/bin/sh", 2, NSLOOKUP_PATH, "stop");
|
||||
#define TRACEROUTE_PATH "/usr/share/icwmp/functions/traceroute_launch"
|
||||
#define TRACEROUTE_STOP DMCMD("/bin/sh", 2, TRACEROUTE_PATH, "stop");
|
||||
#define UDPECHO_PATH "/usr/share/icwmp/functions/udpecho_launch"
|
||||
#define UDPECHO_STOP DMCMD("/bin/sh", 2, UDPECHO_PATH, "stop");
|
||||
#define SERVERSELECTION_PATH "/usr/share/icwmp/functions/serverselection_launch"
|
||||
#define SERVERSELECTION_STOP DMCMD("/bin/sh", 2, SERVERSELECTION_PATH, "stop");
|
||||
|
||||
enum notification_enum {
|
||||
notification_none,
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ typedef struct dm_leaf_s {
|
|||
} DMLEAF;
|
||||
|
||||
typedef struct dm_obj_s {
|
||||
/* OBJ, permission, addobj, delobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker(10)*/
|
||||
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker(11)*/
|
||||
char *obj;
|
||||
struct dm_permession_s *permission;
|
||||
int (*addobj)(char *refparam, struct dmctx *ctx, void *data, char **instance);
|
||||
|
|
@ -375,7 +375,10 @@ enum end_session_enum {
|
|||
END_SESSION_DOWNLOAD_DIAGNOSTIC = 1<<5,
|
||||
END_SESSION_UPLOAD_DIAGNOSTIC = 1<<6,
|
||||
END_SESSION_X_FACTORY_RESET_SOFT = 1<<7,
|
||||
END_SESSION_NSLOOKUP_DIAGNOSTIC = 1<<8
|
||||
END_SESSION_NSLOOKUP_DIAGNOSTIC = 1<<8,
|
||||
END_SESSION_TRACEROUTE_DIAGNOSTIC = 1<<9,
|
||||
END_SESSION_UDPECHO_DIAGNOSTIC = 1<<10,
|
||||
END_SESSION_SERVERSELECTION_DIAGNOSTIC = 1<<11
|
||||
};
|
||||
|
||||
enum dm_browse_enum {
|
||||
|
|
|
|||
|
|
@ -713,6 +713,7 @@ int browsePocessEntriesInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev
|
|||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int browseVcfInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ static inline char *download_diagnostic_get(char *option, char *def)
|
|||
else
|
||||
return tmp;
|
||||
}
|
||||
|
||||
int get_download_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = download_diagnostic_get("DiagnosticState", "None");
|
||||
|
|
@ -101,7 +102,6 @@ int set_download_diagnostics_interface(char *refparam, struct dmctx *ctx, void *
|
|||
|
||||
int get_download_diagnostics_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
|
||||
dmuci_get_varstate_string("cwmp", "@downloaddiagnostic[0]", "url", value);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ DMLEAF tIPPingDiagnosticsParam[] = {
|
|||
{0}
|
||||
};
|
||||
|
||||
|
||||
static inline char *ipping_get(char *option, char *def)
|
||||
{
|
||||
char *tmp;
|
||||
|
|
@ -210,13 +209,11 @@ int set_ipping_block_size(char *refparam, struct dmctx *ctx, void *data, char *i
|
|||
int get_ipping_dscp(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = ipping_get("DSCP", "0");
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_ipping_dscp(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
|
||||
char *tmp;
|
||||
struct uci_section *curr_section = NULL;
|
||||
switch (action) {
|
||||
|
|
@ -255,14 +252,12 @@ int get_ipping_average_response_time(char *refparam, struct dmctx *ctx, void *da
|
|||
int get_ipping_min_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = ipping_get("MinimumResponseTime", "0");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_ipping_max_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = ipping_get("MaximumResponseTime", "0");
|
||||
|
||||
*value = ipping_get("MaximumResponseTime", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ static inline char *upload_diagnostic_get(char *option, char *def)
|
|||
else
|
||||
return tmp;
|
||||
}
|
||||
|
||||
int get_upload_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = upload_diagnostic_get("DiagnosticState", "None");
|
||||
|
|
@ -101,7 +102,6 @@ int set_upload_diagnostics_interface(char *refparam, struct dmctx *ctx, void *da
|
|||
|
||||
int get_upload_diagnostics_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
|
||||
dmuci_get_varstate_string("cwmp", "@uploaddiagnostic[0]", "url", value);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -324,18 +324,6 @@ end:
|
|||
return 0;
|
||||
}
|
||||
|
||||
int browseServiceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
//TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int browseTextRecordInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
//TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*********************************** Add/Delet Object functions *************************/
|
||||
int add_client_server(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -85,8 +85,8 @@ DMLEAF tTimeSpanParams[] = {
|
|||
{"StopTime", &DMWRITE, DMT_STRING, get_time_span_stop_time, set_time_span_stop_time, NULL, NULL},
|
||||
{0}
|
||||
};
|
||||
/***************************** Browse Functions ***********************************/
|
||||
|
||||
/***************************** Browse Functions ***********************************/
|
||||
int browseLevelInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct uci_section *s;
|
||||
|
|
@ -223,8 +223,8 @@ int get_firewall_advanced_level(char *refparam, struct dmctx *ctx, void *data, c
|
|||
|
||||
int get_firewall_level_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value="1";
|
||||
return 0;
|
||||
*value="1";
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_firewall_chain_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
|
|
@ -235,16 +235,16 @@ int get_firewall_chain_number_of_entries(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
int get_level_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct uci_section* levels=(struct uci_section *)data;
|
||||
dmuci_get_value_by_section_string(levels, "name", value);
|
||||
return 0;
|
||||
struct uci_section* levels=(struct uci_section *)data;
|
||||
dmuci_get_value_by_section_string(levels, "name", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_level_description(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct uci_section* levels=(struct uci_section *)data;
|
||||
dmuci_get_value_by_section_string(levels, "description", value);
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_level_chain(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
|
|
|
|||
2330
dm/dmtree/tr181/ip.c
2330
dm/dmtree/tr181/ip.c
File diff suppressed because it is too large
Load diff
|
|
@ -1,17 +1,18 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2016 Inteno Broadband Technology AB
|
||||
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
|
||||
*
|
||||
*/
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2019 iopsys Software Solutions AB
|
||||
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __IP_H
|
||||
#define __IP_H
|
||||
|
||||
extern struct ip_ping_diagnostic ipping_diagnostic;
|
||||
struct ip_args
|
||||
{
|
||||
struct uci_section *ip_sec;
|
||||
|
|
@ -25,13 +26,32 @@ extern DMLEAF tIPv4Params[];
|
|||
extern DMLEAF tIPv6Params[];
|
||||
extern DMLEAF tIPInterfaceStatsParams[];
|
||||
extern DMLEAF tIPintParams[];
|
||||
extern DMLEAF tIpPingDiagParams[];
|
||||
extern DMOBJ tDiagnosticObj[];
|
||||
extern DMLEAF tIPDiagnosticsParams[];
|
||||
extern DMLEAF tIpPingDiagParams[];
|
||||
extern DMOBJ tIPDiagnosticsTraceRouteObj[];
|
||||
extern DMLEAF tIPDiagnosticsTraceRouteParams[];
|
||||
extern DMLEAF tIPDiagnosticsTraceRouteRouteHopsParams[];
|
||||
extern DMOBJ tIPDiagnosticsDownloadDiagnosticsObj[];
|
||||
extern DMLEAF tIPDiagnosticsDownloadDiagnosticsParams[];
|
||||
extern DMLEAF tIPDiagnosticsDownloadDiagnosticsPerConnectionResultParams[];
|
||||
extern DMOBJ tIPDiagnosticsUploadDiagnosticsObj[];
|
||||
extern DMLEAF tIPDiagnosticsUploadDiagnosticsParams[];
|
||||
extern DMLEAF tIPDiagnosticsUploadDiagnosticsPerConnectionResultParams[];
|
||||
extern DMLEAF tIPDiagnosticsUDPEchoConfigParams[];
|
||||
extern DMLEAF tIPDiagnosticsUDPEchoDiagnosticsParams[];
|
||||
extern DMLEAF tIPDiagnosticsServerSelectionDiagnosticsParams[];
|
||||
|
||||
unsigned char get_ipv4_finform(char *refparam, struct dmctx *dmctx, void *data, char *instance);
|
||||
unsigned char get_ipv6_finform(char *refparam, struct dmctx *dmctx, void *data, char *instance);
|
||||
int get_linker_ip_interface(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
|
||||
|
||||
int browseIPIfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
|
||||
int browseIfaceIPv4Inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
|
||||
int browseIfaceIPv6Inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
|
||||
int browseIPDiagnosticsTraceRouteRouteHopsInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
|
||||
int browseIPDiagnosticsDownloadDiagnosticsPerConnectionResultInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
|
||||
int browseIPDiagnosticsUploadDiagnosticsPerConnectionResultInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
|
||||
|
||||
int add_ip_interface(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
|
||||
int delete_ip_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
|
||||
|
|
@ -40,6 +60,8 @@ int delete_ipv4(char *refparam, struct dmctx *ctx, void *data, char *instance, u
|
|||
int add_ipv6(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
|
||||
int delete_ipv6(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
|
||||
|
||||
int get_diag_enable_true(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_diag_enable_false(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_ip_interface_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_ip_interface_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_ip_interface_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
|
|
@ -56,15 +78,20 @@ int get_ipv6_address(char *refparam, struct dmctx *ctx, void *data, char *instan
|
|||
int get_ipv6_addressing_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_ip_ping_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_ip_ping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_ip_ping_protocolversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_ip_ping_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_ip_ping_repetition_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_ip_ping_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_ip_ping_block_size(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_ip_ping_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_ip_ping_success_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_ip_ping_failure_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_ip_ping_average_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_ip_ping_min_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_ip_ping_max_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_ip_ping_AverageResponseTimeDetailed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_ip_ping_MinimumResponseTimeDetailed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_ip_ping_MaximumResponseTimeDetailed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_ip_interface_statistics_tx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_ip_interface_statistics_rx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_ip_interface_statistics_tx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
|
|
@ -86,12 +113,183 @@ int set_ipv6_address(char *refparam, struct dmctx *ctx, void *data, char *instan
|
|||
int set_ipv6_addressing_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int set_ip_ping_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int set_ip_ping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int set_ip_ping_protocolversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int set_ip_ping_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int set_ip_ping_repetition_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int set_ip_ping_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int set_ip_ping_block_size(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int set_ip_ping_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int set_ipv6_addressing_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int set_ip_interface_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
|
||||
int get_linker_ip_interface(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
|
||||
int get_IPDiagnosticsTraceRoute_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsTraceRoute_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsTraceRoute_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsTraceRoute_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsTraceRoute_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsTraceRoute_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsTraceRoute_Host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsTraceRoute_Host(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsTraceRoute_NumberOfTries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsTraceRoute_NumberOfTries(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsTraceRoute_Timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsTraceRoute_Timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsTraceRoute_DataBlockSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsTraceRoute_DataBlockSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsTraceRoute_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsTraceRoute_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsTraceRoute_MaxHopCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsTraceRoute_MaxHopCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsTraceRoute_ResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsTraceRoute_RouteHopsNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsTraceRouteRouteHops_Host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsTraceRouteRouteHops_HostAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsTraceRouteRouteHops_ErrorCode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsTraceRouteRouteHops_RTTimes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
|
||||
int get_IPDiagnosticsDownloadDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsDownloadDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsDownloadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsDownloadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsDownloadDiagnostics_DownloadURL(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsDownloadDiagnostics_DownloadURL(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsDownloadDiagnostics_DownloadTransports(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsDownloadDiagnostics_DownloadDiagnosticMaxConnections(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsDownloadDiagnostics_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsDownloadDiagnostics_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsDownloadDiagnostics_EthernetPriority(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsDownloadDiagnostics_EthernetPriority(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsDownloadDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsDownloadDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsDownloadDiagnostics_NumberOfConnections(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsDownloadDiagnostics_NumberOfConnections(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsDownloadDiagnostics_ROMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsDownloadDiagnostics_BOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsDownloadDiagnostics_EOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsDownloadDiagnostics_TestBytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsDownloadDiagnostics_TotalBytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsDownloadDiagnostics_TotalBytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsDownloadDiagnostics_TestBytesReceivedUnderFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsDownloadDiagnostics_TotalBytesReceivedUnderFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsDownloadDiagnostics_TotalBytesSentUnderFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsDownloadDiagnostics_PeriodOfFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsDownloadDiagnostics_TCPOpenRequestTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsDownloadDiagnostics_TCPOpenResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsDownloadDiagnostics_PerConnectionResultNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsDownloadDiagnostics_EnablePerConnectionResults(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsDownloadDiagnostics_EnablePerConnectionResults(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_ROMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_BOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_EOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_TestBytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_TotalBytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_TotalBytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_TCPOpenRequestTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_TCPOpenResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
|
||||
int get_IPDiagnosticsUploadDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUploadDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUploadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUploadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUploadDiagnostics_UploadURL(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUploadDiagnostics_UploadURL(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUploadDiagnostics_UploadTransports(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUploadDiagnostics_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUploadDiagnostics_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUploadDiagnostics_EthernetPriority(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUploadDiagnostics_EthernetPriority(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUploadDiagnostics_TestFileLength(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUploadDiagnostics_TestFileLength(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUploadDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUploadDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUploadDiagnostics_NumberOfConnections(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUploadDiagnostics_NumberOfConnections(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUploadDiagnostics_ROMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUploadDiagnostics_BOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUploadDiagnostics_EOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUploadDiagnostics_TestBytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUploadDiagnostics_TotalBytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUploadDiagnostics_TotalBytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUploadDiagnostics_TestBytesSentUnderFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUploadDiagnostics_TotalBytesReceivedUnderFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUploadDiagnostics_TotalBytesSentUnderFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUploadDiagnostics_PeriodOfFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUploadDiagnostics_TCPOpenRequestTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUploadDiagnostics_TCPOpenResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUploadDiagnostics_PerConnectionResultNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUploadDiagnostics_EnablePerConnectionResults(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUploadDiagnostics_EnablePerConnectionResults(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_ROMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_BOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_EOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_TestBytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_TotalBytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_TotalBytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_TCPOpenRequestTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_TCPOpenResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
|
||||
int get_IPDiagnosticsUDPEchoConfig_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUDPEchoConfig_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUDPEchoConfig_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUDPEchoConfig_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUDPEchoConfig_SourceIPAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUDPEchoConfig_SourceIPAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUDPEchoConfig_UDPPort(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUDPEchoConfig_UDPPort(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUDPEchoConfig_EchoPlusEnabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUDPEchoConfig_EchoPlusEnabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUDPEchoConfig_EchoPlusSupported(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUDPEchoConfig_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUDPEchoConfig_PacketsResponded(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUDPEchoConfig_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUDPEchoConfig_BytesResponded(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUDPEchoConfig_TimeFirstPacketReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUDPEchoConfig_TimeLastPacketReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
|
||||
int get_IPDiagnosticsUDPEchoDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUDPEchoDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUDPEchoDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUDPEchoDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUDPEchoDiagnostics_Host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUDPEchoDiagnostics_Host(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUDPEchoDiagnostics_Port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUDPEchoDiagnostics_Port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUDPEchoDiagnostics_NumberOfRepetitions(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUDPEchoDiagnostics_NumberOfRepetitions(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUDPEchoDiagnostics_Timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUDPEchoDiagnostics_Timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUDPEchoDiagnostics_DataBlockSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUDPEchoDiagnostics_DataBlockSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUDPEchoDiagnostics_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUDPEchoDiagnostics_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUDPEchoDiagnostics_InterTransmissionTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUDPEchoDiagnostics_InterTransmissionTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUDPEchoDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsUDPEchoDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsUDPEchoDiagnostics_SuccessCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUDPEchoDiagnostics_FailureCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUDPEchoDiagnostics_AverageResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUDPEchoDiagnostics_MinimumResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsUDPEchoDiagnostics_MaximumResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
|
||||
int get_IPDiagnosticsServerSelectionDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsServerSelectionDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsServerSelectionDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsServerSelectionDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsServerSelectionDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsServerSelectionDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsServerSelectionDiagnostics_Protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsServerSelectionDiagnostics_Protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsServerSelectionDiagnostics_Port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsServerSelectionDiagnostics_Port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsServerSelectionDiagnostics_HostList(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsServerSelectionDiagnostics_HostList(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsServerSelectionDiagnostics_NumberOfRepetitions(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsServerSelectionDiagnostics_NumberOfRepetitions(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsServerSelectionDiagnostics_Timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int set_IPDiagnosticsServerSelectionDiagnostics_Timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
int get_IPDiagnosticsServerSelectionDiagnostics_FastestHost(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsServerSelectionDiagnostics_MinimumResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsServerSelectionDiagnostics_AverageResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int get_IPDiagnosticsServerSelectionDiagnostics_MaximumResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -106,6 +106,11 @@ struct package_change {
|
|||
section != NULL; \
|
||||
section = dmuci_walk_section(package, stype, arg, NULL, CMP_FILTER_FUNC, func, section, GET_NEXT_SECTION))
|
||||
|
||||
#define uci_foreach_sections_state(package, stype, section) \
|
||||
for (section = dmuci_walk_state_section(package, stype, NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION); \
|
||||
section != NULL; \
|
||||
section = dmuci_walk_state_section(package, stype, NULL, NULL, CMP_SECTION, NULL, section, GET_NEXT_SECTION))
|
||||
|
||||
#define section_name(s) (s)->e.name
|
||||
|
||||
static inline void uci_list_insert(struct uci_list *list, struct uci_list *ptr)
|
||||
|
|
|
|||
2
event.c
2
event.c
|
|
@ -347,7 +347,7 @@ void cwmp_add_notification(void)
|
|||
|
||||
fp = fopen(DM_ENABLED_NOTIFY, "r");
|
||||
if (fp == NULL)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
while (fgets(buf, 512, fp) != NULL) {
|
||||
dm_ctx_init_sub(&dmctx, DM_CWMP, cwmp_main.conf.amd_version, cwmp_main.conf.instance_mode);
|
||||
|
|
|
|||
|
|
@ -4,9 +4,11 @@
|
|||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2012-2014 PIVA SOFTWARE (www.pivasoftware.com)
|
||||
* Copyright (C) 2019 iopsys Software Solutions AB
|
||||
* Author: Imen Bhiri <imen.bhiri@pivasoftware.com>
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
*/
|
||||
|
||||
#ifndef __DIAGNOSTIC__H
|
||||
#define __DIAGNOSTIC__H
|
||||
|
||||
|
|
@ -41,7 +43,6 @@ struct upload_diagnostic_stats
|
|||
char romtime[default_date_size];
|
||||
char bomtime[default_date_size];
|
||||
char eomtime[default_date_size];
|
||||
int test_bytes_received;
|
||||
unsigned long total_bytes_sent;
|
||||
char tcpopenrequesttime[default_date_size];
|
||||
char tcpopenresponsetime[default_date_size];
|
||||
|
|
@ -68,5 +69,8 @@ enum diagnostic_type {
|
|||
int cwmp_ip_ping_diagnostic();
|
||||
int cwmp_start_diagnostic(int diagnostic_type);
|
||||
int cwmp_nslookup_diagnostic();
|
||||
int cwmp_traceroute_diagnostic();
|
||||
int cwmp_udp_echo_diagnostic();
|
||||
int cwmp_serverselection_diagnostic();
|
||||
|
||||
#endif
|
||||
|
|
|
|||
39
init/icwmp_udpechoserverd
Normal file
39
init/icwmp_udpechoserverd
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
#UDP Echo Server software
|
||||
# Copyright (C) 2019 Iopsys Broadband Technology AB
|
||||
#Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
|
||||
START=99
|
||||
STOP=10
|
||||
|
||||
USE_PROCD=1
|
||||
PROG="/usr/sbin/icwmp_udpechoserverd"
|
||||
|
||||
start_service() {
|
||||
local enable_udpechoserver=`uci -q get cwmp_udpechoserver.udpechoserver.enable`
|
||||
local port_udpechoserver=`uci -q get cwmp_udpechoserver.udpechoserver.server_port`
|
||||
if [ "$port_udpechoserver" != "0" ]; then
|
||||
if [ "$enable_udpechoserver" = "1" ]; then
|
||||
iptables -I zone_wan_input -p udp --dport $port_udpechoserver -j ACCEPT -m comment --comment "Open UDPechoserver port"
|
||||
procd_open_instance
|
||||
procd_set_param command "$PROG"
|
||||
procd_set_param respawn "3" "7" "0"
|
||||
procd_close_instance
|
||||
else
|
||||
iptables -I zone_wan_input -p udp --dport $port_udpechoserver -j REJECT -m comment --comment "Close UDPechoserver port"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
boot() {
|
||||
start
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger cwmp_udpechoserver
|
||||
}
|
||||
|
|
@ -1,22 +1,44 @@
|
|||
#!/bin/sh
|
||||
# Copyright (C) 2015 PIVA Software <www.pivasoftware.com>
|
||||
# Copyright (C) 2019 PIVA Software <www.pivasoftware.com>
|
||||
# Author: IMEN Bhiri <imen.bhiri@pivasoftware.com>
|
||||
# Author: AMIN Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
|
||||
|
||||
UCI_CONFIG_DIR="/etc/config/"
|
||||
UCI_GET_VARSTATE="/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state get -q "
|
||||
UCI_SET_VARSTATE="/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state set -q "
|
||||
UCI_GET_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state get"
|
||||
UCI_SET_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state set"
|
||||
UCI_ADD_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state add"
|
||||
UCI_DELETE_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state delete"
|
||||
CAPTURE_FILE="/tmp/download_dump"
|
||||
DOWNLOAD_DIAGNOSTIC_FILE="/tmp/icwmp_download_diagnostic"
|
||||
|
||||
download_get() {
|
||||
local val=`$UCI_GET_VARSTATE $1`
|
||||
echo ${val:-$2}
|
||||
}
|
||||
|
||||
download_launch() {
|
||||
url=$1
|
||||
interface=$2
|
||||
local tx_bytes_before rx_bytes_before time1 tx_bytes_after rx_bytes_after time2 res rh ba stc periodtime
|
||||
local url=$1
|
||||
local interface=$2
|
||||
[ "`$UCI_GET_VARSTATE cwmp.@downloaddiagnostic[0].DiagnosticState`" != "Requested" ] && return
|
||||
[ "$url" = "" ] && { $UCI_SET_VARSTATE cwmp.@downloaddiagnostic[0].DiagnosticState=Error_InitConnectionFailed; return; }
|
||||
local proto=`download_get cwmp.@downloaddiagnostic[0].ProtocolVersion Any`
|
||||
tcpdump -i $interface tcp -w ${CAPTURE_FILE} > /dev/null 2>&1 &
|
||||
PID=$!
|
||||
sleep 1
|
||||
if [ ${url:0:7} = http:// -o ${url:0:6} = ftp:// ]; then
|
||||
res=$(wget -O ${DOWNLOAD_DIAGNOSTIC_FILE} $url 2>&1)
|
||||
tx_bytes_before=`ubus call network.device status "{'name':'$interface'}" | sed -n '/statistics/,$ p' | grep "tx_bytes" | awk -F ": " '{print $2}' | sed 's/.$//'`
|
||||
rx_bytes_before=`ubus call network.device status "{'name':'$interface'}" | sed -n '/statistics/,$ p' | grep "rx_bytes" | awk -F ": " '{print $2}' | sed 's/.$//'`
|
||||
time1=`date +%s`
|
||||
[ "$proto" = "Any" ] && res=$(wget -O ${DOWNLOAD_DIAGNOSTIC_FILE} $url 2>&1)
|
||||
[ "$proto" = "IPv4" ] && res=$(wget -4 -O ${DOWNLOAD_DIAGNOSTIC_FILE} $url 2>&1)
|
||||
[ "$proto" = "IPv6" ] && res=$(wget -6 -O ${DOWNLOAD_DIAGNOSTIC_FILE} $url 2>&1)
|
||||
time2=`date +%s`
|
||||
tx_bytes_after=`ubus call network.device status "{'name':'$interface'}" | sed -n '/statistics/,$ p' | grep "tx_bytes" | awk -F ": " '{print $2}' | sed 's/.$//'`
|
||||
rx_bytes_after=`ubus call network.device status "{'name':'$interface'}" | sed -n '/statistics/,$ p' | grep "rx_bytes" | awk -F ": " '{print $2}' | sed 's/.$//'`
|
||||
rh=`echo "$res" | grep "resolve host"`
|
||||
[ -n "$ba" ] && { $UCI_SET_VARSTATE cwmp.@downloaddiagnostic[0].DiagnosticState=Error_CannotResolveHostName; kill $PID 2> /dev/null; return; }
|
||||
ba=`echo "$res" | grep "bad address"`
|
||||
[ -n "$ba" ] && { $UCI_SET_VARSTATE cwmp.@downloaddiagnostic[0].DiagnosticState=Error_InitConnectionFailed; kill $PID 2> /dev/null; return; }
|
||||
stc=`echo "$res" | grep "404 Not Found"`
|
||||
|
|
@ -24,7 +46,21 @@ download_launch() {
|
|||
stc=`echo "$res" | grep "100%"`
|
||||
[ -z "$stc" ] && { $UCI_SET_VARSTATE cwmp.@downloaddiagnostic[0].DiagnosticState=Error_TransferFailed; kill $PID 2> /dev/null; return; }
|
||||
fi
|
||||
tx_bytes=$((tx_bytes_after-tx_bytes_before))
|
||||
rx_bytes=$((rx_bytes_after-rx_bytes_before))
|
||||
periodtime=$(($((time2-time1))*1000000))
|
||||
$UCI_SET_VARSTATE cwmp.@downloaddiagnostic[0].DiagnosticState=Completed
|
||||
$UCI_SET_VARSTATE cwmp.@downloaddiagnostic[0].TotalBytesReceived=$rx_bytes
|
||||
$UCI_SET_VARSTATE cwmp.@downloaddiagnostic[0].TotalBytesSent=$tx_bytes
|
||||
$UCI_SET_VARSTATE cwmp.@downloaddiagnostic[0].PeriodOfFullLoading=$periodtime
|
||||
local perconnection=`$UCI_GET_VARSTATE cwmp.@downloaddiagnostic[0].EnablePerConnection`
|
||||
if ([ "$perconnection" == "true" ] || [ "$perconnection" == "1" ]); then
|
||||
$UCI_ADD_VARSTATE cwmp DownloadPerConnection
|
||||
$UCI_SET_VARSTATE cwmp.@DownloadPerConnection[0].TotalBytesReceived=$rx_bytes
|
||||
$UCI_SET_VARSTATE cwmp.@DownloadPerConnection[0].TotalBytesSent=$tx_bytes
|
||||
else
|
||||
$UCI_DELETE_VARSTATE cwmp.@DownloadPerConnection[0]
|
||||
fi
|
||||
rm ${DOWNLOAD_DIAGNOSTIC_FILE} 2>/dev/null
|
||||
sleep 1
|
||||
local pids=`ps | grep $PID`
|
||||
|
|
@ -32,12 +68,13 @@ download_launch() {
|
|||
}
|
||||
|
||||
download_stop_diagnostic() {
|
||||
$UCI_DELETE_VARSTATE cwmp.@DownloadPerConnection[0]
|
||||
local pids=`ps | grep download_launch.*run | grep -v grep | awk '{print $1}'`
|
||||
if [ -n "$pids" ]; then
|
||||
kill -9 $pids &>/dev/null
|
||||
$UCI_SET_VARSTATE cwmp.@downloaddiagnostic[0].DiagnosticState=None
|
||||
fi
|
||||
local pids=`ps | grep upload_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
|
||||
kids=$(grep -l "PPid.*$pids" /proc/*/task/*/status | grep -o "[0-9]*")
|
||||
for kid in $kids; do
|
||||
|
|
|
|||
|
|
@ -1,42 +1,46 @@
|
|||
#!/bin/sh
|
||||
# Copyright (C) 2015 PIVA Software <www.pivasoftware.com>
|
||||
# Copyright (C) 2019 PIVA Software <www.pivasoftware.com>
|
||||
# Author: MOHAMED Kallel <mohamed.kallel@pivasoftware.com>
|
||||
# Author: AMIN Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
|
||||
|
||||
UCI_CONFIG_DIR="/etc/config/"
|
||||
UCI_GET_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state get "
|
||||
UCI_SET_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state set "
|
||||
UCI_GET_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state get"
|
||||
UCI_SET_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state set"
|
||||
|
||||
ipping_get() {
|
||||
local val=`$UCI_GET_VARSTATE $1`
|
||||
echo ${val:-$2}
|
||||
}
|
||||
|
||||
ipping_set() {
|
||||
$UCI_SET_VARSTATE $1=$2
|
||||
return 0
|
||||
}
|
||||
|
||||
ipping_launch() {
|
||||
local i res ba stc times sc1 success_count failure_count min_time avg_time max_time avg_time_sum min max
|
||||
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
|
||||
[ "`$UCI_GET_VARSTATE cwmp.@ippingdiagnostic[0].DiagnosticState`" != "Requested" ] && return
|
||||
local host=`ipping_get cwmp.@ippingdiagnostic[0].Host`
|
||||
local cnt=`ipping_get cwmp.@ippingdiagnostic[0].NumberOfRepetitions 3`
|
||||
local dsize=`ipping_get cwmp.@ippingdiagnostic[0].DataBlockSize 64`
|
||||
local timeout=`ipping_get cwmp.@ippingdiagnostic[0].Timeout 1000`
|
||||
local dscp=`ipping_get cwmp.@ippingdiagnostic[0].DSCP 0`
|
||||
local proto=`ipping_get cwmp.@ippingdiagnostic[0].ProtocolVersion Any`
|
||||
local tos=$((dscp<<2))
|
||||
[ "$host" = "" ] && return
|
||||
#timeout=$((timeout/1000))
|
||||
[ "$timeout" = "0" ] && timeout="1000"
|
||||
timeout=$((timeout/1000))
|
||||
[ "$timeout" = "0" ] && timeout="1"
|
||||
micros=1000
|
||||
success_count=0
|
||||
avg_time_sum=0
|
||||
avg_time_sum_det=0
|
||||
min=9999999
|
||||
min_det=999999999
|
||||
max=0
|
||||
max_det=0
|
||||
i=0
|
||||
|
||||
while [ $i -lt $cnt ]; do
|
||||
let i++
|
||||
res=$(fping -o -c 1 -b $dsize -t $timeout -O $tos $host 2>&1)
|
||||
[ "$proto" = "Any" ] && res=$(fping -o -c 1 -b $dsize -t $timeout -O $tos $host 2>&1)
|
||||
[ "$proto" = "IPv4" ] && res=$(fping -4 -o -c 1 -b $dsize -t $timeout -O $tos $host 2>&1)
|
||||
[ "$proto" = "IPv6" ] && res=$(fping -6 -o -c 1 -b $dsize -t $timeout -O $tos $host 2>&1)
|
||||
ba=`echo "$res" | grep "not known"`
|
||||
[ -n "$ba" ] && { $UCI_SET_VARSTATE cwmp.@ippingdiagnostic[0].DiagnosticState=Error_CannotResolveHostName; return; }
|
||||
stc=`echo "$res" | grep "loss"`
|
||||
|
|
@ -53,24 +57,36 @@ ipping_launch() {
|
|||
min_time=${min_time:-0}
|
||||
avg_time=${avg_time:-0}
|
||||
max_time=${max_time:-0}
|
||||
min_time_det=$(echo $min_time $micros | awk '{printf "%3.0f\n",$1*$2}')
|
||||
avg_time_det=$(echo $avg_time $micros | awk '{printf "%3.0f\n",$1*$2}')
|
||||
max_time_det=$(echo $max_time $micros | awk '{printf "%3.0f\n",$1*$2}')
|
||||
min_time=$(awk "BEGIN{print $min_time * 1000}")
|
||||
avg_time=$(awk "BEGIN{print $avg_time * 1000}")
|
||||
max_time=$(awk "BEGIN{print $max_time * 1000}")
|
||||
[ $min_time -lt $min ] && min=$min_time
|
||||
[ $max_time -gt $max ] && max=$max_time
|
||||
avg_time_sum=$((avg_time_sum+avg_time))
|
||||
[ $min_time_det -lt $min_det ] && min_det=$min_time_det
|
||||
[ $max_time_det -gt $max_det ] && max_det=$max_time_det
|
||||
avg_time_sum_det=$((avg_time_sum_det+avg_time_det))
|
||||
done
|
||||
failure_count=$((cnt-success_count))
|
||||
[ $success_count -gt 0 ] && avg_time=$((avg_time_sum/success_count)) || avg_time=0
|
||||
[ $success_count -gt 0 ] && avg_time_det=$((avg_time_sum_det/success_count)) || avg_time_det=0
|
||||
avg_time=$(awk "BEGIN{print int($avg_time / 1000)}")
|
||||
min_time=$(awk "BEGIN{print int($min / 1000)}")
|
||||
max_time=$(awk "BEGIN{print int($max / 1000)}")
|
||||
min_time_det=$min_det
|
||||
max_time_det=$max_det
|
||||
$UCI_SET_VARSTATE cwmp.@ippingdiagnostic[0].DiagnosticState=Complete
|
||||
$UCI_SET_VARSTATE cwmp.@ippingdiagnostic[0].SuccessCount=$success_count
|
||||
$UCI_SET_VARSTATE cwmp.@ippingdiagnostic[0].FailureCount=$failure_count
|
||||
$UCI_SET_VARSTATE cwmp.@ippingdiagnostic[0].AverageResponseTime=$avg_time
|
||||
$UCI_SET_VARSTATE cwmp.@ippingdiagnostic[0].MinimumResponseTime=$min_time
|
||||
$UCI_SET_VARSTATE cwmp.@ippingdiagnostic[0].MaximumResponseTime=$max_time
|
||||
$UCI_SET_VARSTATE cwmp.@ippingdiagnostic[0].AverageResponseTimeDetailed=$avg_time_det
|
||||
$UCI_SET_VARSTATE cwmp.@ippingdiagnostic[0].MinimumResponseTimeDetailed=$min_time_det
|
||||
$UCI_SET_VARSTATE cwmp.@ippingdiagnostic[0].MaximumResponseTimeDetailed=$max_time_det
|
||||
event_dignostic
|
||||
}
|
||||
|
||||
|
|
@ -84,6 +100,7 @@ event_dignostic() {
|
|||
let i++
|
||||
done
|
||||
}
|
||||
|
||||
ipping_stop_diagnostic() {
|
||||
local pids=`ps | grep ipping_launch | grep -v grep | awk '{print $1}'`
|
||||
if [ -n "$pids" ]; then
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
|
||||
UCI_CONFIG_DIR="/etc/config/"
|
||||
UCI_GET_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state get "
|
||||
UCI_SET_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state set "
|
||||
UCI_GET_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state get"
|
||||
UCI_SET_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state set"
|
||||
LOG_FILE="/tmp/nslookup.log"
|
||||
|
||||
nslookup_get() {
|
||||
|
|
@ -13,11 +13,6 @@ nslookup_get() {
|
|||
echo ${val:-$2}
|
||||
}
|
||||
|
||||
nslookup_set() {
|
||||
$UCI_SET_VARSTATE $1=$2
|
||||
return 0
|
||||
}
|
||||
|
||||
nslookup_launch() {
|
||||
local i time1 time2 timeresponse
|
||||
[ "`$UCI_GET_VARSTATE cwmp.@nslookupdiagnostic[0].DiagnosticState`" != "Requested" ] && return
|
||||
|
|
@ -69,4 +64,4 @@ elif [ "$1" == "stop" ]; then
|
|||
nslookup_stop_diagnostic
|
||||
else
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
|
|
|||
138
scripts/functions/serverselection_launch
Normal file
138
scripts/functions/serverselection_launch
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
#!/bin/sh
|
||||
# Copyright (C) 2019 PIVA Software <www.pivasoftware.com>
|
||||
# Author: AMIN Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
|
||||
|
||||
UCI_CONFIG_DIR="/etc/config/"
|
||||
UCI_GET_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state get"
|
||||
UCI_SET_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state set"
|
||||
|
||||
serverselection_get() {
|
||||
local val=`$UCI_GET_VARSTATE $1`
|
||||
echo ${val:-$2}
|
||||
}
|
||||
|
||||
serverselection_launch() {
|
||||
local i res ba stc times sc1 success_count min_time avg_time max_time avg_time_sum min max fasthost micros
|
||||
[ "`$UCI_GET_VARSTATE cwmp.@serverselectiondiagnostic[0].DiagnosticState`" != "Requested" ] && return
|
||||
local hostlist=`serverselection_get cwmp.@serverselectiondiagnostic[0].HostList`
|
||||
local cnt=`serverselection_get cwmp.@serverselectiondiagnostic[0].NumberOfRepetitions 3`
|
||||
local timeout=`serverselection_get cwmp.@serverselectiondiagnostic[0].Timeout 1000`
|
||||
local port=`serverselection_get cwmp.@serverselectiondiagnostic[0].port`
|
||||
local protoversion=`serverselection_get cwmp.@serverselectiondiagnostic[0].ProtocolVersion Any`
|
||||
local proto=`serverselection_get cwmp.@serverselectiondiagnostic[0].Protocol ICMP`
|
||||
[ "$hostlist" = "" ] && return
|
||||
timeout=$((timeout/1000))
|
||||
[ "$timeout" = "0" ] && timeout="1"
|
||||
micros=1000
|
||||
success_count=0
|
||||
avg_time_sum=0
|
||||
avg_time_host=9999999
|
||||
min=9999999
|
||||
max=0
|
||||
i=0
|
||||
|
||||
for host in $(echo $hostlist | tr "," "\n"); do
|
||||
if [ "$proto" == "ICMP" ]; then
|
||||
while [ $i -lt $cnt ]; do
|
||||
let i++
|
||||
[ "$protoversion" = "Any" ] && res=$(ping -q -c 1 -W $timeout $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"`
|
||||
[ -n "$ba" ] && { $UCI_SET_VARSTATE cwmp.@serverselectiondiagnostic[0].DiagnosticState=Error_CannotResolveHostName; break; }
|
||||
ba=`echo "$res" | grep "unknown host"`
|
||||
[ -n "$ba" ] && { $UCI_SET_VARSTATE cwmp.@serverselectiondiagnostic[0].DiagnosticState=Error_CannotResolveHostName; break; }
|
||||
stc=`echo "$res" | grep "received"`
|
||||
[ -z "$stc" ] && { $UCI_SET_VARSTATE cwmp.@serverselectiondiagnostic[0].DiagnosticState=Error_Other; break; }
|
||||
times=`echo "$res" | grep "min/avg/max"`
|
||||
[ -z "$times" ] && break
|
||||
sc1=`echo $stc | awk '{print $4}'`
|
||||
sc1=${sc1:-0}
|
||||
success_count=$((success_count+sc1))
|
||||
times=`echo $times | awk -F'=' '{ print $2 }'`
|
||||
min_time=`echo $times | awk -F'[=/ ]' '{ print $1 }'`
|
||||
avg_time=`echo $times | awk -F'[=/ ]' '{ print $2 }'`
|
||||
max_time=`echo $times | awk -F'[=/ ]' '{ print $3 }'`
|
||||
min_time=${min_time:-0}
|
||||
avg_time=${avg_time:-0}
|
||||
max_time=${max_time:-0}
|
||||
min_time=$(echo $min_time $micros | awk '{printf "%3.0f\n",$1*$2}')
|
||||
avg_time=$(echo $avg_time $micros | awk '{printf "%3.0f\n",$1*$2}')
|
||||
max_time=$(echo $max_time $micros | awk '{printf "%3.0f\n",$1*$2}')
|
||||
[ $min_time -lt $min ] && min=$min_time
|
||||
[ $max_time -gt $max ] && max=$max_time
|
||||
avg_time_sum=$((avg_time_sum+avg_time))
|
||||
done
|
||||
else
|
||||
while [ $i -lt $cnt ]; do
|
||||
[ "$port" = "" ] && return
|
||||
let i++
|
||||
[ "$protoversion" = "Any" ] && res=$(nping -c 1 --udp --dest-port $port --data-length 24 $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"`
|
||||
[ -z "$ba" ] && { $UCI_SET_VARSTATE cwmp.@ippingdiagnostic[0].DiagnosticState=Error_CannotResolveHostName; return; }
|
||||
stc=`echo "$res" | grep "RCVD" | grep "unreachable"`
|
||||
[ -n "$stc" ] && { $UCI_SET_VARSTATE cwmp.@ippingdiagnostic[0].DiagnosticState=Error_Other; return; }
|
||||
times=`echo "$res" | grep "rtt"`
|
||||
[ -z "$times" ] && continue
|
||||
sc1=`echo "$res" | grep "Rcvd" | awk -F': ' '{print $3}' | awk -F'(' '{ print $1 }'`
|
||||
sc1=${sc1:-0}
|
||||
success_count=$((success_count+sc1))
|
||||
max_time=`echo $times | awk -F': ' '{ print $2 }' | awk -F'ms' '{ print $1 }'`
|
||||
min_time=`echo $times | awk -F': ' '{ print $3 }' | awk -F'ms' '{ print $1 }'`
|
||||
avg_time=`echo $times | awk -F': ' '{ print $4 }' | awk -F'ms' '{ print $1 }'`
|
||||
min_time=${min_time:-0}
|
||||
avg_time=${avg_time:-0}
|
||||
max_time=${max_time:-0}
|
||||
min_time=$(echo $min_time $micros | awk '{printf "%3.0f\n",$1*$2}')
|
||||
avg_time=$(echo $avg_time $micros | awk '{printf "%3.0f\n",$1*$2}')
|
||||
max_time=$(echo $max_time $micros | awk '{printf "%3.0f\n",$1*$2}')
|
||||
[ $min_time -lt $min ] && min=$min_time
|
||||
[ $max_time -gt $max ] && max=$max_time
|
||||
avg_time_sum=$((avg_time_sum+avg_time))
|
||||
done
|
||||
fi
|
||||
[ $success_count -gt 0 ] && avg_time=$((avg_time_sum/success_count)) || avg_time=0
|
||||
[[ "$avg_time" != "0" && $avg_time -lt $avg_time_host ]] && avg_time_host=$avg_time && min_time=$min && max_time=$max && fasthost=$host
|
||||
success_count=0
|
||||
avg_time_sum=0
|
||||
min=9999999
|
||||
max=0
|
||||
i=0
|
||||
done
|
||||
$UCI_SET_VARSTATE cwmp.@serverselectiondiagnostic[0].DiagnosticState=Complete
|
||||
$UCI_SET_VARSTATE cwmp.@serverselectiondiagnostic[0].FastestHost=$fasthost
|
||||
$UCI_SET_VARSTATE cwmp.@serverselectiondiagnostic[0].AverageResponseTime=$avg_time_host
|
||||
$UCI_SET_VARSTATE cwmp.@serverselectiondiagnostic[0].MinimumResponseTime=$min_time
|
||||
$UCI_SET_VARSTATE cwmp.@serverselectiondiagnostic[0].MaximumResponseTime=$max_time
|
||||
event_dignostic
|
||||
}
|
||||
|
||||
event_dignostic() {
|
||||
local e=1
|
||||
local i=0
|
||||
while [ "$e" != 0 -a $i -lt 200 ]; do
|
||||
ubus -t 1 call tr069 inform '{"event":"8 DIAGNOSTICS COMPLETE"}' &>/dev/null
|
||||
e=$?
|
||||
[ "$e" != "0" ] && sleep 1;
|
||||
let i++
|
||||
done
|
||||
}
|
||||
|
||||
serverselection_stop_diagnostic() {
|
||||
local pids=`ps | grep serverselection_launch | grep -v grep | awk '{print $1}'`
|
||||
if [ -n "$pids" ]; then
|
||||
kill -9 $pids &>/dev/null
|
||||
$UCI_SET_VARSTATE cwmp.@serverselectiondiagnostic[0].DiagnosticState=None
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$1" == "run" ] ; then
|
||||
serverselection_launch
|
||||
elif [ "$1" == "stop" ]; then
|
||||
serverselection_stop_diagnostic
|
||||
else
|
||||
return
|
||||
fi
|
||||
88
scripts/functions/traceroute_launch
Normal file
88
scripts/functions/traceroute_launch
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
#!/bin/sh
|
||||
# Copyright (C) 2019 PIVA Software <www.pivasoftware.com>
|
||||
# Author: AMIN Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
|
||||
UCI_GET_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state get"
|
||||
UCI_SET_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state set"
|
||||
UCI_ADD_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state add"
|
||||
UCI_DELETE_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state delete"
|
||||
UCI_SHOW_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state show"
|
||||
|
||||
traceroute_get() {
|
||||
local val=`$UCI_GET_VARSTATE $1`
|
||||
echo ${val:-$2}
|
||||
}
|
||||
|
||||
traceroute_launch() {
|
||||
local i res host ip time=0
|
||||
[ "`$UCI_GET_VARSTATE cwmp.@traceroutediagnostic[0].DiagnosticState`" != "Requested" ] && return
|
||||
local host=`traceroute_get cwmp.@traceroutediagnostic[0].Host`
|
||||
local cnt=`traceroute_get cwmp.@traceroutediagnostic[0].NumberOfTries 3`
|
||||
local dsize=`traceroute_get cwmp.@traceroutediagnostic[0].DataBlockSize 38`
|
||||
local timeout=`traceroute_get cwmp.@traceroutediagnostic[0].Timeout 5000`
|
||||
local maxhop=`traceroute_get cwmp.@traceroutediagnostic[0].MaxHops 30`
|
||||
local proto=`traceroute_get cwmp.@traceroutediagnostic[0].ProtocolVersion Any`
|
||||
[ "$host" = "" ] && return
|
||||
timeout=$((timeout/1000))
|
||||
[ "$timeout" = "0" ] && timeout = "1"
|
||||
i=-2
|
||||
delete_all_route_hops
|
||||
rm -f /tmp/traceres
|
||||
[ "$proto" = "Any" ] && traceroute -m $maxhop -w $timeout -q $cnt $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
|
||||
[ "$host" = "*" -a "$ip" = "*" ] && continue
|
||||
let i++
|
||||
[ "$i" = "-1" ] && continue;
|
||||
ip=${ip#(}; ip=${ip%)}
|
||||
time=${time%.*}
|
||||
$UCI_ADD_VARSTATE cwmp RouteHops
|
||||
$UCI_SET_VARSTATE cwmp.@RouteHops[$i].host=$host
|
||||
$UCI_SET_VARSTATE cwmp.@RouteHops[$i].ip=$ip
|
||||
$UCI_SET_VARSTATE cwmp.@RouteHops[$i].time=$time
|
||||
done < /tmp/traceres
|
||||
rm -f /tmp/traceres
|
||||
let i++
|
||||
|
||||
$UCI_SET_VARSTATE cwmp.@traceroutediagnostic[0].DiagnosticState=Complete
|
||||
$UCI_SET_VARSTATE cwmp.@traceroutediagnostic[0].NumberOfHops=$i
|
||||
$UCI_SET_VARSTATE cwmp.@traceroutediagnostic[0].ResponseTime=$($UCI_GET_VARSTATE cwmp.@RouteHops[-1].time)
|
||||
event_diagnostic
|
||||
}
|
||||
|
||||
delete_all_route_hops() {
|
||||
local j
|
||||
for j in $($UCI_SHOW_VARSTATE cwmp | grep "cwmp.@RouteHops.*=RouteHops"); do
|
||||
$UCI_DELETE_VARSTATE cwmp.@RouteHops[-1]
|
||||
done
|
||||
}
|
||||
|
||||
event_diagnostic() {
|
||||
local e=1
|
||||
local i=0
|
||||
while [ "$e" != 0 -a $i -lt 200 ]; do
|
||||
ubus -t 1 call tr069 inform '{"event":"8 DIAGNOSTICS COMPLETE"}'
|
||||
e=$?
|
||||
[ "$e" != "0" ] && sleep 1;
|
||||
let i++
|
||||
done
|
||||
}
|
||||
|
||||
traceroute_stop() {
|
||||
delete_all_route_hops
|
||||
local pids=`ps aux | grep traceroute_launch | grep -v grep | grep -v stop | awk '{print $2}'`
|
||||
[ -z "$pids" ] && pids=`ps | grep traceroute_launch | grep -v grep | grep -v stop | awk '{print $2}'`
|
||||
if [ -n "$pids" ]; then
|
||||
kill -9 $pids 2>/dev/null
|
||||
$UCI_SET_VARSTATE cwmp.@traceroutediagnostic[0].DiagnosticState=None
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$1" == "run" ]; then
|
||||
traceroute_launch 2>/dev/null
|
||||
elif [ "$1" == "stop" ]; then
|
||||
traceroute_stop 2>/dev/null
|
||||
else
|
||||
return
|
||||
fi
|
||||
103
scripts/functions/udpecho_launch
Normal file
103
scripts/functions/udpecho_launch
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
#!/bin/sh
|
||||
# Copyright (C) 2019 PIVA Software <www.pivasoftware.com>
|
||||
# Author: AMIN Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
|
||||
|
||||
UCI_CONFIG_DIR="/etc/config/"
|
||||
UCI_GET_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state get"
|
||||
UCI_SET_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state set"
|
||||
|
||||
udpecho_get() {
|
||||
local val=`$UCI_GET_VARSTATE $1`
|
||||
echo ${val:-$2}
|
||||
}
|
||||
|
||||
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
|
||||
[ "`$UCI_GET_VARSTATE cwmp.@udpechodiagnostic[0].DiagnosticState`" != "Requested" ] && return
|
||||
local host=`udpecho_get cwmp.@udpechodiagnostic[0].Host`
|
||||
local port=`udpecho_get cwmp.@udpechodiagnostic[0].port`
|
||||
local cnt=`udpecho_get cwmp.@udpechodiagnostic[0].NumberOfRepetitions 1`
|
||||
local dsize=`udpecho_get cwmp.@udpechodiagnostic[0].DataBlockSize 24`
|
||||
local dscp=`udpecho_get cwmp.@udpechodiagnostic[0].DSCP 0`
|
||||
local proto=`udpecho_get cwmp.@udpechodiagnostic[0].ProtocolVersion Any`
|
||||
local inter_time=`udpecho_get cwmp.@udpechodiagnostic[0].InterTransmissionTime 1000`
|
||||
local tos=$((dscp<<2))
|
||||
inter_time=$((inter_time/1000))
|
||||
[ "$inter_time" = "0" ] && inter_time="1"
|
||||
[ "$host" = "" ] && return
|
||||
[ "$port" = "" ] && return
|
||||
micros=1000
|
||||
success_count=0
|
||||
avg_time_sum=0
|
||||
min=9999999
|
||||
max=0
|
||||
i=0
|
||||
|
||||
while [ $i -lt $cnt ]; do
|
||||
let i++
|
||||
[ "$proto" = "Any" ] && res=$(nping -c 1 --tos $tos --udp --dest-port $port --data-length $dsize $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"`
|
||||
[ -z "$ba" ] && { $UCI_SET_VARSTATE cwmp.@ippingdiagnostic[0].DiagnosticState=Error_CannotResolveHostName; return; }
|
||||
stc=`echo "$res" | grep "RCVD" | grep "unreachable"`
|
||||
[ -n "$stc" ] && { $UCI_SET_VARSTATE cwmp.@ippingdiagnostic[0].DiagnosticState=Error_Other; return; }
|
||||
times=`echo "$res" | grep "rtt"`
|
||||
[ -z "$times" ] && continue
|
||||
sc1=`echo "$res" | grep "Rcvd" | awk -F': ' '{print $3}' | awk -F'(' '{ print $1 }'`
|
||||
sc1=${sc1:-0}
|
||||
success_count=$((success_count+sc1))
|
||||
max_time=`echo $times | awk -F': ' '{ print $2 }' | awk -F'ms' '{ print $1 }'`
|
||||
min_time=`echo $times | awk -F': ' '{ print $3 }' | awk -F'ms' '{ print $1 }'`
|
||||
avg_time=`echo $times | awk -F': ' '{ print $4 }' | awk -F'ms' '{ print $1 }'`
|
||||
min_time=${min_time:-0}
|
||||
avg_time=${avg_time:-0}
|
||||
max_time=${max_time:-0}
|
||||
min_time=$(echo $min_time $micros | awk '{printf "%3.0f\n",$1*$2}')
|
||||
avg_time=$(echo $avg_time $micros | awk '{printf "%3.0f\n",$1*$2}')
|
||||
max_time=$(echo $max_time $micros | awk '{printf "%3.0f\n",$1*$2}')
|
||||
[ $min_time -lt $min ] && min=$min_time
|
||||
[ $max_time -gt $max ] && max=$max_time
|
||||
avg_time_sum=$((avg_time_sum+avg_time))
|
||||
sleep $inter_time
|
||||
done
|
||||
failure_count=$((cnt-success_count))
|
||||
[ $success_count -gt 0 ] && avg_time=$((avg_time_sum/success_count)) || avg_time=0
|
||||
min_time=$min
|
||||
max_time=$max
|
||||
$UCI_SET_VARSTATE cwmp.@udpechodiagnostic[0].DiagnosticState=Complete
|
||||
$UCI_SET_VARSTATE cwmp.@udpechodiagnostic[0].SuccessCount=$success_count
|
||||
$UCI_SET_VARSTATE cwmp.@udpechodiagnostic[0].FailureCount=$failure_count
|
||||
$UCI_SET_VARSTATE cwmp.@udpechodiagnostic[0].AverageResponseTime=$avg_time
|
||||
$UCI_SET_VARSTATE cwmp.@udpechodiagnostic[0].MinimumResponseTime=$min_time
|
||||
$UCI_SET_VARSTATE cwmp.@udpechodiagnostic[0].MaximumResponseTime=$max_time
|
||||
event_dignostic
|
||||
}
|
||||
|
||||
event_dignostic() {
|
||||
local e=1
|
||||
local i=0
|
||||
while [ "$e" != 0 -a $i -lt 200 ]; do
|
||||
ubus -t 1 call tr069 inform '{"event":"8 DIAGNOSTICS COMPLETE"}' &>/dev/null
|
||||
e=$?
|
||||
[ "$e" != "0" ] && sleep 1;
|
||||
let i++
|
||||
done
|
||||
}
|
||||
|
||||
udpecho_stop_diagnostic() {
|
||||
local pids=`ps | grep udpecho_launch | grep -v grep | awk '{print $1}'`
|
||||
if [ -n "$pids" ]; then
|
||||
kill -9 $pids &>/dev/null
|
||||
$UCI_SET_VARSTATE cwmp.@udpechodiagnostic[0].DiagnosticState=None
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$1" == "run" ] ; then
|
||||
udpecho_launch
|
||||
elif [ "$1" == "stop" ]; then
|
||||
udpecho_stop_diagnostic
|
||||
else
|
||||
return
|
||||
fi
|
||||
|
|
@ -1,25 +1,45 @@
|
|||
#!/bin/sh
|
||||
# Copyright (C) 2015 PIVA Software <www.pivasoftware.com>
|
||||
# Copyright (C) 2019 PIVA Software <www.pivasoftware.com>
|
||||
# Author: IMEN Bhiri <imen.bhiri@pivasoftware.com>
|
||||
# Author: AMIN Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
|
||||
|
||||
UCI_CONFIG_DIR="/etc/config/"
|
||||
UCI_GET_VARSTATE="/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state get -q "
|
||||
UCI_SET_VARSTATE="/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state set -q "
|
||||
UCI_GET_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state get"
|
||||
UCI_SET_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state set"
|
||||
UCI_ADD_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state add"
|
||||
UCI_DELETE_VARSTATE="/sbin/uci -q ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state delete"
|
||||
CAPTURE_FILE="/tmp/upload_dump"
|
||||
UPLOAD_DIAGNOSTIC_FILE="/tmp/icwmp_upload_diagnostic"
|
||||
CONNECTION_TIMEOUT=20
|
||||
|
||||
upload_get() {
|
||||
local val=`$UCI_GET_VARSTATE $1`
|
||||
echo ${val:-$2}
|
||||
}
|
||||
|
||||
upload_launch() {
|
||||
url=$1
|
||||
interface=$2
|
||||
size=$3
|
||||
local tx_bytes_before rx_bytes_before time1 tx_bytes_after rx_bytes_after time2 res ba stc periodtime
|
||||
local url=$1
|
||||
local interface=$2
|
||||
local size=$3
|
||||
[ "`$UCI_GET_VARSTATE cwmp.@uploaddiagnostic[0].DiagnosticState`" != "Requested" ] && return
|
||||
[ "$url" = "" ] && { $UCI_SET_VARSTATE cwmp.@uploaddiagnostic[0].DiagnosticState=Error_InitConnectionFailed; return; }
|
||||
local proto=`upload_get cwmp.@uploaddiagnostic[0].ProtocolVersion Any`
|
||||
tcpdump -i $interface tcp -w ${CAPTURE_FILE} > /dev/null 2>&1 &
|
||||
PID=$!
|
||||
sleep 1
|
||||
dd if=/dev/zero of=${UPLOAD_DIAGNOSTIC_FILE} bs=${size} count=1 2>/dev/null
|
||||
if [ ${url:0:7} = http:// ]; then
|
||||
res=$(curl --fail --connect-timeout ${CONNECTION_TIMEOUT} -T ${UPLOAD_DIAGNOSTIC_FILE} $url 2>&1)
|
||||
tx_bytes_before=`ubus call network.device status "{'name':'$interface'}" | sed -n '/statistics/,$ p' | grep "tx_bytes" | awk -F ": " '{print $2}' | sed 's/.$//'`
|
||||
rx_bytes_before=`ubus call network.device status "{'name':'$interface'}" | sed -n '/statistics/,$ p' | grep "rx_bytes" | awk -F ": " '{print $2}' | sed 's/.$//'`
|
||||
time1=`date +%s`
|
||||
[ "$proto" = "Any" ] && res=$(curl --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`
|
||||
tx_bytes_after=`ubus call network.device status "{'name':'$interface'}" | sed -n '/statistics/,$ p' | grep "tx_bytes" | awk -F ": " '{print $2}' | sed 's/.$//'`
|
||||
rx_bytes_after=`ubus call network.device status "{'name':'$interface'}" | sed -n '/statistics/,$ p' | grep "rx_bytes" | awk -F ": " '{print $2}' | sed 's/.$//'`
|
||||
ba=`echo "$res" | grep "bad address"`
|
||||
[ -n "$ba" ] && { $UCI_SET_VARSTATE cwmp.@uploaddiagnostic[0].DiagnosticState=Error_InitConnectionFailed; kill $PID &> /dev/null; return; }
|
||||
stc=`echo "$res" | grep "404 Not Found"`
|
||||
|
|
@ -32,7 +52,15 @@ upload_launch() {
|
|||
if [ -z "${url##*$substr*}" ] ;then
|
||||
url=`echo $url |sed -e "s/ftp:\/\/\([^:]*\):\([^:]*\)@\(.*\)/-u \1:\2 ftp:\/\/\3/"`
|
||||
fi
|
||||
res=$(curl --fail --disable-epsv --ftp-pasv --connect-timeout ${CONNECTION_TIMEOUT} -T ${UPLOAD_DIAGNOSTIC_FILE} $url 2>&1)
|
||||
tx_bytes_before=`ubus call network.device status "{'name':'$interface'}" | sed -n '/statistics/,$ p' | grep "tx_bytes" | awk -F ": " '{print $2}' | sed 's/.$//'`
|
||||
rx_bytes_before=`ubus call network.device status "{'name':'$interface'}" | sed -n '/statistics/,$ p' | grep "rx_bytes" | awk -F ": " '{print $2}' | sed 's/.$//'`
|
||||
time1=`date +%s`
|
||||
[ "$proto" = "Any" ] && res=$(curl --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`
|
||||
tx_bytes_after=`ubus call network.device status "{'name':'$interface'}" | sed -n '/statistics/,$ p' | grep "tx_bytes" | awk -F ": " '{print $2}' | sed 's/.$//'`
|
||||
rx_bytes_after=`ubus call network.device status "{'name':'$interface'}" | sed -n '/statistics/,$ p' | grep "rx_bytes" | awk -F ": " '{print $2}' | sed 's/.$//'`
|
||||
ba=`echo "$res" | grep "Couldn't resolve host"`
|
||||
[ -n "$ba" ] && { $UCI_SET_VARSTATE cwmp.@uploaddiagnostic[0].DiagnosticState=Error_InitConnectionFailed; kill $PID 2> /dev/null; return; }
|
||||
stc=`echo "$res" | grep "Access denied"`
|
||||
|
|
@ -42,7 +70,23 @@ upload_launch() {
|
|||
stc=`echo "$res" |tail -n 1 |awk '{print $(NF-11)}'`
|
||||
[ "$stc" != "100" ] && { $UCI_SET_VARSTATE cwmp.@uploaddiagnostic[0].DiagnosticState=Error_TransferFailed; kill $PID 2> /dev/null; return; }
|
||||
fi
|
||||
tx_bytes=$((tx_bytes_after-tx_bytes_before))
|
||||
rx_bytes=$((rx_bytes_after-rx_bytes_before))
|
||||
periodtime=$(($((time2-time1))*1000000))
|
||||
$UCI_SET_VARSTATE cwmp.@uploaddiagnostic[0].DiagnosticState=Completed
|
||||
$UCI_SET_VARSTATE cwmp.@uploaddiagnostic[0].TestBytesSent=$size
|
||||
$UCI_SET_VARSTATE cwmp.@uploaddiagnostic[0].TotalBytesReceived=$rx_bytes
|
||||
$UCI_SET_VARSTATE cwmp.@uploaddiagnostic[0].TotalBytesSent=$tx_bytes
|
||||
$UCI_SET_VARSTATE cwmp.@uploaddiagnostic[0].PeriodOfFullLoading=$periodtime
|
||||
local perconnection=`$UCI_GET_VARSTATE cwmp.@uploaddiagnostic[0].EnablePerConnection`
|
||||
if ([ "$perconnection" == "true" ] || [ "$perconnection" == "1" ]); then
|
||||
$UCI_ADD_VARSTATE cwmp UploadPerConnection
|
||||
$UCI_SET_VARSTATE cwmp.@UploadPerConnection[0].TestBytesSent=$size
|
||||
$UCI_SET_VARSTATE cwmp.@UploadPerConnection[0].TotalBytesReceived=$rx_bytes
|
||||
$UCI_SET_VARSTATE cwmp.@UploadPerConnection[0].TotalBytesSent=$tx_bytes
|
||||
else
|
||||
$UCI_DELETE_VARSTATE cwmp.@UploadPerConnection[0]
|
||||
fi
|
||||
rm ${UPLOAD_DIAGNOSTIC_FILE} &>/dev/null
|
||||
sleep 3
|
||||
local pids=`ps | grep $PID`
|
||||
|
|
@ -50,6 +94,7 @@ upload_launch() {
|
|||
}
|
||||
|
||||
upload_stop_diagnostic() {
|
||||
$UCI_DELETE_VARSTATE cwmp.@UploadPerConnection[0]
|
||||
local pids=`ps | grep upload_launch.*run | grep -v grep | awk '{print $1}'`
|
||||
if [ -n "$pids" ]; then
|
||||
kill -9 $pids &>/dev/null
|
||||
|
|
|
|||
228
udpechoserver/udpechoserver.c
Normal file
228
udpechoserver/udpechoserver.c
Normal file
|
|
@ -0,0 +1,228 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2019 iopsys Software Solutions AB
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
*/
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include "udpechoserver.h"
|
||||
#include "udpechoserverlog.h"
|
||||
#include "udpechoserveruci.h"
|
||||
|
||||
struct udpechoserver_config cur_udpechoserver_conf = {0};
|
||||
struct udpechoserver_result cur_udpechoserver_result={0};
|
||||
|
||||
static void set_udpechoserver_stats(void)
|
||||
{
|
||||
char PacketsReceived[8], PacketsResponded[8], BytesReceived[8], BytesResponded[8];
|
||||
|
||||
sprintf(PacketsReceived, "%d", cur_udpechoserver_result.PacketsReceived);
|
||||
sprintf(PacketsResponded, "%d", cur_udpechoserver_result.PacketsResponded);
|
||||
sprintf(BytesReceived, "%d", cur_udpechoserver_result.BytesReceived);
|
||||
sprintf(BytesResponded, "%d", cur_udpechoserver_result.BytesResponded);
|
||||
|
||||
dmuci_init();
|
||||
dmuci_set_value_state("cwmp_udpechoserver", "udpechoserver", "PacketsReceived", PacketsReceived);
|
||||
dmuci_set_value_state("cwmp_udpechoserver", "udpechoserver", "PacketsResponded", PacketsResponded);
|
||||
dmuci_set_value_state("cwmp_udpechoserver", "udpechoserver", "BytesReceived", BytesReceived);
|
||||
dmuci_set_value_state("cwmp_udpechoserver", "udpechoserver", "BytesResponded", BytesResponded);
|
||||
dmuci_set_value_state("cwmp_udpechoserver", "udpechoserver", "TimeFirstPacketReceived", cur_udpechoserver_result.TimeFirstPacket);
|
||||
dmuci_set_value_state("cwmp_udpechoserver", "udpechoserver", "TimeLastPacketReceived", cur_udpechoserver_result.TimeLastPacket);
|
||||
dmuci_fini();
|
||||
}
|
||||
|
||||
int udpechoserver_connect(void)
|
||||
{
|
||||
int sock, fromlen, n, ret;
|
||||
struct sockaddr_in server, from;
|
||||
struct timeval tv_recv, tv_reply;
|
||||
struct tm lt;
|
||||
char buf[1024];
|
||||
char str[INET_ADDRSTRLEN];
|
||||
char s_now[default_date_size];
|
||||
struct udpechoserver_plus *plus;
|
||||
|
||||
memset(&cur_udpechoserver_result, 0, sizeof(cur_udpechoserver_result));
|
||||
|
||||
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (sock < 0) {
|
||||
udpechoserver_log(SCRIT,"Socket error = %d", sock);
|
||||
return -1;
|
||||
}
|
||||
|
||||
bzero(&server, sizeof(server));
|
||||
server.sin_family=AF_INET;
|
||||
server.sin_addr.s_addr=INADDR_ANY;
|
||||
server.sin_port=htons(cur_udpechoserver_conf.server_port);
|
||||
|
||||
if (bind(sock, (struct sockaddr *)&server, sizeof(server)) > 0) {
|
||||
udpechoserver_log(SCRIT,"Error in bind function");
|
||||
return -1;
|
||||
}
|
||||
|
||||
udpechoserver_log(SINFO,"CONNECT UDPECHOSERVER");
|
||||
|
||||
while(true)
|
||||
{
|
||||
fromlen = sizeof(struct sockaddr_in);
|
||||
n = recvfrom(sock, buf, 1024, 0, (struct sockaddr *)&from, &fromlen);
|
||||
if (n < 0)
|
||||
udpechoserver_log(SCRIT,"Error in receive message");
|
||||
|
||||
inet_ntop(AF_INET, &(from.sin_addr.s_addr), str, INET_ADDRSTRLEN);
|
||||
udpechoserver_log(SINFO,"UDPECHOSERVER receive massage from %s with data size is %d Bytes", str, n);
|
||||
|
||||
if(cur_udpechoserver_conf.address && cur_udpechoserver_conf.address[0] != '\0') {
|
||||
if(strcmp(cur_udpechoserver_conf.address, str) != 0) {
|
||||
udpechoserver_log(SINFO,"UDPECHOSERVER can not respond to a UDP echo from this source IP address %s", str);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
gettimeofday(&tv_recv, NULL);
|
||||
if(cur_udpechoserver_result.TimeFirstPacketReceived.tv_sec == 0 && cur_udpechoserver_result.TimeFirstPacketReceived.tv_usec == 0)
|
||||
cur_udpechoserver_result.TimeFirstPacketReceived = tv_recv;
|
||||
cur_udpechoserver_result.TimeLastPacketReceived = tv_recv;
|
||||
cur_udpechoserver_result.PacketsReceived++;
|
||||
cur_udpechoserver_result.BytesReceived+=n;
|
||||
(void) localtime_r(&(cur_udpechoserver_result.TimeFirstPacketReceived.tv_sec), <);
|
||||
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", <);
|
||||
sprintf(cur_udpechoserver_result.TimeFirstPacket,"%s.%06ld", s_now, (long) cur_udpechoserver_result.TimeFirstPacketReceived.tv_usec);
|
||||
(void) localtime_r(&(cur_udpechoserver_result.TimeLastPacketReceived.tv_sec), <);
|
||||
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", <);
|
||||
sprintf(cur_udpechoserver_result.TimeLastPacket,"%s.%06ld", s_now, (long) cur_udpechoserver_result.TimeLastPacketReceived.tv_usec);
|
||||
|
||||
if(cur_udpechoserver_conf.plus) {
|
||||
if(n >= sizeof(struct udpechoserver_plus)) {
|
||||
plus = (struct udpechoserver_plus *)buf;
|
||||
plus->TestRespSN = htonl(cur_udpechoserver_result.TestRespSN);
|
||||
plus->TestRespRecvTimeStamp = htonl(tv_recv.tv_sec*1000000+tv_recv.tv_usec);
|
||||
plus->TestRespReplyFailureCount = htonl(cur_udpechoserver_result.TestRespReplyFailureCount);
|
||||
gettimeofday(&tv_reply, NULL);
|
||||
plus->TestRespReplyTimeStamp = htonl(tv_reply.tv_sec*1000000+tv_reply.tv_usec);
|
||||
}
|
||||
}
|
||||
|
||||
ret = sendto(sock, buf, n, 0, (struct sockaddr *)&from, fromlen);
|
||||
if (n != ret) {
|
||||
cur_udpechoserver_result.TestRespReplyFailureCount++;
|
||||
udpechoserver_log(SCRIT,"Error in send massage");
|
||||
}
|
||||
else {
|
||||
cur_udpechoserver_result.TestRespSN++;
|
||||
cur_udpechoserver_result.PacketsResponded++;
|
||||
cur_udpechoserver_result.BytesResponded+=ret;
|
||||
}
|
||||
udpechoserver_log(SINFO,"UDPECHOSERVER sent massage to %s with data size is %d Bytes", str, ret);
|
||||
|
||||
set_udpechoserver_stats();
|
||||
|
||||
udpechoserver_log(SDEBUG,"UDPECHOSERVER Stats : PacketsReceived = %d", cur_udpechoserver_result.PacketsReceived);
|
||||
udpechoserver_log(SDEBUG,"UDPECHOSERVER Stats : PacketsResponded = %d", cur_udpechoserver_result.PacketsResponded);
|
||||
udpechoserver_log(SDEBUG,"UDPECHOSERVER Stats : BytesReceived = %d", cur_udpechoserver_result.BytesReceived);
|
||||
udpechoserver_log(SDEBUG,"UDPECHOSERVER Stats : BytesResponded = %d", cur_udpechoserver_result.BytesResponded);
|
||||
udpechoserver_log(SDEBUG,"UDPECHOSERVER Stats : TestRespReplyFailureCount = %d", cur_udpechoserver_result.TestRespReplyFailureCount);
|
||||
udpechoserver_log(SDEBUG,"UDPECHOSERVER Stats : TimeFirstPacketReceived = %s", cur_udpechoserver_result.TimeFirstPacket);
|
||||
udpechoserver_log(SDEBUG,"UDPECHOSERVER Stats : TimeLastPacketReceived = %s", cur_udpechoserver_result.TimeLastPacket);
|
||||
}
|
||||
}
|
||||
|
||||
int udpechoserver_init(void)
|
||||
{
|
||||
char *value = NULL;
|
||||
int a;
|
||||
|
||||
value = dmuci_get_value("cwmp_udpechoserver", "udpechoserver", "log_level");
|
||||
if(value != NULL && *value != '\0') {
|
||||
a = atoi(value);
|
||||
cur_udpechoserver_conf.loglevel = a;
|
||||
}
|
||||
else
|
||||
cur_udpechoserver_conf.loglevel = DEFAULT_LOGLEVEL;
|
||||
udpechoserver_log(SDEBUG,"Log Level of UDP ECHO SERVER is :%d", cur_udpechoserver_conf.loglevel);
|
||||
|
||||
value = dmuci_get_value("cwmp_udpechoserver", "udpechoserver", "enable");
|
||||
if(value != NULL && *value != '\0') {
|
||||
if ((strcasecmp(value,"true")==0) || (strcmp(value,"1")==0)) {
|
||||
cur_udpechoserver_conf.enable = true;
|
||||
udpechoserver_log(SDEBUG,"UDP echo server is Enabled");
|
||||
}
|
||||
}
|
||||
|
||||
value = dmuci_get_value("cwmp_udpechoserver", "udpechoserver", "interface");
|
||||
if(value != NULL && *value != '\0') {
|
||||
if (cur_udpechoserver_conf.interface != NULL)
|
||||
free(cur_udpechoserver_conf.interface);
|
||||
cur_udpechoserver_conf.interface = strdup(value);
|
||||
udpechoserver_log(SDEBUG,"UDP echo server interface is :%s", cur_udpechoserver_conf.interface);
|
||||
}
|
||||
else {
|
||||
cur_udpechoserver_conf.interface = strdup("");
|
||||
udpechoserver_log(SDEBUG,"UDP echo server interface is empty");
|
||||
}
|
||||
|
||||
value = dmuci_get_value("cwmp_udpechoserver", "udpechoserver", "address");
|
||||
if(value != NULL && *value != '\0') {
|
||||
if (cur_udpechoserver_conf.address != NULL)
|
||||
free(cur_udpechoserver_conf.address);
|
||||
cur_udpechoserver_conf.address = strdup(value);
|
||||
udpechoserver_log(SDEBUG,"UDP echo server address is :%s", cur_udpechoserver_conf.address);
|
||||
}
|
||||
else {
|
||||
cur_udpechoserver_conf.address = strdup("");
|
||||
udpechoserver_log(SDEBUG,"UDP echo server address is empty");
|
||||
}
|
||||
|
||||
value = dmuci_get_value("cwmp_udpechoserver", "udpechoserver", "server_port");
|
||||
if(value != NULL && *value != '\0') {
|
||||
a = atoi(value);
|
||||
cur_udpechoserver_conf.server_port = a;
|
||||
udpechoserver_log(SDEBUG,"UDP echo server port is :%d", cur_udpechoserver_conf.server_port);
|
||||
}
|
||||
|
||||
value = dmuci_get_value("cwmp_udpechoserver", "udpechoserver", "plus");
|
||||
if(value != NULL && *value != '\0') {
|
||||
if ((strcasecmp(value,"true")==0) || (strcmp(value,"1")==0)) {
|
||||
cur_udpechoserver_conf.plus = true;
|
||||
udpechoserver_log(SDEBUG,"UDP echo server plus is Enabled");
|
||||
}
|
||||
else {
|
||||
cur_udpechoserver_conf.plus = false;
|
||||
udpechoserver_log(SDEBUG,"UDP echo server plus is Disabled");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void udpechoserver_exit(void)
|
||||
{
|
||||
free(cur_udpechoserver_conf.address);
|
||||
free(cur_udpechoserver_conf.interface);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
dmuci_init();
|
||||
udpechoserver_init();
|
||||
dmuci_fini();
|
||||
udpechoserver_log(SINFO,"START UDPECHOSERVER");
|
||||
|
||||
udpechoserver_connect();
|
||||
|
||||
udpechoserver_exit();
|
||||
udpechoserver_log(SINFO,"EXIT UDPECHOSERVER");
|
||||
return 0;
|
||||
}
|
||||
56
udpechoserver/udpechoserver.h
Normal file
56
udpechoserver/udpechoserver.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2019 iopsys Software Solutions AB
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
*/
|
||||
|
||||
#ifndef _UDPECHOSERVER_H__
|
||||
#define _UDPECHOSERVER_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#define default_date_format "AAAA-MM-JJTHH:MM:SS.000000Z"
|
||||
#define default_date_size sizeof(default_date_format) + 1
|
||||
|
||||
struct udpechoserver_config
|
||||
{
|
||||
bool enable;
|
||||
char *interface;
|
||||
char *address;
|
||||
int server_port;
|
||||
bool plus;
|
||||
int loglevel;
|
||||
};
|
||||
|
||||
struct udpechoserver_plus
|
||||
{
|
||||
unsigned int TestGenSN;
|
||||
unsigned int TestRespSN;
|
||||
unsigned int TestRespRecvTimeStamp;
|
||||
unsigned int TestRespReplyTimeStamp;
|
||||
unsigned int TestRespReplyFailureCount;
|
||||
};
|
||||
|
||||
struct udpechoserver_result
|
||||
{
|
||||
unsigned int TestRespSN;
|
||||
unsigned int TestRespReplyFailureCount;
|
||||
unsigned int PacketsReceived;
|
||||
unsigned int PacketsResponded;
|
||||
unsigned int BytesReceived;
|
||||
unsigned int BytesResponded;
|
||||
struct timeval TimeFirstPacketReceived;
|
||||
struct timeval TimeLastPacketReceived;
|
||||
char TimeFirstPacket[default_date_size];
|
||||
char TimeLastPacket[default_date_size];
|
||||
};
|
||||
|
||||
extern struct udpechoserver_config cur_udpechoserver_conf;
|
||||
extern struct udpechoserver_result cur_udpechoserver_result;
|
||||
|
||||
#endif /* _UDPECHOSERVER_H__ */
|
||||
55
udpechoserver/udpechoserverlog.c
Normal file
55
udpechoserver/udpechoserverlog.c
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2019 iopsys Software Solutions AB
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
#include <syslog.h>
|
||||
#include <stdarg.h>
|
||||
#include "udpechoserverlog.h"
|
||||
#include "udpechoserver.h"
|
||||
#define DEBUG
|
||||
|
||||
static const int log_syslogmap[] = {
|
||||
[SCRIT] = LOG_CRIT,
|
||||
[SWARNING] = LOG_WARNING,
|
||||
[SNOTICE] = LOG_NOTICE,
|
||||
[SINFO] = LOG_INFO,
|
||||
[SDEBUG] = LOG_DEBUG
|
||||
};
|
||||
|
||||
static const char* log_str[] = {
|
||||
[SCRIT] = "CRITICAL",
|
||||
[SWARNING] = "WARNING",
|
||||
[SNOTICE] = "NOTICE",
|
||||
[SINFO] = "INFO",
|
||||
[SDEBUG] = "DEBUG"
|
||||
};
|
||||
|
||||
void udpechoserver_log(int priority, const char *format, ...)
|
||||
{
|
||||
va_list vl;
|
||||
char *log;
|
||||
|
||||
if (priority <= cur_udpechoserver_conf.loglevel) {
|
||||
#ifdef DEBUG
|
||||
time_t t = time(NULL);
|
||||
struct tm tm = *localtime(&t);
|
||||
va_start(vl, format);
|
||||
printf("%d-%02d-%02d %02d:%02d:%02d [udpechoserver] %s - ", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, log_str[priority]);
|
||||
vprintf(format, vl);
|
||||
va_end(vl);
|
||||
printf("\n");
|
||||
#endif
|
||||
openlog("udpechoserver", 0, LOG_DAEMON);
|
||||
va_start(vl, format);
|
||||
vsyslog(log_syslogmap[priority], format, vl);
|
||||
va_end(vl);
|
||||
closelog();
|
||||
}
|
||||
}
|
||||
27
udpechoserver/udpechoserverlog.h
Normal file
27
udpechoserver/udpechoserverlog.h
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2019 iopsys Software Solutions AB
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
*/
|
||||
|
||||
#ifndef _UDPECHOSERVERLOG_H_
|
||||
#define _UDPECHOSERVERLOG_H_
|
||||
|
||||
#define DEFAULT_LOGLEVEL SINFO
|
||||
|
||||
enum udpechoserver_log_level_enum {
|
||||
SCRIT,
|
||||
SWARNING,
|
||||
SNOTICE,
|
||||
SINFO,
|
||||
SDEBUG,
|
||||
__MAX_SLOG
|
||||
};
|
||||
|
||||
void udpechoserver_log(int priority, const char *format, ...);
|
||||
|
||||
#endif /* _UDPECHOSERVERLOG_H_ */
|
||||
185
udpechoserver/udpechoserveruci.c
Normal file
185
udpechoserver/udpechoserveruci.c
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2019 iopsys Software Solutions AB
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
*/
|
||||
|
||||
#include <uci.h>
|
||||
#include "udpechoserveruci.h"
|
||||
|
||||
static struct uci_context *uci_ctx = NULL;
|
||||
static struct uci_context *uci_ctx_state = NULL;
|
||||
|
||||
int dmuci_init(void)
|
||||
{
|
||||
uci_ctx = uci_alloc_context();
|
||||
if (!uci_ctx) {
|
||||
return -1;
|
||||
}
|
||||
uci_ctx_state = uci_alloc_context();
|
||||
if (!uci_ctx_state) {
|
||||
return -1;
|
||||
}
|
||||
uci_add_delta_path(uci_ctx_state, uci_ctx_state->savedir);
|
||||
uci_set_savedir(uci_ctx_state, VAR_STATE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dmuci_fini(void)
|
||||
{
|
||||
if (uci_ctx) {
|
||||
uci_free_context(uci_ctx);
|
||||
}
|
||||
if (uci_ctx_state) {
|
||||
uci_free_context(uci_ctx_state);
|
||||
}
|
||||
uci_ctx = NULL;
|
||||
uci_ctx_state = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool dmuci_validate_section(const char *str)
|
||||
{
|
||||
if (!*str)
|
||||
return false;
|
||||
|
||||
for (; *str; str++) {
|
||||
unsigned char c = *str;
|
||||
|
||||
if (isalnum(c) || c == '_')
|
||||
continue;
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static int dmuci_init_ptr(struct uci_context *ctx, struct uci_ptr *ptr, char *package, char *section, char *option, char *value)
|
||||
{
|
||||
char *last = NULL;
|
||||
char *tmp;
|
||||
|
||||
memset(ptr, 0, sizeof(struct uci_ptr));
|
||||
|
||||
/* value */
|
||||
if (value) {
|
||||
ptr->value = value;
|
||||
}
|
||||
ptr->package = package;
|
||||
if (!ptr->package)
|
||||
goto error;
|
||||
|
||||
ptr->section = section;
|
||||
if (!ptr->section) {
|
||||
ptr->target = UCI_TYPE_PACKAGE;
|
||||
goto lastval;
|
||||
}
|
||||
|
||||
ptr->option = option;
|
||||
if (!ptr->option) {
|
||||
ptr->target = UCI_TYPE_SECTION;
|
||||
goto lastval;
|
||||
} else {
|
||||
ptr->target = UCI_TYPE_OPTION;
|
||||
}
|
||||
|
||||
lastval:
|
||||
if (ptr->section && !dmuci_validate_section(ptr->section))
|
||||
ptr->flags |= UCI_LOOKUP_EXTENDED;
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
void dmuci_print_list(struct uci_list *uh, char **val, char *delimiter)
|
||||
{
|
||||
struct uci_element *e;
|
||||
static char buffer[512];
|
||||
int dlen = strlen(delimiter);
|
||||
int olen = 0;
|
||||
char *buf = buffer;
|
||||
*buf = '\0';
|
||||
|
||||
uci_foreach_element(uh, e) {
|
||||
if (*buf) {
|
||||
strcat(buf, delimiter);
|
||||
strcat(buf, e->name);
|
||||
}
|
||||
else {
|
||||
strcpy(buf, e->name);
|
||||
}
|
||||
}
|
||||
*val = buf;
|
||||
}
|
||||
|
||||
char *dmuci_get_value(char *package, char *section, char *option)
|
||||
{
|
||||
struct uci_ptr ptr;
|
||||
char *val = "";
|
||||
|
||||
if (!section || !option)
|
||||
return val;
|
||||
|
||||
if (dmuci_init_ptr(uci_ctx, &ptr, package, section, option, NULL)) {
|
||||
return val;
|
||||
}
|
||||
if (uci_lookup_ptr(uci_ctx, &ptr, NULL, true) != UCI_OK) {
|
||||
return val;
|
||||
}
|
||||
|
||||
if (!ptr.o)
|
||||
return val;
|
||||
|
||||
if(ptr.o->type == UCI_TYPE_LIST) {
|
||||
dmuci_print_list(&ptr.o->v.list, &val, " ");
|
||||
return val;
|
||||
}
|
||||
|
||||
if (ptr.o->v.string)
|
||||
return ptr.o->v.string;
|
||||
else
|
||||
return val;
|
||||
}
|
||||
|
||||
char *dmuci_set_value(char *package, char *section, char *option, char *value)
|
||||
{
|
||||
struct uci_ptr ptr;
|
||||
int ret = UCI_OK;
|
||||
|
||||
if (!section)
|
||||
return "";
|
||||
|
||||
if (dmuci_init_ptr(uci_ctx, &ptr, package, section, option, value)) {
|
||||
return "";
|
||||
}
|
||||
if (uci_lookup_ptr(uci_ctx, &ptr, NULL, true) != UCI_OK) {
|
||||
return "";
|
||||
}
|
||||
|
||||
uci_set(uci_ctx, &ptr);
|
||||
|
||||
if (ret == UCI_OK)
|
||||
ret = uci_save(uci_ctx, ptr.p);
|
||||
|
||||
if (ptr.o && ptr.o->v.string)
|
||||
return ptr.o->v.string;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/************************* /var/state ***************************/
|
||||
char *dmuci_set_value_state(char *package, char *section, char *option, char *value)
|
||||
{
|
||||
char *val;
|
||||
struct uci_context *save_uci_ctx = uci_ctx;
|
||||
uci_ctx = uci_ctx_state;
|
||||
val = dmuci_set_value(package, section, option, value);
|
||||
uci_ctx = save_uci_ctx;
|
||||
return val;
|
||||
}
|
||||
23
udpechoserver/udpechoserveruci.h
Normal file
23
udpechoserver/udpechoserveruci.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2019 iopsys Software Solutions AB
|
||||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
*/
|
||||
|
||||
#ifndef _UDPECHOSERVERUCI_H__
|
||||
#define _UDPECHOSERVERUCI_H__
|
||||
|
||||
#define VAR_STATE "/var/state"
|
||||
|
||||
int dmuci_init(void);
|
||||
int dmuci_fini(void);
|
||||
void dmuci_print_list(struct uci_list *uh, char **val, char *delimiter);
|
||||
char *dmuci_get_value(char *package, char *section, char *option);
|
||||
char *dmuci_set_value(char *package, char *section, char *option, char *value);
|
||||
char *dmuci_set_value_state(char *package, char *section, char *option, char *value);
|
||||
|
||||
#endif /* _UDPECHOSERVERUCI_H__ */
|
||||
Loading…
Add table
Reference in a new issue