2 * Mausezahn - A fast versatile traffic generator
3 * Copyright (C) 2008-2010 Herbert Haas
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License version 2 as published by the
7 * Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, see http://www.gnu.org/licenses/gpl-2.0.html
27 int launch_bpdu (struct cli_def
*cli
, const char *command
, char *argv
[], int argc
)
30 struct mops_ext_bpdu
* pd
;
32 if ( (strncmp(argv
[argc
-1],"?",2)==0) || (argc
>1) ) {
33 cli_print(cli
, "Launch a(nother) BPDU process:\n");
34 cli_print(cli
, "<CR> Per default a TCN-BPDU is sent.\r");
35 cli_print(cli
, "conf Use this keyword to emit configuration BPDUs\r");
36 cli_print(cli
, " (with this host as root bridge)\n");
41 if (mz_strcmp(argv
[0], "conf", 1)==0) conf
=1;
44 if ((clipkt
= mops_alloc_packet(mp_head
)) == NULL
) { // Problem, memory full?
45 cli_print(cli
, "Cannot allocate additional memory!\n");
49 strncpy (clipkt
->packet_name
, "sysBPDU", 7);
50 // OK, created a new packet
51 cli_print(cli
, "Allocated new packet %s at slot %i",clipkt
->packet_name
, clipkt
->id
);
52 mops_set_defaults(clipkt
);
53 if (mops_ext_add_pdesc (clipkt
, MOPS_BPDU
))
54 cli_print(cli
, "Cannot configure BPDU parameters!?\n");
56 clipkt
->use_ETHER
= 1;
59 clipkt
->ndelay
.tv_sec
= 2;
60 clipkt
->ndelay
.tv_nsec
= 0;
66 mops_set_conf(clipkt
);
67 if (mops_tx_simple (clipkt
)) {
68 cli_print(cli
, "Cannot create sending process.\r");
77 int launch_synflood (struct cli_def
*cli
, const char *command
, char *argv
[], int argc
)
80 int valid_ip
=0, valid_port
=0;
82 if ( (strncmp(argv
[argc
-1],"?",2)==0) || (argc
>2) || (argc
==0)) {
83 cli_print(cli
, "Launch a(nother) TCP SYN-Flood process:\n");
84 cli_print(cli
, "<dst-ip-addr> At least you must specify the destination IP address\r");
85 cli_print(cli
, "<dst-ip-addr> <port-nr> Optionally specify the destination port (default: range from 1-1023)\n");
89 if (mops_pdesc_ip (IP
, argv
[0])==0) { // check if format is really an IP address
92 cli_print(cli
, "Invalid IP address\n");
97 if (mz_strisnum(argv
[1])==0) {
98 cli_print(cli
, "Invalid port number\n");
101 valid_port
= (int) str2int(argv
[1]);
102 if (valid_port
>65535) {
103 cli_print(cli
, "Invalid port number\n");
109 if ((clipkt
= mops_alloc_packet(mp_head
)) == NULL
) { // Problem, memory full?
110 cli_print(cli
, "Cannot allocate additional memory!\n");
114 strncpy (clipkt
->packet_name
, "sysFlood_TCPSYN", 15);
115 // OK, created a new packet
116 cli_print(cli
, "Allocated new packet %s at slot %i",clipkt
->packet_name
, clipkt
->id
);
117 mops_set_defaults(clipkt
);
118 clipkt
->use_ETHER
= 1;
121 clipkt
->ip_proto
= 6;
123 clipkt
->ip_dst
= str2ip32(argv
[0]);
124 clipkt
->ip_src_israndom
=1;
126 clipkt
->dp
= valid_port
;
128 clipkt
->dp_isrange
=1;
130 clipkt
->dp_stop
=1023;
132 clipkt
->ndelay
.tv_sec
= 0;
133 clipkt
->ndelay
.tv_nsec
= 0;
134 mops_set_conf(clipkt
);
135 mops_tcp_add_option (clipkt
,64,0,0,0,0);
136 if (mops_tx_simple (clipkt
)) {
137 cli_print(cli
, "Cannot create sending process.\r");