From b44c4fd7efeca107a388d0ded7c90c0f33ffe5b1 Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Sat, 1 Sep 2012 15:29:05 +0200 Subject: [PATCH] src: make mausezahn build, lots of cleanups on todo Signed-off-by: Daniel Borkmann --- Documentation/Manpages/mausezahn.8 | 3 + src/CMakeLists.txt | 5 +- src/{mz.c => mausezahn.c} | 2 - src/mausezahn/.gitignore | 4 ++ src/mausezahn/CMakeLists.txt | 110 +++++++++++++++++++++++++++++++++++++ src/mops.h | 6 +- src/mopsrx_arp.c | 2 +- src/mz.h | 36 ++++++------ 8 files changed, 142 insertions(+), 26 deletions(-) create mode 100644 Documentation/Manpages/mausezahn.8 rename src/{mz.c => mausezahn.c} (99%) create mode 100644 src/mausezahn/.gitignore create mode 100644 src/mausezahn/CMakeLists.txt diff --git a/Documentation/Manpages/mausezahn.8 b/Documentation/Manpages/mausezahn.8 new file mode 100644 index 00000000..29403f06 --- /dev/null +++ b/Documentation/Manpages/mausezahn.8 @@ -0,0 +1,3 @@ +=head1 NAME + +mausezahn diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e97ebf3e..795e175f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -79,12 +79,13 @@ add_manpage_target() include_directories(.) add_subdirectory(netsniff-ng) -add_subdirectory(ifpps) add_subdirectory(trafgen) +add_subdirectory(mausezahn) add_subdirectory(bpfc) +add_subdirectory(ifpps) +add_subdirectory(flowtop) add_subdirectory(astraceroute) add_subdirectory(curvetun) -add_subdirectory(flowtop) # Release notes install( diff --git a/src/mz.c b/src/mausezahn.c similarity index 99% rename from src/mz.c rename to src/mausezahn.c index 59406f17..247e8bd7 100644 --- a/src/mz.c +++ b/src/mausezahn.c @@ -16,8 +16,6 @@ * */ - - #include "mz.h" #include "cli.h" #include "mops.h" diff --git a/src/mausezahn/.gitignore b/src/mausezahn/.gitignore new file mode 100644 index 00000000..fe65a483 --- /dev/null +++ b/src/mausezahn/.gitignore @@ -0,0 +1,4 @@ +*.* + +!.gitignore +!CMakeLists.txt diff --git a/src/mausezahn/CMakeLists.txt b/src/mausezahn/CMakeLists.txt new file mode 100644 index 00000000..88eff42f --- /dev/null +++ b/src/mausezahn/CMakeLists.txt @@ -0,0 +1,110 @@ +project(mausezahn C) + +set(BUILD_STRING "generic") + +find_package(LibCLI) +find_package(Threads) +find_package(PCAP) +include(Pod2Man) + +if(LIBCLI_FOUND AND CMAKE_HAVE_PTHREAD_CREATE AND HAVE_LIBPCAP) + add_executable( + ${PROJECT_NAME} + ../mausezahn.c + ../layer1.c + ../layer2.c + ../layer3.c + ../layer4.c + ../init.c + ../hextools.c + ../tools.c + ../lookupdev.c + ../time.c + ../modifications.c + ../send_eth.c + ../send.c + ../cdp.c + ../rtp.c + ../dns.c + ../rcv_rtp.c + ../syslog.c + ../cli.c + ../cli_cmds.c + ../cli_launch.c + ../cli_legacy.c + ../cli_packet.c + ../cli_interface.c + ../cli_set.c + ../cli_dns.c + ../cli_arp.c + ../cli_bpdu.c + ../cli_eth.c + ../cli_ip.c + ../cli_udp.c + ../cli_tcp.c + ../cli_rtp.c + ../cli_tools.c + ../tx_switch.c + ../mops.c + ../mops_update.c + ../mops_tools.c + ../mops_checksums.c + ../mops_threads.c + ../mops_dot1Q.c + ../mops_mpls.c + ../mops_ip.c + ../mops_tcp.c + ../mops_ext.c + ../mops_ext_arp.c + ../mops_ext_bpdu.c + ../mops_ext_rtp.c + ../parse_xml.c + ../automops.c + ../mopsrx_arp.c + ../mops_ext_igmp.c + ../mops_ext_lldp.c + ../cli_igmp.c + ../cli_lldp.c + ../cli_sequence.c + ../mops_sequence.c + ../llist.c + ../directmops.c + ) + + add_definitions( + -DPROGNAME_STRING="${PROJECT_NAME}" + -DVERSION_STRING="${VERSION}" + -DBUILD_STRING="${BUILD_STRING}" + ) + + target_link_libraries( + ${PROJECT_NAME} + ${LIBCLI_LIBRARY} + ${CMAKE_THREAD_LIBS_INIT} + ${PCAP_LIBRARY} + -lnet -lrt -lm + ) + + pod2man( + ${CMAKE_SOURCE_DIR}/../Documentation/Manpages/${PROJECT_NAME}.8 + ${PROJECT_NAME} 8 + ) + + install( + TARGETS ${PROJECT_NAME} + DESTINATION ${EXECUTABLE_INSTALL_PATH} + ) + + install( + FILES ../../Documentation/Mausezahn + DESTINATION ${DOC_INSTALL_PATH} + ) +else(LIBCLI_FOUND AND CMAKE_HAVE_PTHREAD_CREATE AND HAVE_LIBPCAP) + if(NOT CMAKE_HAVE_PTHREAD_CREATE) + message("libpthread is missing on target. Skipping ${PROJECT_NAME} build.") + endif(NOT CMAKE_HAVE_PTHREAD_CREATE) + + if(NOT LIBCLI_FOUND) + message("libcli is missing on target. Skipping ${PROJECT_NAME} build.") + endif(NOT LIBCLI_FOUND) +endif(LIBCLI_FOUND AND CMAKE_HAVE_PTHREAD_CREATE AND HAVE_LIBPCAP) diff --git a/src/mops.h b/src/mops.h index ee9e7202..fd9884c7 100644 --- a/src/mops.h +++ b/src/mops.h @@ -693,8 +693,8 @@ struct mops *mp_head; // This global will point to the head of the mops list ///////////////////////////////////////////////////////////////// // MOPS Prototypes: -inline void mops_hton2 (u_int16_t *host16, u_int8_t *net16); -inline void mops_hton4 (u_int32_t *host32, u_int8_t *net32); +void mops_hton2 (u_int16_t *host16, u_int8_t *net16); +void mops_hton4 (u_int32_t *host32, u_int8_t *net32); int mops_get_proto_info (struct mops *mp, char *layers, char *proto); @@ -715,7 +715,7 @@ int mops_get_proto_info (struct mops *mp, char *layers, char *proto); // 1) shift=0 means no shift // 2) Because of speed we do not check if the arguments are reasonable // -inline void mops_flags (u_int8_t *target, u_int8_t *flag, int shift); +void mops_flags (u_int8_t *target, u_int8_t *flag, int shift); u_int16_t mops_sum16 (u_int16_t len, u_int8_t buff[]); diff --git a/src/mopsrx_arp.c b/src/mopsrx_arp.c index 52351cb7..0aac1523 100644 --- a/src/mopsrx_arp.c +++ b/src/mopsrx_arp.c @@ -59,7 +59,7 @@ int mops_rx_arp () void *rx_arp (void *arg) { char errbuf[PCAP_ERRBUF_SIZE]; - pcap_t *p_arp; + struct pcap *p_arp; struct bpf_program filter; char filter_str[] = "arp"; // We want to analyze both requests and responses! struct device_struct *dev = (struct device_struct*) arg; diff --git a/src/mz.h b/src/mz.h index 9135d2c9..f8b7888e 100644 --- a/src/mz.h +++ b/src/mz.h @@ -24,7 +24,7 @@ #define _GNU_SOURCE #include -#include +#include #include #include #include @@ -136,7 +136,7 @@ struct device_struct u_int8_t ip_gw[4]; // IP address of default gateway // ---- various device-specific handles ---- pthread_t arprx_thread; - pcap_t *p_arp; // pcap handle + struct pcap *p_arp; // pcap handle struct arp_table_struct *arp_table; // dedicated ARP table int ps; // packet socket } device_list[MZ_MAX_DEVICES]; @@ -509,7 +509,7 @@ int delay_parse (struct timespec *t, char *a, char *b); // // ************************************ -int send_eth(); +int send_eth(void); libnet_ptag_t create_eth_frame (libnet_t *l, libnet_ptag_t t3, libnet_ptag_t t4); // ************************************ @@ -518,9 +518,9 @@ libnet_ptag_t create_eth_frame (libnet_t *l, libnet_ptag_t t3, libnet_ptag_t // // ************************************ -int send_arp (); -int send_bpdu (); -int send_cdp (); +int send_arp (void); +int send_bpdu (void); +int send_cdp (void); // ************************************ // @@ -529,7 +529,7 @@ int send_cdp (); // ************************************ -libnet_t* get_link_context(); +libnet_t* get_link_context(void); libnet_ptag_t create_ip_packet (libnet_t *l); libnet_ptag_t create_ip6_packet (libnet_t *l); int send_frame (libnet_t *l, libnet_ptag_t t3, libnet_ptag_t t4); @@ -552,9 +552,9 @@ libnet_ptag_t create_tcp_packet (libnet_t *l); // Prototypes: Layer 7 // // ************************************ -int create_dns_packet (); -int create_rtp_packet(); -int create_syslog_packet(); +int create_dns_packet (void); +int create_rtp_packet(void); +int create_syslog_packet(void); // ************************************ // @@ -659,7 +659,7 @@ int check_eth_mac_txt(int src_or_dst); int get_port_range (int sp_or_dp, char *arg); // Return a 4-byte unsigned int random number -u_int32_t mz_rand32 (); +u_int32_t mz_rand32 (void); // Scans argument for TCP flags and sets // tx.tcp_control accordingly. @@ -760,13 +760,13 @@ int update_TSUM(libnet_t *l, libnet_ptag_t t); // // -int print_frame_details(); +int print_frame_details(void); // Calculates the number of frames to be sent. // Should be used as standard output except the // 'quiet' option (-q) has been specified. -int complexity(); +int complexity(void); // Purpose: Calculate time deltas of two timestamps stored in struct timeval. @@ -812,10 +812,10 @@ int timestamp_human(char* result, const char* prefix); int timestamp_hms(char* result); // Initialize the rcv_rtp process: Read user parameters and initialize globals -int rcv_rtp_init(); +int rcv_rtp_init(void); // Defines the pcap handler and the callback function -int rcv_rtp(); +int rcv_rtp(void); // Print current RFC-Jitter on screen void print_jitterbar (long int j, unsigned int d); @@ -836,7 +836,7 @@ int compare4B (u_int8_t *ip1, u_int8_t *ip2); // 0 if usable device found (device_list[] and tx.device set) // 1 if no usable device found // -int lookupdev(); +int lookupdev(void); // For a given device name, find out the following parameters: @@ -858,14 +858,14 @@ void got_rtp_packet(u_char *args, // Additionally, measure the precision. // This function should be called upon program start. // -int check_timer(); +int check_timer(void); // This is the replacement for gettimeofday() which would result in 'jumps' if // the system clock is adjusted (e. g. via a NTP process) and finally the jitter // measurement would include wrong datapoints. // // Furthermore the function below utilizes the newer hi-res nanosecond timers. -inline void getcurtime (struct mz_timestamp *t); +void getcurtime (struct mz_timestamp *t); // Only print out the help text for the 02.1Q option void print_dot1Q_help(void); -- 2.11.4.GIT