tags:

views:

2400

answers:

2

I'm trying to compile a program called ngrep, and when I ran configure, things seemed to go well, but when I run make, I get:

ngrep.c: In function ‘process’:
ngrep.c:544: error: ‘struct udphdr’ has no member named ‘source’
ngrep.c:545: error: ‘struct udphdr’ has no member named ‘dest’
make: *** [ngrep.o] Error 1

What does that mean, and how do I fix it? There are no earlier warnings or errors that suggest the root of the problem.

+1  A: 

Well, there is a struct called udphdr (probably short for udp header). And some part of the program assumes the struct has the members source and dest which it hasn't.

Look at file ngrep.c line 544 and 545 to find the offending lines.

Possible causes:

  • type name type error.
  • struct is not completely defined.
  • using the wrong struct.

Edit: probably related problem: http://ubuntuforums.org/showthread.php?t=371871

Gamecat
Thanks for the link, but I already have build-essential installed, and the site that the forums link to no longer exists.
raldi
+1  A: 

Found the problem:

#ifdef HAVE_DUMB_UDPHDR
                printf("%s:%d -", inet_ntoa(ip_packet->ip_src), ntohs(udp->source));
                printf("> %s:%d", inet_ntoa(ip_packet->ip_dst), ntohs(udp->dest));
#else
                printf("%s:%d -", inet_ntoa(ip_packet->ip_src), ntohs(udp->uh_sport));
                printf("> %s:%d", inet_ntoa(ip_packet->ip_dst), ntohs(udp->uh_dport));
#endif

Apparently, configure has a bug in this test, and it thinks my system has the "dumb" udphdr, even though it doesn't. Changing the first line to "#if 0" fixes the problem.

raldi