3

so I'm getting this warning:

initialization makes integer from pointer without a cast

in the following piece of code:

void receive(u_char *args, const struct pcap_pkthdr *pkthdr, const u_char *buffer)

{

const int one = 1;

int LEN = args;      /* THIS IS THE LINE */

struct ipheader *ip;

struct tcpheader *tcp;

and to be honest little newbie me is not sure what to do as almost all searches return makes pointer from integer.

I'm also getting these compiler messages:

/tmp/cci6u7NH.o: In function `main':
ChannelBunny.c:(.text+0x448): undefined reference to `pthread_create'
ChannelBunny.c:(.text+0x4b7): undefined reference to `pthread_join'
/tmp/cci6u7NH.o: In function `receive':
ChannelBunny.c:(.text+0xcb6): undefined reference to `nthol'
ChannelBunny.c:(.text+0xcdf): undefined reference to `nthol'
collect2: ld returned 1 exit status

got rid of a similar pcap problem by using -l pcap but that didn't work for the other two. It just returned:

gcc: pthread: No such file or directory
gcc: nthol: No such file or director

I'm guessing I have to download something? or is there another command I have to use. (I'm using Backtrack5 if that's of any use to you).

1
  • 1
    honestly, far too many questions in one, try to concentrate on one question at a time. Commented Aug 18, 2012 at 16:11

3 Answers 3

9

You should do

int LEN = *args;

args is a pointer, *args is the value pointed by it. Also, you shouldn't put a u_char into an int.

For nthol: http://msdn.microsoft.com/en-us/library/windows/desktop/ms740069(v=vs.85).aspx

Sign up to request clarification or add additional context in comments.

Comments

3

You can use atoi() function to convert char* to int.

About the link error about pthread, try put -lpthread on your compile command

6 Comments

I'm speaking as a C programmer here, not a moderator. Please do not recommend the use of atoi(), strtol() is much, much safer.
Never used atoi() before, but there is a pcap_loop function further down that I didn't include here which I believe is expecting a char*. wouldn't atoi() conflict with that? -lpthread worked brilliantly btw :) @TimPost how would that look in my example?
@youjustreadthis Just LEN = strtol(args, NULL, 0), the spec is quite informative. But I'm not sure why args is u_char ?
@youjustreadthis what do you expect args to be? @TimPost I agree. if you are not sure what you are passing to atoi
@youjustreadthis oh, so you are receiving a pointer at args, which you actually pass to pcap_loop() what are you passing in the pcap_loop()? it's up to what you expect to have in LEN
|
0

You pass a pointer

u_char *args

You try to assign it to an integer

int LEN = args;

The error message says this.

"makes integer from pointer"

The real question is what do you think args is? Just from looking, I'd guess it holds some arguments, not the length of some arguments?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.