I need to create a message and send it over a unix socket.
I have a socket defined as such: socket(AF_UNIX, SOCK_RAW, 0)
The header structure of the message/packet i want to send is as follows:
struct map_msghdr {
uint8_t map_msglen; /* to skip over non-understood messages */
uint8_t map_version; /* future binary compatibility */
uint16_t map_type; /* message type */
uint32_t map_flags; /* flags, incl. kern & message, e.g. DONE */
uint16_t map_addrs; /* bitmask identifying sockaddrs in msg */
uint16_t map_versioning;/* Mapping Version Number */
int map_rloc_count;/* Number of rlocs appended to the msg */
pid_t map_pid; /* identify sender */
int map_seq; /* for sender to identify action */
int map_errno; /* why failed */
};
I need to build a buffer containing the map_msghdr{}
structure followed by a socket address structure
. The socket address structure will have an ip address. How do i do this? Can you please show me an example? Thank you.