LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-24-2004, 09:11 AM   #1
Config
Member
 
Registered: Jan 2001
Location: Switzerland
Distribution: Gentoo
Posts: 376

Rep: Reputation: 30
Kernel Module programming


I'm about to learn something of kernel module programming. I found a cool article on phrack61 about the network-stack of Linux, so I started out coding... however, i fail to compile my second module - here are the relevant lines:

static const __u32 deny_ip1 = 0x2171e4d8; (Globally defined)

if(sb->nh.iph->daddr == deny_ip1) <- compiling fails here.
return NF_DROP;

The Error-message I get from gcc is:

/home/benjamin/programming/net.c:17: error: dereferencing pointer to incomplete type

daddr is of type __u32.
Ah, I forgot one thing: I'm compiling this on a amd64 operating in 64-bit mode - so sizeof(void*) is 8 bytes.

Any help is welcome.

Last edited by Config; 03-24-2004 at 09:50 AM.
 
Old 03-24-2004, 12:22 PM   #2
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 43
You haven't #include'd the definition of one of the structs you dereference in that line. So either sb, sb->nh, or sb->nh.iph is of a type unknown to the compiler.

Depending on what kernel version you're doing this for, you might need to #define __KERNEL__ or __MODULE__ before #include'ing the relevant header to get the definition.
 
Old 03-24-2004, 04:48 PM   #3
Config
Member
 
Registered: Jan 2001
Location: Switzerland
Distribution: Gentoo
Posts: 376

Original Poster
Rep: Reputation: 30
Ahhh... why am I this stupid...

#include <linux/ip.h>
and it all compiles fine :/

Well, thanks anyway
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
experimenting with kernel module programming bravetanveer Linux - General 0 12-30-2004 03:29 AM
Kernel module programming lokutas Programming 2 04-27-2004 02:26 AM
Kernel Module Programming in 2.6 KneeLess Programming 3 04-13-2004 02:27 PM
kernel module programming shellcode Programming 1 02-05-2004 11:43 PM
Kernel Module Programming Thomas.P Programming 1 11-10-2001 10:23 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration