c - How to convert SOCK_DGRAM to SOCK_RAW? -
i'm working on open source sock_dgram used send rtp packets.
like this:
int sock = socket(af, sock_dgram, 0);
but i'm supposed use same socket sock_raw send udp packets prepare.
is possible convert udp socket raw socket?
if possible how can done?
thanks in advance
i don't know why said need use same socket
, otherwise, can follow below steps transfer packet on raw
socket.
- create
socket
usingsock_raw
. - define , populate ip header [
struct ipheader
] - define , populate udp header [
struct udphdr
] - set socket not use system (kernel) provied header [
setsockopt()
ip_hdrincl
as1
] - send buffer [
sendto()
]
you can find nice tutorials (and maybe sample codes, too) here.
Comments
Post a Comment