제 솔라리스 10 x86 환경에서 컴파일 해보는데..
bash-3.2$ wget http://pypcap.googlecode.com/files/pypcap-1.1.tar.gz
--11:26:03-- http://pypcap.googlecode.com/files/pypcap-1.1.tar.gz
=> `pypcap-1.1.tar.gz'
Resolving pypcap.googlecode.com... 66.102.1.82
Connecting to pypcap.googlecode.com|66.102.1.82|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 22,951 (22K) [application/x-gzip]
100%[====================================>] 22,951 48.56K/s
11:26:05 (48.49 KB/s) - `pypcap-1.1.tar.gz' saved [22951/22951]
bash-3.2$ gtar zxvf pypcap-1.1.tar.gz
bash-3.2$ pwd
/export/home/sandy/pypcap-1.1
bash-3.2$ ls -al
총 270
drwxr-xr-x 3 sandy other 512 3월 10일 11:26 .
drwxr-xr-x 52 sandy other 4096 3월 10일 11:26 ..
-rw-r--r-- 1 sandy other 508 2005년 10월 16일 CHANGES
-rw-r--r-- 1 sandy other 1431 2005년 10월 16일 LICENSE
-rw-r--r-- 1 sandy other 615 2005년 10월 16일 Makefile
-rw-r--r-- 1 sandy other 371 2005년 10월 16일 README
drwxr-xr-x 3 root root 512 3월 10일 11:26 build
-rw-r--r-- 1 sandy other 98124 2005년 10월 16일 pcap.c
-rw-r--r-- 1 sandy other 11982 2005년 10월 16일 pcap.pyx
-rw-r--r-- 1 sandy other 6162 2005년 10월 16일 pcap_ex.c
-rw-r--r-- 1 sandy other 629 2005년 8월 29일 pcap_ex.h
-rw-r--r-- 1 sandy other 4002 2005년 10월 16일 setup.py
-rw-r--r-- 1 sandy other 468 2005년 1월 26일 test.pcap
-rwxr-xr-x 1 sandy other 1431 2005년 9월 11일 test.py
-rwxr-xr-x 1 sandy other 914 2005년 1월 26일 testsniff.py
bash-3.2$ cd py*
bash-3.2$ sudo python setup.py install
running install
running build
running build_ext
building 'pcap' extension
creating build
creating build/temp.solaris-2.10-i86pc-2.5
gcc -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC
-I/usr/local/include/python2.5 -c pcap.c -o
build/temp.solaris-2.10-i86pc-2.5/pcap.o
pcap.c: In function `__pyx_f_4pcap_3bpf___dealloc__':
pcap.c:320: warning: label `__pyx_L1' defined but not used
pcap.c: In function `__pyx_f_4pcap_4pcap_dispatch':
pcap.c:1039: warning: passing arg 3 of `pcap_dispatch' from incompatible
pointer type
pcap.c: In function `__pyx_f_4pcap_4pcap_loop':
pcap.c:1142: warning: passing arg 3 of `pcap_ex_next' from incompatible
pointer type
pcap.c:1134: warning: label `__pyx_L2' defined but not used
pcap.c: In function `__pyx_f_4pcap_4pcap___iter__':
pcap.c:1305: warning: label `__pyx_L1' defined but not used
pcap.c: In function `__pyx_f_4pcap_4pcap___next__':
pcap.c:1338: warning: passing arg 3 of `pcap_ex_next' from incompatible
pointer type
pcap.c:1330: warning: label `__pyx_L2' defined but not used
pcap.c:1382: warning: label `__pyx_L3' defined but not used
pcap.c: In function `__pyx_f_4pcap_4pcap___dealloc__':
pcap.c:1433: warning: label `__pyx_L1' defined but not used
pcap.c: In function `__pyx_tp_new_4pcap_bpf':
pcap.c:1567: warning: unused variable `p'
pcap.c: In function `__pyx_tp_dealloc_4pcap_bpf':
pcap.c:1572: warning: unused variable `p'
pcap.c: In function `__pyx_tp_traverse_4pcap_bpf':
pcap.c:1586: warning: unused variable `e'
pcap.c:1587: warning: unused variable `p'
pcap.c: In function `__pyx_tp_clear_4pcap_bpf':
pcap.c:1592: warning: unused variable `p'
pcap.c: In function `__pyx_tp_new_4pcap_pcap':
pcap.c:1719: warning: unused variable `p'
pcap.c: In function `__pyx_tp_dealloc_4pcap_pcap':
pcap.c:1724: warning: unused variable `p'
pcap.c: In function `__pyx_tp_traverse_4pcap_pcap':
pcap.c:1738: warning: unused variable `e'
pcap.c:1739: warning: unused variable `p'
pcap.c: In function `__pyx_tp_clear_4pcap_pcap':
pcap.c:1744: warning: unused variable `p'
pcap.c: In function `__Pyx_GetStarArgs':
pcap.c:2253: warning: suggest explicit braces to avoid ambiguous `else'
pcap.c:2255: warning: suggest explicit braces to avoid ambiguous `else'
pcap.c: At top level:
pcap.c:14: warning: '__Pyx_UnpackItem' declared `static' but never defined
pcap.c:15: warning: '__Pyx_EndUnpack' declared `static' but never defined
pcap.c:16: warning: '__Pyx_PrintItem' declared `static' but never defined
pcap.c:17: warning: '__Pyx_PrintNewline' declared `static' but never defined
pcap.c:19: warning: '__Pyx_ReRaise' declared `static' but never defined
pcap.c:22: warning: '__Pyx_ArgTypeTest' declared `static' but never defined
pcap.c:23: warning: '__Pyx_TypeTest' declared `static' but never defined
pcap.c:27: warning: '__Pyx_ImportType' declared `static' but never defined
pcap.c:28: warning: '__Pyx_SetVtable' declared `static' but never defined
pcap.c:29: warning: '__Pyx_GetVtable' declared `static' but never defined
pcap.c:30: warning: '__Pyx_CreateClass' declared `static' but never defined
gcc -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC
-I/usr/local/include/python2.5 -c pcap_ex.c -o
build/temp.solaris-2.10-i86pc-2.5/pcap_ex.o
pcap_ex.c:22:20: config.h: 해당 파일이나 디렉토리가 없음
pcap_ex.c: In function `pcap_ex_fileno':
pcap_ex.c:165: error: dereferencing pointer to incomplete type
pcap_ex.c: In function `pcap_ex_next':
pcap_ex.c:253: error: dereferencing pointer to incomplete type
pcap_ex.c: In function `pcap_ex_compile_nopcap':
pcap_ex.c:285: warning: implicit declaration of function `mktemp'
error: command 'gcc' failed with exit status 1
음 문제가 뭘까요?
21
22 #include "config.h"
23
int
156 pcap_ex_fileno(pcap_t *pcap)
157 {
158 #ifdef _WIN32
159 /* XXX - how to handle savefiles? */
160 return ((int)pcap_getevent(pcap));
161 #else
162 # ifdef HAVE_PCAP_FILE
163 FILE *f = pcap_file(pcap);
164 # else
165 FILE *f = pcap->sf.rfile;
166 # endif
167 if (f != NULL)
168 return (fileno(f));
169 return (pcap_fileno(pcap));
170 #endif /* !_WIN32 */
171 }
226 /* return codes: 1 = pkt, 0 = timeout, -1 = error, -2 = EOF */
227 int
228 pcap_ex_next(pcap_t *pcap, struct pcap_pkthdr **hdr, u_char **pkt)
229 {
230 #ifdef _WIN32
231 if (__pcap_ex_gotsig) {
232 __pcap_ex_gotsig = 0;
233 return (-1);
234 }
235 return (pcap_next_ex(pcap, hdr, pkt));
236 #else
237 static u_char *__pkt;
238 static struct pcap_pkthdr __hdr;
239 struct timeval tv = { 1, 0 };
240 fd_set rfds;
241 int fd, n;
242
243 fd = pcap_fileno(pcap);
244 for (;;) {
245 if (__pcap_ex_gotsig) {
246 __pcap_ex_gotsig = 0;
247 return (-1);
248 }
249 if ((__pkt = (u_char *)pcap_next(pcap, &__hdr)) ==
NULL) {
250 #ifdef HAVE_PCAP_FILE
251 if (pcap_file(pcap) != NULL)
252 #else
253 if (pcap->sf.rfile != NULL)
254 #endif
255 return (-2);
256 FD_ZERO(&rfds);
257 FD_SET(fd, &rfds);
258 n = select(fd + 1, &rfds, NULL, NULL, &tv);
259 if (n <= 0)
260 return (n);
261 } else
262 break;
263 }
264 *pkt = __pkt;
265 *hdr = &__hdr;
266
267 return (1);
268 #endif
269 }
270
271 int
272 pcap_ex_compile_nopcap(int snaplen, int dlt, struct bpf_program
*fp, char *str,
273 int optimize, unsigned int netmask)
274 {
275 #ifdef HAVE_PCAP_COMPILE_NOPCAP
276 return (pcap_compile_nopcap(snaplen, dlt, fp, str,
optimize, netmask));
277 #else
278 FILE *f;
279 struct pcap_file_header hdr;
280 pcap_t *pc;
281 char path[] = "/tmp/.pypcapXXXXXX.pcap";
282 char ebuf[PCAP_ERRBUF_SIZE];
283 int ret = -1;
284
285 mktemp(path);
286 if ((f = fopen(path, "w")) != NULL) {
287 hdr.magic = 0xa1b2c3d4;
288 hdr.version_major = PCAP_VERSION_MAJOR;
289 hdr.version_minor = PCAP_VERSION_MINOR;
290 hdr.thiszone = 0;
291 hdr.snaplen = snaplen;
292 hdr.sigfigs = 0;
293 hdr.linktype = dlt;
294 fwrite(&hdr, sizeof(hdr), 1, f);
295 fclose(f);
296
297 if ((pc = pcap_open_offline(path, ebuf)) != NULL) {
298 ret = pcap_compile(pc, fp, str, optimize,
netmask);
299 pcap_close(pc);
300 }
301 unlink(path);
302 }
303 return (ret);
304 #endif
305 }
제 환경입니다.
bash-3.2$ uname -a
SunOS gagemel 5.10 Generic_118844-20 i86pc i386 i86pc
bash-3.2$ python
Python 2.5 (r25:51908, Sep 20 2006, 03:11:51)
[GCC 3.4.6] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>>