Package: softflowd / 0.9.9-5

cherry-pick.softflowd-0.9.9-1-g91b2a2c.changes-for-avoidance-warnings-in-gcc-compilation-on-linux-ubuntu-12-04-openbsd-5-1-and-oracle-solaris-11-with-amd64-architecture-when-enables-enable-gcc-warnings-option-in-configure.patch Patch series | download
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
Subject: Changes for avoidance warnings in gcc compilation on Linux (Ubuntu 12.04), OpenBSD 5.1 and Oracle solaris 11 with AMD64 architecture when enables "--enable-gcc-warnings" option in configure
Origin: softflowd-0.9.9-1-g91b2a2c <https://github.com/irino/softflowd/commit/softflowd-0.9.9-1-g91b2a2c>
Upstream-Author: Hitoshi Irino <hitoshi.irino@gmail.com>
Date: Fri Sep 21 14:46:18 2012 +0900

--- a/common.h
+++ b/common.h
@@ -57,6 +57,7 @@
 #include <signal.h>
 #include <stdio.h>
 #include <string.h>
+#include <strings.h>
 #include <syslog.h>
 #include <time.h>
 
@@ -166,4 +167,13 @@
 } __packed;
 #endif
 
+
+/* following lines are copy from unistd.h in Linux for avoidance warnings in compilation */
+#if defined(HAVE_SETRESGID) && !defined(_GNU_SOURCE)
+extern int setresgid (__uid_t __ruid, __uid_t __euid, __uid_t __suid);
+#endif
+#if defined(HAVE_SETRESUID) && !defined(_GNU_SOURCE)
+extern int setresuid (__uid_t __ruid, __uid_t __euid, __uid_t __suid);
+#endif
+
 #endif /* _SFD_COMMON_H */
--- a/netflow5.c
+++ b/netflow5.c
@@ -99,7 +99,7 @@
 			hdr->flow_sequence = htonl(*flows_exported);
 			if (option->sample > 0) {
 				hdr->sampling_interval =
-					htons(0x01 << 14 | option->sample & 0x3FFF);
+					htons((0x01 << 14) | (option->sample & 0x3FFF));
 			}
 			/* Other fields are left zero */
 			offset = sizeof(*hdr);
--- a/softflowctl.c
+++ b/softflowctl.c
@@ -36,7 +36,9 @@
 	const char *ctlsock_path;
 	char buf[8192], *command;
 	struct sockaddr_un ctl;
+#ifdef SOCK_HAS_LEN 
 	socklen_t ctllen;
+#endif
 	int ctlsock, ch;
 	FILE *ctlf;
 	extern char *optarg;
@@ -73,9 +75,9 @@
 	}
 	ctl.sun_path[sizeof(ctl.sun_path) - 1] = '\0';
 	ctl.sun_family = AF_UNIX;
+#ifdef SOCK_HAS_LEN 
 	ctllen = offsetof(struct sockaddr_un, sun_path) +
             strlen(ctlsock_path) + 1;
-#ifdef SOCK_HAS_LEN 
 	ctl.sun_len = ctllen;
 #endif
 	if ((ctlsock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
--- a/softflowd.c
+++ b/softflowd.c
@@ -255,15 +255,15 @@
 static const char *
 format_flow(struct FLOW *flow)
 {
-	char addr1[64], addr2[64], stime[32], ftime[32];
+	char addr1[64], addr2[64], start_time[32], fin_time[32];
 	static char buf[1024];
 
 	inet_ntop(flow->af, &flow->addr[0], addr1, sizeof(addr1));
 	inet_ntop(flow->af, &flow->addr[1], addr2, sizeof(addr2));
 
-	snprintf(stime, sizeof(ftime), "%s", 
+	snprintf(start_time, sizeof(start_time), "%s", 
 	    format_time(flow->flow_start.tv_sec));
-	snprintf(ftime, sizeof(ftime), "%s", 
+	snprintf(fin_time, sizeof(fin_time), "%s", 
 	    format_time(flow->flow_last.tv_sec));
 
 	snprintf(buf, sizeof(buf),  "seq:%"PRIu64" [%s]:%hu <> [%s]:%hu proto:%u "
@@ -275,8 +275,8 @@
 	    (int)flow->protocol, 
 	    flow->octets[0], flow->packets[0], 
 	    flow->octets[1], flow->packets[1], 
-	    stime, (flow->flow_start.tv_usec + 500) / 1000, 
-	    ftime, (flow->flow_last.tv_usec + 500) / 1000,
+	    start_time, (flow->flow_start.tv_usec + 500) / 1000, 
+	    fin_time, (flow->flow_last.tv_usec + 500) / 1000,
 	    flow->tcp_flags[0], flow->tcp_flags[1],
 	    flow->ip6_flowlabel[0], flow->ip6_flowlabel[1]);
 
@@ -1163,7 +1163,7 @@
 accept_control(int lsock, struct NETFLOW_TARGET *target, struct FLOWTRACK *ft,
     pcap_t *pcap, int *exit_request, int *stop_collection_flag)
 {
-	unsigned char buf[64], *p;
+	char buf[64], *p;
 	FILE *ctlf;
 	int fd, ret;
 
@@ -1202,61 +1202,61 @@
 		ret = 0;
 	} else if (strcmp(buf, "shutdown") == 0) {
 		fprintf(ctlf, "softflowd[%u]: Shutting down gracefully...\n", 
-		    getpid());
+		    (unsigned int)getpid());
 		graceful_shutdown_request = 1;
 		ret = 1;
 	} else if (strcmp(buf, "exit") == 0) {
-		fprintf(ctlf, "softflowd[%u]: Exiting now...\n", getpid());
+		fprintf(ctlf, "softflowd[%u]: Exiting now...\n", (unsigned int)getpid());
 		*exit_request = 1;
 		ret = 1;
 	} else if (strcmp(buf, "expire-all") == 0) {
 		netflow9_resend_template();
-		fprintf(ctlf, "softflowd[%u]: Expired %d flows.\n", getpid(), 
+		fprintf(ctlf, "softflowd[%u]: Expired %d flows.\n", (unsigned int)getpid(), 
 		    check_expired(ft, target, CE_EXPIRE_ALL));
 		ret = 0;
 	} else if (strcmp(buf, "send-template") == 0) {
 		netflow9_resend_template();
 		fprintf(ctlf, "softflowd[%u]: Template will be sent at "
-		    "next flow export\n", getpid());
+		    "next flow export\n", (unsigned int)getpid());
 		ret = 0;
 	} else if (strcmp(buf, "delete-all") == 0) {
-		fprintf(ctlf, "softflowd[%u]: Deleted %d flows.\n", getpid(), 
+		fprintf(ctlf, "softflowd[%u]: Deleted %d flows.\n", (unsigned int)getpid(), 
 		    delete_all_flows(ft));
 		ret = 0;
 	} else if (strcmp(buf, "statistics") == 0) {
 		fprintf(ctlf, "softflowd[%u]: Accumulated statistics "
-		    "since %s UTC:\n", getpid(),
+		    "since %s UTC:\n", (unsigned int)getpid(),
 		    format_time(ft->system_boot_time.tv_sec));
 		statistics(ft, ctlf, pcap);
 		ret = 0;
 	} else if (strcmp(buf, "debug+") == 0) {
 		fprintf(ctlf, "softflowd[%u]: Debug level increased.\n",
-		    getpid());
+		    (unsigned int)getpid());
 		verbose_flag = 1;
 		ret = 0;
 	} else if (strcmp(buf, "debug-") == 0) {
 		fprintf(ctlf, "softflowd[%u]: Debug level decreased.\n",
-		    getpid());
+		    (unsigned int)getpid());
 		verbose_flag = 0;
 		ret = 0;
 	} else if (strcmp(buf, "stop-gather") == 0) {
 		fprintf(ctlf, "softflowd[%u]: Data collection stopped.\n",
-		    getpid());
+		    (unsigned int)getpid());
 		*stop_collection_flag = 1;
 		ret = 0;
 	} else if (strcmp(buf, "start-gather") == 0) {
 		fprintf(ctlf, "softflowd[%u]: Data collection resumed.\n",
-		    getpid());
+		    (unsigned int)getpid());
 		*stop_collection_flag = 0;
 		ret = 0;
 	} else if (strcmp(buf, "dump-flows") == 0) {
 		fprintf(ctlf, "softflowd[%u]: Dumping flow data:\n",
-		    getpid());
+		    (unsigned int)getpid());
 		dump_flows(ft, ctlf);
 		ret = 0;
 	} else if (strcmp(buf, "timeouts") == 0) {
 		fprintf(ctlf, "softflowd[%u]: Printing timeouts:\n",
-		    getpid());
+		    (unsigned int)getpid());
 		print_timeouts(ft, ctlf);
 		ret = 0;
 	} else {
@@ -1868,7 +1868,7 @@
 			    pidfile_path, strerror(errno));
 			exit(1);
 		}
-		fprintf(pidfile, "%u\n", getpid());
+		fprintf(pidfile, "%u\n", (unsigned int)getpid());
 		fclose(pidfile);
 
 		signal(SIGINT, sighand_graceful_shutdown);