Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to use the IP_TRANSPARENT declaration. I am using debian 6.0.5. IP_TRANSPARENT is only defined in linux/in.h however it conflicts with netinet/in.h. In centos for example, IP_TRANSPARENT is defined in both linux/in.h and bits/in.h.

When I look at the top of bits/in.h (which I get when I include netinet/in.h, the centos one has

/* Copyright (C) ... 2008, 2010 Free Software Foundation, Inc.

Whereas one in my debian install has

/* Copyright (C) ... 2004, 2008 Free Software Foundation, Inc.

I've tried

apt-get install linux-headers-2.6.32-5-686

But it says it is already the newest version. How do I update the debian linux headers to the latest versions?

Edit:

In centos, IP_TRANSPARENT is defined in bits/in.h, which I get if I include netinet/in.h. It compiles fine under centos.

In debian, IP_TRANSPARENT is not in bits/in.h, so when I include netinet/in.h I get a ‘IP_TRANSPARENT’ undeclared error when compiling.

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

I'm sure you already have the right versions, but linux/in.h is a kernel header that you should not be trying to include directly in a user space program.

You also shouldn't include bits/in.h as that is a header fragment that will be included by other headers when necessary.

The netinet/in.h is what you should be including and that will, in turn, include the bits/in.h header. If that doesn't have a definition for IP_TRANSPARENT then the version of glibc on the system is too old.

If you can't update glibc because you are already on the latest version offered by your distribution then the pragmatic solution, and the one which will make your program portable, is to add the following to your code:

#ifndef IP_TRANSPARENT
#define IP_TRANSPARENT  19
#endif
share|improve this answer
    
Hi, what do you mean forget about the other declarations, do you mean I should #define IP_TRANSPARENT in my own program instead? In centos, IP_TRANSPARENT is defined in bits/in.h, which I get if I include netinet/in.h. In debian, IP_TRANSPARENT is not in bits/in.h, so when I include netinet/in.h I get a ‘IP_TRANSPARENT’ undeclared error when compiling. –  A G Dec 14 '12 at 9:38
    
Well netinet/in.h should be including bits/in.h I think - it does on my Fedora systems. –  TomH Dec 14 '12 at 11:24
    
Hi, yes I meant while I should only include netinet/in.h, on my debian install, bits/in.h doesn't define IP_TRANSPARENT. which is causing my compile errors. It compiles fine on centos as bits/in.h defines IP_TRANSPARENT because it is newer (dated 2010) than the debian one (dated 2008). I've updated the original question to clarify this. –  A G Dec 14 '12 at 12:12
2  
It sounds like the version of glibc that your distribution has too old then - if there is no newer version (which it sounds like there isn't) then you need a newer distribution. Pragmatically it may be easier to add a define (guarded by ifdef) to your code to make it portable to older systems. –  TomH Dec 14 '12 at 14:07
    
Hi, thanks, that explains it; centos rpm -q glibc shows glibc-2.12 while on debian apt-cache show libc6 shows glibc-2.11. I can't upvote your last comment or mark it as an answer though - assuming updating glibc will update the headers. Or do I upvote and mark your original answer (even though strictly speaking it didn't answer the question?) –  A G Dec 14 '12 at 14:59
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.