Changeset 98
- Timestamp:
- 24.11.2002 20:44:49 (6 years ago)
- Location:
- trunk
- Files:
-
- 6 modified
-
INSTALL (modified) (2 diffs)
-
TODO (modified) (1 diff)
-
doc/ipfm.man (modified) (3 diffs)
-
source/init.c (modified) (7 diffs)
-
source/init.h (modified) (1 diff)
-
source/pcap.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/INSTALL
r48 r98 23 23 24 24 ./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc 25 26 Configure options 27 ----------------- 28 --enable-debug-messages For debug propose, enable debug messages. 29 This has a performance cost, so don't use it if not needed. 30 --enable-ip-check Check IP packets transmitted by libpcap for 31 validity : Version is 4, Length >= 5 and checksum is correct. This has 32 a performance cost and on some systems where IP packets are corrupt, 33 you may not want this option. When used with --enable-debug-messages, 34 ipfm will print a warning when dropping a packet. 35 Corrupt packets have been encountered on FreeBSD 4.4 + 3com or Intel 36 cards. 25 37 26 38 Notes … … 51 63 5. You must be root ... 52 64 * to install ipfm packages (.rpm and .deb) 53 * to run ipfm 65 * to run ipfm (except when using a tcpdump raw log file) 54 66 55 67 For any questions, remarks, requests, you can join us at ipfm@via.ecp.fr -
trunk/TODO
r97 r98 2 2 - RedHat pcap problem 3 3 - CPU optimisations in lists (Filter and Data) 4 - use a pcap filter to select IP packets (integrate patch from Brieuc and do a non regression test)5 4 - if no packets are received, ipfm does not dump its files. 6 5 - ./configure lex and yacc checks do not work as expected (if no yacc or bison is present, does not stop ./configure) 7 - add an ipfm.conf option to read packets from a file (to test IPFM without beeing root).8 - document ./configure options in INSTALL9 6 - indication of time of dump in the dump itself (add a comment) 10 7 -
trunk/doc/ipfm.man
r78 r98 31 31 ] [-h][--help] [-n][--nodaemon] [\-p 32 32 .I pid-file 33 ] [--pid33 ] [--pid 34 34 .I pid-file 35 ] [-r 36 .I file 37 ] [--readfrom 38 .I file 35 39 ] 36 40 … … 45 49 46 50 .B 47 ipfm is developed under Linux libc6 (Debian sid).51 ipfm is developed under Linux libc6 (Debian woody and sid). 48 52 49 53 It was reported to work under Linux libc5 (slackware) and libc6 (RedHat, … … 69 73 .IR __PIDFILE 70 74 is used. 75 .IP "-r file, --readfrom file" 76 .I file 77 is a raw tcpdump log file (créated by using tcpdump -w). When using this option, IPFM will ignore the "device" keyword in the configuration file, read the packets from 78 .I file 79 , dump logs and exit. 71 80 72 81 .SH SIGNALS -
trunk/source/init.c
r83 r98 65 65 extern int line; 66 66 extern char *device; 67 extern struct OptionsType Options;68 67 extern FILE *yyin; 69 68 extern int yyfailed; … … 74 73 printf("ipfm version %s\n\n", VERSION); 75 74 #ifdef __OS_LINUX__ 76 printf("\t-n, --nodaemon:\t do not run as a daemon\n");75 printf("\t-n, --nodaemon:\t\tdo not run as a daemon\n"); 77 76 printf("\t-c <file>, --config <file>:\tspecify an alternate configuration file\n"); 78 printf("\t-h, --help:\t display this help and exit\n");77 printf("\t-h, --help:\t\tdisplay this help and exit\n"); 79 78 printf("\t-p <file>, --pid <file>:\tspecify an alternate pid file\n"); 79 printf("\t-r <file>, --readfrom <file>:\tread packets from file (tcpdump raw format)\n"); 80 80 #else 81 81 printf("\t-n:\tdo not run as a daemon\n"); … … 83 83 printf("\t-h:\tdisplay this help and exit\n"); 84 84 printf("\t-p <file>:\tspecify an alternate pid file\n"); 85 printf("\t-r <file>:\tread packets from file (tcpdump raw format)\n"); 85 86 #endif /* __OS_LINUX__ */ 86 87 printf("\nPlease report bugs to ipfm@via.ecp.fr\n"); … … 100 101 { "nodaemon", 0, &run_as_daemon, 0 }, 101 102 { "pidfile", 1, NULL, 0 }, 103 { "readfrom", 1, NULL, 0 }, 102 104 { NULL, 0, NULL, 0 } 103 105 }; … … 106 108 Options.ConfigFile = NULL; 107 109 Options.PidFile = NULL; 108 109 #ifdef __OS_LINUX__ 110 while (EOF != (ch = getopt_long(argc, argv, "hnc:p:", long_options, 110 Options.ReadFromFile = NULL; 111 112 #ifdef __OS_LINUX__ 113 while (EOF != (ch = getopt_long(argc, argv, "hnc:p:r:", long_options, 111 114 &option_index))) { 112 115 #else 113 while (EOF != (ch = getopt(argc, argv, "hnc:p: "))) {116 while (EOF != (ch = getopt(argc, argv, "hnc:p:r:"))) { 114 117 #endif /* __OS_LINUX__ */ 115 118 switch(ch) { … … 129 132 case 3: 130 133 Options.PidFile = xstrdup(optarg); 134 break; 135 case 4: 136 Options.ReadFromFile = xstrdup(optarg); 131 137 break; 132 138 } … … 142 148 Options.PidFile = xstrdup(optarg); 143 149 break; 150 case 'r': 151 Options.ReadFromFile = xstrdup(optarg); 152 break; 144 153 case 'h': 145 154 case '?': -
trunk/source/init.h
r75 r98 28 28 char *ConfigFile; 29 29 char *PidFile; 30 char *ReadFromFile; 30 31 }; 31 32 -
trunk/source/pcap.c
r96 r98 49 49 extern int promisc; 50 50 extern char *device; 51 extern struct OptionsType Options; 51 52 52 53 /* Global variable. This forbids to open 2 pcap descriptors. */ … … 108 109 } 109 110 110 pcap_global_descriptor = pcap_open_live(device, SNAPLEN, promisc, 0, errbuf); 111 if (Options.ReadFromFile == NULL) { 112 pcap_global_descriptor = pcap_open_live(device, SNAPLEN, promisc, 113 0, errbuf); 114 } else { 115 pcap_global_descriptor = pcap_open_offline(Options.ReadFromFile, errbuf); 116 } 117 111 118 if (NULL == pcap_global_descriptor) { 112 119 fprintf(stderr, "[pcap] error opening pcap: %s\n", errbuf); … … 244 251 245 252 if (NULL == pcap_global_descriptor) { 246 fprintf(stderr, "[pcap] Can't read non-opened pcap descriptor ");253 fprintf(stderr, "[pcap] Can't read non-opened pcap descriptor\n"); 247 254 } 248 255 … … 252 259 if (NULL == packet) { 253 260 /* if pcap_next returns, there is an error on the link, so we close it and try to reopen it */ 254 DEBUG_MSG("pcap_next returned a null pointer [%s]\n", pcap_geterr(pcap_global_descriptor)); 261 DEBUG_MSG("pcap_next returned a null pointer [errormessage : %s]\n", pcap_geterr(pcap_global_descriptor)); 262 if (Options.ReadFromFile != NULL) { 263 /* we reached the end of the file ; dump and exit. */ 264 struct AllLogsType *pTempLog; 265 266 for (pTempLog = pAllLogs; 267 NULL != pTempLog; 268 pTempLog = pTempLog->Next) { 269 data_dump(pTempLog); 270 data_clear(pTempLog); 271 } 272 Exit(0); 273 } 255 274 closepcap(); 256 275 sleep(2); … … 266 285 if ( ((struct ip *) packet)->ip_hl < 5 || ((struct ip *) packet)->ip_v != 4 || iphdr_chksum(packet, ((struct ip *) packet)->ip_hl) != 0 ) { 267 286 /* Not an IP packet */ 268 DEBUG_MSG("getnextippkt : dropped a malformed IP packet ");287 DEBUG_MSG("getnextippkt : dropped a malformed IP packet\n"); 269 288 continue; 270 289 }
