2 * Mausezahn - A fast versatile traffic generator
3 * Copyright (C) 2008-2010 Herbert Haas
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License version 2 as published by the
7 * Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, see http://www.gnu.org/licenses/gpl-2.0.html
27 #include <pcap/pcap.h>
37 #include <sys/types.h>
38 #include <sys/socket.h>
39 #include <arpa/inet.h>
40 #include <sys/ioctl.h>
41 #include <netinet/in.h>
49 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
52 #define MAUSEZAHN_VERSION "Mausezahn 0.40 - (C) 2007-2010 by Herbert Haas - http://www.perihel.at/sec/mz/"
53 #define MAUSEZAHN_VERSION_SHORT "0.40"
56 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
59 // "Dies ist ein schrecklicher Ort."
61 #define MZ_DEFAULT_CONFIG_PATH "/etc/mausezahn/" // see also mz_default_config_path below
62 #define MZ_DEFAULT_LOG_PATH "/var/log/mausezahn/" // see also mz_default_log_path below
64 #define SLEEP usleep // The sleep function to use. Consider 'nanosleep' in future.
65 #define DEFAULT_DELAY 0
66 #define PCAP_READ_TIMEOUT_MSEC 1 // The read timeout for pcap_open_live()
67 #define MZ_MAX_DEVICES 10 // Max number of network devices supported
68 #define MAX_PAYLOAD_SIZE 3*8192
69 #define MAX_DNS_NAME 256
70 #define MAX_8021Q_TAGS 16
71 #define TIME_COUNT_MAX 10000 // the size of the timestamp arrays timeRX and timeTX upon creation
72 #define TIME_COUNT 100 // the default used-size of the timestamp arrays timeRX and timeTX
73 #define MAX_DATA_BLOCKS 1000 // how many data blocks of size TIME_COUNT-1 should be written per file
74 #define MAXBYTES_TO_READ 1500 // how many bytes the pcap routine should read from net
75 #define RCV_RTP_MAX_BAR_WIDTH 500 // max line-width printed in BAR mode (see rcv_rtp.c)
77 #define ETH_SRC 1 // These are only some symbols used by some functions. (Don't touch)
78 #define ETH_DST 2 // These are only some symbols used by some functions.
79 #define SRC_PORT 1 // These are only some symbols used by some functions.
80 #define DST_PORT 2 // These are only some symbols used by some functions.
82 #define TEST fprintf(stderr, "HERE at line %i in file %s\n", __LINE__,__FILE__ ); fflush(stderr);
85 // ----- PCAP-specific definitions: ---------------------
91 char mz_default_config_path
[256];
92 char mz_default_log_path
[256];
95 struct arp_table_struct
{
96 int index
; // an entry index (1, 2, ...) for easier user access
97 u_int8_t sa
[6]; // sent by this MAC SA
98 u_int8_t smac
[6]; // announced MAC
99 u_int8_t smac_prev
[6]; // previously announced MAC
100 u_int8_t sip
[4]; // announced IP
101 unsigned long int uni_rq
; // count unidirectional ARP requests for this IP
102 unsigned long int bc_resp
; // count broadcast ARP responses for this IP
103 unsigned long int uni_resp
; // count normal (unidir) ARP responses for this IP
104 unsigned long int changed
; // count how often the MAC address has changed!
105 int locked
; // 1=this entry cannot be overidden anymore
106 int dynamic
; // 1=learned dynamically, 0=configured by user
107 int flags
; // anomaly information (length anomaly: bit 0, sa!=smac: bit 1 , ...)
108 int gw
; // 1=Default GW
109 char when
[10]; // human readable timestamp (e. g. "11:42:53")
110 u_int32_t sec
, nsec
; // timestamp of last ARP response
111 u_int32_t sec_prev
, nsec_prev
; // timestamp of previous ARP response
112 //-----------------//
113 struct arp_table_struct
*next
;
119 char dev
[16]; // Device name
120 int index
; // Device index (assigned by OS)
121 int phy
; // 1 if physical, 0 if not (e. g. loopback)
123 int cli
; // if set to 1 then the CLI connection must terminate here
124 int mgmt_only
; // if set to 1 then no data traffic is allowed through that interface
125 // ---- MAC addresses ----
126 u_int8_t mac
[6]; // Real MAC address
127 u_int8_t mac_mops
[6]; // MAC address to be used
128 // ---- IP related -----
129 char ip_str
[IPADDRSIZE
+1]; // Real IP address as string in dotted decimal notation
130 u_int8_t ip
[4]; // Real IP address
131 u_int8_t net
[4]; // Real network
132 u_int8_t mask
[4]; // Real mask
133 u_int8_t ip_mops
[4]; // IP address to be used
134 // ---- Default Gateway per interface:
135 u_int8_t mac_gw
[6]; // MAC address of default gateway
136 u_int8_t ip_gw
[4]; // IP address of default gateway
137 // ---- various device-specific handles ----
138 pthread_t arprx_thread
;
139 struct pcap
*p_arp
; // pcap handle
140 struct arp_table_struct
*arp_table
; // dedicated ARP table
141 int ps
; // packet socket
142 } device_list
[MZ_MAX_DEVICES
];
144 int device_list_entries
;
148 struct struct_ethernet
157 u_int16_t arp_hrd
; // hardware address format
158 u_int16_t arp_pro
; // protocol address format
159 u_int8_t arp_hln
; // hardware address length
160 u_int8_t arp_pln
; // protocol address length
161 u_int16_t arp_op
; // ARP operation type
162 u_int8_t arp_smac
[6]; // sender's hardware address
163 u_int8_t arp_sip
[4]; // sender's protocol address
164 u_int8_t arp_tmac
[6]; // target hardware address
165 u_int8_t arp_tip
[4]; // target protocol address
183 offset
; // flags and fragment offset field
212 timestamp
, // official timestamp, created by codecs
214 // csrc, // only used by mixers
225 // ---------End of PCAP-specific definitions---------------
230 // ************************************
234 // ************************************
256 int quiet
; // don't even print 'important standard short messages'
257 int verbose
; // report character
258 int simulate
; // if 1 then don't really send frames
262 FILE *fp
, *fp2
; // global multipurpose file pointer
265 clock_t mz_start
, mz_stop
;
267 enum rtp_display_mode
{
275 struct mz_timestamp
{
282 timeTX
[TIME_COUNT_MAX
],
283 timeRX
[TIME_COUNT_MAX
];
288 jitter
[TIME_COUNT_MAX
];
292 time0_flag
, // If set then time0 has valid data
296 mz_ssrc
[4]; // holds RTP stream identifier for rcv_rtp()
304 drop
, // packet drop count
305 dis
, // packet disorder count
306 gind
, // a global index to run through deltaRX, deltaTX, and jitter
307 gind_max
, // the amount of entries used in the (ugly oversized) arrays; per default set to TIME_COUNT
308 gtotal
; // counts number of file write cycles (see "got_rtp_packet()")
311 char rtp_filter_str
[64];
315 // Management issues for TX
316 char device
[16]; // every packet could be sent through a different device
317 int packet_mode
; // 0 means use LIBNET_LINK_ADV, 1 means LIBNET_RAW4
318 unsigned int count
; // 0 means infinite, 1 is default
319 unsigned int delay
; // Delay in microseconds, 0 means no delay (default)
320 char arg_string
[MAX_PAYLOAD_SIZE
]; // Argument-string when -t is used
322 // Ethernet and 802.3 parameters
323 int eth_params_already_set
; // if set to 1 then send_eth should only send the frame
324 u_int8_t eth_mac_own
[6]; // Contains own interface MAC if needed by some modules
325 char eth_dst_txt
[32]; // Text version of eth_dst (or keyword such as 'rand')
327 int eth_dst_rand
; // 1 if random
328 char eth_src_txt
[32]; // Text version of eth_src (or keyword such as 'rand')
330 int eth_src_rand
; // 1 if random
333 u_int8_t eth_payload
[MAX_PAYLOAD_SIZE
];
334 u_int32_t eth_payload_s
;
335 unsigned int padding
;
341 cdp_payload
[MAX_PAYLOAD_SIZE
],
342 cdp_tlv_id
[2048]; // The ID is the only required TLV
350 int dot1Q
; // 1 if specified
351 char dot1Q_txt
[32]; // contains 802.1p(CoS) and VLAN-ID ("5:130" or only VLAN "130")
353 u_int16_t dot1Q_vlan
;
354 u_int8_t dot1Q_header
[256]; // Contains the complete 802.1Q/P headers (but NOT the Ethernet header!)
355 u_int8_t dot1Q_header_s
;
356 int dot1Q_at_least_two_headers
; // If '1' then we have at least QinQ (or more VLAN tags)
359 int ascii
; // 1 if specified
360 u_int8_t ascii_payload
[MAX_PAYLOAD_SIZE
];
363 u_int8_t hex_payload
[MAX_PAYLOAD_SIZE
];
364 u_int32_t hex_payload_s
; // >0 if hex payload is specified
367 char mpls_txt
[128]; // contains MPLS parameters (label, exp, S, TTL)
368 char mpls_verbose_string
[1024]; // contains all labels for print_frame_details()
369 int mpls
; // 1 if specified
370 u_int32_t mpls_label
;
376 u_int32_t ip_src
; // has always network byte order(!)
377 struct libnet_in6_addr ip6_src
;
378 char ip_src_txt
[256];
379 int ip_src_rand
; // if set to 1 then SA should be random
380 u_int32_t ip_src_h
; // mirror of ip_src (NOT network byte order => easy to count)
381 u_int32_t ip_src_start
; // start of range (NOT network byte order => easy to count)
382 u_int32_t ip_src_stop
; // stop of range (NOT network byte order => easy to count)
383 int ip_src_isrange
; // if set to 1 then the start/stop values above are valid.
384 u_int32_t ip_dst
; // has always network byte order(!)
385 struct libnet_in6_addr ip6_dst
;
386 char ip_dst_txt
[256];
387 u_int32_t ip_dst_h
; // mirror of ip_dst (NOT network byte order => easy to count)
388 u_int32_t ip_dst_start
; // start of range (NOT network byte order => easy to count)
389 u_int32_t ip_dst_stop
; // stop of range (NOT network byte order => easy to count)
390 int ip_dst_isrange
; // if set to 1 then the start/stop values above are valid.
394 ip_frag
, // Flags and Offset !!!
404 ip_payload
[MAX_PAYLOAD_SIZE
];
413 icmp_verbose_txt
[256]; // used for verbose messages in send.c
417 u_int16_t icmp_ident
; // ATTENTION: libnet.h already #defines 'icmp_id', 'icmp_sum', and 'icmp_num'
418 u_int16_t icmp_chksum
; // therefore I needed a renaming here -- be careful in future...
419 u_int16_t icmp_sqnr
; //
424 icmp_payload
[MAX_PAYLOAD_SIZE
];
426 // General L4 parameters:
433 sp_isrange
, // if set to 1 then start/stop values above are valid
434 dp_isrange
; // if set to 1 then start/stop values above are valid
438 udp_len
, // includes header size (8 bytes)
441 udp_payload
[MAX_PAYLOAD_SIZE
];
449 tcp_seq_stop
, // is always set! Usually seq_start = seq_stop (=no range)
450 tcp_seq_delta
, // Also used instead of an 'isrange' variable
459 tcp_len
; // only needed by libnet and must include header size
461 tcp_payload
[MAX_PAYLOAD_SIZE
];
471 } tx
; // NOTE: tx elements are considered as default values for MOPS
477 u_int8_t gbuf
[MAX_PAYLOAD_SIZE
]; // This is only a generic global buffer to handover data more easily
481 // ************************************
483 // Prototypes: General Tools
485 // ************************************
487 void clean_up(int sig
);
490 int getopts(int argc
, char *argv
[]);
491 int getarg(char *str
, char *arg_name
, char *arg_value
);
492 unsigned long int str2int(char *str
); // converts "65535" to 65535
493 unsigned long long int str2lint(char *str
); // same but allows 64-bit integers
494 unsigned long int xstr2int(char *str
); // converts "ffff" to 65535
495 unsigned long long int xstr2lint(char *str
); // same but allows 64-bit integers
496 int mz_strisbinary(char *str
);
497 int mz_strisnum(char *str
);
498 int mz_strishex(char *str
);
499 int str2bin8 (char *str
);
500 long int str2bin16 (char *str
);
501 int char2bits (char c
, char *str
);
502 int mz_strcmp(char* usr
, char* str
, int min
);
503 int mz_tok(char * str
, char * delim
, int anz
, ...);
504 int delay_parse (struct timespec
*t
, char *a
, char *b
);
506 // ************************************
508 // Prototypes: Layer1
510 // ************************************
513 libnet_ptag_t
create_eth_frame (libnet_t
*l
, libnet_ptag_t t3
, libnet_ptag_t t4
);
515 // ************************************
517 // Prototypes: Layer 2
519 // ************************************
522 int send_bpdu (void);
525 // ************************************
527 // Prototypes: Layer 3
529 // ************************************
532 libnet_t
* get_link_context(void);
533 libnet_ptag_t
create_ip_packet (libnet_t
*l
);
534 libnet_ptag_t
create_ip6_packet (libnet_t
*l
);
535 int send_frame (libnet_t
*l
, libnet_ptag_t t3
, libnet_ptag_t t4
);
539 // ************************************
541 // Prototypes: Layer 4
543 // ************************************
544 libnet_ptag_t
create_udp_packet (libnet_t
*l
);
545 libnet_ptag_t
create_icmp_packet (libnet_t
*l
);
546 libnet_ptag_t
create_icmp6_packet (libnet_t
*l
);
547 libnet_ptag_t
create_tcp_packet (libnet_t
*l
);
550 // ************************************
552 // Prototypes: Layer 7
554 // ************************************
555 int create_dns_packet (void);
556 int create_rtp_packet(void);
557 int create_syslog_packet(void);
559 // ************************************
561 // Prototypes: Helper functions for
562 // byte manipulation,
563 // address conversion,
566 // ************************************
568 // Converts MAC address specified in str into u_int8_t array
569 // Usage: str2hex_mac ( "00:01:02:aa:ff:ee", src_addr )
570 int str2hex_mac (char* str
, u_int8_t
*addr
);
572 // Converts ascii hex values (string) into integer array, similarly as above but for any size.
573 // Example: "1a 00:00-2f" => {26, 0, 0, 47}
574 // Note: apply any improvements here and prefer this function in future!
575 // Return value: Number of converted elements (=length of array)
576 int str2hex (char* str
, u_int8_t
*hp
, int n
);
578 // Converts ascii numbers (string) into integer array
579 // Every byte can be specified as integers {0..255}
580 // For example "192.16.1.1" will be converted to {C0, 10, 01, 01}
581 int num2hex(char* str
, u_int8_t
*hp
);
583 // Convert array of integers into string of hex. Useful for verification messages.
584 // Example: {0,1,10} => "00-01-0A"
585 // Usage: bs2str ( src_mac, src_mac_txt, 6 )
586 int bs2str (u_int8_t
*bs
, char* str
, int len
);
588 // Extract contiguous sequence of bytes from an array. First element has index 1 !!!
589 // Usage: getbytes (bs, da, 1, 6);
590 int getbytes(u_int8_t
*source
, u_int8_t
*target
, int from
, int to
);
592 // For any IP address given in 'dotted decimal' returns an unsigned 32-bit integer.
593 // Example: "192.168.0.1" => 3232235521
594 // Note: Result is in LITTLE ENDIAN but usually with IP you need BIG ENDIAN, see next.
595 u_int32_t
str2ip32 (char* str
);
597 // For any IP address given in 'dotted decimal' into an unsigned 32-bit integer
598 // This version does the same as str2ip32() but in BIG ENDIAN.
599 // Note: With netlib you need this one, not the previous function.
600 u_int32_t
str2ip32_rev (char* str
);
602 // Converts a 2-byte value (e. g. a EtherType field)
603 // into a nice string using hex notation.
604 // Useful for verification messages.
605 // Example: type2str (tx.eth_type, msg) may result in msg="08:00"
606 // Return value: how many hex digits have been found.
607 int type2str(u_int16_t type
, char *str
);
610 // Parses string 'arg' for an IP range and finds start and stop IP addresses.
611 // Return value: 0 upon success, 1 upon failure.
613 // NOTE: The results are written in the following variables:
615 // (u_int32_t) tx.ip_dst_start ... contains start value
616 // (u_int32_t) tx.ip_dst_stop ... contains stop value
617 // int tx.ip_dst_isrange ... set to 1 if above values valid
619 // The other function does the same for the source address!
621 // Possible range specifications:
623 // 1) 192.168.0.0-192.168.0.12
624 // 2) 10.2.11.0-10.55.13.2
629 // FIRST detect a range by scanning for the "-" OR "/" chars
630 // THEN determine start and stop value and store them as normal unsigned integers
632 int get_ip_range_dst (char *arg
);
633 int get_ip_range_src (char *arg
);
635 // Sets a random SA for a given IP packet.
636 // Return value: 0 upon success, 1 upon failure
638 int set_rand_SA (libnet_t
*l
, libnet_ptag_t t3
);
640 // Scans tx.eth_dst_txt or tx.eth_src_txt and sets the corresponding
641 // MAC addresses (tx.eth_dst or tx.eth_src) accordingly.
642 // Argument: What string should be checked, ETH_SRC or ETH_DST.
644 // 0 when a MAC address has been set or
646 // Currently eth_src|dst_txt can be:
647 // 'rand', 'own', 'bc'|'bcast', 'stp', 'pvst',
648 // or a real mac address.
650 int check_eth_mac_txt(int src_or_dst
);
652 // Scans argument for a port number or range
653 // and sets the corresponding values in the
656 // Arguments: sp_or_dp is either SRC_PORT or DST_PORT
657 // Return value: 0 on success, 1 upon failure
659 int get_port_range (int sp_or_dp
, char *arg
);
661 // Return a 4-byte unsigned int random number
662 u_int32_t
mz_rand32 (void);
664 // Scans argument for TCP flags and sets
665 // tx.tcp_control accordingly.
667 // Valid keywords are: fin, syn, rst, psh, ack, urg, ecn, cwr
668 // Valid delimiters are: | or + or -
669 // Return value: 0 on success, 1 upon failure
671 int get_tcp_flags (char* flags
);
673 // Scans string 'params' for MPLS parameters
674 // and sets tx.mpls_* accordingly.
676 // CLI Syntax Examples:
678 // -M help .... shows syntax
680 // -M 800 .... label=800
681 // -M 800:S .... label=800 and BOS flag set
682 // -M 800:S:64 .... label=800, BOS, TTL=64
683 // -M 800:64:S .... same
684 // -M 64:77 .... label=64, TTL=77
685 // -M 64:800 .... INVALID
686 // -M 800:64 .... label=800, TTL=64
687 // -M 800:3:S:64 .... additionall the experimental bits are set (all fields required!)
689 // Note: S = BOS(1), s = NOT-BOS(0)
691 // Valid delimiters: :-.,+
692 // Return value: 0 on success, 1 upon failure
693 int get_mpls_params(char *params
);
695 // Parses str for occurence of character or sequence ch.
696 // Returns number of occurences
697 int exists(char* str
, char* ch
);
700 // Applies another random Ethernet source address to a given Ethernet-PTAG.
701 // (The calling function should check 'tx.eth_src_rand' whether the SA
702 // should be randomized.)
703 int update_Eth_SA(libnet_t
*l
, libnet_ptag_t t
);
706 // Update timestamp and sequence number in the RTP header.
707 // The actual RTP message is stored in tx.udp_payload.
708 int update_RTP(libnet_t
*l
, libnet_ptag_t t
);
711 // Applies another SOURCE IP address,
712 // - either a random one (tx.ip_src_rand==1)
713 // - or from a specified range (tx.ip_src_isrange==1)
714 // to a given IP-PTAG.
716 // Note: tx.ip_src MUST be already initialized with tx.ip_src_start.
717 // This is done by 'get_ip_range_src()' in tools.c.
719 // RETURNS '1' if tx.ip_src restarts
720 int update_IP_SA (libnet_t
*l
, libnet_ptag_t t
);
723 // Applies another DESTINATION IP address from a specified range (tx.ip_dst_isrange==1)
724 // to a given IP-PTAG.
726 // Note: tx.ip_dst MUST be already initialized with tx.ip_dst_start.
727 // This is done by 'get_ip_range_dst()' in tools.c.
729 // RETURN VALUE: '1' if tx.ip_dst restarts
730 int update_IP_DA(libnet_t
*l
, libnet_ptag_t t
);
733 // Applies another DESTINATION PORT from a specified range to a given UDP- or TCP-PTAG.
735 // Note: tx.dp MUST be already initialized with tx.dp_start
736 // This is done by 'get_port_range()' in tools.c.
738 // RETURN VALUE: '1' if tx.dp restarts
739 int update_DPORT(libnet_t
*l
, libnet_ptag_t t
);
742 // Applies another SOURCE PORT from a specified range to a given UDP- or TCP-PTAG.
744 // Note: tx.sp MUST be already initialized with tx.sp_start
745 // This is done by 'get_port_range()' in tools.c.
747 // RETURN VALUE: '1' if tx.sp restarts
748 int update_SPORT(libnet_t
*l
, libnet_ptag_t t
);
751 // Applies another TCP SQNR from a specified range to a given TCP-PTAG
753 // RETURN VALUE: '1' if tx.txp_seq restarts
755 int update_TCP_SQNR(libnet_t
*l
, libnet_ptag_t t
);
757 int update_ISUM(libnet_t
*l
, libnet_ptag_t t
);
758 int update_USUM(libnet_t
*l
, libnet_ptag_t t
);
759 int update_TSUM(libnet_t
*l
, libnet_ptag_t t
);
763 int print_frame_details(void);
766 // Calculates the number of frames to be sent.
767 // Should be used as standard output except the
768 // 'quiet' option (-q) has been specified.
769 int complexity(void);
772 // Purpose: Calculate time deltas of two timestamps stored in struct timeval.
773 // Subtract the "struct timeval" values X and Y, storing the result in RESULT.
774 // Return 1 if the difference is negative, otherwise 0.
775 int timestamp_subtract (struct mz_timestamp
*x
,
776 struct mz_timestamp
*y
,
777 struct mz_timestamp
*result
);
779 void timestamp_add (struct mz_timestamp
*x
,
780 struct mz_timestamp
*y
,
781 struct mz_timestamp
*result
);
783 // Returns a human readable timestamp in the string result.
784 // Optionally a prefix can be specified, for example if the
785 // timestamp is part of a filename.
788 // char myTimeStamp[128];
790 // timestamp_human(myTimeStamp, NULL);
792 // => "20080718_155521"
794 // /* or with prefix */
796 // timestamp_human(myTimeStamp, "MZ_RTP_jitter_");
798 // => MZ_RTP_jitter_20080718_155521
800 int timestamp_human(char* result
, const char* prefix
);
802 // Returns a human readable timestamp in the string result.
803 // Optionally a prefix can be specified, for example if the
804 // timestamp is part of a filename.
807 // char myTimeStamp[8];
809 // timestamp_hms (myTimeStamp);
812 int timestamp_hms(char* result
);
814 // Initialize the rcv_rtp process: Read user parameters and initialize globals
815 int rcv_rtp_init(void);
817 // Defines the pcap handler and the callback function
820 // Print current RFC-Jitter on screen
821 void print_jitterbar (long int j
, unsigned int d
);
823 // Compares two 4-byte variables byte by byte
824 // returns 0 if identical, 1 if different
825 int compare4B (u_int8_t
*ip1
, u_int8_t
*ip2
);
827 // PURPOSE: Find usable network devices
831 // 1. Ignores devices without IP address
832 // 2. Ignores loopback (etc)
836 // 0 if usable device found (device_list[] and tx.device set)
837 // 1 if no usable device found
842 // For a given device name, find out the following parameters:
849 int get_dev_params (char *name
);
851 // Handler function to do something when RTP messages are received
852 void got_rtp_packet(u_char
*args
,
853 const struct pcap_pkthdr
*header
, // statistics about the packet (see 'struct pcap_pkthdr')
854 const u_char
*packet
); // the bytestring sniffed
857 // Check if current system supports the nanosecond timer functions.
858 // Additionally, measure the precision.
859 // This function should be called upon program start.
861 int check_timer(void);
863 // This is the replacement for gettimeofday() which would result in 'jumps' if
864 // the system clock is adjusted (e. g. via a NTP process) and finally the jitter
865 // measurement would include wrong datapoints.
867 // Furthermore the function below utilizes the newer hi-res nanosecond timers.
868 void getcurtime (struct mz_timestamp
*t
);
870 // Only print out the help text for the 02.1Q option
871 void print_dot1Q_help(void);
873 // Determines ip and mac address of specified interface 'ifname'
874 // Caller must provide an unsigned char ip[4], mac[6]
876 int get_if_addr (char *ifname
, unsigned char *ip
, unsigned char *mac
);
878 // Takes filename and prepends valid configuration/logging directory
879 // NOTE: filename is overwritten and must be big enough to hold full path!
880 int getfullpath_cfg (char *filename
);
881 int getfullpath_log (char *filename
);
883 // A safer replacement for strncpy which ensures \0-termination
884 char * mz_strncpy(char *dest
, const char *src
, size_t n
);
886 // Helper function to count the number of arguments
887 // in the Mausezahn argument string (comma separated args)
888 // RETURN VALUE: Number of arguments
889 int number_of_args (char *str
);
891 int arptable_add(struct device_struct
*dev
,
899 // Validate ARP requests
900 int arpwatch(struct device_struct
*dev
,