Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LARN
PRRT
Commits
0abdf589
Commit
0abdf589
authored
Jan 16, 2019
by
Andreas Schmidt
Browse files
+= sender parameters
parent
9f718d31
Pipeline
#3422
passed with stages
in 2 minutes and 7 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
prrt/sender.c
View file @
0abdf589
...
...
@@ -14,6 +14,8 @@ static char doc[] = "PRRT Sender";
static
struct
argp_option
options
[]
=
{
{
"target"
,
't'
,
"HOST"
,
0
,
"Target Host"
},
{
"port"
,
'p'
,
"PORT"
,
0
,
"Target Port"
},
{
"delay"
,
'd'
,
"DELAY"
,
0
,
"Target Delay"
},
{
"ipt"
,
'i'
,
"IPT"
,
0
,
"Inter-Packet-Time"
},
{
"local port"
,
'l'
,
"PORT"
,
0
,
"Local Port"
},
{
"rounds"
,
'r'
,
"ROUNDS"
,
0
,
"Rounds"
},
{
"output"
,
'o'
,
"FILE"
,
0
,
"Output to FILE instead of standard output"
},
...
...
@@ -26,6 +28,8 @@ typedef struct arguments
{
char
*
target
;
uint16_t
port
;
uint32_t
delay
;
uint32_t
ipt
;
uint16_t
local_port
;
uint16_t
rounds
;
char
*
outfile
;
...
...
@@ -48,6 +52,12 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state)
case
'p'
:
arguments
->
port
=
(
uint16_t
)
strtol
(
arg
,
&
pEnd
,
10
);
break
;
case
'd'
:
arguments
->
delay
=
(
uint32_t
)
strtol
(
arg
,
&
pEnd
,
10
);
break
;
case
'i'
:
arguments
->
ipt
=
(
uint32_t
)
strtol
(
arg
,
&
pEnd
,
10
);
break
;
case
'l'
:
arguments
->
local_port
=
(
uint16_t
)
strtol
(
arg
,
&
pEnd
,
10
);
break
;
...
...
@@ -86,6 +96,8 @@ int main(int argc, char **argv) {
struct
arguments
arguments
=
{
.
target
=
"127.0.0.1"
,
.
port
=
5000
,
.
delay
=
10
*
1000
*
1000
,
.
ipt
=
100
,
.
local_port
=
6000
,
.
rounds
=
127
,
.
outfile
=
"-"
,
...
...
@@ -111,7 +123,7 @@ int main(int argc, char **argv) {
#endif
s
=
PrrtSocket_create
(
1400
,
10
*
1000
*
1000
);
s
=
PrrtSocket_create
(
1400
,
arguments
.
delay
);
check
(
s
!=
NULL
,
"Socket create failed."
);
if
(
strcmp
(
arguments
.
hardwarestamping_interface
,
"-"
)
!=
0
)
{
...
...
@@ -145,7 +157,9 @@ int main(int argc, char **argv) {
j
++
;
// Send every 100us, as this is a sensible packet interval.
usleep_nano
(
100
);
if
(
arguments
.
ipt
!=
0
)
{
usleep_nano
(
arguments
.
ipt
);
}
}
sleep_nano
(
10
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment