2 * Mausezahn - A fast versatile traffic generator
3 * Copyright (C) 2008 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
25 int transmit (struct cli_def
*cli
, char *command
, char *argv
[], int argc
)
34 for (i
=1; i
<argc
; i
++)
36 if ((strlen(argv
[i
])+strlen(argstr
))>10000)
38 cli_print(cli
, "Argument list too long!\n");
41 if (strncmp(argv
[i
], "?", 1)==0)
43 strcat(argstr
, ",help");
46 strncat(argstr
, argv
[i
], 5000); // TODO: This is ugly!
48 // TEST: cli_print(cli, "argc=%i, got '%s'\n", argc, argstr);
52 if (argv
[0] == NULL
) // raw hex string given
56 else if (strcmp(argv
[0],"arp")==0)
60 else if (strcmp(argv
[0],"bpdu")==0)
64 else if (strcmp(argv
[0],"ip")==0)
68 else if (strcmp(argv
[0],"udp")==0)
72 else if (strcmp(argv
[0],"icmp")==0)
76 else if (strcmp(argv
[0],"tcp")==0)
80 else if (strcmp(argv
[0],"dns")==0)
84 else if (strcmp(argv
[0],"cdp")==0)
88 else if (strcmp(argv
[0],"syslog")==0)
92 else if (strcmp(argv
[0],"lldp")==0)
95 tx
.packet_mode
=0; // create whole frame by ourself
97 else if (strcmp(argv
[0],"rtp")==0)
101 else if (strcmp(argv
[0],"raw")==0)
103 strncpy(tx
.arg_string
, argstr
, MAX_PAYLOAD_SIZE
);
106 else if (strcmp(argv
[0],"?")==0)
109 "| The following packet types are currently implemented:\n"
111 "| arp ... sends ARP packets\n"
112 "| bpdu ... sends BPDU packets (STP)\n"
113 "| cdp ... sends CDP messages\n"
114 "| ip ... sends IPv4 packets\n"
115 "| udp ... sends UDP datagrams\n"
116 "| tcp ... sends TCP segments\n"
117 "| icmp ... sends ICMP messages\n"
118 "| dns ... sends DNS messages\n"
119 "| rtp ... sends RTP datagrams\n"
120 "| syslog ... sends Syslog messages\n"
121 "| lldp ... sends LLDP datagrams\n"
123 "| raw ... raw layer 2 mode (specify whole frame in hex)\n"
130 cli_print(cli
, "Unknown packet type '%s'\r", argv
[0]);
136 strncpy(tx
.arg_string
, argstr
, MAX_PAYLOAD_SIZE
);