* [B.A.T.M.A.N.] [PATCH 01/11] batctl: Fix possible buffer overflow when using strncat
2013-09-10 21:11 [B.A.T.M.A.N.] batctl: Debian patches for 2013.3.0-2 Sven Eckelmann
@ 2013-09-10 21:11 ` Sven Eckelmann
2013-09-11 10:49 ` Marek Lindner
2013-09-10 21:11 ` [B.A.T.M.A.N.] [PATCH 02/11] batctl: Fix inconsistent use of _GNU_SOURCE Sven Eckelmann
` (9 subsequent siblings)
10 siblings, 1 reply; 22+ messages in thread
From: Sven Eckelmann @ 2013-09-10 21:11 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Sven Eckelmann
The length field (n) of strncat is used to specify the length of the buffer
without the \0 delimiter. strncat will add it even when it will write it to the
limit of n bytes was written.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
bat-hosts.c | 2 +-
functions.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/bat-hosts.c b/bat-hosts.c
index 04e7a9b..f0adb9c 100644
--- a/bat-hosts.c
+++ b/bat-hosts.c
@@ -194,7 +194,7 @@ void bat_hosts_init(int read_opt)
strncpy(confdir, homedir, CONF_DIR_LEN);
confdir[CONF_DIR_LEN - 1] = '\0';
- strncat(confdir, &bat_hosts_path[i][1], CONF_DIR_LEN - strlen(confdir));
+ strncat(confdir, &bat_hosts_path[i][1], CONF_DIR_LEN - strlen(confdir) - 1);
} else {
strncpy(confdir, bat_hosts_path[i], CONF_DIR_LEN);
confdir[CONF_DIR_LEN - 1] = '\0';
diff --git a/functions.c b/functions.c
index cc05a48..0359287 100644
--- a/functions.c
+++ b/functions.c
@@ -180,7 +180,7 @@ int read_file(char *dir, char *fname, int read_opt,
strncpy(full_path, dir, strlen(dir));
full_path[strlen(dir)] = '\0';
- strncat(full_path, fname, sizeof(full_path) - strlen(full_path));
+ strncat(full_path, fname, sizeof(full_path) - strlen(full_path) - 1);
open:
line = 0;
@@ -305,7 +305,7 @@ int write_file(char *dir, char *fname, char *arg1, char *arg2)
strncpy(full_path, dir, strlen(dir));
full_path[strlen(dir)] = '\0';
- strncat(full_path, fname, sizeof(full_path) - strlen(full_path));
+ strncat(full_path, fname, sizeof(full_path) - strlen(full_path) - 1);
fd = open(full_path, O_WRONLY);
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 22+ messages in thread* [B.A.T.M.A.N.] [PATCH 02/11] batctl: Fix inconsistent use of _GNU_SOURCE
2013-09-10 21:11 [B.A.T.M.A.N.] batctl: Debian patches for 2013.3.0-2 Sven Eckelmann
2013-09-10 21:11 ` [B.A.T.M.A.N.] [PATCH 01/11] batctl: Fix possible buffer overflow when using strncat Sven Eckelmann
@ 2013-09-10 21:11 ` Sven Eckelmann
2013-09-11 10:53 ` Marek Lindner
2013-09-10 21:11 ` [B.A.T.M.A.N.] [PATCH 03/11] batctl: Avoid assigning const buffer to non-const pointer Sven Eckelmann
` (8 subsequent siblings)
10 siblings, 1 reply; 22+ messages in thread
From: Sven Eckelmann @ 2013-09-10 21:11 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Sven Eckelmann
Either all or no source file should define _GNU_SOURCE to avoid incompatible
types or function declarations.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
Makefile | 1 +
bat-hosts.c | 1 -
functions.c | 1 -
3 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 1961298..7926db3 100755
--- a/Makefile
+++ b/Makefile
@@ -30,6 +30,7 @@ MANPAGE = man/batctl.8
# batctl flags and options
CFLAGS += -Wall -W -std=gnu99 -fno-strict-aliasing -MD
+CPPFLAGS += -D_GNU_SOURCE
LDLIBS += -lm
# disable verbose output
diff --git a/bat-hosts.c b/bat-hosts.c
index f0adb9c..ee862da 100644
--- a/bat-hosts.c
+++ b/bat-hosts.c
@@ -21,7 +21,6 @@
-#define _GNU_SOURCE
#include <stdio.h>
#include <stdint.h>
#include <limits.h>
diff --git a/functions.c b/functions.c
index 0359287..2a2f392 100644
--- a/functions.c
+++ b/functions.c
@@ -20,7 +20,6 @@
*/
-#define _GNU_SOURCE
#include <netinet/ether.h>
#include <arpa/inet.h>
#include <sys/socket.h>
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 22+ messages in thread* [B.A.T.M.A.N.] [PATCH 03/11] batctl: Avoid assigning const buffer to non-const pointer
2013-09-10 21:11 [B.A.T.M.A.N.] batctl: Debian patches for 2013.3.0-2 Sven Eckelmann
2013-09-10 21:11 ` [B.A.T.M.A.N.] [PATCH 01/11] batctl: Fix possible buffer overflow when using strncat Sven Eckelmann
2013-09-10 21:11 ` [B.A.T.M.A.N.] [PATCH 02/11] batctl: Fix inconsistent use of _GNU_SOURCE Sven Eckelmann
@ 2013-09-10 21:11 ` Sven Eckelmann
2013-09-11 10:56 ` Marek Lindner
2013-09-10 21:11 ` [B.A.T.M.A.N.] [PATCH 04/11] batctl: Mark all local functions as static Sven Eckelmann
` (7 subsequent siblings)
10 siblings, 1 reply; 22+ messages in thread
From: Sven Eckelmann @ 2013-09-10 21:11 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Sven Eckelmann
Strings in C are tried to be saved in the .rodata by the compiler/linker. This
section is readonly as the name suggests. Pointer to these strings should
therefore be const.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
functions.c | 8 +++++---
functions.h | 5 +++--
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/functions.c b/functions.c
index 2a2f392..bd4da59 100644
--- a/functions.c
+++ b/functions.c
@@ -124,7 +124,8 @@ int file_exists(const char *fpath)
return stat(fpath, &st) == 0;
}
-static void file_open_problem_dbg(char *dir, char *fname, char *full_path)
+static void file_open_problem_dbg(const char *dir, const char *fname,
+ const char *full_path)
{
const char **ptr;
struct stat st;
@@ -162,7 +163,7 @@ static void file_open_problem_dbg(char *dir, char *fname, char *full_path)
}
}
-int read_file(char *dir, char *fname, int read_opt,
+int read_file(const char *dir, const char *fname, int read_opt,
float orig_timeout, float watch_interval, size_t header_lines)
{
struct ether_addr *mac_addr;
@@ -296,7 +297,8 @@ out:
return res;
}
-int write_file(char *dir, char *fname, char *arg1, char *arg2)
+int write_file(const char *dir, const char *fname, const char *arg1,
+ const char *arg2)
{
int fd = 0, res = EXIT_FAILURE;
char full_path[500];
diff --git a/functions.h b/functions.h
index d88c494..f9c8191 100644
--- a/functions.h
+++ b/functions.h
@@ -34,9 +34,10 @@ char *ether_ntoa_long(const struct ether_addr *addr);
char *get_name_by_macaddr(struct ether_addr *mac_addr, int read_opt);
char *get_name_by_macstr(char *mac_str, int read_opt);
int file_exists(const char *fpath);
-int read_file(char *dir, char *path, int read_opt,
+int read_file(const char *dir, const char *path, int read_opt,
float orig_timeout, float watch_interval, size_t header_lines);
-int write_file(char *dir, char *fname, char *arg1, char *arg2);
+int write_file(const char *dir, const char *fname, const char *arg1,
+ const char *arg2);
struct ether_addr *translate_mac(char *mesh_iface, struct ether_addr *mac);
struct ether_addr *resolve_mac(const char *asc);
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 22+ messages in thread* [B.A.T.M.A.N.] [PATCH 04/11] batctl: Mark all local functions as static
2013-09-10 21:11 [B.A.T.M.A.N.] batctl: Debian patches for 2013.3.0-2 Sven Eckelmann
` (2 preceding siblings ...)
2013-09-10 21:11 ` [B.A.T.M.A.N.] [PATCH 03/11] batctl: Avoid assigning const buffer to non-const pointer Sven Eckelmann
@ 2013-09-10 21:11 ` Sven Eckelmann
2013-09-11 10:58 ` Marek Lindner
2013-09-10 21:11 ` [B.A.T.M.A.N.] [PATCH 05/11] batctl: Add include guards to avoid redundant declarations or include loops Sven Eckelmann
` (6 subsequent siblings)
10 siblings, 1 reply; 22+ messages in thread
From: Sven Eckelmann @ 2013-09-10 21:11 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Sven Eckelmann
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
debug.c | 2 +-
main.c | 2 +-
ping.c | 4 ++--
traceroute.c | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/debug.c b/debug.c
index 3ea112a..2589dbc 100644
--- a/debug.c
+++ b/debug.c
@@ -84,7 +84,7 @@ const struct debug_table_data batctl_debug_tables[BATCTL_TABLE_NUM] = {
},
};
-void debug_table_usage(int debug_table)
+static void debug_table_usage(int debug_table)
{
fprintf(stderr, "Usage: batctl [options] %s|%s [parameters]\n",
batctl_debug_tables[debug_table].opt_long, batctl_debug_tables[debug_table].opt_short);
diff --git a/main.c b/main.c
index 24d42fb..6b44359 100644
--- a/main.c
+++ b/main.c
@@ -43,7 +43,7 @@
char mesh_dfl_iface[] = "bat0";
char module_ver_path[] = "/sys/module/batman_adv/version";
-void print_usage(void)
+static void print_usage(void)
{
int i, opt_indent;
diff --git a/ping.c b/ping.c
index 6679604..4d76484 100644
--- a/ping.c
+++ b/ping.c
@@ -42,7 +42,7 @@
char is_aborted = 0;
-void ping_usage(void)
+static void ping_usage(void)
{
fprintf(stderr, "Usage: batctl [options] ping [parameters] mac|bat-host|host_name|IPv4_address \n");
fprintf(stderr, "parameters:\n");
@@ -54,7 +54,7 @@ void ping_usage(void)
fprintf(stderr, " \t -T don't try to translate mac to originator address\n");
}
-void sig_handler(int sig)
+static void sig_handler(int sig)
{
switch (sig) {
case SIGINT:
diff --git a/traceroute.c b/traceroute.c
index 362d293..d62df5e 100644
--- a/traceroute.c
+++ b/traceroute.c
@@ -41,7 +41,7 @@
#define NUM_PACKETS 3
-void traceroute_usage(void)
+static void traceroute_usage(void)
{
fprintf(stderr, "Usage: batctl [options] traceroute [parameters] mac|bat-host|host_name|IPv4_address \n");
fprintf(stderr, "parameters:\n");
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 22+ messages in thread* [B.A.T.M.A.N.] [PATCH 05/11] batctl: Add include guards to avoid redundant declarations or include loops
2013-09-10 21:11 [B.A.T.M.A.N.] batctl: Debian patches for 2013.3.0-2 Sven Eckelmann
` (3 preceding siblings ...)
2013-09-10 21:11 ` [B.A.T.M.A.N.] [PATCH 04/11] batctl: Mark all local functions as static Sven Eckelmann
@ 2013-09-10 21:11 ` Sven Eckelmann
2013-09-11 11:33 ` Marek Lindner
2013-09-10 21:11 ` [B.A.T.M.A.N.] [PATCH 06/11] batctl: Remove legacy types u64 and caddr_t Sven Eckelmann
` (5 subsequent siblings)
10 siblings, 1 reply; 22+ messages in thread
From: Sven Eckelmann @ 2013-09-10 21:11 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Sven Eckelmann
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
allocate.h | 4 ++--
bat-hosts.h | 4 ++--
bisect_iv.h | 5 +++++
debug.h | 4 ++++
functions.h | 5 ++++-
ioctl.h | 4 ++++
main.h | 5 +++++
ping.h | 5 ++++-
sys.h | 4 ++++
tcpdump.h | 4 ++++
traceroute.h | 5 ++++-
translate.h | 5 ++++-
12 files changed, 46 insertions(+), 8 deletions(-)
diff --git a/allocate.h b/allocate.h
index 72a41f7..0f335e2 100644
--- a/allocate.h
+++ b/allocate.h
@@ -20,8 +20,8 @@
*/
-#ifndef _ALLOCATE_H
-#define _ALLOCATE_H 1
+#ifndef _BATCTL_ALLOCATE_H
+#define _BATCTL_ALLOCATE_H
/* debug allocate wrapper to keep hash.c happy */
diff --git a/bat-hosts.h b/bat-hosts.h
index 0439a46..74a4ce5 100644
--- a/bat-hosts.h
+++ b/bat-hosts.h
@@ -21,8 +21,8 @@
-#ifndef _BAT_HOSTS_H
-#define _BAT_HOSTS_H 1
+#ifndef _BATCTL_BAT_HOSTS_H
+#define _BATCTL_BAT_HOSTS_H
#include <netinet/ether.h>
diff --git a/bisect_iv.h b/bisect_iv.h
index b2e14f6..c4e6df2 100644
--- a/bisect_iv.h
+++ b/bisect_iv.h
@@ -19,6 +19,9 @@
*
*/
+#ifndef _BATCTL_BISECT_IV_H
+#define _BATCTL_BISECT_IV_H
+
#include "list-batman.h"
#define NAME_LEN 18
@@ -95,3 +98,5 @@ struct seqno_trace {
char print;
struct seqno_trace_neigh seqno_trace_neigh;
};
+
+#endif
diff --git a/debug.h b/debug.h
index 532c2fe..8d9de08 100644
--- a/debug.h
+++ b/debug.h
@@ -19,6 +19,8 @@
*
*/
+#ifndef _BATCTL_DEBUG_H
+#define _BATCTL_DEBUG_H
#define DEBUG_BATIF_PATH_FMT "%s/batman_adv/%s"
#define DEBUG_TRANSTABLE_GLOBAL "transtable_global"
@@ -48,3 +50,5 @@ extern const struct debug_table_data batctl_debug_tables[BATCTL_TABLE_NUM];
int handle_debug_table(char *mesh_iface, int debug_table, int argc, char **argv);
int log_print(char *mesh_iface, int argc, char **argv);
int print_vis_info(char *mesh_iface);
+
+#endif
diff --git a/functions.h b/functions.h
index f9c8191..6720a1b 100644
--- a/functions.h
+++ b/functions.h
@@ -19,7 +19,8 @@
*
*/
-
+#ifndef _BATCTL_FUNCTIONS_H
+#define _BATCTL_FUNCTIONS_H
#include <netinet/if_ether.h>
@@ -55,3 +56,5 @@ enum {
COMPAT_FILTER = 0x80,
SKIP_HEADER = 0x100,
};
+
+#endif
diff --git a/ioctl.h b/ioctl.h
index 3bc20d7..5d62f72 100644
--- a/ioctl.h
+++ b/ioctl.h
@@ -19,5 +19,9 @@
*
*/
+#ifndef _BATCTL_IOCTL_H
+#define _BATCTL_IOCTL_H
int ioctl_statistics_get(char *mesh_iface);
+
+#endif
diff --git a/main.h b/main.h
index ad13c2a..350f88b 100644
--- a/main.h
+++ b/main.h
@@ -19,6 +19,9 @@
*
*/
+#ifndef _BATCTL_MAIN_H
+#define _BATCTL_MAIN_H
+
#ifndef SOURCE_VERSION
#define SOURCE_VERSION "2013.3.0"
#endif
@@ -45,3 +48,5 @@
#define BIT(nr) (1UL << (nr)) /* linux kernel compat */
extern char module_ver_path[];
+
+#endif
diff --git a/ping.h b/ping.h
index abe7da4..7c91d5d 100644
--- a/ping.h
+++ b/ping.h
@@ -19,6 +19,9 @@
*
*/
-
+#ifndef _BATCTL_PING_H
+#define _BATCTL_PING_H
int ping(char *mesh_iface, int argc, char **argv);
+
+#endif
diff --git a/sys.h b/sys.h
index a588e0b..dfc167a 100644
--- a/sys.h
+++ b/sys.h
@@ -19,6 +19,8 @@
*
*/
+#ifndef _BATCTL_SYS_H
+#define _BATCTL_SYS_H
#define SYS_BATIF_PATH_FMT "/sys/class/net/%s/mesh/"
#define SYS_LOG_LEVEL "log_level"
@@ -64,3 +66,5 @@ int interface(char *mesh_iface, int argc, char **argv);
int handle_loglevel(char *mesh_iface, int argc, char **argv);
int handle_sys_setting(char *mesh_iface, int setting, int argc, char **argv);
int handle_gw_setting(char *mesh_iface, int argc, char **argv);
+
+#endif
diff --git a/tcpdump.h b/tcpdump.h
index 3c6657d..2845576 100644
--- a/tcpdump.h
+++ b/tcpdump.h
@@ -19,6 +19,8 @@
*
*/
+#ifndef _BATCTL_TCPDUMP_H
+#define _BATCTL_TCPDUMP_H
#include <netpacket/packet.h>
#include <net/ethernet.h>
@@ -105,3 +107,5 @@ struct prism_header {
#define RADIOTAP_HEADER_LEN sizeof(struct radiotap_header)
int tcpdump(int argc, char **argv);
+
+#endif
diff --git a/traceroute.h b/traceroute.h
index 8aae468..5ec1308 100644
--- a/traceroute.h
+++ b/traceroute.h
@@ -19,6 +19,9 @@
*
*/
-
+#ifndef _BATCTL_TRACEROUTE_H
+#define _BATCTL_TRACEROUTE_H
int traceroute(char *mesh_iface, int argc, char **argv);
+
+#endif
diff --git a/translate.h b/translate.h
index 1220a20..320ad0e 100644
--- a/translate.h
+++ b/translate.h
@@ -19,6 +19,9 @@
*
*/
-
+#ifndef _BATCTL_TRANSLATE_H
+#define _BATCTL_TRANSLATE_H
int translate(char *mesh_iface, int argc, char **argv);
+
+#endif
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 22+ messages in thread* [B.A.T.M.A.N.] [PATCH 06/11] batctl: Remove legacy types u64 and caddr_t
2013-09-10 21:11 [B.A.T.M.A.N.] batctl: Debian patches for 2013.3.0-2 Sven Eckelmann
` (4 preceding siblings ...)
2013-09-10 21:11 ` [B.A.T.M.A.N.] [PATCH 05/11] batctl: Add include guards to avoid redundant declarations or include loops Sven Eckelmann
@ 2013-09-10 21:11 ` Sven Eckelmann
2013-09-13 10:51 ` Marek Lindner
2013-09-10 21:11 ` [B.A.T.M.A.N.] [PATCH 07/11] batctl: Add missing includes and remove unused includes Sven Eckelmann
` (4 subsequent siblings)
10 siblings, 1 reply; 22+ messages in thread
From: Sven Eckelmann @ 2013-09-10 21:11 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Sven Eckelmann
The definition of u64 was not obtained from the correct source to always use 64
bit. Instead uint64_t can be used.
Also caddr_t is obsolete BSDism and void* should be used instead.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
ioctl.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/ioctl.c b/ioctl.c
index 26bb482..3d5b50d 100644
--- a/ioctl.c
+++ b/ioctl.c
@@ -30,13 +30,12 @@
#include <linux/if.h>
#include <linux/sockios.h>
#include <linux/ethtool.h>
+#include <stdint.h>
#include "main.h"
#include "ioctl.h"
#include "debugfs.h"
-typedef unsigned long long u64;
-
/* code borrowed from ethtool */
static int statistics_custom_get(int fd, struct ifreq *ifr)
{
@@ -47,7 +46,7 @@ static int statistics_custom_get(int fd, struct ifreq *ifr)
int err, ret = EXIT_FAILURE;
drvinfo.cmd = ETHTOOL_GDRVINFO;
- ifr->ifr_data = (caddr_t)&drvinfo;
+ ifr->ifr_data = (void *)&drvinfo;
err = ioctl(fd, SIOCETHTOOL, ifr);
if (err < 0) {
fprintf(stderr, "Error - can't open driver information: %s\n", strerror(errno));
@@ -59,7 +58,7 @@ static int statistics_custom_get(int fd, struct ifreq *ifr)
goto success;
sz_str = n_stats * ETH_GSTRING_LEN;
- sz_stats = n_stats * sizeof(u64);
+ sz_stats = n_stats * sizeof(uint64_t);
strings = calloc(1, sz_str + sizeof(struct ethtool_gstrings));
stats = calloc(1, sz_stats + sizeof(struct ethtool_stats));
@@ -71,7 +70,7 @@ static int statistics_custom_get(int fd, struct ifreq *ifr)
strings->cmd = ETHTOOL_GSTRINGS;
strings->string_set = ETH_SS_STATS;
strings->len = n_stats;
- ifr->ifr_data = (caddr_t)strings;
+ ifr->ifr_data = (void *)strings;
err = ioctl(fd, SIOCETHTOOL, ifr);
if (err < 0) {
fprintf(stderr, "Error - can't get stats strings information: %s\n", strerror(errno));
@@ -80,7 +79,7 @@ static int statistics_custom_get(int fd, struct ifreq *ifr)
stats->cmd = ETHTOOL_GSTATS;
stats->n_stats = n_stats;
- ifr->ifr_data = (caddr_t) stats;
+ ifr->ifr_data = (void *) stats;
err = ioctl(fd, SIOCETHTOOL, ifr);
if (err < 0) {
fprintf(stderr, "Error - can't get stats information: %s\n", strerror(errno));
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 22+ messages in thread* [B.A.T.M.A.N.] [PATCH 07/11] batctl: Add missing includes and remove unused includes
2013-09-10 21:11 [B.A.T.M.A.N.] batctl: Debian patches for 2013.3.0-2 Sven Eckelmann
` (5 preceding siblings ...)
2013-09-10 21:11 ` [B.A.T.M.A.N.] [PATCH 06/11] batctl: Remove legacy types u64 and caddr_t Sven Eckelmann
@ 2013-09-10 21:11 ` Sven Eckelmann
2013-09-10 21:11 ` [B.A.T.M.A.N.] [PATCH 08/11] batctl: Fix error handling jump in interface when batadv not loaded Sven Eckelmann
` (3 subsequent siblings)
10 siblings, 0 replies; 22+ messages in thread
From: Sven Eckelmann @ 2013-09-10 21:11 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Sven Eckelmann
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
bat-hosts.c | 5 +++--
bat-hosts.h | 2 +-
bisect_iv.c | 7 ++++---
debug.c | 5 -----
debug.h | 3 +++
debugfs.c | 10 ++++------
debugfs.h | 3 ---
functions.c | 2 ++
functions.h | 3 ++-
ioctl.c | 3 +--
list-batman.h | 3 ---
main.c | 3 ---
ping.c | 5 +++++
sys.c | 1 -
sys.h | 2 ++
tcpdump.c | 6 +++++-
tcpdump.h | 5 ++++-
traceroute.c | 4 ++++
translate.c | 1 -
19 files changed, 40 insertions(+), 33 deletions(-)
diff --git a/bat-hosts.c b/bat-hosts.c
index ee862da..9d36531 100644
--- a/bat-hosts.c
+++ b/bat-hosts.c
@@ -21,14 +21,15 @@
-#include <stdio.h>
#include <stdint.h>
+#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
+#include <stddef.h>
+#include <netinet/ether.h>
-#include "main.h"
#include "bat-hosts.h"
#include "hash.h"
#include "functions.h"
diff --git a/bat-hosts.h b/bat-hosts.h
index 74a4ce5..96abfa9 100644
--- a/bat-hosts.h
+++ b/bat-hosts.h
@@ -24,7 +24,7 @@
#ifndef _BATCTL_BAT_HOSTS_H
#define _BATCTL_BAT_HOSTS_H
-#include <netinet/ether.h>
+#include <net/ethernet.h>
#define HOST_NAME_MAX_LEN 50
#define CONF_DIR_LEN 256
diff --git a/bisect_iv.c b/bisect_iv.c
index 0dbc2ef..eadf427 100644
--- a/bisect_iv.c
+++ b/bisect_iv.c
@@ -19,14 +19,15 @@
*
*/
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
-#include <stdint.h>
-#include <unistd.h>
#include <string.h>
#include <errno.h>
+#include <unistd.h>
+#include <stddef.h>
+#include <netinet/ether.h>
-#include "main.h"
#include "bisect_iv.h"
#include "bat-hosts.h"
#include "hash.h"
diff --git a/debug.c b/debug.c
index 2589dbc..6b7b648 100644
--- a/debug.c
+++ b/debug.c
@@ -23,12 +23,7 @@
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include "main.h"
#include "debug.h"
#include "debugfs.h"
#include "functions.h"
diff --git a/debug.h b/debug.h
index 8d9de08..563a7bb 100644
--- a/debug.h
+++ b/debug.h
@@ -22,6 +22,9 @@
#ifndef _BATCTL_DEBUG_H
#define _BATCTL_DEBUG_H
+#include <stddef.h>
+#include "main.h"
+
#define DEBUG_BATIF_PATH_FMT "%s/batman_adv/%s"
#define DEBUG_TRANSTABLE_GLOBAL "transtable_global"
#define DEBUG_LOG "log"
diff --git a/debugfs.c b/debugfs.c
index bfedcfe..8033f8b 100644
--- a/debugfs.c
+++ b/debugfs.c
@@ -19,14 +19,12 @@
*/
#include "debugfs.h"
-#include <stdio.h>
-#include <stdlib.h>
#include <errno.h>
-#include <sys/vfs.h>
-#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/mount.h>
#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
+#include <sys/statfs.h>
#ifndef DEBUGFS_MAGIC
#define DEBUGFS_MAGIC 0x64626720
diff --git a/debugfs.h b/debugfs.h
index 3981b8b..e608902 100644
--- a/debugfs.h
+++ b/debugfs.h
@@ -21,9 +21,6 @@
#ifndef __DEBUGFS_H__
#define __DEBUGFS_H__
-#include <sys/mount.h>
-#include <string.h>
-
#ifndef MAX_PATH
# define MAX_PATH 256
#endif
diff --git a/functions.c b/functions.c
index bd4da59..1a33d6d 100644
--- a/functions.c
+++ b/functions.c
@@ -33,6 +33,8 @@
#include <errno.h>
#include <fcntl.h>
#include <sys/time.h>
+#include <netinet/in.h>
+#include <stdint.h>
#include "main.h"
#include "functions.h"
diff --git a/functions.h b/functions.h
index 6720a1b..a96b7ee 100644
--- a/functions.h
+++ b/functions.h
@@ -22,7 +22,8 @@
#ifndef _BATCTL_FUNCTIONS_H
#define _BATCTL_FUNCTIONS_H
-#include <netinet/if_ether.h>
+#include <net/ethernet.h>
+#include <stddef.h>
#define ETH_STR_LEN 17
diff --git a/ioctl.c b/ioctl.c
index 3d5b50d..cbb1aa5 100644
--- a/ioctl.c
+++ b/ioctl.c
@@ -26,15 +26,14 @@
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
+#include <sys/types.h>
#include <sys/socket.h>
#include <linux/if.h>
#include <linux/sockios.h>
#include <linux/ethtool.h>
#include <stdint.h>
-#include "main.h"
#include "ioctl.h"
-#include "debugfs.h"
/* code borrowed from ethtool */
static int statistics_custom_get(int fd, struct ifreq *ifr)
diff --git a/list-batman.h b/list-batman.h
index 7de5943..aea0f95 100644
--- a/list-batman.h
+++ b/list-batman.h
@@ -19,9 +19,6 @@
*
*/
-
-#include <stddef.h> /* offsetof() */
-
#ifndef _LINUX_LIST_H
#define _LINUX_LIST_H
diff --git a/main.c b/main.c
index 6b44359..84bb42a 100644
--- a/main.c
+++ b/main.c
@@ -21,9 +21,7 @@
-#include <sys/types.h>
#include <stdio.h>
-#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
@@ -38,7 +36,6 @@
#include "bisect_iv.h"
#include "ioctl.h"
#include "functions.h"
-#include <err.h>
char mesh_dfl_iface[] = "bat0";
char module_ver_path[] = "/sys/module/batman_adv/version";
diff --git a/ping.c b/ping.c
index 4d76484..d505d02 100644
--- a/ping.c
+++ b/ping.c
@@ -30,6 +30,11 @@
#include <fcntl.h>
#include <string.h>
#include <math.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <sys/select.h>
+#include <sys/time.h>
+#include <linux/if_ether.h>
#include "main.h"
#include "ping.h"
diff --git a/sys.c b/sys.c
index b1d7ea8..2fcd67b 100644
--- a/sys.c
+++ b/sys.c
@@ -25,7 +25,6 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <sys/types.h>
#include <dirent.h>
#include "main.h"
diff --git a/sys.h b/sys.h
index dfc167a..5d207a1 100644
--- a/sys.h
+++ b/sys.h
@@ -22,6 +22,8 @@
#ifndef _BATCTL_SYS_H
#define _BATCTL_SYS_H
+#include "main.h"
+
#define SYS_BATIF_PATH_FMT "/sys/class/net/%s/mesh/"
#define SYS_LOG_LEVEL "log_level"
#define SYS_LOG "log"
diff --git a/tcpdump.c b/tcpdump.c
index 7e0987b..a220c3c 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -36,8 +36,12 @@
#include <netinet/udp.h>
#include <netinet/ip_icmp.h>
#include <netinet/if_ether.h>
+#include <net/ethernet.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <sys/select.h>
+#include <sys/socket.h>
-#include "main.h"
#include "tcpdump.h"
#include "packet.h"
#include "bat-hosts.h"
diff --git a/tcpdump.h b/tcpdump.h
index 2845576..3c1a0e1 100644
--- a/tcpdump.h
+++ b/tcpdump.h
@@ -23,7 +23,10 @@
#define _BATCTL_TCPDUMP_H
#include <netpacket/packet.h>
-#include <net/ethernet.h>
+#include <linux/if_ether.h>
+#include <net/if_arp.h>
+#include <sys/types.h>
+#include "main.h"
#include "list-batman.h"
#ifndef ARPHRD_IEEE80211_PRISM
diff --git a/traceroute.c b/traceroute.c
index d62df5e..0cb0441 100644
--- a/traceroute.c
+++ b/traceroute.c
@@ -28,6 +28,10 @@
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
+#include <linux/if_ether.h>
+#include <stddef.h>
+#include <sys/select.h>
+#include <sys/time.h>
#include "main.h"
#include "traceroute.h"
diff --git a/translate.c b/translate.c
index 0b4fbc6..da6d593 100644
--- a/translate.c
+++ b/translate.c
@@ -19,7 +19,6 @@
*
*/
-#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 22+ messages in thread* [B.A.T.M.A.N.] [PATCH 08/11] batctl: Fix error handling jump in interface when batadv not loaded
2013-09-10 21:11 [B.A.T.M.A.N.] batctl: Debian patches for 2013.3.0-2 Sven Eckelmann
` (6 preceding siblings ...)
2013-09-10 21:11 ` [B.A.T.M.A.N.] [PATCH 07/11] batctl: Add missing includes and remove unused includes Sven Eckelmann
@ 2013-09-10 21:11 ` Sven Eckelmann
2013-09-13 10:58 ` Marek Lindner
2013-09-10 21:12 ` [B.A.T.M.A.N.] [PATCH 09/11] batctl: Fix type of new neighbor buffer in _seqno_trace_neigh_add Sven Eckelmann
` (2 subsequent siblings)
10 siblings, 1 reply; 22+ messages in thread
From: Sven Eckelmann @ 2013-09-10 21:11 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Sven Eckelmann
The jump to the path_buffer free must be taken when batman-adv was not loaded
because it has to free path_buff which was allocated earlier
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
sys.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys.c b/sys.c
index 2fcd67b..7539f76 100644
--- a/sys.c
+++ b/sys.c
@@ -230,7 +230,7 @@ int interface(char *mesh_iface, int argc, char **argv)
if (!file_exists(module_ver_path)) {
fprintf(stderr, "Error - batman-adv module has not been loaded\n");
- goto err;
+ goto err_buff;
}
fprintf(stderr, "Error - interface type not supported by batman-adv: %s\n", argv[i]);
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 22+ messages in thread* [B.A.T.M.A.N.] [PATCH 09/11] batctl: Fix type of new neighbor buffer in _seqno_trace_neigh_add
2013-09-10 21:11 [B.A.T.M.A.N.] batctl: Debian patches for 2013.3.0-2 Sven Eckelmann
` (7 preceding siblings ...)
2013-09-10 21:11 ` [B.A.T.M.A.N.] [PATCH 08/11] batctl: Fix error handling jump in interface when batadv not loaded Sven Eckelmann
@ 2013-09-10 21:12 ` Sven Eckelmann
2013-09-13 11:22 ` Marek Lindner
2013-09-10 21:12 ` [B.A.T.M.A.N.] [PATCH 10/11] batctl: Don't fail rebuild when header is removed Sven Eckelmann
2013-09-10 21:12 ` [B.A.T.M.A.N.] [PATCH 11/11] batctl: Don't use hyphen for parameter in manpage Sven Eckelmann
10 siblings, 1 reply; 22+ messages in thread
From: Sven Eckelmann @ 2013-09-10 21:12 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Sven Eckelmann
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
bisect_iv.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bisect_iv.c b/bisect_iv.c
index eadf427..917ffec 100644
--- a/bisect_iv.c
+++ b/bisect_iv.c
@@ -1041,7 +1041,7 @@ static void seqno_trace_print(struct list_head_first *trace_list, char *trace_or
static int _seqno_trace_neigh_add(struct seqno_trace_neigh *seqno_trace_mom,
struct seqno_trace_neigh *seqno_trace_child)
{
- struct seqno_trace_neigh *data_ptr;
+ struct seqno_trace_neigh **data_ptr;
data_ptr = malloc((seqno_trace_mom->num_neighbors + 1) * sizeof(struct seqno_trace_neigh *));
if (!data_ptr)
@@ -1054,7 +1054,7 @@ static int _seqno_trace_neigh_add(struct seqno_trace_neigh *seqno_trace_mom,
}
seqno_trace_mom->num_neighbors++;
- seqno_trace_mom->seqno_trace_neigh = (void *)data_ptr;
+ seqno_trace_mom->seqno_trace_neigh = data_ptr;
seqno_trace_mom->seqno_trace_neigh[seqno_trace_mom->num_neighbors - 1] = seqno_trace_child;
return 1;
}
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 22+ messages in thread* [B.A.T.M.A.N.] [PATCH 10/11] batctl: Don't fail rebuild when header is removed
2013-09-10 21:11 [B.A.T.M.A.N.] batctl: Debian patches for 2013.3.0-2 Sven Eckelmann
` (8 preceding siblings ...)
2013-09-10 21:12 ` [B.A.T.M.A.N.] [PATCH 09/11] batctl: Fix type of new neighbor buffer in _seqno_trace_neigh_add Sven Eckelmann
@ 2013-09-10 21:12 ` Sven Eckelmann
2013-09-13 11:24 ` Marek Lindner
2013-09-10 21:12 ` [B.A.T.M.A.N.] [PATCH 11/11] batctl: Don't use hyphen for parameter in manpage Sven Eckelmann
10 siblings, 1 reply; 22+ messages in thread
From: Sven Eckelmann @ 2013-09-10 21:12 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Sven Eckelmann
The *.d depends files for make just list the files used when building an object
file. Removing a file listed in such a dependency file causes make to search
for a way to recreate it. This usually cannot work because these files aren't
autogenerated.
The gcc option -MP can be used to generate empty rule for these files. Removing
a file in a dependency list will then execute this empty rule and continue with
the execution of the creation of the object file. This compilation process will
then automatically correct the dependency file.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 7926db3..90d3d79 100755
--- a/Makefile
+++ b/Makefile
@@ -29,7 +29,7 @@ OBJ_BISECT = bisect_iv.o
MANPAGE = man/batctl.8
# batctl flags and options
-CFLAGS += -Wall -W -std=gnu99 -fno-strict-aliasing -MD
+CFLAGS += -Wall -W -std=gnu99 -fno-strict-aliasing -MD -MP
CPPFLAGS += -D_GNU_SOURCE
LDLIBS += -lm
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 22+ messages in thread* Re: [B.A.T.M.A.N.] [PATCH 10/11] batctl: Don't fail rebuild when header is removed
2013-09-10 21:12 ` [B.A.T.M.A.N.] [PATCH 10/11] batctl: Don't fail rebuild when header is removed Sven Eckelmann
@ 2013-09-13 11:24 ` Marek Lindner
0 siblings, 0 replies; 22+ messages in thread
From: Marek Lindner @ 2013-09-13 11:24 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Sven Eckelmann
On Tuesday 10 September 2013 23:12:01 Sven Eckelmann wrote:
> The *.d depends files for make just list the files used when building an
> object file. Removing a file listed in such a dependency file causes make
> to search for a way to recreate it. This usually cannot work because these
> files aren't autogenerated.
>
> The gcc option -MP can be used to generate empty rule for these files.
> Removing a file in a dependency list will then execute this empty rule and
> continue with the execution of the creation of the object file. This
> compilation process will then automatically correct the dependency file.
>
> Signed-off-by: Sven Eckelmann <sven@narfation.org>
> ---
> Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied in revision 4c5c86e.
Thanks,
Marek
^ permalink raw reply [flat|nested] 22+ messages in thread
* [B.A.T.M.A.N.] [PATCH 11/11] batctl: Don't use hyphen for parameter in manpage
2013-09-10 21:11 [B.A.T.M.A.N.] batctl: Debian patches for 2013.3.0-2 Sven Eckelmann
` (9 preceding siblings ...)
2013-09-10 21:12 ` [B.A.T.M.A.N.] [PATCH 10/11] batctl: Don't fail rebuild when header is removed Sven Eckelmann
@ 2013-09-10 21:12 ` Sven Eckelmann
2013-09-13 11:26 ` Marek Lindner
10 siblings, 1 reply; 22+ messages in thread
From: Sven Eckelmann @ 2013-09-10 21:12 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Sven Eckelmann
By default, "-" chars are interpreted as hyphens (U+2010) by groff, not as
minus signs (U+002D). Since options to programs use minus signs (U+002D), this
means for example in UTF-8 locales that you cannot cut and paste options, nor
search for them easily.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
man/batctl.8 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/man/batctl.8 b/man/batctl.8
index d04385b..157f96d 100644
--- a/man/batctl.8
+++ b/man/batctl.8
@@ -269,7 +269,7 @@ except specified). The following packet types are available:
128 - non batman packets
.RE
.RS 7
-Example: batctl td <interface> -p 129 \-> only display batman ogm packets and non batman packets
+Example: batctl td <interface> \-p 129 \-> only display batman ogm packets and non batman packets
.RE
.br
.IP "\fBbisect_iv\fP [\fB\-l MAC\fP][\fB\-t MAC\fP][\fB\-r MAC\fP][\fB\-s min\fP [\fB\- max\fP]][\fB\-o MAC\fP][\fB\-n\fP] \fBlogfile1\fP [\fBlogfile2\fP ... \fBlogfileN\fP]"
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 22+ messages in thread* Re: [B.A.T.M.A.N.] [PATCH 11/11] batctl: Don't use hyphen for parameter in manpage
2013-09-10 21:12 ` [B.A.T.M.A.N.] [PATCH 11/11] batctl: Don't use hyphen for parameter in manpage Sven Eckelmann
@ 2013-09-13 11:26 ` Marek Lindner
0 siblings, 0 replies; 22+ messages in thread
From: Marek Lindner @ 2013-09-13 11:26 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Sven Eckelmann
On Tuesday 10 September 2013 23:12:02 Sven Eckelmann wrote:
> By default, "-" chars are interpreted as hyphens (U+2010) by groff, not as
> minus signs (U+002D). Since options to programs use minus signs (U+002D),
> this means for example in UTF-8 locales that you cannot cut and paste
> options, nor search for them easily.
>
> Signed-off-by: Sven Eckelmann <sven@narfation.org>
> ---
> man/batctl.8 | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied in revision b64f1c8.
Thanks,
Marek
^ permalink raw reply [flat|nested] 22+ messages in thread