1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
/*
Copyright (C) 2006 Renaissance Technologies Corp.
main developer: HP Wei <hp@rentec.com>
Copyright (C) 2005 Renaissance Technologies Corp.
Copyright (C) 2001 Renaissance Technologies Corp.
main developer: HP Wei <hp@rentec.com>
Codes in this file are extracted and modified from multicatcher.c.
Copyright (C) 2000 Aaron Hillegass <aaron@classmax.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "rttmain.h"
char * my_MCAST_ADDR = MCAST_ADDR;
int my_FLOW_PORT = FLOW_PORT;
int my_PORT = PORT;
char * my_IFname = MCAST_IF;
void usage()
{
fprintf(stderr,
"rttcatcher (to receive pages on the target. version %s\n"
" Option list:\n"
" [ -v flag to turn on verbose]\n"
" -------- mcast options --------------------------------------\n"
" [ -A <my_mcast_address default=%s)> ]\n"
" [ -P <my_PORT default=%d> ]\n"
" [ -I <my_MCAST_IF default=NULL> ]\n",
VERSION, MCAST_ADDR, PORT);
}
int main(int argc, char *argv[])
{
int old_mode; /* hp: from char to int for mode */
int mode;
int c;
verbose = 0;
while ((c = getopt(argc, argv, "vA:P:I:")) != EOF) {
switch (c) {
case 'v':
verbose = 1;
break;
case 'A':
my_MCAST_ADDR = optarg;
break;
case 'P':
my_PORT = atoi(optarg);
my_FLOW_PORT = my_PORT -1;
break;
case 'I':
my_IFname = optarg;
break;
case '?':
usage();
exit(-1);
}
}
init_page_reader();
init_complaint_sender();
/* initialize random numbers */
srand(time(NULL) + getpid());
/* Wait forever if necessary for first packet */
set_delay(0, -1);
mode = old_mode = TEST; /* hp: add mode */
while(1) { /* loop for all incoming pages */
if (verbose)
fprintf(stderr, "Starting listen loop with mode %d\n", mode);
mode = read_handle_page();
if (verbose) fprintf(stderr, "in mode %d\n", mode);
if (mode == ALL_DONE_CMD) break;
/* got no data? */
if (mode == TIMED_OUT) {
if (verbose) fprintf(stderr, "*");
continue;
} /* end if TIMED_OUT */
/* changing modes? */
if ((old_mode != SENDING_DATA) && (mode == SENDING_DATA)){
/* Taking data, wait at least 3 to 8 seconds */
set_delay( 3 + rand() % 8, 200);
if (verbose) fprintf(stderr, "Receiving data\n");
old_mode = mode;
continue;
}
/* all other modes */
old_mode = mode;
} /* end of incoming page loop */
if (verbose) fprintf(stderr, "Done!\n");
return 0;
}
|