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_rtp_version (struct cli_def
*cli
, const char *command
, char *argv
[], int argc
)
28 struct mops_ext_rtp
* pd
= clipkt
->p_desc
;
31 if ( (strcmp(argv
[argc
-1],"?")==0) || (argc
!=1)) {
32 cli_print(cli
, "Set the RTP version (0..3, default: v2).\n");
35 if (mz_strisnum(argv
[0])==0) {
36 cli_print(cli
, "Invalid number.\n");
39 v
= (int) str2int(argv
[0]);
41 cli_print(cli
, "Range exceeded (0..3).\n");
48 int cmd_rtp_padding (struct cli_def
*cli
, const char *command
, char *argv
[], int argc
)
50 struct mops_ext_rtp
* pd
= clipkt
->p_desc
;
53 if ( (strcmp(argv
[argc
-1],"?")==0) || (argc
!=1)) {
54 cli_print(cli
, "Sets or unsets the RTP padding flag (default: disabled).\n");
55 cli_print(cli
, "Use the keywords 'set' or 'unset'.\n");
56 sprintf(state
, "%s", (pd
->p
) ? "SET" : "UNSET");
57 cli_print(cli
, "Current state of the padding flag: %s\n",state
);
61 if (mz_strcmp(argv
[0], "set", 1)==0) {
63 } else if (mz_strcmp(argv
[0], "unset", 1)==0) {
67 cli_print(cli
, "Invalid keyword. Use 'set' or 'unset'.\n");
73 int cmd_rtp_xten (struct cli_def
*cli
, const char *command
, char *argv
[], int argc
)
75 struct mops_ext_rtp
* pd
= clipkt
->p_desc
;
78 if ( (strcmp(argv
[argc
-1],"?")==0) || (argc
!=1)) {
79 cli_print(cli
, "Sets or unsets the RTP extension flag (default: disabled).\n");
80 cli_print(cli
, "NOTE: This command only sets the extension flag in the RTP header.\r");
81 cli_print(cli
, "If you really want an extension header use the 'extension' command.\n");
82 cli_print(cli
, "Use the keywords 'set' or 'unset'.\n");
83 sprintf(state
, "%s", (pd
->x
) ? "SET" : "UNSET");
84 cli_print(cli
, "Current state of the extension flag: %s\n",state
);
88 if (mz_strcmp(argv
[0], "set", 1)==0) {
90 } else if (mz_strcmp(argv
[0], "unset", 1)==0) {
94 cli_print(cli
, "Invalid keyword. Use 'set' or 'unset'.\n");
101 int cmd_rtp_marker (struct cli_def
*cli
, const char *command
, char *argv
[], int argc
)
103 struct mops_ext_rtp
* pd
= clipkt
->p_desc
;
106 if ( (strcmp(argv
[argc
-1],"?")==0) || (argc
!=1)) {
107 cli_print(cli
, "Sets or unsets the RTP marker flag (default: disabled).\n");
108 cli_print(cli
, "Use the keywords 'set' or 'unset'.\n");
109 sprintf(state
, "%s", (pd
->m
) ? "SET" : "UNSET");
110 cli_print(cli
, "Current state of the marker flag: %s\n",state
);
113 if (mz_strcmp(argv
[0], "set", 1)==0) {
115 } else if (mz_strcmp(argv
[0], "unset", 1)==0) {
119 cli_print(cli
, "Invalid keyword. Use 'set' or 'unset'.\n");
125 int cmd_rtp_cc (struct cli_def
*cli
, const char *command
, char *argv
[], int argc
)
127 struct mops_ext_rtp
* pd
= clipkt
->p_desc
;
130 if ( (strcmp(argv
[argc
-1],"?")==0) || (argc
!=1)) {
131 cli_print(cli
, "Configure the RTP CSRC count (0..15, default: 0).\n");
132 cli_print(cli
, "NOTE: This command only configures the CSRC value in the RTP header.\r");
133 cli_print(cli
, "If you want to add a valid CSRC list use the 'csrc-list' command.\r");
134 cli_print(cli
, "The main purpose of this command is to create an invalid RTP packet.\r");
137 if (mz_strisnum(argv
[0])==0) {
138 cli_print(cli
, "Invalid number.\n");
141 cc
= (int) str2int(argv
[0]);
143 cli_print(cli
, "Range exceeded (0..15).\n");
151 int cmd_rtp_pt (struct cli_def
*cli
, const char *command
, char *argv
[], int argc
)
153 struct mops_ext_rtp
* pd
= clipkt
->p_desc
;
156 if ( (strcmp(argv
[argc
-1],"?")==0) || (argc
!=1)) {
157 cli_print(cli
, "Configure the RTP payload type (0..127, default: 8 (G.711, A-law)).\n");
158 // TODO: provide a list with well-known PT values
161 if (mz_strisnum(argv
[0])==0) {
162 cli_print(cli
, "Invalid number.\n");
165 pt
= (int) str2int(argv
[0]);
167 cli_print(cli
, "Range exceeded (0..127).\n");
174 int cmd_rtp_ssrc (struct cli_def
*cli
, const char *command
, char *argv
[], int argc
)
176 struct mops_ext_rtp
* pd
= clipkt
->p_desc
;
177 unsigned long long int ssrc
= 0xcafefeed;
179 if ( (strcmp(argv
[argc
-1],"?")==0) || (argc
!=1)) {
180 cli_print(cli
, "Configure the RTP SSRC (source identifier) (0..ffffffff, default: random!).\n");
181 cli_print(cli
, "NOTE: The SSRC value is used by another Mausezahn receiver to identify a original\r");
182 cli_print(cli
, "Mausezahn RTP stream. By default, Mausezahn receivers check for the magic number\r");
183 cli_print(cli
, "'cafebabe' (hex). Use another number for another RTP stream (e. g. bidirectional\r");
184 cli_print(cli
, "measurements).\n");
188 if (mz_strishex(argv
[0])==0) {
189 cli_print(cli
, "Invalid number.\n");
193 ssrc
= xstr2lint(argv
[0]);
194 if (ssrc
>0xffffffff) {
195 cli_print(cli
, "Range exceeded (0..ffffffff).\n");
198 pd
->ssrc
= (u_int32_t
) ssrc
;
203 int cmd_rtp_sqnr (struct cli_def
*cli
, const char *command
, char *argv
[], int argc
)
205 struct mops_ext_rtp
* pd
= clipkt
->p_desc
;
206 unsigned long long int sqnr
= 0;
208 if ( (strcmp(argv
[argc
-1],"?")==0) || (argc
!=1)) {
209 cli_print(cli
, "Configure the RTP initial sequence number (0..ffffffff, default: 0).\n");
213 if (mz_strishex(argv
[0])==0) {
214 cli_print(cli
, "Invalid number.\n");
217 sqnr
= xstr2lint(argv
[0]);
218 if (sqnr
>0xffffffff) {
219 cli_print(cli
, "Range exceeded (0..ffffffff).\n");
222 pd
->sqnr
= (u_int32_t
) sqnr
;
227 int cmd_rtp_time (struct cli_def
*cli
, const char *command
, char *argv
[], int argc
)
229 struct mops_ext_rtp
* pd
= clipkt
->p_desc
;
230 unsigned long long int t
= 0;
232 if ( (strcmp(argv
[argc
-1],"?")==0) || (argc
!=1)) {
233 cli_print(cli
, "Configure the RTP initial timestamp (0..ffffffff, default: 0).\n");
237 if (mz_strishex(argv
[0])==0) {
238 cli_print(cli
, "Invalid number.\n");
241 t
= xstr2lint(argv
[0]);
243 cli_print(cli
, "Range exceeded (0..ffffffff).\n");
246 pd
->tst
= (u_int32_t
) t
;
251 int cmd_rtp_extension (struct cli_def
*cli
, const char *command
, char *argv
[], int argc
)
253 struct mops_ext_rtp
* pd
= clipkt
->p_desc
;
255 if ( (strcmp(argv
[argc
-1],"?")==0) || (argc
!=1)) {
256 cli_print(cli
, "Configure an RTP extension header (default: none).\n");
257 cli_print(cli
, "Currently supported RTP extension headers:\n");
258 cli_print(cli
, "none Don't use any extension.\r");
259 cli_print(cli
, "mausezahn Use the new Mausezahn jitter/RTT measurement extension.\r");
260 cli_print(cli
, " (Note that this is incompatible with Mausezahn's direct\r");
261 cli_print(cli
, " mode jitter measurement.)\r");
262 cli_print(cli
, "\n");
266 if (mz_strcmp(argv
[0], "none", 1)==0) {
268 pd
->x
= 0; // X bit in header
269 } else if (mz_strcmp(argv
[0], "mausezahn", 1)==0) {
271 pd
->x
= 1; // X bit in header
272 pd
->ssrc
= 0xcafefeed;
274 cli_print(cli
, "Unknown keyword.\n");
279 mops_update_rtp (clipkt
); // re-build RTP packet (for proper show commands)
285 int cmd_rtp_source (struct cli_def
*cli
, const char *command
, char *argv
[], int argc
)
287 // struct mops_ext_rtp * pd = clipkt->p_desc;
289 if ( (strcmp(argv
[argc
-1],"?")==0) || (argc
!=1)) {
290 cli_print(cli
, "Specify a RTP media source.\n");
294 // [TODO] -- Allow to use /dev/dsp or a mixer source ...
296 cli_print(cli
, "Currently not supported.\n");
302 int cmd_rtp_cclist (struct cli_def
*cli
, const char *command
, char *argv
[], int argc
)
304 struct mops_ext_rtp
* pd
= clipkt
->p_desc
;
305 unsigned long long int csrc
=0;
310 if ((strcmp(argv
[argc
-1],"?")==0) || (argc
==0)) {
311 cli_print(cli
, "Specify a CSRC list consisting of 1-15 CSRC values.\r");
312 cli_print(cli
, "Each CSRC is a 4-byte value and must be specified in hexadecimal notation,\r");
313 cli_print(cli
, "hence each value must be within 0..ffffffff.\n");
318 cli_print(cli
, "The CSRC list must not exceed 15 items!\n");
322 for (i
=0; i
<n
; i
++) {
323 if (mz_strishex(argv
[i
])==0) {
324 sprintf(str
, "Parameter %i: Invalid number!", i
);
325 cli_print(cli
, "%s\n", str
);
328 csrc
= xstr2lint(argv
[i
]);
329 if (csrc
>0xffffffff) {
330 sprintf(str
, "Parameter %i: Range exceeded (0..ffffffff)", i
);
331 cli_print(cli
, "%s\n", str
);
334 pd
->csrc
[i
] = (u_int32_t
) csrc
;
336 pd
->cc
= n
; // this one can be accessed and modified to "wrong" values by the user