inet_* functions in kernel?

Boris Kochergin spawk at acm.poly.edu
Mon Jul 12 22:26:11 UTC 2010


Bartosz Marcin Kojak wrote:
>
> Hi.
>
> Currently I'm writing a kernel module using MAC Framework to control 
> binding to local IP addresses (kind of mac_portacl variation) and I 
> need some advice.
>
> I want to be able to write rules for module through sysctl (rule will 
> contain IP addresses in human-readable format, e.g. 
> "uid:1002:192.168.2.3") and I'm wondering how to translate addresses 
> to network byte order without inet_* functions.  Well, they look like 
> they're available to use in kernel (using <netinet/in.h>) but it's no 
> able to compile module with inet_* functions using typical Makefile 
> (this one with ".include <bsd.kmod.mk>" line) - it just produces 
> warnings, and all warnings are treated as errors in this case.
>
> So, possible solutions are: just add custom CFLAGS without "-Werror" 
> to Makefile (but it's quite ugly though) or write an userspace 
> application that will write an addresses in NBO to sysctl (but now 
> sysctl won't be easy to read and modify by hand).
>
> What do you think?
>
> Thanks in advance for any useful hints.
>
Check out the byteorder(9) man page.

-Boris


More information about the freebsd-hackers mailing list