-
Notifications
You must be signed in to change notification settings - Fork 0
/
0003-vyatta-server.patch
58 lines (54 loc) · 1.64 KB
/
0003-vyatta-server.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
--- a/server/dhcp.c 2020-01-21 20:21:48.000000000 +0100
+++ b/server/dhcp.c 2021-01-25 17:13:13.644020610 +0100
@@ -31,6 +31,12 @@
#include <limits.h>
#include <sys/time.h>
+//vyatta request/response output file
+FILE *fd_pckt_ct = NULL;
+static const char *dhcp_packet_count_file = "/var/log/dhcpd.status";
+long pckt_req_ct = 0;
+long pckt_resp_ct = 0;
+
static void maybe_return_agent_options(struct packet *packet,
struct option_state *options);
@@ -101,6 +107,31 @@ dhcp (struct packet *packet) {
const char *errmsg;
struct data_string data;
+ //vyatta
+ if (packet &&
+ packet->packet_type == DHCPREQUEST) {
+ pckt_req_ct++;
+ }
+
+ if (fd_pckt_ct == NULL) {
+ unlink(dhcp_packet_count_file);
+ int file_pckt_ct = open (dhcp_packet_count_file, O_WRONLY | O_EXCL | O_CREAT, 0664);
+ if (file_pckt_ct < 0) {
+ log_error ("Can't create new lease file: %m");
+ } else {
+ if ((fd_pckt_ct = fdopen (file_pckt_ct, "w")) == NULL) {
+ log_error ("Can't fdopen new lease file!");
+ }
+ }
+ }
+ if (fd_pckt_ct != NULL) {
+ fseek(fd_pckt_ct, 0, SEEK_SET);
+ fprintf(fd_pckt_ct, "request-count: %ld\n", pckt_req_ct);
+ fprintf(fd_pckt_ct, "response-count: %ld\n", pckt_resp_ct);
+ fflush(fd_pckt_ct);
+ }
+ //vyatta
+
if (!locate_network(packet) &&
packet->packet_type != DHCPREQUEST &&
packet->packet_type != DHCPINFORM &&
@@ -442,6 +473,10 @@ void dhcpdiscover (packet, ms_nulltp)
if (when < lease -> ends)
when = lease -> ends;
+//vyatta
+ pckt_resp_ct++;
+//vyatta
+
ack_lease (packet, lease, DHCPOFFER, when, msgbuf, ms_nulltp,
(struct host_decl *)0);
out: