Modify

Opened 7 years ago

Last modified 2 years ago

#4787 new Patches

ASIO - adding support for accessing UDP control headers

Reported by: anonymous Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
Version: Boost 1.44.0 Severity: Problem
Keywords: Cc: saleyn@…, leon@…

Description

Attached patch implements ASIO support for accessing optional UDP control headers such as the timestamp information set with SO_TIMESTAMP.

Here are two ways of getting timestamp information using the new feature of the patch. Note that it works in synchronous and asynchronous mode.

ip::udp::socket sock; ... sock.set_option(ip::unicast::timestamp(true)); ... ip::udp::endpoint ep; sock.receive_from(buf, ep, bytes_transferred);

boost::asio::detail::io_control::siocgstamp tv1;

for (const cmsghdr* cmsg = ep.control_header_first();

cmsg;

cmsg = ep.control_header_next(cmsg)) { printf(" cmsg_len %zu: ", cmsg->cmsg_len); switch (cmsg->cmsg_level) {

case SOL_SOCKET:

switch (cmsg->cmsg_type) {

case SO_TIMESTAMP: {

const timeval *stamp =

ep.control_msg_data<const timeval*>(cmsg);

printf("SO_TIMESTAMP %ld.%06ld",

(long)stamp->tv_sec, (long)stamp->tv_usec);

tv1.set(*stamp); break;

} case SO_TIMESTAMPNS: {

const timespec* stamp =

ep.control_msg_data<const timespec*>(cmsg);

... break;

} default:

printf("type %d", cmsg->cmsg_type); break;

} break;

}

default:

printf("Level %d, Type %d", cmsg->cmsg_level,

cmsg->cmsg_type);

break;

}

}

Alternative way of getting the last datagram's kernel timestamp boost::asio::detail::io_control::siocgstamp tv; boost::system::error_code ec; boost::asio::detail::socket_ops::state_type client_state = 0; boost::asio::detail::socket_ops::ioctl(

a_sock.native(), client_state, tv.name(), tv.data(), ec);

Hope it can be included in the release.

Regards,

Serge

Attachments (5)

boost_1_44_0.asio.patch (7.4 KB) - added by saleyn@… 7 years ago.
Support of optional datagram control headers.
boost-ext.hpp (2.8 KB) - added by saleyn@… 7 years ago.
Implementation of timestamp supporting socket options.
boost_1_44_0.asio.2.patch (8.5 KB) - added by saleyn@… 7 years ago.
Please use this patch instead - apparently when I ported the patch from 1.41.0 to 1.44.0 I previously missed to add support for non_blocking mode in 1.44.0.
so_timestamping.1.53.0.patch (6.5 KB) - added by jason@… 4 years ago.
Updated patch for boost 1.53.0
so_timestamping.1.53.0.2.patch (6.6 KB) - added by jason@… 4 years ago.
Improvement to previous patch for 1.53.0. These patches change the existing interfaces by adding additional parameters.

Download all attachments as: .zip

Change History (11)

Changed 7 years ago by saleyn@…

Attachment: boost_1_44_0.asio.patch added

Support of optional datagram control headers.

Changed 7 years ago by saleyn@…

Attachment: boost-ext.hpp added

Implementation of timestamp supporting socket options.

Changed 7 years ago by saleyn@…

Attachment: boost_1_44_0.asio.2.patch added

Please use this patch instead - apparently when I ported the patch from 1.41.0 to 1.44.0 I previously missed to add support for non_blocking mode in 1.44.0.

comment:1 Changed 6 years ago by Leonid Evdokimov <leon@…>

Cc: leon@… added

comment:2 Changed 4 years ago by jason@…

Is there a problem with the patch? I ask because it's still not in the release and is 3 years old.

Jason

Changed 4 years ago by jason@…

Updated patch for boost 1.53.0

Changed 4 years ago by jason@…

Improvement to previous patch for 1.53.0. These patches change the existing interfaces by adding additional parameters.

comment:3 Changed 2 years ago by pdurkan@…

Is this patch working?

comment:4 Changed 2 years ago by jason@…

It worked for me. However, we no longer use the related code so I'm unlikely to track this patch much more.

Regards, Jason

comment:5 Changed 2 years ago by saleyn@…

Worked fine for me in 1.44.0. Haven't used that code since that version.

comment:6 Changed 2 years ago by rpopescu@…

Hello,

Why isn't this applied? We also would like support for SO_BUSY_POLL.

Thank you!

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain chris_kohlhoff.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.