Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
tsn-measures
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
tsn-measures
Commits
6ce8b49a
Commit
6ce8b49a
authored
May 26, 2020
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix mistakes regarding timestamps configuration
parent
c73d8534
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
15 deletions
+25
-15
packet-exchange/src/send_packet.c
packet-exchange/src/send_packet.c
+25
-15
No files found.
packet-exchange/src/send_packet.c
View file @
6ce8b49a
...
@@ -41,9 +41,9 @@
...
@@ -41,9 +41,9 @@
#define MESSAGE ((uint32_t)0x00FACADE)
#define MESSAGE ((uint32_t)0x00FACADE)
#define NSEC_PER_SEC 1000000000
#define NSEC_PER_SEC 1000000000
static
int
process_socket_error_queue
(
int
fd
);
static
int
process_socket_error_queue
();
static
void
print_timestamps
(
struct
msghdr
*
msg
);
static
void
print_timestamps
(
struct
msghdr
*
msg
);
static
void
process_timestamps
(
int
sock
);
static
void
process_timestamps
(
int
recvmsg_flags
);
static
int
so_priority
=
3
;
static
int
so_priority
=
3
;
static
struct
sock_txtime
sk_txtime
;
static
struct
sock_txtime
sk_txtime
;
...
@@ -130,6 +130,8 @@ void send_udp_packet(int use_etf, int use_timestamps, uint64_t txtime,
...
@@ -130,6 +130,8 @@ void send_udp_packet(int use_etf, int use_timestamps, uint64_t txtime,
.
fd
=
fd
,
.
fd
=
fd
,
};
};
int
sendmsgerr
;
int
sendmsgerr
;
int
res
;
fd_set
readfs
;
memset
(
&
sin
,
0
,
sizeof
(
sin
));
memset
(
&
sin
,
0
,
sizeof
(
sin
));
sin
.
sin_family
=
AF_INET
;
sin
.
sin_family
=
AF_INET
;
...
@@ -163,34 +165,42 @@ void send_udp_packet(int use_etf, int use_timestamps, uint64_t txtime,
...
@@ -163,34 +165,42 @@ void send_udp_packet(int use_etf, int use_timestamps, uint64_t txtime,
error
(
EXIT_FAILURE
,
errno
,
"sendmsg failed, ret value: %d
\n
"
,
sendmsgerr
);
error
(
EXIT_FAILURE
,
errno
,
"sendmsg failed, ret value: %d
\n
"
,
sendmsgerr
);
if
(
use_timestamps
)
{
if
(
use_timestamps
)
{
#ifdef DEBUG
printf
(
"Polling for timestamps...
\n
"
);
FD_ZERO
(
&
readfs
);
#endif
FD_SET
(
fd
,
&
readfs
);
poll
(
&
poll_fd
,
1
,
0
);
process_timestamps
(
fd
);
res
=
select
(
fd
+
1
,
&
readfs
,
0
,
NULL
,
NULL
);
printf
(
"select returned: %d, %s
\n
"
,
res
,
res
<
0
?
strerror
(
errno
)
:
"success"
);
if
(
res
>
0
)
{
if
(
FD_ISSET
(
fd
,
&
readfs
))
printf
(
"ready for reading
\n
"
);
process_timestamps
(
MSG_ERRQUEUE
);
}
}
}
}
}
static
void
process_timestamps
(
int
sock
)
{
static
void
process_timestamps
(
int
recvmsg_flags
)
{
char
data
[
256
];
struct
msghdr
msg
;
struct
msghdr
msg
;
struct
iovec
entry
;
struct
iovec
entry
;
struct
sockaddr_in
from_addr
;
struct
{
struct
{
struct
cmsghdr
cm
;
struct
cmsghdr
cm
;
char
control
[
512
];
char
control
[
512
];
}
control
;
}
control
;
int
res
;
#ifdef DEBUG
printf
(
"process_timestamps
\n
"
);
#endif
memset
(
&
msg
,
0
,
sizeof
(
msg
));
memset
(
&
msg
,
0
,
sizeof
(
msg
));
msg
.
msg_iov
=
&
entry
;
msg
.
msg_iov
=
&
entry
;
msg
.
msg_iovlen
=
1
;
msg
.
msg_iovlen
=
1
;
entry
.
iov_base
=
data
;
entry
.
iov_len
=
sizeof
(
data
);
msg
.
msg_name
=
(
caddr_t
)
&
from_addr
;
msg
.
msg_namelen
=
sizeof
(
from_addr
);
msg
.
msg_control
=
&
control
;
msg
.
msg_control
=
&
control
;
msg
.
msg_controllen
=
sizeof
(
control
);
msg
.
msg_controllen
=
sizeof
(
control
);
if
(
recvmsg
(
sock
,
&
msg
,
MSG_DONTWAIT
)
==
-
1
)
{
if
(
recvmsg
(
fd
,
&
msg
,
recvmsg_flags
|
MSG_DONTWAIT
)
==
-
1
)
{
fprintf
(
stderr
,
"recvmsg failed"
);
fprintf
(
stderr
,
"recvmsg failed
\n
"
);
}
}
else
{
else
{
print_timestamps
(
&
msg
);
print_timestamps
(
&
msg
);
...
@@ -254,7 +264,7 @@ static void print_timestamps(struct msghdr *msg) {
...
@@ -254,7 +264,7 @@ static void print_timestamps(struct msghdr *msg) {
/*
/*
* Code from scheduled_tx_tools
* Code from scheduled_tx_tools
*/
*/
static
int
process_socket_error_queue
(
int
fd
)
{
static
int
process_socket_error_queue
()
{
uint8_t
msg_control
[
CMSG_SPACE
(
sizeof
(
struct
sock_extended_err
))];
uint8_t
msg_control
[
CMSG_SPACE
(
sizeof
(
struct
sock_extended_err
))];
unsigned
char
err_buffer
[
sizeof
(
tx_buffer
)];
unsigned
char
err_buffer
[
sizeof
(
tx_buffer
)];
struct
sock_extended_err
*
serr
;
struct
sock_extended_err
*
serr
;
...
...
Write
Preview
Markdown
is supported
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