Unable to talk to tap(4)

Wojciech Puchar wojtek at wojtek.tensor.gdynia.pl
Fri May 16 14:19:48 UTC 2008


>>>>>  unsigned char * buffer = (unsigned char*)malloc(1514);

is stdlib.h included (i'm asking for sure)?

>>>>>  if (buffer = NULL) {
>
>       if (buffer == NULL) {
>
>
>>>>>    fprintf (stderr, "No memory available.\n");
>>>>>    close (tapFD);
>>>>>    exit(3);
>>>>>  }
>>
>> When I replace the malloc with an automatic array, the
>> error goes away and I get the data I am looking for. i.e.:
>>
>>    unsigned char buffer[1514];
>>
>> So why can't I use malloc to create that buffer?

anyway not using malloc is good habit :) but it should work anyway.
try


buffer[0]=buffer[1513]=0;

to make sure page is actually allocated.

if this help - maybe tap driver is buggy.


More information about the freebsd-questions mailing list