2

I want to develop a network kernel extension on mac os. I got some data with gzip format in function sf_data_in(). I included the header file named <libkern/zlib.h>, and my mac crashed when it was running the code below after I loading the kext with "kextload".

z_stream strm;
bzero(&strm, sizeof(z_stream));

if (Z_OK != inflateInit2(&strm))
{
    printf("inflateInit error.\n");

    inflateEnd(&strm);

    return 0;
}

who can tell me how to use it in kernel programming. it's much better to give some samples. Thanks very much.

Cédric Julien
  • 78,516
  • 15
  • 127
  • 132
kyle
  • 21
  • 1

2 Answers2

2

You are passing the wrong number of parameters to inflateInit2(), it requires both a pointer to a stream and the window size in bits. if you do not wish to set the latter, use inflateInit() instead.

You may also want to look at some of the kernel code using zlib, ppp_deflate.c, ipcomp_core.c

Hasturkun
  • 35,395
  • 6
  • 71
  • 104
0

I found some use of the zlib kernel library in the arch/powerpc/boot/gunzip_util.c file, maybe it will be a good starting point for your code.

Cédric Julien
  • 78,516
  • 15
  • 127
  • 132
  • Thanks for your help. But gunzip is for Linux, can you please tell me how to use zlib as kernel extension in Mac OS X or some other solutions. Thanks again! – kyle Aug 18 '11 at 08:35
  • @kyle : oh, I didn't notice that was in OSX kernel, I just notice the kernel word... :( – Cédric Julien Aug 18 '11 at 08:46