[getting IP-header]How do I get the IP-header information

Hello, I'm trying to get the IP-header information from an IP-message sent using boost. I can get the message itself by using: void Receiver::wait_for_packet() { socket.async_receive_from(boost::asio::buffer(receive_buffer), remote_endpoint, boost::bind( &Receiver::handle_packet, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); } void Receiver::handle_packet(const boost::system::error_code& error, int bytes_transferred) { if (error) { //throw boost::system::system_error(error); } std::string message; for (int i = 0; i < bytes_transferred; i++) { message += receive_buffer[i]; } std::string payload(message); Packet packet; packet.set_payload(payload); listener->new_packet_received(packet); wait_for_packet(); } Where "message" is the body of the sent stuff. But how do I get to the IP-header things? I've been looking in doc/html/boost_asio/example/serialization/connection.hpp, but do not really get what to do. BR, /Mats Carlsson

On Thu, Oct 29, 2009 at 9:10 AM, Mats Carlsson
I'm trying to get the IP-header information from an IP-message sent using boost.
Which fields are you looking for? If you just want information about the remote (client) host, you can get that via the asio api when a connection is made. If you're looking for more than that, then you need "raw" sockets, a la libpcap. The "regular" sockets api is at a higher level than network/transport protocol headers. Jon

I'm not sure exactly what I need just yet. I think remote client info
is a good place to start.
The thing is that I do not understand where to look. The socket seems
to be created in this statement:
Receiver::Receiver(int port) :
socket(io_service,
boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), port)),
connected(false), listener(0) {
}
So is in "socket" somewhere?
/Mats
2009/10/29 Jonathan Franklin
On Thu, Oct 29, 2009 at 9:10 AM, Mats Carlsson
wrote: I'm trying to get the IP-header information from an IP-message sent using boost.
Which fields are you looking for? If you just want information about the remote (client) host, you can get that via the asio api when a connection is made.
If you're looking for more than that, then you need "raw" sockets, a la libpcap. The "regular" sockets api is at a higher level than network/transport protocol headers.
Jon _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

On Thu, Oct 29, 2009 at 10:30 AM, Mats Carlsson
So is in "socket" somewhere?
Once you have "accepted" a client connection in your "server", I think you can get the client host info by calling the tcp::socket::remote_endpoint() method. http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/reference/basic_str... You should probably check out some basic socket and TCP/IP resources to get a better idea of how sockets work w/ TCP/IP. Not sure what specific resource to recommend at this point. But you can't go wrong w/ the Stevens books. Jon
participants (2)
-
Jonathan Franklin
-
Mats Carlsson