Mailing List Archive

userspace access to "u8", "u16", etc. types with filter.h
Hello,
As I am not on the linux-kernel list currently, I would appreciate it if
you could please CC me (that funky looking From: address will get your
reply back to me :-) on any responses.
I am updating the ISC's DHCP package for Linux 2.[12]. Specifically I
am dealing with the networking changes in the 2.[12] kernels that
require substantial changes in the way the ISC DHCP's dhcp client works.
I am using the new Linux Packet Filter for doing some of the job. It is
cool stuff, but I am running into a problem. In <linux/filter.h> there
is a structure defined:
struct sock_filter /* Filter block */
{
u16 code; /* Actual filter code */
u8 jt; /* Jump true */
u8 jf; /* Jump false */
u32 k; /* Generic multiuse field */
};
which is required by the userspace "setsockopt()" call to install the
filter.
The problem is however, when I include <linux/filter.h> the u* types are
not defined. I cannot find a header file that defines them for
userspace programs. <asm/types.h> has the definitions that I want, but
they are wrapped with a _KERNEL_ macro.
Any ideas on how to best handle this situation?
BTW: I seem to be getting a:
dhclient uses obsolete (PF_INET,SOCK_PACKET)
message as well. If somebody can point me to what has obsoleted this
facility I will see about updating that part of the dhcp client as well.
Much thanks,
b.
--
Brian J. Murrell InterLinx Support Services, Inc.
North Vancouver, B.C. 604 983 UNIX
Platform and Brand Independent UNIX Support - R3.2 - R4 - BSD
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
Re: userspace access to "u8", "u16", etc. types with filter.h [ In reply to ]
>The problem is however, when I include <linux/filter.h> the u* types are
>not defined. I cannot find a header file that defines them for
>userspace programs. <asm/types.h> has the definitions that I want, but
>they are wrapped with a _KERNEL_ macro.
Including <linux/*> headers from user space is always dubious. Either typedef
those names yourself or duplicate the structure with types that do exist.
>dhclient uses obsolete (PF_INET,SOCK_PACKET)
>
>message as well. If somebody can point me to what has obsoleted this
>facility I will see about updating that part of the dhcp client as well.
AF_PACKET is the new way to do this.
p.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
Re: userspace access to "u8", "u16", etc. types with filter.h [ In reply to ]
from the quill of Philip Blundell <pb@nexus.co.uk> on scroll
<E103gyu-0006uz-00@fountain.nexus.co.uk>
>
> Including <linux/*> headers from user space is always dubious.
Indeed. But this brings us to an intersting dilemma. What is a
userspace program to do when it wants to build an LPF and attach it to a
socket? It needs the definitions in <linux/filter.h> to build the
filter.
> Either typedef
> those names yourself or duplicate the structure with types that do
> exist.
Uggh! Does this not sound like a deficiency in the kernel interface to
you? I really shouldn't have to do either of these. There should be a
"userspace" version of the required data structures shouldn't there?
> AF_PACKET is the new way to do this.
Cool. Will look into this.
Thanks very much for your insight on this matter.
b.
--
Brian J. Murrell InterLinx Support Services, Inc.
North Vancouver, B.C. 604 983 UNIX
Platform and Brand Independent UNIX Support - R3.2 - R4 - BSD
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
Re: userspace access to "u8", "u16", etc. types with filter.h [ In reply to ]
On Fri, 22 Jan 1999, wrote:
> struct sock_filter /* Filter block */
> {
> u16 code; /* Actual filter code */
[....]
> The problem is however, when I include <linux/filter.h> the u* types are
> not defined. I cannot find a header file that defines them for
> userspace programs. <asm/types.h> has the definitions that I want, but
> they are wrapped with a _KERNEL_ macro.
> Any ideas on how to best handle this situation?
The structure should be changed to use __u16, __u32 types.

> BTW: I seem to be getting a:
> dhclient uses obsolete (PF_INET,SOCK_PACKET)
> message as well. If somebody can point me to what has obsoleted this
> facility I will see about updating that part of the dhcp client as well.
There's a new address family called AF_PACKET.
Kris
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
Re: userspace access to "u8", "u16", etc. types with filter.h [ In reply to ]
from the quill of "Krzysztof G. Baranowski" <kgb@manjak.knm.org.pl> on
scroll <Pine.LNX.4.02.9901222106420.738-100000@manjak.knm.org.pl>
> On Fri, 22 Jan 1999, wrote:
>
> The structure should be changed to use __u16, __u32 types.
That's what's even funnier. In the 2.1.129 kernel I was using, it was
__u*.
> There's a new address family called AF_PACKET.
Will look into it.
Thanks,
b.
--
Brian J. Murrell InterLinx Support Services, Inc.
North Vancouver, B.C. 604 983 UNIX
Platform and Brand Independent UNIX Support - R3.2 - R4 - BSD
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
Re: userspace access to "u8", "u16", etc. types with filter.h [ In reply to ]
In <199901221958.LAA10673@bmurrell.sympatico.bconnected.net> c22b2f405844e04510a79eef20f630a7@interlinx.bc.ca (c22b2f405844e04510a79eef20f630a7@interlinx.bc.ca) wrote:
> from the quill of Philip Blundell <pb@nexus.co.uk> on scroll
> <E103gyu-0006uz-00@fountain.nexus.co.uk>
>>
>> Including <linux/*> headers from user space is always dubious.
> Indeed. But this brings us to an intersting dilemma. What is a
> userspace program to do when it wants to build an LPF and attach it to a
> socket? It needs the definitions in <linux/filter.h> to build the
> filter.
Copy needed structures to your program and ask glibc folks to add definition
in next glibc version.
>> Either typedef
>> those names yourself or duplicate the structure with types that do
>> exist.
> Uggh! Does this not sound like a deficiency in the kernel interface to
> you? I really shouldn't have to do either of these. There should be a
> "userspace" version of the required data structures shouldn't there?
In glibc. Ask glibc folks to add it. While it's not added just copy
structure to you program. BTW glibc folks could change definition (for
example UID is 16bit in kernel now, but 32bit in glibc) and add wrapper
for syscall -- when this will be done you'll redo your program...
>> AF_PACKET is the new way to do this.
> Cool. Will look into this.
> Thanks very much for your insight on this matter.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
Re: userspace access to "u8", "u16", etc. types with filter.h [ In reply to ]
>Indeed. But this brings us to an intersting dilemma. What is a
>userspace program to do when it wants to build an LPF and attach it to a
>socket? It needs the definitions in <linux/filter.h> to build the
>filter.
There are three options:
- clean up the kernel header so it works from user space
- get the appropriate definitions included in the libc
- include the definitions somewhere else, either in your application or in
some new library invented for the purpose.
In most cases the latter is probably best.
>Uggh! Does this not sound like a deficiency in the kernel interface to
>you? I really shouldn't have to do either of these. There should be a
>"userspace" version of the required data structures shouldn't there?
It's not really the kernel's job to provide the user space API.
p.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
Re: userspace access to "u8", "u16", etc. types with filter.h [ In reply to ]
In article <199901220945.BAA30925@bmurrell.sympatico.bconnected.net> you wrote:
: I am updating the ISC's DHCP package for Linux 2.[12]. Specifically I
: am dealing with the networking changes in the 2.[12] kernels that
: require substantial changes in the way the ISC DHCP's dhcp client works.
BTW look at ftp:/ftp.inr.ac.ru/ip-routing/dhcp.bootp.rarp/
Seems, the patch to ISC DHCP is quite complete.
You may grab it and improve further 8)8)8)
: u16 code; /* Actual filter code */
: u8 jt; /* Jump true */
: u8 jf; /* Jump false */
: u32 k; /* Generic multiuse field */
Add __ to uXX. Probably, it would be not so bad idea to apply
patch ftp://ftp.inr.ac.ru/ip-routing/kernel-ss*.dif.gz to kernel.
I still hope that it will enter 2.2 earlier or later.
Alexey Kuznetsov
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
Re: userspace access to "u8", "u16", etc. types with filter.h [ In reply to ]
On Sat, 23 Jan 1999, wrote:
> from the quill of "Khimenko Victor" <khim@sch57.msk.ru> on scroll
> <ABCSTgsuK0@khim.sch57.msk.ru>
> >
> > Copy needed structures to your program and ask glibc folks to add
> > definition
> > in next glibc version.
>
> Wow! Really? I guess I am surprised something as O/S specific as LPF
> would have any interface in the libc. Is it really libc's job to
> provide O/S specific interfaces? I guess libc would be a huge beast
> with lots of O/S specific macros in that case, yes?
I do #include <site.h> with -I. on the compile command line.
site.h may have things like:
#if !defined(u8)
#define u8 unsigned char
#endif
It saves a lot of sweat, trying to compile things in the future.
Cheers,
Dick Johnson
***** FILE SYSTEM WAS MODIFIED *****
Penguin : Linux version 2.1.131 on an i686 machine (400.59 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.
Wisdom : It's not a Y2K problem. It's a Y2Day problem.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/