Modifying IPv4 headers

Hi,

My query is:
I need to set the IPv4 header fields(like TOS, TTL, Precedence and Flags) in the linux kernel using the system calls.
I tried setting the fields using the setsockopt() call using sockets but it is not reflecting the actual IPv4 header fields. Is it possible to modify these fields? Please let me know the way of setting IPv4 header fields using the system calls.

Also, I can set the TTL field using /proc interface - /proc/sys/net/ipv4/ip_default_ttl. Anyone knows how to set for other header fields?

I tried googling but I couldn't find it. Please help me.

Thanks in advance,
Kiran.