You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
6.3 KiB

  1. diff --git a/include/config.h b/include/config.h
  2. index 5212c69..ac948ba 100644
  3. --- a/include/config.h
  4. +++ b/include/config.h
  5. @@ -1,69 +1,69 @@
  6. -/*
  7. - * Copyright (c) 2015 Mike Maraya <mike[dot]maraya[at]gmail[dot]com>
  8. - * All rights reserved.
  9. - *
  10. - * This file is subject to the terms and conditions defined in
  11. - * https://github.com/mmaraya/port-mirroring/blob/master/LICENSE,
  12. - * which is part of this software package.
  13. - *
  14. - */
  15. -
  16. -#ifndef PORT_MIRRORING_UTIL_H_
  17. -#define PORT_MIRRORING_UTIL_H_
  18. -
  19. -#include <errno.h>
  20. -#include <net/if.h>
  21. -#include <netinet/in.h>
  22. -#include <stdint.h>
  23. -#include <stdio.h>
  24. -#include <stdlib.h>
  25. -#include <string.h>
  26. -#include <syslog.h>
  27. -#include <linux/limits.h>
  28. -
  29. -#define OPTION_MAX 254 /* max value for program options */
  30. -#define TIMEBUF 32 /* max timestamp length RFC3339 */
  31. -#define SRC_MAX 4 /* maxium number of source network interfaces */
  32. -#define PFE_MAX 80 /* maximum length of packet filter expression */
  33. -#define MACADDRLEN 6 /* length of a MAC address */
  34. -
  35. -// port-mirroring configuration bit flags
  36. -#define PM_DAEMON 0x01 /* run as background process */
  37. -#define PM_DEBUG 0x02 /* display debugging messages to console */
  38. -#define PM_TZSP 0x04 /* send packets using TaZmen Sniffer Protocol */
  39. -#define PM_DST_IF 0x08 /* destination is a network interface */
  40. -#define PM_DST_IP 0x10 /* destination is an internet protocol address */
  41. -#define PM_PROMISC 0x20 /* place source interface in promiscuous mode */
  42. -#define PM_SYSLOG 0x40 /* log messages to syslog facility */
  43. -
  44. -// if no configuration file is specified, look through these in order
  45. -#define CFG_PATH_1 "/etc/config/port-mirroring"
  46. -#define CFG_PATH_2 "/etc/port-mirroring"
  47. -#define CFG_PATH_3 "port-mirroring.conf"
  48. -
  49. -// default program id file
  50. -#define PID_PATH "/var/run/port-mirroring.pid"
  51. -
  52. -// program-wide configuration settings and variables
  53. -struct pm_cfg
  54. -{
  55. - char *cfg_file; /* path to configuration file */
  56. - uint8_t flags; /* boolean setting bitmask */
  57. - char src[SRC_MAX][IFNAMSIZ]; /* source network interfaces */
  58. - char dst_if[IFNAMSIZ]; /* destination network interface */
  59. - in_addr_t dst_ip; /* destination IP address */
  60. - char pfe[PFE_MAX]; /* tcpdump packet filter expression */
  61. - char *pid_file; /* path to process id file */
  62. - int src_count; /* number of source ports */
  63. - char src_mac[MACADDRLEN]; /* source MAC address */
  64. - char dst_mac[MACADDRLEN]; /* destination MAC address */
  65. - time_t init_time; /* used to check for timeouts */
  66. - int packet_count; /* number of packets processed */
  67. -};
  68. -
  69. -void find_cfg(struct pm_cfg *cfg);
  70. -char * printMACStr(const char *mac);
  71. -char * getUCIItem(char *buf, char *item);
  72. -int getUCIConf(char *buf, char *option, char *value);
  73. -
  74. -#endif // PORT_MIRRORING_UTIL_H_
  75. +/*
  76. + * Copyright (c) 2015 Mike Maraya <mike[dot]maraya[at]gmail[dot]com>
  77. + * All rights reserved.
  78. + *
  79. + * This file is subject to the terms and conditions defined in
  80. + * https://github.com/mmaraya/port-mirroring/blob/master/LICENSE,
  81. + * which is part of this software package.
  82. + *
  83. + */
  84. +
  85. +#ifndef PORT_MIRRORING_UTIL_H_
  86. +#define PORT_MIRRORING_UTIL_H_
  87. +
  88. +#include <errno.h>
  89. +#include <net/if.h>
  90. +#include <netinet/in.h>
  91. +#include <stdint.h>
  92. +#include <stdio.h>
  93. +#include <stdlib.h>
  94. +#include <string.h>
  95. +#include <syslog.h>
  96. +#include <linux/limits.h>
  97. +
  98. +#define OPTION_MAX 254 /* max value for program options */
  99. +#define TIMEBUF 32 /* max timestamp length RFC3339 */
  100. +#define SRC_MAX 4 /* maxium number of source network interfaces */
  101. +#define PFE_MAX 80 /* maximum length of packet filter expression */
  102. +#define MACADDRLEN 6 /* length of a MAC address */
  103. +
  104. +// port-mirroring configuration bit flags
  105. +#define PM_DAEMON 0x01 /* run as background process */
  106. +#define PM_DEBUG 0x02 /* display debugging messages to console */
  107. +#define PM_TZSP 0x04 /* send packets using TaZmen Sniffer Protocol */
  108. +#define PM_DST_IF 0x08 /* destination is a network interface */
  109. +#define PM_DST_IP 0x10 /* destination is an internet protocol address */
  110. +#define PM_PROMISC 0x20 /* place source interface in promiscuous mode */
  111. +#define PM_SYSLOG 0x40 /* log messages to syslog facility */
  112. +
  113. +// if no configuration file is specified, look through these in order
  114. +#define CFG_PATH_1 "/etc/config/port-mirroring"
  115. +#define CFG_PATH_2 "/etc/port-mirroring"
  116. +#define CFG_PATH_3 "port-mirroring.conf"
  117. +
  118. +// default program id file
  119. +#define PID_PATH "/var/run/port-mirroring.pid"
  120. +
  121. +// program-wide configuration settings and variables
  122. +struct pm_cfg
  123. +{
  124. + char *cfg_file; /* path to configuration file */
  125. + uint8_t flags; /* boolean setting bitmask */
  126. + char src[SRC_MAX][IFNAMSIZ]; /* source network interfaces */
  127. + char dst_if[IFNAMSIZ]; /* destination network interface */
  128. + in_addr_t dst_ip; /* destination IP address */
  129. + char pfe[PFE_MAX]; /* tcpdump packet filter expression */
  130. + char *pid_file; /* path to process id file */
  131. + int src_count; /* number of source ports */
  132. + char src_mac[MACADDRLEN]; /* source MAC address */
  133. + char dst_mac[MACADDRLEN]; /* destination MAC address */
  134. + time_t init_time; /* used to check for timeouts */
  135. + int packet_count; /* number of packets processed */
  136. +};
  137. +
  138. +void find_cfg(struct pm_cfg *cfg);
  139. +char * printMACStr(const char *mac);
  140. +char * getUCIItem(char *buf, char *item);
  141. +int getUCIConf(char *buf, char *option, char *value);
  142. +
  143. +#endif // PORT_MIRRORING_UTIL_H_