You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(27) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: <jn...@us...> - 2007-05-24 22:48:45
|
Revision: 43 http://opencalea.svn.sourceforge.net/opencalea/?rev=43&view=rev Author: jnorell Date: 2007-05-24 15:48:43 -0700 (Thu, 24 May 2007) Log Message: ----------- Added function stubs for wispa functions. Updated contact addr. Modified Paths: -------------- trunk/configure trunk/configure.ac trunk/doc/Makefile.in trunk/doc/TODO.tap trunk/src/opencalea.c trunk/src/packet_processing.c trunk/src/tap.c trunk/src/tap.h Modified: trunk/configure =================================================================== --- trunk/configure 2007-05-22 17:06:49 UTC (rev 42) +++ trunk/configure 2007-05-24 22:48:43 UTC (rev 43) @@ -2,7 +2,7 @@ # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for opencalea 0.52. # -# Report bugs to <mk...@me...>. +# Report bugs to <ope...@me...>. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. @@ -730,7 +730,7 @@ PACKAGE_TARNAME='opencalea' PACKAGE_VERSION='0.52' PACKAGE_STRING='opencalea 0.52' -PACKAGE_BUGREPORT='mk...@me...' +PACKAGE_BUGREPORT='ope...@me...' ac_unique_file="src/tap.c" # Factoring default headers for most tests. @@ -1512,7 +1512,7 @@ Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. -Report bugs to <mk...@me...>. +Report bugs to <ope...@me...>. _ACEOF ac_status=$? fi @@ -5080,9 +5080,9 @@ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## ------------------------------- ## -## Report this to mk...@me... ## -## ------------------------------- ## +## ---------------------------------------- ## +## Report this to ope...@me... ## +## ---------------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; @@ -20208,9 +20208,9 @@ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## ------------------------------- ## -## Report this to mk...@me... ## -## ------------------------------- ## +## ---------------------------------------- ## +## Report this to ope...@me... ## +## ---------------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-05-22 17:06:49 UTC (rev 42) +++ trunk/configure.ac 2007-05-24 22:48:43 UTC (rev 43) @@ -2,7 +2,7 @@ AC_PREREQ(2.59) -AC_INIT([opencalea], [0.52], [mk...@me...]) +AC_INIT([opencalea], [0.52], [ope...@me...]) AC_CONFIG_SRCDIR(src/tap.c) AM_INIT_AUTOMAKE([1.9 foreign]) Modified: trunk/doc/Makefile.in =================================================================== --- trunk/doc/Makefile.in 2007-05-22 17:06:49 UTC (rev 42) +++ trunk/doc/Makefile.in 2007-05-24 22:48:43 UTC (rev 43) @@ -165,12 +165,14 @@ top_srcdir = @top_srcdir@ opencaleadir = $(datadir)/opencalea dist_opencalea_DATA = LICENSE \ - AUTHORS \ - TODO \ - TODO.opencalea \ - TODO.df_collector \ - TODO.lea_collector \ - TODO.tap + README \ + MICRO-HOWTO \ + AUTHORS \ + TODO \ + TODO.opencalea \ + TODO.df_collector \ + TODO.lea_collector \ + TODO.tap all: all-am Modified: trunk/doc/TODO.tap =================================================================== --- trunk/doc/TODO.tap 2007-05-22 17:06:49 UTC (rev 42) +++ trunk/doc/TODO.tap 2007-05-24 22:48:43 UTC (rev 43) @@ -9,3 +9,5 @@ -- change -x -y and -z requirement according to -c type (eg. some content types won't need ContentID or IAPSystemID) +-- use Syslog_Facility from config file + Modified: trunk/src/opencalea.c =================================================================== --- trunk/src/opencalea.c 2007-05-22 17:06:49 UTC (rev 42) +++ trunk/src/opencalea.c 2007-05-24 22:48:43 UTC (rev 43) @@ -713,7 +713,7 @@ int i=0; /* command line options processing */ - while (( i = getopt ( argc, argv, "f:u:g:b:p:m:n:d:D:l:L:h" )) != -1 ) { + while (( i = getopt ( argc, argv, "f:u:g:b:p:dD:l:L:h" )) != -1 ) { switch ( i ) { case 'f': // config file @@ -842,8 +842,7 @@ controllerd_addr = strdup (value); debug_5 ( "opencalea: Controllerd address set from config file (%s)", controllerd_addr); } else { - controllerd_addr = Calloc ( 64 ); - snprintf ( controllerd_addr, 64, "%s", CONTROLLERD_ADDR ); + controllerd_addr = Strdup ( CONTROLLERD_ADDR ); debug_5 ( "opencalea: Using default Controllerd address (%s)", controllerd_addr); } } @@ -853,8 +852,7 @@ controllerd_port = strdup (value); debug_5 ( "opencalea: Controllerd listener port set from config file (%s)", controllerd_port ); } else { - controllerd_port = Calloc ( 64 ); - snprintf ( controllerd_port, 64, "%d", CONTROLLERD_PORT ); + controllerd_port = Strdup ( CONTROLLERD_PORT ); debug_5 ( "opencalea: Using default Controllerd listener port (%s)", controllerd_port ); } } Modified: trunk/src/packet_processing.c =================================================================== --- trunk/src/packet_processing.c 2007-05-22 17:06:49 UTC (rev 42) +++ trunk/src/packet_processing.c 2007-05-24 22:48:43 UTC (rev 43) @@ -40,13 +40,10 @@ extern struct sockaddr_in send_df_addr; -// tmp ... need to clean up / write all the functions below -int content_option = 1; - /* - * process_packet_cc_apdu: sends CC-APDU structures for VoP CC + * process_packet_ias_cc_apdu: sends CC-APDU structures for VoP CC */ -void process_packet_cc_apdu( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ) { +void process_packet_ias_cc_apdu( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ) { struct ether_header *ethernet; struct ip *ip; @@ -185,9 +182,9 @@ /* - * process_packet_cmii_pdhr: sends PacketDataHeaderReport structures for IAS CACmII + * process_packet_ias_cmii_pdhr: sends PacketDataHeaderReport structures for IAS CACmII */ -void process_packet_cmii_pdhr( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ) { +void process_packet_ias_cmii_pdhr( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ) { struct ether_header *ethernet; struct ip *ip; @@ -323,10 +320,10 @@ /* - * process_packet_cmc_pdhr: sends PacketDataHeaderReport structures for IAS CACmII, + * process_packet_ias_cmc_pdhr: sends PacketDataHeaderReport structures for IAS CACmII, * and IAS-CC-APDU structures for IAS CmC */ -void process_packet_cmc_pdhr( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ) { +void process_packet_ias_cmc_pdhr( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ) { struct ether_header *ethernet; struct ip *ip; @@ -496,11 +493,12 @@ // NOTE THIS FUNCTION ISN'T FINISHED - IT'S AN EXACT COPY OF THE OLD process_packet() /* - * process_packet_cmc_udp: sends PacketDataHeaderReport structures for IAS CACmII, + * process_packet_ias_cmc_udp: sends PacketDataHeaderReport structures for IAS CACmII, * and UDP encapsulated IAS CmC (per IAS D.3.1) */ -void process_packet_cmc_udp( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ) { +void process_packet_ias_cmc_udp( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ) { + const int content_option = 1; struct ether_header *ethernet; struct ip *ip; struct udphdr *udp; @@ -679,12 +677,327 @@ } + +/* + * process_packet_wispa_cmii: sends CmII in WISPA format (pcap, layer 3/4 headers) +NOTE: CURRENTLY THIS IS JUST A COPY OF process_packet_ias_cmii_pdhr!!!!!! + */ +void process_packet_wispa_cmii( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ) { + + struct ether_header *ethernet; + struct ip *ip; + struct udphdr *udp; + struct tcphdr *tcp; + Msg *cmii_pkt; + int total_pkt_length; + int ip_size; + int tcp_size; + int udp_size; + int payload_size; + int ip_size_total; + const char *payload; /* Packet Payload */ + HEADER *dfheader; + + dfheader = (HEADER *)args; + +#ifdef DEBUG_PKTS + char msg[ MAX_LOG_DEBUG_MSG_LEN ]; + memset ( msg, '\0', MAX_LOG_DEBUG_MSG_LEN ); +#endif + + dfheader->sec = header->ts.tv_sec; + dfheader->usec = header->ts.tv_usec/100; + + /* Ethernet Packet */ + ethernet = (struct ether_header *)(packet); + + /* IP Header Offset */ + ip = ( struct ip* )( (char *)ethernet + datalink_hdr_len ); + ip_size_total = (int)ntohs(ip->ip_len); + ip_size = ip->ip_hl * 4; + if (ip_size < 20) { + log_5("Packet has invalid IP header length: %u bytes", ip_size); + debug_3("Packet has invalid IP header length: %u bytes", ip_size); + return; + } + + dfheader->srcIP = htonl(ip->ip_src.s_addr); + dfheader->dstIP = htonl(ip->ip_dst.s_addr); + + if (inet_ntop(AF_INET, &ip->ip_src.s_addr, dfheader->src_ip, sizeof(dfheader->src_ip)) == NULL ) { + pdie("inet_ntop"); + } + if (inet_ntop(AF_INET, &ip->ip_dst.s_addr, dfheader->dst_ip, sizeof(dfheader->dst_ip)) == NULL ) { + pdie("inet_ntop"); + } + + if ( ip->ip_p == IPPROTO_UDP ) { + /* UDP Header */ + udp = ( struct udphdr* ) ( (u_char *)ip + ip_size ); + + udp_size = sizeof(struct udphdr); + if (ntohs(udp->uh_ulen) <= 12) { + log_5("Packet has invalid UDP header length: %u bytes", udp_size); + debug_3("Packet has invalid UDP header length: %u bytes", udp_size); + return; + } + + /* UDP Payload */ + payload = (char *)((u_char *)udp + udp_size); + + /* UDP Payload size */ + payload_size = ntohs(udp->uh_ulen) - udp_size; + +#ifdef DEBUG_PKTS + if (payload_size > 0) { + debug_5("Payload (%d bytes):", payload_size); + print_hex(payload, payload_size); + } +#endif + + //format_vop_payload(dfheader); + + dfheader->srcPort = ntohs(udp->uh_sport); + dfheader->dstPort = ntohs(udp->uh_dport); + + } else if ( ip->ip_p == IPPROTO_TCP ) { + + /* TCP Header */ + tcp = ( struct tcphdr* ) ( (u_char *)ip + ip_size); + + tcp_size = tcp->th_off * 4; + if (tcp_size < 20) { + log_5("Packet has invalid TCP header length: %u bytes", tcp_size); + debug_3("Packet has invalid TCP header length: %u bytes", tcp_size); + return; + } + + /* TCP Payload */ + payload = (char *)((u_char *)tcp + tcp_size); + + /* TCP Payload size */ + payload_size = ntohs(ip->ip_len) - (ip_size + tcp_size); + + dfheader->srcPort = ntohs(tcp->th_sport); + dfheader->dstPort = ntohs(tcp->th_dport); + + } else { + debug_4("Packet is neither UDP or TCP"); + dfheader->srcPort = 0; + dfheader->dstPort = 0; + } + + /*------------------------------------------------------------------------*/ + /* WARNING: packet_data_header_report will allocate space for the BER */ + /* encoded message. This space MUST be freed when it is no */ + /* longer needed or a memory leak will occur. */ + /* */ + /* The address of the allocated memory is dfheader->encoded. */ + /* The size of the allocated memory is dfheader->encoded_size. */ + /* If packet_data_header_report does not return 0, no deallocation is needed. */ + /*------------------------------------------------------------------------*/ + + if (packet_data_header_report(dfheader) == 0) { + debug_5("Packet_Data_Header_Report encoded addr: %p, size: %Zd", dfheader->encoded, dfheader->encoded_size); + //print_hex((const u_char *)dfheader->encoded, (size_t)dfheader->encoded_size); + } else { + return; + } + + total_pkt_length = sizeof(Msg) + dfheader->encoded_size; + debug_5 ( "building T1.IAS CmII packet size: %d", total_pkt_length); + cmii_pkt = CmIIPacketBuild ( dfheader ); + debug_5 ( "sending T1.IAS CmII packet size: %d", total_pkt_length ); + //print_hex((const u_char *)cmii_pkt, (size_t)total_pkt_length); + PacketSend ( cmii_pkt, total_pkt_length, &send_df_socket ); + PacketFree ( cmii_pkt ); + + free(dfheader->encoded); + +} + + +/* + * process_packet_wispa_cmc: sends CmC in WISPA format (pcap) +NOTE: CURRENTLY THIS IS JUST A COPY OF process_packet_ias_cmc_pdhr!!!!!! + */ +void process_packet_wispa_cmc( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ) { + + struct ether_header *ethernet; + struct ip *ip; + struct udphdr *udp; + struct tcphdr *tcp; + Msg *cmc_pkt; + Msg *cmii_pkt; + int total_pkt_length; + int ip_size; + int tcp_size; + int udp_size; + int payload_size; + int ip_size_total; + const char *payload; /* Packet Payload */ + HEADER *dfheader; + + dfheader = (HEADER *)args; + +#ifdef DEBUG_PKTS + char msg[ MAX_LOG_DEBUG_MSG_LEN ]; + memset ( msg, '\0', MAX_LOG_DEBUG_MSG_LEN ); +#endif + + dfheader->sec = header->ts.tv_sec; + dfheader->usec = header->ts.tv_usec/100; + + /* Ethernet Packet */ + ethernet = (struct ether_header *)(packet); + + /* IP Header Offset */ + ip = ( struct ip* )( (char *)ethernet + datalink_hdr_len ); + ip_size_total = (int)ntohs(ip->ip_len); + ip_size = ip->ip_hl * 4; + if (ip_size < 20) { + log_5("Packet has invalid IP header length: %u bytes", ip_size); + debug_3("Packet has invalid IP header length: %u bytes", ip_size); + return; + } + + dfheader->srcIP = htonl(ip->ip_src.s_addr); + dfheader->dstIP = htonl(ip->ip_dst.s_addr); + + if (inet_ntop(AF_INET, &ip->ip_src.s_addr, dfheader->src_ip, sizeof(dfheader->src_ip)) == NULL ) { + pdie("inet_ntop"); + } + if (inet_ntop(AF_INET, &ip->ip_dst.s_addr, dfheader->dst_ip, sizeof(dfheader->dst_ip)) == NULL ) { + pdie("inet_ntop"); + } + + if ( ip->ip_p == IPPROTO_UDP ) { + /* UDP Header */ + udp = ( struct udphdr* ) ( (u_char *)ip + ip_size ); + + udp_size = sizeof(struct udphdr); + if (ntohs(udp->uh_ulen) <= 12) { + log_5("Packet has invalid UDP header length: %u bytes", udp_size); + debug_3("Packet has invalid UDP header length: %u bytes", udp_size); + return; + } + + /* UDP Payload */ + payload = (char *)((u_char *)udp + udp_size); + + /* UDP Payload size */ + payload_size = ntohs(udp->uh_ulen) - udp_size; + +#ifdef DEBUG_PKTS + if (payload_size > 0) { + debug_5("Payload (%d bytes):", payload_size); + print_hex(payload, payload_size); + } +#endif + + //format_vop_payload(dfheader); + + dfheader->srcPort = ntohs(udp->uh_sport); + dfheader->dstPort = ntohs(udp->uh_dport); + + } else if ( ip->ip_p == IPPROTO_TCP ) { + + /* TCP Header */ + tcp = ( struct tcphdr* ) ( (u_char *)ip + ip_size); + + tcp_size = tcp->th_off * 4; + if (tcp_size < 20) { + log_5("Packet has invalid TCP header length: %u bytes", tcp_size); + debug_3("Packet has invalid TCP header length: %u bytes", tcp_size); + return; + } + + /* TCP Payload */ + payload = (char *)((u_char *)tcp + tcp_size); + + /* TCP Payload size */ + payload_size = ntohs(ip->ip_len) - (ip_size + tcp_size); + + dfheader->srcPort = ntohs(tcp->th_sport); + dfheader->dstPort = ntohs(tcp->th_dport); + + } else { + debug_4("Packet is neither UDP or TCP"); + dfheader->srcPort = 0; + dfheader->dstPort = 0; + } + + + //debug_5("IP (%d bytes):", ip_size_total); + //print_hex((const u_char *)ip, (size_t)ip_size_total); + + dfheader->sequenceNumber++; + dfheader->payload = (const char *)ip; + dfheader->payload_size = (size_t)ip_size_total; + /*------------------------------------------------------------------------*/ + /* WARNING: cc_apdu will allocate space for the BER encoded message. */ + /* This space MUST be freed when it is no longer needed or a */ + /* memory leak will occur. */ + /* */ + /* The address of the allocated memory is dfheader->encoded. */ + /* The size of the allocated memory is dfheader->encoded_size. */ + /* If cc_apdu does not return 0, no deallocation is needed. */ + /*------------------------------------------------------------------------*/ + if ( cc_apdu(dfheader) == 0) { + debug_5("Encoded addr(size): %p(%Zd)", dfheader->encoded_size, dfheader->encoded); + } else { + debug_5("cc_apdu returned nonzero"); + return; + } + + total_pkt_length = sizeof(Msg) + dfheader->encoded_size; + debug_5 ( "building CmC packet size: %d", total_pkt_length ); + cmc_pkt = CmCPacketBuild ( dfheader ); + debug_5 ( "sending CmC packet size: %d", total_pkt_length ); + PacketSend ( cmc_pkt, total_pkt_length, &send_df_socket ); + PacketFree ( cmc_pkt ); + + free(dfheader->encoded); + + + /*------------------------------------------------------------------------*/ + /* WARNING: packet_data_header_report will allocate space for the BER */ + /* encoded message. This space MUST be freed when it is no */ + /* longer needed or a memory leak will occur. */ + /* */ + /* The address of the allocated memory is dfheader->encoded. */ + /* The size of the allocated memory is dfheader->encoded_size. */ + /* If packet_data_header_report does not return 0, no deallocation is needed. */ + /*------------------------------------------------------------------------*/ + if (packet_data_header_report(dfheader) == 0) { + debug_5("Packet_Data_Header_Report encoded addr: %p, size: %Zd", dfheader->encoded, dfheader->encoded_size); + //print_hex((const u_char *)dfheader->encoded, (size_t)dfheader->encoded_size); + } else { + return; + } + + total_pkt_length = sizeof(Msg) + dfheader->encoded_size; + debug_5 ( "building T1.IAS CmII packet size: %d", total_pkt_length); + cmii_pkt = CmIIPacketBuild ( dfheader ); + debug_5 ( "sending T1.IAS CmII packet size: %d", total_pkt_length ); + //print_hex((const u_char *)cmii_pkt, (size_t)total_pkt_length); + PacketSend ( cmii_pkt, total_pkt_length, &send_df_socket ); + PacketFree ( cmii_pkt ); + + free(dfheader->encoded); + +} + + + + // NOTE THIS FUNCTION ISN'T FINISHED - IT'S AN EXACT COPY OF THE OLD process_packet() /* * process_packet_raw: sends content raw with no formatting */ void process_packet_raw( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ) { + const int content_option = 1; struct ether_header *ethernet; struct ip *ip; struct udphdr *udp; @@ -869,6 +1182,7 @@ */ void process_packet_pcap( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ) { + const int content_option = 1; struct ether_header *ethernet; struct ip *ip; struct udphdr *udp; @@ -1045,5 +1359,3 @@ free(dfheader->encoded); } - - Modified: trunk/src/tap.c =================================================================== --- trunk/src/tap.c 2007-05-22 17:06:49 UTC (rev 42) +++ trunk/src/tap.c 2007-05-24 22:48:43 UTC (rev 43) @@ -35,10 +35,12 @@ #include <net/ethernet.h> /* function declarations */ -void process_packet_cc_apdu( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ); -void process_packet_cmii_pdhr( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ); -void process_packet_cmc_pdhr( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ); -void process_packet_cmc_udp( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ); +void process_packet_ias_cc_apdu( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ); +void process_packet_ias_cmii_pdhr( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ); +void process_packet_ias_cmc_pdhr( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ); +void process_packet_ias_cmc_udp( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ); +void process_packet_wispa_cmii( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ); +void process_packet_wispa_cmc( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ); void process_packet_raw( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ); void process_packet_pcap( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ); @@ -415,17 +417,23 @@ } if (! strcmp(content_type, "vop-cc")) { - debug_5("setting process_packet function to: process_packet_cc_apdu"); - process_packet_fp = &process_packet_cc_apdu; + debug_5("setting process_packet function to: process_packet_ias_cc_apdu"); + process_packet_fp = &process_packet_ias_cc_apdu; } else if (! strcmp(content_type, "ias-cmii")) { - debug_5("setting process_packet function to: process_packet_cmii_pdhr"); - process_packet_fp = &process_packet_cmii_pdhr; + debug_5("setting process_packet function to: process_packet_ias_cmii_pdhr"); + process_packet_fp = &process_packet_ias_cmii_pdhr; } else if (! strcmp(content_type, "ias-cmc")) { - debug_5("setting process_packet function to: process_packet_cmc_pdhr"); - process_packet_fp = &process_packet_cmc_pdhr; + debug_5("setting process_packet function to: process_packet_ias_cmc_pdhr"); + process_packet_fp = &process_packet_ias_cmc_pdhr; } else if (! strcmp(content_type, "ias-cmc-udp")) { - debug_5("setting process_packet function to: process_packet_cmc_udp"); - process_packet_fp = &process_packet_cmc_udp; + debug_5("setting process_packet function to: process_packet_ias_cmc_udp"); + process_packet_fp = &process_packet_ias_cmc_udp; + } else if (! strcmp(content_type, "wispa-cmii")) { + debug_5("setting process_packet function to: process_packet_wispa_cmii"); + process_packet_fp = &process_packet_wispa_cmii; + } else if (! strcmp(content_type, "wispa-cmc")) { + debug_5("setting process_packet function to: process_packet_wispa_cmc"); + process_packet_fp = &process_packet_wispa_cmc; } else if (! strcmp(content_type, "raw")) { debug_5("setting process_packet function to: process_packet_raw"); process_packet_fp = &process_packet_raw; @@ -439,14 +447,13 @@ debug_4 ( "running pcap_datalink" ); switch (pcap_datalink(handle)) { case DLT_NULL: - datalink_hdr_len = NULL_HDRLEN; + datalink_hdr_len = NULL_HDR_LEN; break; case DLT_EN10MB: datalink_hdr_len = ETHER_HDR_LEN; break; default: - debug_1 ( "unknown datalink, using ethernet offset" ); - datalink_hdr_len = ETHER_HDR_LEN; + die ( "unknown datalink type (not ethernet) : %i", pcap_datalink(handle) ); break; } debug_4 ( "datalink_hdr_len = %d", datalink_hdr_len ); Modified: trunk/src/tap.h =================================================================== --- trunk/src/tap.h 2007-05-22 17:06:49 UTC (rev 42) +++ trunk/src/tap.h 2007-05-24 22:48:43 UTC (rev 43) @@ -37,8 +37,8 @@ #define TAP_CONF_SECTION "TAP" #endif -#ifndef NULL_HDRLEN -#define NULL_HDRLEN 4 +#ifndef NULL_HDR_LEN +#define NULL_HDR_LEN 4 #endif /* function declarations */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nor...@us...> - 2007-05-16 22:08:51
|
Revision: 41 http://opencalea.svn.sourceforge.net/opencalea/?rev=41&view=rev Author: norm_brandinger Date: 2007-05-16 15:08:53 -0700 (Wed, 16 May 2007) Log Message: ----------- Updates to opencalea to put config files related to different programs (df_collector, controllerd, tap) in different Config structures. Modified Paths: -------------- trunk/src/opencalea.c Modified: trunk/src/opencalea.c =================================================================== --- trunk/src/opencalea.c 2007-05-16 21:42:37 UTC (rev 40) +++ trunk/src/opencalea.c 2007-05-16 22:08:53 UTC (rev 41) @@ -32,6 +32,10 @@ int read_config_file(int level, char *arg); Config config_intercept; +Config config_df_collector; +Config config_lea_collector; +Config config_controllerd; +Config config_tap; /** * Main Routine @@ -154,28 +158,28 @@ case STATE_STOP_DF_COLLECTOR_FILE: case STATE_STATUS_DF_COLLECTOR_FILE: strcpy(file_df_collector, arg); - if (parse_config(&config_intercept, "DF_COLLECTOR", local_path) < 0) + if (parse_config(&config_df_collector, "DF_COLLECTOR", local_path) < 0) die("Error with config file \"%s\"", local_path); break; case STATE_START_CONTROLLERD_FILE: case STATE_STOP_CONTROLLERD_FILE: case STATE_STATUS_CONTROLLERD_FILE: strcpy(file_controllerd, arg); - if (parse_config(&config_intercept, "CONTROLLERD", local_path) < 0) + if (parse_config(&config_controllerd, "CONTROLLERD", local_path) < 0) die("Error with config file \"%s\"", local_path); break; case STATE_START_LEA_COLLECTOR_FILE: case STATE_STOP_LEA_COLLECTOR_FILE: case STATE_STATUS_LEA_COLLECTOR_FILE: strcpy(file_lea_collector, arg); - if (parse_config(&config_intercept, "LEA_COLLECTOR", local_path) < 0) + if (parse_config(&config_lea_collector, "LEA_COLLECTOR", local_path) < 0) die("Error with config file \"%s\"", local_path); break; case STATE_START_TAP_FILE: case STATE_STOP_TAP_FILE: case STATE_STATUS_TAP_FILE: strcpy(file_tap, arg); - if (parse_config(&config_intercept, "TAP", local_path) < 0) + if (parse_config(&config_tap, "TAP", local_path) < 0) die("Error with config file \"%s\"", local_path); break; default: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nor...@us...> - 2007-05-16 19:17:36
|
Revision: 38 http://opencalea.svn.sourceforge.net/opencalea/?rev=38&view=rev Author: norm_brandinger Date: 2007-05-16 12:17:37 -0700 (Wed, 16 May 2007) Log Message: ----------- Added structured user input processing to opencalea.c Added opencalea.c globals to opencalea.h This update does NOT complete the work on opencalea.c It is only being posted for review. None of the commands are operating yet. Modified Paths: -------------- trunk/src/opencalea.c trunk/src/opencalea.h Modified: trunk/src/opencalea.c =================================================================== --- trunk/src/opencalea.c 2007-05-14 22:28:37 UTC (rev 37) +++ trunk/src/opencalea.c 2007-05-16 19:17:37 UTC (rev 38) @@ -24,18 +24,20 @@ * SUCH DAMAGE. */ +#include <getopt.h> + #include "common.h" #include "msg.h" #include "calea.h" #include "opencalea.h" -void display_prompt(); -void get_input(char *buffer, size_t buffer_len, FILE *file); -int process_input(char *buffer); - +/** + * Main Routine + */ int main(int argc, char *argv[]) { char buffer[MAX_LINE+1]; + int level = STATE_NONE; setdebug( DEF_DEBUG_LEVEL, DEF_DEBUG_DEST, 1 ); //setdebug( 5, "stdout", 1 ); @@ -43,25 +45,35 @@ parse_commandline(argc, argv); - for (;;) { - display_prompt(); + printf("BETA FOR REVIEW - NON OPERATIONAL\n"); + + while(1) { + display_prompt(level); get_input(buffer, MAX_LINE, stdin); - if (!process_input(buffer)) + if ( !(level=process_input(level, buffer)) ) break; } return 0; } -void display_prompt() { - printf("OpenCALEA> "); - fflush (stdout); -} - +/** + * Get user input from a file pointer + */ void get_input(char *buffer, size_t buffer_len, FILE *file) { size_t last; bzero(buffer,buffer_len+1); + + /*********************************************************************/ + /* the next two lines are used to add a dummy value as argv[0]. */ + /* argv[0] is usually the name used to execute this program. */ + /* If standard subroutines are used to process this argument vector, */ + /* for example, getopt, then this argv[0] fix is required. */ + /*********************************************************************/ + strncpy(buffer, "opencalea ", 10); + buffer+=10; + if (fgets (buffer, buffer_len, file)) { last = strlen (buffer) - 1; @@ -76,36 +88,568 @@ return; } -int process_input(char *buffer) { +/** + * Process a complete line of input from a user + * An argv[] vector is created and then each argv is processed + * The resulting enum STATE (level) is returned + */ +int process_input(int level, char *buffer) { - char **ap; - char *argv[MAX_LINE]; - char *inputstring; - int i, argc; + char **ap; + char *argv[MAX_LINE]; + char *inputstring; + int argc = 0; + /* the following usees strsep to parse a string */ + /* containing tokens into an argument vector */ + bzero(argv, MAX_LINE); + inputstring = buffer; + for (ap = argv; (*ap = strsep(&inputstring, "\r\n\t ")) != NULL;) + if (**ap != '\0') { + argc++; + if (++ap >= &argv[MAX_LINE]) + break; + } - /* the following used strsep to parse a string containing tokens into an argument vector */ - bzero(argv, sizeof(argv)); - argc = 0; - inputstring = buffer; - for (ap = argv; (*ap = strsep(&inputstring, "\r\n\t ")) != NULL;) - if (**ap != '\0') { - argc++; - if (++ap >= &argv[MAX_LINE]) + // for (int c=0;c<argc;c++) { printf("argv[%d]=%s\n", c, argv[c]); } + + /* nothing to process, just return */ + if (argc == 1) + return level; + + if (argc == 2) { + level = process_arg(level, argv[1]); + } else if (argc == 3) { + level = process_arg(level, argv[1]); + level = process_arg(level, argv[2]); + } else if (argc == 4) { + level = process_arg(level, argv[1]); + level = process_arg(level, argv[2]); + level = process_arg(level, argv[3]); + } + + fflush(stdout); + return(level); +} + + +/** + * Display a prompt for the user based upon the current enum STATE (level) + */ +void display_prompt(int level) { + + switch (level) { + case STATE_NONE: + strcpy(prompt, "OpenCALEA>"); break; + case STATE_START: + strcpy(prompt, "OpenCALEA Start>"); + break; + case STATE_STOP: + strcpy(prompt, "OpenCALEA Stop>"); + break; + case STATE_STATUS: + strcpy(prompt, "OpenCALEA Status>"); + break; + case STATE_START_INTERCEPT: + strcpy(prompt, "OpenCALEA Start Intercept>"); + break; + case STATE_START_DF_COLLECTOR: + strcpy(prompt, "OpenCALEA Start df_collector>"); + break; + case STATE_START_CONTROLLERD: + strcpy(prompt, "OpenCALEA Start controllerd>"); + break; + case STATE_START_LEA_COLLECTOR: + strcpy(prompt, "OpenCALEA Start lea_collector>"); + break; + case STATE_START_TAP: + strcpy(prompt, "OpenCALEA Start tap>"); + break; + case STATE_STOP_INTERCEPT: + strcpy(prompt, "OpenCALEA Stop Intercept>"); + break; + case STATE_STOP_DF_COLLECTOR: + strcpy(prompt, "OpenCALEA Stop df_collector>"); + break; + case STATE_STOP_CONTROLLERD: + strcpy(prompt, "OpenCALEA Stop controllerd>"); + break; + case STATE_STOP_LEA_COLLECTOR: + strcpy(prompt, "OpenCALEA Stop lea_collector>"); + break; + case STATE_STOP_TAP: + strcpy(prompt, "OpenCALEA Stop tap>"); + break; + case STATE_STATUS_INTERCEPT: + strcpy(prompt, "OpenCALEA Status Intercept>"); + break; + case STATE_STATUS_DF_COLLECTOR: + strcpy(prompt, "OpenCALEA Status df_collector>"); + break; + case STATE_STATUS_CONTROLLERD: + strcpy(prompt, "OpenCALEA Status controllerd>"); + break; + case STATE_STATUS_LEA_COLLECTOR: + strcpy(prompt, "OpenCALEA Status lea_collector>"); + break; + case STATE_STATUS_TAP: + strcpy(prompt, "OpenCALEA Status tap>"); + break; + case STATE_START_INTERCEPT_FILE: + strcpy(prompt, "OpenCALEA Start Intercept "); + strcat(prompt, file_intercept); + strcat(prompt, ">"); + break; + case STATE_START_DF_COLLECTOR_FILE: + strcpy(prompt, "OpenCALEA Start df_collector "); + strcat(prompt, file_df_collector); + strcat(prompt, ">"); + break; + case STATE_START_CONTROLLERD_FILE: + strcpy(prompt, "OpenCALEA Start controllerd "); + strcat(prompt, file_controllerd); + strcat(prompt, ">"); + break; + case STATE_START_LEA_COLLECTOR_FILE: + strcpy(prompt, "OpenCALEA Start lea_collector "); + strcat(prompt, file_lea_collector); + strcat(prompt, ">"); + break; + case STATE_START_TAP_FILE: + strcpy(prompt, "OpenCALEA Start tap "); + strcat(prompt, file_tap); + strcat(prompt, ">"); + break; + case STATE_STOP_INTERCEPT_FILE: + strcpy(prompt, "OpenCALEA Stop Intercept "); + strcat(prompt, file_intercept); + strcat(prompt, ">"); + break; + case STATE_STOP_DF_COLLECTOR_FILE: + strcpy(prompt, "OpenCALEA Stop df_collector "); + strcat(prompt, file_df_collector); + strcat(prompt, ">"); + break; + case STATE_STOP_CONTROLLERD_FILE: + strcpy(prompt, "OpenCALEA Stop controllerd "); + strcat(prompt, file_controllerd); + strcat(prompt, ">"); + break; + case STATE_STOP_LEA_COLLECTOR_FILE: + strcpy(prompt, "OpenCALEA Stop lea_collector "); + strcat(prompt, file_lea_collector); + strcat(prompt, ">"); + break; + case STATE_STOP_TAP_FILE: + strcpy(prompt, "OpenCALEA Stop tap "); + strcat(prompt, file_tap); + strcat(prompt, ">"); + break; + case STATE_STATUS_INTERCEPT_FILE: + strcpy(prompt, "OpenCALEA Status Intercept "); + strcat(prompt, file_intercept); + strcat(prompt, ">"); + break; + case STATE_STATUS_DF_COLLECTOR_FILE: + strcpy(prompt, "OpenCALEA Status df_collector "); + strcat(prompt, file_df_collector); + strcat(prompt, ">"); + break; + case STATE_STATUS_CONTROLLERD_FILE: + strcpy(prompt, "OpenCALEA Status controllerd "); + strcat(prompt, file_controllerd); + strcat(prompt, ">"); + break; + case STATE_STATUS_LEA_COLLECTOR_FILE: + strcpy(prompt, "OpenCALEA Status lea_collector "); + strcat(prompt, file_lea_collector); + strcat(prompt, ">"); + break; + case STATE_STATUS_TAP_FILE: + strcpy(prompt, "OpenCALEA Status tap "); + strcat(prompt, file_tap); + strcat(prompt, ">"); + break; + } - if ( !strncmp(buffer, "quit", 4) || !strncmp(buffer, "exit", 4) ) - return 0; + printf("%s ", prompt); + fflush (stdout); +} - printf("OpenCALEA> "); - for (i=0; i<argc; i++) { - printf("arg[%d]=%s ", i, argv[i]); + +/** + * Process an argv[] item associated with the current enum STATE (level) + * This routine will return a new STATE (level) + */ +int process_arg(int level, char *arg) { + + if ( !strncmp(arg, "quit", 4) ) + return(STATE_QUIT); + + if (arg[0] == '?') { + print_help(level); + return(level); } - printf("\n"); - fflush (stdout); - return 1; + switch (level) { + case STATE_NONE: + if ( !strncmp(arg, "start", 5) ) { + level = STATE_START; + } else if ( !strncmp(arg, "stop", 4) ) { + level = STATE_STOP; + } else if ( !strncmp(arg, "status", 6) ) { + level = STATE_STATUS; + } else if ( !strncmp(arg, "exit", 4) ) { + level = STATE_QUIT; + } + break; + case STATE_START: + if ( !strncmp(arg, "intercept", 9) ) { + level = STATE_START_INTERCEPT; + } else if ( !strncmp(arg, "df_collector", 12) ) { + level = STATE_START_DF_COLLECTOR; + } else if ( !strncmp(arg, "controllerd", 11) ) { + level = STATE_START_CONTROLLERD; + } else if ( !strncmp(arg, "lea_collector", 13) ) { + level = STATE_START_LEA_COLLECTOR; + } else if ( !strncmp(arg, "tap", 3) ) { + level = STATE_START_TAP; + } else if ( !strncmp(arg, "exit", 4) ) { + level = STATE_NONE; + } + break; + case STATE_STOP: + if ( !strncmp(arg, "intercept", 9) ) { + level = STATE_STOP_INTERCEPT; + } else if ( !strncmp(arg, "df_collector", 12) ) { + level = STATE_STOP_DF_COLLECTOR; + } else if ( !strncmp(arg, "controllerd", 11) ) { + level = STATE_STOP_CONTROLLERD; + } else if ( !strncmp(arg, "lea_collector", 13) ) { + level = STATE_STOP_LEA_COLLECTOR; + } else if ( !strncmp(arg, "tap", 3) ) { + level = STATE_STOP_TAP; + } else if ( !strncmp(arg, "exit", 4) ) { + level = STATE_NONE; + } + break; + case STATE_STATUS: + if ( !strncmp(arg, "intercept", 9) ) { + level = STATE_STATUS_INTERCEPT; + } else if ( !strncmp(arg, "df_collector", 12) ) { + level = STATE_STATUS_DF_COLLECTOR; + } else if ( !strncmp(arg, "controllerd", 11) ) { + level = STATE_STATUS_CONTROLLERD; + } else if ( !strncmp(arg, "lea_collector", 13) ) { + level = STATE_STATUS_LEA_COLLECTOR; + } else if ( !strncmp(arg, "tap", 3) ) { + level = STATE_STATUS_TAP; + } else if ( !strncmp(arg, "exit", 4) ) { + level = STATE_NONE; + } + break; + + case STATE_START_INTERCEPT: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_START; + } else { + strcpy(file_intercept, arg); + level = STATE_START_INTERCEPT_FILE; + } + break; + case STATE_START_DF_COLLECTOR: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_START; + } else { + strcpy(file_df_collector, arg); + level = STATE_START_DF_COLLECTOR_FILE; + } + break; + case STATE_START_CONTROLLERD: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_START; + } else { + strcpy(file_controllerd, arg); + level = STATE_START_CONTROLLERD_FILE; + } + break; + case STATE_START_LEA_COLLECTOR: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_START; + } else { + strcpy(file_lea_collector, arg); + level = STATE_START_LEA_COLLECTOR_FILE; + } + break; + case STATE_START_TAP: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_START; + } else { + strcpy(file_tap, arg); + level = STATE_START_TAP_FILE; + } + break; + case STATE_STOP_INTERCEPT: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_STOP; + } else { + strcpy(file_intercept, arg); + level = STATE_STOP_INTERCEPT_FILE; + } + break; + case STATE_STOP_DF_COLLECTOR: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_STOP; + } else { + strcpy(file_df_collector, arg); + level = STATE_STOP_DF_COLLECTOR_FILE; + } + break; + case STATE_STOP_CONTROLLERD: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_STOP; + } else { + strcpy(file_controllerd, arg); + level = STATE_STOP_CONTROLLERD_FILE; + } + break; + case STATE_STOP_LEA_COLLECTOR: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_STOP; + } else { + strcpy(file_lea_collector, arg); + level = STATE_STOP_LEA_COLLECTOR_FILE; + } + break; + case STATE_STOP_TAP: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_STOP; + } else { + strcpy(file_tap, arg); + level = STATE_STOP_TAP_FILE; + } + break; + case STATE_STATUS_INTERCEPT: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_STATUS; + } else { + strcpy(file_intercept, arg); + level = STATE_STATUS_INTERCEPT_FILE; + } + break; + case STATE_STATUS_DF_COLLECTOR: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_STATUS; + } else { + strcpy(file_df_collector, arg); + level = STATE_STATUS_DF_COLLECTOR_FILE; + } + break; + case STATE_STATUS_CONTROLLERD: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_STATUS; + } else { + strcpy(file_controllerd, arg); + level = STATE_STATUS_CONTROLLERD_FILE; + } + break; + case STATE_STATUS_LEA_COLLECTOR: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_STATUS; + } else { + strcpy(file_lea_collector, arg); + level = STATE_STATUS_LEA_COLLECTOR_FILE; + } + break; + case STATE_STATUS_TAP: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_STATUS; + } else { + strcpy(file_tap, arg); + level = STATE_STATUS_TAP_FILE; + } + break; + case STATE_START_INTERCEPT_FILE: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_START_INTERCEPT; + } else { + printf("reading file: %s ... (not really)\n", file_intercept); + } + break; + case STATE_START_DF_COLLECTOR_FILE: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_START_DF_COLLECTOR; + } else { + printf("reading file: %s ... (not really)\n", file_df_collector); + } + break; + case STATE_START_CONTROLLERD_FILE: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_START_CONTROLLERD; + } else { + printf("reading file: %s ... (not really)\n", file_controllerd); + } + break; + case STATE_START_LEA_COLLECTOR_FILE: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_START_LEA_COLLECTOR; + } else { + printf("reading file: %s ... (not really)\n", file_lea_collector); + } + break; + case STATE_START_TAP_FILE: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_START_TAP; + } else { + printf("reading file: %s ... (not really)\n", file_tap); + } + break; + case STATE_STOP_INTERCEPT_FILE: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_STOP_INTERCEPT; + } else { + printf("reading file: %s ... (not really)\n", file_intercept); + } + break; + case STATE_STOP_DF_COLLECTOR_FILE: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_STOP_DF_COLLECTOR; + } else { + printf("reading file: %s ... (not really)\n", file_df_collector); + } + break; + case STATE_STOP_CONTROLLERD_FILE: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_STOP_CONTROLLERD; + } else { + printf("reading file: %s ... (not really)\n", file_controllerd); + } + break; + case STATE_STOP_LEA_COLLECTOR_FILE: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_STOP_LEA_COLLECTOR; + } else { + printf("reading file: %s ... (not really)\n", file_lea_collector); + } + break; + case STATE_STOP_TAP_FILE: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_STOP_TAP; + } else { + printf("reading file: %s ... (not really)\n", file_tap); + } + break; + case STATE_STATUS_INTERCEPT_FILE: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_STATUS_INTERCEPT; + } else { + printf("reading file: %s ... (not really)\n", file_intercept); + } + break; + case STATE_STATUS_DF_COLLECTOR_FILE: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_STATUS_DF_COLLECTOR; + } else { + printf("reading file: %s ... (not really)\n", file_df_collector); + } + break; + case STATE_STATUS_CONTROLLERD_FILE: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_STATUS_CONTROLLERD; + } else { + printf("reading file: %s ... (not really)\n", file_controllerd); + } + break; + case STATE_STATUS_LEA_COLLECTOR_FILE: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_STATUS_LEA_COLLECTOR; + } else { + printf("reading file: %s ... (not really)\n", file_lea_collector); + } + break; + case STATE_STATUS_TAP_FILE: + if ( !strncmp(arg, "exit", 4) ) { + level = STATE_STATUS_TAP; + } else { + printf("reading file: %s ... (not really)\n", file_tap); + } + break; + + } + + return level; +} + +/** + * Print help text based on the enum STATE (level) + */ +void print_help(int level) { + + /* display help line based on the current level */ + switch (level) { + case STATE_NONE: + printf("Commands: start, stop, status, exit, quit\n"); + break; + case STATE_START: + printf("Start: controllerd, df_collector, tap, intercept, lea_collector, exit, quit\n"); + break; + case STATE_STOP: + printf("Stop: controllerd, df_collector, tap, intercept, lea_collector, exit, quit\n"); + break; + case STATE_STATUS: + printf("Status: controllerd, df_collector, tap, intercept, lea_collector, exit, quit\n"); + break; + case STATE_START_INTERCEPT: + printf("Start Intercept: <file>\n"); + break; + case STATE_START_DF_COLLECTOR: + printf("Start df_collector: <file>\n"); + break; + case STATE_START_TAP: + printf("Start tap: <file>\n"); + break; + case STATE_START_LEA_COLLECTOR: + printf("Start lea_collector: <file>\n"); + break; + case STATE_START_CONTROLLERD: + printf("Start controllerd: <file>\n"); + break; + case STATE_STOP_INTERCEPT: + printf("Stop Intercept: <file>\n"); + break; + case STATE_STOP_DF_COLLECTOR: + printf("Stop df_collector: <file>\n"); + break; + case STATE_STOP_TAP: + printf("Stop tap: <file>\n"); + break; + case STATE_STOP_LEA_COLLECTOR: + printf("Stop lea_collector: <file>\n"); + break; + case STATE_STOP_CONTROLLERD: + printf("Stop controllerd: <file>\n"); + break; + case STATE_STATUS_INTERCEPT: + printf("Status Intercept: <file>\n"); + break; + case STATE_STATUS_DF_COLLECTOR: + printf("Status df_collector: <file>\n"); + break; + case STATE_STATUS_TAP: + printf("Status tap: <file>\n"); + break; + case STATE_STATUS_LEA_COLLECTOR: + printf("Status lea_collector: <file>\n"); + break; + case STATE_STATUS_CONTROLLERD: + printf("Status controllerd: <file>\n"); + break; + } + + fflush(stdout); + return; } @@ -164,10 +708,10 @@ debug_4 ( "got opt %c: %s", i, optarg ); break; case 'h': // help - usage(); + print_usage(); exit ( 0 ); default: - usage (); + print_usage (); exit ( 1 ); } } @@ -263,7 +807,7 @@ return; } -void usage(void) { - printf("opencalea usage...\n"); +void print_usage(void) { + printf("OpenCALEA usage...\n"); return; } Modified: trunk/src/opencalea.h =================================================================== --- trunk/src/opencalea.h 2007-05-14 22:28:37 UTC (rev 37) +++ trunk/src/opencalea.h 2007-05-16 19:17:37 UTC (rev 38) @@ -29,7 +29,12 @@ /* function prototypes */ void parse_commandline(int argc, char *argv[]); -void usage(void); +void print_usage(void); +void display_prompt(int level); +void get_input(char *buffer, size_t buffer_len, FILE *file); +int process_arg(int level, char *arg); +int process_input(int level, char *buffer); +void print_help(int level); char *prog_name = "opencalea"; int syslog_facility = DEF_SYSLOG_FACILITY; @@ -55,4 +60,51 @@ char *debug_file_name = NULL; char *log_file_name = NULL; +enum e_state +{ + STATE_QUIT = 0, + STATE_NONE, + STATE_START, + STATE_START_INTERCEPT, + STATE_START_INTERCEPT_FILE, + STATE_START_DF_COLLECTOR, + STATE_START_DF_COLLECTOR_FILE, + STATE_START_CONTROLLERD, + STATE_START_CONTROLLERD_FILE, + STATE_START_LEA_COLLECTOR, + STATE_START_LEA_COLLECTOR_FILE, + STATE_START_TAP, + STATE_START_TAP_FILE, + STATE_STOP, + STATE_STOP_INTERCEPT, + STATE_STOP_INTERCEPT_FILE, + STATE_STOP_DF_COLLECTOR, + STATE_STOP_DF_COLLECTOR_FILE, + STATE_STOP_CONTROLLERD, + STATE_STOP_CONTROLLERD_FILE, + STATE_STOP_LEA_COLLECTOR, + STATE_STOP_LEA_COLLECTOR_FILE, + STATE_STOP_TAP, + STATE_STOP_TAP_FILE, + STATE_STATUS, + STATE_STATUS_INTERCEPT, + STATE_STATUS_INTERCEPT_FILE, + STATE_STATUS_DF_COLLECTOR, + STATE_STATUS_DF_COLLECTOR_FILE, + STATE_STATUS_CONTROLLERD, + STATE_STATUS_CONTROLLERD_FILE, + STATE_STATUS_LEA_COLLECTOR, + STATE_STATUS_LEA_COLLECTOR_FILE, + STATE_STATUS_TAP, + STATE_STATUS_TAP_FILE +}; + +char prompt[MAX_LINE] = "OpenCALEA>"; +char file_intercept[MAX_LINE]; +char file_df_collector[MAX_LINE]; +char file_controllerd[MAX_LINE]; +char file_lea_collector[MAX_LINE]; +char file_tap[MAX_LINE]; + + #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jn...@us...> - 2007-05-14 22:28:37
|
Revision: 37 http://opencalea.svn.sourceforge.net/opencalea/?rev=37&view=rev Author: jnorell Date: 2007-05-14 15:28:37 -0700 (Mon, 14 May 2007) Log Message: ----------- adding sample intercept conf file Added Paths: ----------- trunk/etc/opencalea/intercept.conf Added: trunk/etc/opencalea/intercept.conf =================================================================== --- trunk/etc/opencalea/intercept.conf (rev 0) +++ trunk/etc/opencalea/intercept.conf 2007-05-14 22:28:37 UTC (rev 37) @@ -0,0 +1,36 @@ +# don't know the proper place for this file yet... probably not /etc, but it's here for now + +[Intercept] +caseid = blah +start = date +stop = date +type = ias-cmc + +[Subject] +identifier = 1.2.3.4 +type = ip_addr +agent_type = dhcp + +[LEA] +host = input.fbi.gov +protocol = udp +cmii_port = 1234 +cmc_port = 1235 +cmc_format = udp_encaps + +[OpenCALEA] +df_collector = df.localdomain.com +df_port = 41805 +df_prot = tcp +log_host = df.localdomain.com +log_port = 41805 +log_prot = tcp + +[STATE] +# don't change this stuff manually +state = fully_running +agent1 = dhcp_cmii_agent +agent1_args = ip 1.2.3.4 +agent2 = tap +agent2_args = host 1.2.3.4 + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jn...@us...> - 2007-05-14 19:48:28
|
Revision: 36 http://opencalea.svn.sourceforge.net/opencalea/?rev=36&view=rev Author: jnorell Date: 2007-05-14 12:48:26 -0700 (Mon, 14 May 2007) Log Message: ----------- Documentation update (and small length check in df_collector). Modified Paths: -------------- trunk/doc/MICRO-HOWTO trunk/doc/Makefile.am trunk/doc/Makefile.in trunk/doc/README trunk/doc/TODO trunk/doc/TODO.df_collector trunk/doc/TODO.lea_collector trunk/doc/TODO.tap trunk/man/controllerd.8 trunk/man/df_collector.8 trunk/man/lea_collector.8 trunk/src/df_collector.c Added Paths: ----------- trunk/doc/TODO.opencalea Removed Paths: ------------- trunk/doc/TODO.collector trunk/doc/TODO.controller Modified: trunk/doc/MICRO-HOWTO =================================================================== --- trunk/doc/MICRO-HOWTO 2007-05-14 15:39:37 UTC (rev 35) +++ trunk/doc/MICRO-HOWTO 2007-05-14 19:48:26 UTC (rev 36) @@ -17,28 +17,42 @@ RUNNING --- Start a lea_collector, say on localhost +-- Read opencalea.conf(5) man page - lea_collector -t /tmp/cmii.txt + man 5 opencalea.conf +-- Copy the sample opencalea.conf to /etc/opencalea/opencalea.conf + and edit to suit your needs. + + mkdir /etc/opencalea + cp etc/opencalea/opencalea.conf /etc/opencalea/ + vi /etc/opencalea/opencalea.conf + +-- Start a lea_collector, eg. on localhost + + lea_collector + +-- Start a df_collector, eg. on localhost + + df_collector + -- Start a tap sending data to it - tap -x x -y y -z z -f "host 1.2.3.4" + tap -x "Host 1.2.3.4" -y MyTestCaseID host 1.2.3.4 PROGRAMS -lea_collector: - Currently accepts data from tap(8); needs started before tap(8). - tap: - A network tap, currently sends data to a lea_collector(8). + A network tap, sends data to a df_collector(8). Install on IAPs that will collect packets from the network. -collector: - Used to start/stop taps by a controller(8) client; install on - same machines as tap(8). +df_collector: + A DF (Delivery Function), which collects data for an opencalea + network and sends to the LEA (Law Enforcement Agency). For + testing, use lea_collector. -controller: - Connects to a collector(8) to start/stop taps(8). +lea_collector: + A sample LEA CF (Collection Function); accepts data from + df_collector(8). Modified: trunk/doc/Makefile.am =================================================================== --- trunk/doc/Makefile.am 2007-05-14 15:39:37 UTC (rev 35) +++ trunk/doc/Makefile.am 2007-05-14 19:48:26 UTC (rev 36) @@ -2,13 +2,12 @@ opencaleadir = $(datadir)/opencalea dist_opencalea_DATA = LICENSE \ - TODO.collector \ - TODO.controller \ - TODO.df_collector \ - TODO.lea_collector \ - TODO.tap \ README \ - TODO \ MICRO-HOWTO \ - AUTHORS + AUTHORS \ + TODO \ + TODO.opencalea \ + TODO.df_collector \ + TODO.lea_collector \ + TODO.tap Modified: trunk/doc/Makefile.in =================================================================== --- trunk/doc/Makefile.in 2007-05-14 15:39:37 UTC (rev 35) +++ trunk/doc/Makefile.in 2007-05-14 19:48:26 UTC (rev 36) @@ -165,15 +165,12 @@ top_srcdir = @top_srcdir@ opencaleadir = $(datadir)/opencalea dist_opencalea_DATA = LICENSE \ - TODO.collector \ - TODO.controller \ - TODO.df_collector \ - TODO.lea_collector \ - TODO.tap \ - README \ - TODO \ - MICRO-HOWTO \ - AUTHORS + AUTHORS \ + TODO \ + TODO.opencalea \ + TODO.df_collector \ + TODO.lea_collector \ + TODO.tap all: all-am Modified: trunk/doc/README =================================================================== --- trunk/doc/README 2007-05-14 15:39:37 UTC (rev 35) +++ trunk/doc/README 2007-05-14 19:48:26 UTC (rev 36) @@ -37,6 +37,9 @@ https://www.atis.org/docstore/product.aspx?id=21221 (currently a pre-published ANSI standard) + OpenCALEA is contributing to the design of the WISPA calea standard. +Support will be added as the standard is created. + LICENSE: OpenCALEA is distributed under terms of the modified BSD license. Modified: trunk/doc/TODO =================================================================== --- trunk/doc/TODO 2007-05-14 15:39:37 UTC (rev 35) +++ trunk/doc/TODO 2007-05-14 19:48:26 UTC (rev 36) @@ -3,24 +3,21 @@ GENERAL ------ --- implement config files, including some variables like: +-- create/implement control architecture -[LEA_COLLECTOR] -capturefile_basedir = /var/lib/opencalea/{CaseID}/{IASP_ID} +-- add WISPA standard support (when available) --- define interface to, and create df_collector - --- implement ASN/BER between df_collector and lea_collector - --- change default port numbers to something not reserved - - DOCUMENTATION ------------- --- create man pages - -- create some security pointers/info (currently going in man pages) +-- improve the HOWTO + +-- create some sample forms for tracking CALEA intercepts + +-- create some general CALEA guidelines covering the overall + issue, not just specifics of installing/running OpenCALEA + Deleted: trunk/doc/TODO.collector =================================================================== --- trunk/doc/TODO.collector 2007-05-14 15:39:37 UTC (rev 35) +++ trunk/doc/TODO.collector 2007-05-14 19:48:26 UTC (rev 36) @@ -1,21 +0,0 @@ -OpenCALEA collector TODO - --- rename to "cmd_collector" or something more self-descriptive - --- create a method to invoke other commands beside tap(8) - (or rename to "tap_collector", and make similar "collector" - programs for other CmII/CmC agents) - --- better command parsing - --- fix process monitoring (eg. if a tap(8) exits/dies, need - to catch that and clean up the process list) - --- implement authentication for controller!! - --- tcp connection from controller(s) - --- tcp wrappers support - --- run as non-root, with tap(8) setuid - Deleted: trunk/doc/TODO.controller =================================================================== --- trunk/doc/TODO.controller 2007-05-14 15:39:37 UTC (rev 35) +++ trunk/doc/TODO.controller 2007-05-14 19:48:26 UTC (rev 36) @@ -1,8 +0,0 @@ -OpenCALEA controller TODO - --- better command parsing - --- implement authentication to collector!! - --- tcp connection to controller - Modified: trunk/doc/TODO.df_collector =================================================================== --- trunk/doc/TODO.df_collector 2007-05-14 15:39:37 UTC (rev 35) +++ trunk/doc/TODO.df_collector 2007-05-14 19:48:26 UTC (rev 36) @@ -1,11 +1,8 @@ OpenCALEA df_collector TODO --- define an interface to send CmII and CmC events to, -potentially using xml so 3rd party CmII/CmC agents are -easier to create +-- Implement tcpwrappers and possibly also internal acls to only + accept traffic from agents we're supposed to --- convert the CmII/CmC agent interface data to ASN.1/BER -to send to lea_collector +-- Implement some authentication between agents and df_collector, + and to/from controllerd --- accept CmII (and CmC?) on tcp socket - Modified: trunk/doc/TODO.lea_collector =================================================================== --- trunk/doc/TODO.lea_collector 2007-05-14 15:39:37 UTC (rev 35) +++ trunk/doc/TODO.lea_collector 2007-05-14 19:48:26 UTC (rev 36) @@ -1,7 +1,5 @@ OpenCALEA lea_collector TODO --- change to receive ASN/BER from df_collector once df_collector is created - -- Save data to a default location based on CaseID, time, pid and optionally IaspID. Eg. Copied: trunk/doc/TODO.opencalea (from rev 27, trunk/doc/TODO.controller) =================================================================== --- trunk/doc/TODO.opencalea (rev 0) +++ trunk/doc/TODO.opencalea 2007-05-14 19:48:26 UTC (rev 36) @@ -0,0 +1,4 @@ +OpenCALEA opencalea (controlling ui) TODO + +-- implement authentication to controllerd + Modified: trunk/doc/TODO.tap =================================================================== --- trunk/doc/TODO.tap 2007-05-14 15:39:37 UTC (rev 35) +++ trunk/doc/TODO.tap 2007-05-14 19:48:26 UTC (rev 36) @@ -1,14 +1,11 @@ OpenCALEA tap TODO --- change to use df_collector interface +-- implement additional output formats (raw, pcap, wispa) --- re-impliment always dropping root privs once some install -documentation covers that +-- implement authentication to (and from?) df_collector --- remove "-f" flag, and use all remaining commandline args -(after getopt) as the filter +-- implement authentication to/from collectord --- target design for running as root and changing uid asap -(though support running as a user with appropriate capabilities). -ultimately collector should run as non-root, with tap setuid. +-- change -x -y and -z requirement according to -c type + (eg. some content types won't need ContentID or IAPSystemID) Modified: trunk/man/controllerd.8 =================================================================== --- trunk/man/controllerd.8 2007-05-14 15:39:37 UTC (rev 35) +++ trunk/man/controllerd.8 2007-05-14 19:48:26 UTC (rev 36) @@ -30,7 +30,7 @@ .\" * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" */ -.TH "controllerd" "8" "conceptware-0.0.1" "The OpenCALEA Project" "OpenCALEA" +.TH "controllerd" "8" "svn-20070514" "The OpenCALEA Project" "OpenCALEA" .SH "NAME" .LP controllerd \- OpenCALEA Control Daemon @@ -46,12 +46,10 @@ [\fB\-D\fR \fIdebug\-file\fR] [\fB\-l\fR \fIlog\-level\fR] [\fB\-L\fR \fIlogfile\fR] - +[\fB\-h\fR] .SH "DESCRIPTION" .LP -This program is the Control Daemon from the OpenCALEA project. It runs as a daemon, listening for tcp connections from OpenCALEA control agents. It is used to tie together all the disparate pieces by sending/receiving messages to start and stop things, check status, and also handles the surveillance log. -.LP -\fBcontrollerd\fR(8) design is still being considered as it's being developed. It may end up being stateful and able to detect/recover from crashes, or could end up event driven and stateless (manual crash recovery). Check back soon for more info. +This program is the Control Daemon from the OpenCALEA project. It runs as a daemon, listening for tcp connections from OpenCALEA control agents. It is used to tie together all the disparate pieces by sending/receiving messages to start and stop things and check status. .SH "OPTIONS" .LP @@ -120,6 +118,10 @@ .br Default: \fBLog_Destination\fR from config file or \fBsyslog\fR. + +.TP +\fB\-h\fR +Prints help / usage message. .SH "FILES" .LP .TP @@ -135,14 +137,11 @@ \fBcontrollerd\fR .SH "AUTHORS" .LP -Jesse Norell <je...@kc...> -.br -Henry F. Camacho Jr. <hf...@un...> +Norman Brandinger <no...@go...> .SH "SEE ALSO" .LP -\fIcontroller\fR(8), \fIdhcp_cmii_controller\fR(8), -\fIopencalea\fR(8), \fIradius_cmii_controller\fR(8), -\fItap_controller\fR(8) +\fIopencalea\fR(8), \fIdhcp_cmii_controller\fR(8), +\fIradius_cmii_controller\fR(8), \fItap_controller\fR(8) .LP \fIcontrollerd.conf\fR(5), \fIopencalea.conf\fR(5) .LP @@ -161,7 +160,7 @@ OpenCALEA is following the development of the WISPA standard for data capture and will add support when possible. .SH "SECURITY" .LP -\fBcontrollerd\fR(8) is currently conceptware. This section will be updated as the implementation unfolds. +This section will be updated as the implementation unfolds. .SH "BUGS" .LP Please report all bugs to the OpenCALEA mailing list at: Modified: trunk/man/df_collector.8 =================================================================== --- trunk/man/df_collector.8 2007-05-14 15:39:37 UTC (rev 35) +++ trunk/man/df_collector.8 2007-05-14 19:48:26 UTC (rev 36) @@ -30,7 +30,7 @@ .\" * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" */ -.TH "df_collector" "8" "svn-20070502" "The OpenCALEA Project" "OpenCALEA" +.TH "df_collector" "8" "svn-20070514" "The OpenCALEA Project" "OpenCALEA" .SH "NAME" .LP df_collector \- OpenCALEA Delivery Function (DF) @@ -42,13 +42,12 @@ [\fB\-g\fR \fIgroup\fR] [\fB\-b\fR \fIbind\-addr\fR] [\fB\-p\fR \fIdf\-port\fR] -[\fB\-d\fR \fIdestination\fR] -[\fB\-M\fR \fIcf\-cmc\-port\fR] -[\fB\-N\fR \fIcf\-cmii\-port\fR] [\fB\-v\fR [\fI...\fR]] [\fB\-D\fR \fIdebug\-file\fR] [\fB\-l\fR \fIlog\-level\fR] [\fB\-L\fR \fIlogfile\fR] +[\fB\-L\fR] +[\fB\-h\fR] .SH "DESCRIPTION" .LP @@ -96,33 +95,39 @@ Default: \fBDF_Port\fR from config file or \fB41805\fR. .TP -\fB\-d\fR \fIdestination\fR -Specifies the \fIdestination\fR CF host to send CmII and CmC to. -For testing this host should be running \fIlea_collector\fR(8). +\fB\-v\fR [\fI...\fR] +Enable debugging (\fB\-d\fR was taken). Use multiple times to increase verbosity. .br -Default: \fBCF_Destination\fR \fBlocalhost\fR (127.0.0.1). +Default: \fBDebug_Level\fR from config file or off. .TP -\fB\-M\fR \fIcf\-cmc\-port\fR -Specifies the \fIport\fR on \fIdestination\fR above to send CmC data to. +\fB\-D\fR \fIdebug\-file\fR +Specifies where to debug to. +Valid values are \fBstdout\fR, \fBstderr\fR, \fBsyslog\fR or a \fIfilename\fR. .br -Default: \fBCF_CmC_Port\fR from config file or \fB41820\fR. +Default: \fBDebug_Destination\fR from config file or \fBsyslog\fR. .TP -\fB\-N\fR \fIcf\-cmii\-port\fR -Specifies the \fIport\fR on \fIdestination\fR above to send CmII data to. +\fB\-l\fR \fIlog\-level\fR +Specifies log level. +\fIlog\-level\fR should be a numeric value from \fB1\fR (least) to \fB5\fR (most). .br -Default: \fBCF_CmII_Port\fR from config file or \fB41810\fR. +Default: \fBLog_Level\fR from config file or \fB1\fR. .TP -\fB\-o\fR \fIcmii\-output\-format\fR -Specifies the \fICmII output format\fR. Valid values are \fBber\fR or \fBxml\fR. +\fB\-L\fR \fIlogfile\fR +Specifies where to log to. +Valid values are \fBstdout\fR, \fBstderr\fR, \fBsyslog\fR or a \fIfilename\fR. + .br -Default: \fBCmII_Output_Format\fR from config file or \fBber\fR. +Default: \fBLog_Destination\fR from config file or \fBsyslog\fR. +.TP +\fB\-h\fR +Prints help / usage message. .SH "FILES" .LP .TP @@ -139,6 +144,8 @@ .SH "AUTHORS" .LP Norman Brandinger <no...@go...> +.br +Jesse Norell <je...@kc...> .SH "SEE ALSO" .LP \fIcontrollerd\fR(8), \fIlea_collector\fR(8), \fIopencalea\fR(8), @@ -161,7 +168,9 @@ OpenCALEA is following the development of the WISPA standard for data capture and will add support when possible. .SH "SECURITY" .LP -This section will be updated as the implementation unfolds. +\fBdf_collector\fR(8) can accept UDP or TCP input; use of TCP reduces risk of malicious packet injection from illegitimate sources. +.LP +Currently \fBdf_collector\fR(8) does not support tcp wrappers or have any client connection restrictions. .SH "BUGS" .LP Please report all bugs to the OpenCALEA mailing list at: Modified: trunk/man/lea_collector.8 =================================================================== --- trunk/man/lea_collector.8 2007-05-14 15:39:37 UTC (rev 35) +++ trunk/man/lea_collector.8 2007-05-14 19:48:26 UTC (rev 36) @@ -30,87 +30,122 @@ .\" * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" */ -.TH "lea_collector" "8" "svn-20070502" "The OpenCALEA Project" "OpenCALEA" +.TH "lea_collector" "8" "svn-20070514" "The OpenCALEA Project" "OpenCALEA" .SH "NAME" .LP lea_collector \- OpenCALEA Law Enforcement Agency (LEA) Collection Function (CF) .SH "SYNTAX" .LP \fBlea_collector\fR -\fB\-t\fR \fIcmii\-capture\-file\fR -[\fB\-f\fR \fIcmc\-capture\-file\fR] -[\fB\-b\fR \fIbind\-addr\fR] +[\fB\-f\fR \fIconfig\-file\fR] [\fB\-u\fR \fIuser\fR] [\fB\-g\fR \fIgroup\fR] -[\fB\-m\fR \fIcmc\-port\fR] -[\fB\-n\fR \fIcmii\-port\fR] -[\fB\-x\fR] +[\fB\-b\fR \fIbind\-addr\fR] +[\fB\-p\fR \fIcmii\-port\fR] +[\fB\-c\fR \fIcmii\-content\-type\fR] +[\fB\-P\fR \fIcmc\-port\fR] +[\fB\-C\fR \fIcmc\-content\-type\fR] [\fB\-v\fR [\fI...\fR]] [\fB\-D\fR \fIdebug\-file\fR] [\fB\-l\fR \fIlog\-level\fR] [\fB\-L\fR \fIlogfile\fR] +[\fB\-h\fR] .SH "DESCRIPTION" .LP -This program is a LEA (Law Enforcement Agency) CF (Collection Function) from the OpenCALEA project. It currently only accepts data from one or more \fItap\fR(8) programs, outputs a plaintext \fIcmii\-capture\-file\fR and optionally also a \fIcmc\-capture\-file\fR in pcap format. -.LP -\fBlea_collector\fR(8) is planned to undergo substantial redesign with the implementation of \fBdf_collector\fR(8). +This program is a LEA (Law Enforcement Agency) CF (Collection Function) from the OpenCALEA project. It accepts data from one or more \fIdf_collector\fR(8) programs, which is the collective output of an OpenCALEA network for an intercept. .SH "OPTIONS" .LP .TP -\fB\-t\fR \fIcmii\-capture\-file\fR -Specify the file to write CmII data to (plaintext). -.br -Default: none. +\fB\-f\fR \fIconfig\-file\fR +Specifies an alternate \fIconfig file\fR. -.TP -\fB\-f\fR \fIcmc\-capture\-file\fR -Specify file to save CmC data to (pcap format). -\fBlea_collector\fR will not listen on the -\fIcmc\-port\fR if you do not use this option. .br -Default: none. +Default: see FILES below. .TP -\fB\-b\fR \fIbind\-addr\fR -Specifies the ip address to bind to. -.br -Default: \fBBind_Addr\fR from config file or 0.0.0.0 (any) - -.TP \fB\-u\fR \fIuser\fR Specifies the \fIuser\fR to change to if run as root. + .br Default: \fBUser\fR from config file or \fBcalea\fR. .TP \fB\-g\fR \fIgroup\fR Specifies the \fIgroup\fR to change to if run as root. + .br -Default: \fBGroup\fR from config file or \fBcalea\fR. +Default: \fBGroup\fR from config file or \fBcalea\fR .TP -\fB\-m\fR \fIcmc\-port\fR -Specifies the \fIport\fR to listen on for CmC data. -Requires \fB\-f\fR to be specified. +\fB\-b\fR \fIbind\-addr\fR +Specifies the ip address to bind to. + .br -Default: \fBCmC_Port\fR from config file or \fB6666\fR (this will change). +Default: \fBBind_Addr\fR from config file or 0.0.0.0 (any) .TP -\fB\-n\fR \fIcmii\-port\fR +\fB\-p\fR \fIcmii\-port\fR Specifies the \fIport\fR to listen on for CmII data. +As all intercepts include Identifying Information, +you must always provide this port. + .br -Default: \fBCmII_Port\fR from config file or \fB6667\fR (this will change). +Default: \fBCmII_Port\fR from config file or \fB41810\fR. +Required: yes +TP> +\fB\-c\fR \fIcmii\-content\-type\fR +Specifies the type of CmII content to receive. +Valid values of \fIcmii\-content\-type\fR are: + +.br +\fBvop\-cii\fR Receive ATIS VOP CII. +.br +\fBias\-cmii\fR Receive ATIS IAS CmII. +.br +\fBraw\fR Receive OSI layer 3 packets (no formatting). +.br +\fBpcap\fR Receive packets with link layer headers in pcap format. + +.br +Default: \fBCmII_Content_Type\fR from config file. +.br +Required: yes. + .TP -\fB\-x\fR -Enable cooked format. A description of that would be great. +\fB\-P\fR \fIcmc\-port\fR +Specifies the \fIport\fR to listen on for CmC data. +Only required for full content intercepts. + .br -Default: disabled. +Default: \fBCmC_Port\fR from config file or \fB41820\fR. +TP> +\fB\-C\fR \fIcmc\-content\-type\fR +Specifies the type of CmC content to receive. +Valid values of \fIcmc\-content\-type\fR are: + +.br +\fBvop\-cc\fR Receive ATIS VOP CC (CC\-APDU). +.br +\fBias\-cmc\fR Receive ATIS IAS CmC (IAS\-CC\-APDU). +.br +\fBias\-cmc\-udp\fR Receive ATIS IAS CmC (Annex D.3.1 udp encapsulation) +.br +\fBraw\fR Receive OSI layer 3 packets (no formatting). +.br +\fBpcap\fR Receive packets with link layer headers in pcap format. + +.br +Default: \fBCmC_Content_Type\fR from config file. +.br +Required: yes. + .TP \fB\-v\fR [\fI...\fR] Enable debugging (\fB\-d\fR was taken). Use multiple times to increase verbosity. + .br Default: \fBDebug_Level\fR from config file or off. @@ -118,6 +153,7 @@ \fB\-D\fR \fIdebug\-file\fR Specifies where to debug to. Valid values are \fBstdout\fR, \fBstderr\fR, \fBsyslog\fR or a \fIfilename\fR. + .br Default: \fBDebug_Destination\fR from config file or \fBsyslog\fR. @@ -125,6 +161,7 @@ \fB\-l\fR \fIlog\-level\fR Specifies log level. \fIlog\-level\fR should be a numeric value from \fB1\fR (least) to \fB5\fR (most). + .br Default: \fBLog_Level\fR from config file or \fB1\fR. @@ -132,8 +169,13 @@ \fB\-L\fR \fIlogfile\fR Specifies where to log to. Valid values are \fBstdout\fR, \fBstderr\fR, \fBsyslog\fR or a \fIfilename\fR. + .br Default: \fBLog_Destination\fR from config file or \fBsyslog\fR. + +.TP +\fB\-h\fR +Prints help / usage message. .SH "FILES" .LP \fBNote: config files are not yet used\fR Modified: trunk/src/df_collector.c =================================================================== --- trunk/src/df_collector.c 2007-05-14 15:39:37 UTC (rev 35) +++ trunk/src/df_collector.c 2007-05-14 19:48:26 UTC (rev 36) @@ -90,7 +90,7 @@ int i=0; /* command line options processing */ - while (( i = getopt ( argc, argv, "f:u:g:b:p:m:n:vD:l:L:h" )) != -1 ) { + while (( i = getopt ( argc, argv, "f:u:g:b:p:vD:l:L:h" )) != -1 ) { switch ( i ) { case 'f': // config file @@ -310,9 +310,9 @@ /* Make CmII directory based on the CaseID */ /*******************************************/ bzero(filename,MAX_LINE); - strcat(filename,cmii_path); - strcat(filename,"/"); - strcat(filename,(char *)ctrlmsg->ctrlh.intercept.CaseID); + strncat(filename,cmii_path,MAX_LINE - strlen(filename)); + strncat(filename,"/",MAX_LINE - strlen(filename)); + strncat(filename,(char *)ctrlmsg->ctrlh.intercept.CaseID,MAX_LINE - strlen(filename)); status = mkdir(filename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); if (status == -1) { switch (errno) { @@ -320,7 +320,8 @@ debug_5("df_collector: CmII mkdir %s", strerror(errno)); break; default: - debug_5("df_collector: CmII mkdir %s", strerror(errno)); + debug_2("df_collector: CmII mkdir %s", strerror(errno)); + log_2("df_collector: CmII mkdir %s", strerror(errno)); } } @@ -343,9 +344,9 @@ /* Make CmC directory based on the CaseID */ /******************************************/ bzero(filename,MAX_LINE); - strcat(filename,cmc_path); - strcat(filename,"/"); - strcat(filename,(char *)ctrlmsg->ctrlh.intercept.CaseID); + strncat(filename,cmc_path,MAX_LINE - strlen(filename)); + strncat(filename,"/",MAX_LINE - strlen(filename)); + strncat(filename,(char *)ctrlmsg->ctrlh.intercept.CaseID,MAX_LINE - strlen(filename)); status = mkdir(filename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); if (status == -1) { switch (errno) { @@ -353,7 +354,8 @@ debug_5("df_collector: CmC mkdir %s", strerror(errno)); break; default: - debug_5("df_collector: CmC mkdir %s", strerror(errno)); + debug_2("df_collector: CmC mkdir %s", strerror(errno)); + log_2("df_collector: CmC mkdir %s", strerror(errno)); } } @@ -668,7 +670,7 @@ printf ( " [-f config-file]" ); printf ( " [-u user] [-g group]" ); printf ( " [-b bind-addr] " ); - printf ( " [-m cmc-port] [-n cmii-port] [-x]" ); + printf ( " [-p df-port] " ); printf ( " [-v [...]] [-D debug-file]" ); printf ( " [-l log-level ] [-L logfile]" ); printf ( " [-h]" ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nor...@us...> - 2007-05-14 15:23:02
|
Revision: 34 http://opencalea.svn.sourceforge.net/opencalea/?rev=34&view=rev Author: norm_brandinger Date: 2007-05-14 08:22:45 -0700 (Mon, 14 May 2007) Log Message: ----------- Minor update to opencalea.c stub Modified Paths: -------------- trunk/src/opencalea.c Modified: trunk/src/opencalea.c =================================================================== --- trunk/src/opencalea.c 2007-05-14 12:17:52 UTC (rev 33) +++ trunk/src/opencalea.c 2007-05-14 15:22:45 UTC (rev 34) @@ -29,17 +29,65 @@ #include "calea.h" #include "opencalea.h" +void display_prompt(); +void get_input(char *buffer, size_t buffer_len, FILE *file); +int process_input(char *buffer); + int main(int argc, char *argv[]) { + char buffer[MAX_LINE+1]; + + setdebug( DEF_DEBUG_LEVEL, DEF_DEBUG_DEST, 1 ); //setdebug( 5, "stdout", 1 ); - setdebug( DEF_DEBUG_LEVEL, DEF_DEBUG_DEST, 1 ); setlog( DEF_LOG_LEVEL, DEF_LOG_DEST, 1 ); parse_commandline(argc, argv); + for (;;) { + display_prompt(); + get_input(buffer, MAX_LINE, stdin); + if (!process_input(buffer)) + break; + } + return 0; } +void display_prompt() { + printf("OpenCALEA> "); + fflush (stdout); +} + +void get_input(char *buffer, size_t buffer_len, FILE *file) { + size_t last; + + bzero(buffer,buffer_len+1); + if (fgets (buffer, buffer_len, file)) { + last = strlen (buffer) - 1; + + if (buffer[last] == '\n') { + buffer[last] = '\0'; + } else { + fscanf (file, "%*[^\n]"); + fgetc(file); + } + } + + return; +} + +int process_input(char *buffer) { + + if ( !strncmp(buffer, "quit", 4) || !strncmp(buffer, "exit", 4) ) + return 0; + + printf("OpenCALEA> [%s]\n", buffer); + fflush (stdout); + + return 1; + +} + void parse_commandline(int argc, char *argv[]) { int i=0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jn...@us...> - 2007-05-11 23:10:11
|
Revision: 32 http://opencalea.svn.sourceforge.net/opencalea/?rev=32&view=rev Author: jnorell Date: 2007-05-11 16:10:08 -0700 (Fri, 11 May 2007) Log Message: ----------- Broke up the first three process_packet functions such that they may be doing their intended job. Ie: process_packet_cc_apdu process_packet_cmii_pdhr process_packet_cmc_pdhr This is untested. Modified Paths: -------------- trunk/src/packet_processing.c Modified: trunk/src/packet_processing.c =================================================================== --- trunk/src/packet_processing.c 2007-05-11 22:53:48 UTC (rev 31) +++ trunk/src/packet_processing.c 2007-05-11 23:10:08 UTC (rev 32) @@ -53,7 +53,6 @@ struct udphdr *udp; struct tcphdr *tcp; Msg *cmc_pkt; - Msg *cmii_pkt; int total_pkt_length; int ip_size; int tcp_size; @@ -62,7 +61,6 @@ int ip_size_total; const char *payload; /* Packet Payload */ HEADER *dfheader; - char calea_time[TS_LENGTH]; dfheader = (HEADER *)args; @@ -71,8 +69,6 @@ memset ( msg, '\0', MAX_LOG_DEBUG_MSG_LEN ); #endif - get_calea_time ( header->ts.tv_sec, header->ts.tv_usec, &calea_time[0] ); - dfheader->sec = header->ts.tv_sec; dfheader->usec = header->ts.tv_usec/100; @@ -155,77 +151,36 @@ dfheader->dstPort = 0; } + //debug_5("IP (%d bytes):", ip_size_total); + //print_hex((const u_char *)ip, (size_t)ip_size_total); + + dfheader->sequenceNumber++; + dfheader->payload = (const char *)ip; + dfheader->payload_size = (size_t)ip_size_total; /*------------------------------------------------------------------------*/ - /* only send Communications Content CmC msg if requested */ + /* WARNING: cc_apdu will allocate space for the BER encoded message. */ + /* This space MUST be freed when it is no longer needed or a */ + /* memory leak will occur. */ + /* */ + /* The address of the allocated memory is dfheader->encoded. */ + /* The size of the allocated memory is dfheader->encoded_size. */ + /* If cc_apdu does not return 0, no deallocation is needed. */ /*------------------------------------------------------------------------*/ - if ( content_option == 1 ) { - - //debug_5("IP (%d bytes):", ip_size_total); - //print_hex((const u_char *)ip, (size_t)ip_size_total); - - dfheader->sequenceNumber++; - dfheader->payload = (const char *)ip; - dfheader->payload_size = (size_t)ip_size_total; - /*------------------------------------------------------------------------*/ - /* WARNING: cc_apdu will allocate space for the BER encoded message. */ - /* This space MUST be freed when it is no longer needed or a */ - /* memory leak will occur. */ - /* */ - /* The address of the allocated memory is dfheader->encoded. */ - /* The size of the allocated memory is dfheader->encoded_size. */ - /* If cc_apdu does not return 0, no deallocation is needed. */ - /*------------------------------------------------------------------------*/ - if ( cc_apdu(dfheader) == 0) { - debug_5("Encoded addr(size): %p(%Zd)", dfheader->encoded_size, dfheader->encoded); - } else { - debug_5("cc_apdu returned nonzero"); - return; - } - - total_pkt_length = sizeof(Msg) + dfheader->encoded_size; - debug_5 ( "building CmC packet size: %d", total_pkt_length ); - cmc_pkt = CmCPacketBuild ( dfheader ); - debug_5 ( "sending CmC packet size: %d", total_pkt_length ); - PacketSend ( cmc_pkt, total_pkt_length, &send_df_socket ); - PacketFree ( cmc_pkt ); - - free(dfheader->encoded); - - } - - if (packet_data_header_report(dfheader) == 0) { - debug_5("Packet_Data_Header_Report encoded addr: %p, size: %Zd", dfheader->encoded, dfheader->encoded_size); - //print_hex((const u_char *)dfheader->encoded, (size_t)dfheader->encoded_size); + if ( cc_apdu(dfheader) == 0) { + debug_5("Encoded addr(size): %p(%Zd)", dfheader->encoded_size, dfheader->encoded); } else { + debug_5("cc_apdu returned nonzero"); return; } total_pkt_length = sizeof(Msg) + dfheader->encoded_size; - debug_5 ( "building T1.IAS CmII packet size: %d", total_pkt_length); - cmii_pkt = CmIIPacketBuild ( dfheader ); - debug_5 ( "sending T1.IAS CmII packet size: %d", total_pkt_length ); - //print_hex((const u_char *)cmii_pkt, (size_t)total_pkt_length); - PacketSend ( cmii_pkt, total_pkt_length, &send_df_socket ); - PacketFree ( cmii_pkt ); + debug_5 ( "building CmC packet size: %d", total_pkt_length ); + cmc_pkt = CmCPacketBuild ( dfheader ); + debug_5 ( "sending CmC packet size: %d", total_pkt_length ); + PacketSend ( cmc_pkt, total_pkt_length, &send_df_socket ); + PacketFree ( cmc_pkt ); free(dfheader->encoded); - - if (directsignalreporting(dfheader) == 0) { - debug_5("Direct Signal Reporting encoded addr: %p, size: %Zd", dfheader->encoded, dfheader->encoded_size); - //print_hex((const u_char *)dfheader->encoded, (size_t)dfheader->encoded_size); - } else { - return; - } - - total_pkt_length = sizeof(Msg) + dfheader->encoded_size; - debug_5 ( "building T1.678 CmII packet size: %d", total_pkt_length); - cmii_pkt = CmIIPacketBuild ( dfheader ); - debug_5 ( "sending T1.678 CmII packet size: %d", total_pkt_length ); - //print_hex((const u_char *)cmii_pkt, (size_t)total_pkt_length); - PacketSend ( cmii_pkt, total_pkt_length, &send_df_socket ); - PacketFree ( cmii_pkt ); - - free(dfheader->encoded); } @@ -238,7 +193,6 @@ struct ip *ip; struct udphdr *udp; struct tcphdr *tcp; - Msg *cmc_pkt; Msg *cmii_pkt; int total_pkt_length; int ip_size; @@ -248,7 +202,6 @@ int ip_size_total; const char *payload; /* Packet Payload */ HEADER *dfheader; - char calea_time[TS_LENGTH]; dfheader = (HEADER *)args; @@ -257,8 +210,6 @@ memset ( msg, '\0', MAX_LOG_DEBUG_MSG_LEN ); #endif - get_calea_time ( header->ts.tv_sec, header->ts.tv_usec, &calea_time[0] ); - dfheader->sec = header->ts.tv_sec; dfheader->usec = header->ts.tv_usec/100; @@ -342,43 +293,15 @@ } /*------------------------------------------------------------------------*/ - /* only send Communications Content CmC msg if requested */ + /* WARNING: packet_data_header_report will allocate space for the BER */ + /* encoded message. This space MUST be freed when it is no */ + /* longer needed or a memory leak will occur. */ + /* */ + /* The address of the allocated memory is dfheader->encoded. */ + /* The size of the allocated memory is dfheader->encoded_size. */ + /* If packet_data_header_report does not return 0, no deallocation is needed. */ /*------------------------------------------------------------------------*/ - if ( content_option == 1 ) { - //debug_5("IP (%d bytes):", ip_size_total); - //print_hex((const u_char *)ip, (size_t)ip_size_total); - - dfheader->sequenceNumber++; - dfheader->payload = (const char *)ip; - dfheader->payload_size = (size_t)ip_size_total; - /*------------------------------------------------------------------------*/ - /* WARNING: cc_apdu will allocate space for the BER encoded message. */ - /* This space MUST be freed when it is no longer needed or a */ - /* memory leak will occur. */ - /* */ - /* The address of the allocated memory is dfheader->encoded. */ - /* The size of the allocated memory is dfheader->encoded_size. */ - /* If cc_apdu does not return 0, no deallocation is needed. */ - /*------------------------------------------------------------------------*/ - if ( cc_apdu(dfheader) == 0) { - debug_5("Encoded addr(size): %p(%Zd)", dfheader->encoded_size, dfheader->encoded); - } else { - debug_5("cc_apdu returned nonzero"); - return; - } - - total_pkt_length = sizeof(Msg) + dfheader->encoded_size; - debug_5 ( "building CmC packet size: %d", total_pkt_length ); - cmc_pkt = CmCPacketBuild ( dfheader ); - debug_5 ( "sending CmC packet size: %d", total_pkt_length ); - PacketSend ( cmc_pkt, total_pkt_length, &send_df_socket ); - PacketFree ( cmc_pkt ); - - free(dfheader->encoded); - - } - if (packet_data_header_report(dfheader) == 0) { debug_5("Packet_Data_Header_Report encoded addr: %p, size: %Zd", dfheader->encoded, dfheader->encoded_size); //print_hex((const u_char *)dfheader->encoded, (size_t)dfheader->encoded_size); @@ -396,22 +319,6 @@ free(dfheader->encoded); - if (directsignalreporting(dfheader) == 0) { - debug_5("Direct Signal Reporting encoded addr: %p, size: %Zd", dfheader->encoded, dfheader->encoded_size); - //print_hex((const u_char *)dfheader->encoded, (size_t)dfheader->encoded_size); - } else { - return; - } - - total_pkt_length = sizeof(Msg) + dfheader->encoded_size; - debug_5 ( "building T1.678 CmII packet size: %d", total_pkt_length); - cmii_pkt = CmIIPacketBuild ( dfheader ); - debug_5 ( "sending T1.678 CmII packet size: %d", total_pkt_length ); - //print_hex((const u_char *)cmii_pkt, (size_t)total_pkt_length); - PacketSend ( cmii_pkt, total_pkt_length, &send_df_socket ); - PacketFree ( cmii_pkt ); - - free(dfheader->encoded); } @@ -435,7 +342,6 @@ int ip_size_total; const char *payload; /* Packet Payload */ HEADER *dfheader; - char calea_time[TS_LENGTH]; dfheader = (HEADER *)args; @@ -444,8 +350,6 @@ memset ( msg, '\0', MAX_LOG_DEBUG_MSG_LEN ); #endif - get_calea_time ( header->ts.tv_sec, header->ts.tv_usec, &calea_time[0] ); - dfheader->sec = header->ts.tv_sec; dfheader->usec = header->ts.tv_usec/100; @@ -528,44 +432,48 @@ dfheader->dstPort = 0; } + + //debug_5("IP (%d bytes):", ip_size_total); + //print_hex((const u_char *)ip, (size_t)ip_size_total); + + dfheader->sequenceNumber++; + dfheader->payload = (const char *)ip; + dfheader->payload_size = (size_t)ip_size_total; /*------------------------------------------------------------------------*/ - /* only send Communications Content CmC msg if requested */ + /* WARNING: cc_apdu will allocate space for the BER encoded message. */ + /* This space MUST be freed when it is no longer needed or a */ + /* memory leak will occur. */ + /* */ + /* The address of the allocated memory is dfheader->encoded. */ + /* The size of the allocated memory is dfheader->encoded_size. */ + /* If cc_apdu does not return 0, no deallocation is needed. */ /*------------------------------------------------------------------------*/ - if ( content_option == 1 ) { + if ( cc_apdu(dfheader) == 0) { + debug_5("Encoded addr(size): %p(%Zd)", dfheader->encoded_size, dfheader->encoded); + } else { + debug_5("cc_apdu returned nonzero"); + return; + } - //debug_5("IP (%d bytes):", ip_size_total); - //print_hex((const u_char *)ip, (size_t)ip_size_total); + total_pkt_length = sizeof(Msg) + dfheader->encoded_size; + debug_5 ( "building CmC packet size: %d", total_pkt_length ); + cmc_pkt = CmCPacketBuild ( dfheader ); + debug_5 ( "sending CmC packet size: %d", total_pkt_length ); + PacketSend ( cmc_pkt, total_pkt_length, &send_df_socket ); + PacketFree ( cmc_pkt ); - dfheader->sequenceNumber++; - dfheader->payload = (const char *)ip; - dfheader->payload_size = (size_t)ip_size_total; - /*------------------------------------------------------------------------*/ - /* WARNING: cc_apdu will allocate space for the BER encoded message. */ - /* This space MUST be freed when it is no longer needed or a */ - /* memory leak will occur. */ - /* */ - /* The address of the allocated memory is dfheader->encoded. */ - /* The size of the allocated memory is dfheader->encoded_size. */ - /* If cc_apdu does not return 0, no deallocation is needed. */ - /*------------------------------------------------------------------------*/ - if ( cc_apdu(dfheader) == 0) { - debug_5("Encoded addr(size): %p(%Zd)", dfheader->encoded_size, dfheader->encoded); - } else { - debug_5("cc_apdu returned nonzero"); - return; - } + free(dfheader->encoded); - total_pkt_length = sizeof(Msg) + dfheader->encoded_size; - debug_5 ( "building CmC packet size: %d", total_pkt_length ); - cmc_pkt = CmCPacketBuild ( dfheader ); - debug_5 ( "sending CmC packet size: %d", total_pkt_length ); - PacketSend ( cmc_pkt, total_pkt_length, &send_df_socket ); - PacketFree ( cmc_pkt ); - free(dfheader->encoded); - - } - + /*------------------------------------------------------------------------*/ + /* WARNING: packet_data_header_report will allocate space for the BER */ + /* encoded message. This space MUST be freed when it is no */ + /* longer needed or a memory leak will occur. */ + /* */ + /* The address of the allocated memory is dfheader->encoded. */ + /* The size of the allocated memory is dfheader->encoded_size. */ + /* If packet_data_header_report does not return 0, no deallocation is needed. */ + /*------------------------------------------------------------------------*/ if (packet_data_header_report(dfheader) == 0) { debug_5("Packet_Data_Header_Report encoded addr: %p, size: %Zd", dfheader->encoded, dfheader->encoded_size); //print_hex((const u_char *)dfheader->encoded, (size_t)dfheader->encoded_size); @@ -583,25 +491,10 @@ free(dfheader->encoded); - if (directsignalreporting(dfheader) == 0) { - debug_5("Direct Signal Reporting encoded addr: %p, size: %Zd", dfheader->encoded, dfheader->encoded_size); - //print_hex((const u_char *)dfheader->encoded, (size_t)dfheader->encoded_size); - } else { - return; - } - - total_pkt_length = sizeof(Msg) + dfheader->encoded_size; - debug_5 ( "building T1.678 CmII packet size: %d", total_pkt_length); - cmii_pkt = CmIIPacketBuild ( dfheader ); - debug_5 ( "sending T1.678 CmII packet size: %d", total_pkt_length ); - //print_hex((const u_char *)cmii_pkt, (size_t)total_pkt_length); - PacketSend ( cmii_pkt, total_pkt_length, &send_df_socket ); - PacketFree ( cmii_pkt ); - - free(dfheader->encoded); } +// NOTE THIS FUNCTION ISN'T FINISHED - IT'S AN EXACT COPY OF THE OLD process_packet() /* * process_packet_cmc_udp: sends PacketDataHeaderReport structures for IAS CACmII, * and UDP encapsulated IAS CmC (per IAS D.3.1) @@ -622,7 +515,6 @@ int ip_size_total; const char *payload; /* Packet Payload */ HEADER *dfheader; - char calea_time[TS_LENGTH]; dfheader = (HEADER *)args; @@ -631,8 +523,6 @@ memset ( msg, '\0', MAX_LOG_DEBUG_MSG_LEN ); #endif - get_calea_time ( header->ts.tv_sec, header->ts.tv_usec, &calea_time[0] ); - dfheader->sec = header->ts.tv_sec; dfheader->usec = header->ts.tv_usec/100; @@ -789,6 +679,7 @@ } +// NOTE THIS FUNCTION ISN'T FINISHED - IT'S AN EXACT COPY OF THE OLD process_packet() /* * process_packet_raw: sends content raw with no formatting */ @@ -808,7 +699,6 @@ int ip_size_total; const char *payload; /* Packet Payload */ HEADER *dfheader; - char calea_time[TS_LENGTH]; dfheader = (HEADER *)args; @@ -817,8 +707,6 @@ memset ( msg, '\0', MAX_LOG_DEBUG_MSG_LEN ); #endif - get_calea_time ( header->ts.tv_sec, header->ts.tv_usec, &calea_time[0] ); - dfheader->sec = header->ts.tv_sec; dfheader->usec = header->ts.tv_usec/100; @@ -975,6 +863,7 @@ } +// NOTE THIS FUNCTION ISN'T FINISHED - IT'S AN EXACT COPY OF THE OLD process_packet() /* * process_packet_pcap: sends content, with link headers, in pcap packets */ @@ -994,7 +883,6 @@ int ip_size_total; const char *payload; /* Packet Payload */ HEADER *dfheader; - char calea_time[TS_LENGTH]; dfheader = (HEADER *)args; @@ -1003,8 +891,6 @@ memset ( msg, '\0', MAX_LOG_DEBUG_MSG_LEN ); #endif - get_calea_time ( header->ts.tv_sec, header->ts.tv_usec, &calea_time[0] ); - dfheader->sec = header->ts.tv_sec; dfheader->usec = header->ts.tv_usec/100; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jn...@us...> - 2007-05-11 22:53:47
|
Revision: 31 http://opencalea.svn.sourceforge.net/opencalea/?rev=31&view=rev Author: jnorell Date: 2007-05-11 15:53:48 -0700 (Fri, 11 May 2007) Log Message: ----------- Moved process_packet() function to packet_processing.c, and copied to support a separate function per output content type. Currently every function, no matter what the name, is exactly what process_packet used to be, and content_option = 1 is hardcoded. You need to specify "Content_Type" in config file or -c on the command line. Modified Paths: -------------- trunk/man/tap.8 trunk/src/Makefile.am trunk/src/Makefile.in trunk/src/calea.c trunk/src/calea.h trunk/src/log_debug.c trunk/src/msg.h trunk/src/packet_data_header_report.c trunk/src/tap.c trunk/src/tap.h Added Paths: ----------- trunk/src/packet_data_header_report.h trunk/src/packet_processing.c Modified: trunk/man/tap.8 =================================================================== --- trunk/man/tap.8 2007-05-11 16:58:30 UTC (rev 30) +++ trunk/man/tap.8 2007-05-11 22:53:48 UTC (rev 31) @@ -57,7 +57,7 @@ .LP This program is a network tap (packet sniffer) from the OpenCALEA project. It can be invoked to collect CACmII (Content Associated Communications Identifying Information) and CmC (Communication Content) for an intercept subject, which is sent to a running \fBdf_collector\fR(8) program somewhere in the network. .LP -We currently use the same content format for an Internet data tap (T1.IAS standard) and a Voice intercept (T1.678 standard), ie. a \fICC\-APDU\fR structure. More formats will likely be added in the future. The \fB\-c\fR switch will parse other formats, but they're not there yet. +We currently use the same content format for an Internet data tap (T1.I AS standard) and a Voice intercept (T1.678 standard), ie. a \fICC\-APDU\fR structure. More formats will likely be added in the future. The \fB\-c\fR switch will parse other formats, but they're not there yet. .LP \fBtap\fR(8) can be invoked by itself, but is normally started by the \fBtap_controller\fR(8) program. See \fBtap_controller\fR(8) for more information. .SH "OPTIONS" @@ -123,7 +123,7 @@ .br \fBraw\fR Send captured packets, sans link layer headers (no formatting). .br -\fBraw\-full\fR Send captured packets with link layer headers (no formatting). +\fBpcap\fR Send captured packets with link layer headers in pcap format. .br Default: \fBContent_Type\fR from config file. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2007-05-11 16:58:30 UTC (rev 30) +++ trunk/src/Makefile.am 2007-05-11 22:53:48 UTC (rev 31) @@ -10,7 +10,7 @@ controllerd_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS) controllerd_LDADD = -lpthread $(GLIB_LIBS) -tap_SOURCES = tap.c tap.h common.h calea.c calea.h log_debug.c log_debug.h cc_apdu.c packet_data_header_report.c directsignalreporting.c util.h util.c +tap_SOURCES = tap.c tap.h common.h calea.c calea.h log_debug.c log_debug.h cc_apdu.c packet_data_header_report.c directsignalreporting.c util.h util.c packet_processing.c tap_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS) tap_LDADD = -lpcap -Lasn.1/T1.678/CCDeliveryHeader -lCCDeliveryHeader -Lasn.1/T1.IAS/CmII -lCmII -Lasn.1/T1.678/VoP -lVoP $(GLIB_LIBS) Modified: trunk/src/Makefile.in =================================================================== --- trunk/src/Makefile.in 2007-05-11 16:58:30 UTC (rev 30) +++ trunk/src/Makefile.in 2007-05-11 22:53:48 UTC (rev 31) @@ -79,7 +79,8 @@ am_tap_OBJECTS = tap-tap.$(OBJEXT) tap-calea.$(OBJEXT) \ tap-log_debug.$(OBJEXT) tap-cc_apdu.$(OBJEXT) \ tap-packet_data_header_report.$(OBJEXT) \ - tap-directsignalreporting.$(OBJEXT) tap-util.$(OBJEXT) + tap-directsignalreporting.$(OBJEXT) tap-util.$(OBJEXT) \ + tap-packet_processing.$(OBJEXT) tap_OBJECTS = $(am_tap_OBJECTS) tap_DEPENDENCIES = $(am__DEPENDENCIES_1) tap_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ @@ -221,7 +222,7 @@ controllerd_SOURCES = controllerd.c log_debug.c util.c controllerd_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS) controllerd_LDADD = -lpthread $(GLIB_LIBS) -tap_SOURCES = tap.c tap.h common.h calea.c calea.h log_debug.c log_debug.h cc_apdu.c packet_data_header_report.c directsignalreporting.c util.h util.c +tap_SOURCES = tap.c tap.h common.h calea.c calea.h log_debug.c log_debug.h cc_apdu.c packet_data_header_report.c directsignalreporting.c util.h util.c packet_processing.c tap_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS) tap_LDADD = -lpcap -Lasn.1/T1.678/CCDeliveryHeader -lCCDeliveryHeader -Lasn.1/T1.IAS/CmII -lCmII -Lasn.1/T1.678/VoP -lVoP $(GLIB_LIBS) df_collector_SOURCES = df_collector.c common.h log_debug.c log_debug.h util.h calea.c util.c @@ -332,6 +333,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tap-directsignalreporting.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tap-log_debug.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tap-packet_data_header_report.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tap-packet_processing.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tap-tap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tap-util.Po@am__quote@ @@ -650,6 +652,20 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tap_CFLAGS) $(CFLAGS) -c -o tap-util.obj `if test -f 'util.c'; then $(CYGPATH_W) 'util.c'; else $(CYGPATH_W) '$(srcdir)/util.c'; fi` +tap-packet_processing.o: packet_processing.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tap_CFLAGS) $(CFLAGS) -MT tap-packet_processing.o -MD -MP -MF $(DEPDIR)/tap-packet_processing.Tpo -c -o tap-packet_processing.o `test -f 'packet_processing.c' || echo '$(srcdir)/'`packet_processing.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/tap-packet_processing.Tpo $(DEPDIR)/tap-packet_processing.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='packet_processing.c' object='tap-packet_processing.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tap_CFLAGS) $(CFLAGS) -c -o tap-packet_processing.o `test -f 'packet_processing.c' || echo '$(srcdir)/'`packet_processing.c + +tap-packet_processing.obj: packet_processing.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tap_CFLAGS) $(CFLAGS) -MT tap-packet_processing.obj -MD -MP -MF $(DEPDIR)/tap-packet_processing.Tpo -c -o tap-packet_processing.obj `if test -f 'packet_processing.c'; then $(CYGPATH_W) 'packet_processing.c'; else $(CYGPATH_W) '$(srcdir)/packet_processing.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/tap-packet_processing.Tpo $(DEPDIR)/tap-packet_processing.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='packet_processing.c' object='tap-packet_processing.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tap_CFLAGS) $(CFLAGS) -c -o tap-packet_processing.obj `if test -f 'packet_processing.c'; then $(CYGPATH_W) 'packet_processing.c'; else $(CYGPATH_W) '$(srcdir)/packet_processing.c'; fi` + mostlyclean-libtool: -rm -f *.lo Modified: trunk/src/calea.c =================================================================== --- trunk/src/calea.c 2007-05-11 16:58:30 UTC (rev 30) +++ trunk/src/calea.c 2007-05-11 22:53:48 UTC (rev 31) @@ -14,10 +14,10 @@ * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY MERIT NETWORK, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR OR CONTRIBUTORS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL MERIT NETWORK, INC. BE LIABLE FOR ANY + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND @@ -45,17 +45,13 @@ mytm->tm_sec, (int) usec/1000 ); } - Msg *CmCPacketBuild (HEADER *dfheader) { Msg *msg; size_t msg_len; msg_len = sizeof(Msg); - if (! ( msg = (Msg *) malloc ( msg_len + dfheader->encoded_size ) ) ) { - perror("malloc"); - exit ( -1 ); - } + msg = (Msg *) Calloc(msg_len + dfheader->encoded_size); msg->msgh.msgtype = MSGTYPE_CMC; msg->msgh.format = MSGFMT_BER; @@ -70,10 +66,7 @@ Msg *msg; - if (! ( msg = (Msg *) malloc ( sizeof(Msg) + dfheader->encoded_size ) ) ) { - perror("malloc"); - exit ( -1 ); - } + msg = (Msg *) Calloc(sizeof(Msg) + dfheader->encoded_size); msg->msgh.msgtype = MSGTYPE_CMII; msg->msgh.format = MSGFMT_BER; @@ -85,7 +78,6 @@ } void PacketFree ( Msg *msg ) { - free ( msg ); } @@ -94,10 +86,7 @@ Msg *msg; CtrlMsg *ctrlmsg; - if ( !(msg = (Msg *)malloc(sizeof(Msg) + sizeof(CtrlMsg) ) ) ) { - perror("CtrlMsgBuild: malloc"); - exit(-1); - } + msg = (Msg *)Calloc(sizeof(Msg) + sizeof(CtrlMsg)); ctrlmsg = (CtrlMsg *)((char *)msg + sizeof(Msg)); @@ -148,4 +137,3 @@ return bytes_sent; } -/* */ Modified: trunk/src/calea.h =================================================================== --- trunk/src/calea.h 2007-05-11 16:58:30 UTC (rev 30) +++ trunk/src/calea.h 2007-05-11 22:53:48 UTC (rev 31) @@ -57,4 +57,13 @@ } header_t; #define HEADER header_t +/* function declarations */ +void get_calea_time ( time_t sec, time_t usec, char *buf ); +Msg *CmCPacketBuild (HEADER *dfheader); +Msg *CmIIPacketBuild (HEADER *dfheader); +void PacketFree ( Msg *msg ); +int PacketSend (Msg *packet, int length, int *send_socket); +Msg *CtrlMsgBuild (HEADER *dfheader); + #endif + Modified: trunk/src/log_debug.c =================================================================== --- trunk/src/log_debug.c 2007-05-11 16:58:30 UTC (rev 30) +++ trunk/src/log_debug.c 2007-05-11 22:53:48 UTC (rev 31) @@ -10,9 +10,6 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of Merit Network, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR OR CONTRIBUTORS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED Modified: trunk/src/msg.h =================================================================== --- trunk/src/msg.h 2007-05-11 16:58:30 UTC (rev 30) +++ trunk/src/msg.h 2007-05-11 22:53:48 UTC (rev 31) @@ -10,9 +10,6 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of Merit Network, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR OR CONTRIBUTORS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED Modified: trunk/src/packet_data_header_report.c =================================================================== --- trunk/src/packet_data_header_report.c 2007-05-11 16:58:30 UTC (rev 30) +++ trunk/src/packet_data_header_report.c 2007-05-11 22:53:48 UTC (rev 31) @@ -33,6 +33,7 @@ #include "common.h" #include "calea.h" +#include "packet_data_header_report.h" int encode_ias_protocol(HEADER *dfheader, IasProtocol_t *IasProtocol) { Added: trunk/src/packet_data_header_report.h =================================================================== --- trunk/src/packet_data_header_report.h (rev 0) +++ trunk/src/packet_data_header_report.h 2007-05-11 22:53:48 UTC (rev 31) @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2007, Jesse Norell <je...@kc...> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR OR CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _PACKET_DATA_HEADER_REPORT_H +#define _PACKET_DATA_HEADER_REPORT_H + +#include "IasProtocol.h" + +/* function declarations */ +int encode_ias_protocol(HEADER *dfheader, IasProtocol_t *IasProtocol); +int packet_data_header_report(HEADER *dfheader); + +#endif + Added: trunk/src/packet_processing.c =================================================================== --- trunk/src/packet_processing.c (rev 0) +++ trunk/src/packet_processing.c 2007-05-11 22:53:48 UTC (rev 31) @@ -0,0 +1,1163 @@ +/* + * Copyright (c) 2007, Jesse Norell <je...@kc...> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR OR CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "common.h" +#include "calea.h" +#include "tap.h" +#include "packet_data_header_report.h" + +#include <pcap.h> +#include <net/ethernet.h> + +/* function declarations */ +char *cc_apdu(HEADER *dfheader); +char *directsignalreporting(HEADER *dfheader); + +extern int datalink_hdr_len; +extern int send_df_socket; +extern struct sockaddr_in send_df_addr; + + +// tmp ... need to clean up / write all the functions below +int content_option = 1; + +/* + * process_packet_cc_apdu: sends CC-APDU structures for VoP CC + */ +void process_packet_cc_apdu( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ) { + + struct ether_header *ethernet; + struct ip *ip; + struct udphdr *udp; + struct tcphdr *tcp; + Msg *cmc_pkt; + Msg *cmii_pkt; + int total_pkt_length; + int ip_size; + int tcp_size; + int udp_size; + int payload_size; + int ip_size_total; + const char *payload; /* Packet Payload */ + HEADER *dfheader; + char calea_time[TS_LENGTH]; + + dfheader = (HEADER *)args; + +#ifdef DEBUG_PKTS + char msg[ MAX_LOG_DEBUG_MSG_LEN ]; + memset ( msg, '\0', MAX_LOG_DEBUG_MSG_LEN ); +#endif + + get_calea_time ( header->ts.tv_sec, header->ts.tv_usec, &calea_time[0] ); + + dfheader->sec = header->ts.tv_sec; + dfheader->usec = header->ts.tv_usec/100; + + /* Ethernet Packet */ + ethernet = (struct ether_header *)(packet); + + /* IP Header Offset */ + ip = ( struct ip* )( (char *)ethernet + datalink_hdr_len ); + ip_size_total = (int)ntohs(ip->ip_len); + ip_size = ip->ip_hl * 4; + if (ip_size < 20) { + log_5("Packet has invalid IP header length: %u bytes", ip_size); + debug_3("Packet has invalid IP header length: %u bytes", ip_size); + return; + } + + dfheader->srcIP = htonl(ip->ip_src.s_addr); + dfheader->dstIP = htonl(ip->ip_dst.s_addr); + + if (inet_ntop(AF_INET, &ip->ip_src.s_addr, dfheader->src_ip, sizeof(dfheader->src_ip)) == NULL ) { + pdie("inet_ntop"); + } + if (inet_ntop(AF_INET, &ip->ip_dst.s_addr, dfheader->dst_ip, sizeof(dfheader->dst_ip)) == NULL ) { + pdie("inet_ntop"); + } + + if ( ip->ip_p == IPPROTO_UDP ) { + /* UDP Header */ + udp = ( struct udphdr* ) ( (u_char *)ip + ip_size ); + + udp_size = sizeof(struct udphdr); + if (ntohs(udp->uh_ulen) <= 12) { + log_5("Packet has invalid UDP header length: %u bytes", udp_size); + debug_3("Packet has invalid UDP header length: %u bytes", udp_size); + return; + } + + /* UDP Payload */ + payload = (char *)((u_char *)udp + udp_size); + + /* UDP Payload size */ + payload_size = ntohs(udp->uh_ulen) - udp_size; + +#ifdef DEBUG_PKTS + if (payload_size > 0) { + debug_5("Payload (%d bytes):", payload_size); + print_hex(payload, payload_size); + } +#endif + + //format_vop_payload(dfheader); + + dfheader->srcPort = ntohs(udp->uh_sport); + dfheader->dstPort = ntohs(udp->uh_dport); + + } else if ( ip->ip_p == IPPROTO_TCP ) { + + /* TCP Header */ + tcp = ( struct tcphdr* ) ( (u_char *)ip + ip_size); + + tcp_size = tcp->th_off * 4; + if (tcp_size < 20) { + log_5("Packet has invalid TCP header length: %u bytes", tcp_size); + debug_3("Packet has invalid TCP header length: %u bytes", tcp_size); + return; + } + + /* TCP Payload */ + payload = (char *)((u_char *)tcp + tcp_size); + + /* TCP Payload size */ + payload_size = ntohs(ip->ip_len) - (ip_size + tcp_size); + + dfheader->srcPort = ntohs(tcp->th_sport); + dfheader->dstPort = ntohs(tcp->th_dport); + + } else { + debug_4("Packet is neither UDP or TCP"); + dfheader->srcPort = 0; + dfheader->dstPort = 0; + } + + /*------------------------------------------------------------------------*/ + /* only send Communications Content CmC msg if requested */ + /*------------------------------------------------------------------------*/ + if ( content_option == 1 ) { + + //debug_5("IP (%d bytes):", ip_size_total); + //print_hex((const u_char *)ip, (size_t)ip_size_total); + + dfheader->sequenceNumber++; + dfheader->payload = (const char *)ip; + dfheader->payload_size = (size_t)ip_size_total; + /*------------------------------------------------------------------------*/ + /* WARNING: cc_apdu will allocate space for the BER encoded message. */ + /* This space MUST be freed when it is no longer needed or a */ + /* memory leak will occur. */ + /* */ + /* The address of the allocated memory is dfheader->encoded. */ + /* The size of the allocated memory is dfheader->encoded_size. */ + /* If cc_apdu does not return 0, no deallocation is needed. */ + /*------------------------------------------------------------------------*/ + if ( cc_apdu(dfheader) == 0) { + debug_5("Encoded addr(size): %p(%Zd)", dfheader->encoded_size, dfheader->encoded); + } else { + debug_5("cc_apdu returned nonzero"); + return; + } + + total_pkt_length = sizeof(Msg) + dfheader->encoded_size; + debug_5 ( "building CmC packet size: %d", total_pkt_length ); + cmc_pkt = CmCPacketBuild ( dfheader ); + debug_5 ( "sending CmC packet size: %d", total_pkt_length ); + PacketSend ( cmc_pkt, total_pkt_length, &send_df_socket ); + PacketFree ( cmc_pkt ); + + free(dfheader->encoded); + + } + + if (packet_data_header_report(dfheader) == 0) { + debug_5("Packet_Data_Header_Report encoded addr: %p, size: %Zd", dfheader->encoded, dfheader->encoded_size); + //print_hex((const u_char *)dfheader->encoded, (size_t)dfheader->encoded_size); + } else { + return; + } + + total_pkt_length = sizeof(Msg) + dfheader->encoded_size; + debug_5 ( "building T1.IAS CmII packet size: %d", total_pkt_length); + cmii_pkt = CmIIPacketBuild ( dfheader ); + debug_5 ( "sending T1.IAS CmII packet size: %d", total_pkt_length ); + //print_hex((const u_char *)cmii_pkt, (size_t)total_pkt_length); + PacketSend ( cmii_pkt, total_pkt_length, &send_df_socket ); + PacketFree ( cmii_pkt ); + + free(dfheader->encoded); + + if (directsignalreporting(dfheader) == 0) { + debug_5("Direct Signal Reporting encoded addr: %p, size: %Zd", dfheader->encoded, dfheader->encoded_size); + //print_hex((const u_char *)dfheader->encoded, (size_t)dfheader->encoded_size); + } else { + return; + } + + total_pkt_length = sizeof(Msg) + dfheader->encoded_size; + debug_5 ( "building T1.678 CmII packet size: %d", total_pkt_length); + cmii_pkt = CmIIPacketBuild ( dfheader ); + debug_5 ( "sending T1.678 CmII packet size: %d", total_pkt_length ); + //print_hex((const u_char *)cmii_pkt, (size_t)total_pkt_length); + PacketSend ( cmii_pkt, total_pkt_length, &send_df_socket ); + PacketFree ( cmii_pkt ); + + free(dfheader->encoded); +} + + +/* + * process_packet_cmii_pdhr: sends PacketDataHeaderReport structures for IAS CACmII + */ +void process_packet_cmii_pdhr( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ) { + + struct ether_header *ethernet; + struct ip *ip; + struct udphdr *udp; + struct tcphdr *tcp; + Msg *cmc_pkt; + Msg *cmii_pkt; + int total_pkt_length; + int ip_size; + int tcp_size; + int udp_size; + int payload_size; + int ip_size_total; + const char *payload; /* Packet Payload */ + HEADER *dfheader; + char calea_time[TS_LENGTH]; + + dfheader = (HEADER *)args; + +#ifdef DEBUG_PKTS + char msg[ MAX_LOG_DEBUG_MSG_LEN ]; + memset ( msg, '\0', MAX_LOG_DEBUG_MSG_LEN ); +#endif + + get_calea_time ( header->ts.tv_sec, header->ts.tv_usec, &calea_time[0] ); + + dfheader->sec = header->ts.tv_sec; + dfheader->usec = header->ts.tv_usec/100; + + /* Ethernet Packet */ + ethernet = (struct ether_header *)(packet); + + /* IP Header Offset */ + ip = ( struct ip* )( (char *)ethernet + datalink_hdr_len ); + ip_size_total = (int)ntohs(ip->ip_len); + ip_size = ip->ip_hl * 4; + if (ip_size < 20) { + log_5("Packet has invalid IP header length: %u bytes", ip_size); + debug_3("Packet has invalid IP header length: %u bytes", ip_size); + return; + } + + dfheader->srcIP = htonl(ip->ip_src.s_addr); + dfheader->dstIP = htonl(ip->ip_dst.s_addr); + + if (inet_ntop(AF_INET, &ip->ip_src.s_addr, dfheader->src_ip, sizeof(dfheader->src_ip)) == NULL ) { + pdie("inet_ntop"); + } + if (inet_ntop(AF_INET, &ip->ip_dst.s_addr, dfheader->dst_ip, sizeof(dfheader->dst_ip)) == NULL ) { + pdie("inet_ntop"); + } + + if ( ip->ip_p == IPPROTO_UDP ) { + /* UDP Header */ + udp = ( struct udphdr* ) ( (u_char *)ip + ip_size ); + + udp_size = sizeof(struct udphdr); + if (ntohs(udp->uh_ulen) <= 12) { + log_5("Packet has invalid UDP header length: %u bytes", udp_size); + debug_3("Packet has invalid UDP header length: %u bytes", udp_size); + return; + } + + /* UDP Payload */ + payload = (char *)((u_char *)udp + udp_size); + + /* UDP Payload size */ + payload_size = ntohs(udp->uh_ulen) - udp_size; + +#ifdef DEBUG_PKTS + if (payload_size > 0) { + debug_5("Payload (%d bytes):", payload_size); + print_hex(payload, payload_size); + } +#endif + + //format_vop_payload(dfheader); + + dfheader->srcPort = ntohs(udp->uh_sport); + dfheader->dstPort = ntohs(udp->uh_dport); + + } else if ( ip->ip_p == IPPROTO_TCP ) { + + /* TCP Header */ + tcp = ( struct tcphdr* ) ( (u_char *)ip + ip_size); + + tcp_size = tcp->th_off * 4; + if (tcp_size < 20) { + log_5("Packet has invalid TCP header length: %u bytes", tcp_size); + debug_3("Packet has invalid TCP header length: %u bytes", tcp_size); + return; + } + + /* TCP Payload */ + payload = (char *)((u_char *)tcp + tcp_size); + + /* TCP Payload size */ + payload_size = ntohs(ip->ip_len) - (ip_size + tcp_size); + + dfheader->srcPort = ntohs(tcp->th_sport); + dfheader->dstPort = ntohs(tcp->th_dport); + + } else { + debug_4("Packet is neither UDP or TCP"); + dfheader->srcPort = 0; + dfheader->dstPort = 0; + } + + /*------------------------------------------------------------------------*/ + /* only send Communications Content CmC msg if requested */ + /*------------------------------------------------------------------------*/ + if ( content_option == 1 ) { + + //debug_5("IP (%d bytes):", ip_size_total); + //print_hex((const u_char *)ip, (size_t)ip_size_total); + + dfheader->sequenceNumber++; + dfheader->payload = (const char *)ip; + dfheader->payload_size = (size_t)ip_size_total; + /*------------------------------------------------------------------------*/ + /* WARNING: cc_apdu will allocate space for the BER encoded message. */ + /* This space MUST be freed when it is no longer needed or a */ + /* memory leak will occur. */ + /* */ + /* The address of the allocated memory is dfheader->encoded. */ + /* The size of the allocated memory is dfheader->encoded_size. */ + /* If cc_apdu does not return 0, no deallocation is needed. */ + /*------------------------------------------------------------------------*/ + if ( cc_apdu(dfheader) == 0) { + debug_5("Encoded addr(size): %p(%Zd)", dfheader->encoded_size, dfheader->encoded); + } else { + debug_5("cc_apdu returned nonzero"); + return; + } + + total_pkt_length = sizeof(Msg) + dfheader->encoded_size; + debug_5 ( "building CmC packet size: %d", total_pkt_length ); + cmc_pkt = CmCPacketBuild ( dfheader ); + debug_5 ( "sending CmC packet size: %d", total_pkt_length ); + PacketSend ( cmc_pkt, total_pkt_length, &send_df_socket ); + PacketFree ( cmc_pkt ); + + free(dfheader->encoded); + + } + + if (packet_data_header_report(dfheader) == 0) { + debug_5("Packet_Data_Header_Report encoded addr: %p, size: %Zd", dfheader->encoded, dfheader->encoded_size); + //print_hex((const u_char *)dfheader->encoded, (size_t)dfheader->encoded_size); + } else { + return; + } + + total_pkt_length = sizeof(Msg) + dfheader->encoded_size; + debug_5 ( "building T1.IAS CmII packet size: %d", total_pkt_length); + cmii_pkt = CmIIPacketBuild ( dfheader ); + debug_5 ( "sending T1.IAS CmII packet size: %d", total_pkt_length ); + //print_hex((const u_char *)cmii_pkt, (size_t)total_pkt_length); + PacketSend ( cmii_pkt, total_pkt_length, &send_df_socket ); + PacketFree ( cmii_pkt ); + + free(dfheader->encoded); + + if (directsignalreporting(dfheader) == 0) { + debug_5("Direct Signal Reporting encoded addr: %p, size: %Zd", dfheader->encoded, dfheader->encoded_size); + //print_hex((const u_char *)dfheader->encoded, (size_t)dfheader->encoded_size); + } else { + return; + } + + total_pkt_length = sizeof(Msg) + dfheader->encoded_size; + debug_5 ( "building T1.678 CmII packet size: %d", total_pkt_length); + cmii_pkt = CmIIPacketBuild ( dfheader ); + debug_5 ( "sending T1.678 CmII packet size: %d", total_pkt_length ); + //print_hex((const u_char *)cmii_pkt, (size_t)total_pkt_length); + PacketSend ( cmii_pkt, total_pkt_length, &send_df_socket ); + PacketFree ( cmii_pkt ); + + free(dfheader->encoded); +} + + +/* + * process_packet_cmc_pdhr: sends PacketDataHeaderReport structures for IAS CACmII, + * and IAS-CC-APDU structures for IAS CmC + */ +void process_packet_cmc_pdhr( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ) { + + struct ether_header *ethernet; + struct ip *ip; + struct udphdr *udp; + struct tcphdr *tcp; + Msg *cmc_pkt; + Msg *cmii_pkt; + int total_pkt_length; + int ip_size; + int tcp_size; + int udp_size; + int payload_size; + int ip_size_total; + const char *payload; /* Packet Payload */ + HEADER *dfheader; + char calea_time[TS_LENGTH]; + + dfheader = (HEADER *)args; + +#ifdef DEBUG_PKTS + char msg[ MAX_LOG_DEBUG_MSG_LEN ]; + memset ( msg, '\0', MAX_LOG_DEBUG_MSG_LEN ); +#endif + + get_calea_time ( header->ts.tv_sec, header->ts.tv_usec, &calea_time[0] ); + + dfheader->sec = header->ts.tv_sec; + dfheader->usec = header->ts.tv_usec/100; + + /* Ethernet Packet */ + ethernet = (struct ether_header *)(packet); + + /* IP Header Offset */ + ip = ( struct ip* )( (char *)ethernet + datalink_hdr_len ); + ip_size_total = (int)ntohs(ip->ip_len); + ip_size = ip->ip_hl * 4; + if (ip_size < 20) { + log_5("Packet has invalid IP header length: %u bytes", ip_size); + debug_3("Packet has invalid IP header length: %u bytes", ip_size); + return; + } + + dfheader->srcIP = htonl(ip->ip_src.s_addr); + dfheader->dstIP = htonl(ip->ip_dst.s_addr); + + if (inet_ntop(AF_INET, &ip->ip_src.s_addr, dfheader->src_ip, sizeof(dfheader->src_ip)) == NULL ) { + pdie("inet_ntop"); + } + if (inet_ntop(AF_INET, &ip->ip_dst.s_addr, dfheader->dst_ip, sizeof(dfheader->dst_ip)) == NULL ) { + pdie("inet_ntop"); + } + + if ( ip->ip_p == IPPROTO_UDP ) { + /* UDP Header */ + udp = ( struct udphdr* ) ( (u_char *)ip + ip_size ); + + udp_size = sizeof(struct udphdr); + if (ntohs(udp->uh_ulen) <= 12) { + log_5("Packet has invalid UDP header length: %u bytes", udp_size); + debug_3("Packet has invalid UDP header length: %u bytes", udp_size); + return; + } + + /* UDP Payload */ + payload = (char *)((u_char *)udp + udp_size); + + /* UDP Payload size */ + payload_size = ntohs(udp->uh_ulen) - udp_size; + +#ifdef DEBUG_PKTS + if (payload_size > 0) { + debug_5("Payload (%d bytes):", payload_size); + print_hex(payload, payload_size); + } +#endif + + //format_vop_payload(dfheader); + + dfheader->srcPort = ntohs(udp->uh_sport); + dfheader->dstPort = ntohs(udp->uh_dport); + + } else if ( ip->ip_p == IPPROTO_TCP ) { + + /* TCP Header */ + tcp = ( struct tcphdr* ) ( (u_char *)ip + ip_size); + + tcp_size = tcp->th_off * 4; + if (tcp_size < 20) { + log_5("Packet has invalid TCP header length: %u bytes", tcp_size); + debug_3("Packet has invalid TCP header length: %u bytes", tcp_size); + return; + } + + /* TCP Payload */ + payload = (char *)((u_char *)tcp + tcp_size); + + /* TCP Payload size */ + payload_size = ntohs(ip->ip_len) - (ip_size + tcp_size); + + dfheader->srcPort = ntohs(tcp->th_sport); + dfheader->dstPort = ntohs(tcp->th_dport); + + } else { + debug_4("Packet is neither UDP or TCP"); + dfheader->srcPort = 0; + dfheader->dstPort = 0; + } + + /*------------------------------------------------------------------------*/ + /* only send Communications Content CmC msg if requested */ + /*------------------------------------------------------------------------*/ + if ( content_option == 1 ) { + + //debug_5("IP (%d bytes):", ip_size_total); + //print_hex((const u_char *)ip, (size_t)ip_size_total); + + dfheader->sequenceNumber++; + dfheader->payload = (const char *)ip; + dfheader->payload_size = (size_t)ip_size_total; + /*------------------------------------------------------------------------*/ + /* WARNING: cc_apdu will allocate space for the BER encoded message. */ + /* This space MUST be freed when it is no longer needed or a */ + /* memory leak will occur. */ + /* */ + /* The address of the allocated memory is dfheader->encoded. */ + /* The size of the allocated memory is dfheader->encoded_size. */ + /* If cc_apdu does not return 0, no deallocation is needed. */ + /*------------------------------------------------------------------------*/ + if ( cc_apdu(dfheader) == 0) { + debug_5("Encoded addr(size): %p(%Zd)", dfheader->encoded_size, dfheader->encoded); + } else { + debug_5("cc_apdu returned nonzero"); + return; + } + + total_pkt_length = sizeof(Msg) + dfheader->encoded_size; + debug_5 ( "building CmC packet size: %d", total_pkt_length ); + cmc_pkt = CmCPacketBuild ( dfheader ); + debug_5 ( "sending CmC packet size: %d", total_pkt_length ); + PacketSend ( cmc_pkt, total_pkt_length, &send_df_socket ); + PacketFree ( cmc_pkt ); + + free(dfheader->encoded); + + } + + if (packet_data_header_report(dfheader) == 0) { + debug_5("Packet_Data_Header_Report encoded addr: %p, size: %Zd", dfheader->encoded, dfheader->encoded_size); + //print_hex((const u_char *)dfheader->encoded, (size_t)dfheader->encoded_size); + } else { + return; + } + + total_pkt_length = sizeof(Msg) + dfheader->encoded_size; + debug_5 ( "building T1.IAS CmII packet size: %d", total_pkt_length); + cmii_pkt = CmIIPacketBuild ( dfheader ); + debug_5 ( "sending T1.IAS CmII packet size: %d", total_pkt_length ); + //print_hex((const u_char *)cmii_pkt, (size_t)total_pkt_length); + PacketSend ( cmii_pkt, total_pkt_length, &send_df_socket ); + PacketFree ( cmii_pkt ); + + free(dfheader->encoded); + + if (directsignalreporting(dfheader) == 0) { + debug_5("Direct Signal Reporting encoded addr: %p, size: %Zd", dfheader->encoded, dfheader->encoded_size); + //print_hex((const u_char *)dfheader->encoded, (size_t)dfheader->encoded_size); + } else { + return; + } + + total_pkt_length = sizeof(Msg) + dfheader->encoded_size; + debug_5 ( "building T1.678 CmII packet size: %d", total_pkt_length); + cmii_pkt = CmIIPacketBuild ( dfheader ); + debug_5 ( "sending T1.678 CmII packet size: %d", total_pkt_length ); + //print_hex((const u_char *)cmii_pkt, (size_t)total_pkt_length); + PacketSend ( cmii_pkt, total_pkt_length, &send_df_socket ); + PacketFree ( cmii_pkt ); + + free(dfheader->encoded); +} + + +/* + * process_packet_cmc_udp: sends PacketDataHeaderReport structures for IAS CACmII, + * and UDP encapsulated IAS CmC (per IAS D.3.1) + */ +void process_packet_cmc_udp( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ) { + + struct ether_header *ethernet; + struct ip *ip; + struct udphdr *udp; + struct tcphdr *tcp; + Msg *cmc_pkt; + Msg *cmii_pkt; + int total_pkt_length; + int ip_size; + int tcp_size; + int udp_size; + int payload_size; + int ip_size_total; + const char *payload; /* Packet Payload */ + HEADER *dfheader; + char calea_time[TS_LENGTH]; + + dfheader = (HEADER *)args; + +#ifdef DEBUG_PKTS + char msg[ MAX_LOG_DEBUG_MSG_LEN ]; + memset ( msg, '\0', MAX_LOG_DEBUG_MSG_LEN ); +#endif + + get_calea_time ( header->ts.tv_sec, header->ts.tv_usec, &calea_time[0] ); + + dfheader->sec = header->ts.tv_sec; + dfheader->usec = header->ts.tv_usec/100; + + /* Ethernet Packet */ + ethernet = (struct ether_header *)(packet); + + /* IP Header Offset */ + ip = ( struct ip* )( (char *)ethernet + datalink_hdr_len ); + ip_size_total = (int)ntohs(ip->ip_len); + ip_size = ip->ip_hl * 4; + if (ip_size < 20) { + log_5("Packet has invalid IP header length: %u bytes", ip_size); + debug_3("Packet has invalid IP header length: %u bytes", ip_size); + return; + } + + dfheader->srcIP = htonl(ip->ip_src.s_addr); + dfheader->dstIP = htonl(ip->ip_dst.s_addr); + + if (inet_ntop(AF_INET, &ip->ip_src.s_addr, dfheader->src_ip, sizeof(dfheader->src_ip)) == NULL ) { + pdie("inet_ntop"); + } + if (inet_ntop(AF_INET, &ip->ip_dst.s_addr, dfheader->dst_ip, sizeof(dfheader->dst_ip)) == NULL ) { + pdie("inet_ntop"); + } + + if ( ip->ip_p == IPPROTO_UDP ) { + /* UDP Header */ + udp = ( struct udphdr* ) ( (u_char *)ip + ip_size ); + + udp_size = sizeof(struct udphdr); + if (ntohs(udp->uh_ulen) <= 12) { + log_5("Packet has invalid UDP header length: %u bytes", udp_size); + debug_3("Packet has invalid UDP header length: %u bytes", udp_size); + return; + } + + /* UDP Payload */ + payload = (char *)((u_char *)udp + udp_size); + + /* UDP Payload size */ + payload_size = ntohs(udp->uh_ulen) - udp_size; + +#ifdef DEBUG_PKTS + if (payload_size > 0) { + debug_5("Payload (%d bytes):", payload_size); + print_hex(payload, payload_size); + } +#endif + + //format_vop_payload(dfheader); + + dfheader->srcPort = ntohs(udp->uh_sport); + dfheader->dstPort = ntohs(udp->uh_dport); + + } else if ( ip->ip_p == IPPROTO_TCP ) { + + /* TCP Header */ + tcp = ( struct tcphdr* ) ( (u_char *)ip + ip_size); + + tcp_size = tcp->th_off * 4; + if (tcp_size < 20) { + log_5("Packet has invalid TCP header length: %u bytes", tcp_size); + debug_3("Packet has invalid TCP header length: %u bytes", tcp_size); + return; + } + + /* TCP Payload */ + payload = (char *)((u_char *)tcp + tcp_size); + + /* TCP Payload size */ + payload_size = ntohs(ip->ip_len) - (ip_size + tcp_size); + + dfheader->srcPort = ntohs(tcp->th_sport); + dfheader->dstPort = ntohs(tcp->th_dport); + + } else { + debug_4("Packet is neither UDP or TCP"); + dfheader->srcPort = 0; + dfheader->dstPort = 0; + } + + /*------------------------------------------------------------------------*/ + /* only send Communications Content CmC msg if requested */ + /*------------------------------------------------------------------------*/ + if ( content_option == 1 ) { + + //debug_5("IP (%d bytes):", ip_size_total); + //print_hex((const u_char *)ip, (size_t)ip_size_total); + + dfheader->sequenceNumber++; + dfheader->payload = (const char *)ip; + dfheader->payload_size = (size_t)ip_size_total; + /*------------------------------------------------------------------------*/ + /* WARNING: cc_apdu will allocate space for the BER encoded message. */ + /* This space MUST be freed when it is no longer needed or a */ + /* memory leak will occur. */ + /* */ + /* The address of the allocated memory is dfheader->encoded. */ + /* The size of the allocated memory is dfheader->encoded_size. */ + /* If cc_apdu does not return 0, no deallocation is needed. */ + /*------------------------------------------------------------------------*/ + if ( cc_apdu(dfheader) == 0) { + debug_5("Encoded addr(size): %p(%Zd)", dfheader->encoded_size, dfheader->encoded); + } else { + debug_5("cc_apdu returned nonzero"); + return; + } + + total_pkt_length = sizeof(Msg) + dfheader->encoded_size; + debug_5 ( "building CmC packet size: %d", total_pkt_length ); + cmc_pkt = CmCPacketBuild ( dfheader ); + debug_5 ( "sending CmC packet size: %d", total_pkt_length ); + PacketSend ( cmc_pkt, total_pkt_length, &send_df_socket ); + PacketFree ( cmc_pkt ); + + free(dfheader->encoded); + + } + + if (packet_data_header_report(dfheader) == 0) { + debug_5("Packet_Data_Header_Report encoded addr: %p, size: %Zd", dfheader->encoded, dfheader->encoded_size); + //print_hex((const u_char *)dfheader->encoded, (size_t)dfheader->encoded_size); + } else { + return; + } + + total_pkt_length = sizeof(Msg) + dfheader->encoded_size; + debug_5 ( "building T1.IAS CmII packet size: %d", total_pkt_length); + cmii_pkt = CmIIPacketBuild ( dfheader ); + debug_5 ( "sending T1.IAS CmII packet size: %d", total_pkt_length ); + //print_hex((const u_char *)cmii_pkt, (size_t)total_pkt_length); + PacketSend ( cmii_pkt, total_pkt_length, &send_df_socket ); + PacketFree ( cmii_pkt ); + + free(dfheader->encoded); + + if (directsignalreporting(dfheader) == 0) { + debug_5("Direct Signal Reporting encoded addr: %p, size: %Zd", dfheader->encoded, dfheader->encoded_size); + //print_hex((const u_char *)dfheader->encoded, (size_t)dfheader->encoded_size); + } else { + return; + } + + total_pkt_length = sizeof(Msg) + dfheader->encoded_size; + debug_5 ( "building T1.678 CmII packet size: %d", total_pkt_length); + cmii_pkt = CmIIPacketBuild ( dfheader ); + debug_5 ( "sending T1.678 CmII packet size: %d", total_pkt_length ); + //print_hex((const u_char *)cmii_pkt, (size_t)total_pkt_length); + PacketSend ( cmii_pkt, total_pkt_length, &send_df_socket ); + PacketFree ( cmii_pkt ); + + free(dfheader->encoded); +} + + +/* + * process_packet_raw: sends content raw with no formatting + */ +void process_packet_raw( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ) { + + struct ether_header *ethernet; + struct ip *ip; + struct udphdr *udp; + struct tcphdr *tcp; + Msg *cmc_pkt; + Msg *cmii_pkt; + int total_pkt_length; + int ip_size; + int tcp_size; + int udp_size; + int payload_size; + int ip_size_total; + const char *payload; /* Packet Payload */ + HEADER *dfheader; + char calea_time[TS_LENGTH]; + + dfheader = (HEADER *)args; + +#ifdef DEBUG_PKTS + char msg[ MAX_LOG_DEBUG_MSG_LEN ]; + memset ( msg, '\0', MAX_LOG_DEBUG_MSG_LEN ); +#endif + + get_calea_time ( header->ts.tv_sec, header->ts.tv_usec, &calea_time[0] ); + + dfheader->sec = header->ts.tv_sec; + dfheader->usec = header->ts.tv_usec/100; + + /* Ethernet Packet */ + ethernet = (struct ether_header *)(packet); + + /* IP Header Offset */ + ip = ( struct ip* )( (char *)ethernet + datalink_hdr_len ); + ip_size_total = (int)ntohs(ip->ip_len); + ip_size = ip->ip_hl * 4; + if (ip_size < 20) { + log_5("Packet has invalid IP header length: %u bytes", ip_size); + debug_3("Packet has invalid IP header length: %u bytes", ip_size); + return; + } + + dfheader->srcIP = htonl(ip->ip_src.s_addr); + dfheader->dstIP = htonl(ip->ip_dst.s_addr); + + if (inet_ntop(AF_INET, &ip->ip_src.s_addr, dfheader->src_ip, sizeof(dfheader->src_ip)) == NULL ) { + pdie("inet_ntop"); + } + if (inet_ntop(AF_INET, &ip->ip_dst.s_addr, dfheader->dst_ip, sizeof(dfheader->dst_ip)) == NULL ) { + pdie("inet_ntop"); + } + + if ( ip->ip_p == IPPROTO_UDP ) { + /* UDP Header */ + udp = ( struct udphdr* ) ( (u_char *)ip + ip_size ); + + udp_size = sizeof(struct udphdr); + if (ntohs(udp->uh_ulen) <= 12) { + log_5("Packet has invalid UDP header length: %u bytes", udp_size); + debug_3("Packet has invalid UDP header length: %u bytes", udp_size); + return; + } + + /* UDP Payload */ + payload = (char *)((u_char *)udp + udp_size); + + /* UDP Payload size */ + payload_size = ntohs(udp->uh_ulen) - udp_size; + +#ifdef DEBUG_PKTS + if (payload_size > 0) { + debug_5("Payload (%d bytes):", payload_size); + print_hex(payload, payload_size); + } +#endif + + //format_vop_payload(dfheader); + + dfheader->srcPort = ntohs(udp->uh_sport); + dfheader->dstPort = ntohs(udp->uh_dport); + + } else if ( ip->ip_p == IPPROTO_TCP ) { + + /* TCP Header */ + tcp = ( struct tcphdr* ) ( (u_char *)ip + ip_size); + + tcp_size = tcp->th_off * 4; + if (tcp_size < 20) { + log_5("Packet has invalid TCP header length: %u bytes", tcp_size); + debug_3("Packet has invalid TCP header length: %u bytes", tcp_size); + return; + } + + /* TCP Payload */ + payload = (char *)((u_char *)tcp + tcp_size); + + /* TCP Payload size */ + payload_size = ntohs(ip->ip_len) - (ip_size + tcp_size); + + dfheader->srcPort = ntohs(tcp->th_sport); + dfheader->dstPort = ntohs(tcp->th_dport); + + } else { + debug_4("Packet is neither UDP or TCP"); + dfheader->srcPort = 0; + dfheader->dstPort = 0; + } + + /*------------------------------------------------------------------------*/ + /* only send Communications Content CmC msg if requested */ + /*------------------------------------------------------------------------*/ + if ( content_option == 1 ) { + + //debug_5("IP (%d bytes):", ip_size_total); + //print_hex((const u_char *)ip, (size_t)ip_size_total); + + dfheader->sequenceNumber++; + dfheader->payload = (const char *)ip; + dfheader->payload_size = (size_t)ip_size_total; + /*------------------------------------------------------------------------*/ + /* WARNING: cc_apdu will allocate space for the BER encoded message. */ + /* This space MUST be freed when it is no longer needed or a */ + /* memory leak will occur. */ + /* */ + /* The address of the allocated memory is dfheader->encoded. */ + /* The size of the allocated memory is dfheader->encoded_size. */ + /* If cc_apdu does not return 0, no deallocation is needed. */ + /*------------------------------------------------------------------------*/ + if ( cc_apdu(dfheader) == 0) { + debug_5("Encoded addr(size): %p(%Zd)", dfheader->encoded_size, dfheader->encoded); + } else { + debug_5("cc_apdu returned nonzero"); + return; + } + + total_pkt_length = sizeof(Msg) + dfheader->encoded_size; + debug_5 ( "building CmC packet size: %d", total_pkt_length ); + cmc_pkt = CmCPacketBuild ( dfheader ); + debug_5 ( "sending CmC packet size: %d", total_pkt_length ); + PacketSend ( cmc_pkt, total_pkt_length, &send_df_socket ); + PacketFree ( cmc_pkt ); + + free(dfheader->encoded); + + } + + if (packet_data_header_report(dfheader) == 0) { + debug_5("Packet_Data_Header_Report encoded addr: %p, size: %Zd", dfheader->encoded, dfheader->encoded_size); + //print_hex((const u_char *)dfheader->encoded, (size_t)dfheader->encoded_size); + } else { + return; + } + + total_pkt_length = sizeof(Msg) + dfheader->encoded_size; + debug_5 ( "building T1.IAS CmII packet size: %d", total_pkt_length); + cmii_pkt = CmIIPacketBuild ( dfheader ); + debug_5 ( "sending T1.IAS CmII packet size: %d", total_pkt_length ); + //print_hex((const u_char *)cmii_pkt, (size_t)total_pkt_length); + PacketSend ( cmii_pkt, total_pkt_length, &send_df_socket ); + PacketFree ( cmii_pkt ); + + free(dfheader->encoded); + + if (directsignalreporting(dfheader) == 0) { + debug_5("Direct Signal Reporting encoded addr: %p, size: %Zd", dfheader->encoded, dfheader->encoded_size); + //print_hex((const u_char *)dfheader->encoded, (size_t)dfheader->encoded_size); + } else { + return; + } + + total_pkt_length = sizeof(Msg) + dfheader->encoded_size; + debug_5 ( "building T1.678 CmII packet size: %d", total_pkt_length); + cmii_pkt = CmIIPacketBuild ( dfheader ); + debug_5 ( "sending T1.678 CmII packet size: %d", total_pkt_length ); + //print_hex((const u_char *)cmii_pkt, (size_t)total_pkt_length); + PacketSend ( cmii_pkt, total_pkt_length, &send_df_socket ); + PacketFree ( cmii_pkt ); + + free(dfheader->encoded); +} + + +/* + * process_packet_pcap: sends content, with link headers, in pcap packets + */ +void process_packet_pcap( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ) { + + struct ether_header *ethernet; + struct ip *ip; + struct udphdr *udp; + struct tcphdr *tcp; + Msg *cmc_pkt; + Msg *cmii_pkt; + int total_pkt_length; + int ip_size; + int tcp_size; + int udp_size; + int payload_size; + int ip_size_total; + const char *payload; /* Packet Payload */ + HEADER *dfheader; + char calea_time[TS_LENGTH]; + + dfheader = (HEADER *)args; + +#ifdef DEBUG_PKTS + char msg[ MAX_LOG_DEBUG_MSG_LEN ]; + memset ( msg, '\0', MAX_LOG_DEBUG_MSG_LEN ); +#endif + + get_calea_time ( header->ts.tv_sec, header->ts.tv_usec, &calea_time[0] ); + + dfheader->sec = header->ts.tv_sec; + dfheader->usec = header->ts.tv_usec/100; + + /* Ethernet Packet */ + ethernet = (struct ether_header *)(packet); + + /* IP Header Offset */ + ip = ( struct ip* )( (char *)ethernet + datalink_hdr_len ); + ip_size_total = (int)ntohs(ip->ip_len); + ip_size = ip->ip_hl * 4; + if (ip_size < 20) { + log_5("Packet has invalid IP header length: %u bytes", ip_size); + debug_3("Packet has invalid IP header length: %u bytes", ip_size); + return; + } + + dfheader->srcIP = htonl(ip->ip_src.s_addr); + dfheader->dstIP = htonl(ip->ip_dst.s_addr); + + if (inet_ntop(AF_INET, &ip->ip_src.s_addr, dfheader->src_ip, sizeof(dfheader->src_ip)) == NULL ) { + pdie("inet_ntop"); + } + if (inet_ntop(AF_INET, &ip->ip_dst.s_addr, dfheader->dst_ip, sizeof(dfheader->dst_ip)) == NULL ) { + pdie("inet_ntop"); + } + + if ( ip->ip_p == IPPROTO_UDP ) { + /* UDP Header */ + udp = ( struct udphdr* ) ( (u_char *)ip + ip_size ); + + udp_size = sizeof(struct udphdr); + if (ntohs(udp->uh_ulen) <= 12) { + log_5("Packet has invalid UDP header length: %u bytes", udp_size); + debug_3("Packet has invalid UDP header length: %u bytes", udp_size); + return; + } + + /* UDP Payload */ + payload = (char *)((u_char *)udp + udp_size); + + /* UDP Payload size */ + payload_size = ntohs(udp->uh_ulen) - udp_size; + +#ifdef DEBUG_PKTS + if (payload_size > 0) { + debug_5("Payload (%d bytes):", payload_size); + print_hex(payload, payload_size); + } +#endif + + //format_vop_payload(dfheader); + + dfheader->srcPort = ntohs(udp->uh_sport); + dfheader->dstPort = ntohs(udp->uh_dport); + + } else if ( ip->ip_p == IPPROTO_TCP ) { + + /* TCP Header */ + tcp = ( struct tcphdr* ) ( (u_char *)ip + ip_size); + + tcp_size = tcp->th_off * 4; + if (tcp_size < 20) { + log_5("Packet has invalid TCP header length: %u bytes", tcp_size); + debug_3("Packet has invalid TCP header length: %u bytes", tcp_size); + return; + } + + /* TCP Payload */ + payload = (char *)((u_char *)tcp + tcp_size); + + /* TCP Payload size */ + payload_size = ntohs(ip->ip_len) - (ip_size + tcp_size); + + dfheader->srcPort = ntohs(tcp->th_sport); + dfheader->dstPort = ntohs(tcp->th_dport); + + } else { + debug_4("Packet is neither UDP or TCP"); + dfheader->srcPort = 0; + dfheader->dstPort = 0; + } + + /*------------------------------------------------------------------------*/ + /* only send Communications Content CmC msg if requested */ + /*------------------------------------------------------------------------*/ + if ( content_option == 1 ) { + + //debug_5("IP (%d bytes):", ip_size_total); + //print_hex((const u_char *)ip, (size_t)ip_size_total); + + dfheader->sequenceNumber++; + dfheader->payload = (const char *)ip; + dfheader->payload_size = (size_t)ip_size_total; + /*------------------------------------------------------------------------*/ + /* WARNING: cc_apdu will allocate space for the BER encoded message. */ + /* This space MUST be freed when it is no longer needed or a */ + /* memory leak will occur. */ + /* */ + /* The address of the allocated memory is dfheader->encoded. */ + /* The size of the allocated memory is dfheader->encoded_size. */ + /* If cc_apdu does not return 0, no deallocation is needed. */ + /*------------------------------------------------------------------------*/ + if ( cc_apdu(dfheader) == 0) { + debug_5("Encoded addr(size): %p(%Zd)", dfheader->encoded_size, dfheader->encoded); + } else { + debug_5("cc_apdu returned nonzero"); + return; + } + + total_pkt_length = sizeof(Msg) + dfheader->encoded_size; + debug_5 ( "building CmC packet size: %d", total_pkt_length ); + cmc_pkt = CmCPacketBuild ( dfheader ); + debug_5 ( "sending CmC packet size: %d", total_pkt_length ); + PacketSend ( cmc_pkt, total_pkt_length, &send_df_socket ); + PacketFree ( cmc_pkt ); + + free(dfheader->encoded); + + } + + if (packet_data_header_report(dfheader) == 0) { + debug_5("Packet_Data_Header_Report encoded addr: %p, size: %Zd", dfheader->encoded, dfheader->encoded_size); + //print_hex((const u_char *)dfheader->encoded, (size_t)dfheader->encoded_size); + } else { + return; + } + + total_pkt_length = sizeof(Msg) + dfheader->encoded_size; + debug_5 ( "building T1.IAS CmII packet size: %d", total_pkt_length); + cmii_pkt = CmIIPacketBuild ( dfheader ); + debug_5 ( "sending T1.IAS CmII packet size: %d", total_pkt_length ); + //print_hex((const u_char *)cmii_pkt, (size_t)total_pkt_length); + PacketSend ( cmii_pkt, total_pkt_length, &send_df_socket ); + PacketFree ( cmii_pkt ); + + free(dfheader->encoded); + + if (directsignalreporting(dfheader) == 0) { + debug_5("Direct Signal Reporting encoded addr: %p, size: %Zd", dfheader->encoded, dfheader->encoded_size); + //print_hex((const u_char *)dfheader->encoded, (size_t)dfheader->encoded_size); + } else { + return; + } + + total_pkt_length = sizeof(Msg) + dfheader->encoded_size; + debug_5 ( "building T1.678 CmII packet size: %d", total_pkt_length); + cmii_pkt = CmIIPacketBuild ( dfheader ); + debug_5 ( "sending T1.678 CmII packet size: %d", total_pkt_length ); + //print_hex((const u_char *)cmii_pkt, (size_t)total_pkt_length); + PacketSend ( cmii_pkt, total_pkt_length, &send_df_socket ); + PacketFree ( cmii_pkt ); + + free(dfheader->encoded); +} + + Modified: trunk/src/tap.c =================================================================== --- trunk/src/tap.c 2007-05-11 16:58:30 UTC (rev 30) +++ trunk/src/tap.c 2007-05-11 22:53:48 UTC (rev 31) @@ -29,217 +29,31 @@ #include "common.h" #include "calea.h" #include "tap.h" +#include "packet_data_header_report.h" #include <pcap.h> #include <net/ethernet.h> /* function declarations */ -char *cc_apdu(HEADER *); -char *packet_data_header_report(HEADER *); -char *directsignalreporting(HEADER *); -void get_calea_time (time_t, time_t, char *); -Msg *CmCPacketBuild (HEADER *); -Msg *CmIIPacketBuild (HEADER *); -int PacketSend ( Msg *, int, int * ); -void PacketFree (Msg *); -Msg *CtrlMsgBuild (HEADER *); -ssize_t tcp_write(int, const void *, size_t); -ssize_t tcp_read(int, void *, size_t); +void process_packet_cc_apdu( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ); +void process_packet_cmii_pdhr( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ); +void process_packet_cmc_pdhr( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ); +void process_packet_cmc_udp( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ); +void process_packet_raw( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ); +void process_packet_pcap( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ); + char *prog_name = "tap"; int syslog_facility = DEF_SYSLOG_FACILITY; char contentID[MAX_CONTENT_ID_LENGTH]; char caseID[MAX_CASE_ID_LENGTH]; char iapID[MAX_IAP_SYSTEM_ID_LENGTH]; -int datalink_hdr_len; +int datalink_hdr_len; int send_df_socket; struct sockaddr_in send_df_addr; -int content_option = 0; -void process_packet( u_char *args, const struct pcap_pkthdr *header, const u_char *packet ) { - - struct ether_header *ethernet; - struct ip *ip; - struct udphdr *udp; - struct tcphdr *tcp; - Msg *cmc_pkt; - Msg *cmii_pkt; - int total_pkt_length; - int ip_size; - int tcp_size; - int udp_size; - int payload_size; - int ip_size_total; - const char *payload; /* Packet Payload */ - HEADER *dfheader; - char calea_time[TS_LENGTH]; - - dfheader = (HEADER *)args; - -#ifdef DEBUG_PKTS - char msg[ MAX_LOG_DEBUG_MSG_LEN ]; - memset ( msg, '\0', MAX_LOG_DEBUG_MSG_LEN ); -#endif - - get_calea_time ( header->ts.tv_sec, header->ts.tv_usec, &calea_time[0] ); - - dfheader->sec = header->ts.tv_sec; - dfheader->usec = header->ts.tv_usec/100; - - /* Ethernet Packet */ - ethernet = (struct ether_header *)(packet); - - /* IP Header Offset */ - ip = ( struct ip* )( (char *)ethernet + datalink_hdr_len ); - ip_size_total = (int)ntohs(ip->ip_len); - ip_size = ip->ip_hl * 4; - if (ip_size < 20) { - log_5("Packet has invalid IP header length: %u bytes", ip_size); - debug_3("Packet has invalid IP header length: %u bytes", ip_size); - return; - } - - dfheader->srcIP = htonl(ip->ip_src.s_addr); - dfheader->dstIP = htonl(ip->ip_dst.... [truncated message content] |
From: <jn...@us...> - 2007-05-11 16:58:29
|
Revision: 30 http://opencalea.svn.sourceforge.net/opencalea/?rev=30&view=rev Author: jnorell Date: 2007-05-11 09:58:30 -0700 (Fri, 11 May 2007) Log Message: ----------- Die on listening socket errors. Modified Paths: -------------- trunk/src/df_collector.c trunk/src/log_debug.c trunk/src/tap.c Modified: trunk/src/df_collector.c =================================================================== --- trunk/src/df_collector.c 2007-05-11 16:26:07 UTC (rev 29) +++ trunk/src/df_collector.c 2007-05-11 16:58:30 UTC (rev 30) @@ -25,11 +25,11 @@ */ #include "common.h" -#include "msg.h" #include "calea.h" - #include "df_collector.h" +#include <sys/stat.h> + ssize_t tcp_write(int fd, const void *buf, size_t tot_len); ssize_t tcp_read(int fd, void *buf, size_t tot_len); void parse_commandline(int argc, char *argv[]); @@ -642,6 +642,9 @@ parse_commandline(argc, argv); + debug_4("setting umask: %07d", S_IRWXO); + umask(S_IRWXO); + /************************/ /* Create DF TCP socket */ /************************/ @@ -673,9 +676,15 @@ res->ai_family == PF_INET6 ? 6 : 4, addrstr, res->ai_canonname, ntohs(servaddr.sin_port)); freeaddrinfo(res); - Setsockopt(df_tcpfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); - Bind(df_tcpfd, (struct sockaddr *) &servaddr, sizeof(servaddr)); - Listen(df_tcpfd, MAX_CONNECTIONS); + if (Setsockopt(df_tcpfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0) { + pdie("DF TCP listen socket: setsockopt"); + } + if (Bind(df_tcpfd, (struct sockaddr *) &servaddr, sizeof(servaddr)) < 0) { + pdie("DF TCP listen socket: bind"); + } + if (Listen(df_tcpfd, MAX_CONNECTIONS) < 0) { + pdie("DF TCP listen socket: listen"); + } /*****************************/ /* Create control TCP socket */ @@ -710,9 +719,15 @@ res->ai_family == PF_INET6 ? 6 : 4, addrstr, res->ai_canonname, ntohs(servaddr.sin_port)); freeaddrinfo(res); - Setsockopt(controlfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); - Bind(controlfd, (struct sockaddr *) &servaddr, sizeof(servaddr)); - Listen(controlfd, MAX_CONNECTIONS); + if (Setsockopt(controlfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0) { + pdie("DF TCP control socket: setsockopt"); + } + if (Bind(controlfd, (struct sockaddr *) &servaddr, sizeof(servaddr)) < 0) { + pdie("DF TCP control socket: bind"); + } + if (Listen(controlfd, MAX_CONNECTIONS) < 0) { + pdie("DF TCP control socket: listen"); + } /************************/ /* Create DF UDP socket */ @@ -745,8 +760,12 @@ res->ai_family == PF_INET6 ? 6 : 4, addrstr, res->ai_canonname, ntohs(servaddr.sin_port)); freeaddrinfo(res); - Setsockopt(df_udpfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); - Bind(df_udpfd, (struct sockaddr *) &servaddr, sizeof(servaddr)); + if (Setsockopt(df_udpfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0) { + pdie("DF UDP listen socket: setsockopt"); + } + if (Bind(df_udpfd, (struct sockaddr *) &servaddr, sizeof(servaddr)) < 0) { + pdie("DF UDP listen socket: bind"); + } /********************************************************************/ Modified: trunk/src/log_debug.c =================================================================== --- trunk/src/log_debug.c 2007-05-11 16:26:07 UTC (rev 29) +++ trunk/src/log_debug.c 2007-05-11 16:58:30 UTC (rev 30) @@ -363,8 +363,8 @@ exit ( -1 ); } - snprintf ( mymsg, MAX_LOG_DEBUG_MSG_LEN, "%s: %s: %s\n", - save_name, msg, strerror ( errno ) ); + snprintf ( mymsg, MAX_LOG_DEBUG_MSG_LEN, "%s: %s\n", + msg, strerror ( errno ) ); die ( mymsg ); free ( mymsg ); Modified: trunk/src/tap.c =================================================================== --- trunk/src/tap.c 2007-05-11 16:26:07 UTC (rev 29) +++ trunk/src/tap.c 2007-05-11 16:58:30 UTC (rev 30) @@ -29,7 +29,6 @@ #include "common.h" #include "calea.h" #include "tap.h" -#include "util.h" #include <pcap.h> #include <net/ethernet.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jn...@us...> - 2007-05-11 16:26:08
|
Revision: 29 http://opencalea.svn.sourceforge.net/opencalea/?rev=29&view=rev Author: jnorell Date: 2007-05-11 09:26:07 -0700 (Fri, 11 May 2007) Log Message: ----------- Enhancing debug/log messages with program name and pid. Modified Paths: -------------- trunk/src/common.h trunk/src/df_collector.c trunk/src/lea_collector.c trunk/src/log_debug.c trunk/src/tap.c Modified: trunk/src/common.h =================================================================== --- trunk/src/common.h 2007-05-11 14:22:35 UTC (rev 28) +++ trunk/src/common.h 2007-05-11 16:26:07 UTC (rev 29) @@ -132,8 +132,9 @@ #define DEF_TAP_USER DEF_USER #define DEF_TAP_GROUP DEF_GROUP -#define MAX_MSGSIZE 4096 /* max size of control message/response */ +#define MAX_MSGSIZE 4096 /* max size of control message/response */ #define MAX_LINE 512 +#define MAX_HOST 128 /* maximum size of hostname */ #define min(a,b) ((a) < (b) ? (a) : (b)) #define max(a,b) ((a) > (b) ? (a) : (b)) Modified: trunk/src/df_collector.c =================================================================== --- trunk/src/df_collector.c 2007-05-11 14:22:35 UTC (rev 28) +++ trunk/src/df_collector.c 2007-05-11 16:26:07 UTC (rev 29) @@ -216,39 +216,39 @@ /* Get CmII_Path from config file */ if ((confptr = get_config(&config, "CmII_Path")) != NULL) { cmii_path = Strdup(*confptr->nextval++); - debug_4("df_collector: CmII_Path [%s]", cmii_path); + debug_4("CmII_Path [%s]", cmii_path); } /* Get CmC_Path from config file */ if ((confptr = get_config(&config, "CmC_Path")) != NULL) { cmc_path = Strdup(*confptr->nextval++); - debug_4("df_collector: CmC_Path [%s]", cmc_path); + debug_4("CmC_Path [%s]", cmc_path); } /* Get Log_Path from config file */ if ((confptr = get_config(&config, "Log_Path")) != NULL) { log_path = Strdup(*confptr->nextval++); - debug_4("df_collector: log_path [%s]", log_path); + debug_4("log_path [%s]", log_path); } if ( bind_addr == NULL ) { if ((confptr = get_config(&config, "Bind_Addr"))) { bind_addr = Strdup ( *confptr->nextval++ ); - debug_4("df_collector: bind address set from config file (%s)", bind_addr); + debug_4("bind address set from config file (%s)", bind_addr); } else { bind_addr = Strdup ( "127.0.0.1" ); - debug_4("df_collector: Using default bind address (%s)", bind_addr); + debug_4("Using default bind address (%s)", bind_addr); } } if ( df_port == NULL ) { if ((confptr = get_config(&config, "DF_Port"))) { df_port = Strdup ( *confptr->nextval++ ); - debug_5 ( "df_collector: DF listener port set from config file (%d)", df_port ); + debug_4 ( "DF listener port set from config file (%d)", df_port ); } else { df_port = Calloc ( 64 ); snprintf ( df_port, 64, "%d", DF_PORT ); - debug_5 ( "df_collector: Using default DF listener port (%d)", df_port ); + debug_4 ( "Using default DF listener port (%d)", df_port ); } } @@ -279,11 +279,11 @@ switch(msg->msgh.msgtype) { case MSGTYPE_NONE: - debug_2("df_collector: MSGTYPE_NONE uninitialized or not present"); + debug_2("MSGTYPE_NONE uninitialized or not present"); break; case MSGTYPE_CONTROL: - //debug_3("df_collector: MSGTYPE_CONTROL OpenCALEA Control message"); + debug_3("MSGTYPE_CONTROL OpenCALEA Control message"); ctrlmsg = (CtrlMsg *)((char *)msg + msg_len); //print_hex((const u_char *)msg, msg_len); @@ -292,7 +292,7 @@ switch (ctrlmsg->ctrlh.cmd) { case CTRLCMD_ROUTE_ADD: - debug_3("df_collector: ROUTE ADD Control message received"); + debug_3("ROUTE ADD Control message received"); /* look for a free slot in the route[] table */ for (id=0; id<MAXROUTES; id++) { @@ -301,8 +301,8 @@ } if (id == MAXROUTES) { - debug_1("df_collector: no available routes"); - log_2("df_collector: no available routes"); + debug_1("no available routes"); + log_2("no available routes"); return -1; } @@ -316,8 +316,8 @@ strncat(filename,(char *)ctrlmsg->ctrlh.intercept.CaseID,MAX_LINE - strlen(filename)); strncat(filename,".CmII",MAX_LINE - strlen(filename)); if (!(route[id].cmii_fp = fopen(filename, "wb"))) { - error("df_collector: CmII_fp open failed for %s", filename); - pdie("df_collector: CmII_fp fopen"); + error("CmII_fp open failed for %s", filename); + pdie("CmII_fp fopen"); } } @@ -331,8 +331,8 @@ strncat(filename,(char *)ctrlmsg->ctrlh.intercept.CaseID,MAX_LINE - strlen(filename)); strncat(filename,".CmC",MAX_LINE - strlen(filename)); if (!(route[id].cmc_fp = fopen(filename, "wb"))) { - error("df_collector: CmC_fp open failed for %s", filename); - pdie("df_collector: CmC_fp fopen"); + error("CmC_fp open failed for %s", filename); + pdie("CmC_fp fopen"); } } @@ -346,8 +346,8 @@ strncat(filename,(char *)ctrlmsg->ctrlh.intercept.CaseID,MAX_LINE - strlen(filename)); strncat(filename,".LOG",MAX_LINE - strlen(filename)); if (!(route[id].log_fp = fopen(filename, "w"))) { - error("df_collector: Surveillance log file open failed for %s", filename); - pdie("df_collector: Surveillance log fopen"); + error("Surveillance log file open failed for %s", filename); + pdie("Surveillance log fopen"); } } @@ -356,20 +356,21 @@ /*****************************************/ sprintf(route_port, "%d", ntohs(ctrlmsg->ctrlh.dfhost.port)); if (strcmp((char *)ctrlmsg->ctrlh.dfhost.protocol,"udp") == 0) { - debug_4("df_collector: route protocol is UDP"); + debug_4("route protocol is UDP"); socktype = SOCK_DGRAM; } else if (strcmp((char *)ctrlmsg->ctrlh.dfhost.protocol,"tcp") == 0) { - error("df_collector: TCP is currently an unsupported route protocol"); + error("TCP is currently an unsupported route protocol"); socktype = SOCK_STREAM; } else { - debug_2("df_collector: %s is currently an unsupported route protocol. Defaulting to UDP", + debug_2("%s is currently an unsupported route protocol. Defaulting to UDP", ctrlmsg->ctrlh.dfhost.protocol); socktype = SOCK_DGRAM; } res = Getaddrinfo1st((char *)ctrlmsg->ctrlh.dfhost.host, route_port, AF_INET, socktype); if (!res) { - debug_5("df_collector: ROUTE ADD Getaddrinfo1st failed"); + debug_3("ROUTE ADD Getaddrinfo1st failed"); + log_3("ROUTE ADD Getaddrinfo1st failed"); return -1; } @@ -381,17 +382,17 @@ route[id].lea_addr.sin_port = ((struct sockaddr_in *)res->ai_addr)->sin_port; route[id].lea_addr.sin_addr.s_addr = ((struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr; if ((route[id].lea_fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) { - debug_2("df_collector: ipv4 route[%d]=%d socket failure", id, route[id].lea_fd); + debug_2("ipv4 route[%d]=%d socket failure", id, route[id].lea_fd); break; } if (connect(route[id].lea_fd, res->ai_addr, res->ai_addrlen) < 0) { - debug_2 ( "df_collector: connect error"); + debug_2 ( "connect error"); Close(route[id].lea_fd); route[id].lea_fd = -1; } - debug_3("df_collector: ROUTE[%d] created to %s://%s:%d [%s %s %s]", + debug_3("ROUTE[%d] created to %s://%s:%d [%s %s %s]", id, ctrlmsg->ctrlh.dfhost.protocol, ctrlmsg->ctrlh.dfhost.host, @@ -404,10 +405,10 @@ freeaddrinfo(res); return DF_REPLY; case AF_INET6: - error("df_collector: we don't handle IPv6 yet."); + error("we don't handle IPv6 yet."); break; default: - error("df_collector: we don't handle address family %d.", res->ai_family); + error("we don't handle address family %d.", res->ai_family); break; } break; @@ -417,7 +418,7 @@ } case MSGTYPE_LOG: - debug_4("df_collector: MSGTYPE_LOG Surveillance Log message"); + debug_4("MSGTYPE_LOG Surveillance Log message"); //print_hex((const u_char *)msg, msg_len); //print_hex((const u_char *)((char *)msg + msg_len), msg->msgh.msglen); @@ -426,21 +427,24 @@ if (route[id].log_fp) { ret = fwrite(((char *)msg + msg_len), msg->msgh.msglen, 1, route[id].log_fp); if (ret != 1) { - error("df_collector: error writing to Log file: %s", strerror(errno)); + error("error writing to Log file: %s", strerror(errno)); } } else { - debug_2("df_collector: Warning Log file is not available"); + debug_2("Warning Log file is not available"); } break; case MSGTYPE_CMII: - debug_5("df_collector: MSGTYPE_CMII Communications Identifying Information message"); + debug_5("MSGTYPE_CMII Communications Identifying Information message"); //print_hex((const u_char *)msg, msg_len); //print_hex((const u_char *)((char *)msg + msg_len), msg->msgh.msglen); id = ntohs(msg->msgh.routeid); - inet_ntop (route[id].lea_addr.sin_family, &route[id].lea_addr.sin_addr.s_addr, addrstr, sizeof(addrstr)); + if (inet_ntop (route[id].lea_addr.sin_family, + &route[id].lea_addr.sin_addr.s_addr, addrstr, sizeof(addrstr)) == NULL) { + error("inet_ntop: %s", strerror(errno)); + } /**************************/ /* Write packet to a file */ @@ -448,10 +452,10 @@ if (route[id].cmii_fp) { ret = fwrite(((char *)msg + msg_len), msg->msgh.msglen, 1, route[id].cmii_fp); if (ret != 1) { - error("df_collector: error writing to CmII file: %s", strerror(errno)); + error("error writing to CmII file: %s", strerror(errno)); } } else { - debug_5("df_collector: CmII capture file is not available"); + debug_5("CmII capture file is not available"); } num_sent = sendto (route[id].lea_fd, @@ -469,7 +473,7 @@ /* GUARANTEE that the data was actually received at the remote end. */ /****************************************************************************/ if (num_sent == -1) { - debug_5("df_collector: CmII packet -> route[%d] %s:%d failed saving to file", + debug_5("CmII packet -> route[%d] %s:%d failed, saving to file", id, addrstr, ntohs(route[id].lea_addr.sin_port)); @@ -482,15 +486,15 @@ if (route[id].cmii_fp) { ret = fwrite(((char *)msg + msg_len), msg->msgh.msglen, 1, route[id].cmii_fp); if (ret != 1) { - debug_5("df_collector: Error writing to CmII file"); + error("Error writing to CmII file: %s", strerror(errno)); } else { - debug_5("df_collector: Wrote %d bytes to CmII file", (ret * msg->msgh.msglen)); + debug_5("Wrote %d bytes to CmII file", (ret * msg->msgh.msglen)); } } else { - debug_5("df_collector: Warning CmII capture file is not available"); + debug_5("Warning CmII capture file is not available"); } } else { - debug_5("df_collector: CmII packet -> route[%d] %s:%d %d bytes sent ", + debug_5("CmII packet -> route[%d] %s:%d %d bytes sent ", id, addrstr, ntohs(route[id].lea_addr.sin_port), @@ -500,16 +504,19 @@ break; case MSGTYPE_CII: - debug_3("df_collector: MSGTYPE_CII Call Identifying Information message"); + debug_3("MSGTYPE_CII Call Identifying Information message"); break; case MSGTYPE_CMC: - debug_5("df_collector: MSGTYPE_CMC Communications Content message"); + debug_5("MSGTYPE_CMC Communications Content message"); //print_hex((const u_char *)msg, msg_len); //print_hex((const u_char *)((char *)msg + msg_len), msg->msgh.msglen); id = ntohs(msg->msgh.routeid); - inet_ntop (route[id].lea_addr.sin_family, &route[id].lea_addr.sin_addr.s_addr, addrstr, sizeof(addrstr)); + if (inet_ntop (route[id].lea_addr.sin_family, + &route[id].lea_addr.sin_addr.s_addr, addrstr, sizeof(addrstr)) == NULL) { + error("inet_ntop: %s", strerror(errno)); + } num_sent = sendto (route[id].lea_fd, ((char *)msg + msg_len), @@ -526,7 +533,7 @@ /* GUARANTEE that the data was actually received at the remote end. */ /****************************************************************************/ if (num_sent == -1) { - debug_5("df_collector: CmC packet -> route[%d] %s:%d failed saving to file", + debug_5("CmC packet -> route[%d] %s:%d failed, saving to file", id, addrstr, ntohs(route[id].lea_addr.sin_port)); @@ -538,16 +545,16 @@ if (route[id].cmc_fp) { ret = fwrite(((char *)msg + msg_len), msg->msgh.msglen, 1, route[id].cmc_fp); if (ret != 1) { - debug_5("df_collector: Error writing to CmC file"); + error("Error writing to CmC file: %s", strerror(errno)); } else { - debug_5("df_collector: Wrote %d bytes to CmC file", (ret * msg->msgh.msglen)); + debug_5("Wrote %d bytes to CmC file", (ret * msg->msgh.msglen)); } } else { - debug_5("df_collector: Warning CmC capture file is not available"); + debug_5("Warning CmC capture file is not available"); } } else { - debug_5("df_collector: CmC packet -> route[%d] %s:%d %d bytes sent ", + debug_5("CmC packet -> route[%d] %s:%d %d bytes sent ", id, addrstr, ntohs(route[id].lea_addr.sin_port), @@ -557,10 +564,10 @@ break; case MSGTYPE_CC: - debug_3("df_collector: MSGTYPE_CC Call Content message"); + debug_3("MSGTYPE_CC Call Content message"); break; default: - debug_2("df_collector: Unknown MSGTYPE detected"); + debug_2("Unknown MSGTYPE detected: %d", msg->msgh.msgtype); break; } @@ -570,31 +577,31 @@ switch(msg->msgh.format) { case MSGFMT_NONE: - debug_5("df_collector: MSGFMT_NONE uninitialized or not present"); + debug_5("MSGFMT_NONE uninitialized or not present"); break; case MSGFMT_C: - debug_5("df_collector: MSGFMT_C C structure"); + debug_5("MSGFMT_C C structure"); break; case MSGFMT_XML: - debug_5("df_collector: MSGFMT_XML eXtensible Markup Language"); + debug_5("MSGFMT_XML eXtensible Markup Language"); break; case MSGFMT_BER: - debug_5("df_collector: MSGFMT_BER Basic Encoding Rules"); + debug_5("MSGFMT_BER Basic Encoding Rules"); break; case MSGFMT_TXT: - debug_5("df_collector: MSGFMT_TXT Plain Text"); + debug_5("MSGFMT_TXT Plain Text"); break; case MSGFMT_CSV: - debug_5("df_collector: MSGFMT_CSV Comma Seperated Values"); + debug_5("MSGFMT_CSV Comma Seperated Values"); break; case MSGFMT_IAS_D31: - debug_5("df_collector: MSGFMT_IAS_D31 IAS section D.3.1 CmC in UDP Encapsulation"); + debug_5("MSGFMT_IAS_D31 IAS section D.3.1 CmC in UDP Encapsulation"); break; case MSGFMT_IAS_D32: - debug_5("df_collector: MSGFMT_IAS_D32 IAS section D.3.2 CmC in IC-APDU's"); + debug_5("MSGFMT_IAS_D32 IAS section D.3.2 CmC in IC-APDU's"); break; default: - debug_5("df_collector: Unknown MSGFMT detected"); + debug_5("Unknown MSGFMT detected"); break; } @@ -641,7 +648,7 @@ res = Getaddrinfo1st(bind_addr, df_port, AF_INET, SOCK_STREAM); if (!res) { - debug_5("df_collector: %s:%s TCP Gteaddrinfo1st failed", bind_addr, df_port); + error("%s:%s TCP Gteaddrinfo1st failed", bind_addr, df_port); return -1; } @@ -652,15 +659,17 @@ servaddr.sin_port = ((struct sockaddr_in *)res->ai_addr)->sin_port; servaddr.sin_addr.s_addr = ((struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr; if ((df_tcpfd = Socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) { - error("df_collector: DF TCP socket error"); + error("DF TCP socket error"); } break; default: - die("df_collector: DF TCP unsupported family"); + die("DF TCP unsupported family"); break; } - inet_ntop (servaddr.sin_family, &servaddr.sin_addr.s_addr, addrstr, sizeof(addrstr)); - debug_5("df_collector: DF TCP IPv%d address: %s (%s) port: %d", + if (inet_ntop (servaddr.sin_family, &servaddr.sin_addr.s_addr, addrstr, sizeof(addrstr)) == NULL) { + error("inet_ntop: %s", strerror(errno)); + } + debug_5("DF TCP IPv%d address: %s (%s) port: %d", res->ai_family == PF_INET6 ? 6 : 4, addrstr, res->ai_canonname, ntohs(servaddr.sin_port)); freeaddrinfo(res); @@ -676,7 +685,7 @@ res = Getaddrinfo1st(bind_addr, ctrl_port, AF_INET, SOCK_STREAM); if (!res) { - debug_5("df_collector: Control %s:%s TCP Gteaddrinfo1st failed", bind_addr, ctrl_port); + error("Control %s:%s TCP Gteaddrinfo1st failed", bind_addr, ctrl_port); return -1; } @@ -687,15 +696,17 @@ servaddr.sin_port = ((struct sockaddr_in *)res->ai_addr)->sin_port; servaddr.sin_addr.s_addr = ((struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr; if ((controlfd = Socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) { - pdie("df_collector: control TCP socket error"); + pdie("control TCP socket error"); } break; default: - die("df_collector: control TCP unsupported family"); + die("control TCP unsupported family"); break; } - inet_ntop (servaddr.sin_family, &servaddr.sin_addr.s_addr, addrstr, sizeof(addrstr)); - debug_5("df_collector: control TCP IPv%d address: %s (%s) port: %d", + if (inet_ntop (servaddr.sin_family, &servaddr.sin_addr.s_addr, addrstr, sizeof(addrstr)) == NULL) { + error("inet_ntop: %s", strerror(errno)); + } + debug_5("control TCP IPv%d address: %s (%s) port: %d", res->ai_family == PF_INET6 ? 6 : 4, addrstr, res->ai_canonname, ntohs(servaddr.sin_port)); freeaddrinfo(res); @@ -709,7 +720,7 @@ res = Getaddrinfo1st(bind_addr, df_port, AF_INET, SOCK_DGRAM); if (!res) { - debug_5("df_collector: %s:%s TCP Gteaddrinfo1st failed", bind_addr, df_port); + error("%s:%s TCP Gteaddrinfo1st failed", bind_addr, df_port); return -1; } @@ -720,15 +731,17 @@ servaddr.sin_port = ((struct sockaddr_in *)res->ai_addr)->sin_port; servaddr.sin_addr.s_addr = ((struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr; if ((df_udpfd = Socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) { - error("df_collector: DF UDP socket error"); + error("DF UDP socket error"); } break; default: - die("df_collector: DF UDP unsupported family"); + die("DF UDP unsupported family"); break; } - inet_ntop (servaddr.sin_family, &servaddr.sin_addr.s_addr, addrstr, sizeof(addrstr)); - debug_5("df_collector: DF UDP IPv%d address: %s (%s) port: %d", + if (inet_ntop (servaddr.sin_family, &servaddr.sin_addr.s_addr, addrstr, sizeof(addrstr)) == NULL) { + error("inet_ntop: %s", strerror(errno)); + } + debug_5("DF UDP IPv%d address: %s (%s) port: %d", res->ai_family == PF_INET6 ? 6 : 4, addrstr, res->ai_canonname, ntohs(servaddr.sin_port)); freeaddrinfo(res); @@ -765,7 +778,7 @@ if (errno == EINTR) continue; else { - pdie("df_collector: select error"); + pdie("select error"); } } @@ -782,7 +795,7 @@ } if (i == FD_SETSIZE) { - debug_5("Too many clients", 1); + error("Too many clients", 1); } FD_SET(connfd, &allset); /* add new descriptor to the set */ @@ -812,7 +825,7 @@ if (FD_ISSET(sockfd, &rset)) { if ((n=read(sockfd, buf, MAX_MSGSIZE)) <= 0) { - debug_3("df_collector: client closed connection (fd: %d)", sockfd); + debug_3("client closed connection (fd: %d)", sockfd); Close(sockfd); FD_CLR(sockfd, &allset); client[i] = -1; Modified: trunk/src/lea_collector.c =================================================================== --- trunk/src/lea_collector.c 2007-05-11 14:22:35 UTC (rev 28) +++ trunk/src/lea_collector.c 2007-05-11 16:26:07 UTC (rev 29) @@ -402,28 +402,28 @@ FD_SET( cmc_receiver_socket, &sock_fds ); num_sock_fds = select( max_fd+1 , &sock_fds, NULL, NULL, NULL); if ( num_sock_fds < 0 ) { - pdie ( "lea_collector: select " ); + pdie ( "select " ); } else if ( num_sock_fds == 0 ) { - debug_5 ( "lea_collector: select returned with 0 descriptors ready" ); + debug_5 ( "select returned with 0 descriptors ready" ); } else { /* read data on sockets */ if ( FD_ISSET( cmii_receiver_socket, &sock_fds )) { - debug_5 ( "lea_collector: CmII socket ready" ); + debug_5 ( "CmII socket ready" ); if ((n = recvfrom ( cmii_receiver_socket, buf, 10000, 0, (struct sockaddr*) &cmii_receiver_addr, &len)) == -1) { - pdie ( "lea_collector: cmii recvfrom" ); + pdie ( "cmii recvfrom" ); } else { - debug_5 ( "lea_collector: cmii recvfrom returned %d bytes", n ); + debug_5 ( "cmii recvfrom returned %d bytes", n ); } fwrite( buf, n, 1, cmii_fp); } if ( FD_ISSET( cmc_receiver_socket, &sock_fds )) { - debug_5 ( "lea_collector: CmC socket ready" ); + debug_5 ( "CmC socket ready" ); if ((n = recvfrom ( cmc_receiver_socket, buf, 10000, 0, (struct sockaddr*) &cmc_receiver_addr, &len)) == -1) { - pdie ( "lea_collector: cmc recvfrom " ); + pdie ( "cmc recvfrom " ); } else { - debug_5 ( "lea_collector: cmc recvfrom returned %d bytes", n ); + debug_5 ( "cmc recvfrom returned %d bytes", n ); } fwrite( buf, n, 1, cmc_fp); Modified: trunk/src/log_debug.c =================================================================== --- trunk/src/log_debug.c 2007-05-11 14:22:35 UTC (rev 28) +++ trunk/src/log_debug.c 2007-05-11 16:26:07 UTC (rev 29) @@ -49,6 +49,10 @@ int debug_with_newlines = 0; int log_with_newlines = 0; +char save_name[64]; +int save_facility; +int save_pid; + /* we want a high performance "do nothing" */ static void my_nulllog ( char *msg, ... ) { } @@ -68,7 +72,6 @@ va_list ap; char msg[MAX_DEBUG_MSG_LEN]; char *append = NULL; - char myname[64]; char *curtime; time_t tim; @@ -88,13 +91,11 @@ } curtime = ctime ( &tim ); curtime[ strlen ( curtime ) - 1 ] = 0; // remove \n - if ( fprintf ( debug_fp, "%s %s%s", curtime, msg, append ) == -1 ) { + if ( fprintf ( debug_fp, "%s %s[%d]: %s%s", curtime, save_name, save_pid, msg, append ) == -1 ) { perror ( "fprintf" ); exit ( -1 ); } } else { - snprintf ( myname, 64, "%s debug", prog_name ); - openlog ( myname, LOG_PID, syslog_facility ); syslog ( LOG_DEBUG, "%s", msg ); } } @@ -122,13 +123,11 @@ } curtime = ctime ( &tim ); curtime[ strlen ( curtime ) - 1 ] = 0; // remove \n - if ( fprintf ( log_fp, "%s %s%s", curtime, msg, append ) == -1 ) { + if ( fprintf ( log_fp, "%s %s[%d]: %s%s", curtime, save_name, save_pid, msg, append ) == -1 ) { perror ( "fprintf" ); exit ( -1 ); } } else { - openlog (prog_name, LOG_PID, syslog_facility); - switch ( log_level ) { case 1: syslog ( LOG_ALERT, "%s", msg ); @@ -161,7 +160,10 @@ * with_newlines: guarantee terminating newlines to file output, */ void setdebug ( int level, char *debug_to, int with_newlines ) { - + if (save_pid == 0) { + save_pid = (int)getpid(); + } + if ( ( debug_fd && debug_to_file ) && ( debug_fp != stdout ) && ( debug_fp != stderr ) @@ -230,6 +232,14 @@ * with_newlines: guarantee terminating newlines to file output */ void setlog ( int level, char *log_to, int with_newlines ) { + if (save_pid == 0) { + save_pid = (int)getpid(); + } + if (strncmp(save_name, prog_name, 64) || (save_facility != syslog_facility)) { + strncpy(save_name, prog_name, 64); + save_facility = syslog_facility; + openlog(save_name, LOG_PID, save_facility); + } if ( ( log_fd && log_to_file ) && ( log_fp != stdout ) @@ -310,7 +320,7 @@ if ( ( debug_fp != stdout ) && ( debug_fp != stderr ) && ( log_fp != stdout ) && ( log_fp != stderr ) ) { - fprintf ( stderr, "%s%s", msg, append ); + fprintf ( stderr, "%s: %s%s", save_name, msg, append ); } } @@ -338,7 +348,7 @@ if ( ( debug_fp != stdout ) && ( debug_fp != stderr ) && ( log_fp != stdout ) && ( log_fp != stderr ) ) { - fprintf ( stderr, "%s%s", msg, append ); + fprintf ( stderr, "%s: %s%s", save_name, msg, append ); } exit( -1 ); @@ -353,8 +363,8 @@ exit ( -1 ); } - snprintf ( mymsg, MAX_LOG_DEBUG_MSG_LEN, "%s: %s\n", - msg, strerror ( errno ) ); + snprintf ( mymsg, MAX_LOG_DEBUG_MSG_LEN, "%s: %s: %s\n", + save_name, msg, strerror ( errno ) ); die ( mymsg ); free ( mymsg ); Modified: trunk/src/tap.c =================================================================== --- trunk/src/tap.c 2007-05-11 14:22:35 UTC (rev 28) +++ trunk/src/tap.c 2007-05-11 16:26:07 UTC (rev 29) @@ -191,7 +191,7 @@ if ( cc_apdu(dfheader) == 0) { debug_5("Encoded addr(size): %p(%Zd)", dfheader->encoded_size, dfheader->encoded); } else { - debug_5("tap: cc_apdu returned nonzero"); + debug_5("cc_apdu returned nonzero"); return; } @@ -295,7 +295,7 @@ Msg *ctrlmsg; int controlfd = 0; char df_control_port[8]; - char addrstr[MAX_LINE]; + char addrstr[MAX_HOST]; void *ptr = NULL; CtrlMsg *temp; @@ -708,7 +708,7 @@ } for (res = res0; res; res = res->ai_next) { - if (inet_ntop (res->ai_family, res->ai_addr->sa_data, addrstr, MAX_LINE) == NULL) { + if (inet_ntop (res->ai_family, res->ai_addr->sa_data, addrstr, MAX_HOST) == NULL) { pdie("inet_ntop"); } @@ -717,11 +717,11 @@ ptr = &((struct sockaddr_in *) res->ai_addr)->sin_addr; controlfd = Socket(res->ai_family, res->ai_socktype, res->ai_protocol); if (controlfd == -1) { - debug_3("tap: ipv4 control socket failure"); + debug_3("ipv4 control socket failure"); break; } if (Connect(controlfd, res->ai_addr, res->ai_addrlen) == -1) { - debug_3("tap: ipv4 control connect failure"); + debug_3("ipv4 control connect failure"); Close(controlfd); controlfd = -1; break; @@ -731,10 +731,10 @@ ptr = &((struct sockaddr_in6 *) res->ai_addr)->sin6_addr; break; } - if (inet_ntop (res->ai_family, ptr, addrstr, MAX_LINE) == NULL) { + if (inet_ntop (res->ai_family, ptr, addrstr, MAX_HOST) == NULL) { pdie("inet_ntop"); } - debug_5 ("tap: df_control IPv%d address: %s (%s)", + debug_5 ("df_control IPv%d address: %s (%s)", res->ai_family == PF_INET6 ? 6 : 4, addrstr, res->ai_canonname); } freeaddrinfo(res0); @@ -746,14 +746,14 @@ temp->ctrlh.dfhost.port = htons(CF_CmII_PORT); i = tcp_write(controlfd, ctrlmsg, sizeof(Msg) + sizeof(CtrlMsg)); tcp_read(controlfd, ctrlmsg, i); - debug_3("tap: df_collector returned route[%d]", ntohs(ctrlmsg->msgh.routeid)); + debug_3("df_collector returned route[%d]", ntohs(ctrlmsg->msgh.routeid)); dfheader->cmii_routeid = ntohs(ctrlmsg->msgh.routeid); ctrlmsg->msgh.routeid = htons(-1); temp->ctrlh.dfhost.port = htons(CF_CmC_PORT); i = tcp_write(controlfd, ctrlmsg, i); tcp_read(controlfd, ctrlmsg, i); - debug_3("tap: df_collector returned route[%d]", ntohs(ctrlmsg->msgh.routeid)); + debug_3("df_collector returned route[%d]", ntohs(ctrlmsg->msgh.routeid)); dfheader->cmc_routeid = ntohs(ctrlmsg->msgh.routeid); free(ctrlmsg); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nor...@us...> - 2007-05-11 12:40:40
|
Revision: 27 http://opencalea.svn.sourceforge.net/opencalea/?rev=27&view=rev Author: norm_brandinger Date: 2007-05-11 05:40:32 -0700 (Fri, 11 May 2007) Log Message: ----------- Reapply df_collector fixes Modified Paths: -------------- trunk/src/df_collector.c Modified: trunk/src/df_collector.c =================================================================== --- trunk/src/df_collector.c 2007-05-10 23:07:56 UTC (rev 26) +++ trunk/src/df_collector.c 2007-05-11 12:40:32 UTC (rev 27) @@ -32,8 +32,8 @@ ssize_t tcp_write(int fd, const void *buf, size_t tot_len); ssize_t tcp_read(int fd, void *buf, size_t tot_len); +void parse_commandline(int argc, char *argv[]); void usage (void); -int PacketSend ( char *packet, int length, int *send_sock ); #define DF_REPLY 1 @@ -263,7 +263,7 @@ ssize_t num_sent; msg_len = sizeof(Msg); CtrlMsg *ctrlmsg; - int id; + int id, socktype; char route_port[8]; char filename[MAX_LINE]; @@ -283,7 +283,7 @@ break; case MSGTYPE_CONTROL: - debug_3("df_collector: MSGTYPE_CONTROL OpenCALEA Control message"); + //debug_3("df_collector: MSGTYPE_CONTROL OpenCALEA Control message"); ctrlmsg = (CtrlMsg *)((char *)msg + msg_len); //print_hex((const u_char *)msg, msg_len); @@ -355,26 +355,23 @@ /* Create a Route (generally to the LEA) */ /*****************************************/ sprintf(route_port, "%d", ntohs(ctrlmsg->ctrlh.dfhost.port)); - debug_4("df_collector: route port is %s", route_port); - - bzero(&hints, sizeof(hints)); - hints.ai_family = AF_INET; - if (strcmp((char *)ctrlmsg->ctrlh.dfhost.protocol,"udp") == 0) { debug_4("df_collector: route protocol is UDP"); - hints.ai_socktype = SOCK_DGRAM; + socktype = SOCK_DGRAM; } else if (strcmp((char *)ctrlmsg->ctrlh.dfhost.protocol,"tcp") == 0) { error("df_collector: TCP is currently an unsupported route protocol"); - hints.ai_socktype = SOCK_STREAM; + socktype = SOCK_STREAM; } else { debug_2("df_collector: %s is currently an unsupported route protocol. Defaulting to UDP", ctrlmsg->ctrlh.dfhost.protocol); - hints.ai_socktype = SOCK_DGRAM; + socktype = SOCK_DGRAM; } - if (getaddrinfo((char *)ctrlmsg->ctrlh.dfhost.host, route_port, &hints, &res)) { - return -1; - } + res = Getaddrinfo1st((char *)ctrlmsg->ctrlh.dfhost.host, route_port, AF_INET, socktype); + if (!res) { + debug_5("df_collector: ROUTE ADD Getaddrinfo1st failed"); + return -1; + } switch (res->ai_family) { case AF_INET: @@ -457,28 +454,49 @@ debug_5("df_collector: CmII capture file is not available"); } - num_sent = sendto (route[id].lea_fd, - ((char *)msg + msg_len), - msg->msgh.msglen, - 0, - (struct sockaddr *)&route[id].lea_addr, - sizeof(route[id].lea_addr)); + num_sent = sendto (route[id].lea_fd, + ((char *)msg + msg_len), + msg->msgh.msglen, + 0, + (struct sockaddr *)&route[id].lea_addr, + sizeof(route[id].lea_addr)); - if (num_sent == -1) { - debug_3("df_collector: CmII packet -> route[%d] %s:%d failed", - id, - addrstr, - ntohs(route[id].lea_addr.sin_port)); - socklen = sizeof(sockval); - Getsockopt(route[id].lea_fd, SOL_SOCKET, SO_ERROR, &sockval, &socklen); - } else { - debug_5("df_collector: CmII packet -> route[%d] %s:%d %d bytes sent ", - id, - addrstr, - ntohs(route[id].lea_addr.sin_port), - num_sent); - } + /****************************************************************************/ + /* If there was an error sending the data to the other end of the route[id] */ + /* then save the data locally for future transmission. */ + /* Note that for UDP transmissions, an error will only be indicated if the */ + /* the socket to the route[id] is in an error state. For UDP, there IS NO */ + /* GUARANTEE that the data was actually received at the remote end. */ + /****************************************************************************/ + if (num_sent == -1) { + debug_5("df_collector: CmII packet -> route[%d] %s:%d failed saving to file", + id, + addrstr, + ntohs(route[id].lea_addr.sin_port)); + socklen = sizeof(sockval); + Getsockopt(route[id].lea_fd, SOL_SOCKET, SO_ERROR, &sockval, &socklen); + /**************************/ + /* Write packet to a file */ + /**************************/ + if (route[id].cmii_fp) { + ret = fwrite(((char *)msg + msg_len), msg->msgh.msglen, 1, route[id].cmii_fp); + if (ret != 1) { + debug_5("df_collector: Error writing to CmII file"); + } else { + debug_5("df_collector: Wrote %d bytes to CmII file", (ret * msg->msgh.msglen)); + } + } else { + debug_5("df_collector: Warning CmII capture file is not available"); + } + } else { + debug_5("df_collector: CmII packet -> route[%d] %s:%d %d bytes sent ", + id, + addrstr, + ntohs(route[id].lea_addr.sin_port), + num_sent); + } + break; case MSGTYPE_CII: @@ -493,37 +511,49 @@ id = ntohs(msg->msgh.routeid); inet_ntop (route[id].lea_addr.sin_family, &route[id].lea_addr.sin_addr.s_addr, addrstr, sizeof(addrstr)); - if (route[id].cmc_fp) { - ret = fwrite(((char *)msg + msg_len), msg->msgh.msglen, 1, route[id].cmc_fp); - if (ret != 1) { - error("df_collector: error writing to CmC file: %s", strerror(errno)); - } - } else { - debug_5("df_collector: CmC capture file is not available"); - } + num_sent = sendto (route[id].lea_fd, + ((char *)msg + msg_len), + msg->msgh.msglen, + 0, + (struct sockaddr *)&route[id].lea_addr, + sizeof(route[id].lea_addr)); - num_sent = sendto (route[id].lea_fd, - ((char *)msg + msg_len), - msg->msgh.msglen, - 0, - (struct sockaddr *)&route[id].lea_addr, - sizeof(route[id].lea_addr)); - - if (num_sent == -1) { - debug_3("df_collector: CmC packet -> route[%d] %s:%d failed", - id, - addrstr, - ntohs(route[id].lea_addr.sin_port)); - socklen = sizeof(sockval); - Getsockopt(route[id].lea_fd, SOL_SOCKET, SO_ERROR, &sockval, &socklen); - } else { - debug_5("df_collector: CmC packet -> route[%d] %s:%d %d bytes sent ", - id, - addrstr, - ntohs(route[id].lea_addr.sin_port), - num_sent); - } + /****************************************************************************/ + /* If there was an error sending the data to the other end of the route[id] */ + /* then save the data locally for future transmission. */ + /* Note that for UDP transmissions, an error will only be indicated if the */ + /* the socket to the route[id] is in an error state. For UDP, there IS NO */ + /* GUARANTEE that the data was actually received at the remote end. */ + /****************************************************************************/ + if (num_sent == -1) { + debug_5("df_collector: CmC packet -> route[%d] %s:%d failed saving to file", + id, + addrstr, + ntohs(route[id].lea_addr.sin_port)); + socklen = sizeof(sockval); + Getsockopt(route[id].lea_fd, SOL_SOCKET, SO_ERROR, &sockval, &socklen); + /**************************/ + /* Write packet to a file */ + /**************************/ + if (route[id].cmc_fp) { + ret = fwrite(((char *)msg + msg_len), msg->msgh.msglen, 1, route[id].cmc_fp); + if (ret != 1) { + debug_5("df_collector: Error writing to CmC file"); + } else { + debug_5("df_collector: Wrote %d bytes to CmC file", (ret * msg->msgh.msglen)); + } + } else { + debug_5("df_collector: Warning CmC capture file is not available"); + } + } else { + debug_5("df_collector: CmC packet -> route[%d] %s:%d %d bytes sent ", + id, + addrstr, + ntohs(route[id].lea_addr.sin_port), + num_sent); + } + break; case MSGTYPE_CC: @@ -608,7 +638,13 @@ /************************/ /* Create DF TCP socket */ /************************/ + res = Getaddrinfo1st(bind_addr, df_port, AF_INET, SOCK_STREAM); + if (!res) { + debug_5("df_collector: %s:%s TCP Gteaddrinfo1st failed", bind_addr, df_port); + return -1; + } + switch (res->ai_family) { case AF_INET: bzero(&servaddr, sizeof(servaddr)); @@ -637,7 +673,13 @@ /*****************************/ ctrl_port = Calloc ( 64 ); snprintf ( ctrl_port, 64, "%d", DF_CONTROL_PORT ); + res = Getaddrinfo1st(bind_addr, ctrl_port, AF_INET, SOCK_STREAM); + if (!res) { + debug_5("df_collector: Control %s:%s TCP Gteaddrinfo1st failed", bind_addr, ctrl_port); + return -1; + } + switch (res->ai_family) { case AF_INET: bzero(&servaddr, sizeof(servaddr)); @@ -664,7 +706,13 @@ /************************/ /* Create DF UDP socket */ /************************/ + res = Getaddrinfo1st(bind_addr, df_port, AF_INET, SOCK_DGRAM); + if (!res) { + debug_5("df_collector: %s:%s TCP Gteaddrinfo1st failed", bind_addr, df_port); + return -1; + } + switch (res->ai_family) { case AF_INET: bzero(&servaddr, sizeof(servaddr)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jn...@us...> - 2007-05-10 23:07:57
|
Revision: 26 http://opencalea.svn.sourceforge.net/opencalea/?rev=26&view=rev Author: jnorell Date: 2007-05-10 16:07:56 -0700 (Thu, 10 May 2007) Log Message: ----------- Makefile.am fix Modified Paths: -------------- trunk/src/Makefile.am trunk/src/Makefile.in Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2007-05-10 23:04:31 UTC (rev 25) +++ trunk/src/Makefile.am 2007-05-10 23:07:56 UTC (rev 26) @@ -1,6 +1,6 @@ ## Makefile.am -- Process this file with automake to produce Makefile.in AM_CFLAGS = -g -O2 -Wall -Iasn.1/T1.678/CCDeliveryHeader -Iasn.1/T1.IAS/CmII -Iasn.1/T1.678/VoP -bin_PROGRAMS = tap df_collector lea_collector controller collector +bin_PROGRAMS = tap df_collector lea_collector tap_SOURCES = tap.c tap.h common.h calea.c calea.h log_debug.c log_debug.h cc_apdu.c packet_data_header_report.c directsignalreporting.c util.h util.c tap_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS) Modified: trunk/src/Makefile.in =================================================================== --- trunk/src/Makefile.in 2007-05-10 23:04:31 UTC (rev 25) +++ trunk/src/Makefile.in 2007-05-10 23:07:56 UTC (rev 26) @@ -33,7 +33,7 @@ build_triplet = @build@ host_triplet = @host@ bin_PROGRAMS = tap$(EXEEXT) df_collector$(EXEEXT) \ - lea_collector$(EXEEXT) controller$(EXEEXT) collector$(EXEEXT) + lea_collector$(EXEEXT) subdir = src DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -45,12 +45,6 @@ am__installdirs = "$(DESTDIR)$(bindir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) -collector_SOURCES = collector.c -collector_OBJECTS = collector.$(OBJEXT) -collector_LDADD = $(LDADD) -controller_SOURCES = controller.c -controller_OBJECTS = controller.$(OBJEXT) -controller_LDADD = $(LDADD) am_df_collector_OBJECTS = df_collector-df_collector.$(OBJEXT) \ df_collector-log_debug.$(OBJEXT) df_collector-calea.$(OBJEXT) \ df_collector-util.$(OBJEXT) @@ -89,10 +83,10 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ -SOURCES = collector.c controller.c $(df_collector_SOURCES) \ - $(lea_collector_SOURCES) $(tap_SOURCES) -DIST_SOURCES = collector.c controller.c $(df_collector_SOURCES) \ - $(lea_collector_SOURCES) $(tap_SOURCES) +SOURCES = $(df_collector_SOURCES) $(lea_collector_SOURCES) \ + $(tap_SOURCES) +DIST_SOURCES = $(df_collector_SOURCES) $(lea_collector_SOURCES) \ + $(tap_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -277,12 +271,6 @@ echo " rm -f $$p $$f"; \ rm -f $$p $$f ; \ done -collector$(EXEEXT): $(collector_OBJECTS) $(collector_DEPENDENCIES) - @rm -f collector$(EXEEXT) - $(LINK) $(collector_OBJECTS) $(collector_LDADD) $(LIBS) -controller$(EXEEXT): $(controller_OBJECTS) $(controller_DEPENDENCIES) - @rm -f controller$(EXEEXT) - $(LINK) $(controller_OBJECTS) $(controller_LDADD) $(LIBS) df_collector$(EXEEXT): $(df_collector_OBJECTS) $(df_collector_DEPENDENCIES) @rm -f df_collector$(EXEEXT) $(df_collector_LINK) $(df_collector_OBJECTS) $(df_collector_LDADD) $(LIBS) @@ -299,8 +287,6 @@ distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/collector.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/controller.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/df_collector-calea.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/df_collector-df_collector.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/df_collector-log_debug.Po@am__quote@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jn...@us...> - 2007-05-10 23:04:33
|
Revision: 25 http://opencalea.svn.sourceforge.net/opencalea/?rev=25&view=rev Author: jnorell Date: 2007-05-10 16:04:31 -0700 (Thu, 10 May 2007) Log Message: ----------- Moving everything to trunk/ Added Paths: ----------- trunk/LICENSE trunk/Makefile.am trunk/Makefile.in trunk/aclocal.m4 trunk/compile trunk/config.guess trunk/config.sub trunk/configure trunk/configure.ac trunk/depcomp trunk/doc/ trunk/etc/ trunk/install-sh trunk/ltmain.sh trunk/man/ trunk/missing trunk/src/ Removed Paths: ------------- LICENSE Makefile.am Makefile.in aclocal.m4 compile config.guess config.sub configure configure.ac depcomp doc/ etc/ install-sh ltmain.sh man/ missing src/ Deleted: LICENSE =================================================================== --- LICENSE 2007-05-10 22:57:13 UTC (rev 24) +++ LICENSE 2007-05-10 23:04:31 UTC (rev 25) @@ -1,29 +0,0 @@ -OpenCalea is distributed under the terms of the modified BSD license: - -/* - * Copyright (c) 2007, Merit Network, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Merit Network, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY MERIT NETWORK, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL MERIT NETWORK, INC. BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ Deleted: Makefile.am =================================================================== --- Makefile.am 2007-05-10 22:57:13 UTC (rev 24) +++ Makefile.am 2007-05-10 23:04:31 UTC (rev 25) @@ -1,3 +0,0 @@ -## Makefile.am -- Process this file with automake to produce Makefile.in - -SUBDIRS = doc/ man/ src/asn.1/T1.678/VoP src/asn.1/T1.678/CCDeliveryHeader src/asn.1/T1.IAS/CmII src/asn.1/T1.IAS/CmCC src/asn.1/T1.IAS/CmIIOptionalMessages src/ Deleted: Makefile.in =================================================================== --- Makefile.in 2007-05-10 22:57:13 UTC (rev 24) +++ Makefile.in 2007-05-10 23:04:31 UTC (rev 25) @@ -1,609 +0,0 @@ -# Makefile.in generated by automake 1.10 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = . -DIST_COMMON = $(am__configure_deps) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in $(top_srcdir)/configure compile \ - config.guess config.sub depcomp install-sh ltmain.sh missing -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ - configure.lineno config.status.lineno -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = -SOURCES = -DIST_SOURCES = -RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ - html-recursive info-recursive install-data-recursive \ - install-dvi-recursive install-exec-recursive \ - install-html-recursive install-info-recursive \ - install-pdf-recursive install-ps-recursive install-recursive \ - installcheck-recursive installdirs-recursive pdf-recursive \ - ps-recursive uninstall-recursive -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -distdir = $(PACKAGE)-$(VERSION) -top_distdir = $(distdir) -am__remove_distdir = \ - { test ! -d $(distdir) \ - || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ - && rm -fr $(distdir); }; } -DIST_ARCHIVES = $(distdir).tar.gz -GZIP_ENV = --best -distuninstallcheck_listfiles = find . -type f -print -distcleancheck_listfiles = find . -type f -print -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -ECHO = @ECHO@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -F77 = @F77@ -FFLAGS = @FFLAGS@ -GLIB_CFLAGS = @GLIB_CFLAGS@ -GLIB_LIBS = @GLIB_LIBS@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MATH_LIBS = @MATH_LIBS@ -MKDIR_P = @MKDIR_P@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PCAP_LIBS = @PCAP_LIBS@ -PKG_CONFIG = @PKG_CONFIG@ -RANLIB = @RANLIB@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_F77 = @ac_ct_F77@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -SUBDIRS = doc/ man/ src/asn.1/T1.678/VoP src/asn.1/T1.678/CCDeliveryHeader src/asn.1/T1.IAS/CmII src/asn.1/T1.IAS/CmCC src/asn.1/T1.IAS/CmIIOptionalMessages src/ -all: all-recursive - -.SUFFIXES: -am--refresh: - @: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \ - cd $(srcdir) && $(AUTOMAKE) --foreign \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - echo ' $(SHELL) ./config.status'; \ - $(SHELL) ./config.status;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - $(SHELL) ./config.status --recheck - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(srcdir) && $(AUTOCONF) -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -rm -f libtool - -# This directory's subdirectories are mostly independent; you can cd -# into them and run `make' without going through this Makefile. -# To change the values of `make' variables: instead of editing Makefiles, -# (1) if the variable is set in `config.status', edit `config.status' -# (which will cause the Makefiles to be regenerated when you run `make'); -# (2) otherwise, pass the desired values on the `make' command line. -$(RECURSIVE_TARGETS): - @failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -$(RECURSIVE_CLEAN_TARGETS): - @failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - rev=''; for subdir in $$list; do \ - if test "$$subdir" = "."; then :; else \ - rev="$$subdir $$rev"; \ - fi; \ - done; \ - rev="$$rev ."; \ - target=`echo $@ | sed s/-recursive//`; \ - for subdir in $$rev; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done && test -z "$$fail" -tags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ - done -ctags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ - done - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ - fi -ctags: CTAGS -CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - $(am__remove_distdir) - test -d $(distdir) || mkdir $(distdir) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done - list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - distdir=`$(am__cd) $(distdir) && pwd`; \ - top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ - (cd $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$top_distdir" \ - distdir="$$distdir/$$subdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - distdir) \ - || exit 1; \ - fi; \ - done - -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ - ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ - ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ - ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ - || chmod -R a+r $(distdir) -dist-gzip: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__remove_distdir) - -dist-bzip2: distdir - tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 - $(am__remove_distdir) - -dist-tarZ: distdir - tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z - $(am__remove_distdir) - -dist-shar: distdir - shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz - $(am__remove_distdir) - -dist-zip: distdir - -rm -f $(distdir).zip - zip -rq $(distdir).zip $(distdir) - $(am__remove_distdir) - -dist dist-all: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__remove_distdir) - -# This target untars the dist file and tries a VPATH configuration. Then -# it guarantees that the distribution is self-contained by making another -# tarfile. -distcheck: dist - case '$(DIST_ARCHIVES)' in \ - *.tar.gz*) \ - GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ - *.tar.bz2*) \ - bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ - *.tar.Z*) \ - uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ - *.shar.gz*) \ - GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ - *.zip*) \ - unzip $(distdir).zip ;;\ - esac - chmod -R a-w $(distdir); chmod a+w $(distdir) - mkdir $(distdir)/_build - mkdir $(distdir)/_inst - chmod a-w $(distdir) - dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ - && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ - && cd $(distdir)/_build \ - && ../configure --srcdir=.. --prefix="$$dc_install_base" \ - $(DISTCHECK_CONFIGURE_FLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) dvi \ - && $(MAKE) $(AM_MAKEFLAGS) check \ - && $(MAKE) $(AM_MAKEFLAGS) install \ - && $(MAKE) $(AM_MAKEFLAGS) installcheck \ - && $(MAKE) $(AM_MAKEFLAGS) uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ - distuninstallcheck \ - && chmod -R a-w "$$dc_install_base" \ - && ({ \ - (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ - distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ - } || { rm -rf "$$dc_destdir"; exit 1; }) \ - && rm -rf "$$dc_destdir" \ - && $(MAKE) $(AM_MAKEFLAGS) dist \ - && rm -rf $(DIST_ARCHIVES) \ - && $(MAKE) $(AM_MAKEFLAGS) distcleancheck - $(am__remove_distdir) - @(echo "$(distdir) archives ready for distribution: "; \ - list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ - sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' -distuninstallcheck: - @cd $(distuninstallcheck_dir) \ - && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ - || { echo "ERROR: files left after uninstall:" ; \ - if test -n "$(DESTDIR)"; then \ - echo " (check DESTDIR support)"; \ - fi ; \ - $(distuninstallcheck_listfiles) ; \ - exit 1; } >&2 -distcleancheck: distclean - @if test '$(srcdir)' = . ; then \ - echo "ERROR: distcleancheck can only run from a VPATH build" ; \ - exit 1 ; \ - fi - @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ - || { echo "ERROR: files left in build directory after distclean:" ; \ - $(distcleancheck_listfiles) ; \ - exit 1; } >&2 -check-am: all-am -check: check-recursive -all-am: Makefile -installdirs: installdirs-recursive -installdirs-am: -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic clean-libtool mostlyclean-am - -distclean: distclean-recursive - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-libtool \ - distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -info: info-recursive - -info-am: - -install-data-am: - -install-dvi: install-dvi-recursive - -install-exec-am: - -install-html: install-html-recursive - -install-info: install-info-recursive - -install-man: - -install-pdf: install-pdf-recursive - -install-ps: install-ps-recursive - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf $(top_srcdir)/autom4te.cache - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-generic mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: - -.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ - install-strip - -.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ - all all-am am--refresh check check-am clean clean-generic \ - clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \ - dist-gzip dist-shar dist-tarZ dist-zip distcheck distclean \ - distclean-generic distclean-libtool distclean-tags \ - distcleancheck distdir distuninstallcheck dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \ - uninstall uninstall-am - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: Deleted: aclocal.m4 =================================================================== --- aclocal.m4 2007-05-10 22:57:13 UTC (rev 24) +++ aclocal.m4 2007-05-10 23:04:31 UTC (rev 25) @@ -1,7389 +0,0 @@ -# generated automatically by aclocal 1.10 -*- Autoconf -*- - -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006 Free Software Foundation, Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -m4_if(m4_PACKAGE_VERSION, [2.61],, -[m4_fatal([this file was generated for autoconf 2.61. -You have another version of autoconf. If you want to use that, -you should regenerate the build system entirely.], [63])]) - -# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- - -# serial 48 Debian 1.5.22-4 AC_PROG_LIBTOOL - - -# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED) -# ----------------------------------------------------------- -# If this macro is not defined by Autoconf, define it here. -m4_ifdef([AC_PROVIDE_IFELSE], - [], - [m4_define([AC_PROVIDE_IFELSE], - [m4_ifdef([AC_PROVIDE_$1], - [$2], [$3])])]) - - -# AC_PROG_LIBTOOL -# --------------- -AC_DEFUN([AC_PROG_LIBTOOL], -[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl -dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX -dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX. - AC_PROVIDE_IFELSE([AC_PROG_CXX], - [AC_LIBTOOL_CXX], - [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX - ])]) -dnl And a similar setup for Fortran 77 support - AC_PROVIDE_IFELSE([AC_PROG_F77], - [AC_LIBTOOL_F77], - [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77 -])]) - -dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly. -dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run -dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both. - AC_PROVIDE_IFELSE([AC_PROG_GCJ], - [AC_LIBTOOL_GCJ], - [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], - [AC_LIBTOOL_GCJ], - [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ], - [AC_LIBTOOL_GCJ], - [ifdef([AC_PROG_GCJ], - [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])]) - ifdef([A][M_PROG_GCJ], - [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])]) - ifdef([LT_AC_PROG_GCJ], - [define([LT_AC_PROG_GCJ], - defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])]) -])])# AC_PROG_LIBTOOL - - -# _AC_PROG_LIBTOOL -# ---------------- -AC_DEFUN([_AC_PROG_LIBTOOL], -[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl -AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl -AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl -AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl - -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" - -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' -AC_SUBST(LIBTOOL)dnl - -# Prevent multiple expansion -define([AC_PROG_LIBTOOL], []) -])# _AC_PROG_LIBTOOL - - -# AC_LIBTOOL_SETUP -# ---------------- -AC_DEFUN([AC_LIBTOOL_SETUP], -[AC_PREREQ(2.50)dnl -AC_REQUIRE([AC_ENABLE_SHARED])dnl -AC_REQUIRE([AC_ENABLE_STATIC])dnl -AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl -AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([AC_PROG_LD])dnl -AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl -AC_REQUIRE([AC_PROG_NM])dnl - -AC_REQUIRE([AC_PROG_LN_S])dnl -AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl -# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! -AC_REQUIRE([AC_OBJEXT])dnl -AC_REQUIRE([AC_EXEEXT])dnl -dnl - -AC_LIBTOOL_SYS_MAX_CMD_LEN -AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE -AC_LIBTOOL_OBJDIR - -AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl -_LT_AC_PROG_ECHO_BACKSLASH - -case $host_os in -aix3*) - # AIX sometimes has problems with the GCC collect2 program. For some - # reason, if we set the COLLECT_NAMES environment variable, the problems - # vanish in a puff of smoke. - if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES - fi - ;; -esac - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed='sed -e 1s/^X//' -[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'] - -# Same as above, but do not quote variable references. -[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'] - -# Sed substitution to delay expansion of an escaped shell variable in a -# double_quote_subst'ed string. -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - -# Sed substitution to avoid accidental globbing in evaled expressions -no_glob_subst='s/\*/\\\*/g' - -# Constants: -rm="rm -f" - -# Global variables: -default_ofile=libtool -can_build_shared=yes - -# All known linkers require a `.a' archive for static linking (except MSVC, -# which needs '.lib'). -libext=a -ltmain="$ac_aux_dir/ltmain.sh" -ofile="$default_ofile" -with_gnu_ld="$lt_cv_prog_gnu_ld" - -AC_CHECK_TOOL(AR, ar, false) -AC_CHECK_TOOL(RANLIB, ranlib, :) -AC_CHECK_TOOL(STRIP, strip, :) - -old_CC="$CC" -old_CFLAGS="$CFLAGS" - -# Set sane defaults for various variables -test -z "$AR" && AR=ar -test -z "$AR_FLAGS" && AR_FLAGS=cru -test -z "$AS" && AS=as -test -z "$CC" && CC=cc -test -z "$LTCC" && LTCC=$CC -test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS -test -z "$DLLTOOL" && DLLTOOL=dlltool -test -z "$LD" && LD=ld -test -z "$LN_S" && LN_S="ln -s" -test -z "$MAGIC_CMD" && MAGIC_CMD=file -test -z "$NM" && NM=nm -test -z "$SED" && SED=sed -test -z "$OBJDUMP" && OBJDUMP=objdump -test -z "$RANLIB" && RANLIB=: -test -z "$STRIP" && STRIP=: -test -z "$ac_objext" && ac_objext=o - -# Determine commands to create old-style static archives. -old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= - -if test -n "$RANLIB"; then - case $host_os in - openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" - ;; - *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" - ;; - esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" -fi - -_LT_CC_BASENAME([$compiler]) - -# Only perform the check for file, if the check method requires it -case $deplibs_check_method in -file_magic*) - if test "$file_magic_cmd" = '$MAGIC_CMD'; then - AC_PATH_MAGIC - fi - ;; -esac - -AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no) -AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], -enable_win32_dll=yes, enable_win32_dll=no) - -AC_ARG_ENABLE([libtool-lock], - [AC_HELP_STRING([--disable-libtool-lock], - [avoid locking (might break parallel builds)])]) -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes - -AC_ARG_WITH([pic], - [AC_HELP_STRING([--with-pic], - [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], - [pic_mode="$withval"], - [pic_mode=default]) -test -z "$pic_mode" && pic_mode=default - -# Use C for the default configuration in the libtool script -tagname= -AC_LIBTOOL_LANG_C_CONFIG -_LT_AC_TAGCONFIG -])# AC_LIBTOOL_SETUP - - -# _LT_AC_SYS_COMPILER -# ------------------- -AC_DEFUN([_LT_AC_SYS_COMPILER], -[AC_REQUIRE([AC_PROG_CC])dnl - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC -])# _LT_AC_SYS_COMPILER - - -# _LT_CC_BASENAME(CC) -# ------------------- -# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. -AC_DEFUN([_LT_CC_BASENAME], -[for cc_temp in $1""; do - case $cc_temp in - compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; - distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` -]) - - -# _LT_COMPILER_BOILERPLATE -# ------------------------ -# Check for compiler boilerplate output or warnings with -# the simple compiler test code. -AC_DEFUN([_LT_COMPILER_BOILERPLATE], -[ac_outfile=conftest.$ac_objext -printf "$lt_simple_compile_test_code" >conftest.$ac_ext -eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_compiler_boilerplate=`cat conftest.err` -$rm conftest* -])# _LT_COMPILER_BOILERPLATE - - -# _LT_LINKER_BOILERPLATE -# ---------------------- -# Check for linker boilerplate output or warnings with -# the simple link test code. -AC_DEFUN([_LT_LINKER_BOILERPLATE], -[ac_outfile=conftest.$ac_objext -printf "$lt_simple_link_test_code" >conftest.$ac_ext -eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_linker_boilerplate=`cat conftest.err` -$rm conftest* -])# _LT_LINKER_BOILERPLATE - - -# _LT_AC_SYS_LIBPATH_AIX -# ---------------------- -# Links a minimal program and checks the executable -# for the system default hardcoded library path. In most cases, -# this is /usr/lib:/lib, but when the MPI compilers are used -# the location of the communication and MPI libs are included too. -# If we don't find anything, use the default library path according -# to the aix ld manual. -AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX], -[AC_LINK_IFELSE(AC_LANG_PROGRAM,[ -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'`; fi],[]) -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi -])# _LT_AC_SYS_LIBPATH_AIX - - -# _LT_AC_SHELL_INIT(ARG) -# ---------------------- -AC_DEFUN([_LT_AC_SHELL_INIT], -[ifdef([AC_DIVERSION_NOTICE], - [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], - [AC_DIVERT_PUSH(NOTICE)]) -$1 -AC_DIVERT_POP -])# _LT_AC_SHELL_INIT - - -# _LT_AC_PROG_ECHO_BACKSLASH -# -------------------------- -# Add some code to the start of the generated configure script which -# will find an echo command which doesn't interpret backslashes. -AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH], -[_LT_AC_SHELL_INIT([ -# Check that we are running under the correct shell. -SHELL=${CONFIG_SHELL-/bin/sh} - -case X$ECHO in -X*--fallback-echo) - # Remove one level of quotation (which was required for Make). - ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` - ;; -esac - -echo=${ECHO-echo} -if test "X[$]1" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift -elif test "X[$]1" = X--fallback-echo; then - # Avoid inline document here, it may be left over - : -elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then - # Yippee, $echo works! - : -else - # Restart under the correct shell. - exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} -fi - -if test "X[$]1" = X--fallback-echo; then - # used as fallback echo - shift - cat <<EOF -[$]* -EOF - exit 0 -fi - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -if test -z "$ECHO"; then -if test "X${echo_test_string+set}" != Xset; then -# find a string as large as possible, as long as the shell can cope with it - for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do - # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... - if (echo_test_string=`eval $cmd`) 2>/dev/null && - echo_test_string=`eval $cmd` && - (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null - then - break - fi - done -fi - -if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - : -else - # The Solaris, AIX, and Digital Unix default echo programs unquote - # backslashes. This makes it impossible to quote backslashes using - # echo "$something" | sed 's/\\/\\\\/g' - # - # So, first we look for a working echo in the user's PATH. - - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for dir in $PATH /usr/ucb; do - IFS="$lt_save_ifs" - if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && - test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - echo="$dir/echo" - break - fi - done - IFS="$lt_save_ifs" - - if test "X$echo" = Xecho; then - # We didn't find a better echo, so look for alternatives. - if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # This shell has a builtin print -r that does the trick. - echo='print -r' - elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && - test "X$CONFIG_SHELL" != X/bin/ksh; then - # If we have ksh, try running configure again with it. - ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} - export ORIGINAL_CONFIG_SHELL - CONFIG_SHELL=/bin/ksh - export CONFIG_SHELL - exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} - else - # Try using printf. - echo='printf %s\n' - if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # Cool, printf works - : - elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL - export CONFIG_SHELL - SHELL="$CONFIG_SHELL" - export SHELL - echo="$CONFIG_SHELL [$]0 --fallback-echo" - elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - echo="$CONFIG_SHELL [$]0 --fallback-echo" - else - # maybe with a smaller string... - prev=: - - for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do - if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null - then - break - fi - prev="$cmd" - done - - if test "$prev" != 'sed 50q "[$]0"'; then - echo_test_string=`eval $prev` - export echo_test_string - exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} - else - # Oops. We lost completely, so just stick with echo. - echo=echo - fi - fi - fi - fi -fi -fi - -# Copy echo and quote the copy suitably for passing to libtool from -# the Makefile, instead of quoting the original, which is used later. -ECHO=$echo -if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then - ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" -fi - -AC_SUBST(ECHO) -])])# _LT_AC_PROG_ECHO_BACKSLASH - - -# _LT_AC_LOCK -# ----------- -AC_DEFUN([_LT_AC_LOCK], -[AC_ARG_ENABLE([libtool-lock], - [AC_HELP_STRING([--disable-libtool-lock], - [avoid locking (might break parallel builds)])]) -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes - -# Some flags need to be propagated to the compiler or linker for good -# libtool support. -case $host in -ia64-*-hpux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.$ac_objext` in - *ELF-32*) - HPUX_IA64_MODE="32" - ;; - *ELF-64*) - HPUX_IA64_MODE="64" - ;; - esac - fi - rm -rf conftest* - ;; -*-*-irix6*) - # Find out which ABI we are using. - echo '[#]line __oline__ "configure"' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - if test "$lt_cv_prog_gnu_ld" = yes; then - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -melf32bsmip" - ;; - *N32*) - LD="${LD-ld} -melf32bmipn32" - ;; - *64-bit*) - LD="${LD-ld} -melf64bmip" - ;; - esac - else - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -32" - ;; - *N32*) - LD="${LD-ld} -n32" - ;; - *64-bit*) - LD="${LD-ld} -64" - ;; - esac - fi - fi - rm -rf conftest* - ;; - -x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in - *32-bit*) - case $host in - x86_64-*linux*) - LD="${LD-ld} -m elf_i386" - ;; - ppc64-*linux*|powerpc64-*linux*) - LD="${LD-ld} -m elf32ppclinux" - ;; - s390x-*linux*) - LD="${LD-ld} -m elf_s390" - ;; - sparc64-*linux*) - LD="${LD-ld} -m elf32_sparc" - ;; - esac - ;; - *64-bit*) - case $host in - x86_64-*linux*) - LD="${LD-ld} -m elf_x86_64" - ;; - ppc*-*linux*|powerpc*-*linux*) - LD="${LD-ld} -m elf64ppc" - ;; - s390*-*linux*) - LD="${LD-ld} -m elf64_s390" - ;; - sparc*-*linux*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; - -*-*-sco3.2v5*) - # On SCO OpenServer 5, we need -belf to get full-featured binaries. - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -belf" - AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, - [AC_LANG_PUSH(C) - AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) - AC_LANG_POP]) - if test x"$lt_cv_cc_needs_belf" != x"yes"; then - # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf - CFLAGS="$SAVE_CFLAGS" - fi - ;; -sparc*-*solaris*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in - *64-bit*) - case $lt_cv_prog_gnu_ld in - yes*) LD="${LD-ld} -m elf64_sparc" ;; - *) LD="${LD-ld} -64" ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; - -AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], -[*-*-cygwin* | *-*-mingw* | *-*-pw32*) - AC_CHECK_TOOL(DLLTOOL, dlltool, false) - AC_CHECK_TOOL(AS, as, false) - AC_CHECK_TOOL(OBJDUMP, objdump, false) - ;; - ]) -esac - -need_locks="$enable_libtool_lock" - -])# _LT_AC_LOCK - - -# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) -# ---------------------------------------------------------------- -# Check whether the given compiler option works -AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], -[AC_REQUIRE([LT_AC_PROG_SED]) -AC_CACHE_CHECK([$1], [$2], - [$2=no - ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$3" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - $2=yes - fi - fi - $rm conftest* -]) - -if test x"[$]$2" = xyes; then - ifelse([$5], , :, [$5]) -else - ifelse([$6], , :, [$6]) -fi -])# AC_LIBTOOL_COMPILER_OPTION - - -# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [ACTION-SUCCESS], [ACTION-FAILURE]) -# ------------------------------------------------------------ -# Check whether the given compiler option works -AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], -[AC_CACHE_CHECK([$1], [$2], - [$2=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $3" - printf "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The linker can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&AS_MESSAGE_LOG_FD - $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - $2=yes - fi - else - $2=yes - fi - fi - $rm conftest* - LDFLAGS="$save_LDFLAGS" -]) - -if test x"[$]$2" = xyes; then - ifelse([$4], , :, [$4]) -else - ifelse([$5], , :, [$5]) -fi -])# AC_LIBTOOL_LINKER_OPTION - - -# AC_LIBTOOL_SYS_MAX_CMD_LEN -# -------------------------- -AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], -[# find the maximum length of command line arguments -AC_MSG_CHECKING([the maximum length of command line arguments]) -AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl - i=0 - teststring="ABCD" - - case $build_os in - msdosdjgpp*) - # On DJGPP, this test can blow up pretty badly due to problems in libc - # (any single argument exceeding 2000 bytes causes a buffer overrun - # during glob expansion). Even if it were fixed, the result of this - # check would be larger than it should be. - lt_cv_sys_max_cmd_len=12288; # 12K is about right - ;; - - gnu*) - # Under GNU Hurd, this test is not required because there is - # no limit to the length of command line arguments. - # Libtool will interpret -1 as no limit whatsoever - lt_cv_sys_max_cmd_len=-1; - ;; - - cygwin* | mingw*) - # On Win9x/ME, this test blows up -- it succeeds, but takes - # about 5 minutes as the teststring grows exponentially. - # Worse, since 9x/ME are not pre-emptively multitasking, - # you end up with a "frozen" computer, even though with patience - # the test eventually succeeds (with a max line length of 256k). - # Instead, let's just punt: use the minimum linelength reported by - # all of the supported platforms: 8192 (on NT/2K/XP). - lt_cv_sys_max_cmd_len=8192; - ;; - - amigaos*) - # On AmigaOS with pdksh, this test takes hours, literally. - # So we just punt and use a minimum line length of 8192. - lt_cv_sys_max_cmd_len=8192; - ;; - - netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) - # This has been around since 386BSD, at least. Likely further. - if test -x /sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` - elif test -x /usr/sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` - else - lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs - fi - # And add a safety zone - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - ;; - - interix*) - # We know the value 262144 and hardcode it with a safety zone (like BSD) - lt_cv_sys_max_cmd_len=196608 - ;; - - osf*) - # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure - # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not - # nice to cause kernel panics so lets avoid the loop below. - # First set a reasonable default. - lt_cv_sys_max_cmd_len=16384 - # - if test -x /sbin/sysconfig; then - case `/sbin/sysconfig -q proc exec_disable_arg_limit` in - *1*) lt_cv_sys_max_cmd_len=-1 ;; - esac - fi - ;; - sco3.2v5*) - lt_cv_sys_max_cmd_len=102400 - ;; - sysv5* | sco5v6* | sysv4.2uw2*) - kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` - if test -n "$kargmax"; then - lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` - else - lt_cv_sys_max_cmd_len=32768 - fi - ;; - *) - # If test is not a shell built-in, we'll probably end up computing a - # maximum length that is only half of the actual maximum length, but - # we can't tell. - SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} - while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \ - = "XX$teststring") >/dev/null 2>&1 && - new_result=`expr "X$teststring" : ".*" 2>&1` && - lt_cv_sys_max_cmd_len=$new_result && - test $i != 17 # 1/2 MB should be enough - do - i=`expr $i + 1` - teststring=$teststring$teststring - done - teststring= - # Add a significant safety factor because C++ compilers can tack on massive - # amounts of additional arguments before passing them to the linker. - # It appears as though 1/2 is a usable value. - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` - ;; - esac -]) -if test -n $lt_cv_sys_max_cmd_len ; then - AC_MSG_RESULT($lt_cv_sys_max_cmd_len) -else - AC_MSG_RESULT(none) -fi -])# AC_LIBTOOL_SYS_MAX_CMD_LEN - - -# _LT_AC_CHECK_DLFCN -# ------------------ -AC_DEFUN([_LT_AC_CHECK_DLFCN], -[AC_CHECK_HEADERS(dlfcn.h)dnl -])# _LT_AC_CHECK_DLFCN - - -# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, -# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) -# --------------------------------------------------------------------- -AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF], -[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl -if test "$cross_compiling" = yes; then : - [$4] -else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<EOF -[#line __oline__ "configure" -#include "confdefs.h" - -#if HAVE_DLFCN_H -#include <dlfcn.h> -#endif - -#include <stdio.h> - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -#ifdef __cplusplus -extern "C" void exit (int); -#endif - -void fnord() { int i=42;} -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - /* dlclose (self); */ - } - else - puts (dlerror ()); - - exit (status); -}] -EOF - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) $1 ;; - x$lt_dlneed_uscore) $2 ;; - x$lt_dlunknown|x*) $3 ;; - esac - else : - # compilation failed - $3 - fi -fi -rm -fr conftest* -])# _LT_AC_TRY_DLOPEN_SELF - - -# AC_LIBTOOL_DLOPEN_SELF -# ---------------------- -AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], -[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl -if test "x$enable_dlopen" != xyes; then - enable_dlopen=unknown - enable_dlopen_self=unknown - enable_dlopen_self_static=unknown -else - lt_cv_dlopen=no - lt_cv_dlopen_libs= - - case $host_os in - beos*) - lt_cv_dlopen="load_add_on" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ;; - - mingw* | pw32*) - lt_cv_dlopen="LoadLibrary" - lt_cv_dlopen_libs= - ;; - - cygwin*) - lt_cv_dlopen="dlopen" - lt_cv_dlopen_libs= - ;; - - darwin*) - # if libdl is installed we need to link against it - AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ - lt_cv_dlopen="dyld" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ]) - ;; - - *) - AC_CHECK_FUNC([shl_load], - [lt_cv_dlopen="shl_load"], - [AC_CHECK_LIB([dld], [shl_load], - [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"], - [AC_CHECK_FUNC([dlopen], - [lt_cv_dlopen="dlopen"], - [AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], - [AC_CHECK_LIB([svld], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], - [AC_CHECK_LIB([dld], [dld_link], - [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"]) - ]) - ]) - ]) - ]) - ]) - ;; - esac - - if test "x$lt_cv_dlopen" != xno; then - enable_dlopen=yes - else - enable_dlopen=no - fi - - case $lt_cv_dlopen in - dlopen) - save_CPPFLAGS="$CPPFLAGS" - test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" - - save_LDFLAGS="$LDFLAGS" - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - - save_LIBS="$LIBS" - LIBS="$lt_cv_dlopen_libs $LIBS" - - AC_CACHE_CHECK([whether a program can dlopen itself], - lt_cv_dlopen_self, [dnl - _LT_AC_TRY_DLOPEN_SELF( - lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, - lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) - ]) - - if test "x$lt_cv_dlopen_self" = xyes; then - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" - AC_CACHE_CHECK([whether a statically linked program can dlopen itself], - lt_cv_dlopen_self_static, [dnl - _LT_AC_TRY_DLOPEN_SELF( - lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, - lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) - ]) - fi - - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - LIBS="$save_LIBS" - ;; - esac - - case $lt_cv_dlopen_self in - yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; - *) enable_dlopen_self=unknown ;; - esac - - case $lt_cv_dlopen_self_static in - yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; - *) enable_dlopen_self_static=unknown ;; - esac -fi -])# AC_LIBTOOL_DLOPEN_SELF - - -# AC_LIBTOOL_PROG_CC_C_O([TAGNAME]) -# --------------------------------- -# Check to see if options -c and -o are simultaneously supported by compiler -AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O], -[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl -AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], - [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)], - [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no - $rm -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes - fi - fi - chmod u+w . 2>&AS_MESSAGE_LOG_FD - $rm conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files - $rm out/* && rmdir out - cd .. - rmdir conftest - $rm conftest* -]) -])# AC_LIBTOOL_PROG_CC_C_O - - -# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME]) -# ----------------------------------------- -# Check to see if we can do hard links to lock some files if needed -AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], -[AC_REQUIRE([_LT_AC_LOCK])dnl - -hard_links="nottested" -if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - AC_MSG_CHECKING([if we can lock with hard links]) - hard_links=yes - $rm conftest* - ln conftest.a conftest.b 2>/dev/null && hard_links=no - touch conftest.a - ln conftest.a conftest.b 2>&5 || hard_links=no - ln conftest.a conftest.b 2>/dev/null && hard_links=no - AC_MSG_RESULT([$hard_links]) - if test "$hard_links" = no; then - AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) - need_locks=warn - fi -else - need_locks=no -fi -])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS - - -# AC_LIBTOOL_OBJDIR -# ----------------- -AC_DEFUN([AC_LIBTOOL_OBJDIR], -[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], -[rm -f .libs 2>/dev/null -mkdir .libs 2>/dev/null -if test -d .libs; then - lt_cv_objdir=.libs -else - # MS-DOS does not allow filenames that begin with a dot. - lt_cv_objdir=_libs -fi -rmdir .libs 2>/dev/null]) -objdir=$lt_cv_objdir -])# AC_LIBTOOL_OBJDIR - - -# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME]) -# ---------------------------------------------- -# Check hardcoding attributes. -AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], -[AC_MSG_CHECKING([how to hardcode library paths into programs]) -_LT_AC_TAGVAR(hardcode_action, $1)= -if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \ - test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \ - test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then - - # We can hardcode non-existant directories. - if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no && - test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then - # Linking always hardcodes the temporary library directory. - _LT_AC_TAGVAR(hardcode_action, $1)=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - _LT_AC_TAGVAR(hardcode_action, $1)=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - _LT_AC_TAGVAR(hardcode_action, $1)=unsupported -fi -AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)]) - -if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then - # Fast installation is not supported - enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then - # Fast installation is not necessary - enable_fast_install=needless -fi -])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH - - -# AC_LIBTOOL_SYS_LIB_STRIP -# ------------------------ -AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP], -[striplib= -old_striplib= -AC_MSG_CHECKING([whether stripping libraries is possible]) -if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" - test -z "$striplib" && striplib="$STRIP --strip-unneeded" - AC_MSG_RESULT([yes]) -else -# FIXME - insert some real tests, host_os isn't really good enough - case $host_os in - darwin*) - if test -n "$STRIP" ; then - striplib="$STRIP -x" - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) -fi - ;; - *) - AC_MSG_RESULT([no]) - ;; - esac -fi -])# AC_LIBTOOL_SYS_LIB_STRIP - - -# AC_LIBTOOL_SYS_DYNAMIC_LINKER -# ----------------------------- -# PORTME Fill in your ld.so characteristics -AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER], -[AC_MSG_CHECKING([dynamic linker characteristics]) -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext_cmds=".so" -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -shlibpath_overrides_runpath=unknown -version_type=none -dynamic_linker="$host_os ld.so" -sys_lib_dlse... [truncated message content] |
From: <jn...@us...> - 2007-05-10 22:57:11
|
Revision: 24 http://opencalea.svn.sourceforge.net/opencalea/?rev=24&view=rev Author: jnorell Date: 2007-05-10 15:57:13 -0700 (Thu, 10 May 2007) Log Message: ----------- commit of autoconf changes Modified Paths: -------------- src/Makefile.in Modified: src/Makefile.in =================================================================== --- src/Makefile.in 2007-05-10 22:52:39 UTC (rev 23) +++ src/Makefile.in 2007-05-10 22:57:13 UTC (rev 24) @@ -45,27 +45,17 @@ am__installdirs = "$(DESTDIR)$(bindir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) -am_collector_OBJECTS = collector-collector.$(OBJEXT) \ - collector-process_registry.$(OBJEXT) \ - collector-log_debug.$(OBJEXT) collector-util.$(OBJEXT) -collector_OBJECTS = $(am_collector_OBJECTS) -am__DEPENDENCIES_1 = -collector_DEPENDENCIES = $(am__DEPENDENCIES_1) -collector_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(collector_CFLAGS) \ - $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -am_controller_OBJECTS = controller-controller.$(OBJEXT) \ - controller-process_registry.$(OBJEXT) \ - controller-log_debug.$(OBJEXT) controller-util.$(OBJEXT) -controller_OBJECTS = $(am_controller_OBJECTS) -controller_DEPENDENCIES = $(am__DEPENDENCIES_1) -controller_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(controller_CFLAGS) \ - $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +collector_SOURCES = collector.c +collector_OBJECTS = collector.$(OBJEXT) +collector_LDADD = $(LDADD) +controller_SOURCES = controller.c +controller_OBJECTS = controller.$(OBJEXT) +controller_LDADD = $(LDADD) am_df_collector_OBJECTS = df_collector-df_collector.$(OBJEXT) \ df_collector-log_debug.$(OBJEXT) df_collector-calea.$(OBJEXT) \ df_collector-util.$(OBJEXT) df_collector_OBJECTS = $(am_df_collector_OBJECTS) +am__DEPENDENCIES_1 = df_collector_DEPENDENCIES = $(am__DEPENDENCIES_1) df_collector_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(df_collector_CFLAGS) \ @@ -99,12 +89,10 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ -SOURCES = $(collector_SOURCES) $(controller_SOURCES) \ - $(df_collector_SOURCES) $(lea_collector_SOURCES) \ - $(tap_SOURCES) -DIST_SOURCES = $(collector_SOURCES) $(controller_SOURCES) \ - $(df_collector_SOURCES) $(lea_collector_SOURCES) \ - $(tap_SOURCES) +SOURCES = collector.c controller.c $(df_collector_SOURCES) \ + $(lea_collector_SOURCES) $(tap_SOURCES) +DIST_SOURCES = collector.c controller.c $(df_collector_SOURCES) \ + $(lea_collector_SOURCES) $(tap_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -228,12 +216,6 @@ lea_collector_SOURCES = lea_collector.c lea_collector.h common.h log_debug.c log_debug.h util.h calea.c util.c lea_collector_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS) lea_collector_LDADD = -lpcap $(GLIB_LIBS) -controller_SOURCES = controller.c common.h process_registry.c process_registry.h log_debug.c log_debug.h util.h util.c -controller_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS) -controller_LDADD = -lpthread $(GLIB_LIBS) -collector_SOURCES = collector.c common.h process_registry.c process_registry.h log_debug.c log_debug.h util.h util.c -collector_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS) -collector_LDADD = -lpthread $(GLIB_LIBS) all: all-am .SUFFIXES: @@ -297,10 +279,10 @@ done collector$(EXEEXT): $(collector_OBJECTS) $(collector_DEPENDENCIES) @rm -f collector$(EXEEXT) - $(collector_LINK) $(collector_OBJECTS) $(collector_LDADD) $(LIBS) + $(LINK) $(collector_OBJECTS) $(collector_LDADD) $(LIBS) controller$(EXEEXT): $(controller_OBJECTS) $(controller_DEPENDENCIES) @rm -f controller$(EXEEXT) - $(controller_LINK) $(controller_OBJECTS) $(controller_LDADD) $(LIBS) + $(LINK) $(controller_OBJECTS) $(controller_LDADD) $(LIBS) df_collector$(EXEEXT): $(df_collector_OBJECTS) $(df_collector_DEPENDENCIES) @rm -f df_collector$(EXEEXT) $(df_collector_LINK) $(df_collector_OBJECTS) $(df_collector_LDADD) $(LIBS) @@ -317,14 +299,8 @@ distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/collector-collector.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/collector-log_debug.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/collector-process_registry.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/collector-util.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/controller-controller.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/controller-log_debug.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/controller-process_registry.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/controller-util.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/collector.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/controller.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/df_collector-calea.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/df_collector-df_collector.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/df_collector-log_debug.Po@am__quote@ @@ -362,118 +338,6 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< -collector-collector.o: collector.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(collector_CFLAGS) $(CFLAGS) -MT collector-collector.o -MD -MP -MF $(DEPDIR)/collector-collector.Tpo -c -o collector-collector.o `test -f 'collector.c' || echo '$(srcdir)/'`collector.c -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/collector-collector.Tpo $(DEPDIR)/collector-collector.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='collector.c' object='collector-collector.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(collector_CFLAGS) $(CFLAGS) -c -o collector-collector.o `test -f 'collector.c' || echo '$(srcdir)/'`collector.c - -collector-collector.obj: collector.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(collector_CFLAGS) $(CFLAGS) -MT collector-collector.obj -MD -MP -MF $(DEPDIR)/collector-collector.Tpo -c -o collector-collector.obj `if test -f 'collector.c'; then $(CYGPATH_W) 'collector.c'; else $(CYGPATH_W) '$(srcdir)/collector.c'; fi` -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/collector-collector.Tpo $(DEPDIR)/collector-collector.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='collector.c' object='collector-collector.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(collector_CFLAGS) $(CFLAGS) -c -o collector-collector.obj `if test -f 'collector.c'; then $(CYGPATH_W) 'collector.c'; else $(CYGPATH_W) '$(srcdir)/collector.c'; fi` - -collector-process_registry.o: process_registry.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(collector_CFLAGS) $(CFLAGS) -MT collector-process_registry.o -MD -MP -MF $(DEPDIR)/collector-process_registry.Tpo -c -o collector-process_registry.o `test -f 'process_registry.c' || echo '$(srcdir)/'`process_registry.c -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/collector-process_registry.Tpo $(DEPDIR)/collector-process_registry.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='process_registry.c' object='collector-process_registry.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(collector_CFLAGS) $(CFLAGS) -c -o collector-process_registry.o `test -f 'process_registry.c' || echo '$(srcdir)/'`process_registry.c - -collector-process_registry.obj: process_registry.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(collector_CFLAGS) $(CFLAGS) -MT collector-process_registry.obj -MD -MP -MF $(DEPDIR)/collector-process_registry.Tpo -c -o collector-process_registry.obj `if test -f 'process_registry.c'; then $(CYGPATH_W) 'process_registry.c'; else $(CYGPATH_W) '$(srcdir)/process_registry.c'; fi` -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/collector-process_registry.Tpo $(DEPDIR)/collector-process_registry.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='process_registry.c' object='collector-process_registry.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(collector_CFLAGS) $(CFLAGS) -c -o collector-process_registry.obj `if test -f 'process_registry.c'; then $(CYGPATH_W) 'process_registry.c'; else $(CYGPATH_W) '$(srcdir)/process_registry.c'; fi` - -collector-log_debug.o: log_debug.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(collector_CFLAGS) $(CFLAGS) -MT collector-log_debug.o -MD -MP -MF $(DEPDIR)/collector-log_debug.Tpo -c -o collector-log_debug.o `test -f 'log_debug.c' || echo '$(srcdir)/'`log_debug.c -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/collector-log_debug.Tpo $(DEPDIR)/collector-log_debug.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='log_debug.c' object='collector-log_debug.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(collector_CFLAGS) $(CFLAGS) -c -o collector-log_debug.o `test -f 'log_debug.c' || echo '$(srcdir)/'`log_debug.c - -collector-log_debug.obj: log_debug.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(collector_CFLAGS) $(CFLAGS) -MT collector-log_debug.obj -MD -MP -MF $(DEPDIR)/collector-log_debug.Tpo -c -o collector-log_debug.obj `if test -f 'log_debug.c'; then $(CYGPATH_W) 'log_debug.c'; else $(CYGPATH_W) '$(srcdir)/log_debug.c'; fi` -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/collector-log_debug.Tpo $(DEPDIR)/collector-log_debug.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='log_debug.c' object='collector-log_debug.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(collector_CFLAGS) $(CFLAGS) -c -o collector-log_debug.obj `if test -f 'log_debug.c'; then $(CYGPATH_W) 'log_debug.c'; else $(CYGPATH_W) '$(srcdir)/log_debug.c'; fi` - -collector-util.o: util.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(collector_CFLAGS) $(CFLAGS) -MT collector-util.o -MD -MP -MF $(DEPDIR)/collector-util.Tpo -c -o collector-util.o `test -f 'util.c' || echo '$(srcdir)/'`util.c -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/collector-util.Tpo $(DEPDIR)/collector-util.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='util.c' object='collector-util.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(collector_CFLAGS) $(CFLAGS) -c -o collector-util.o `test -f 'util.c' || echo '$(srcdir)/'`util.c - -collector-util.obj: util.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(collector_CFLAGS) $(CFLAGS) -MT collector-util.obj -MD -MP -MF $(DEPDIR)/collector-util.Tpo -c -o collector-util.obj `if test -f 'util.c'; then $(CYGPATH_W) 'util.c'; else $(CYGPATH_W) '$(srcdir)/util.c'; fi` -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/collector-util.Tpo $(DEPDIR)/collector-util.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='util.c' object='collector-util.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(collector_CFLAGS) $(CFLAGS) -c -o collector-util.obj `if test -f 'util.c'; then $(CYGPATH_W) 'util.c'; else $(CYGPATH_W) '$(srcdir)/util.c'; fi` - -controller-controller.o: controller.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(controller_CFLAGS) $(CFLAGS) -MT controller-controller.o -MD -MP -MF $(DEPDIR)/controller-controller.Tpo -c -o controller-controller.o `test -f 'controller.c' || echo '$(srcdir)/'`controller.c -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/controller-controller.Tpo $(DEPDIR)/controller-controller.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='controller.c' object='controller-controller.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(controller_CFLAGS) $(CFLAGS) -c -o controller-controller.o `test -f 'controller.c' || echo '$(srcdir)/'`controller.c - -controller-controller.obj: controller.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(controller_CFLAGS) $(CFLAGS) -MT controller-controller.obj -MD -MP -MF $(DEPDIR)/controller-controller.Tpo -c -o controller-controller.obj `if test -f 'controller.c'; then $(CYGPATH_W) 'controller.c'; else $(CYGPATH_W) '$(srcdir)/controller.c'; fi` -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/controller-controller.Tpo $(DEPDIR)/controller-controller.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='controller.c' object='controller-controller.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(controller_CFLAGS) $(CFLAGS) -c -o controller-controller.obj `if test -f 'controller.c'; then $(CYGPATH_W) 'controller.c'; else $(CYGPATH_W) '$(srcdir)/controller.c'; fi` - -controller-process_registry.o: process_registry.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(controller_CFLAGS) $(CFLAGS) -MT controller-process_registry.o -MD -MP -MF $(DEPDIR)/controller-process_registry.Tpo -c -o controller-process_registry.o `test -f 'process_registry.c' || echo '$(srcdir)/'`process_registry.c -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/controller-process_registry.Tpo $(DEPDIR)/controller-process_registry.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='process_registry.c' object='controller-process_registry.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(controller_CFLAGS) $(CFLAGS) -c -o controller-process_registry.o `test -f 'process_registry.c' || echo '$(srcdir)/'`process_registry.c - -controller-process_registry.obj: process_registry.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(controller_CFLAGS) $(CFLAGS) -MT controller-process_registry.obj -MD -MP -MF $(DEPDIR)/controller-process_registry.Tpo -c -o controller-process_registry.obj `if test -f 'process_registry.c'; then $(CYGPATH_W) 'process_registry.c'; else $(CYGPATH_W) '$(srcdir)/process_registry.c'; fi` -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/controller-process_registry.Tpo $(DEPDIR)/controller-process_registry.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='process_registry.c' object='controller-process_registry.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(controller_CFLAGS) $(CFLAGS) -c -o controller-process_registry.obj `if test -f 'process_registry.c'; then $(CYGPATH_W) 'process_registry.c'; else $(CYGPATH_W) '$(srcdir)/process_registry.c'; fi` - -controller-log_debug.o: log_debug.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(controller_CFLAGS) $(CFLAGS) -MT controller-log_debug.o -MD -MP -MF $(DEPDIR)/controller-log_debug.Tpo -c -o controller-log_debug.o `test -f 'log_debug.c' || echo '$(srcdir)/'`log_debug.c -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/controller-log_debug.Tpo $(DEPDIR)/controller-log_debug.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='log_debug.c' object='controller-log_debug.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(controller_CFLAGS) $(CFLAGS) -c -o controller-log_debug.o `test -f 'log_debug.c' || echo '$(srcdir)/'`log_debug.c - -controller-log_debug.obj: log_debug.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(controller_CFLAGS) $(CFLAGS) -MT controller-log_debug.obj -MD -MP -MF $(DEPDIR)/controller-log_debug.Tpo -c -o controller-log_debug.obj `if test -f 'log_debug.c'; then $(CYGPATH_W) 'log_debug.c'; else $(CYGPATH_W) '$(srcdir)/log_debug.c'; fi` -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/controller-log_debug.Tpo $(DEPDIR)/controller-log_debug.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='log_debug.c' object='controller-log_debug.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(controller_CFLAGS) $(CFLAGS) -c -o controller-log_debug.obj `if test -f 'log_debug.c'; then $(CYGPATH_W) 'log_debug.c'; else $(CYGPATH_W) '$(srcdir)/log_debug.c'; fi` - -controller-util.o: util.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(controller_CFLAGS) $(CFLAGS) -MT controller-util.o -MD -MP -MF $(DEPDIR)/controller-util.Tpo -c -o controller-util.o `test -f 'util.c' || echo '$(srcdir)/'`util.c -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/controller-util.Tpo $(DEPDIR)/controller-util.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='util.c' object='controller-util.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(controller_CFLAGS) $(CFLAGS) -c -o controller-util.o `test -f 'util.c' || echo '$(srcdir)/'`util.c - -controller-util.obj: util.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(controller_CFLAGS) $(CFLAGS) -MT controller-util.obj -MD -MP -MF $(DEPDIR)/controller-util.Tpo -c -o controller-util.obj `if test -f 'util.c'; then $(CYGPATH_W) 'util.c'; else $(CYGPATH_W) '$(srcdir)/util.c'; fi` -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/controller-util.Tpo $(DEPDIR)/controller-util.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='util.c' object='controller-util.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(controller_CFLAGS) $(CFLAGS) -c -o controller-util.obj `if test -f 'util.c'; then $(CYGPATH_W) 'util.c'; else $(CYGPATH_W) '$(srcdir)/util.c'; fi` - df_collector-df_collector.o: df_collector.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(df_collector_CFLAGS) $(CFLAGS) -MT df_collector-df_collector.o -MD -MP -MF $(DEPDIR)/df_collector-df_collector.Tpo -c -o df_collector-df_collector.o `test -f 'df_collector.c' || echo '$(srcdir)/'`df_collector.c @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/df_collector-df_collector.Tpo $(DEPDIR)/df_collector-df_collector.Po This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jn...@us...> - 2007-05-10 22:52:54
|
Revision: 23 http://opencalea.svn.sourceforge.net/opencalea/?rev=23&view=rev Author: jnorell Date: 2007-05-10 15:52:39 -0700 (Thu, 10 May 2007) Log Message: ----------- Added full config file parsing to df_collector. DF collector now listens on, and tap sends to, a single df_port for all cmii/cmc content. (We could use that for the route/ctrl message too.) Removed collector and controller, preparing for upcoming controllerd. Need to run autoreconf (keeping that as a separate commit). Modified Paths: -------------- etc/opencalea/opencalea.conf src/Makefile.am src/common.h src/df_collector.c src/lea_collector.c src/tap.c src/tap.h src/util.c src/util.h Removed Paths: ------------- src/collector.c src/controller.c src/process_registry.c src/process_registry.h Modified: etc/opencalea/opencalea.conf =================================================================== --- etc/opencalea/opencalea.conf 2007-05-10 16:13:21 UTC (rev 22) +++ etc/opencalea/opencalea.conf 2007-05-10 22:52:39 UTC (rev 23) @@ -25,38 +25,35 @@ Debug_Level = 4 Debug_Destination = /var/log/opencalea/opencalea.debug -pid_directory = /var/run/opencalea -state_directory = /var/run/opencalea +PID_Dir = /var/run/opencalea +State_Dir = /var/run/opencalea [TAP] Program_Name = tap -Interface = eth0,eth1,eth2 +Interface = eth0 Debug_Level = 4 Debug_Destination = /var/log/opencalea/tap.debug -ContentID = Test1234 - [TAP_CONTROLLER] Program_Name = tap_controller - -pid_file = tap_controller.pid +PID_File = tap_controller.pid #Control_Socket = /var/run/opencalea/ +Tap_Exe = /usr/local/bin/tap [DF_COLLECTOR] -Program_Name = df_collector -CmII_Path = /var/log/opencalea/capture -CmC_Path = /var/log/opencalea/capture -Log_Path = /var/log/opencalea/log +Program_Name = df_collector +CmII_Path = /var/lib/opencalea/storage +CmC_Path = /var/lib/opencalea/storage +Log_Path = /var/log/opencalea + [LEA_COLLECTOR] Program_Name = lea_collector +CF_Data_Path = /var/lib/opencalea/cf_data +Log_File = /var/log/opencalea/lea_collector.log +Debug_Destination = /var/log/opencalea/lea_collector.debug -capturefile_directory = /var/lib/opencalea - -logfile = /var/log/opencalea/lea_collector.log -errorlog = /var/log/opencalea/lea_collector.err - Modified: src/Makefile.am =================================================================== --- src/Makefile.am 2007-05-10 16:13:21 UTC (rev 22) +++ src/Makefile.am 2007-05-10 22:52:39 UTC (rev 23) @@ -14,10 +14,3 @@ lea_collector_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS) lea_collector_LDADD = -lpcap $(GLIB_LIBS) -controller_SOURCES = controller.c common.h process_registry.c process_registry.h log_debug.c log_debug.h util.h util.c -controller_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS) -controller_LDADD = -lpthread $(GLIB_LIBS) - -collector_SOURCES = collector.c common.h process_registry.c process_registry.h log_debug.c log_debug.h util.h util.c -collector_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS) -collector_LDADD = -lpthread $(GLIB_LIBS) Deleted: src/collector.c =================================================================== --- src/collector.c 2007-05-10 16:13:21 UTC (rev 22) +++ src/collector.c 2007-05-10 22:52:39 UTC (rev 23) @@ -1,373 +0,0 @@ -/* - * Copyright (c) 2007, Merit Network, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Merit Network, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY MERIT NETWORK, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL MERIT NETWORK, INC. BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "common.h" -#include "process_registry.h" - -#include <signal.h> -#include <sys/wait.h> -#include <pthread.h> -#include <glob.h> - -char *prog_name = "collector"; -int syslog_facility = DEF_SYSLOG_FACILITY; - -extern char **environ; - -int get_command ( char* msgbuf ) { - int msg_id; - sscanf ( msgbuf, "%d", &msg_id ); - return msg_id ; -} - -int get_target_pid ( char* msgbuf ) { - int msg_id, target_pid, batch_id; - sscanf ( msgbuf, "%d %d %d", &msg_id, &batch_id, &target_pid ); - return target_pid; -} - -int get_batch_id ( char* msgbuf ) { - int msg_id, target_pid, batch_id; - sscanf ( msgbuf, "%d %d %d", &msg_id, &batch_id, &target_pid ); - return batch_id; -} - -void* reply ( void* args, uint reply_code ) { - int *handler_socket; - char* buf; - - if (! ( buf = (char*) malloc ( 128 ) ) ) { - perror("malloc"); - exit ( -1 ); - } - memset ( buf, '\0', 128 ); - snprintf ( buf, 128, "%u", reply_code ); - printf( "about to send: %s\n", buf); - - handler_socket = ( int* ) args; - if ( (send( *handler_socket, buf, strlen( buf ), 0 )) == -1 ) { - perror("send"); - exit (-1); - } - - free ( buf ); - return ( NULL ); -} - -void* controller_thread ( void* args ) { - int recv_len; - char *msg_buf; - int *handler_socket; - int msg_id = 0; - int pid = 0; - int target_pid = 0; - - handler_socket = ( int* ) args; - char* return_buf; - int send_len = 0; - if (! ( return_buf = (char*) malloc ( MAX_MSGSIZE ) ) ) { - perror("malloc"); - exit ( -1 ); - } - if (! ( msg_buf = (char*) malloc ( MAX_MSGSIZE ) ) ) { - perror("malloc"); - exit ( -1 ); - } - - while ( 1 ) { - - memset ( msg_buf, '\0', MAX_MSGSIZE ); - memset ( return_buf, '\0', MAX_MSGSIZE ); - - if ( (recv_len = recv ( *handler_socket, msg_buf, MAX_MSGSIZE - 1, 0 )) == -1 ) - if ( errno != EAGAIN ) { - perror("recv"); - exit (-1); - } - - if ( recv_len > 0 ) { - - msg_id = get_command ( msg_buf ); - switch ( msg_id ) { - case TAP_START: - printf ( "start...\n" ); - char *f; - - /* send an ACK for the start command */ - reply ( handler_socket, ACK ); - - /* extract the batch-id */ - int batch_id = 0; - batch_id = get_batch_id ( msg_buf ); - - /* extract the filter from the start command */ - char *filter; - int len = 0; - printf ( "the msg is: %s\n", msg_buf ); - if ( (f = strstr ( msg_buf, " \"" )) == NULL ) { - printf ( "syntax error: filter not found\n" ); - break; - } - if (! ( filter = (char*) malloc ( MAX_MSGSIZE ) ) ) { - perror("malloc"); - exit ( -1 ); - } - memset ( filter, '\0', MAX_MSGSIZE ); - memcpy ( filter, f+2, MAX_MSGSIZE - (f+2 - msg_buf) ); - - len = strlen ( filter ); - filter[len-2] = '\0'; - printf ( "the filter is: %s\n", filter ); - - /* ignore signals temporarily before we fork - we re-enable them on the child process only */ - - signal ( SIGCHLD, SIG_IGN ); - signal ( SIGUSR1, SIG_IGN ); - - pid = fork( ); - - if ( pid == 0 ) { - - /* this is the child process re-enable signals */ - signal ( SIGUSR1, SIG_DFL ); - - /* get the arguments with which to run the tap */ - char* argv[32]; - char item[64]; - char filter_item[1024]; - int filter_start = 0 ; - pid = getpid ( ); - argv[0] = strdup ( "tap" ); - int n = 0; - char* iter = filter; - while ( iter < filter + strlen ( filter ) ) { - n++; - sscanf ( iter, "%s", item ); - if ( strncmp ( item , "\"", 1 ) == 0 ) { - if ( filter_start == 0 ) { - n--; - filter_start = 1; - } else { - /* end of filter */ - printf ( "filter_item: %s\n", filter_item ); - argv[n] = strdup ( filter_item ); - memset ( filter_item , '\0', 1024 ); - } - } else { - if ( filter_start == 0 ) { - argv[n] = strdup ( item ); - } else { - n--; - strcat ( filter_item, " " ); - strcat ( filter_item, item ); - } - } - iter = iter + strlen ( item ) + 1; - } - argv[n+1] = NULL; - free ( filter ); - - /* run the tap program with the correct args */ - printf ( "attempting to run tap...\n" ); - execv ( TAP, argv ); - - exit( 0 ); - - } else { - /* if this is the parent process we register - the child - attempt to validate whether the process - actually started correctly first - */ - int retval = 0; - sleep ( 1 ); - retval = kill ( pid, 0 ); - if ( retval == 0 ) { - /* process exists */ - char cmd[1024]; - sprintf ( cmd, "%s %s", TAP, filter ); - free ( filter ); - pid_registry_add ( batch_id, pid, cmd ); - syslog ( LOG_ALERT, - "starting monitoring session with pid: %d and filter: %s", pid, filter ); - } else { - syslog ( LOG_ALERT, - "tap process did not start correctly...\n"); - } - } - break; - case TAP_STOP: - printf ( "stop...\n" ); - - /* send an ACK for the stop command */ - reply ( handler_socket, ACK ); - - /* get batch_id */ - batch_id = get_batch_id ( msg_buf ); - - if ( batch_id == 0 ) { - /* this is a stop command */ - /* extract the pid which we want to stop */ - target_pid = get_target_pid ( msg_buf ); - if ( pid_validate ( target_pid ) == 0 ) { - /* pid was not in our process registry */ - break; - } - int retval = 0; - - /* send kill signal to the tap pid and make - sure it actually died */ - - if ( target_pid != 0 ) { - syslog ( LOG_ALERT, - "stoping monitoring session %d", target_pid ); - retval = kill ( target_pid, SIGUSR1 ); - if ( retval == 0 ) { - /* the kill worked */ - pid_registry_del ( target_pid ); - } else { - /* unable to kill the process */ - } - } else { - /* killing with pid zero will kill all processes - in the same process group so dont do it */ - } - - } else { - /* batch stop: we lookup all pid for this batch id - and stop them all */ - int pid_list[128]; - int i = 0; - int retval = 0; - printf ( "looking up pids...\n"); - pid_batch_id_lookup ( batch_id, (int*) &pid_list ); - for ( i = 0; i <= 128; i++ ) { - printf ( "killing pids... %d\n", pid_list[i]); - syslog ( LOG_ALERT, - "stoping monitoring session %d", target_pid ); - if ( pid_list[i] != 0 ) { - retval = kill ( pid_list[i], SIGUSR1 ); - if ( retval == 0 ) { - /* the kill worked */ - pid_registry_del ( pid_list[i] ); - } else { - /* unable to kill the process */ - } - } - } - - } - break; - case SHOW_PROCESS_REGISTRY: - printf ( "show...\n" ); - memset ( return_buf, '\0', MAX_MSGSIZE ); - pid_registry_show ( return_buf ); - send_len = send ( *handler_socket, return_buf, - strlen ( return_buf ), 0 ); - break; - case CLOSE_SESSION: - printf ( "close...\n" ); - reply ( handler_socket, QUIT ); - close ( *handler_socket ); - pthread_exit( NULL ); - exit(-1); - break; - case CONNECT: - printf ( "connect...\n" ); - memset ( return_buf, '\0', MAX_MSGSIZE ); - reply ( handler_socket, ACK ); - break; - case PING: - printf ( "ping...\n" ); - reply ( handler_socket, ACK ); - break; - case NOP: - printf ( "nop ...\n" ); - reply ( handler_socket, ACK ); - break; - default: - printf ( "command code not valid\n" ); - reply ( handler_socket, ACK ); - break; - } - } - - } - free ( msg_buf ); - free ( return_buf ); - return ( NULL ); -} - - -int main ( void ) { - - int s; - int handler_socket;; - struct sockaddr_in myaddr; - socklen_t myaddrlen; - int retval = 0; - int errno; - - printf ( "Starting server...\n" ); - - s = socket ( AF_INET, SOCK_STREAM, 0 ); - - if ( s == -1 ) { - printf ( "Error while creating server socket\n" ); - exit ( -1 ); - } - - memset ( (char *) &myaddr, 0, sizeof(myaddr) ); - myaddr.sin_family = AF_INET; - myaddr.sin_port = htons( Collector_PORT ); - myaddr.sin_addr.s_addr = htonl ( INADDR_ANY ); - - myaddrlen = sizeof( struct sockaddr_in ); - retval = bind ( s, (struct sockaddr*) &myaddr, sizeof(myaddr) ); - if ( retval == -1 ) { - perror ( "Error while binding socket" ); - exit ( -1 ); - } - - syslog ( LOG_ALERT, "Starting CALEA Collector...\n" ); - listen ( s, MAX_CONNECTIONS ); - - myaddrlen = sizeof( struct sockaddr_in ); - - while ( 1 ) { - handler_socket = accept( s, (struct sockaddr*) &myaddr, &myaddrlen ); - if ( handler_socket == -1 ) { - printf ( "Error while accepting client connection\n" ); - exit ( -1 ); - } - pthread_t ctrl_thread; - pthread_create ( &ctrl_thread, NULL, controller_thread, &handler_socket ); - } - return 0; -} Modified: src/common.h =================================================================== --- src/common.h 2007-05-10 16:13:21 UTC (rev 22) +++ src/common.h 2007-05-10 22:52:39 UTC (rev 23) @@ -88,34 +88,31 @@ #endif +/* default control port (controllerd) */ #ifndef Controller_PORT #define Controller_PORT 41800 #endif -#ifndef Collector_PORT -#define Collector_PORT 41805 /* deprecated - collector will be gone soon */ +/* default port to send to df_controller */ +#ifndef DF_PORT +#define DF_PORT 41805 #endif -#ifndef CmII_PORT -#define CmII_PORT 41810 +/* default lea_collector CmII port */ +#ifndef CF_CmII_PORT +#define CF_CmII_PORT 41810 #endif -#ifndef CmC_PORT -#define CmC_PORT 41820 +/* default lea_collector CmC port */ +#ifndef CF_CmC_PORT +#define CF_CmC_PORT 41820 #endif +/* tmp df controller port */ #ifndef DF_CONTROL_PORT #define DF_CONTROL_PORT 41816 #endif -#ifndef LEA_COLLECTOR_CmII_PORT -#define LEA_COLLECTOR_CmII_PORT 41817 -#endif - -#ifndef LEA_COLLECTOR_CmC_PORT -#define LEA_COLLECTOR_CmC_PORT 41818 -#endif - #define MAX_CONNECTIONS 10 /* for socket connections, limit the queue of incoming connections */ #define MAX_CONTENT_ID_LENGTH 128 @@ -130,25 +127,8 @@ #define DEF_TAP_USER DEF_USER #define DEF_TAP_GROUP DEF_GROUP -/* temporary */ -#define TAP "./tap" - -/* valid command codes */ -#define TAP_START 1 -#define TAP_STOP 2 -#define SHOW_PROCESS_REGISTRY 3 -#define CLOSE_SESSION 4 -#define CONNECT 5 -#define PING 6 -#define NOP 7 - -/* valid repsonse codes */ -#define ACK 0 -#define NACK 1 -#define QUIT 2 - #define MAX_MSGSIZE 4096 /* max size of control message/response */ -#define MAX_LINE 100 +#define MAX_LINE 512 #define min(a,b) ((a) < (b) ? (a) : (b)) #define max(a,b) ((a) > (b) ? (a) : (b)) Deleted: src/controller.c =================================================================== --- src/controller.c 2007-05-10 16:13:21 UTC (rev 22) +++ src/controller.c 2007-05-10 22:52:39 UTC (rev 23) @@ -1,382 +0,0 @@ -/* - * Copyright (c) 2007, Merit Network, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Merit Network, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY MERIT NETWORK, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL MERIT NETWORK, INC. BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "common.h" - -#include <fcntl.h> - -char *prog_name = "controller"; -int syslog_facility = DEF_SYSLOG_FACILITY; - -#define PROMPT "CALEA-CTRL> " - -int controller_socket = -1; -struct sockaddr_in collector_addr; - -int connected_flag = 0; -int batch_mode = 0; - -void print_help_msg (void) { - printf ( " Valid commands are: \n" ); - printf ( " batch-start <ip-list> <filter>\tStart a new collection process\n" ); - printf ( " batch-stop <ip-list> <batch-id>\tStop a collection process\n" ); - printf ( " connect <ip-addr>\t\tConnect to a collector\n" ); - printf ( " start <filter>\t\t\tStart a new collection process\n" ); - printf ( " status\t\t\t\tShow currently running collection processes\n" ); - printf ( " stop <pid>\t\t\tStop a collection process\n" ); - printf ( " quit\t\t\t\tQuit this session\n" ); - printf ( " help\t\t\t\tThis Message\n" ); - printf ( " \n" ); - printf ( " Examples: \n" ); - printf ( " start \"-n host 1.1.1.1\" \n"); - printf ( " batch-start \"1.1.1.1 2.2.2.2\" \"-x x -y y -z z\"\n"); - printf ( " stop 9999 \n"); -} - -int process_response ( char* recv_buf ) { - int response_code = -1; - - sscanf ( recv_buf, "%d", &response_code ); - return response_code; -} - -int process_user_cmd ( char* user_input, char* msgbuf ) { - - char cmd[64]; - memset ( cmd, '\0', 64 ); - - if ( strlen ( user_input ) >= MAX_MSGSIZE ) { - fprintf ( stderr, "Input too long.\n" ); - exit ( -1 ); - } - if ( strcmp ( user_input, "\n" ) == 0 ) { - return 0; - } - sscanf ( user_input, "%63s", cmd ); - - if ( strcmp ( cmd, "batch-start" ) == 0 ) { - if ( controller_socket > 0 ) { - close ( controller_socket ); - controller_socket = -1; - } - batch_mode = 1; - return 1; - } - if ( strcmp ( cmd, "batch-stop" ) == 0 ) { - if ( controller_socket > 0 ) { - close ( controller_socket ); - controller_socket = -1; - connected_flag = 0; - } - batch_mode = 2; - return 1; - } - if ( strcmp ( cmd, "quit" ) == 0 ) { - exit ( 0 ) ; - } - if ( ( strcmp ( cmd, "exit" ) == 0 ) || ( strcmp ( cmd, "quit" ) == 0 ) ) { - if ( connected_flag ) { - snprintf ( msgbuf, 64, "%d", CLOSE_SESSION ); - return 1; - } else { - printf ("Closing.\n"); - exit ( 0 ); - } - return 0; - } - - if ( strcmp ( cmd, "help" ) == 0 ) { - print_help_msg ( ); - return 0; - } - - if ( (strcmp ( cmd, "connect" ) != 0) && ( !connected_flag ) ) { - printf ("Error: Bad Command. (maybe \"connect\" first?)\n\n"); - print_help_msg ( ); - return 0; - } - - if ( strcmp ( cmd, "connect" ) == 0 ) { - char *collector_ipaddr; - - /* how large do we need to support ipv6 addrs? */ - if (! ( collector_ipaddr = (char*) malloc ( 16 ) ) ) { - perror("malloc"); - exit ( -1 ); - } - memset ( collector_ipaddr, '\0', 16 ); - - sscanf ( user_input, "%63s %15s", cmd, collector_ipaddr ); - - controller_socket = socket ( AF_INET, SOCK_STREAM, 0 ); - if ( controller_socket == -1 ) { - perror ( "Error while creating server socket: socket" ); - exit ( -1 ); - } - if (fcntl ( controller_socket, F_SETFL, O_NONBLOCK ) == -1) { - perror ( "fcntl" ); - exit ( -1 ); - } - - collector_addr.sin_family = AF_INET; - collector_addr.sin_port = htons ( Collector_PORT ) ; - collector_addr.sin_addr.s_addr = inet_addr( collector_ipaddr ); - free ( collector_ipaddr ); - - if (collector_addr.sin_addr.s_addr == INADDR_NONE) { - printf ( "Bad IP Addr\n" ); - return 0; - } - - int i = 0; - printf ( "Connecting." ); - fflush ( stdout ); - for ( i = 0; i < 5 ; i++ ) { - if (connect ( controller_socket, - (struct sockaddr*) &collector_addr, - sizeof(struct sockaddr_in) ) == 0 ) - break; - sleep ( 1 ); - if ( errno == EISCONN ) { - printf ( "Done." ); - break; - } - printf ( "." ); - fflush ( stdout ); - } - printf ( "\n" ); - fcntl ( controller_socket, F_SETFL, 2 ); - - char return_buf[MAX_MSGSIZE]; - snprintf ( msgbuf, MAX_MSGSIZE, "%d", NOP ); - if ( send ( controller_socket, msgbuf, strlen ( msgbuf ), 0 ) != -1 ) { - if ( recv ( controller_socket, return_buf, MAX_MSGSIZE, 0 ) == -1 ) { - if ( errno != EAGAIN ) { - perror("recv"); - exit (-1); - } - } - /* we were able to send on socket and recv ACK so we must be connected */ - if ( batch_mode == 0 ) { - connected_flag = 1; - } - snprintf ( msgbuf, MAX_MSGSIZE, "%d", CONNECT ); - } else { - perror ( "Connect failed" ); - return 0; - } - - return 1; - } - - if ( strcmp ( cmd, "start" ) == 0 ) { - char *filter; - int batch_id = 0; - - if (! ( filter = (char*) malloc ( MAX_MSGSIZE ) ) ) { - perror("malloc"); - exit ( -1 ); - } - memset ( filter, '\0', MAX_MSGSIZE ); - - sscanf ( user_input, " %63s ", cmd ); - strncpy ( filter, &user_input[ strlen ( cmd ) ], MAX_MSGSIZE - strlen ( cmd ) ); - snprintf ( msgbuf, MAX_MSGSIZE, "%d %d %s", TAP_START, batch_id, filter ); - free ( filter ); - return 1; - } - if ( strcmp ( cmd, "stop" ) == 0 ) { - int target_pid = 0; - sscanf ( user_input, "%63s %d", cmd, &target_pid ); - snprintf ( msgbuf, 64, "%d %d %d", TAP_STOP, 0, target_pid ); - return 1; - } - if ( strcmp ( cmd, "status" ) == 0 ) { - snprintf ( msgbuf, 64, "%d", SHOW_PROCESS_REGISTRY ); - return 1; - } - - return -1; -} - -int main ( void ) { - - char* msgbuf; - char* return_buf; - char* user_input; - - printf ( "Starting client...\n" ); - srand (getpid()); - - if (! ( msgbuf = (char*) malloc ( MAX_MSGSIZE ) ) ) { - perror("malloc"); - exit ( -1 ); - } - if (! ( user_input = (char*) malloc ( MAX_MSGSIZE ) ) ) { - perror("malloc"); - exit ( -1 ); - } - if (! ( return_buf = (char*) malloc ( MAX_MSGSIZE ) ) ) { - perror("malloc"); - exit ( -1 ); - } - int send_len = 0; - int recv_len = 0; - int retval = 0; - - /* process user commands till we exit */ - while ( 1 ) { - printf ( "%s ", PROMPT ); - memset ( user_input, '\0', MAX_MSGSIZE ); - memset ( msgbuf, '\0', MAX_MSGSIZE ); - - if ( fgets ( user_input, MAX_MSGSIZE, stdin ) == NULL ) { - perror( "fgets" ); - exit( -1 ); - } - - retval = process_user_cmd ( user_input, msgbuf ); - - if ( batch_mode == 0 ) { - if ( retval == 1) { - if ( (send_len = send ( controller_socket, msgbuf, strlen ( msgbuf ), 0 )) == -1 ) { - perror("send"); - exit (-1); - } - memset ( return_buf, '\0', MAX_MSGSIZE ); - if ( (recv_len = recv ( controller_socket, return_buf, MAX_MSGSIZE, 0 )) == -1 ) - if ( errno != EAGAIN ) { - perror("recv"); - exit (-1); - } - if ( recv_len > 0 ) { - int resp_code; - resp_code = process_response ( return_buf ); - switch ( resp_code ) { - case QUIT: - /* collector ACKed our request to quit */ - break; - case ACK: - /* collector ACKed our request */ - break; - default: - printf ( "%s\n", return_buf ); - break; - } - } - } else { - /* command was not valid */ - if ( retval == -1 ) { - printf ( "%s ", "Invalid command\n" ); - print_help_msg ( ); - } - } - - } else if ( batch_mode >= 1 ) { - - char *batch_cmd; - char *filter = NULL; - char *f; - char *start = NULL; - char *str_end; - char *tok; - int end; - char cmd[64]; - char my_input[MAX_MSGSIZE]; - int batch_id = rand(); - - sscanf ( user_input, "%63s", cmd ); - batch_cmd = user_input + strlen ( cmd ) + 1; - - if ( batch_mode == 1 ) { - /* extract the filter */ - f = strstr ( batch_cmd, " \"" ); - filter = strdup (f); - /* shorten the string to only have the ip address list */ - f[0] = '\0'; - /* get rid of starting and ending quote characters */ - start = batch_cmd + 1; - end = strlen ( batch_cmd ) - 1; - batch_cmd[end] = '\0'; - } else if ( batch_mode == 2 ) { - /* extract the batch_id */ - f = strstr ( batch_cmd, "\" " ); - f = f + 2; - batch_id = atoi ( f ); - f[0] = '\0'; - printf ( "batch_id is: %d\n", batch_id ); - printf ( "ip list is: %s\n", batch_cmd ); - /* get rid of starting and ending quote characters */ - start = batch_cmd + 1; - end = strlen ( batch_cmd ) - 2; - batch_cmd[end] = '\0'; - } - - str_end = start + strlen ( batch_cmd ); - - while (start < str_end) { - tok = strtok ( start, " " ); - printf ("tok: %s\n", tok); - snprintf ( my_input, MAX_MSGSIZE, "connect %s", tok ); - retval = process_user_cmd ( my_input, msgbuf ); - if ( batch_mode == 1 ) { - snprintf ( msgbuf, MAX_MSGSIZE, "%d %d %s", - TAP_START, batch_id, filter ); - } else if ( batch_mode == 2 ) { - snprintf ( msgbuf, MAX_MSGSIZE, "%d %d %d", TAP_STOP, batch_id, 0 ); - } - if ( (send_len = send ( controller_socket, msgbuf, strlen ( msgbuf ), 0 )) == -1 ) { - perror("send"); - exit (-1); - } - snprintf ( msgbuf, 64, "%d", CLOSE_SESSION ); - if ( (send_len = send ( controller_socket, msgbuf, strlen ( msgbuf ), 0 )) == -1 ) { - perror("send"); - exit (-1); - } - - start = start + strlen ( tok ) + 1; - memset ( msgbuf, '\0', MAX_MSGSIZE); - } - batch_mode = 0; - connected_flag = 0; - if ( filter ) - free ( filter ); - } - } - - free ( return_buf ); - free ( user_input ); - free ( msgbuf ); - - close( controller_socket ); - controller_socket = -1; - - return 0; -} - Modified: src/df_collector.c =================================================================== --- src/df_collector.c 2007-05-10 16:13:21 UTC (rev 22) +++ src/df_collector.c 2007-05-10 22:52:39 UTC (rev 23) @@ -24,8 +24,6 @@ * SUCH DAMAGE. */ -#include <string.h> - #include "common.h" #include "msg.h" #include "calea.h" @@ -39,14 +37,9 @@ #define DF_REPLY 1 -char *prog_name = "df_collector"; -int syslog_facility = DEF_SYSLOG_FACILITY; +char *prog_name = "df_collector"; +int syslog_facility = DEF_SYSLOG_FACILITY; -char *cmc_file = NULL; -char *cmii_file = NULL; -int cmc_port = 0; -int cmii_port = 0; - /* Routes to LEA */ #define MAXROUTES 10 @@ -64,9 +57,12 @@ struct addrinfo hints, *res; char *bind_addr = NULL; -const int on = 1; -const int off = 0; +char *df_port = NULL; +char *ctrl_port = NULL; +const int on = 1; +const int off = 0; + int change_user = 0; int change_group = 0; struct passwd *pwent; @@ -94,51 +90,39 @@ int i=0; /* command line options processing */ - while (( i = getopt ( argc, argv, "t:f:b:hm:n:u:g:vD:l:L:" )) != -1 ) { + while (( i = getopt ( argc, argv, "f:u:g:b:p:m:n:vD:l:L:h" )) != -1 ) { switch ( i ) { - case 'f': // CmC file - if ( ( cmc_file = strdup ( optarg ) ) == NULL ) - pdie ( "strdup" ); - debug_5 ( "got opt %c: %s", i, optarg ); - break; - case 't': // CmII file - if ( ( cmii_file = strdup ( optarg ) ) == NULL ) - pdie ( "strdup" ); - debug_5 ( "got opt %c: %s", i, optarg ); - break; - case 'b': // address to bind to - if ( ( bind_addr = strdup ( optarg ) ) == NULL ) - pdie ( "strdup" ); - debug_5 ( "got opt %c: %s", i, optarg ); - break; + case 'f': // config file + conf_file = Strdup ( optarg ); + debug_4 ( "got opt %c: %s", i, optarg ); + break; case 'u': // username strncpy ( (char *)user, optarg, 31 ); - debug_5 ( "got opt %c: %s", i, optarg ); + debug_4 ( "got opt %c: %s", i, optarg ); change_user = 1; break; case 'g': // group name strncpy ( &group[0], optarg, 31 ); - debug_5 ( "got opt %c: %s", i, optarg ); + debug_4 ( "got opt %c: %s", i, optarg ); change_group = 1; break; - case 'm': // cmc port - cmc_port = atoi ( optarg ); - debug_5 ( "got opt %c: %s", i, optarg ); + case 'b': // address to bind to + bind_addr = Strdup ( optarg ); + debug_4 ( "got opt %c: %s", i, optarg ); break; - case 'n': // cmii port - cmii_port = atoi ( optarg ); - debug_5 ( "got opt %c: %s", i, optarg ); + case 'p': // df listening port + df_port = Strdup ( optarg ); + debug_4 ( "got opt %c: %s", i, optarg ); break; case 'v': // debug ('d' was taken) debug_level_set++; - debug_5 ( "got opt %c, debug level now %d", + debug_4 ( "got opt %c, debug level now %d", i, debug_level_set ); break; case 'D': // debug file - if ( ( debug_file_name = strdup ( optarg ) ) == NULL ) - pdie ( "strdup" ); - debug_5 ( "got opt %c: %s", i, optarg ); + debug_file_name = Strdup ( optarg ); + debug_4 ( "got opt %c: %s", i, optarg ); break; case 'l': // log level errno = 0; @@ -149,12 +133,11 @@ else die ( "invalid log_level_set" ); } - debug_5 ( "got opt %c: %d", i, log_level_set ); + debug_4 ( "got opt %c: %d", i, log_level_set ); break; case 'L': // logfile - if ( ( log_file_name = strdup ( optarg ) ) == NULL ) - pdie ( "strdup" ); - debug_5 ( "got opt %c: %s", i, optarg ); + log_file_name = Strdup ( optarg ); + debug_4 ( "got opt %c: %s", i, optarg ); break; case 'h': // help usage(); @@ -185,79 +168,91 @@ die("Error parsing config file: %s", DEF_DF_COLLECTOR_CONF); } + + /* Now determine what user/group to change to */ + if ( ! change_user ) { + if ((confptr = get_config(&config, "User")) != NULL) { + strncpy ( user, *confptr->nextval++, 31 ); + debug_4("user set from config file: %s", user); + } + } + if ( ! change_group ) { + if ((confptr = get_config(&config, "Group")) != NULL) { + strncpy ( group, *confptr->nextval++, 31 ); + debug_4("group set from config file: %s", group); + } + } + + /* Drop privs if running as root or if requested */ + if ( ((uid_t)getegid() == 0) || change_group ) { + debug_3 ( "changing group id to: %s", group ); + errno = 0; + if (! (grent = getgrnam(group)) ) { + if (errno) { + pdie ( "getgrnam" ); + } else { + die ( "Group %s not found\n", group ); + } + } + if ( setgid(grent->gr_gid) < 0 ) + pdie ( "setgid" ); + } + if ( ((uid_t)geteuid() == 0) || change_user ) { + debug_3 ( "changing userid to: %s", user ); + errno = 0; + if (! (pwent = getpwnam(user)) ) { + if (errno) { + pdie ( "getpwnam" ); + } else { + die ( "User %s not found\n", user ); + } + } + if ( setuid(pwent->pw_uid) < 0 ) + pdie ( "setuid" ); + } + + /* We're running as non-root from here on... */ + /* Get CmII_Path from config file */ if ((confptr = get_config(&config, "CmII_Path")) != NULL) { - cmii_path = Calloc(strlen(*confptr->nextval) + 1); - bzero(cmii_path,strlen(*confptr->nextval) + 1); - strncpy(cmii_path, *confptr->nextval, strlen(*confptr->nextval)); - debug_5("df_collector: CmII_Path [%s]", cmii_path); + cmii_path = Strdup(*confptr->nextval++); + debug_4("df_collector: CmII_Path [%s]", cmii_path); } /* Get CmC_Path from config file */ if ((confptr = get_config(&config, "CmC_Path")) != NULL) { - cmc_path = Calloc(strlen(*confptr->nextval) + 1); - bzero(cmc_path,strlen(*confptr->nextval) + 1); - strncpy(cmc_path, *confptr->nextval, strlen(*confptr->nextval)); - debug_5("df_collector: CmC_Path [%s]", cmc_path); + cmc_path = Strdup(*confptr->nextval++); + debug_4("df_collector: CmC_Path [%s]", cmc_path); } /* Get Log_Path from config file */ if ((confptr = get_config(&config, "Log_Path")) != NULL) { - log_path = Calloc(strlen(*confptr->nextval) + 1); - bzero(log_path, strlen(*confptr->nextval) + 1); - strncpy(log_path, *confptr->nextval, strlen(*confptr->nextval)); - debug_5("df_collector: log_path [%s]", log_path); + log_path = Strdup(*confptr->nextval++); + debug_4("df_collector: log_path [%s]", log_path); } - if ( cmii_file == NULL ) { - usage(); - die ( "CmII file not specified (need -f)." ); - } + if ( bind_addr == NULL ) { + if ((confptr = get_config(&config, "Bind_Addr"))) { + bind_addr = Strdup ( *confptr->nextval++ ); + debug_4("df_collector: bind address set from config file (%s)", bind_addr); + } else { + bind_addr = Strdup ( "127.0.0.1" ); + debug_4("df_collector: Using default bind address (%s)", bind_addr); + } + } - /* drop privs if running as root or told to do so */ - if ( ((uid_t)geteuid() == 0) || change_user ) { - debug_5 ( "changing userid to: %s", user ); - errno = 0; - if (! (pwent = getpwnam(user)) ) { - if (errno) { - pdie ( "getpwnam" ); - } else { - die ( "User %s not found\n", user ); - } - } - if ( setuid(pwent->pw_uid) < 0 ) - pdie ( "setuid" ); + if ( df_port == NULL ) { + if ((confptr = get_config(&config, "DF_Port"))) { + df_port = Strdup ( *confptr->nextval++ ); + debug_5 ( "df_collector: DF listener port set from config file (%d)", df_port ); + } else { + df_port = Calloc ( 64 ); + snprintf ( df_port, 64, "%d", DF_PORT ); + debug_5 ( "df_collector: Using default DF listener port (%d)", df_port ); + } } - if ( ((uid_t)geteuid() == 0) || change_group ) { - debug_5 ( "changing group id to: %s", group ); - errno = 0; - if (! (grent = getgrnam(group)) ) { - if (errno) { - pdie ( "getgrnam" ); - } else { - die ( "Group %s not found\n", group ); - } - } - if (setgid(grent->gr_gid) < 0) - pdie ( "setgid" ); - } - if (!bind_addr) { - bind_addr = "127.0.0.1"; - debug_5 ( "df_collector: Using default bind address (%s)", bind_addr ); - } - if ( cmii_port == 0 ) { - cmii_port = CmII_PORT; - debug_5 ( "df_collector: Using default CmII listener port (%d)", cmii_port ); - } - - if ( cmc_port == 0 ) { - cmc_port = CmC_PORT; - debug_5 ( "df_collector: Using default CmC listener port (%d)", cmc_port ); - } - - return; } @@ -271,7 +266,7 @@ int id; char route_port[8]; char filename[MAX_LINE]; - int socktype; + socklen_t socklen; /* returned by Getsockopt */ union sockval { @@ -284,11 +279,11 @@ switch(msg->msgh.msgtype) { case MSGTYPE_NONE: - debug_5("df_collector: MSGTYPE_NONE uninitialized or not present"); + debug_2("df_collector: MSGTYPE_NONE uninitialized or not present"); break; case MSGTYPE_CONTROL: - //debug_5("df_collector: MSGTYPE_CONTROL OpenCALEA Control message"); + debug_3("df_collector: MSGTYPE_CONTROL OpenCALEA Control message"); ctrlmsg = (CtrlMsg *)((char *)msg + msg_len); //print_hex((const u_char *)msg, msg_len); @@ -297,7 +292,7 @@ switch (ctrlmsg->ctrlh.cmd) { case CTRLCMD_ROUTE_ADD: - //debug_5("df_collector: ROUTE ADD Control message received"); + debug_3("df_collector: ROUTE ADD Control message received"); /* look for a free slot in the route[] table */ for (id=0; id<MAXROUTES; id++) { @@ -306,7 +301,8 @@ } if (id == MAXROUTES) { - debug_5("df_collector: no available routes"); + debug_1("df_collector: no available routes"); + log_2("df_collector: no available routes"); return -1; } @@ -315,12 +311,12 @@ /************************************/ if (!route[id].cmii_fp) { bzero(filename,MAX_LINE); - strcat(filename,cmii_path); - strcat(filename,"/"); - strcat(filename,(char *)ctrlmsg->ctrlh.intercept.CaseID); - strcat(filename,".CmII"); - if (!(route[id].cmii_fp = fopen(filename, "ab"))) { - debug_5("df_collector: CmII_fp open failed for %s", filename); + strncat(filename,cmii_path,MAX_LINE); + strncat(filename,"/",MAX_LINE - strlen(filename)); + strncat(filename,(char *)ctrlmsg->ctrlh.intercept.CaseID,MAX_LINE - strlen(filename)); + strncat(filename,".CmII",MAX_LINE - strlen(filename)); + if (!(route[id].cmii_fp = fopen(filename, "wb"))) { + error("df_collector: CmII_fp open failed for %s", filename); pdie("df_collector: CmII_fp fopen"); } } @@ -330,12 +326,12 @@ /************************************/ if (!route[id].cmc_fp) { bzero(filename,MAX_LINE); - strcat(filename,cmc_path); - strcat(filename,"/"); - strcat(filename,(char *)ctrlmsg->ctrlh.intercept.CaseID); - strcat(filename,".CmC"); - if (!(route[id].cmc_fp = fopen(filename, "ab"))) { - debug_5("df_collector: CmC_fp open failed for %s", filename); + strncat(filename,cmc_path,MAX_LINE - strlen(filename)); + strncat(filename,"/",MAX_LINE - strlen(filename)); + strncat(filename,(char *)ctrlmsg->ctrlh.intercept.CaseID,MAX_LINE - strlen(filename)); + strncat(filename,".CmC",MAX_LINE - strlen(filename)); + if (!(route[id].cmc_fp = fopen(filename, "wb"))) { + error("df_collector: CmC_fp open failed for %s", filename); pdie("df_collector: CmC_fp fopen"); } } @@ -345,12 +341,12 @@ /******************************************/ if (!route[id].log_fp) { bzero(filename,MAX_LINE); - strcat(filename,log_path); - strcat(filename,"/"); - strcat(filename,(char *)ctrlmsg->ctrlh.intercept.CaseID); - strcat(filename,".LOG"); - if (!(route[id].log_fp = fopen(filename, "a"))) { - debug_5("df_collector: Surveillance log file open failed for %s", filename); + strncat(filename,log_path,MAX_LINE - strlen(filename)); + strncat(filename,"/",MAX_LINE - strlen(filename)); + strncat(filename,(char *)ctrlmsg->ctrlh.intercept.CaseID,MAX_LINE - strlen(filename)); + strncat(filename,".LOG",MAX_LINE - strlen(filename)); + if (!(route[id].log_fp = fopen(filename, "w"))) { + error("df_collector: Surveillance log file open failed for %s", filename); pdie("df_collector: Surveillance log fopen"); } } @@ -358,18 +354,25 @@ /*****************************************/ /* Create a Route (generally to the LEA) */ /*****************************************/ + sprintf(route_port, "%d", ntohs(ctrlmsg->ctrlh.dfhost.port)); + debug_4("df_collector: route port is %s", route_port); + + bzero(&hints, sizeof(hints)); + hints.ai_family = AF_INET; + if (strcmp((char *)ctrlmsg->ctrlh.dfhost.protocol,"udp") == 0) { - socktype = SOCK_DGRAM; + debug_4("df_collector: route protocol is UDP"); + hints.ai_socktype = SOCK_DGRAM; } else if (strcmp((char *)ctrlmsg->ctrlh.dfhost.protocol,"tcp") == 0) { - socktype = SOCK_STREAM; + error("df_collector: TCP is currently an unsupported route protocol"); + hints.ai_socktype = SOCK_STREAM; } else { - debug_5("df_collector: %s is currently an unsupported route protocol. Defaulting to UDP", ctrlmsg->ctrlh.dfhost.protocol); - socktype = SOCK_DGRAM; + debug_2("df_collector: %s is currently an unsupported route protocol. Defaulting to UDP", + ctrlmsg->ctrlh.dfhost.protocol); + hints.ai_socktype = SOCK_DGRAM; } - res = Getaddrinfo1st((char *)ctrlmsg->ctrlh.dfhost.host, ntohs(ctrlmsg->ctrlh.dfhost.port), AF_INET, socktype); - if (!res) { - debug_5("df_collector: ROUTE ADD Getaddrinfo1st failed"); + if (getaddrinfo((char *)ctrlmsg->ctrlh.dfhost.host, route_port, &hints, &res)) { return -1; } @@ -381,17 +384,17 @@ route[id].lea_addr.sin_port = ((struct sockaddr_in *)res->ai_addr)->sin_port; route[id].lea_addr.sin_addr.s_addr = ((struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr; if ((route[id].lea_fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) { - debug_5("df_collector: ipv4 route[%d]=%d socket failure", id, route[id].lea_fd); + debug_2("df_collector: ipv4 route[%d]=%d socket failure", id, route[id].lea_fd); break; } if (connect(route[id].lea_fd, res->ai_addr, res->ai_addrlen) < 0) { - debug_4 ( "df_collector: connect error"); - close(route[id].lea_fd); + debug_2 ( "df_collector: connect error"); + Close(route[id].lea_fd); route[id].lea_fd = -1; } - debug_5("df_collector: ROUTE[%d] created to %s://%s:%d [%s %s %s]", + debug_3("df_collector: ROUTE[%d] created to %s://%s:%d [%s %s %s]", id, ctrlmsg->ctrlh.dfhost.protocol, ctrlmsg->ctrlh.dfhost.host, @@ -404,8 +407,10 @@ freeaddrinfo(res); return DF_REPLY; case AF_INET6: + error("df_collector: we don't handle IPv6 yet."); break; default: + error("df_collector: we don't handle address family %d.", res->ai_family); break; } break; @@ -415,7 +420,7 @@ } case MSGTYPE_LOG: - debug_5("df_collector: MSGTYPE_LOG Surveillance Log message"); + debug_4("df_collector: MSGTYPE_LOG Surveillance Log message"); //print_hex((const u_char *)msg, msg_len); //print_hex((const u_char *)((char *)msg + msg_len), msg->msgh.msglen); @@ -424,22 +429,34 @@ if (route[id].log_fp) { ret = fwrite(((char *)msg + msg_len), msg->msgh.msglen, 1, route[id].log_fp); if (ret != 1) { - debug_5("df_collector: error writing to Log file"); + error("df_collector: error writing to Log file: %s", strerror(errno)); } } else { - debug_5("df_collector: Warning Log file is not available"); + debug_2("df_collector: Warning Log file is not available"); } break; case MSGTYPE_CMII: - //debug_5("df_collector: MSGTYPE_CMII Communications Identifying Information message"); + debug_5("df_collector: MSGTYPE_CMII Communications Identifying Information message"); //print_hex((const u_char *)msg, msg_len); //print_hex((const u_char *)((char *)msg + msg_len), msg->msgh.msglen); id = ntohs(msg->msgh.routeid); inet_ntop (route[id].lea_addr.sin_family, &route[id].lea_addr.sin_addr.s_addr, addrstr, sizeof(addrstr)); + /**************************/ + /* Write packet to a file */ + /**************************/ + if (route[id].cmii_fp) { + ret = fwrite(((char *)msg + msg_len), msg->msgh.msglen, 1, route[id].cmii_fp); + if (ret != 1) { + error("df_collector: error writing to CmII file: %s", strerror(errno)); + } + } else { + debug_5("df_collector: CmII capture file is not available"); + } + num_sent = sendto (route[id].lea_fd, ((char *)msg + msg_len), msg->msgh.msglen, @@ -447,34 +464,13 @@ (struct sockaddr *)&route[id].lea_addr, sizeof(route[id].lea_addr)); - /****************************************************************************/ - /* If there was an error sending the data to the other end of the route[id] */ - /* then save the data locally for future transmission. */ - /* Note that for UDP transmissions, an error will only be indicated if the */ - /* the socket to the route[id] is in an error state. For UDP, there IS NO */ - /* GUARANTEE that the data was actually received at the remote end. */ - /****************************************************************************/ if (num_sent == -1) { - debug_5("df_collector: CmII packet -> route[%d] %s:%d failed saving to file", + debug_3("df_collector: CmII packet -> route[%d] %s:%d failed", id, addrstr, ntohs(route[id].lea_addr.sin_port)); socklen = sizeof(sockval); Getsockopt(route[id].lea_fd, SOL_SOCKET, SO_ERROR, &sockval, &socklen); - - /**************************/ - /* Write packet to a file */ - /**************************/ - if (route[id].cmii_fp) { - ret = fwrite(((char *)msg + msg_len), msg->msgh.msglen, 1, route[id].cmii_fp); - if (ret != 1) { - debug_5("df_collector: Error writing to CmII file"); - } else { - debug_5("df_collector: Wrote %d bytes to CmII file", (ret * msg->msgh.msglen)); - } - } else { - debug_5("df_collector: Warning CmII capture file is not available"); - } } else { debug_5("df_collector: CmII packet -> route[%d] %s:%d %d bytes sent ", id, @@ -486,17 +482,26 @@ break; case MSGTYPE_CII: - debug_5("df_collector: MSGTYPE_CII Call Identifying Information message"); + debug_3("df_collector: MSGTYPE_CII Call Identifying Information message"); break; case MSGTYPE_CMC: - //debug_5("df_collector: MSGTYPE_CMC Communications Content message"); + debug_5("df_collector: MSGTYPE_CMC Communications Content message"); //print_hex((const u_char *)msg, msg_len); //print_hex((const u_char *)((char *)msg + msg_len), msg->msgh.msglen); id = ntohs(msg->msgh.routeid); inet_ntop (route[id].lea_addr.sin_family, &route[id].lea_addr.sin_addr.s_addr, addrstr, sizeof(addrstr)); + if (route[id].cmc_fp) { + ret = fwrite(((char *)msg + msg_len), msg->msgh.msglen, 1, route[id].cmc_fp); + if (ret != 1) { + error("df_collector: error writing to CmC file: %s", strerror(errno)); + } + } else { + debug_5("df_collector: CmC capture file is not available"); + } + num_sent = sendto (route[id].lea_fd, ((char *)msg + msg_len), msg->msgh.msglen, @@ -504,34 +509,13 @@ (struct sockaddr *)&route[id].lea_addr, sizeof(route[id].lea_addr)); - /****************************************************************************/ - /* If there was an error sending the data to the other end of the route[id] */ - /* then save the data locally for future transmission. */ - /* Note that for UDP transmissions, an error will only be indicated if the */ - /* the socket to the route[id] is in an error state. For UDP, there IS NO */ - /* GUARANTEE that the data was actually received at the remote end. */ - /****************************************************************************/ if (num_sent == -1) { - debug_5("df_collector: CmC packet -> route[%d] %s:%d failed saving to file", + debug_3("df_collector: CmC packet -> route[%d] %s:%d failed", id, addrstr, ntohs(route[id].lea_addr.sin_port)); socklen = sizeof(sockval); Getsockopt(route[id].lea_fd, SOL_SOCKET, SO_ERROR, &sockval, &socklen); - /**************************/ - /* Write packet to a file */ - /**************************/ - if (route[id].cmc_fp) { - ret = fwrite(((char *)msg + msg_len), msg->msgh.msglen, 1, route[id].cmc_fp); - if (ret != 1) { - debug_5("df_collector: Error writing to CmC file"); - } else { - debug_5("df_collector: Wrote %d bytes to CmC file", (ret * msg->msgh.msglen)); - } - } else { - debug_5("df_collector: Warning CmC capture file is not available"); - } - } else { debug_5("df_collector: CmC packet -> route[%d] %s:%d %d bytes sent ", id, @@ -543,10 +527,10 @@ break; case MSGTYPE_CC: - debug_5("df_collector: MSGTYPE_CC Call Content message"); + debug_3("df_collector: MSGTYPE_CC Call Content message"); break; default: - debug_5("df_collector: Unknown MSGTYPE detected"); + debug_2("df_collector: Unknown MSGTYPE detected"); break; } @@ -589,13 +573,14 @@ void usage ( void ) { - printf ( "Usage: df_collector -t cmii-capture-file " ); - printf ( "[-f cmc-capture-file] " ); - printf ( "[-b bind-addr] " ); - printf ( "[-u user] [-g group] " ); + printf ( "Usage: df_collector " ); + printf ( " [-f config-file]" ); + printf ( " [-u user] [-g group]" ); + printf ( " [-b bind-addr] " ); printf ( " [-m cmc-port] [-n cmii-port] [-x]" ); printf ( " [-v [...]] [-D debug-file]" ); printf ( " [-l log-level ] [-L logfile]" ); + printf ( " [-h]" ); printf ( "\n" ); @@ -604,10 +589,8 @@ int main ( int argc, char *argv[] ) { int i, maxi, maxfd, connfd, sockfd; - int CmII_tcpfd = -1; - int CmC_tcpfd = -1; - int CmII_udpfd = -1; - int CmC_udpfd = -1; + int df_tcpfd = -1; + int df_udpfd = -1; int controlfd = -1; int nready, client[FD_SETSIZE]; ssize_t n; @@ -617,78 +600,44 @@ socklen_t len, clilen; struct sockaddr_in cliaddr, servaddr; - setdebug( 5, "stdout", 1 ); + setdebug( DEF_DEBUG_LEVEL, DEF_DEBUG_DEST, 1 ); + setlog( DEF_LOG_LEVEL, DEF_LOG_DEST, 1 ); parse_commandline(argc, argv); - /**************************/ - /* Create CmII TCP socket */ - /**************************/ - res = Getaddrinfo1st(bind_addr, cmii_port, AF_INET, SOCK_STREAM); - if (!res) { - debug_5("df_collector: CmII TCP Gteaddrinfo1st failed"); - return -1; - } + /************************/ + /* Create DF TCP socket */ + /************************/ + res = Getaddrinfo1st(bind_addr, df_port, AF_INET, SOCK_STREAM); switch (res->ai_family) { case AF_INET: bzero(&servaddr, sizeof(servaddr)); servaddr.sin_family = res->ai_family; servaddr.sin_port = ((struct sockaddr_in *)res->ai_addr)->sin_port; servaddr.sin_addr.s_addr = ((struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr; - if ((CmII_tcpfd = Socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) { - debug_5("df_collector: CmII TCP socket error"); + if ((df_tcpfd = Socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) { + error("df_collector: DF TCP socket error"); } break; default: - debug_5("df_collector: CmII TCP unsupported family"); + die("df_collector: DF TCP unsupported family"); break; } inet_ntop (servaddr.sin_family, &servaddr.sin_addr.s_addr, addrstr, sizeof(addrstr)); - debug_5("df_collector: CmII TCP IPv%d address: %s (%s) port: %d", res->ai_family == PF_INET6 ? 6 : 4, addrstr, res->ai_canonname, ntohs(servaddr.sin_port)); + debug_5("df_collector: DF TCP IPv%d address: %s (%s) port: %d", + res->ai_family == PF_INET6 ? 6 : 4, addrstr, res->ai_canonname, ntohs(servaddr.sin_port)); freeaddrinfo(res); - Setsockopt(CmII_tcpfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); - Bind(CmII_tcpfd, (struct sockaddr *) &servaddr, sizeof(servaddr)); - Listen(CmII_tcpfd, MAX_CONNECTIONS); + Setsockopt(df_tcpfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); + Bind(df_tcpfd, (struct sockaddr *) &servaddr, sizeof(servaddr)); + Listen(df_tcpfd, MAX_CONNECTIONS); - /*************************/ - /* Create CmC TCP socket */ - /*************************/ - res = Getaddrinfo1st(bind_addr, cmc_port, AF_INET, SOCK_STREAM); - if (!res) { - debug_5("df_collector: CmC TCP Getaddrinfo1st failed"); - return -1; - } - switch (res->ai_family) { - case AF_INET: - bzero(&servaddr, sizeof(servaddr)); - servaddr.sin_family = res->ai_family; - servaddr.sin_port = ((struct sockaddr_in *)res->ai_addr)->sin_port; - servaddr.sin_addr.s_addr = ((struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr; - if ((CmC_tcpfd = Socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) { - debug_5("df_collector: CmC TCP socket error"); - } - break; - default: - debug_5("df_collector: CmC TCP unsupported family"); - break; - } - inet_ntop (servaddr.sin_family, &servaddr.sin_addr.s_addr, addrstr, sizeof(addrstr)); - debug_5("df_collector: CmC TCP IPv%d address: %s (%s) port: %d", res->ai_family == PF_INET6 ? 6 : 4, addrstr, res->ai_canonname, ntohs(servaddr.sin_port)); - freeaddrinfo(res); - - Setsockopt(CmC_tcpfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); - Bind(CmC_tcpfd, (struct sockaddr *) &servaddr, sizeof(servaddr)); - Listen(CmC_tcpfd, MAX_CONNECTIONS); - /*****************************/ /* Create control TCP socket */ /*****************************/ - res = Getaddrinfo1st(bind_addr, DF_CONTROL_PORT, AF_INET, SOCK_STREAM); - if (!res) { - debug_5("df_collector: Control TCP Getaddrinfo1st failed"); - return -1; - } + ctrl_port = Calloc ( 64 ); + snprintf ( ctrl_port, 64, "%d", DF_CONTROL_PORT ); + res = Getaddrinfo1st(bind_addr, ctrl_port, AF_INET, SOCK_STREAM); switch (res->ai_family) { case AF_INET: bzero(&servaddr, s... [truncated message content] |
From: <jn...@us...> - 2007-05-10 16:13:24
|
Revision: 22 http://opencalea.svn.sourceforge.net/opencalea/?rev=22&view=rev Author: jnorell Date: 2007-05-10 09:13:21 -0700 (Thu, 10 May 2007) Log Message: ----------- Adding "tags" and "branches" directories. Added Paths: ----------- branches/ tags/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jn...@us...> - 2007-05-10 16:12:04
|
Revision: 21 http://opencalea.svn.sourceforge.net/opencalea/?rev=21&view=rev Author: jnorell Date: 2007-05-10 09:12:01 -0700 (Thu, 10 May 2007) Log Message: ----------- Making "trunk" directory. Added Paths: ----------- trunk/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nor...@us...> - 2007-05-10 13:44:22
|
Revision: 20 http://opencalea.svn.sourceforge.net/opencalea/?rev=20&view=rev Author: norm_brandinger Date: 2007-05-10 06:44:23 -0700 (Thu, 10 May 2007) Log Message: ----------- Only write data to a file if an error is returned from sendto. Modified Paths: -------------- src/df_collector.c Modified: src/df_collector.c =================================================================== --- src/df_collector.c 2007-05-10 11:53:58 UTC (rev 19) +++ src/df_collector.c 2007-05-10 13:44:23 UTC (rev 20) @@ -319,7 +319,7 @@ strcat(filename,"/"); strcat(filename,(char *)ctrlmsg->ctrlh.intercept.CaseID); strcat(filename,".CmII"); - if (!(route[id].cmii_fp = fopen(filename, "wb"))) { + if (!(route[id].cmii_fp = fopen(filename, "ab"))) { debug_5("df_collector: CmII_fp open failed for %s", filename); pdie("df_collector: CmII_fp fopen"); } @@ -334,7 +334,7 @@ strcat(filename,"/"); strcat(filename,(char *)ctrlmsg->ctrlh.intercept.CaseID); strcat(filename,".CmC"); - if (!(route[id].cmc_fp = fopen(filename, "wb"))) { + if (!(route[id].cmc_fp = fopen(filename, "ab"))) { debug_5("df_collector: CmC_fp open failed for %s", filename); pdie("df_collector: CmC_fp fopen"); } @@ -349,7 +349,7 @@ strcat(filename,"/"); strcat(filename,(char *)ctrlmsg->ctrlh.intercept.CaseID); strcat(filename,".LOG"); - if (!(route[id].log_fp = fopen(filename, "w"))) { + if (!(route[id].log_fp = fopen(filename, "a"))) { debug_5("df_collector: Surveillance log file open failed for %s", filename); pdie("df_collector: Surveillance log fopen"); } @@ -440,18 +440,6 @@ id = ntohs(msg->msgh.routeid); inet_ntop (route[id].lea_addr.sin_family, &route[id].lea_addr.sin_addr.s_addr, addrstr, sizeof(addrstr)); - /**************************/ - /* Write packet to a file */ - /**************************/ - if (route[id].cmii_fp) { - ret = fwrite(((char *)msg + msg_len), msg->msgh.msglen, 1, route[id].cmii_fp); - if (ret != 1) { - debug_5("df_collector: error writing to CmII file"); - } - } else { - debug_5("df_collector: Warning CmII capture file is not available"); - } - num_sent = sendto (route[id].lea_fd, ((char *)msg + msg_len), msg->msgh.msglen, @@ -459,13 +447,34 @@ (struct sockaddr *)&route[id].lea_addr, sizeof(route[id].lea_addr)); + /****************************************************************************/ + /* If there was an error sending the data to the other end of the route[id] */ + /* then save the data locally for future transmission. */ + /* Note that for UDP transmissions, an error will only be indicated if the */ + /* the socket to the route[id] is in an error state. For UDP, there IS NO */ + /* GUARANTEE that the data was actually received at the remote end. */ + /****************************************************************************/ if (num_sent == -1) { - debug_5("df_collector: CmII packet -> route[%d] %s:%d failed", + debug_5("df_collector: CmII packet -> route[%d] %s:%d failed saving to file", id, addrstr, ntohs(route[id].lea_addr.sin_port)); socklen = sizeof(sockval); Getsockopt(route[id].lea_fd, SOL_SOCKET, SO_ERROR, &sockval, &socklen); + + /**************************/ + /* Write packet to a file */ + /**************************/ + if (route[id].cmii_fp) { + ret = fwrite(((char *)msg + msg_len), msg->msgh.msglen, 1, route[id].cmii_fp); + if (ret != 1) { + debug_5("df_collector: Error writing to CmII file"); + } else { + debug_5("df_collector: Wrote %d bytes to CmII file", (ret * msg->msgh.msglen)); + } + } else { + debug_5("df_collector: Warning CmII capture file is not available"); + } } else { debug_5("df_collector: CmII packet -> route[%d] %s:%d %d bytes sent ", id, @@ -488,15 +497,6 @@ id = ntohs(msg->msgh.routeid); inet_ntop (route[id].lea_addr.sin_family, &route[id].lea_addr.sin_addr.s_addr, addrstr, sizeof(addrstr)); - if (route[id].cmc_fp) { - ret = fwrite(((char *)msg + msg_len), msg->msgh.msglen, 1, route[id].cmc_fp); - if (ret != 1) { - debug_5("df_collector: error writing to CmC file"); - } - } else { - debug_5("df_collector: Warning CmC capture file is not available"); - } - num_sent = sendto (route[id].lea_fd, ((char *)msg + msg_len), msg->msgh.msglen, @@ -504,13 +504,34 @@ (struct sockaddr *)&route[id].lea_addr, sizeof(route[id].lea_addr)); + /****************************************************************************/ + /* If there was an error sending the data to the other end of the route[id] */ + /* then save the data locally for future transmission. */ + /* Note that for UDP transmissions, an error will only be indicated if the */ + /* the socket to the route[id] is in an error state. For UDP, there IS NO */ + /* GUARANTEE that the data was actually received at the remote end. */ + /****************************************************************************/ if (num_sent == -1) { - debug_5("df_collector: CmC packet -> route[%d] %s:%d failed", + debug_5("df_collector: CmC packet -> route[%d] %s:%d failed saving to file", id, addrstr, ntohs(route[id].lea_addr.sin_port)); socklen = sizeof(sockval); Getsockopt(route[id].lea_fd, SOL_SOCKET, SO_ERROR, &sockval, &socklen); + /**************************/ + /* Write packet to a file */ + /**************************/ + if (route[id].cmc_fp) { + ret = fwrite(((char *)msg + msg_len), msg->msgh.msglen, 1, route[id].cmc_fp); + if (ret != 1) { + debug_5("df_collector: Error writing to CmC file"); + } else { + debug_5("df_collector: Wrote %d bytes to CmC file", (ret * msg->msgh.msglen)); + } + } else { + debug_5("df_collector: Warning CmC capture file is not available"); + } + } else { debug_5("df_collector: CmC packet -> route[%d] %s:%d %d bytes sent ", id, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nor...@us...> - 2007-05-10 11:53:58
|
Revision: 19 http://opencalea.svn.sourceforge.net/opencalea/?rev=19&view=rev Author: norm_brandinger Date: 2007-05-10 04:53:58 -0700 (Thu, 10 May 2007) Log Message: ----------- Added NULL checking for Getaddrinfo1st Modified Paths: -------------- src/df_collector.c Modified: src/df_collector.c =================================================================== --- src/df_collector.c 2007-05-10 11:14:00 UTC (rev 18) +++ src/df_collector.c 2007-05-10 11:53:58 UTC (rev 19) @@ -271,7 +271,7 @@ int id; char route_port[8]; char filename[MAX_LINE]; - + int socktype; socklen_t socklen; /* returned by Getsockopt */ union sockval { @@ -358,21 +358,18 @@ /*****************************************/ /* Create a Route (generally to the LEA) */ /*****************************************/ - sprintf(route_port, "%d", ntohs(ctrlmsg->ctrlh.dfhost.port)); - bzero(&hints, sizeof(hints)); - hints.ai_family = AF_INET; - if (strcmp((char *)ctrlmsg->ctrlh.dfhost.protocol,"udp") == 0) { - hints.ai_socktype = SOCK_DGRAM; + socktype = SOCK_DGRAM; } else if (strcmp((char *)ctrlmsg->ctrlh.dfhost.protocol,"tcp") == 0) { - debug_5("df_collector: TCP is currently an unsupported route protocol"); - hints.ai_socktype = SOCK_STREAM; + socktype = SOCK_STREAM; } else { debug_5("df_collector: %s is currently an unsupported route protocol. Defaulting to UDP", ctrlmsg->ctrlh.dfhost.protocol); - hints.ai_socktype = SOCK_DGRAM; + socktype = SOCK_DGRAM; } - if (getaddrinfo((char *)ctrlmsg->ctrlh.dfhost.host, route_port, &hints, &res)) { + res = Getaddrinfo1st((char *)ctrlmsg->ctrlh.dfhost.host, ntohs(ctrlmsg->ctrlh.dfhost.port), AF_INET, socktype); + if (!res) { + debug_5("df_collector: ROUTE ADD Getaddrinfo1st failed"); return -1; } @@ -607,6 +604,10 @@ /* Create CmII TCP socket */ /**************************/ res = Getaddrinfo1st(bind_addr, cmii_port, AF_INET, SOCK_STREAM); + if (!res) { + debug_5("df_collector: CmII TCP Gteaddrinfo1st failed"); + return -1; + } switch (res->ai_family) { case AF_INET: bzero(&servaddr, sizeof(servaddr)); @@ -633,6 +634,10 @@ /* Create CmC TCP socket */ /*************************/ res = Getaddrinfo1st(bind_addr, cmc_port, AF_INET, SOCK_STREAM); + if (!res) { + debug_5("df_collector: CmC TCP Getaddrinfo1st failed"); + return -1; + } switch (res->ai_family) { case AF_INET: bzero(&servaddr, sizeof(servaddr)); @@ -659,6 +664,10 @@ /* Create control TCP socket */ /*****************************/ res = Getaddrinfo1st(bind_addr, DF_CONTROL_PORT, AF_INET, SOCK_STREAM); + if (!res) { + debug_5("df_collector: Control TCP Getaddrinfo1st failed"); + return -1; + } switch (res->ai_family) { case AF_INET: bzero(&servaddr, sizeof(servaddr)); @@ -685,6 +694,10 @@ /* Create CmII UDP socket */ /**************************/ res = Getaddrinfo1st(bind_addr, cmii_port, AF_INET, SOCK_DGRAM); + if (!res) { + debug_5("df_collector: CmII UDP Getaddrinfo1st failed"); + return -1; + } switch (res->ai_family) { case AF_INET: bzero(&servaddr, sizeof(servaddr)); @@ -710,6 +723,10 @@ /* Create CmC UDP socket */ /*************************/ res = Getaddrinfo1st(bind_addr, cmc_port, AF_INET, SOCK_DGRAM); + if (!res) { + debug_5("df_collector: CmC UDP Getaddrinfo1st failed"); + return -1; + } switch (res->ai_family) { case AF_INET: bzero(&servaddr, sizeof(servaddr)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nor...@us...> - 2007-05-09 22:48:17
|
Revision: 17 http://opencalea.svn.sourceforge.net/opencalea/?rev=17&view=rev Author: norm_brandinger Date: 2007-05-09 15:48:18 -0700 (Wed, 09 May 2007) Log Message: ----------- Replaced malloc with local Calloc in df_collector Modified Paths: -------------- src/df_collector.c Modified: src/df_collector.c =================================================================== --- src/df_collector.c 2007-05-09 21:08:02 UTC (rev 16) +++ src/df_collector.c 2007-05-09 22:48:18 UTC (rev 17) @@ -187,10 +187,7 @@ /* Get CmII_Path from config file */ if ((confptr = get_config(&config, "CmII_Path")) != NULL) { - cmii_path = malloc(strlen(*confptr->nextval) + 1); - if (!cmii_path) { - debug_5("df_collector: memory allocation for cmii_path failed"); - } + cmii_path = Calloc(strlen(*confptr->nextval) + 1); bzero(cmii_path,strlen(*confptr->nextval) + 1); strncpy(cmii_path, *confptr->nextval, strlen(*confptr->nextval)); debug_5("df_collector: CmII_Path [%s]", cmii_path); @@ -198,10 +195,7 @@ /* Get CmC_Path from config file */ if ((confptr = get_config(&config, "CmC_Path")) != NULL) { - cmc_path = malloc(strlen(*confptr->nextval) + 1); - if (!cmc_path) { - debug_5("df_collector: memory allocation for cmc_path failed"); - } + cmc_path = Calloc(strlen(*confptr->nextval) + 1); bzero(cmc_path,strlen(*confptr->nextval) + 1); strncpy(cmc_path, *confptr->nextval, strlen(*confptr->nextval)); debug_5("df_collector: CmC_Path [%s]", cmc_path); @@ -209,10 +203,7 @@ /* Get Log_Path from config file */ if ((confptr = get_config(&config, "Log_Path")) != NULL) { - log_path = malloc(strlen(*confptr->nextval) + 1); - if (!log_path) { - debug_5("df_collector: memory allocation for capture_path failed"); - } + log_path = Calloc(strlen(*confptr->nextval) + 1); bzero(log_path, strlen(*confptr->nextval) + 1); strncpy(log_path, *confptr->nextval, strlen(*confptr->nextval)); debug_5("df_collector: log_path [%s]", log_path); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nor...@us...> - 2007-05-09 18:38:31
|
Revision: 15 http://opencalea.svn.sourceforge.net/opencalea/?rev=15&view=rev Author: norm_brandinger Date: 2007-05-09 11:38:10 -0700 (Wed, 09 May 2007) Log Message: ----------- updated opencalea.conf Modified Paths: -------------- etc/opencalea/opencalea.conf Modified: etc/opencalea/opencalea.conf =================================================================== --- etc/opencalea/opencalea.conf 2007-05-09 18:37:24 UTC (rev 14) +++ etc/opencalea/opencalea.conf 2007-05-09 18:38:10 UTC (rev 15) @@ -47,9 +47,10 @@ [DF_COLLECTOR] -Program_Name = df_collector +Program_Name = df_collector +Capture_Path = /opencalea/capture +Surveillance_Path = /var/log/opencalea/surveillance_log - [LEA_COLLECTOR] Program_Name = lea_collector This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nor...@us...> - 2007-05-09 18:37:25
|
Revision: 14 http://opencalea.svn.sourceforge.net/opencalea/?rev=14&view=rev Author: norm_brandinger Date: 2007-05-09 11:37:24 -0700 (Wed, 09 May 2007) Log Message: ----------- added df_collector.h started adding config parser support to df_collector Modified Paths: -------------- src/df_collector.c Added Paths: ----------- src/df_collector.h Modified: src/df_collector.c =================================================================== --- src/df_collector.c 2007-05-09 16:47:08 UTC (rev 13) +++ src/df_collector.c 2007-05-09 18:37:24 UTC (rev 14) @@ -30,12 +30,13 @@ #include "msg.h" #include "calea.h" +#include "df_collector.h" + ssize_t tcp_write(int fd, const void *buf, size_t tot_len); ssize_t tcp_read(int fd, void *buf, size_t tot_len); void usage (void); int PacketSend ( char *packet, int length, int *send_sock ); -#define MAXROUTES 10 #define DF_REPLY 1 char *prog_name = "df_collector"; @@ -49,6 +50,7 @@ int cmii_port = 0; /* Routes to LEA */ +#define MAXROUTES 10 typedef struct route_t { char protocol[8]; /* Protocol used to communicate across this route */ @@ -78,6 +80,13 @@ char addrstr[INET_ADDRSTRLEN]; +Config config; +Config *confptr = NULL; +char* conf_file = NULL; + +char *capture_path; +char *surveillance_path; + void parse_commandline(int argc, char *argv[]) { int i=0; @@ -154,6 +163,48 @@ } } + bzero (&config, sizeof(config)); + + /* if config file was specified, read that */ + if (conf_file && strlen(conf_file)) { + if (parse_config(&config, OPENCALEA_CONF_SECTION, conf_file) < 0) + die("Error with config file \"%s\"", conf_file); + if (parse_config(&config, DF_COLLECTOR_CONF_SECTION, conf_file) < 0) + die("Error with config file \"%s\"", conf_file); + } else { + /* otherwise read default config files */ + if (parse_config(&config, OPENCALEA_CONF_SECTION, DEF_OPENCALEA_CONF) < 0) + die("Error parsing config file: %s", DEF_OPENCALEA_CONF); + if (parse_config(&config, DF_COLLECTOR_CONF_SECTION, DEF_OPENCALEA_CONF) < 0) + die("Error parsing config file: %s", DEF_OPENCALEA_CONF); + if (parse_config(&config, OPENCALEA_CONF_SECTION, DEF_DF_COLLECTOR_CONF) < 0) + die("Error parsing config file: %s", DEF_DF_COLLECTOR_CONF); + if (parse_config(&config, DF_COLLECTOR_CONF_SECTION, DEF_DF_COLLECTOR_CONF) < 0) + die("Error parsing config file: %s", DEF_DF_COLLECTOR_CONF); + } + + /* Get Capture_Path from config file */ + if ((confptr = get_config(&config, "Capture_Path")) != NULL) { + capture_path = malloc(strlen(*confptr->nextval) + 1); + if (!capture_path) { + debug_5("df_collector: memory allocation for capture_path failed"); + } + bzero(capture_path,strlen(*confptr->nextval) + 1); + strncpy(capture_path, *confptr->nextval, strlen(*confptr->nextval)); + debug_5("df_collector: Capture_Path [%s]", capture_path); + } + + /* Get Surveillance_Path from config file */ + if ((confptr = get_config(&config, "Surveillance_Path")) != NULL) { + surveillance_path = malloc(strlen(*confptr->nextval) + 1); + if (!surveillance_path) { + debug_5("df_collector: memory allocation for capture_path failed"); + } + bzero(surveillance_path, strlen(*confptr->nextval) + 1); + strncpy(surveillance_path, *confptr->nextval, strlen(*confptr->nextval)); + debug_5("df_collector: Surveillance_Path [%s]", surveillance_path); + } + if ( cmii_file == NULL ) { usage(); die ( "CmII file not specified (need -f)." ); Added: src/df_collector.h =================================================================== --- src/df_collector.h (rev 0) +++ src/df_collector.h 2007-05-09 18:37:24 UTC (rev 14) @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2007 Norman Brandinger <no...@go...> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _DF_COLLECTOR_H +#define _DF_COLLECTOR_H + +#ifndef DEF_DF_COLLECTOR_CONF +#define DEF_DF_COLLECTOR_CONF "/etc/opencalea/df_collector.conf" +#endif + +#ifndef DF_COLLECTOR_CONF_SECTION +#define DF_COLLECTOR_CONF_SECTION "DF_COLLECTOR" +#endif + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nor...@us...> - 2007-05-09 16:47:08
|
Revision: 13 http://opencalea.svn.sourceforge.net/opencalea/?rev=13&view=rev Author: norm_brandinger Date: 2007-05-09 09:47:08 -0700 (Wed, 09 May 2007) Log Message: ----------- added: etc/opencalea/opencalea.conf Added Paths: ----------- etc/ etc/opencalea/ etc/opencalea/opencalea.conf Added: etc/opencalea/opencalea.conf =================================================================== --- etc/opencalea/opencalea.conf (rev 0) +++ etc/opencalea/opencalea.conf 2007-05-09 16:47:08 UTC (rev 13) @@ -0,0 +1,60 @@ +# /etc/opencalea/opencalea.conf +# This is the shared OpenCALEA config file. +# See opencalea.conf(5) for more info. + +[OpenCALEA] + +IAPSystemID = "IAP-1" + +Controller = localhost +Control_Port = 41800 + +DF_Collector = localhost +DF_Port = 41805 + +CmII_Port = 41810 +CmC_Port = 41820 + +User = calea +Group = calea + +# see /usr/include/syslog.h ( LOG_USER = (1<<3) = 8 ) +Syslog_Facility = 8 +Log_Level = 2 +Log_File = /var/log/opencalea/opencalea.log +Debug_Level = 4 +Debug_Destination = /var/log/opencalea/opencalea.debug + +pid_directory = /var/run/opencalea +state_directory = /var/run/opencalea + + +[TAP] +Program_Name = tap +Interface = eth0,eth1,eth2 + +Debug_Level = 4 +Debug_Destination = /var/log/opencalea/tap.debug + +ContentID = Test1234 + + +[TAP_CONTROLLER] +Program_Name = tap_controller + +pid_file = tap_controller.pid +#Control_Socket = /var/run/opencalea/ + + +[DF_COLLECTOR] +Program_Name = df_collector + + +[LEA_COLLECTOR] +Program_Name = lea_collector + +capturefile_directory = /var/lib/opencalea + +logfile = /var/log/opencalea/lea_collector.log +errorlog = /var/log/opencalea/lea_collector.err + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nor...@us...> - 2007-05-09 16:41:20
|
Revision: 11 http://opencalea.svn.sourceforge.net/opencalea/?rev=11&view=rev Author: norm_brandinger Date: 2007-05-09 09:41:21 -0700 (Wed, 09 May 2007) Log Message: ----------- added: etc/opencalea/opencalea.conf Added Paths: ----------- etc/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nor...@us...> - 2007-05-09 16:40:20
|
Revision: 10 http://opencalea.svn.sourceforge.net/opencalea/?rev=10&view=rev Author: norm_brandinger Date: 2007-05-09 09:40:21 -0700 (Wed, 09 May 2007) Log Message: ----------- added: etc/opencalea/opencalea.conf df_collector: socket fixes Modified Paths: -------------- src/calea.c src/common.h src/df_collector.c src/util.c src/util.h Modified: src/calea.c =================================================================== --- src/calea.c 2007-05-09 14:44:04 UTC (rev 9) +++ src/calea.c 2007-05-09 16:40:21 UTC (rev 10) @@ -126,7 +126,8 @@ int bytes_sent; if ( (bytes_sent = send ( *send_socket, packet, length, 0)) == -1 ) { - pdie ( "PacketSend:" ); + debug_5("PacketSend error: %s", strerror(errno)); + // pdie ( "PacketSend:" ); switch ( errno ) { case EHOSTUNREACH: case EHOSTDOWN: Modified: src/common.h =================================================================== --- src/common.h 2007-05-09 14:44:04 UTC (rev 9) +++ src/common.h 2007-05-09 16:40:21 UTC (rev 10) @@ -101,7 +101,7 @@ #endif #ifndef CmC_PORT -#define CmC_PORT 41815 +#define CmC_PORT 41820 #endif #ifndef DF_CONTROL_PORT Modified: src/df_collector.c =================================================================== --- src/df_collector.c 2007-05-09 14:44:04 UTC (rev 9) +++ src/df_collector.c 2007-05-09 16:40:21 UTC (rev 10) @@ -216,6 +216,15 @@ int id; char route_port[8]; + socklen_t socklen; + /* returned by Getsockopt */ + union sockval { + int i_sockval; + long l_sockval; + struct linger linger_sockval; + struct timeval timeval_sockval; + } sockval; + switch(msg->msgh.msgtype) { case MSGTYPE_NONE: @@ -329,14 +338,8 @@ } id = ntohs(msg->msgh.routeid); - inet_ntop (route[id].lea_addr.sin_family, &route[id].lea_addr.sin_addr.s_addr, addrstr, sizeof(addrstr)); - debug_5("df_collector: CmII packet -> route[%d] %s:%d", - id, - addrstr, - ntohs(route[id].lea_addr.sin_port)); - num_sent = sendto (route[id].fd, ((char *)msg + msg_len), msg->msgh.msglen, @@ -349,6 +352,8 @@ id, addrstr, ntohs(route[id].lea_addr.sin_port)); + socklen = sizeof(sockval); + Getsockopt(route[id].fd, SOL_SOCKET, SO_ERROR, &sockval, &socklen); } else { debug_5("df_collector: CmII packet -> route[%d] %s:%d %d bytes sent ", id, @@ -378,12 +383,8 @@ } id = ntohs(msg->msgh.routeid); + inet_ntop (route[id].lea_addr.sin_family, &route[id].lea_addr.sin_addr.s_addr, addrstr, sizeof(addrstr)); - debug_5("df_collector: CmC packet -> route[%d]=%d port:%d", - id, - route[id].fd, - ntohs(route[id].lea_addr.sin_port)); - num_sent = sendto (route[id].fd, ((char *)msg + msg_len), msg->msgh.msglen, @@ -396,6 +397,8 @@ id, addrstr, ntohs(route[id].lea_addr.sin_port)); + socklen = sizeof(sockval); + Getsockopt(route[id].fd, SOL_SOCKET, SO_ERROR, &sockval, &socklen); } else { debug_5("df_collector: CmC packet -> route[%d] %s:%d %d bytes sent ", id, @@ -648,9 +651,9 @@ FD_SET(CmII_tcpfd, &allset); FD_SET(CmII_udpfd, &allset); - FD_SET(CmC_tcpfd, &allset); - FD_SET(CmC_udpfd, &allset); - FD_SET(controlfd, &allset); + FD_SET(CmC_tcpfd, &allset); + FD_SET(CmC_udpfd, &allset); + FD_SET(controlfd, &allset); /* initialize the maximum file desctiptor for the select() */ maxfd = max(CmII_tcpfd, CmII_udpfd); Modified: src/util.c =================================================================== --- src/util.c 2007-05-09 14:44:04 UTC (rev 9) +++ src/util.c 2007-05-09 16:40:21 UTC (rev 10) @@ -433,6 +433,20 @@ * Setsockopt - set the socket options */ +int Getsockopt(int socket, int level, int option_name, void *option_value, socklen_t *option_len) { + int rc; + + rc = getsockopt(socket, level, option_name, option_value, option_len); + if (rc == -1) { + debug_5("Getsockopt error: %s", strerror(errno)); + } + return(rc); +} + +/** + * Setsockopt - set the socket options + */ + int Setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len) { int rc; @@ -486,7 +500,6 @@ char *trim_line(char *buf) { char *buf_ptr, *p2; - int i; if (buf) { Modified: src/util.h =================================================================== --- src/util.h 2007-05-09 14:44:04 UTC (rev 9) +++ src/util.h 2007-05-09 16:40:21 UTC (rev 10) @@ -57,6 +57,7 @@ int Connect(int socket, const struct sockaddr *address, socklen_t address_len); int Bind(int socket, const struct sockaddr *address, socklen_t address_len); int Listen(int socket, int backlog); +int Getsockopt(int socket, int level, int option_name, void *option_value, socklen_t *option_len); int Setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len); struct addrinfo *Getaddrinfo1st(const char *hostname, int port, int family, int socktype); int Gethostname(char *, size_t ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |