LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Test Kernel API (https://www.linuxquestions.org/questions/programming-9/test-kernel-api-441292/)

dongthao 05-03-2006 12:42 PM

Test Kernel API
 
Hi all,
I'm reading about linux networking architecture. Now I want to test some kernel APIs in manipulating socket buffers so I write a very small program :-D to test the functions in skbuff.h file. First, I try the alloc_skb:
Code:

#include <linux/skbuff.h>
#include <socket.h>

int main(){
        sk_buff socketbuff;
        socketbuff = alloc_skb(12, GFP_DMA);
        return 0;
}

You see, a very simple program but when I compile with
Code:

gcc -o test testskbuff.c
or
gcc -o test testskbuff.c -l /usr/include/linux

, the errors sank me!
Code:

In file included from /usr/include/linux/sched.h:14,
                from /usr/include/linux/skbuff.h:19,
                from testskbuff.c:1:
/usr/include/linux/timex.h:173: field `time' has incomplete type
In file included from /usr/include/linux/bitops.h:69,
                from /usr/include/asm/system.h:7,
                from /usr/include/linux/sched.h:16,
                from /usr/include/linux/skbuff.h:19,
                from testskbuff.c:1:
/usr/include/asm/bitops.h:327:2: warning: #warning This includefile is not available on all architectures.
/usr/include/asm/bitops.h:328:2: warning: #warning Using kernel headers in userspace: atomicity not guaranteed
In file included from /usr/include/linux/signal.h:4,
                from /usr/include/linux/sched.h:25,
                from /usr/include/linux/skbuff.h:19,
                from testskbuff.c:1:
/usr/include/asm/signal.h:107: syntax error before "sigset_t"
/usr/include/asm/signal.h:110: syntax error before '}' token
In file included from /usr/include/linux/sched.h:81,
                from /usr/include/linux/skbuff.h:19,
                from testskbuff.c:1:
/usr/include/linux/timer.h:32: field `vec' has incomplete type
/usr/include/linux/timer.h:37: field `vec' has incomplete type
/usr/include/linux/timer.h:45: syntax error before "spinlock_t"
/usr/include/linux/timer.h:53: syntax error before '}' token
/usr/include/linux/timer.h:63: field `list' has incomplete type
/usr/include/linux/timer.h:67: syntax error before "tvec_base_t"
/usr/include/linux/timer.h:101: syntax error before "tvec_bases"
/usr/include/linux/timer.h: In function `init_timer':
....

My god! It's only a little bit on my screen. I guess that I have missed some including files but I can't know what exactly they are:confused: .
So can you explain me what happen and tell me what to do to run this simple program?


All times are GMT -5. The time now is 05:55 PM.