2 * Mausezahn - A fast versatile traffic generator
3 * Copyright (C) 2008-2010 Herbert Haas
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License version 2 as published by the
7 * Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, see http://www.gnu.org/licenses/gpl-2.0.html
26 int cmd_igmpv2_genquery (struct cli_def
*cli
, char *command
, char *argv
[], int argc
)
30 if ( (strcmp(argv
[argc
-1],"?")==0) || (argc
>2) ) {
31 cli_print(cli
, "Configure a IGMPv2 general query.\n");
32 cli_print(cli
, "ARGUMENTS: [<MRT> [<checksum>]]\n");
33 cli_print(cli
, "<MRT> ... maximum response time in 100 msec units (default: 10 s)\r");
34 cli_print(cli
, "<checksum> ... user-defined checksum (usually wrong by intention) in \r");
35 cli_print(cli
, " hexadecimal notation (e. g. 'c7b3').\n");
40 if (mz_strisnum(argv
[0])==0) {
41 cli_print(cli
, "Maximum response time must only contain numbers!\n");
44 mrt
= (int) str2int(argv
[0]);
45 } else mrt
= 100; // default: 10 s
48 if (mz_strishex(argv
[1])==0) {
49 cli_print(cli
, "Checksum must only contain hexadecimal numbers!\n");
52 sum
= (int) xstr2int(argv
[1]);
54 cli_print(cli
, "Checksum must be a 2-byte value!\n");
60 clipkt
->ip_dst
= str2ip32("224.0.0.1");
62 clipkt
->ndelay
.tv_sec
= 125;
63 clipkt
->ndelay
.tv_nsec
= 0;
64 if (mops_create_igmpv2 (clipkt
, 0, IGMP_GENERAL_QUERY
, mrt
, sum
, 0))
65 cli_print(cli
, "Invalid parameters!\n");
71 int cmd_igmpv2_specquery (struct cli_def
*cli
, char *command
, char *argv
[], int argc
)
77 if ( (strcmp(argv
[argc
-1],"?")==0) || (argc
>3) ) {
78 cli_print(cli
, "Configure a IGMPv2 group-specific query.\n");
79 cli_print(cli
, "ARGUMENTS: <IP-address> [<MRT> [<checksum>]]\n");
80 cli_print(cli
, "<IP-Address> ... multicast group to be queried (can be ANY IP address!)\r");
81 cli_print(cli
, "<MRT> ... maximum response time in 100 msec units (default: 10 s)\r");
82 cli_print(cli
, "<checksum> ... user-defined checksum (usually wrong by intention) in \r");
83 cli_print(cli
, " hexadecimal notation (e. g. 'c7b3').\n");
89 cli_print(cli
, "You must at least specify the group address\n");
94 if (mops_pdesc_ip (IP
, argv
[0])==0) // check if format is really an IP address
95 mip
= str2ip32(argv
[0]);
97 cli_print(cli
, "Invalid IP address\n");
103 if (mz_strisnum(argv
[1])==0) {
104 cli_print(cli
, "Maximum response time must only contain numbers!\n");
107 mrt
= (int) str2int(argv
[1]);
111 if (mz_strishex(argv
[2])==0) {
112 cli_print(cli
, "Checksum must only contain hexadecimal numbers!\n");
115 sum
= (int) xstr2int(argv
[2]);
117 cli_print(cli
, "Checksum must be a 2-byte value!\n");
122 clipkt
->ip_dst
= mip
;
124 clipkt
->ndelay
.tv_sec
= 125;
125 clipkt
->ndelay
.tv_nsec
= 0;
126 if (mops_create_igmpv2 (clipkt
, 0, IGMP_GSPEC_QUERY
, mrt
, sum
, mip
))
127 cli_print(cli
, "Invalid parameters!\n");
136 int cmd_igmpv2_report (struct cli_def
*cli
, char *command
, char *argv
[], int argc
)
142 if ( (strcmp(argv
[argc
-1],"?")==0) || (argc
>2) || (argc
==0)) {
143 cli_print(cli
, "Configure a IGMPv2 membership report.\n");
144 cli_print(cli
, "ARGUMENTS: <IP-Address> [<checksum>]\n");
145 cli_print(cli
, "<IP-Address> ... multicast group address to be reported (but ANY IP\r");
146 cli_print(cli
, " address allowed, Mausezahn is really generous...)\r");
147 cli_print(cli
, "<checksum> ... user-defined checksum (usually wrong by intention) in \r");
148 cli_print(cli
, " hexadecimal notation (e. g. 'c7b3').\n");
154 if (mops_pdesc_ip (IP
, argv
[0])==0) // check if format is really an IP address
155 mip
= str2ip32(argv
[0]);
157 cli_print(cli
, "Invalid IP address\n");
163 if (mz_strishex(argv
[1])==0) {
164 cli_print(cli
, "Checksum must only contain hexadecimal numbers!\n");
167 sum
= (int) xstr2int(argv
[1]);
169 cli_print(cli
, "Checksum must be a 2-byte value!\n");
174 clipkt
->ip_dst
= mip
;
176 clipkt
->ndelay
.tv_sec
= 1;
177 clipkt
->ndelay
.tv_nsec
= 0;
179 if (mops_create_igmpv2 (clipkt
, 0, IGMP_V2_REPORT
, 0, sum
, mip
))
180 cli_print(cli
, "Invalid parameters!\n");
186 int cmd_igmpv2_leave (struct cli_def
*cli
, char *command
, char *argv
[], int argc
)
192 if ( (strcmp(argv
[argc
-1],"?")==0) || (argc
>2) || (argc
==0)) {
193 cli_print(cli
, "Configure a IGMPv2 leave group message.\n");
194 cli_print(cli
, "ARGUMENTS: <IP-Address> [<checksum>]\n");
195 cli_print(cli
, "<IP-Address> ... multicast group address that should be left; use\r");
196 cli_print(cli
, " the special address 0.0.0.0 for a 'general leave'\r");
197 cli_print(cli
, "<checksum> ... user-defined checksum (usually wrong by intention) in \r");
198 cli_print(cli
, " hexadecimal notation (e. g. 'c7b3').\n");
204 if (mops_pdesc_ip (IP
, argv
[0])==0) // check if format is really an IP address
205 mip
= str2ip32(argv
[0]);
207 cli_print(cli
, "Invalid IP address\n");
213 if (mz_strishex(argv
[1])==0) {
214 cli_print(cli
, "Checksum must only contain hexadecimal numbers!\n");
217 sum
= (int) xstr2int(argv
[1]);
219 cli_print(cli
, "Checksum must be a 2-byte value!\n");
224 clipkt
->ip_dst
= str2ip32("224.0.0.2");
226 clipkt
->ndelay
.tv_sec
= 1;
227 clipkt
->ndelay
.tv_nsec
= 0;
229 if (mops_create_igmpv2 (clipkt
, 0, IGMP_LEAVE
, 0, sum
, mip
))
230 cli_print(cli
, "Invalid parameters!\n");
239 int cmd_igmpv1_query (struct cli_def
*cli
, char *command
, char *argv
[], int argc
)
243 if ( (strcmp(argv
[argc
-1],"?")==0) || (argc
>1) ) {
244 cli_print(cli
, "Configure a IGMPv1 query.\n");
245 cli_print(cli
, "OPTIONAL ARGUMENT: [<checksum>]\n");
246 cli_print(cli
, "<checksum> ... user-defined checksum (usually wrong by intention) in \r");
247 cli_print(cli
, " hexadecimal notation (e. g. 'c7b3').\n");
252 if (mz_strishex(argv
[0])==0) {
253 cli_print(cli
, "Checksum must only contain hexadecimal numbers!\n");
256 sum
= (int) xstr2int(argv
[0]);
258 cli_print(cli
, "Checksum must be a 2-byte value!\n");
263 clipkt
->ip_dst
= str2ip32("224.0.0.1");
265 clipkt
->ndelay
.tv_sec
= 125;
266 clipkt
->ndelay
.tv_nsec
= 0;
267 if (mops_create_igmpv2 (clipkt
, 0, IGMP_GENERAL_QUERY
, 0, sum
, 0))
268 cli_print(cli
, "Invalid parameters!\n");
274 int cmd_igmpv1_report (struct cli_def
*cli
, char *command
, char *argv
[], int argc
)
280 if ( (strcmp(argv
[argc
-1],"?")==0) || (argc
>2) || (argc
==0)) {
281 cli_print(cli
, "Configure a IGMPv1 membership report.\n");
282 cli_print(cli
, "ARGUMENTS: <IP-Address> [<checksum>]\n");
283 cli_print(cli
, "<IP-Address> ... multicast group address to be reported (but ANY IP\r");
284 cli_print(cli
, " address allowed, Mausezahn is really generous...)\r");
285 cli_print(cli
, "<checksum> ... user-defined checksum (usually wrong by intention) in \r");
286 cli_print(cli
, " hexadecimal notation (e. g. 'c7b3').\n");
292 if (mops_pdesc_ip (IP
, argv
[0])==0) // check if format is really an IP address
293 mip
= str2ip32(argv
[0]);
295 cli_print(cli
, "Invalid IP address\n");
301 if (mz_strishex(argv
[1])==0) {
302 cli_print(cli
, "Checksum must only contain hexadecimal numbers!\n");
305 sum
= (int) xstr2int(argv
[1]);
307 cli_print(cli
, "Checksum must be a 2-byte value!\n");
312 clipkt
->ip_dst
= mip
;
314 clipkt
->ndelay
.tv_sec
= 1;
315 clipkt
->ndelay
.tv_nsec
= 0;
317 if (mops_create_igmpv2 (clipkt
, 0, IGMP_V1_REPORT
, 0, sum
, mip
))
318 cli_print(cli
, "Invalid parameters!\n");