All of lore.kernel.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] batmand: Debian patches for 0.3.2+51+g1e275d9-1
@ 2013-09-12 20:58 Sven Eckelmann
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 01/13] batmand: Disable strict-aliasing rules Sven Eckelmann
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: Sven Eckelmann @ 2013-09-12 20:58 UTC (permalink / raw)
  To: b.a.t.m.a.n

Hi,

different patches [1] were aggregated in the Debian package of batmand
0.3.2+51+g1e275d9-1.

Kind regards,
        Sven

[1] http://anonscm.debian.org/gitweb/?p=collab-maint/batmand.git;a=tree;f=debian/patches;hb=refs/tags/debian/0.3.2%2B51%2Bg1e275d9-1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [B.A.T.M.A.N.] [PATCH 01/13] batmand: Disable strict-aliasing rules
  2013-09-12 20:58 [B.A.T.M.A.N.] batmand: Debian patches for 0.3.2+51+g1e275d9-1 Sven Eckelmann
@ 2013-09-12 20:58 ` Sven Eckelmann
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 02/13] batmand: Add CFLAGS to the linker step Sven Eckelmann
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Sven Eckelmann @ 2013-09-12 20:58 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Sven Eckelmann

There are different aliasing problems in posix/tunnel.c and maybe other files.
This can lead to wrongly generated code when the compiler assumes strict
aliasing rules.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index ce1e198..3205573 100755
--- a/Makefile
+++ b/Makefile
@@ -37,7 +37,7 @@ MANPAGE = man/batmand.8
 #NO_POLICY_ROUTING = -DNO_POLICY_ROUTING
 
 # batmand flags and options
-CFLAGS +=	-pedantic -Wall -W -std=gnu99 -MD
+CFLAGS +=	-pedantic -Wall -W -std=gnu99 -MD -fno-strict-aliasing
 CPPFLAGS +=	-DDEBUG_MALLOC -DMEMORY_USAGE -DPROFILE_DATA $(NO_POLICY_ROUTING)
 LDLIBS +=	-lpthread
 
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [B.A.T.M.A.N.] [PATCH 02/13] batmand: Add CFLAGS to the linker step
  2013-09-12 20:58 [B.A.T.M.A.N.] batmand: Debian patches for 0.3.2+51+g1e275d9-1 Sven Eckelmann
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 01/13] batmand: Disable strict-aliasing rules Sven Eckelmann
@ 2013-09-12 20:58 ` Sven Eckelmann
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 03/13] batmand: Don't fail rebuild when header is removed Sven Eckelmann
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Sven Eckelmann @ 2013-09-12 20:58 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Sven Eckelmann

The GCC manual states for different parameters that the options for compilation
must also be used when linking. The options for compilation are stored in
CFLAGS and added to LINK.o to fix the behavior.

Option which need this are for example -fPIC/-fPIE or -flto.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 3205573..50d1fe8 100755
--- a/Makefile
+++ b/Makefile
@@ -57,7 +57,7 @@ RM ?= rm -f
 INSTALL ?= install
 MKDIR ?= mkdir -p
 COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
-LINK.o = $(Q_LD)$(CC) $(LDFLAGS) $(TARGET_ARCH)
+LINK.o = $(Q_LD)$(CC) $(CFLAGS) $(LDFLAGS) $(TARGET_ARCH)
 
 # standard install paths
 PREFIX = /usr/local
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [B.A.T.M.A.N.] [PATCH 03/13] batmand: Don't fail rebuild when header is removed
  2013-09-12 20:58 [B.A.T.M.A.N.] batmand: Debian patches for 0.3.2+51+g1e275d9-1 Sven Eckelmann
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 01/13] batmand: Disable strict-aliasing rules Sven Eckelmann
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 02/13] batmand: Add CFLAGS to the linker step Sven Eckelmann
@ 2013-09-12 20:58 ` Sven Eckelmann
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 04/13] batmand: Add include guards to avoid redundant declarations or include loops Sven Eckelmann
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Sven Eckelmann @ 2013-09-12 20:58 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 50d1fe8..6eae7ef 100755
--- a/Makefile
+++ b/Makefile
@@ -37,7 +37,7 @@ MANPAGE = man/batmand.8
 #NO_POLICY_ROUTING = -DNO_POLICY_ROUTING
 
 # batmand flags and options
-CFLAGS +=	-pedantic -Wall -W -std=gnu99 -MD -fno-strict-aliasing
+CFLAGS +=	-pedantic -Wall -W -std=gnu99 -MD -MP -fno-strict-aliasing
 CPPFLAGS +=	-DDEBUG_MALLOC -DMEMORY_USAGE -DPROFILE_DATA $(NO_POLICY_ROUTING)
 LDLIBS +=	-lpthread
 
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [B.A.T.M.A.N.] [PATCH 04/13] batmand: Add include guards to avoid redundant declarations or include loops
  2013-09-12 20:58 [B.A.T.M.A.N.] batmand: Debian patches for 0.3.2+51+g1e275d9-1 Sven Eckelmann
                   ` (2 preceding siblings ...)
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 03/13] batmand: Don't fail rebuild when header is removed Sven Eckelmann
@ 2013-09-12 20:58 ` Sven Eckelmann
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 05/13] batmand: Avoid assigning const buffer to non-const pointer Sven Eckelmann
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Sven Eckelmann @ 2013-09-12 20:58 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Sven Eckelmann

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 allocate.h    | 6 +++---
 batman.h      | 4 ++--
 bitarray.h    | 4 +++-
 hash.h        | 4 ++--
 hna.h         | 5 ++++-
 originator.h  | 4 +++-
 os.h          | 4 ++--
 packet.h      | 5 +++++
 profile.h     | 5 ++++-
 ring_buffer.h | 5 ++++-
 schedule.h    | 4 ++++
 types.h       | 4 ++--
 12 files changed, 38 insertions(+), 16 deletions(-)

diff --git a/allocate.h b/allocate.h
index 167ab33..99c3a49 100644
--- a/allocate.h
+++ b/allocate.h
@@ -20,10 +20,10 @@
  */
 
 
-#ifndef _ALLOCATE_H
-#define _ALLOCATE_H 1
-#include <stdint.h>
+#ifndef _BATMAND_ALLOCATE_H
+#define _BATMAND_ALLOCATE_H
 
+#include <stdint.h>
 
 
 void checkIntegrity(void);
diff --git a/batman.h b/batman.h
index c8e35f1..05c48c1 100644
--- a/batman.h
+++ b/batman.h
@@ -21,8 +21,8 @@
 
 
 
-#ifndef _BATMAN_BATMAN_H
-#define _BATMAN_BATMAN_H
+#ifndef _BATMAND_BATMAN_H
+#define _BATMAND_BATMAN_H
 
 #include <sys/types.h>
 #include <netinet/in.h>
diff --git a/bitarray.h b/bitarray.h
index 9a1f80d..e0ca302 100644
--- a/bitarray.h
+++ b/bitarray.h
@@ -19,7 +19,8 @@
  *
  */
 
-
+#ifndef _BATMAND_BITARRAY_H
+#define _BATMAND_BITARRAY_H
 
 #include "batman.h"
 #define WORD_BIT_SIZE ( sizeof(TYPE_OF_WORD) * 8 )
@@ -34,3 +35,4 @@ char bit_get_packet( TYPE_OF_WORD *seq_bits, int16_t seq_num_diff, int8_t set_ma
 int  bit_packet_count( TYPE_OF_WORD *seq_bits );
 uint8_t bit_count( int32_t to_count );
 
+#endif
diff --git a/hash.h b/hash.h
index 91ee7d8..66d7162 100644
--- a/hash.h
+++ b/hash.h
@@ -18,8 +18,8 @@
  * 02110-1301, USA
  *
  */
-#ifndef _BATMAN_HASH_H
-#define _BATMAN_HASH_H
+#ifndef _BATMAND_HASH_H
+#define _BATMAND_HASH_H
 
 
 
diff --git a/hna.h b/hna.h
index 5af9317..99f7664 100644
--- a/hna.h
+++ b/hna.h
@@ -19,7 +19,8 @@
  *
  */
 
-
+#ifndef _BATMAND_HNA_H
+#define _BATMAND_HNA_H
 
 #include "batman.h"
 
@@ -82,3 +83,5 @@ void hna_global_update(struct orig_node *orig_node, unsigned char *new_hna,
 				int16_t new_hna_len, struct neigh_node *old_router);
 void hna_global_check_tq(struct orig_node *orig_node);
 void hna_global_del(struct orig_node *orig_node);
+
+#endif
diff --git a/originator.h b/originator.h
index fb5e063..5ce5162 100644
--- a/originator.h
+++ b/originator.h
@@ -19,7 +19,8 @@
  *
  */
 
-
+#ifndef _BATMAND_ORIGINATOR_H
+#define _BATMAND_ORIGINATOR_H
 
 #include "batman.h"
 #include "types.h"
@@ -33,3 +34,4 @@ void update_orig( struct orig_node *orig_node, struct bat_packet *in, uint32_t n
 void purge_orig( uint32_t curr_time );
 void debug_orig(void);
 
+#endif
diff --git a/os.h b/os.h
index ab02497..26e97f5 100644
--- a/os.h
+++ b/os.h
@@ -19,8 +19,8 @@
  *
  */
 
-#ifndef _BATMAN_OS_H
-#define _BATMAN_OS_H
+#ifndef _BATMAND_OS_H
+#define _BATMAND_OS_H
 
 #include "batman.h"
 
diff --git a/packet.h b/packet.h
index 7d7e5b4..3a98ea5 100644
--- a/packet.h
+++ b/packet.h
@@ -19,6 +19,9 @@
  *
  */
 
+#ifndef _BATMAND_PACKET_H
+#define _BATMAND_PACKET_H
+
 #define COMPAT_VERSION 5
 #define VIS_COMPAT_VERSION 23
 
@@ -57,3 +60,5 @@ struct vis_data {
 	uint8_t data;
 	uint32_t ip;
 } __attribute__((packed));
+
+#endif
diff --git a/profile.h b/profile.h
index a4afde0..d9221d5 100644
--- a/profile.h
+++ b/profile.h
@@ -19,7 +19,8 @@
  *
  */
 
-
+#ifndef _BATMAND_PROFILE_H
+#define _BATMAND_PROFILE_H
 
 enum {
 
@@ -51,3 +52,5 @@ void prof_init(int32_t index, char *name);
 void prof_start(int32_t index);
 void prof_stop(int32_t index);
 void prof_print(void);
+
+#endif
diff --git a/ring_buffer.h b/ring_buffer.h
index 78d8f9e..c1679d9 100644
--- a/ring_buffer.h
+++ b/ring_buffer.h
@@ -19,7 +19,8 @@
  *
  */
 
-
+#ifndef _BATMAND_RING_BUFFER_H
+#define _BATMAND_RING_BUFFER_H
 
 #include <stdint.h>
 #include "batman.h"
@@ -28,3 +29,5 @@
 
 void ring_buffer_set(uint8_t tq_recv[], uint8_t *tq_index, uint8_t value);
 uint8_t ring_buffer_avg(uint8_t tq_recv[]);
+
+#endif
diff --git a/schedule.h b/schedule.h
index 50fd5aa..8bd54cd 100644
--- a/schedule.h
+++ b/schedule.h
@@ -19,7 +19,11 @@
  *
  */
 
+#ifndef _BATMAND_SCHEDULE_H
+#define _BATMAND_SCHEDULE_H
 
 void schedule_own_packet( struct batman_if *batman_if );
 void schedule_forward_packet(struct orig_node *orig_node, struct bat_packet *in, uint32_t neigh, uint8_t directlink, int16_t hna_buff_len, struct batman_if *if_outgoing, uint32_t curr_time);
 void send_outstanding_packets(uint32_t curr_time);
+
+#endif
diff --git a/types.h b/types.h
index 7aa4884..6ae336e 100644
--- a/types.h
+++ b/types.h
@@ -19,8 +19,8 @@
  *
  */
 
-#ifndef TYPES_H
-#define TYPES_H
+#ifndef _BATMAND_TYPES_H
+#define _BATMAND_TYPES_H
 
 #include "packet.h"
 
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [B.A.T.M.A.N.] [PATCH 05/13] batmand: Avoid assigning const buffer to non-const pointer
  2013-09-12 20:58 [B.A.T.M.A.N.] batmand: Debian patches for 0.3.2+51+g1e275d9-1 Sven Eckelmann
                   ` (3 preceding siblings ...)
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 04/13] batmand: Add include guards to avoid redundant declarations or include loops Sven Eckelmann
@ 2013-09-12 20:58 ` Sven Eckelmann
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 06/13] batmand: Fix preprocessor check for defined NO_POLICY_ROUTING Sven Eckelmann
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Sven Eckelmann @ 2013-09-12 20:58 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>
---
 allocate.c          |  2 +-
 hna.c               |  4 ++--
 linux/kernel.c      | 10 +++++-----
 linux/route.c       |  8 ++++----
 linux/tun.c         |  4 ++--
 os.h                | 16 ++++++++--------
 posix/posix.c       |  2 +-
 posix/unix_socket.c |  2 +-
 profile.c           |  2 +-
 profile.h           |  4 ++--
 10 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/allocate.c b/allocate.c
index 9d79d87..57a4894 100644
--- a/allocate.c
+++ b/allocate.c
@@ -67,7 +67,7 @@ struct memoryUsage
 };
 
 
-static size_t getHeaderPad() {
+static size_t getHeaderPad(void) {
 	size_t alignwith, pad;
 
 	if (sizeof(TYPE_OF_WORD) > sizeof(void*))
diff --git a/hna.c b/hna.c
index 4c90dd3..b007ce5 100644
--- a/hna.c
+++ b/hna.c
@@ -39,12 +39,12 @@ struct list_head_first hna_chg_list;
 static pthread_mutex_t hna_chg_list_mutex;
 static struct hashtable_t *hna_global_hash = NULL;
 
-int compare_hna(void *data1, void *data2)
+static int compare_hna(void *data1, void *data2)
 {
 	return (memcmp(data1, data2, 5) == 0 ? 1 : 0);
 }
 
-int choose_hna(void *data, int32_t size)
+static int choose_hna(void *data, int32_t size)
 {
 	unsigned char *key= data;
 	uint32_t hash = 0;
diff --git a/linux/kernel.c b/linux/kernel.c
index fa8882c..08c7e20 100644
--- a/linux/kernel.c
+++ b/linux/kernel.c
@@ -70,7 +70,7 @@ static void set_integer_file(const char* filename, int32_t integer)
 	fclose(f);
 }
 
-void set_rp_filter(int32_t state, char* dev)
+void set_rp_filter(int32_t state, const char* dev)
 {
 	char filename[100], *colon_ptr;
 
@@ -85,7 +85,7 @@ void set_rp_filter(int32_t state, char* dev)
 		*colon_ptr = ':';
 }
 
-int32_t get_rp_filter(char *dev)
+int32_t get_rp_filter(const char *dev)
 {
 	int32_t state = 0;
 	char filename[100], *colon_ptr;
@@ -103,7 +103,7 @@ int32_t get_rp_filter(char *dev)
 	return state;
 }
 
-void set_send_redirects(int32_t state, char* dev)
+void set_send_redirects(int32_t state, const char* dev)
 {
 	char filename[100], *colon_ptr;
 
@@ -118,7 +118,7 @@ void set_send_redirects(int32_t state, char* dev)
 		*colon_ptr = ':';
 }
 
-int32_t get_send_redirects(char *dev)
+int32_t get_send_redirects(const char *dev)
 {
 	int32_t state = 0;
 	char filename[100], *colon_ptr;
@@ -146,7 +146,7 @@ int32_t get_forwarding(void)
 	return get_integer_file("/proc/sys/net/ipv4/ip_forward");
 }
 
-int8_t bind_to_iface(int32_t sock, char *dev)
+int8_t bind_to_iface(int32_t sock, const char *dev)
 {
 	char *colon_ptr;
 
diff --git a/linux/route.c b/linux/route.c
index bceac95..7934c27 100644
--- a/linux/route.c
+++ b/linux/route.c
@@ -73,7 +73,7 @@ static const char *rule_type_to_string_script[] = {
 
 #include <net/route.h>
 
-void add_del_route(uint32_t dest, uint8_t netmask, uint32_t router, uint32_t src_ip, int32_t ifi, char *dev, uint8_t rt_table, int8_t route_type, int8_t route_action)
+void add_del_route(uint32_t dest, uint8_t netmask, uint32_t router, uint32_t src_ip, int32_t ifi, const char *dev, uint8_t rt_table, int8_t route_type, int8_t route_action)
 {
 	struct rtentry route;
 	struct sockaddr_in *addr;
@@ -152,7 +152,7 @@ void add_del_route(uint32_t dest, uint8_t netmask, uint32_t router, uint32_t src
 	close(sock);
 }
 
-void add_del_rule(uint32_t BATMANUNUSED(network), uint8_t BATMANUNUSED(netmask), int8_t BATMANUNUSED(rt_table), uint32_t BATMANUNUSED(prio), char *BATMANUNUSED(iif), int8_t BATMANUNUSED(rule_type), int8_t BATMANUNUSED(rule_action))
+void add_del_rule(uint32_t BATMANUNUSED(network), uint8_t BATMANUNUSED(netmask), int8_t BATMANUNUSED(rt_table), uint32_t BATMANUNUSED(prio), const char *BATMANUNUSED(iif), int8_t BATMANUNUSED(rule_type), int8_t BATMANUNUSED(rule_action))
 {
 	return;
 }
@@ -169,7 +169,7 @@ int flush_routes_rules(int8_t BATMANUNUSED(is_rule))
 
 #else
 
-void add_del_route(uint32_t dest, uint8_t netmask, uint32_t router, uint32_t src_ip, int32_t ifi, char *dev, uint8_t rt_table, int8_t route_type, int8_t route_action)
+void add_del_route(uint32_t dest, uint8_t netmask, uint32_t router, uint32_t src_ip, int32_t ifi, const char *dev, uint8_t rt_table, int8_t route_type, int8_t route_action)
 {
 	int netlink_sock;
 	size_t len;
@@ -354,7 +354,7 @@ void add_del_route(uint32_t dest, uint8_t netmask, uint32_t router, uint32_t src
  *
  ***/
 
-void add_del_rule(uint32_t network, uint8_t netmask, int8_t rt_table, uint32_t prio, char *iif, int8_t rule_type, int8_t rule_action)
+void add_del_rule(uint32_t network, uint8_t netmask, int8_t rt_table, uint32_t prio, const char *iif, int8_t rule_type, int8_t rule_action)
 {
 	int netlink_sock;
 	size_t len;
diff --git a/linux/tun.c b/linux/tun.c
index afb0447..ac5e069 100644
--- a/linux/tun.c
+++ b/linux/tun.c
@@ -47,7 +47,7 @@
 #define IPTABLES_DEL_ACC "iptables -t nat -D POSTROUTING -s %s/%i -j ACCEPT"
 
 
-int run_cmd(char *cmd) {
+static int run_cmd(const char *cmd) {
 	int error, pipes[2], stderr = -1, ret = 0;
 	char error_log[256];
 
@@ -90,7 +90,7 @@ int probe_nat_tool(void) {
 	return run_cmd("which iptables > /dev/null");
 }
 
-void exec_iptables_rule(char *cmd, int8_t route_action) {
+static void exec_iptables_rule(const char *cmd, int8_t route_action) {
 	if (disable_client_nat)
 		return;
 
diff --git a/os.h b/os.h
index 26e97f5..2f2b2df 100644
--- a/os.h
+++ b/os.h
@@ -44,8 +44,8 @@ void segmentation_fault(int32_t sig) NO_RETURN;
 void restore_and_exit(uint8_t is_sigsegv) NO_RETURN;
 
 /* route.c */
-void add_del_route( uint32_t dest, uint8_t netmask, uint32_t router, uint32_t src_ip, int32_t ifi, char *dev, uint8_t rt_table, int8_t route_type, int8_t del );
-void add_del_rule( uint32_t network, uint8_t netmask, int8_t rt_table, uint32_t prio, char *iif, int8_t dst_rule, int8_t del );
+void add_del_route( uint32_t dest, uint8_t netmask, uint32_t router, uint32_t src_ip, int32_t ifi, const char *dev, uint8_t rt_table, int8_t route_type, int8_t del );
+void add_del_rule( uint32_t network, uint8_t netmask, int8_t rt_table, uint32_t prio, const char *iif, int8_t dst_rule, int8_t del );
 int add_del_interface_rules( int8_t del );
 int flush_routes_rules( int8_t rt_table );
 
@@ -69,13 +69,13 @@ void init_interface_gw(void);
 void interface_listen_sockets(void);
 
 /* kernel.c */
-void set_rp_filter( int32_t state, char* dev );
-int32_t get_rp_filter( char *dev );
-void set_send_redirects( int32_t state, char* dev );
-int32_t get_send_redirects( char *dev );
+void set_rp_filter( int32_t state, const char* dev );
+int32_t get_rp_filter( const char *dev );
+void set_send_redirects( int32_t state, const char* dev );
+int32_t get_send_redirects( const char *dev );
 void set_forwarding( int32_t state );
 int32_t get_forwarding( void );
-int8_t bind_to_iface( int32_t sock, char *dev );
+int8_t bind_to_iface( int32_t sock, const char *dev );
 int is_wifi_interface(char *dev, int fd);
 
 /* posix.c */
@@ -96,7 +96,7 @@ void *client_to_gw_tun( void *arg );
 /* unix_sokcet.c */
 void *unix_listen( void *arg );
 void internal_output(uint32_t sock);
-void debug_output( int8_t debug_prio, char *format, ... );
+void debug_output( int8_t debug_prio, const char *format, ... );
 
 
 #endif
diff --git a/posix/posix.c b/posix/posix.c
index ae1cef0..81cd2e1 100644
--- a/posix/posix.c
+++ b/posix/posix.c
@@ -125,7 +125,7 @@ uint64_t get_time_msec64(void)
 }
 
 /* batman animation */
-static void sym_print( char x, char y, char *z ) {
+static void sym_print( char x, char y, const char *z ) {
 
 	char i = 0, Z;
 
diff --git a/posix/unix_socket.c b/posix/unix_socket.c
index 02a0a3a..11c5d3e 100644
--- a/posix/unix_socket.c
+++ b/posix/unix_socket.c
@@ -39,7 +39,7 @@
 #include "../hna.h"
 
 
-void debug_output(int8_t debug_prio, char *format, ...) {
+void debug_output(int8_t debug_prio, const char *format, ...) {
 
 	struct list_head *debug_pos;
 	struct debug_level_info *debug_level_info;
diff --git a/profile.c b/profile.c
index e691f5d..c76ae8d 100644
--- a/profile.c
+++ b/profile.c
@@ -33,7 +33,7 @@ static struct prof_container prof_container[PROF_COUNT];
 
 
 
-void prof_init(int32_t index, char *name) {
+void prof_init(int32_t index, const char *name) {
 
 	prof_container[index].total_time = 0;
 	prof_container[index].calls = 0;
diff --git a/profile.h b/profile.h
index d9221d5..e50bf70 100644
--- a/profile.h
+++ b/profile.h
@@ -42,13 +42,13 @@ struct prof_container {
 
 	clock_t start_time;
 	clock_t total_time;
-	char *name;
+	const char *name;
 	uint64_t calls;
 
 };
 
 
-void prof_init(int32_t index, char *name);
+void prof_init(int32_t index, const char *name);
 void prof_start(int32_t index);
 void prof_stop(int32_t index);
 void prof_print(void);
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [B.A.T.M.A.N.] [PATCH 06/13] batmand: Fix preprocessor check for defined NO_POLICY_ROUTING
  2013-09-12 20:58 [B.A.T.M.A.N.] batmand: Debian patches for 0.3.2+51+g1e275d9-1 Sven Eckelmann
                   ` (4 preceding siblings ...)
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 05/13] batmand: Avoid assigning const buffer to non-const pointer Sven Eckelmann
@ 2013-09-12 20:58 ` Sven Eckelmann
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 07/13] batmand: Fix printf format strings Sven Eckelmann
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Sven Eckelmann @ 2013-09-12 20:58 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Sven Eckelmann

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 linux/route.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux/route.c b/linux/route.c
index 7934c27..12f7734 100644
--- a/linux/route.c
+++ b/linux/route.c
@@ -69,7 +69,7 @@ static const char *rule_type_to_string_script[] = {
  *
  ***/
 
-#if NO_POLICY_ROUTING
+#ifdef NO_POLICY_ROUTING
 
 #include <net/route.h>
 
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [B.A.T.M.A.N.] [PATCH 07/13] batmand: Fix printf format strings
  2013-09-12 20:58 [B.A.T.M.A.N.] batmand: Debian patches for 0.3.2+51+g1e275d9-1 Sven Eckelmann
                   ` (5 preceding siblings ...)
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 06/13] batmand: Fix preprocessor check for defined NO_POLICY_ROUTING Sven Eckelmann
@ 2013-09-12 20:58 ` Sven Eckelmann
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 08/13] batmand: Clear screen using ANSI escape codes Sven Eckelmann
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Sven Eckelmann @ 2013-09-12 20:58 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Sven Eckelmann

The types for the format string did not always match the type of the parameter.
This can lead to wrong output or crashes. There is also no '' format string but
a thousand format string. But this thousand '  is not ISO C and doesn't work
with all libc implementations. And the thousand ' is not supported for strings.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 allocate.c          |  2 +-
 originator.c        | 12 ++++++------
 os.h                |  2 +-
 posix/unix_socket.c |  2 +-
 profile.c           |  3 ++-
 5 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/allocate.c b/allocate.c
index 57a4894..beedafe 100644
--- a/allocate.c
+++ b/allocate.c
@@ -210,7 +210,7 @@ void checkIntegrity(void)
 	for ( memoryWalker = memoryList; memoryWalker != NULL; memoryWalker = memoryWalker->next ) {
 
 		if ( memoryWalker->counter != 0 )
-			debug_output( 5, "   tag: %''4i, num malloc: %4i, bytes per malloc: %''4i, total: %6i\n", memoryWalker->tag, memoryWalker->counter, memoryWalker->length, memoryWalker->counter * memoryWalker->length );
+			debug_output( 5, "   tag: %4i, num malloc: %4i, bytes per malloc: %4i, total: %6i\n", memoryWalker->tag, memoryWalker->counter, memoryWalker->length, memoryWalker->counter * memoryWalker->length );
 
 	}
 	pthread_mutex_unlock(&memory_mutex);
diff --git a/originator.c b/originator.c
index f58bbcf..7de0e4d 100644
--- a/originator.c
+++ b/originator.c
@@ -423,7 +423,7 @@ void debug_orig(void) {
 		uptime_sec = (uint64_t)(get_time_msec64() / 1000);
 
 		debug_output(2, "BOD\n");
-		debug_output(2, "%''12s     (%s/%i) %''15s [%10s], gw_class ... [B.A.T.M.A.N. %s, MainIF/IP: %s/%s, UT: %id%2ih%2im] \n", "Gateway", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF", SOURCE_VERSION, ((struct batman_if *)if_list.next)->dev, orig_str, (uint32_t)(uptime_sec/86400), (uint32_t)((uptime_sec%86400)/3600), (uint32_t)((uptime_sec%3600)/60));
+		debug_output(2, "%12s     (%s/%i) %15s [%10s], gw_class ... [B.A.T.M.A.N. %s, MainIF/IP: %s/%s, UT: %id%2ih%2im] \n", "Gateway", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF", SOURCE_VERSION, ((struct batman_if *)if_list.next)->dev, orig_str, (uint32_t)(uptime_sec/86400), (uint32_t)((uptime_sec%86400)/3600), (uint32_t)((uptime_sec%3600)/60));
 
 		if ( list_empty( &gw_list ) ) {
 
@@ -446,7 +446,7 @@ void debug_orig(void) {
 
 				get_gw_speeds( gw_node->orig_node->gwflags, &download_speed, &upload_speed );
 
-				debug_output(2, "%s %-15s (%3i) %''15s [%10s], gw_class %3i - %i%s/%i%s, gateway failures: %i \n", ( curr_gateway == gw_node ? "=>" : "  " ), str, gw_node->orig_node->router->tq_avg, str2, gw_node->orig_node->router->if_incoming->dev, gw_node->orig_node->gwflags, (download_speed > 2048 ? download_speed / 1024 : download_speed), (download_speed > 2048 ? "MBit" : "KBit"), (upload_speed > 2048 ? upload_speed / 1024 : upload_speed), (upload_speed > 2048 ? "MBit" : "KBit"), gw_node->gw_failure);
+				debug_output(2, "%s %-15s (%3i) %15s [%10s], gw_class %3i - %i%s/%i%s, gateway failures: %i \n", ( curr_gateway == gw_node ? "=>" : "  " ), str, gw_node->orig_node->router->tq_avg, str2, gw_node->orig_node->router->if_incoming->dev, gw_node->orig_node->gwflags, (download_speed > 2048 ? download_speed / 1024 : download_speed), (download_speed > 2048 ? "MBit" : "KBit"), (upload_speed > 2048 ? upload_speed / 1024 : upload_speed), (upload_speed > 2048 ? "MBit" : "KBit"), gw_node->gw_failure);
 
 				batman_count++;
 
@@ -467,7 +467,7 @@ void debug_orig(void) {
 		uptime_sec = (uint64_t)(get_time_msec64() / 1000);
 
 		debug_output(1, "BOD \n");
-		debug_output(1, "  %-11s (%s/%i) %''15s [%10s]: %''20s ... [B.A.T.M.A.N. %s, MainIF/IP: %s/%s, UT: %id%2ih%2im] \n", "Originator", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF", "Potential nexthops", SOURCE_VERSION, ((struct batman_if *)if_list.next)->dev, orig_str, (uint32_t)(uptime_sec/86400), (uint32_t)((uptime_sec%86400)/3600), (uint32_t)((uptime_sec%3600)/60));
+		debug_output(1, "  %-11s (%s/%i) %15s [%10s]: %20s ... [B.A.T.M.A.N. %s, MainIF/IP: %s/%s, UT: %id%2ih%2im] \n", "Originator", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF", "Potential nexthops", SOURCE_VERSION, ((struct batman_if *)if_list.next)->dev, orig_str, (uint32_t)(uptime_sec/86400), (uint32_t)((uptime_sec%86400)/3600), (uint32_t)((uptime_sec%3600)/60));
 
 		if ( debug_clients.clients_num[3] > 0 ) {
 
@@ -481,7 +481,7 @@ void debug_orig(void) {
 			}
 
 			debug_output( 4, "Originator list \n" );
-			debug_output( 4, "  %-11s (%s/%i) %''15s [%10s]: %''20s\n", "Originator", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF", "Potential nexthops" );
+			debug_output( 4, "  %-11s (%s/%i) %15s [%10s]: %20s\n", "Originator", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF", "Potential nexthops" );
 
 		}
 
@@ -497,8 +497,8 @@ void debug_orig(void) {
 			addr_to_string( orig_node->orig, str, sizeof (str) );
 			addr_to_string( orig_node->router->addr, str2, sizeof (str2) );
 
-			debug_output( 1, "%-15s (%3i) %''15s [%10s]:", str, orig_node->router->tq_avg, str2, orig_node->router->if_incoming->dev );
-			debug_output( 4, "%''15s (%3i) %''15s [%10s], last_valid: %u: \n", str, orig_node->router->tq_avg, str2, orig_node->router->if_incoming->dev, orig_node->last_valid );
+			debug_output( 1, "%-15s (%3i) %15s [%10s]:", str, orig_node->router->tq_avg, str2, orig_node->router->if_incoming->dev );
+			debug_output( 4, "%15s (%3i) %15s [%10s], last_valid: %u: \n", str, orig_node->router->tq_avg, str2, orig_node->router->if_incoming->dev, orig_node->last_valid );
 
 			debug_out_size = 0;
 
diff --git a/os.h b/os.h
index 2f2b2df..2272030 100644
--- a/os.h
+++ b/os.h
@@ -96,7 +96,7 @@ void *client_to_gw_tun( void *arg );
 /* unix_sokcet.c */
 void *unix_listen( void *arg );
 void internal_output(uint32_t sock);
-void debug_output( int8_t debug_prio, const char *format, ... );
+void debug_output( int8_t debug_prio, const char *format, ... ) __attribute__ ((format (printf, 2, 3)));
 
 
 #endif
diff --git a/posix/unix_socket.c b/posix/unix_socket.c
index 11c5d3e..fc9983b 100644
--- a/posix/unix_socket.c
+++ b/posix/unix_socket.c
@@ -347,7 +347,7 @@ void *unix_listen(void * BATMANUNUSED(arg)) {
 							} else if ( buff[0] == 'q' ) {
 
 								if ( status > 2 ) {
-									debug_output(3, "Unix socket: changing purge timeout from: %i to: %i\n", purge_timeout, strtol(buff + 2, NULL, 10));
+									debug_output(3, "Unix socket: changing purge timeout from: %i to: %li\n", purge_timeout, strtol(buff + 2, NULL, 10));
 									purge_timeout = strtol(buff + 2, NULL, 10);
 								}
 
diff --git a/profile.c b/profile.c
index c76ae8d..11d8aa9 100644
--- a/profile.c
+++ b/profile.c
@@ -23,6 +23,7 @@
 
 #include "os.h"
 #include "batman.h"
+#include <inttypes.h>
 
 
 
@@ -67,7 +68,7 @@ void prof_print(void) {
 
 	for ( index = 0; index < PROF_COUNT; index++ ) {
 
-		debug_output( 5, "   %''30s: cpu time = %10.3f, calls = %''10i, avg time per call = %4.10f \n", prof_container[index].name, (float)prof_container[index].total_time/CLOCKS_PER_SEC, prof_container[index].calls, ( prof_container[index].calls == 0 ? 0.0 : ( ( (float)prof_container[index].total_time/CLOCKS_PER_SEC ) / (float)prof_container[index].calls ) ) );
+		debug_output( 5, "   %30s: cpu time = %10.3f, calls = %10"PRId64", avg time per call = %4.10f \n", prof_container[index].name, (float)prof_container[index].total_time/CLOCKS_PER_SEC, prof_container[index].calls, ( prof_container[index].calls == 0 ? 0.0 : ( ( (float)prof_container[index].total_time/CLOCKS_PER_SEC ) / (float)prof_container[index].calls ) ) );
 
 	}
 
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [B.A.T.M.A.N.] [PATCH 08/13] batmand: Clear screen using ANSI escape codes
  2013-09-12 20:58 [B.A.T.M.A.N.] batmand: Debian patches for 0.3.2+51+g1e275d9-1 Sven Eckelmann
                   ` (6 preceding siblings ...)
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 07/13] batmand: Fix printf format strings Sven Eckelmann
@ 2013-09-12 20:58 ` Sven Eckelmann
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 09/13] batmand: Use POSIX daemon function instead of self-written one Sven Eckelmann
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Sven Eckelmann @ 2013-09-12 20:58 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Sven Eckelmann

It is not necessary to call an external binary to clear the screen of a default
unix terminal emulator. The external call using system("clear") may be used by
an attacker to get untrusted code called with an higher privilege because
batmand has to be run using uid 0.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 posix/init.c        | 3 ++-
 posix/posix.c       | 3 ++-
 posix/unix_socket.c | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/posix/init.c b/posix/init.c
index 9cefe73..308e476 100644
--- a/posix/init.c
+++ b/posix/init.c
@@ -719,7 +719,8 @@ more_hna:
 				} else if ( strncmp( buff_ptr, "BOD", 3 ) == 0 ) {
 
 					if ( !batch_mode )
-						system( "clear" );
+						/* clear screen, set cursor back to 0,0 */
+						printf("\033[2J\033[0;0f");
 
 				} else {
 
diff --git a/posix/posix.c b/posix/posix.c
index 81cd2e1..5cdf417 100644
--- a/posix/posix.c
+++ b/posix/posix.c
@@ -181,7 +181,8 @@ static void bat_wait( int32_t T, int32_t t ) {
 
 void print_animation( void ) {
 
-	system( "clear" );
+	/* clear screen, set cursor back to 0,0 */
+	printf("\033[2J\033[0;0f");
 	BAT_LOGO_END( 0, 50 );
 
 	sym_print( 0, 3, "." );
diff --git a/posix/unix_socket.c b/posix/unix_socket.c
index fc9983b..11c96b2 100644
--- a/posix/unix_socket.c
+++ b/posix/unix_socket.c
@@ -100,7 +100,8 @@ void debug_output(int8_t debug_prio, const char *format, ...) {
 			dprintf(debug_level_info->fd, "[%10u] ", get_time_msec());
 
 		if (((debug_level == 1) || (debug_level == 2)) && (debug_level_info->fd == 1) && (strncmp(format, "BOD", 3) == 0))
-			system("clear");
+			/* clear screen, set cursor back to 0,0 */
+			printf("\033[2J\033[0;0f");
 
 		if (((debug_level != 1) && (debug_level != 2)) || (debug_level_info->fd != 1) || (strncmp(format, "EOD", 3) != 0))
 			vdprintf(debug_level_info->fd, format, args);
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [B.A.T.M.A.N.] [PATCH 09/13] batmand: Use POSIX daemon function instead of self-written one
  2013-09-12 20:58 [B.A.T.M.A.N.] batmand: Debian patches for 0.3.2+51+g1e275d9-1 Sven Eckelmann
                   ` (7 preceding siblings ...)
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 08/13] batmand: Clear screen using ANSI escape codes Sven Eckelmann
@ 2013-09-12 20:58 ` Sven Eckelmann
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 10/13] batmand: Add missing includes and remove unused includes Sven Eckelmann
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Sven Eckelmann @ 2013-09-12 20:58 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Sven Eckelmann

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 posix/init.c | 45 ++-------------------------------------------
 1 file changed, 2 insertions(+), 43 deletions(-)

diff --git a/posix/init.c b/posix/init.c
index 308e476..3bc54b0 100644
--- a/posix/init.c
+++ b/posix/init.c
@@ -35,6 +35,7 @@
 #include <arpa/inet.h>
 #include <fcntl.h>
 #include <getopt.h>
+#include <unistd.h>
 
 
 #include "../os.h"
@@ -44,48 +45,6 @@
 int8_t stop;
 
 
-
-static int my_daemon(void) {
-
-	int fd;
-
-	switch( fork() ) {
-
-		case -1:
-			return -1;
-
-		case 0:
-			break;
-
-		default:
-			exit(EXIT_SUCCESS);
-
-	}
-
-	if ( setsid() == -1 )
-		return(-1);
-
-	/* Make certain we are not a session leader, or else we might reacquire a controlling terminal */
-	if ( fork() )
-		exit(EXIT_SUCCESS);
-
-	chdir( "/" );
-
-	if ( ( fd = open(_PATH_DEVNULL, O_RDWR, 0) ) != -1 ) {
-
-		dup2(fd, STDIN_FILENO);
-		dup2(fd, STDOUT_FILENO);
-		dup2(fd, STDERR_FILENO);
-
-		if ( fd > 2 )
-			close(fd);
-
-	}
-
-	return 0;
-
-}
-
 static void create_routing_pipe(void)
 {
 	int fd[2], pipe_opts;
@@ -534,7 +493,7 @@ void apply_init_args( int argc, char *argv[] ) {
 		/* daemonize */
 		if (debug_level == 0) {
 
-			if (my_daemon() < 0) {
+			if (daemon(0, 0) < 0) {
 
 				printf("Error - can't fork to background: %s\n", strerror(errno));
 				restore_defaults();
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [B.A.T.M.A.N.] [PATCH 10/13] batmand: Add missing includes and remove unused includes
  2013-09-12 20:58 [B.A.T.M.A.N.] batmand: Debian patches for 0.3.2+51+g1e275d9-1 Sven Eckelmann
                   ` (8 preceding siblings ...)
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 09/13] batmand: Use POSIX daemon function instead of self-written one Sven Eckelmann
@ 2013-09-12 20:58 ` Sven Eckelmann
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 11/13] batmand: Mark unused parameter in dummy functions Sven Eckelmann
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Sven Eckelmann @ 2013-09-12 20:58 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Sven Eckelmann

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 allocate.c          |  1 -
 batman.c            |  7 ++++++-
 batman.h            | 17 ++++++++---------
 bitarray.c          |  3 ---
 bitarray.h          |  1 +
 hna.c               | 10 ++++++++++
 hna.h               |  2 ++
 linux/kernel.c      |  7 ++-----
 linux/route.c       |  8 ++++++++
 linux/tun.c         |  6 +++++-
 list-batman.h       |  2 --
 originator.c        | 10 +++++++++-
 originator.h        |  3 ++-
 os.h                |  7 ++++++-
 packet.h            |  2 ++
 posix/init.c        | 12 ++++++++++--
 posix/posix.c       | 14 ++++++++++++--
 posix/tunnel.c      | 16 +++++++++++-----
 posix/unix_socket.c | 11 ++++++++++-
 profile.c           |  9 ++++++---
 profile.h           |  3 +++
 ring_buffer.c       |  2 +-
 ring_buffer.h       |  3 ---
 schedule.c          |  9 +++++++++
 schedule.h          |  3 +++
 types.h             |  7 +++++++
 26 files changed, 133 insertions(+), 42 deletions(-)

diff --git a/allocate.c b/allocate.c
index beedafe..4196dab 100644
--- a/allocate.c
+++ b/allocate.c
@@ -23,7 +23,6 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "os.h"
 #include "allocate.h"
diff --git a/batman.c b/batman.c
index a1e387c..39ef9be 100644
--- a/batman.c
+++ b/batman.c
@@ -25,7 +25,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
-#include <errno.h>
+#include <netinet/in.h>
 
 #include "os.h"
 #include "batman.h"
@@ -33,6 +33,11 @@
 #include "schedule.h"
 #include "hna.h"
 #include "types.h"
+#include "profile.h"
+#include "allocate.h"
+#include "hash.h"
+#include "bitarray.h"
+#include "packet.h"
 
 
 uint8_t debug_level = 0;
diff --git a/batman.h b/batman.h
index 05c48c1..9a00d1b 100644
--- a/batman.h
+++ b/batman.h
@@ -25,20 +25,15 @@
 #define _BATMAND_BATMAN_H
 
 #include <sys/types.h>
-#include <netinet/in.h>
 #include <pthread.h>
-#include <sys/un.h>
 #include <stdint.h>
-#include <stdio.h>
+#include <sys/select.h>
+#include <sys/un.h>
+#include <netinet/in.h>
 
 #define TYPE_OF_WORD uintmax_t /* you should choose something big, if you don't want to waste cpu */
 
 #include "list-batman.h"
-#include "bitarray.h"
-#include "hash.h"
-#include "allocate.h"
-#include "profile.h"
-#include "ring_buffer.h"
 
 #ifndef SOURCE_VERSION
 #define SOURCE_VERSION "0.4"
@@ -192,7 +187,11 @@ extern uint8_t local_win_size;
 extern uint8_t num_words;
 extern uint8_t aggregation_enabled;
 
-#include "types.h" // can be removed as soon as these function have been cleaned up
+/* fwd declarations */
+struct batman_if;
+struct orig_node;
+struct neigh_node;
+
 int8_t batman(void);
 void usage(void);
 void verbose_usage(void);
diff --git a/bitarray.c b/bitarray.c
index 234f8a8..133f6e7 100644
--- a/bitarray.c
+++ b/bitarray.c
@@ -20,9 +20,6 @@
  */
 
 
-
-#include <stdio.h>              /* printf() */
-
 #include "bitarray.h"
 #include "os.h"
 
diff --git a/bitarray.h b/bitarray.h
index e0ca302..70449a0 100644
--- a/bitarray.h
+++ b/bitarray.h
@@ -22,6 +22,7 @@
 #ifndef _BATMAND_BITARRAY_H
 #define _BATMAND_BITARRAY_H
 
+#include <stdint.h>
 #include "batman.h"
 #define WORD_BIT_SIZE ( sizeof(TYPE_OF_WORD) * 8 )
 
diff --git a/hna.c b/hna.c
index b007ce5..f0d64e1 100644
--- a/hna.c
+++ b/hna.c
@@ -21,13 +21,23 @@
 
 
 
+#include "allocate.h"
 #include "hna.h"
 #include "os.h"
 #include "hash.h"
+#include "packet.h"
+#include "types.h"
 
 #include <errno.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <arpa/inet.h>
+#include <netinet/in.h>
+#include <pthread.h>
+#include <stddef.h>
+#include <string.h>
+#include <sys/socket.h>
+
 
 
 unsigned char *hna_buff_local = NULL;
diff --git a/hna.h b/hna.h
index 99f7664..e5a6833 100644
--- a/hna.h
+++ b/hna.h
@@ -22,6 +22,8 @@
 #ifndef _BATMAND_HNA_H
 #define _BATMAND_HNA_H
 
+#include <stdint.h>
+#include "list-batman.h"
 #include "batman.h"
 
 
diff --git a/linux/kernel.c b/linux/kernel.c
index 08c7e20..141981d 100644
--- a/linux/kernel.c
+++ b/linux/kernel.c
@@ -22,17 +22,14 @@
 
 
 #include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <unistd.h>
+#include <stdint.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <inttypes.h>
 #include <net/if.h>
+#include <string.h>
 
 #include "../os.h"
-#include "../batman.h"
-
 
 #define IOCGETNWDEV 1
 
diff --git a/linux/route.c b/linux/route.c
index 12f7734..1945d22 100644
--- a/linux/route.c
+++ b/linux/route.c
@@ -29,6 +29,14 @@
 #include <linux/netlink.h>
 #include <linux/rtnetlink.h>
 #include <sys/socket.h>
+#include <netinet/in.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/uio.h>
+#include "../allocate.h"
+#include "../bitarray.h"
 
 #include "../os.h"
 #include "../batman.h"
diff --git a/linux/tun.c b/linux/tun.c
index ac5e069..adeea56 100644
--- a/linux/tun.c
+++ b/linux/tun.c
@@ -26,16 +26,20 @@
 #include <errno.h>
 #include <sys/ioctl.h>
 #include <arpa/inet.h>    /* inet_ntop() */
-#include <netinet/ip.h>   /* iph */
+#include <netinet/in.h>
 #include <linux/if_tun.h> /* TUNSETPERSIST, ... */
 #include <linux/if.h>     /* ifr_if, ifr_tun */
 #include <sys/socket.h>
 #include <stdio.h>
 #include <stdlib.h>       /* system() */
 #include <sys/wait.h>     /* WEXITSTATUS */
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
 
 #include "../os.h"
 #include "../batman.h"
+#include "../types.h"
 
 #define IPTABLES_ADD_MASQ "iptables -t nat -A POSTROUTING -o %s -j MASQUERADE"
 #define IPTABLES_DEL_MASQ "iptables -t nat -D POSTROUTING -o %s -j MASQUERADE"
diff --git a/list-batman.h b/list-batman.h
index cb97bf5..a0103f1 100644
--- a/list-batman.h
+++ b/list-batman.h
@@ -20,8 +20,6 @@
  */
 
 
-#include <stddef.h> /* offsetof() */
-
 #ifndef _LINUX_LIST_H
 #define _LINUX_LIST_H
 
diff --git a/originator.c b/originator.c
index 7de0e4d..f017741 100644
--- a/originator.c
+++ b/originator.c
@@ -22,12 +22,20 @@
 
 
 #include <string.h>
-#include <stdlib.h>
 #include <stdio.h>
+#include <netinet/in.h>
+#include <stddef.h>
+
+#include "list-batman.h"
+#include "packet.h"
 #include "os.h"
 #include "batman.h"
 #include "originator.h"
 #include "hna.h"
+#include "hash.h"
+#include "profile.h"
+#include "allocate.h"
+#include "ring_buffer.h"
 #include "types.h"
 
 struct neigh_node * create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node, uint32_t neigh, struct batman_if *if_incoming) {
diff --git a/originator.h b/originator.h
index 5ce5162..0c92150 100644
--- a/originator.h
+++ b/originator.h
@@ -22,7 +22,8 @@
 #ifndef _BATMAND_ORIGINATOR_H
 #define _BATMAND_ORIGINATOR_H
 
-#include "batman.h"
+#include <stdint.h>
+
 #include "types.h"
 
 
diff --git a/os.h b/os.h
index 2272030..cab762c 100644
--- a/os.h
+++ b/os.h
@@ -22,7 +22,12 @@
 #ifndef _BATMAND_OS_H
 #define _BATMAND_OS_H
 
-#include "batman.h"
+#include <stddef.h>
+#include <stdint.h>
+#include <netinet/in.h>
+
+
+#include "types.h"
 
 #ifdef __GNUC_MINOR__
 #define NO_RETURN  __attribute__ ((__noreturn__))
diff --git a/packet.h b/packet.h
index 3a98ea5..cbecd22 100644
--- a/packet.h
+++ b/packet.h
@@ -22,6 +22,8 @@
 #ifndef _BATMAND_PACKET_H
 #define _BATMAND_PACKET_H
 
+#include <stdint.h>
+
 #define COMPAT_VERSION 5
 #define VIS_COMPAT_VERSION 23
 
diff --git a/posix/init.c b/posix/init.c
index 3bc54b0..cb710f2 100644
--- a/posix/init.c
+++ b/posix/init.c
@@ -21,13 +21,13 @@
 
 
 
+#include <stdint.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <syslog.h>
 #include <errno.h>
 #include <signal.h>
-#include <paths.h>
 #include <string.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
@@ -35,12 +35,20 @@
 #include <arpa/inet.h>
 #include <fcntl.h>
 #include <getopt.h>
-#include <unistd.h>
+#include <netinet/in.h>
+#include <pthread.h>
+#include <sys/select.h>
+#include <sys/un.h>
 
 
 #include "../os.h"
 #include "../batman.h"
 #include "../hna.h"
+#include "../allocate.h"
+#include "../bitarray.h"
+#include "../list-batman.h"
+#include "../packet.h"
+#include "../types.h"
 
 int8_t stop;
 
diff --git a/posix/posix.c b/posix/posix.c
index 5cdf417..084b40c 100644
--- a/posix/posix.c
+++ b/posix/posix.c
@@ -31,13 +31,23 @@
 #include <syslog.h>
 #include <sys/socket.h>
 #include <sys/times.h>
-#include <sys/ioctl.h>
 #include <sys/wait.h>
-#include <net/if.h>
+#include <netinet/in.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <sys/select.h>
+#include <sys/time.h>
+#include <time.h>
+
 
 #include "../os.h"
 #include "../batman.h"
 #include "../hna.h"
+#include "../allocate.h"
+#include "../hash.h"
+#include "../packet.h"
+#include "../types.h"
+#include "../list-batman.h"
 
 
 #define BAT_LOGO_PRINT(x,y,z) printf( "\x1B[%i;%iH%c", y + 1, x, z )                      /* write char 'z' into column 'x', row 'y' */
diff --git a/posix/tunnel.c b/posix/tunnel.c
index 3290eaa..08c56a2 100644
--- a/posix/tunnel.c
+++ b/posix/tunnel.c
@@ -23,21 +23,27 @@
 
 #include <errno.h>
 #include <unistd.h>
-#include <stdlib.h>
 #include <string.h>
-#include <arpa/inet.h>
-#include <sys/ioctl.h>
 #include <sys/socket.h>
-#include <netinet/in_systm.h>
 #include <netinet/ip.h>
 #include <netinet/udp.h>
-#include <netinet/tcp.h>
 #include <net/if.h>
 #include <fcntl.h>        /* open(), O_RDWR */
+#include <netinet/in.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <sys/select.h>
+#include <sys/time.h>
+#include <sys/types.h>
 
 
 #include "../os.h"
 #include "../batman.h"
+#include "../allocate.h"
+#include "../hash.h"
+#include "../list-batman.h"
+#include "../packet.h"
+#include "../types.h"
 
 
 
diff --git a/posix/unix_socket.c b/posix/unix_socket.c
index 11c96b2..943a652 100644
--- a/posix/unix_socket.c
+++ b/posix/unix_socket.c
@@ -32,11 +32,20 @@
 #include <unistd.h>
 #include <sys/socket.h>
 #include <arpa/inet.h>
-
+#include <netinet/in.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <sys/select.h>
+#include <sys/un.h>
+#include <sys/types.h>
 
 #include "../os.h"
 #include "../batman.h"
 #include "../hna.h"
+#include "../allocate.h"
+#include "../list-batman.h"
+#include "../packet.h"
+#include "../types.h"
 
 
 void debug_output(int8_t debug_prio, const char *format, ...) {
diff --git a/profile.c b/profile.c
index 11d8aa9..9692d7d 100644
--- a/profile.c
+++ b/profile.c
@@ -21,9 +21,12 @@
 
 
 
-#include "os.h"
-#include "batman.h"
 #include <inttypes.h>
+#include <stdint.h>
+#include <time.h>
+
+#include "profile.h"
+#include "os.h"
 
 
 
@@ -78,7 +81,7 @@ void prof_print(void) {
 #else
 
 
-void prof_init( int32_t index, char *name ) {
+void prof_init( int32_t index, const char *name ) {
 
 }
 
diff --git a/profile.h b/profile.h
index e50bf70..07cffc1 100644
--- a/profile.h
+++ b/profile.h
@@ -22,6 +22,9 @@
 #ifndef _BATMAND_PROFILE_H
 #define _BATMAND_PROFILE_H
 
+#include <stdint.h>
+#include <time.h>
+
 enum {
 
 	PROF_choose_gw,
diff --git a/ring_buffer.c b/ring_buffer.c
index 7a0c8c8..45bd175 100644
--- a/ring_buffer.c
+++ b/ring_buffer.c
@@ -20,7 +20,7 @@
  */
 
 
-
+#include "batman.h"
 #include "ring_buffer.h"
 
 
diff --git a/ring_buffer.h b/ring_buffer.h
index c1679d9..b291868 100644
--- a/ring_buffer.h
+++ b/ring_buffer.h
@@ -23,9 +23,6 @@
 #define _BATMAND_RING_BUFFER_H
 
 #include <stdint.h>
-#include "batman.h"
-
-
 
 void ring_buffer_set(uint8_t tq_recv[], uint8_t *tq_index, uint8_t value);
 uint8_t ring_buffer_avg(uint8_t tq_recv[]);
diff --git a/schedule.c b/schedule.c
index 83576c8..3e65d68 100644
--- a/schedule.c
+++ b/schedule.c
@@ -23,6 +23,15 @@
 
 #include <string.h>
 #include <stdlib.h>
+#include <netinet/in.h>
+
+#include "list-batman.h"
+#include "packet.h"
+#include "types.h"
+#include "allocate.h"
+#include "hash.h"
+#include "profile.h"
+#include "bitarray.h"
 #include "os.h"
 #include "batman.h"
 #include "schedule.h"
diff --git a/schedule.h b/schedule.h
index 8bd54cd..30165e3 100644
--- a/schedule.h
+++ b/schedule.h
@@ -22,6 +22,9 @@
 #ifndef _BATMAND_SCHEDULE_H
 #define _BATMAND_SCHEDULE_H
 
+#include <stdint.h>
+#include "types.h"
+
 void schedule_own_packet( struct batman_if *batman_if );
 void schedule_forward_packet(struct orig_node *orig_node, struct bat_packet *in, uint32_t neigh, uint8_t directlink, int16_t hna_buff_len, struct batman_if *if_outgoing, uint32_t curr_time);
 void send_outstanding_packets(uint32_t curr_time);
diff --git a/types.h b/types.h
index 6ae336e..3716b1f 100644
--- a/types.h
+++ b/types.h
@@ -22,7 +22,14 @@
 #ifndef _BATMAND_TYPES_H
 #define _BATMAND_TYPES_H
 
+#include <stdint.h>
+#include <pthread.h>
+#include <sys/un.h>
+#include <netinet/in.h>
+
+#include "list-batman.h"
 #include "packet.h"
+#include "batman.h"
 
 struct orig_node {                /* structure for orig_list maintaining nodes of mesh */
 	uint32_t orig;
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [B.A.T.M.A.N.] [PATCH 11/13] batmand: Mark unused parameter in dummy functions
  2013-09-12 20:58 [B.A.T.M.A.N.] batmand: Debian patches for 0.3.2+51+g1e275d9-1 Sven Eckelmann
                   ` (9 preceding siblings ...)
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 10/13] batmand: Add missing includes and remove unused includes Sven Eckelmann
@ 2013-09-12 20:58 ` Sven Eckelmann
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 12/13] batmand: Fix preprocessor check for defined DEBUG_MALLOC && MEMORY_USAGE Sven Eckelmann
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Sven Eckelmann @ 2013-09-12 20:58 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Sven Eckelmann

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 allocate.c | 4 +++-
 profile.c  | 7 ++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/allocate.c b/allocate.c
index 4196dab..c6c3082 100644
--- a/allocate.c
+++ b/allocate.c
@@ -421,6 +421,8 @@ void debugFree(void *memoryParameter, int tag)
 
 #else
 
+#include "batman.h"
+
 void checkIntegrity(void)
 {
 }
@@ -459,7 +461,7 @@ void *debugRealloc(void *memory, uint32_t length, int32_t tag)
 	return result;
 }
 
-void debugFree(void *memory, int32_t tag)
+void debugFree(void *memory, int32_t BATMANUNUSED(tag))
 {
 	free(memory);
 }
diff --git a/profile.c b/profile.c
index 9692d7d..a063750 100644
--- a/profile.c
+++ b/profile.c
@@ -80,20 +80,21 @@ void prof_print(void) {
 
 #else
 
+#include "batman.h"
 
-void prof_init( int32_t index, const char *name ) {
+void prof_init( int32_t BATMANUNUSED(index), const char *BATMANUNUSED(name) ) {
 
 }
 
 
 
-void prof_start( int32_t index ) {
+void prof_start( int32_t BATMANUNUSED(index) ) {
 
 }
 
 
 
-void prof_stop( int32_t index ) {
+void prof_stop( int32_t BATMANUNUSED(index) ) {
 
 }
 
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [B.A.T.M.A.N.] [PATCH 12/13] batmand: Fix preprocessor check for defined DEBUG_MALLOC && MEMORY_USAGE
  2013-09-12 20:58 [B.A.T.M.A.N.] batmand: Debian patches for 0.3.2+51+g1e275d9-1 Sven Eckelmann
                   ` (10 preceding siblings ...)
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 11/13] batmand: Mark unused parameter in dummy functions Sven Eckelmann
@ 2013-09-12 20:58 ` Sven Eckelmann
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 13/13] batmand: Add error for MEMORY_USAGE dependency Sven Eckelmann
  2013-09-15 15:52 ` [B.A.T.M.A.N.] batmand: Debian patches for 0.3.2+51+g1e275d9-1 Elektra
  13 siblings, 0 replies; 15+ messages in thread
From: Sven Eckelmann @ 2013-09-12 20:58 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Sven Eckelmann

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 batman.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/batman.c b/batman.c
index 39ef9be..89b3bf1 100644
--- a/batman.c
+++ b/batman.c
@@ -47,7 +47,7 @@ uint8_t debug_level = 0;
 
 uint8_t debug_level_max = 5;
 
-#elif DEBUG_MALLOC && MEMORY_USAGE
+#elif defined DEBUG_MALLOC && defined MEMORY_USAGE
 
 uint8_t debug_level_max = 5;
 
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [B.A.T.M.A.N.] [PATCH 13/13] batmand: Add error for MEMORY_USAGE dependency
  2013-09-12 20:58 [B.A.T.M.A.N.] batmand: Debian patches for 0.3.2+51+g1e275d9-1 Sven Eckelmann
                   ` (11 preceding siblings ...)
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 12/13] batmand: Fix preprocessor check for defined DEBUG_MALLOC && MEMORY_USAGE Sven Eckelmann
@ 2013-09-12 20:58 ` Sven Eckelmann
  2013-09-15 15:52 ` [B.A.T.M.A.N.] batmand: Debian patches for 0.3.2+51+g1e275d9-1 Elektra
  13 siblings, 0 replies; 15+ messages in thread
From: Sven Eckelmann @ 2013-09-12 20:58 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Sven Eckelmann

Print error during build when MEMORY_USAGE is requested but the build is done
without DEBUG_MALLOC.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 allocate.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/allocate.c b/allocate.c
index c6c3082..fe61847 100644
--- a/allocate.c
+++ b/allocate.c
@@ -32,6 +32,10 @@
 
 #if defined DEBUG_MALLOC
 
+#ifndef MEMORY_USAGE
+#error DEBUG_MALLOC can only be used together with MEMORY_USAGE
+#endif
+
 static pthread_mutex_t chunk_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 struct chunkHeader *chunkList = NULL;
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [B.A.T.M.A.N.] batmand: Debian patches for 0.3.2+51+g1e275d9-1
  2013-09-12 20:58 [B.A.T.M.A.N.] batmand: Debian patches for 0.3.2+51+g1e275d9-1 Sven Eckelmann
                   ` (12 preceding siblings ...)
  2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 13/13] batmand: Add error for MEMORY_USAGE dependency Sven Eckelmann
@ 2013-09-15 15:52 ` Elektra
  13 siblings, 0 replies; 15+ messages in thread
From: Elektra @ 2013-09-15 15:52 UTC (permalink / raw)
  To: b.a.t.m.a.n

Hello –

applied in a27537a...

Thanks for your kind support.

Cheers,
Elektra

-- 
Elektra <onelektra@gmx.net>

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2013-09-15 15:52 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-12 20:58 [B.A.T.M.A.N.] batmand: Debian patches for 0.3.2+51+g1e275d9-1 Sven Eckelmann
2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 01/13] batmand: Disable strict-aliasing rules Sven Eckelmann
2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 02/13] batmand: Add CFLAGS to the linker step Sven Eckelmann
2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 03/13] batmand: Don't fail rebuild when header is removed Sven Eckelmann
2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 04/13] batmand: Add include guards to avoid redundant declarations or include loops Sven Eckelmann
2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 05/13] batmand: Avoid assigning const buffer to non-const pointer Sven Eckelmann
2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 06/13] batmand: Fix preprocessor check for defined NO_POLICY_ROUTING Sven Eckelmann
2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 07/13] batmand: Fix printf format strings Sven Eckelmann
2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 08/13] batmand: Clear screen using ANSI escape codes Sven Eckelmann
2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 09/13] batmand: Use POSIX daemon function instead of self-written one Sven Eckelmann
2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 10/13] batmand: Add missing includes and remove unused includes Sven Eckelmann
2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 11/13] batmand: Mark unused parameter in dummy functions Sven Eckelmann
2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 12/13] batmand: Fix preprocessor check for defined DEBUG_MALLOC && MEMORY_USAGE Sven Eckelmann
2013-09-12 20:58 ` [B.A.T.M.A.N.] [PATCH 13/13] batmand: Add error for MEMORY_USAGE dependency Sven Eckelmann
2013-09-15 15:52 ` [B.A.T.M.A.N.] batmand: Debian patches for 0.3.2+51+g1e275d9-1 Elektra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.