Welcome to Soft32 Linux Forums!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

getting path mtu (PMTU)

 
   Soft32 Home -> Linux -> App Development RSS
Next:  Laufwerk einbinden  
Author Message
markryde

External


Since: Nov 27, 2008
Posts: 8



(Msg. 1) Posted: Thu Jun 18, 2009 4:22 am
Post subject: getting path mtu (PMTU)
Archived from groups: comp>os>linux>development>apps (more info?)

Hello,
I am trying to get PMTU of a connected socket thus:
....
res = getsockopt(s,SOL_IP, IP_MTU, &mtu, &mtulen);
....
The problem is that I get a compilation error about IP_MTU. I grepped
under /usr/include. But the thing is that I found it only in linux/
in.h. Why is that so ?
Trying to add #include <linux/in.h> in my program (which is a user
space application) gives compilation error. The linux/in.h file is a
kernel header and it
intended to be used only in kernel modules.

If, however, you look at man 7 ip, you will
see this:
....
....
IP_MTU Retrieve the current known path MTU of the current socket.
Only
valid when the socket has been connected. Returns an
integer.
Only valid as a getsockopt(2).
....

So the system should support such a call.
I want to add that I use quite a new os
(Fedora 10).

Any ideas ?
Regards,
MR
Back to top
Login to vote
David Schwartz

External


Since: Apr 25, 2007
Posts: 134



(Msg. 2) Posted: Thu Jun 18, 2009 4:59 am
Post subject: Re: getting path mtu (PMTU) [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Jun 18, 4:22 am, "markr...@gmail.com" <markr... RemoveThis @gmail.com> wrote:
> Hello,
>    I am trying to get PMTU of a connected socket thus:
> ...
>          res = getsockopt(s,SOL_IP, IP_MTU, &mtu, &mtulen);
> ...
> The problem is that I get a compilation error about IP_MTU. I grepped
> under /usr/include. But the thing is that I found it only in linux/
> in.h. Why is that so ?

Because otherwise code that tried to use 'IP_MTU' to mean something
else would break.

> Trying to add #include <linux/in.h> in my program (which is a user
> space application) gives compilation error. The linux/in.h file is a
> kernel header and it
> intended to be used only in kernel modules.

Can you paste the precise error?

In any event, you can just do what everyone else does:
#define IP_MTU 14

DS
Back to top
Login to vote
markryde

External


Since: Nov 27, 2008
Posts: 8



(Msg. 3) Posted: Thu Jun 18, 2009 7:00 am
Post subject: Re: getting path mtu (PMTU) [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thanks a lot !

With these includes, I get the following errors:
#include <linux/in.h>
#include <stdlib.h>

#include <netdb.h>
#include <string.h>
#include <stdio.h>

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>

#include <signal.h>

In file included from /usr/include/stdlib.h:320,
from udpnochecksum.c:4:
/usr/include/sys/types.h:46: error: conflicting types for ‘loff_t’
/usr/include/linux/types.h:30: error: previous declaration of ‘loff_t’
was here
/usr/include/sys/types.h:62: error: conflicting types for ‘dev_t’
/usr/include/linux/types.h:13: error: previous declaration of ‘dev_t’
was here
In file included from /usr/include/sys/types.h:133,
from /usr/include/stdlib.h:320,
from udpnochecksum.c:4:
/usr/include/time.h:105: error: conflicting types for ‘timer_t’
/usr/include/linux/types.h:22: error: previous declaration of
‘timer_t’ was here
In file included from /usr/include/stdlib.h:320,
from udpnochecksum.c:4:
/usr/include/sys/types.h:198: error: conflicting types for ‘int64_t’
/usr/include/linux/types.h:98: error: previous declaration of
‘int64_t’ was here
/usr/include/sys/types.h:204: error: conflicting types for ‘u_int64_t’
/usr/include/linux/types.h:97: error: previous declaration of
‘u_int64_t’ was here
In file included from /usr/include/sys/types.h:220,
from /usr/include/stdlib.h:320,
from udpnochecksum.c:4:
/usr/include/sys/select.h:78: error: conflicting types for ‘fd_set’
/usr/include/linux/types.h:12: error: previous declaration of ‘fd_set’
was here
In file included from /usr/include/stdlib.h:320,
from udpnochecksum.c:4:
/usr/include/sys/types.h:235: error: conflicting types for ‘blkcnt_t’
/usr/include/linux/types.h:124: error: previous declaration of
‘blkcnt_t’ was here
In file included from /usr/include/netinet/in.h:24,
from /usr/include/netdb.h:28,
from udpnochecksum.c:6:
/usr/include/stdint.h:56: error: conflicting types for ‘uint64_t’
/usr/include/linux/types.h:96: error: previous declaration of
‘uint64_t’ was here
In file included from /usr/include/sys/uio.h:29,
from /usr/include/sys/socket.h:28,
from /usr/include/netinet/in.h:25,
from /usr/include/netdb.h:28,
from udpnochecksum.c:6:
/usr/include/bits/uio.h:45: error: redefinition of ‘struct iovec’
In file included from /usr/include/sys/socket.h:36,
from /usr/include/netinet/in.h:25,
from /usr/include/netdb.h:28,
from udpnochecksum.c:6:
/usr/include/bits/socket.h:149: error: redefinition of ‘struct
sockaddr’
/usr/include/bits/socket.h:162: error: redefinition of ‘struct
__kernel_sockaddr_storage’
/usr/include/bits/socket.h:172: error: expected identifier before
numeric constant
/usr/include/bits/socket.h:220: error: redefinition of ‘struct msghdr’
/usr/include/bits/socket.h:238: error: redefinition of ‘struct
cmsghdr’
/usr/include/bits/socket.h:267: error: conflicting types for
‘__cmsg_nxthdr’
/usr/include/linux/socket.h:128: error: previous definition of
‘__cmsg_nxthdr’ was here
/usr/include/bits/socket.h:296: error: expected identifier before
numeric constant
/usr/include/bits/socket.h:375: error: redefinition of ‘struct linger’
In file included from /usr/include/netdb.h:28,
from udpnochecksum.c:6:
/usr/include/netinet/in.h:34: error: redeclaration of enumerator
‘IPPROTO_IP’
/usr/include/linux/in.h:26: error: previous definition of ‘IPPROTO_IP’
was here
/usr/include/netinet/in.h:38: error: redeclaration of enumerator
‘IPPROTO_ICMP’
/usr/include/linux/in.h:27: error: previous definition of
‘IPPROTO_ICMP’ was here
/usr/include/netinet/in.h:40: error: redeclaration of enumerator
‘IPPROTO_IGMP’
/usr/include/linux/in.h:28: error: previous definition of
‘IPPROTO_IGMP’ was here
/usr/include/netinet/in.h:42: error: redeclaration of enumerator
‘IPPROTO_IPIP’
/usr/include/linux/in.h:29: error: previous definition of
‘IPPROTO_IPIP’ was here
/usr/include/netinet/in.h:44: error: redeclaration of enumerator
‘IPPROTO_TCP’
/usr/include/linux/in.h:30: error: previous definition of
‘IPPROTO_TCP’ was here
/usr/include/netinet/in.h:46: error: redeclaration of enumerator
‘IPPROTO_EGP’
/usr/include/linux/in.h:31: error: previous definition of
‘IPPROTO_EGP’ was here
/usr/include/netinet/in.h:48: error: redeclaration of enumerator
‘IPPROTO_PUP’
/usr/include/linux/in.h:32: error: previous definition of
‘IPPROTO_PUP’ was here
/usr/include/netinet/in.h:50: error: redeclaration of enumerator
‘IPPROTO_UDP’
/usr/include/linux/in.h:33: error: previous definition of
‘IPPROTO_UDP’ was here
/usr/include/netinet/in.h:52: error: redeclaration of enumerator
‘IPPROTO_IDP’
/usr/include/linux/in.h:34: error: previous definition of
‘IPPROTO_IDP’ was here
/usr/include/netinet/in.h:56: error: redeclaration of enumerator
‘IPPROTO_IPV6’
/usr/include/linux/in.h:39: error: previous definition of
‘IPPROTO_IPV6’ was here
/usr/include/netinet/in.h:62: error: redeclaration of enumerator
‘IPPROTO_RSVP’
/usr/include/linux/in.h:36: error: previous definition of
‘IPPROTO_RSVP’ was here
/usr/include/netinet/in.h:64: error: redeclaration of enumerator
‘IPPROTO_GRE’
/usr/include/linux/in.h:37: error: previous definition of
‘IPPROTO_GRE’ was here
/usr/include/netinet/in.h:66: error: redeclaration of enumerator
‘IPPROTO_ESP’
/usr/include/linux/in.h:41: error: previous definition of
‘IPPROTO_ESP’ was here
/usr/include/netinet/in.h:68: error: redeclaration of enumerator
‘IPPROTO_AH’
/usr/include/linux/in.h:42: error: previous definition of ‘IPPROTO_AH’
was here
/usr/include/netinet/in.h:80: error: redeclaration of enumerator
‘IPPROTO_PIM’
/usr/include/linux/in.h:44: error: previous definition of
‘IPPROTO_PIM’ was here
/usr/include/netinet/in.h:82: error: redeclaration of enumerator
‘IPPROTO_COMP’
/usr/include/linux/in.h:46: error: previous definition of
‘IPPROTO_COMP’ was here
/usr/include/netinet/in.h:84: error: redeclaration of enumerator
‘IPPROTO_SCTP’
/usr/include/linux/in.h:47: error: previous definition of
‘IPPROTO_SCTP’ was here
/usr/include/netinet/in.h:86: error: redeclaration of enumerator
‘IPPROTO_RAW’
/usr/include/linux/in.h:50: error: previous definition of
‘IPPROTO_RAW’ was here
/usr/include/netinet/in.h:89: error: redeclaration of enumerator
‘IPPROTO_MAX’
/usr/include/linux/in.h:52: error: previous definition of
‘IPPROTO_MAX’ was here
/usr/include/netinet/in.h:139: error: redefinition of ‘struct in_addr’
/usr/include/netinet/in.h:222: error: redefinition of ‘struct
sockaddr_in’
/usr/include/netinet/in.h:248: error: redefinition of ‘struct ip_mreq’
/usr/include/netinet/in.h:257: error: redefinition of ‘struct
ip_mreq_source’
/usr/include/netinet/in.h:284: error: redefinition of ‘struct
group_req’
/usr/include/netinet/in.h:293: error: redefinition of ‘struct
group_source_req’
/usr/include/netinet/in.h:307: error: redefinition of ‘struct
ip_msfilter’
/usr/include/netinet/in.h:328: error: redefinition of ‘struct
group_filter’
In file included from /usr/include/netinet/in.h:352,
from /usr/include/netdb.h:28,
from udpnochecksum.c:6:
/usr/include/bits/in.h:93: error: redefinition of ‘struct ip_mreqn’
/usr/include/bits/in.h:101: error: redefinition of ‘struct in_pktinfo’


Any ideas ?

MR


On Jun 18, 2:59 pm, David Schwartz <dav....TakeThisOut@webmaster.com> wrote:
> On Jun 18, 4:22 am, "markr...@gmail.com" <markr....TakeThisOut@gmail.com> wrote:
>
> > Hello,
> >    I am trying to get PMTU of a connected socket thus:
> > ...
> >          res = getsockopt(s,SOL_IP, IP_MTU, &mtu, &mtulen);
> > ...
> > The problem is that I get a compilation error about IP_MTU. I grepped
> > under /usr/include. But the thing is that I found it only in linux/
> > in.h. Why is that so ?
>
> Because otherwise code that tried to use 'IP_MTU' to mean something
> else would break.
>
> > Trying to add #include <linux/in.h> in my program (which is a user
> > space application) gives compilation error. The linux/in.h file is a
> > kernel header and it
> > intended to be used only in kernel modules.
>
> Can you paste the precise error?
>
> In any event, you can just do what everyone else does:
> #define IP_MTU 14
>
> DS
Back to top
Login to vote
Display posts from previous:   
Related Topics:
How can i register a link protocol for browsers - I want to add an action to the system so that every time a user clicks in a link with for example ..

storing the data in ln2440 target board memory - hai.. i using the target board ln2440sbc..and linux OS.. (16Mb flash and 32Mb sdram) i have cross compiled and porte...

GTK run error - hi i had created one same application in glad interface designer with c option.the n i compiled the same after that i....

C++ -> mplayer, stdin, stdout, popen / fork / pipe... - Hello everybody. I tried to work this out on my own for about 6 hours non-stop now and I just don't get it working.......

mss to pmtu clamping partially broken? - There seems to be a problem with mss to pmtu clamping for incoming syn packets on reply to an outgoing connection on a....

[S390] cio: Use path verification to check for path state. - From: Cornelia Huck <cornelia.huck@de.ibm.com> [S390] cio: Use path verification to check for path state. After...
       Soft32 Home -> Linux -> App Development All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Categories:
 Windows
  Linux
 Mac
 PDA


[ Contact us | Terms of Service/Privacy Policy ]