1
0

004-hostapd-Add-possibility-to-send-debug-messages-to-sy.patch 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. From cc3dae85bd694506cdea66ae532d452fb8716297 Mon Sep 17 00:00:00 2001
  2. From: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
  3. Date: Mon, 23 Jan 2017 13:55:04 +0100
  4. Subject: [PATCH] hostapd: Add possibility to send debug messages to syslog
  5. We can only send module specific messages to syslog and not debug
  6. messages printed with wpa_printf. Add an extra command line parameter
  7. '-s' to allow it. The feature is enabled with compile flag
  8. CONFIG_DEBUG_SYSLOG as for wpa_supplicant and behaves in the same manner
  9. as the wpa_supplicant -s command line argument.
  10. Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
  11. ---
  12. hostapd/Android.mk | 4 ++++
  13. hostapd/Makefile | 4 ++++
  14. hostapd/defconfig | 3 +++
  15. hostapd/main.c | 19 ++++++++++++++++++-
  16. src/utils/wpa_debug.c | 2 +-
  17. src/utils/wpa_debug.h | 3 +++
  18. 6 files changed, 33 insertions(+), 2 deletions(-)
  19. --- a/hostapd/Android.mk
  20. +++ b/hostapd/Android.mk
  21. @@ -952,6 +952,10 @@ ifdef CONFIG_NO_STDOUT_DEBUG
  22. L_CFLAGS += -DCONFIG_NO_STDOUT_DEBUG
  23. endif
  24. +ifdef CONFIG_DEBUG_SYSLOG
  25. +L_CFLAGS += -DCONFIG_DEBUG_SYSLOG
  26. +endif
  27. +
  28. ifdef CONFIG_DEBUG_LINUX_TRACING
  29. L_CFLAGS += -DCONFIG_DEBUG_LINUX_TRACING
  30. endif
  31. --- a/hostapd/Makefile
  32. +++ b/hostapd/Makefile
  33. @@ -997,6 +997,10 @@ ifdef CONFIG_NO_STDOUT_DEBUG
  34. CFLAGS += -DCONFIG_NO_STDOUT_DEBUG
  35. endif
  36. +ifdef CONFIG_DEBUG_SYSLOG
  37. +CFLAGS += -DCONFIG_DEBUG_SYSLOG
  38. +endif
  39. +
  40. ifdef CONFIG_DEBUG_LINUX_TRACING
  41. CFLAGS += -DCONFIG_DEBUG_LINUX_TRACING
  42. endif
  43. --- a/hostapd/defconfig
  44. +++ b/hostapd/defconfig
  45. @@ -166,6 +166,9 @@ CONFIG_IPV6=y
  46. # Disabled by default.
  47. #CONFIG_DEBUG_FILE=y
  48. +# Send debug messages to syslog instead of stdout
  49. +#CONFIG_DEBUG_SYSLOG=y
  50. +
  51. # Add support for sending all debug messages (regardless of debug verbosity)
  52. # to the Linux kernel tracing facility. This helps debug the entire stack by
  53. # making it easy to record everything happening from the driver up into the
  54. --- a/hostapd/main.c
  55. +++ b/hostapd/main.c
  56. @@ -108,6 +108,10 @@ static void hostapd_logger_cb(void *ctx,
  57. module_str ? module_str : "",
  58. module_str ? ": " : "", txt);
  59. +#ifdef CONFIG_DEBUG_SYSLOG
  60. + if (wpa_debug_syslog)
  61. + conf_stdout = 0;
  62. +#endif /* CONFIG_DEBUG_SYSLOG */
  63. if ((conf_stdout & module) && level >= conf_stdout_level) {
  64. wpa_debug_print_timestamp();
  65. wpa_printf(MSG_INFO, "%s", format);
  66. @@ -484,6 +488,9 @@ static void usage(void)
  67. " (records all messages regardless of debug verbosity)\n"
  68. #endif /* CONFIG_DEBUG_LINUX_TRACING */
  69. " -i list of interface names to use\n"
  70. +#ifdef CONFIG_DEBUG_SYSLOG
  71. + " -s log output to syslog instead of stdout\n"
  72. +#endif /* CONFIG_DEBUG_SYSLOG */
  73. " -S start all the interfaces synchronously\n"
  74. " -t include timestamps in some debug messages\n"
  75. " -v show hostapd version\n");
  76. @@ -661,7 +668,7 @@ int main(int argc, char *argv[])
  77. dl_list_init(&interfaces.global_ctrl_dst);
  78. for (;;) {
  79. - c = getopt(argc, argv, "b:Bde:f:hi:KP:STtu:vg:G:");
  80. + c = getopt(argc, argv, "b:Bde:f:hi:KP:sSTtu:vg:G:");
  81. if (c < 0)
  82. break;
  83. switch (c) {
  84. @@ -718,6 +725,11 @@ int main(int argc, char *argv[])
  85. bss_config = tmp_bss;
  86. bss_config[num_bss_configs++] = optarg;
  87. break;
  88. +#ifdef CONFIG_DEBUG_SYSLOG
  89. + case 's':
  90. + wpa_debug_syslog = 1;
  91. + break;
  92. +#endif /* CONFIG_DEBUG_SYSLOG */
  93. case 'S':
  94. start_ifaces_in_sync = 1;
  95. break;
  96. @@ -746,6 +758,10 @@ int main(int argc, char *argv[])
  97. wpa_debug_open_file(log_file);
  98. else
  99. wpa_debug_setup_stdout();
  100. +#ifdef CONFIG_DEBUG_SYSLOG
  101. + if (wpa_debug_syslog)
  102. + wpa_debug_open_syslog();
  103. +#endif /* CONFIG_DEBUG_SYSLOG */
  104. #ifdef CONFIG_DEBUG_LINUX_TRACING
  105. if (enable_trace_dbg) {
  106. int tret = wpa_debug_open_linux_tracing();
  107. @@ -882,6 +898,7 @@ int main(int argc, char *argv[])
  108. hostapd_global_deinit(pid_file, interfaces.eloop_initialized);
  109. os_free(pid_file);
  110. + wpa_debug_close_syslog();
  111. if (log_file)
  112. wpa_debug_close_file();
  113. wpa_debug_close_linux_tracing();
  114. --- a/src/utils/wpa_debug.c
  115. +++ b/src/utils/wpa_debug.c
  116. @@ -13,7 +13,7 @@
  117. #ifdef CONFIG_DEBUG_SYSLOG
  118. #include <syslog.h>
  119. -static int wpa_debug_syslog = 0;
  120. +int wpa_debug_syslog = 0;
  121. #endif /* CONFIG_DEBUG_SYSLOG */
  122. #ifdef CONFIG_DEBUG_LINUX_TRACING
  123. --- a/src/utils/wpa_debug.h
  124. +++ b/src/utils/wpa_debug.h
  125. @@ -14,6 +14,9 @@
  126. extern int wpa_debug_level;
  127. extern int wpa_debug_show_keys;
  128. extern int wpa_debug_timestamp;
  129. +#ifdef CONFIG_DEBUG_SYSLOG
  130. +extern int wpa_debug_syslog;
  131. +#endif /* CONFIG_DEBUG_SYSLOG */
  132. /* Debugging function - conditional printf and hex dump. Driver wrappers can
  133. * use these for debugging purposes. */