RE: ioctl between user/kernel space

From: Richard B. Johnson (root@chaos.analogic.com)
Date: Fri Jul 12 2002 - 06:41:18 EST


On Thu, 11 Jul 2002, Shipman, Jeffrey E wrote:

> Thanks for your answers. I do have a couple more questions,
> however:
>
> 1) I'm not dealing with any hardware. Is it still ok to
> call some sort of register_xxxdev() function? If so, where can
> I find the definitions of these register functions and which
> one would you think be appropriate for a module which simply
> does packet manipulation via Netfilter?
>

In that case, you want to look at ../ipv4/netfilter/ip_fw_compat.c and
../ipv4/netfilter/ip_chains_core.c.

You can see that these network things don't generally use ioctl(),
although a device driver can. Instead, you probably should use
setsockopt() from user-space and enable it in you driver with:
        nf_register_sockopt(struct nf_sock_ops *);

Your function address is put into the 6th member of nf_sock_ops. Just
check out existing code in netfilter. It's quite straight-forward.

setsockopt(int s, int level, int name, void *val, int len);
The void *val can be a pointer to your table of parameters and
it's length is put into len.

> 2) What if my module is not in the kernel? Does ioctl()
> just return an error code?
>

Well, if it's not in the kernel, you can do anything you want,
passing parameters using shared-memory to Morse-Code, and everything
in-between.

> Thanks again.
>
> Jeff Shipman - CCD
> Sandia National Laboratories
> (505) 844-1158 / MS-1372

Cheers,
Dick Johnson

Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).

                 Windows-2000/Professional isn't.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Jul 15 2002 - 22:00:22 EST