Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Slackware This Forum is for the discussion of Slackware Linux.


  Search this Thread
Old 02-21-2005, 02:25 AM   #1
Registered: Feb 2005
Posts: 39

Rep: Reputation: 15
C error "dereferencing pointer to incomplete type"

I'm not a very good programmer and I've got a problem with gcc compiler. I make a C file but there's an error. Here there's my code:

printk(KERN_INFO "\n IP source:%d IPdest:%d\n",skb->nh.iph->saddr, skb->nh.iph->saddr);

and here there's the error:

error: dereferencing pointer to incomplete type.

But I don't understand where's my error. What does this error mean?Could you help me?Thanks....lucs
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 02-21-2005, 02:52 AM   #2
Senior Member
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973

Rep: Reputation: 46
post the declaration of skb and your includes.
Old 02-21-2005, 04:11 AM   #3
Registered: Feb 2005
Posts: 39

Original Poster
Rep: Reputation: 15
skb is a pointer of skbuff structure. Here there's the structure

struct sk_buff {
/* These two members must be first. */
struct sk_buff * next; /* Next buffer in list */
struct sk_buff * prev; /* Previous buffer in list */

struct sk_buff_head * list; /* List we are on */
struct sock *sk; /* Socket we are owned by */
struct timeval stamp; /* Time we arrived */
struct net_device *dev; /* Device we arrived on/are leaving by */
struct net_device *real_dev; /* For support of point to point protocols
(e.g. 802.3ad) over bonding, we must save the
physical device that got the packet before
replacing skb->dev with the virtual device. */

/* Transport layer header */
struct tcphdr *th;
struct udphdr *uh;
struct icmphdr *icmph;
struct igmphdr *igmph;
struct iphdr *ipiph;
struct spxhdr *spxh;
unsigned char *raw;
} h;

/* Network layer header */
struct iphdr *iph;
struct ipv6hdr *ipv6h;
struct arphdr *arph;
struct ipxhdr *ipxh;
unsigned char *raw;
} nh;

/* Link layer header */
struct ethhdr *ethernet;
unsigned char *raw;
} mac;

struct dst_entry *dst;

* This is the control buffer. It is free to use for every
* layer. Please put your private variables there. If you
* want to keep them across layers you have to do a skb_clone()
* first. This is owned by whoever has the skb queued ATM.
char cb[48];

unsigned int len; /* Length of actual data */
unsigned int data_len;
unsigned int csum; /* Checksum */
unsigned char __unused, /* Dead field, may be reused */
cloned, /* head may be cloned (check refcnt to be sure). */
pkt_type, /* Packet class */
ip_summed; /* Driver fed us an IP checksum */
__u32 priority; /* Packet queueing priority */
atomic_t users; /* User count - see datagram.c,tcp.c */
unsigned short protocol; /* Packet protocol from driver. */
unsigned short security; /* Security level of packet */
unsigned int truesize; /* Buffer size */

unsigned char *head; /* Head of buffer */
unsigned char *data; /* Data head pointer */
unsigned char *tail; /* Tail pointer */
unsigned char *end; /* End pointer */

void (*destructor)(struct sk_buff *); /* Destruct function */
/* Can be used for communication between hooks. */
unsigned long nfmark;
/* Cache info */
__u32 nfcache;
/* Associated connection, if any */
struct nf_ct_info *nfct;
unsigned int nf_debug;

#if defined(CONFIG_HIPPI)
__u32 ifield;
} private;

__u32 tc_index; /* traffic control index */
Old 02-21-2005, 04:35 AM   #4
Senior Member
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973

Rep: Reputation: 46
Originally posted by __J
post the declaration of skb and your includes.
post the line in your code where skb is being declared ( initialized and allocated)
Old 02-21-2005, 04:47 AM   #5
Registered: Feb 2005
Posts: 39

Original Poster
Rep: Reputation: 15
static int transmit(struct sk_buff *skb, struct net_device *dev).....but I don't find where is it iniatialized...I think that mine is a casting problem, what do you think?
Old 02-21-2005, 04:59 AM   #6
Senior Member
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973

Rep: Reputation: 46

look at section 2.2

EDIT: if the pointer is pointing nowhere (i.e. skb does not have memory assigned to it) and the compiler does not catch it ( it did here, but in other instances.....) this could lead to disaster. remember, there are no segmentation faults in kernel programming . A wild pointer in kernel land that overwrites something like filesystem info in ram could lead to very bad results...

If you're new to all this I'd suggest you set up another partition and install a minimal linux disto on it to do your programming that way a wild bug doesn't damage you're main install ( in application programming you're ok, but kernel is a different story).

Last edited by __J; 02-21-2005 at 05:11 AM.
Old 02-21-2005, 09:33 AM   #7
Senior Member
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
I think this error usually means that the line with the offending code is in a .c file which does NOT have the necessary .h file included. You may have included the necessary file somewhere else, but if it's not ALSO in each and every .c file where it's needed, you'll get this error.
2 members found this post helpful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
tai64nlocal.c:55: error: dereferencing pointer to incomplete type ExCIA Linux - General 1 03-31-2009 09:49 AM
"...incompatible pointer type" Can it be ended? lyd Programming 3 07-29-2005 02:43 PM
"dereferencing `void *' pointer" but how else?!? f0rmula Programming 6 03-24-2005 05:32 AM
ereferencing pointer to incomplete type? ams Programming 5 03-03-2005 10:32 AM
curl "incompatible pointer type" while making PHP basse- Linux - Software 2 04-15-2004 10:21 AM > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:56 PM.

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