• R/O
  • HTTP
  • SSH
  • HTTPS

dscsd-cap: Commit


Commit MetaInfo

Revision4a48959a0d419ec27d61509b2c244c774c75648c (tree)
Time2018-11-19 13:30:26
AuthorSatoshi Yasuda <7m3tjz;jarl.com>
CommiterSatoshi Yasuda

Log Message

modified: capture_read.c
modified: dscsd_cap.h
modified: handler.c
modified: init.c
modified: main.c
modified: read_config.c

Change Summary

Incremental Difference

--- a/capture_read.c
+++ b/capture_read.c
@@ -49,5 +49,17 @@ void capture_read (void)
4949 sendto (sock, buff, length+8, 0, rp->ai_addr, rp->ai_addrlen);
5050 }
5151 }
52+ if (mon_port)
53+ {
54+ if ((length == 32) || (length == 36))
55+ {
56+ memcpy (&buff, &pkt_data[data_p], length);
57+ if (length == 32) memcpy (&buff[length+4], &pkt_data[26], 4);
58+ else memcpy (&buff[length+4], &pkt_data[30], 4);
59+ memcpy (&buff[length], &pkt_data[34], 2);
60+ sendto (mon_sd, buff, length+8, 0,
61+ mon_info->ai_addr, mon_info->ai_addrlen);
62+ }
63+ }
5264 }
5365
--- a/dscsd_cap.h
+++ b/dscsd_cap.h
@@ -107,3 +107,8 @@ struct trust_table *trust_last;
107107 int sig_term;
108108 int debug_sw;
109109
110+int mon_port;
111+char mon_fqdn[128];
112+struct addrinfo *mon_info;
113+int mon_sd;
114+
--- a/handler.c
+++ b/handler.c
@@ -4,14 +4,9 @@ int get_server_ip(void);
44
55 void handler (int sig)
66 {
7- time_t atime;
8-
7+ syslog (LOG_INFO,"singal %d", sig);
98 if (sig == SIGTERM) sig_term = TRUE;
109 else if (sig == SIGINT) sig_term = TRUE;
11- else if (sig == SIGUSR1)
12- {
13- get_server_ip();
14- }
1510 else if (sig == SIGUSR2)
1611 {
1712 if (debug_sw)
--- a/init.c
+++ b/init.c
@@ -45,5 +45,35 @@ void init(void)
4545 syslog (LOG_INFO, "setsockopt() is OK.");
4646 }
4747 }
48+ if (mon_port)
49+ {
50+ memset (&hints, 0x00, sizeof(hints));
51+ hints.ai_socktype = SOCK_DGRAM;
52+ hints.ai_family = PF_UNSPEC;
53+ sprintf (PORT, "%d", mon_port);
54+ if ((err = getaddrinfo (mon_fqdn, PORT, &hints, &mon_info)) != 0)
55+ {
56+ syslog (LOG_ERR, "getaddrinfo error (TRUST Monitor:%s:%0d) %s",
57+ mon_fqdn, mon_port, gai_strerror(err));
58+ mon_port = 0;
59+ if (mon_info != NULL) freeaddrinfo (mon_info);
60+ }
61+ else
62+ {
63+ if((mon_sd = socket(mon_info->ai_family,
64+ mon_info->ai_socktype, mon_info->ai_protocol)) < 0)
65+ {
66+ syslog (LOG_ERR, "TRUST Monitor UDP socket not open (%s)",
67+ mon_fqdn);
68+ mon_port = 0;
69+ if (mon_info != NULL) freeaddrinfo (mon_info);
70+ }
71+ else
72+ {
73+ syslog (LOG_INFO, "Trust Monitor Port %s:%0d open.",
74+ mon_fqdn, mon_port);
75+ }
76+ }
77+ }
4878 }
4979
--- a/main.c
+++ b/main.c
@@ -31,6 +31,7 @@ main(int argc, const char **argv)
3131
3232 sig_term = 0;
3333 debug_sw = 0;
34+ mon_port = 0;
3435
3536 strcpy (trust_server_fqdn, TRUST_SERVER);
3637
@@ -48,7 +49,7 @@ main(int argc, const char **argv)
4849
4950 handler_init();
5051
51- syslog (LOG_INFO, "\ndscsd Capture & Re-Send Start(Ver:V%s Compiled Date:%s Time:%s)\n",
52+ syslog (LOG_INFO, "dscsd Capture & Re-Send Start(Ver:V%s Compiled Date:%s Time:%s)",
5253 PACKAGE_VERSION, __DATE__, __TIME__);
5354
5455 cap_port = CAP_PORT;
--- a/read_config.c
+++ b/read_config.c
@@ -69,6 +69,30 @@ void read_config(int argc, char **argv)
6969 {
7070 debug_sw = atoi(pnt);
7171 }
72+ else if (!memcmp (p, "TRUST_MONITOR", 13))
73+ {
74+ n = 0;
75+ field_sw = 0;
76+ mon_port = 0;
77+ memset (mon_fqdn, 0x00, 128);
78+ while (*pnt)
79+ {
80+ if (field_sw)
81+ {
82+ if (isdigit(*pnt)) mon_port = mon_port * 10 + *pnt - '0';
83+ }
84+ else
85+ {
86+ if (*pnt == ':') field_sw = 1;
87+ else
88+ {
89+ if (*pnt != 0x20) mon_fqdn[n++] = *pnt;
90+ if (n > 127) n = 127;
91+ }
92+ }
93+ pnt++;
94+ }
95+ }
7296 else
7397 {
7498 syslog (LOG_ERR, "Error on config file : %s", buff);
Show on old repository browser