Modifying IPv4 headers


 
Thread Tools Search this Thread
Special Forums IP Networking Modifying IPv4 headers
# 1  
Old 12-25-2009
Question 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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Disable IPV4

Hi im using Redhat Ver 6.4 is it possible to disable IPV4 and use only IPV6? how can i do that? thanks Guy (2 Replies)
Discussion started by: guy3145
2 Replies

2. Solaris

Ntp between ipv4 and ipv6

Hi, I am looking for a solution to configure ntp between ipv4 ( ntp server ) to ipv6 ( client) . I had google, but lot many sites suggest to have dual stock or tunnaling. my issue is I have client has only ipv6 address ans server has ipv4 address. is it possible to sync time,... (4 Replies)
Discussion started by: naveen.surisett
4 Replies

3. Programming

IPv4 string->int

Does anyone know how to convert a IP address given as 'string' into a 'u_int32_t'? Are there any build any functions already? (1 Reply)
Discussion started by: Freaky123
1 Replies

4. AIX

IPv6/IPv4 Only in AIX

Hi all, I have setup ipv6 in AIX machine using autoconf6 command. I was successfull in doing this. after execution of the command local link address was assigned to one of the interfaces (en1).But I have to setup the following environment as well. 1) Machine with only IPv6 support(IPv4... (0 Replies)
Discussion started by: ard
0 Replies

5. UNIX for Dummies Questions & Answers

Modifying headers

I have a FASTA file with thousands of sequences that looks something like this: I need to modfy the header in such way that everything after the dot is remove. Thus, I will end up with something like this: Thanks (1 Reply)
Discussion started by: Xterra
1 Replies

6. Shell Programming and Scripting

Merging of files with different headers to make combined headers file

Hi , I have a typical situation. I have 4 files and with different headers (number of headers is varible ). I need to make such a merged file which will have headers combined from all files (comman coluns should appear once only). For example - File 1 H1|H2|H3|H4 11|12|13|14 21|22|23|23... (1 Reply)
Discussion started by: marut_ashu
1 Replies

7. Shell Programming and Scripting

Remove text between headers while leaving headers intact

Hi, I'm trying to strip all lines between two headers in a file: ### BEGIN ### Text to remove, contains all kinds of characters ... Antispyware-Downloadserver.com (Germany)=http://www.antispyware-downloadserver.c om/updates/ Antispyware-Downloadserver.com #2... (3 Replies)
Discussion started by: Trones
3 Replies

8. AIX

convert ipv4 ti ipv6

hello i'm working on AIX 5300-05-03 P520 hacmp 5.4 when connection to the internet is going down , firewall down, my application work verey verey slowly!!! and on the sliffer output i'm got trys of my serevr to do convert from ipv4 ipv6 ( 0.0.2.0 and AAAAAAAA). some one have an idea why... (1 Reply)
Discussion started by: ariec
1 Replies

9. UNIX for Advanced & Expert Users

convert from ipv4 to ipv6

hello i'm working on aix 5300-05-03 hacmp ver 5.4 well my issue is that when firewall (gateway to internet ) goes down my machine start to work very very slowly!!! the output of the sniffer is that on the output card , my machine try to convert ipv4 to ipv6 0.0.2.0 my machine is not configure... (1 Reply)
Discussion started by: ariec
1 Replies

10. Programming

IPv4 LSRR Option

Hello Friends, I have one doubt regarding LSRR (Loose Source and Record Route) IP option. Whether IPv4 optoins will be processed only by Router or they can be processed by any PC within the network?? What i'm trying is: i'm giving a list of IP address in the option using setsockopt system call,... (1 Reply)
Discussion started by: aamirglb
1 Replies
Login or Register to Ask a Question
PIM(4)							   BSD Kernel Interfaces Manual 						    PIM(4)

NAME
pim -- Protocol Independent Multicast SYNOPSIS
options MROUTING options PIM #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netinet/ip_mroute.h> #include <netinet/pim.h> int getsockopt(int s, IPPROTO_IP, MRT_PIM, void *optval, socklen_t *optlen); int setsockopt(int s, IPPROTO_IP, MRT_PIM, const void *optval, socklen_t optlen); int getsockopt(int s, IPPROTO_IPV6, MRT6_PIM, void *optval, socklen_t *optlen); int setsockopt(int s, IPPROTO_IPV6, MRT6_PIM, const void *optval, socklen_t optlen); DESCRIPTION
PIM is the common name for two multicast routing protocols: Protocol Independent Multicast - Sparse Mode (PIM-SM) and Protocol Independent Multicast - Dense Mode (PIM-DM). PIM-SM is a multicast routing protocol that can use the underlying unicast routing information base or a separate multicast-capable routing information base. It builds unidirectional shared trees rooted at a Rendezvous Point (RP) per group, and optionally creates shortest-path trees per source. PIM-DM is a multicast routing protocol that uses the underlying unicast routing information base to flood multicast datagrams to all multi- cast routers. Prune messages are used to prevent future datagrams from propagating to routers with no group membership information. Both PIM-SM and PIM-DM are fairly complex protocols, though PIM-SM is much more complex. To enable PIM-SM or PIM-DM multicast routing in a router, the user must enable multicast routing and PIM processing in the kernel (see SYNOPSIS about the kernel configuration options), and must run a PIM-SM or PIM-DM capable user-level process. From developer's point of view, the programming guide described in the Programming Guide section should be used to control the PIM processing in the kernel. Programming Guide After a multicast routing socket is open and multicast forwarding is enabled in the kernel (see multicast(4)), one of the following socket options should be used to enable or disable PIM processing in the kernel. Note that those options require certain privilege (i.e., root privilege): /* IPv4 */ int v = 1; /* 1 to enable, or 0 to disable */ setsockopt(mrouter_s4, IPPROTO_IP, MRT_PIM, (void *)&v, sizeof(v)); /* IPv6 */ int v = 1; /* 1 to enable, or 0 to disable */ setsockopt(mrouter_s6, IPPROTO_IPV6, MRT6_PIM, (void *)&v, sizeof(v)); After PIM processing is enabled, the multicast-capable interfaces should be added (see multicast(4)). In case of PIM-SM, the PIM-Register virtual interface must be added as well. This can be accomplished by using the following options: /* IPv4 */ struct vifctl vc; memset(&vc, 0, sizeof(vc)); /* Assign all vifctl fields as appropriate */ ... if (is_pim_register_vif) vc.vifc_flags |= VIFF_REGISTER; setsockopt(mrouter_s4, IPPROTO_IP, MRT_ADD_VIF, (void *)&vc, sizeof(vc)); /* IPv6 */ struct mif6ctl mc; memset(&mc, 0, sizeof(mc)); /* Assign all mif6ctl fields as appropriate */ ... if (is_pim_register_vif) mc.mif6c_flags |= MIFF_REGISTER; setsockopt(mrouter_s6, IPPROTO_IPV6, MRT6_ADD_MIF, (void *)&mc, sizeof(mc)); Sending or receiving of PIM packets can be accomplished by opening first a ``raw socket'' (see socket(2)), with protocol value of IPPROTO_PIM: /* IPv4 */ int pim_s4; pim_s4 = socket(AF_INET, SOCK_RAW, IPPROTO_PIM); /* IPv6 */ int pim_s6; pim_s6 = socket(AF_INET6, SOCK_RAW, IPPROTO_PIM); Then, the following system calls can be used to send or receive PIM packets: sendto(2), sendmsg(2), recvfrom(2), recvmsg(2). SEE ALSO
getsockopt(2), recvfrom(2), recvmsg(2), sendmsg(2), sendto(2), setsockopt(2), socket(2), inet(4), intro(4), ip(4), multicast(4) STANDARDS
The PIM-SM protocol is specified in RFC 2362 (to be replaced by draft-ietf-pim-sm-v2-new-*). The PIM-DM protocol is specified in draft-ietf-pim-dm-new-v2-*). AUTHORS
The original IPv4 PIM kernel support for IRIX and SunOS-4.x was implemented by Ahmed Helmy (USC and SGI). Later the code was ported to vari- ous BSD flavors and modified by George Edmond Eddy (Rusty) (ISI), Hitoshi Asaeda (WIDE Project), and Pavlin Radoslavov (USC/ISI and ICSI). The IPv6 PIM kernel support was implemented by the KAME project (http://www.kame.net), and was based on the IPv4 PIM kernel support. This manual page was written by Pavlin Radoslavov (ICSI). BSD
September 4, 2003 BSD