Using netgraph in kernel modules

Julian Elischer julian at freebsd.org
Mon Jun 20 06:27:06 UTC 2016


On 20/06/2016 1:40 PM, Nomad Esst via freebsd-hackers wrote:
> Hi
>
> I included the two files in my kernel module :
>
> #include <netgraph/netgraph.h>#include <netgraph/ng_message.h>

did you start with /usr/src/sys/netgraph/ng_sample.c?

My suggestion is to start with that and add in your code a bit at a time
To see it compile,
go to /usr/src/sys/modules/netgraph/sample  and type "make

to make your own module,

copy the build directory to
/usr/src/sys/modules/netgraph/mymodule
copy the source files to
/usr/src/sys/netgraph/ng_mymodule.h
/usr/src/sys/netgraph/ng_mymodule.c

and replace all instances of 'sample' in all the files and the 
Makefile with 'mymodule'

Then go to
/usr/src/sys/modules/netgraph/mymodule
and make sure it still compiles

then add all your own code, adding include files as you need them
recompile it every time you have the oportunity while you are working 
on it.

>
> And here is contents of Makefile:
>
>    KMOD= echo   SRCS= char_dev.c
>
>    .include <bsd.kmod.mk>
>
> When I try to run make I face the following errors:
>
>
> @/netgraph/ng_message.h:59: error: expected specifier-qualifier-list before 'u_char'
> @/netgraph/ng_message.h:227: error: expected specifier-qualifier-list before 'uint32_t'
> @/netgraph/ng_message.h:269: error: expected specifier-qualifier-list before 'u_int32_t'
> @/netgraph/ng_message.h:283: error: expected specifier-qualifier-list before 'u_int32_t'
> @/netgraph/ng_message.h:294: error: expected specifier-qualifier-list before 'u_int32_t'
> @/netgraph/ng_message.h:306: error: expected specifier-qualifier-list before 'u_int64_t'
> @/netgraph/ng_message.h:332: error: expected specifier-qualifier-list before 'u_int'
> @/netgraph/ng_message.h:352: error: expected specifier-qualifier-list before 'uint32_t'
> In file included from @/sys/lock.h:36,
>                   from @/netgraph/netgraph.h:52,
>                   from char_dev.c:2:
> @/sys/_lock.h:36: error: expected specifier-qualifier-list before 'u_int'
> In file included from @/netgraph/netgraph.h:52,
>                   from char_dev.c:2:
> @/sys/lock.h:60: error: expected specifier-qualifier-list before 'u_int'
> In file included from char_dev.c:2:
> @/netgraph/netgraph.h:1187: error: field 'tag' has incomplete type
> *** [char_dev.o] Error code 1
>
>
> Stop in /extra/char-dev.
>
>
> What's the problem??
> _______________________________________________
> freebsd-hackers at freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
>
>



More information about the freebsd-hackers mailing list