Ticket #28132: patch-pcap.c.diff
File patch-pcap.c.diff, 99.6 KB (added by andrew.reusch@…, 14 years ago) |
---|
-
pcap.c
old new 1 /* Generated by Pyrex 0.9. 3 on Sun Oct 16 19:38:39 2005*/1 /* Generated by Pyrex 0.9.9 on Tue Jan 25 12:41:20 2011 */ 2 2 3 #define PY_SSIZE_T_CLEAN 3 4 #include "Python.h" 4 5 #include "structmember.h" 5 6 #ifndef PY_LONG_LONG 6 7 #define PY_LONG_LONG LONG_LONG 7 8 #endif 9 #if PY_VERSION_HEX < 0x02050000 10 typedef int Py_ssize_t; 11 #define PY_SSIZE_T_MAX INT_MAX 12 #define PY_SSIZE_T_MIN INT_MIN 13 #define PyInt_FromSsize_t(z) PyInt_FromLong(z) 14 #define PyInt_AsSsize_t(o) PyInt_AsLong(o) 15 #endif 16 #if !defined(WIN32) && !defined(MS_WINDOWS) 17 #ifndef __stdcall 18 #define __stdcall 19 #endif 20 #ifndef __cdecl 21 #define __cdecl 22 #endif 23 #endif 24 #ifdef __cplusplus 25 #define __PYX_EXTERN_C extern "C" 26 #else 27 #define __PYX_EXTERN_C extern 28 #endif 29 #include <math.h> 8 30 #include "pcap.h" 9 31 #include "pcap_ex.h" 10 32 11 33 12 typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/ 13 typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/ 14 static PyObject *__Pyx_UnpackItem(PyObject *, int); /*proto*/ 15 static int __Pyx_EndUnpack(PyObject *, int); /*proto*/ 16 static int __Pyx_PrintItem(PyObject *); /*proto*/ 17 static int __Pyx_PrintNewline(void); /*proto*/ 18 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ 19 static void __Pyx_ReRaise(void); /*proto*/ 20 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/ 21 static PyObject *__Pyx_GetExcValue(void); /*proto*/ 22 static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name); /*proto*/ 23 static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ 24 static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], int nargs, PyObject **args2, PyObject **kwds2); /*proto*/ 25 static void __Pyx_WriteUnraisable(char *name); /*proto*/ 26 static void __Pyx_AddTraceback(char *funcname); /*proto*/ 27 static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size); /*proto*/ 28 static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ 29 static int __Pyx_GetVtable(PyObject *dict, void *vtabptr); /*proto*/ 30 static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, char *modname); /*proto*/ 31 static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/ 32 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ 33 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ 34 typedef struct {PyObject **p; int i; char *s; long n;} __Pyx_StringTabEntry; /*proto*/ 34 35 35 36 static PyObject *__pyx_m; 36 37 static PyObject *__pyx_b; 37 38 static int __pyx_lineno; 38 39 static char *__pyx_filename; 39 static forwardchar **__pyx_f;40 static char **__pyx_f; 40 41 41 42 static char __pyx_mdoc[] = "packet capture library\n\nThis module provides a high level interface to packet capture systems.\nAll packets on the network, even those destined for other hosts, are\naccessible through this mechanism.\n"; 42 43 44 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ 45 46 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ 47 48 static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], Py_ssize_t nargs, PyObject **args2, PyObject **kwds2, char rqd_kwds[]); /*proto*/ 49 50 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ 51 52 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/ 53 54 static void __Pyx_AddTraceback(char *funcname); /*proto*/ 55 43 56 /* Declarations from pcap */ 44 57 58 59 /* Declarations from implementation of pcap */ 60 61 typedef void (*__pyx_t_4pcap_pcap_handler)(void *,struct pcap_pkthdr *,char *); 62 45 63 struct __pyx_t_4pcap_pcap_handler_ctx { 46 void (*callback);47 void (*args);64 void *callback; 65 void *args; 48 66 int got_exc; 49 67 }; 50 68 51 staticforward PyTypeObject __pyx_type_4pcap_bpf;52 53 69 struct __pyx_obj_4pcap_bpf { 54 70 PyObject_HEAD 55 71 struct bpf_program fcode; 56 72 }; 57 73 58 staticforward PyTypeObject __pyx_type_4pcap_pcap;59 60 74 struct __pyx_obj_4pcap_pcap { 61 75 PyObject_HEAD 62 pcap_t (*__pcap);63 char (*__name);64 char (*__filter);65 char (__ebuf[256]);76 pcap_t *__pcap; 77 char *__name; 78 char *__filter; 79 char __ebuf[256]; 66 80 int __dloff; 67 81 }; 68 82 83 84 69 85 static PyTypeObject *__pyx_ptype_4pcap_bpf = 0; 70 86 static PyTypeObject *__pyx_ptype_4pcap_pcap = 0; 71 static PyObject *__pyx_k13; 72 static PyObject *__pyx_k14; 73 static PyObject *__pyx_k15; 74 static PyObject *__pyx_k16; 75 static PyObject *__pyx_k17; 76 static PyObject *__pyx_k18; 77 static PyObject *__pyx_k19; 78 static PyObject *__pyx_k20; 79 static void (__pyx_f_4pcap___pcap_handler(void (*),struct pcap_pkthdr (*),char (*))); /*proto*/ 87 static void __pyx_f_4pcap___pcap_handler(void *,struct pcap_pkthdr *,char *); /*proto*/ 80 88 81 /* Implementation of pcap */ 82 83 static char (__pyx_k1[]) = "Network interface or dumpfile name."; 84 static char (__pyx_k2[]) = "Maximum number of bytes to capture for each packet."; 85 static char (__pyx_k3[]) = "Datalink offset (length of layer-2 frame header)."; 86 static char (__pyx_k4[]) = "Current packet capture filter."; 87 static char (__pyx_k5[]) = "File descriptor (or Win32 HANDLE) for capture handle."; 88 static char (__pyx_k6[]) = "Dug Song <dugsong@monkey.org>"; 89 static char (__pyx_k7[]) = "Copyright (c) 2004 Dug Song"; 90 static char (__pyx_k8[]) = "BSD license"; 91 static char (__pyx_k9[]) = "http://monkey.org/~dugsong/pypcap/"; 92 static char (__pyx_k10[]) = "1.1"; 89 static char __pyx_k1[] = "bad filter"; 90 static char __pyx_k2[] = ""; 91 static char __pyx_k3[] = "dltoff"; 92 static char __pyx_k4[] = "couldn't set BPF immediate mode"; 93 static char __pyx_k5[] = "append"; 94 static char __pyx_k6[] = "dispatch"; 95 static char __pyx_k7[] = "__add_pkts"; 96 static char __pyx_k8[] = "sys"; 97 static char __pyx_k9[] = "exc_info"; 98 static char __pyx_k10[] = "Network interface or dumpfile name."; 99 static char __pyx_k11[] = "Maximum number of bytes to capture for each packet."; 100 static char __pyx_k12[] = "Datalink offset (length of layer-2 frame header)."; 101 static char __pyx_k13[] = "Current packet capture filter."; 102 static char __pyx_k14[] = "File descriptor (or Win32 HANDLE) for capture handle."; 103 static char __pyx_k15[] = "Dug Song <dugsong@monkey.org>"; 104 static char __pyx_k16[] = "__author__"; 105 static char __pyx_k17[] = "Copyright (c) 2004 Dug Song"; 106 static char __pyx_k18[] = "__copyright__"; 107 static char __pyx_k19[] = "BSD license"; 108 static char __pyx_k20[] = "__license__"; 109 static char __pyx_k21[] = "http://monkey.org/~dugsong/pypcap/"; 110 static char __pyx_k22[] = "__url__"; 111 static char __pyx_k23[] = "1.1"; 112 static char __pyx_k24[] = "__version__"; 113 static char __pyx_k25[] = "DLT_NULL"; 114 static char __pyx_k26[] = "DLT_EN10MB"; 115 static char __pyx_k27[] = "DLT_EN3MB"; 116 static char __pyx_k28[] = "DLT_AX25"; 117 static char __pyx_k29[] = "DLT_PRONET"; 118 static char __pyx_k30[] = "DLT_CHAOS"; 119 static char __pyx_k31[] = "DLT_IEEE802"; 120 static char __pyx_k32[] = "DLT_ARCNET"; 121 static char __pyx_k33[] = "DLT_SLIP"; 122 static char __pyx_k34[] = "DLT_PPP"; 123 static char __pyx_k35[] = "DLT_FDDI"; 124 static char __pyx_k36[] = "DLT_LINUX_SLL"; 125 static char __pyx_k37[] = "DLT_PFLOG"; 126 static char __pyx_k38[] = "DLT_PFSYNC"; 127 static char __pyx_k39[] = "platform"; 128 static char __pyx_k40[] = "find"; 129 static char __pyx_k41[] = "openbsd"; 130 static char __pyx_k42[] = "DLT_LOOP"; 131 static char __pyx_k43[] = "DLT_RAW"; 93 132 94 static PyObject *__pyx_n___author__; 95 static PyObject *__pyx_n___copyright__; 96 static PyObject *__pyx_n___license__; 97 static PyObject *__pyx_n___url__; 98 static PyObject *__pyx_n___version__; 99 static PyObject *__pyx_n_sys; 100 static PyObject *__pyx_n_DLT_NULL; 101 static PyObject *__pyx_n_DLT_EN10MB; 102 static PyObject *__pyx_n_DLT_EN3MB; 133 static PyObject *__pyx_n_DLT_ARCNET; 103 134 static PyObject *__pyx_n_DLT_AX25; 104 static PyObject *__pyx_n_DLT_PRONET;105 135 static PyObject *__pyx_n_DLT_CHAOS; 106 static PyObject *__pyx_n_DLT_IEEE802; 107 static PyObject *__pyx_n_DLT_ARCNET; 108 static PyObject *__pyx_n_DLT_SLIP; 109 static PyObject *__pyx_n_DLT_PPP; 136 static PyObject *__pyx_n_DLT_EN10MB; 137 static PyObject *__pyx_n_DLT_EN3MB; 110 138 static PyObject *__pyx_n_DLT_FDDI; 139 static PyObject *__pyx_n_DLT_IEEE802; 111 140 static PyObject *__pyx_n_DLT_LINUX_SLL; 141 static PyObject *__pyx_n_DLT_LOOP; 142 static PyObject *__pyx_n_DLT_NULL; 112 143 static PyObject *__pyx_n_DLT_PFLOG; 113 144 static PyObject *__pyx_n_DLT_PFSYNC; 114 static PyObject *__pyx_n_DLT_LOOP; 145 static PyObject *__pyx_n_DLT_PPP; 146 static PyObject *__pyx_n_DLT_PRONET; 115 147 static PyObject *__pyx_n_DLT_RAW; 148 static PyObject *__pyx_n_DLT_SLIP; 149 static PyObject *__pyx_n___add_pkts; 150 static PyObject *__pyx_n___author__; 151 static PyObject *__pyx_n___copyright__; 152 static PyObject *__pyx_n___license__; 153 static PyObject *__pyx_n___url__; 154 static PyObject *__pyx_n___version__; 155 static PyObject *__pyx_n_append; 156 static PyObject *__pyx_n_dispatch; 116 157 static PyObject *__pyx_n_dltoff; 117 static PyObject *__pyx_n_ex_name; 118 static PyObject *__pyx_n_lookupdev; 119 static PyObject *__pyx_n_platform; 158 static PyObject *__pyx_n_exc_info; 120 159 static PyObject *__pyx_n_find; 121 160 static PyObject *__pyx_n_openbsd; 122 static PyObject *__pyx_n_ True;123 static PyObject *__pyx_n_ False;161 static PyObject *__pyx_n_platform; 162 static PyObject *__pyx_n_sys; 124 163 125 static PyObject *__pyx_k6p; 126 static PyObject *__pyx_k7p; 127 static PyObject *__pyx_k8p; 128 static PyObject *__pyx_k9p; 129 static PyObject *__pyx_k10p; 164 static PyObject *__pyx_k1p; 165 static PyObject *__pyx_k4p; 166 static PyObject *__pyx_k15p; 167 static PyObject *__pyx_k17p; 168 static PyObject *__pyx_k19p; 169 static PyObject *__pyx_k21p; 170 static PyObject *__pyx_k23p; 130 171 131 static void __pyx_f_4pcap___pcap_handler(void (*__pyx_v_arg),struct pcap_pkthdr (*__pyx_v_hdr),char (*__pyx_v_pkt)) { 132 struct __pyx_t_4pcap_pcap_handler_ctx (*__pyx_v_ctx); 172 static __Pyx_StringTabEntry __pyx_string_tab[] = { 173 {&__pyx_n_DLT_ARCNET, 1, __pyx_k32, sizeof(__pyx_k32)}, 174 {&__pyx_n_DLT_AX25, 1, __pyx_k28, sizeof(__pyx_k28)}, 175 {&__pyx_n_DLT_CHAOS, 1, __pyx_k30, sizeof(__pyx_k30)}, 176 {&__pyx_n_DLT_EN10MB, 1, __pyx_k26, sizeof(__pyx_k26)}, 177 {&__pyx_n_DLT_EN3MB, 1, __pyx_k27, sizeof(__pyx_k27)}, 178 {&__pyx_n_DLT_FDDI, 1, __pyx_k35, sizeof(__pyx_k35)}, 179 {&__pyx_n_DLT_IEEE802, 1, __pyx_k31, sizeof(__pyx_k31)}, 180 {&__pyx_n_DLT_LINUX_SLL, 1, __pyx_k36, sizeof(__pyx_k36)}, 181 {&__pyx_n_DLT_LOOP, 1, __pyx_k42, sizeof(__pyx_k42)}, 182 {&__pyx_n_DLT_NULL, 1, __pyx_k25, sizeof(__pyx_k25)}, 183 {&__pyx_n_DLT_PFLOG, 1, __pyx_k37, sizeof(__pyx_k37)}, 184 {&__pyx_n_DLT_PFSYNC, 1, __pyx_k38, sizeof(__pyx_k38)}, 185 {&__pyx_n_DLT_PPP, 1, __pyx_k34, sizeof(__pyx_k34)}, 186 {&__pyx_n_DLT_PRONET, 1, __pyx_k29, sizeof(__pyx_k29)}, 187 {&__pyx_n_DLT_RAW, 1, __pyx_k43, sizeof(__pyx_k43)}, 188 {&__pyx_n_DLT_SLIP, 1, __pyx_k33, sizeof(__pyx_k33)}, 189 {&__pyx_n___add_pkts, 1, __pyx_k7, sizeof(__pyx_k7)}, 190 {&__pyx_n___author__, 1, __pyx_k16, sizeof(__pyx_k16)}, 191 {&__pyx_n___copyright__, 1, __pyx_k18, sizeof(__pyx_k18)}, 192 {&__pyx_n___license__, 1, __pyx_k20, sizeof(__pyx_k20)}, 193 {&__pyx_n___url__, 1, __pyx_k22, sizeof(__pyx_k22)}, 194 {&__pyx_n___version__, 1, __pyx_k24, sizeof(__pyx_k24)}, 195 {&__pyx_n_append, 1, __pyx_k5, sizeof(__pyx_k5)}, 196 {&__pyx_n_dispatch, 1, __pyx_k6, sizeof(__pyx_k6)}, 197 {&__pyx_n_dltoff, 1, __pyx_k3, sizeof(__pyx_k3)}, 198 {&__pyx_n_exc_info, 1, __pyx_k9, sizeof(__pyx_k9)}, 199 {&__pyx_n_find, 1, __pyx_k40, sizeof(__pyx_k40)}, 200 {&__pyx_n_openbsd, 1, __pyx_k41, sizeof(__pyx_k41)}, 201 {&__pyx_n_platform, 1, __pyx_k39, sizeof(__pyx_k39)}, 202 {&__pyx_n_sys, 1, __pyx_k8, sizeof(__pyx_k8)}, 203 {&__pyx_k1p, 0, __pyx_k1, sizeof(__pyx_k1)}, 204 {&__pyx_k4p, 0, __pyx_k4, sizeof(__pyx_k4)}, 205 {&__pyx_k15p, 0, __pyx_k15, sizeof(__pyx_k15)}, 206 {&__pyx_k17p, 0, __pyx_k17, sizeof(__pyx_k17)}, 207 {&__pyx_k19p, 0, __pyx_k19, sizeof(__pyx_k19)}, 208 {&__pyx_k21p, 0, __pyx_k21, sizeof(__pyx_k21)}, 209 {&__pyx_k23p, 0, __pyx_k23, sizeof(__pyx_k23)}, 210 {0, 0, 0, 0} 211 }; 212 213 static PyObject *__pyx_d1; 214 static PyObject *__pyx_d2; 215 static PyObject *__pyx_d3; 216 static PyObject *__pyx_d4; 217 static PyObject *__pyx_d5; 218 static PyObject *__pyx_d6; 219 static PyObject *__pyx_d7; 220 static PyObject *__pyx_d8; 221 222 223 /* Implementation of pcap */ 224 225 static void __pyx_f_4pcap___pcap_handler(void *__pyx_v_arg,struct pcap_pkthdr *__pyx_v_hdr,char *__pyx_v_pkt) { 226 struct __pyx_t_4pcap_pcap_handler_ctx *__pyx_v_ctx; 133 227 int __pyx_v_gil; 134 228 PyObject *__pyx_1 = 0; 135 229 PyObject *__pyx_2 = 0; 136 230 PyObject *__pyx_3 = 0; 137 PyObject *__pyx_4 = 0;138 231 139 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":92 */140 __pyx_v_ctx = ((struct __pyx_t_4pcap_pcap_handler_ctx (*))__pyx_v_arg);232 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":92 */ 233 __pyx_v_ctx = ((struct __pyx_t_4pcap_pcap_handler_ctx *)__pyx_v_arg); 141 234 142 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":93 */235 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":93 */ 143 236 __pyx_v_gil = PyGILState_Ensure(); 144 237 145 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":94 */238 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":94 */ 146 239 /*try:*/ { 147 148 /* "/Users/dugsong/projects/pypcap/pcap.pyx":95 */ 149 __pyx_1 = (PyObject *)__pyx_v_ctx->callback; 150 Py_INCREF(__pyx_1); 151 __pyx_2 = PyFloat_FromDouble((__pyx_v_hdr->ts.tv_sec + (__pyx_v_hdr->ts.tv_usec / 1000000.0))); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L2;} 152 __pyx_3 = PyBuffer_FromMemory(__pyx_v_pkt,__pyx_v_hdr->caplen); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; goto __pyx_L2;} 153 __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L2;} 154 PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2); 155 PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3); 240 __pyx_1 = PyFloat_FromDouble((__pyx_v_hdr->ts.tv_sec + (__pyx_v_hdr->ts.tv_usec / 1000000.0))); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L2;} 241 __pyx_2 = PyBuffer_FromMemory(__pyx_v_pkt,__pyx_v_hdr->caplen); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; goto __pyx_L2;} 242 __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L2;} 243 PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1); 244 PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2); 245 __pyx_1 = 0; 156 246 __pyx_2 = 0; 157 __pyx_3 = 0; 158 __pyx_2 = (PyObject *)__pyx_v_ctx->args; 159 Py_INCREF(__pyx_2); 160 __pyx_3 = PySequence_Tuple(__pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L2;} 161 Py_DECREF(__pyx_2); __pyx_2 = 0; 162 __pyx_2 = PyNumber_Add(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L2;} 163 Py_DECREF(__pyx_4); __pyx_4 = 0; 247 __pyx_1 = PySequence_Tuple(((PyObject *)__pyx_v_ctx->args)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L2;} 248 __pyx_2 = PyNumber_Add(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L2;} 164 249 Py_DECREF(__pyx_3); __pyx_3 = 0; 165 __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L2;}166 250 Py_DECREF(__pyx_1); __pyx_1 = 0; 251 __pyx_3 = PyObject_CallObject(((PyObject *)__pyx_v_ctx->callback), __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L2;} 167 252 Py_DECREF(__pyx_2); __pyx_2 = 0; 168 Py_DECREF(__pyx_ 4); __pyx_4= 0;253 Py_DECREF(__pyx_3); __pyx_3 = 0; 169 254 } 170 255 goto __pyx_L3; 171 256 __pyx_L2:; 172 Py_XDECREF(__pyx_3); __pyx_3 = 0;173 257 Py_XDECREF(__pyx_1); __pyx_1 = 0; 174 258 Py_XDECREF(__pyx_2); __pyx_2 = 0; 175 Py_XDECREF(__pyx_ 4); __pyx_4= 0;259 Py_XDECREF(__pyx_3); __pyx_3 = 0; 176 260 177 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":98 */261 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":98 */ 178 262 /*except:*/ { 179 __Pyx_AddTraceback("pcap.__pcap_handler");180 __pyx_3 = __Pyx_GetExcValue(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; goto __pyx_L1;}181 Py_DECREF(__pyx_3); __pyx_3 = 0;182 183 /* "/Users/dugsong/projects/pypcap/pcap.pyx":99 */184 263 __pyx_v_ctx->got_exc = 1; 185 264 goto __pyx_L3; 186 265 } 187 266 __pyx_L3:; 188 267 189 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":100 */268 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":100 */ 190 269 PyGILState_Release(__pyx_v_gil); 191 270 192 goto __pyx_L0;193 __pyx_L1:;194 Py_XDECREF(__pyx_1);195 Py_XDECREF(__pyx_2);196 Py_XDECREF(__pyx_3);197 Py_XDECREF(__pyx_4);198 __Pyx_WriteUnraisable("pcap.__pcap_handler");199 __pyx_L0:;200 271 } 201 272 202 static PyObject *__pyx_n_IOError;203 204 static PyObject *__pyx_k21p;205 206 static char (__pyx_k21[]) = "bad filter";207 208 273 static int __pyx_f_4pcap_3bpf___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 209 274 static int __pyx_f_4pcap_3bpf___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { 210 char (*__pyx_v_filter);275 char *__pyx_v_filter; 211 276 PyObject *__pyx_v_dlt = 0; 212 277 int __pyx_r; 213 278 int __pyx_1; 214 279 int __pyx_2; 215 PyObject *__pyx_3 = 0;216 280 static char *__pyx_argnames[] = {"filter","dlt",0}; 217 __pyx_v_dlt = __pyx_ k13;281 __pyx_v_dlt = __pyx_d1; 218 282 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "s|O", __pyx_argnames, &__pyx_v_filter, &__pyx_v_dlt)) return -1; 219 283 Py_INCREF(__pyx_v_self); 220 284 Py_INCREF(__pyx_v_dlt); 221 222 /* "/Users/dugsong/projects/pypcap/pcap.pyx":133 */223 285 __pyx_1 = PyInt_AsLong(__pyx_v_dlt); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; goto __pyx_L1;} 224 286 __pyx_2 = (pcap_ex_compile_nopcap(65535,__pyx_1,(&((struct __pyx_obj_4pcap_bpf *)__pyx_v_self)->fcode),__pyx_v_filter,1,0) < 0); 225 287 if (__pyx_2) { 226 227 /* "/Users/dugsong/projects/pypcap/pcap.pyx":134 */ 228 __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_IOError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; goto __pyx_L1;} 229 __Pyx_Raise(__pyx_3, __pyx_k21p, 0); 230 Py_DECREF(__pyx_3); __pyx_3 = 0; 288 __Pyx_Raise(PyExc_IOError, __pyx_k1p, 0); 231 289 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; goto __pyx_L1;} 232 290 goto __pyx_L2; 233 291 } … … 236 294 __pyx_r = 0; 237 295 goto __pyx_L0; 238 296 __pyx_L1:; 239 Py_XDECREF(__pyx_3);240 297 __Pyx_AddTraceback("pcap.bpf.__init__"); 241 298 __pyx_r = -1; 242 299 __pyx_L0:; … … 245 302 return __pyx_r; 246 303 } 247 304 248 static PyObject *__pyx_n_len;249 250 305 static PyObject *__pyx_f_4pcap_3bpf_filter(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 251 306 static char __pyx_doc_4pcap_3bpf_filter[] = "Return boolean match for buf against our filter."; 252 307 static PyObject *__pyx_f_4pcap_3bpf_filter(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { 253 308 PyObject *__pyx_v_buf = 0; 254 309 int __pyx_v_n; 255 310 PyObject *__pyx_r; 256 PyObject *__pyx_1 = 0; 257 PyObject *__pyx_2 = 0; 258 PyObject *__pyx_3 = 0; 259 int __pyx_4; 260 char (*__pyx_5); 311 Py_ssize_t __pyx_1; 312 char *__pyx_2; 313 int __pyx_3; 261 314 static char *__pyx_argnames[] = {"buf",0}; 262 315 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_buf)) return 0; 263 316 Py_INCREF(__pyx_v_self); 264 317 Py_INCREF(__pyx_v_buf); 265 318 266 /* "/Users/dugsong/projects/pypcap/pcap.pyx":138 */ 267 __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; goto __pyx_L1;} 268 __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; goto __pyx_L1;} 269 Py_INCREF(__pyx_v_buf); 270 PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_buf); 271 __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; goto __pyx_L1;} 272 Py_DECREF(__pyx_1); __pyx_1 = 0; 273 Py_DECREF(__pyx_2); __pyx_2 = 0; 274 __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; goto __pyx_L1;} 275 Py_DECREF(__pyx_3); __pyx_3 = 0; 276 __pyx_v_n = __pyx_4; 277 278 /* "/Users/dugsong/projects/pypcap/pcap.pyx":139 */ 279 __pyx_5 = PyString_AsString(__pyx_v_buf); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; goto __pyx_L1;} 280 __pyx_4 = (bpf_filter(((struct __pyx_obj_4pcap_bpf *)__pyx_v_self)->fcode.bf_insns,__pyx_5,__pyx_v_n,__pyx_v_n) == 0); 281 if (__pyx_4) { 282 283 /* "/Users/dugsong/projects/pypcap/pcap.pyx":140 */ 284 __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; goto __pyx_L1;} 285 __pyx_r = __pyx_1; 286 __pyx_1 = 0; 319 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":138 */ 320 __pyx_1 = PyObject_Length(__pyx_v_buf); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; goto __pyx_L1;} 321 __pyx_v_n = __pyx_1; 322 323 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":139 */ 324 __pyx_2 = PyString_AsString(__pyx_v_buf); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; goto __pyx_L1;} 325 __pyx_3 = (bpf_filter(((struct __pyx_obj_4pcap_bpf *)__pyx_v_self)->fcode.bf_insns,__pyx_2,__pyx_v_n,__pyx_v_n) == 0); 326 if (__pyx_3) { 327 Py_INCREF(Py_False); 328 __pyx_r = Py_False; 287 329 goto __pyx_L0; 288 330 goto __pyx_L2; 289 331 } 290 332 __pyx_L2:; 291 333 292 /* "/Users/dugsong/projects/pypcap/pcap.pyx":141 */ 293 __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; goto __pyx_L1;} 294 __pyx_r = __pyx_2; 295 __pyx_2 = 0; 334 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":141 */ 335 Py_INCREF(Py_True); 336 __pyx_r = Py_True; 296 337 goto __pyx_L0; 297 338 298 __pyx_r = Py_None; Py_INCREF( __pyx_r);339 __pyx_r = Py_None; Py_INCREF(Py_None); 299 340 goto __pyx_L0; 300 341 __pyx_L1:; 301 Py_XDECREF(__pyx_1);302 Py_XDECREF(__pyx_2);303 Py_XDECREF(__pyx_3);304 342 __Pyx_AddTraceback("pcap.bpf.filter"); 305 343 __pyx_r = 0; 306 344 __pyx_L0:; … … 312 350 static void __pyx_f_4pcap_3bpf___dealloc__(PyObject *__pyx_v_self); /*proto*/ 313 351 static void __pyx_f_4pcap_3bpf___dealloc__(PyObject *__pyx_v_self) { 314 352 Py_INCREF(__pyx_v_self); 315 316 /* "/Users/dugsong/projects/pypcap/pcap.pyx":143 */317 353 pcap_freecode((&((struct __pyx_obj_4pcap_bpf *)__pyx_v_self)->fcode)); 318 354 319 goto __pyx_L0;320 __pyx_L1:;321 __Pyx_AddTraceback("pcap.bpf.__dealloc__");322 __pyx_L0:;323 355 Py_DECREF(__pyx_v_self); 324 356 } 325 357 326 static PyObject *__pyx_n_OSError;327 static PyObject *__pyx_n_KeyError;328 329 static PyObject *__pyx_k23p;330 331 static char (__pyx_k22[]) = "";332 static char (__pyx_k23[]) = "couldn't set BPF immediate mode";333 334 358 static int __pyx_f_4pcap_4pcap___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 335 359 static int __pyx_f_4pcap_4pcap___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { 336 360 PyObject *__pyx_v_name = 0; … … 338 362 PyObject *__pyx_v_promisc = 0; 339 363 PyObject *__pyx_v_timeout_ms = 0; 340 364 PyObject *__pyx_v_immediate = 0; 341 char (*__pyx_v_p);365 char *__pyx_v_p; 342 366 int __pyx_r; 343 367 int __pyx_1; 344 368 int __pyx_2; 345 369 PyObject *__pyx_3 = 0; 346 PyObject *__pyx_4 = 0;347 char (*__pyx_5);348 int __pyx_6;370 char *__pyx_4; 371 int __pyx_5; 372 PyObject *__pyx_6 = 0; 349 373 PyObject *__pyx_7 = 0; 350 374 static char *__pyx_argnames[] = {"name","snaplen","promisc","timeout_ms","immediate",0}; 351 __pyx_v_name = __pyx_ k14;352 __pyx_v_snaplen = __pyx_ k15;353 __pyx_v_promisc = __pyx_ k16;354 __pyx_v_timeout_ms = __pyx_ k17;355 __pyx_v_immediate = __pyx_ k18;375 __pyx_v_name = __pyx_d2; 376 __pyx_v_snaplen = __pyx_d3; 377 __pyx_v_promisc = __pyx_d4; 378 __pyx_v_timeout_ms = __pyx_d5; 379 __pyx_v_immediate = __pyx_d6; 356 380 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOOOO", __pyx_argnames, &__pyx_v_name, &__pyx_v_snaplen, &__pyx_v_promisc, &__pyx_v_timeout_ms, &__pyx_v_immediate)) return -1; 357 381 Py_INCREF(__pyx_v_self); 358 382 Py_INCREF(__pyx_v_name); … … 361 385 Py_INCREF(__pyx_v_timeout_ms); 362 386 Py_INCREF(__pyx_v_immediate); 363 387 364 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":168 */388 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":168 */ 365 389 __pyx_1 = PyObject_IsTrue(__pyx_v_name); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; goto __pyx_L1;} 366 390 __pyx_2 = (!__pyx_1); 367 391 if (__pyx_2) { 368 392 369 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":169 */393 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":169 */ 370 394 __pyx_v_p = pcap_ex_lookupdev(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf); 371 395 372 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":170 */373 __pyx_1 = (__pyx_v_p == 0);396 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":170 */ 397 __pyx_1 = (__pyx_v_p == NULL); 374 398 if (__pyx_1) { 375 376 /* "/Users/dugsong/projects/pypcap/pcap.pyx":171 */ 377 __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; goto __pyx_L1;} 378 __pyx_4 = PyString_FromString(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; goto __pyx_L1;} 379 __Pyx_Raise(__pyx_3, __pyx_4, 0); 399 __pyx_3 = PyString_FromString(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; goto __pyx_L1;} 400 __Pyx_Raise(PyExc_OSError, __pyx_3, 0); 380 401 Py_DECREF(__pyx_3); __pyx_3 = 0; 381 Py_DECREF(__pyx_4); __pyx_4 = 0;382 402 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; goto __pyx_L1;} 383 403 goto __pyx_L3; 384 404 } … … 386 406 goto __pyx_L2; 387 407 } 388 408 /*else*/ { 389 390 /* "/Users/dugsong/projects/pypcap/pcap.pyx":173 */ 391 __pyx_5 = PyString_AsString(__pyx_v_name); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; goto __pyx_L1;} 392 __pyx_v_p = __pyx_5; 409 __pyx_4 = PyString_AsString(__pyx_v_name); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; goto __pyx_L1;} 410 __pyx_v_p = __pyx_4; 393 411 } 394 412 __pyx_L2:; 395 413 396 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":175 */414 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":175 */ 397 415 ((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap = pcap_open_offline(__pyx_v_p,((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf); 398 416 399 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":176 */417 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":176 */ 400 418 __pyx_2 = (!(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap != 0)); 401 419 if (__pyx_2) { 402 403 /* "/Users/dugsong/projects/pypcap/pcap.pyx":177 */404 420 __pyx_1 = PyInt_AsLong(__pyx_v_snaplen); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;} 405 421 __pyx_2 = PyInt_AsLong(__pyx_v_promisc); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;} 406 __pyx_ 6= PyInt_AsLong(__pyx_v_timeout_ms); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; goto __pyx_L1;}407 ((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap = pcap_open_live(pcap_ex_name(__pyx_v_p),__pyx_1,__pyx_2,__pyx_ 6,((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf);422 __pyx_5 = PyInt_AsLong(__pyx_v_timeout_ms); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; goto __pyx_L1;} 423 ((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap = pcap_open_live(pcap_ex_name(__pyx_v_p),__pyx_1,__pyx_2,__pyx_5,((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf); 408 424 goto __pyx_L4; 409 425 } 410 426 __pyx_L4:; 411 427 412 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":179 */428 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":179 */ 413 429 __pyx_1 = (!(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap != 0)); 414 430 if (__pyx_1) { 415 416 /* "/Users/dugsong/projects/pypcap/pcap.pyx":180 */ 417 __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; goto __pyx_L1;} 418 __pyx_4 = PyString_FromString(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; goto __pyx_L1;} 419 __Pyx_Raise(__pyx_3, __pyx_4, 0); 431 __pyx_3 = PyString_FromString(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; goto __pyx_L1;} 432 __Pyx_Raise(PyExc_OSError, __pyx_3, 0); 420 433 Py_DECREF(__pyx_3); __pyx_3 = 0; 421 Py_DECREF(__pyx_4); __pyx_4 = 0;422 434 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; goto __pyx_L1;} 423 435 goto __pyx_L5; 424 436 } 425 437 __pyx_L5:; 426 438 427 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":182 */439 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":182 */ 428 440 ((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__name = strdup(__pyx_v_p); 429 441 430 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":183 */431 ((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__filter = strdup(__pyx_k2 2);442 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":183 */ 443 ((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__filter = strdup(__pyx_k2); 432 444 433 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":184 */445 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":184 */ 434 446 /*try:*/ { 435 447 __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_dltoff); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; goto __pyx_L6;} 436 __pyx_ 4 = PyInt_FromLong(pcap_datalink(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; goto __pyx_L6;}437 __pyx_7 = PyObject_GetItem(__pyx_3, __pyx_ 4); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; goto __pyx_L6;}448 __pyx_6 = PyInt_FromLong(pcap_datalink(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; goto __pyx_L6;} 449 __pyx_7 = PyObject_GetItem(__pyx_3, __pyx_6); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; goto __pyx_L6;} 438 450 Py_DECREF(__pyx_3); __pyx_3 = 0; 439 Py_DECREF(__pyx_ 4); __pyx_4= 0;451 Py_DECREF(__pyx_6); __pyx_6 = 0; 440 452 __pyx_2 = PyInt_AsLong(__pyx_7); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; goto __pyx_L6;} 441 453 Py_DECREF(__pyx_7); __pyx_7 = 0; 442 454 ((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__dloff = __pyx_2; … … 444 456 goto __pyx_L7; 445 457 __pyx_L6:; 446 458 Py_XDECREF(__pyx_3); __pyx_3 = 0; 447 Py_XDECREF(__pyx_ 4); __pyx_4= 0;459 Py_XDECREF(__pyx_6); __pyx_6 = 0; 448 460 Py_XDECREF(__pyx_7); __pyx_7 = 0; 449 461 450 /* "/Users/dugsong/projects/pypcap/pcap.pyx":185 */ 451 __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_KeyError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; goto __pyx_L1;} 452 __pyx_6 = PyErr_ExceptionMatches(__pyx_3); 453 Py_DECREF(__pyx_3); __pyx_3 = 0; 454 if (__pyx_6) { 455 __Pyx_AddTraceback("pcap.__init__"); 456 __pyx_4 = __Pyx_GetExcValue(); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; goto __pyx_L1;} 457 Py_DECREF(__pyx_4); __pyx_4 = 0; 462 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":185 */ 463 __pyx_5 = PyErr_ExceptionMatches(PyExc_KeyError); 464 if (__pyx_5) { 458 465 goto __pyx_L7; 459 466 } 460 467 goto __pyx_L1; 461 468 __pyx_L7:; 462 469 463 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":186 */464 __pyx_ 7= __pyx_v_immediate;465 Py_INCREF(__pyx_ 7);466 __pyx_1 = PyObject_IsTrue(__pyx_ 7); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; goto __pyx_L1;}470 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":186 */ 471 __pyx_3 = __pyx_v_immediate; 472 Py_INCREF(__pyx_3); 473 __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; goto __pyx_L1;} 467 474 if (__pyx_1) { 468 Py_DECREF(__pyx_ 7); __pyx_7= 0;469 __pyx_ 7 = PyInt_FromLong((pcap_ex_immediate(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap) < 0)); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; goto __pyx_L1;}475 Py_DECREF(__pyx_3); __pyx_3 = 0; 476 __pyx_3 = PyInt_FromLong((pcap_ex_immediate(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap) < 0)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; goto __pyx_L1;} 470 477 } 471 __pyx_2 = PyObject_IsTrue(__pyx_ 7); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; goto __pyx_L1;}472 Py_DECREF(__pyx_ 7); __pyx_7= 0;478 __pyx_2 = PyObject_IsTrue(__pyx_3); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; goto __pyx_L1;} 479 Py_DECREF(__pyx_3); __pyx_3 = 0; 473 480 if (__pyx_2) { 474 475 /* "/Users/dugsong/projects/pypcap/pcap.pyx":187 */ 476 __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; goto __pyx_L1;} 477 __Pyx_Raise(__pyx_3, __pyx_k23p, 0); 478 Py_DECREF(__pyx_3); __pyx_3 = 0; 481 __Pyx_Raise(PyExc_OSError, __pyx_k4p, 0); 479 482 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; goto __pyx_L1;} 480 483 goto __pyx_L8; 481 484 } … … 485 488 goto __pyx_L0; 486 489 __pyx_L1:; 487 490 Py_XDECREF(__pyx_3); 488 Py_XDECREF(__pyx_ 4);491 Py_XDECREF(__pyx_6); 489 492 Py_XDECREF(__pyx_7); 490 493 __Pyx_AddTraceback("pcap.pcap.__init__"); 491 494 __pyx_r = -1; … … 504 507 PyObject *__pyx_r; 505 508 PyObject *__pyx_1 = 0; 506 509 Py_INCREF(__pyx_v_self); 507 508 /* "/Users/dugsong/projects/pypcap/pcap.pyx":192 */509 510 __pyx_1 = PyString_FromString(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__name); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; goto __pyx_L1;} 510 511 __pyx_r = __pyx_1; 511 512 __pyx_1 = 0; 512 513 goto __pyx_L0; 513 514 514 __pyx_r = Py_None; Py_INCREF( __pyx_r);515 __pyx_r = Py_None; Py_INCREF(Py_None); 515 516 goto __pyx_L0; 516 517 __pyx_L1:; 517 518 Py_XDECREF(__pyx_1); … … 527 528 PyObject *__pyx_r; 528 529 PyObject *__pyx_1 = 0; 529 530 Py_INCREF(__pyx_v_self); 530 531 /* "/Users/dugsong/projects/pypcap/pcap.pyx":197 */532 531 __pyx_1 = PyInt_FromLong(pcap_snapshot(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; goto __pyx_L1;} 533 532 __pyx_r = __pyx_1; 534 533 __pyx_1 = 0; 535 534 goto __pyx_L0; 536 535 537 __pyx_r = Py_None; Py_INCREF( __pyx_r);536 __pyx_r = Py_None; Py_INCREF(Py_None); 538 537 goto __pyx_L0; 539 538 __pyx_L1:; 540 539 Py_XDECREF(__pyx_1); … … 550 549 PyObject *__pyx_r; 551 550 PyObject *__pyx_1 = 0; 552 551 Py_INCREF(__pyx_v_self); 553 554 /* "/Users/dugsong/projects/pypcap/pcap.pyx":202 */555 552 __pyx_1 = PyInt_FromLong(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__dloff); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; goto __pyx_L1;} 556 553 __pyx_r = __pyx_1; 557 554 __pyx_1 = 0; 558 555 goto __pyx_L0; 559 556 560 __pyx_r = Py_None; Py_INCREF( __pyx_r);557 __pyx_r = Py_None; Py_INCREF(Py_None); 561 558 goto __pyx_L0; 562 559 __pyx_L1:; 563 560 Py_XDECREF(__pyx_1); … … 573 570 PyObject *__pyx_r; 574 571 PyObject *__pyx_1 = 0; 575 572 Py_INCREF(__pyx_v_self); 576 577 /* "/Users/dugsong/projects/pypcap/pcap.pyx":207 */578 573 __pyx_1 = PyString_FromString(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__filter); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; goto __pyx_L1;} 579 574 __pyx_r = __pyx_1; 580 575 __pyx_1 = 0; 581 576 goto __pyx_L0; 582 577 583 __pyx_r = Py_None; Py_INCREF( __pyx_r);578 __pyx_r = Py_None; Py_INCREF(Py_None); 584 579 goto __pyx_L0; 585 580 __pyx_L1:; 586 581 Py_XDECREF(__pyx_1); … … 596 591 PyObject *__pyx_r; 597 592 PyObject *__pyx_1 = 0; 598 593 Py_INCREF(__pyx_v_self); 599 600 /* "/Users/dugsong/projects/pypcap/pcap.pyx":212 */601 594 __pyx_1 = PyInt_FromLong(pcap_ex_fileno(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; goto __pyx_L1;} 602 595 __pyx_r = __pyx_1; 603 596 __pyx_1 = 0; 604 597 goto __pyx_L0; 605 598 606 __pyx_r = Py_None; Py_INCREF( __pyx_r);599 __pyx_r = Py_None; Py_INCREF(Py_None); 607 600 goto __pyx_L0; 608 601 __pyx_L1:; 609 602 Py_XDECREF(__pyx_1); … … 622 615 static char *__pyx_argnames[] = {0}; 623 616 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; 624 617 Py_INCREF(__pyx_v_self); 625 626 /* "/Users/dugsong/projects/pypcap/pcap.pyx":216 */627 618 __pyx_1 = PyInt_FromLong(pcap_ex_fileno(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;} 628 619 __pyx_r = __pyx_1; 629 620 __pyx_1 = 0; 630 621 goto __pyx_L0; 631 622 632 __pyx_r = Py_None; Py_INCREF( __pyx_r);623 __pyx_r = Py_None; Py_INCREF(Py_None); 633 624 goto __pyx_L0; 634 625 __pyx_L1:; 635 626 Py_XDECREF(__pyx_1); … … 647 638 PyObject *__pyx_v_optimize = 0; 648 639 struct bpf_program __pyx_v_fcode; 649 640 PyObject *__pyx_r; 650 char (*__pyx_1);641 char *__pyx_1; 651 642 int __pyx_2; 652 643 int __pyx_3; 653 644 PyObject *__pyx_4 = 0; 654 PyObject *__pyx_5 = 0;655 645 static char *__pyx_argnames[] = {"value","optimize",0}; 656 __pyx_v_optimize = __pyx_ k19;646 __pyx_v_optimize = __pyx_d7; 657 647 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_value, &__pyx_v_optimize)) return 0; 658 648 Py_INCREF(__pyx_v_self); 659 649 Py_INCREF(__pyx_v_value); 660 650 Py_INCREF(__pyx_v_optimize); 661 651 662 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":221 */652 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":221 */ 663 653 free(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__filter); 664 654 665 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":222 */666 __pyx_1 = PyString_AsString(__pyx_v_value); if ( PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; goto __pyx_L1;}655 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":222 */ 656 __pyx_1 = PyString_AsString(__pyx_v_value); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; goto __pyx_L1;} 667 657 ((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__filter = strdup(__pyx_1); 668 658 669 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":223 */659 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":223 */ 670 660 __pyx_2 = PyInt_AsLong(__pyx_v_optimize); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;} 671 661 __pyx_3 = (pcap_compile(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,(&__pyx_v_fcode),((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__filter,__pyx_2,0) < 0); 672 662 if (__pyx_3) { 673 674 /* "/Users/dugsong/projects/pypcap/pcap.pyx":224 */ 675 __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; goto __pyx_L1;} 676 __pyx_5 = PyString_FromString(pcap_geterr(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; goto __pyx_L1;} 677 __Pyx_Raise(__pyx_4, __pyx_5, 0); 663 __pyx_4 = PyString_FromString(pcap_geterr(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; goto __pyx_L1;} 664 __Pyx_Raise(PyExc_OSError, __pyx_4, 0); 678 665 Py_DECREF(__pyx_4); __pyx_4 = 0; 679 Py_DECREF(__pyx_5); __pyx_5 = 0;680 666 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; goto __pyx_L1;} 681 667 goto __pyx_L2; 682 668 } 683 669 __pyx_L2:; 684 670 685 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":225 */671 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":225 */ 686 672 __pyx_2 = (pcap_setfilter(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,(&__pyx_v_fcode)) < 0); 687 673 if (__pyx_2) { 688 689 /* "/Users/dugsong/projects/pypcap/pcap.pyx":226 */ 690 __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} 691 __pyx_5 = PyString_FromString(pcap_geterr(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} 692 __Pyx_Raise(__pyx_4, __pyx_5, 0); 674 __pyx_4 = PyString_FromString(pcap_geterr(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} 675 __Pyx_Raise(PyExc_OSError, __pyx_4, 0); 693 676 Py_DECREF(__pyx_4); __pyx_4 = 0; 694 Py_DECREF(__pyx_5); __pyx_5 = 0;695 677 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; goto __pyx_L1;} 696 678 goto __pyx_L3; 697 679 } 698 680 __pyx_L3:; 699 681 700 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":227 */682 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":227 */ 701 683 pcap_freecode((&__pyx_v_fcode)); 702 684 703 __pyx_r = Py_None; Py_INCREF( __pyx_r);685 __pyx_r = Py_None; Py_INCREF(Py_None); 704 686 goto __pyx_L0; 705 687 __pyx_L1:; 706 688 Py_XDECREF(__pyx_4); 707 Py_XDECREF(__pyx_5);708 689 __Pyx_AddTraceback("pcap.pcap.setfilter"); 709 690 __pyx_r = 0; 710 691 __pyx_L0:; … … 721 702 PyObject *__pyx_r; 722 703 int __pyx_1; 723 704 static char *__pyx_argnames[] = {"nonblock",0}; 724 __pyx_v_nonblock = __pyx_ k20;705 __pyx_v_nonblock = __pyx_d8; 725 706 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_nonblock)) return 0; 726 707 Py_INCREF(__pyx_v_self); 727 708 Py_INCREF(__pyx_v_nonblock); 728 729 /* "/Users/dugsong/projects/pypcap/pcap.pyx":231 */730 709 __pyx_1 = PyInt_AsLong(__pyx_v_nonblock); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;} 731 710 pcap_ex_setnonblock(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,__pyx_1,((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf); 732 711 733 __pyx_r = Py_None; Py_INCREF( __pyx_r);712 __pyx_r = Py_None; Py_INCREF(Py_None); 734 713 goto __pyx_L0; 735 714 __pyx_L1:; 736 715 __Pyx_AddTraceback("pcap.pcap.setnonblock"); … … 748 727 PyObject *__pyx_r; 749 728 PyObject *__pyx_1 = 0; 750 729 int __pyx_2; 751 PyObject *__pyx_3 = 0;752 730 static char *__pyx_argnames[] = {0}; 753 731 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; 754 732 Py_INCREF(__pyx_v_self); 755 __pyx_v_ret = Py_None; Py_INCREF( __pyx_v_ret);733 __pyx_v_ret = Py_None; Py_INCREF(Py_None); 756 734 757 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":235 */735 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":235 */ 758 736 __pyx_1 = PyInt_FromLong(pcap_ex_getnonblock(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; goto __pyx_L1;} 759 737 Py_DECREF(__pyx_v_ret); 760 738 __pyx_v_ret = __pyx_1; 761 739 __pyx_1 = 0; 762 740 763 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":236 */741 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":236 */ 764 742 __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; goto __pyx_L1;} 765 743 if (PyObject_Cmp(__pyx_v_ret, __pyx_1, &__pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; goto __pyx_L1;} 766 744 __pyx_2 = __pyx_2 < 0; 767 745 Py_DECREF(__pyx_1); __pyx_1 = 0; 768 746 if (__pyx_2) { 769 770 /* "/Users/dugsong/projects/pypcap/pcap.pyx":237 */ 771 __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; goto __pyx_L1;} 772 __pyx_3 = PyString_FromString(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; goto __pyx_L1;} 773 __Pyx_Raise(__pyx_1, __pyx_3, 0); 747 __pyx_1 = PyString_FromString(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; goto __pyx_L1;} 748 __Pyx_Raise(PyExc_OSError, __pyx_1, 0); 774 749 Py_DECREF(__pyx_1); __pyx_1 = 0; 775 Py_DECREF(__pyx_3); __pyx_3 = 0;776 750 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; goto __pyx_L1;} 777 751 goto __pyx_L2; 778 752 } 779 753 __pyx_2 = PyObject_IsTrue(__pyx_v_ret); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; goto __pyx_L1;} 780 754 if (__pyx_2) { 781 782 /* "/Users/dugsong/projects/pypcap/pcap.pyx":239 */ 783 __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; goto __pyx_L1;} 784 __pyx_r = __pyx_1; 785 __pyx_1 = 0; 755 Py_INCREF(Py_True); 756 __pyx_r = Py_True; 786 757 goto __pyx_L0; 787 758 goto __pyx_L2; 788 759 } 789 760 __pyx_L2:; 790 761 791 /* "/Users/dugsong/projects/pypcap/pcap.pyx":240 */ 792 __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; goto __pyx_L1;} 793 __pyx_r = __pyx_3; 794 __pyx_3 = 0; 762 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":240 */ 763 Py_INCREF(Py_False); 764 __pyx_r = Py_False; 795 765 goto __pyx_L0; 796 766 797 __pyx_r = Py_None; Py_INCREF( __pyx_r);767 __pyx_r = Py_None; Py_INCREF(Py_None); 798 768 goto __pyx_L0; 799 769 __pyx_L1:; 800 770 Py_XDECREF(__pyx_1); 801 Py_XDECREF(__pyx_3);802 771 __Pyx_AddTraceback("pcap.pcap.getnonblock"); 803 772 __pyx_r = 0; 804 773 __pyx_L0:; … … 815 784 static char *__pyx_argnames[] = {0}; 816 785 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; 817 786 Py_INCREF(__pyx_v_self); 818 819 /* "/Users/dugsong/projects/pypcap/pcap.pyx":244 */820 787 __pyx_1 = PyInt_FromLong(pcap_datalink(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; goto __pyx_L1;} 821 788 __pyx_r = __pyx_1; 822 789 __pyx_1 = 0; 823 790 goto __pyx_L0; 824 791 825 __pyx_r = Py_None; Py_INCREF( __pyx_r);792 __pyx_r = Py_None; Py_INCREF(Py_None); 826 793 goto __pyx_L0; 827 794 __pyx_L1:; 828 795 Py_XDECREF(__pyx_1); … … 837 804 static char __pyx_doc_4pcap_4pcap_next[] = "Return the next (timestamp, packet) tuple, or None on error."; 838 805 static PyObject *__pyx_f_4pcap_4pcap_next(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { 839 806 struct pcap_pkthdr __pyx_v_hdr; 840 char (*__pyx_v_pkt);807 char *__pyx_v_pkt; 841 808 PyObject *__pyx_r; 842 809 int __pyx_1; 843 810 PyObject *__pyx_2 = 0; … … 847 814 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; 848 815 Py_INCREF(__pyx_v_self); 849 816 850 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":250 */851 __pyx_v_pkt = ((char (*))pcap_next(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,(&__pyx_v_hdr)));817 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":250 */ 818 __pyx_v_pkt = ((char *)pcap_next(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,(&__pyx_v_hdr))); 852 819 853 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":251 */820 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":251 */ 854 821 __pyx_1 = (!(__pyx_v_pkt != 0)); 855 822 if (__pyx_1) { 856 857 /* "/Users/dugsong/projects/pypcap/pcap.pyx":252 */858 823 Py_INCREF(Py_None); 859 824 __pyx_r = Py_None; 860 825 goto __pyx_L0; … … 862 827 } 863 828 __pyx_L2:; 864 829 865 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":253 */830 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":253 */ 866 831 __pyx_2 = PyFloat_FromDouble((__pyx_v_hdr.ts.tv_sec + (__pyx_v_hdr.ts.tv_usec / 1000000.0))); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; goto __pyx_L1;} 867 832 __pyx_3 = PyBuffer_FromMemory(__pyx_v_pkt,__pyx_v_hdr.caplen); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; goto __pyx_L1;} 868 833 __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; goto __pyx_L1;} … … 874 839 __pyx_4 = 0; 875 840 goto __pyx_L0; 876 841 877 __pyx_r = Py_None; Py_INCREF( __pyx_r);842 __pyx_r = Py_None; Py_INCREF(Py_None); 878 843 goto __pyx_L0; 879 844 __pyx_L1:; 880 845 Py_XDECREF(__pyx_2); … … 887 852 return __pyx_r; 888 853 } 889 854 890 static PyObject *__pyx_n_append;891 892 855 static PyObject *__pyx_f_4pcap_4pcap___add_pkts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 893 856 static PyObject *__pyx_f_4pcap_4pcap___add_pkts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { 894 857 PyObject *__pyx_v_ts = 0; … … 904 867 Py_INCREF(__pyx_v_ts); 905 868 Py_INCREF(__pyx_v_pkt); 906 869 Py_INCREF(__pyx_v_pkts); 907 908 /* "/Users/dugsong/projects/pypcap/pcap.pyx":257 */909 870 __pyx_1 = PyObject_GetAttr(__pyx_v_pkts, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; goto __pyx_L1;} 910 871 __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; goto __pyx_L1;} 911 872 Py_INCREF(__pyx_v_ts); … … 920 881 Py_DECREF(__pyx_3); __pyx_3 = 0; 921 882 Py_DECREF(__pyx_2); __pyx_2 = 0; 922 883 923 __pyx_r = Py_None; Py_INCREF( __pyx_r);884 __pyx_r = Py_None; Py_INCREF(Py_None); 924 885 goto __pyx_L0; 925 886 __pyx_L1:; 926 887 Py_XDECREF(__pyx_1); … … 936 897 return __pyx_r; 937 898 } 938 899 939 static PyObject *__pyx_n_dispatch;940 static PyObject *__pyx_n___add_pkts;941 942 900 static PyObject *__pyx_f_4pcap_4pcap_readpkts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 943 901 static char __pyx_doc_4pcap_4pcap_readpkts[] = "Return a list of (timestamp, packet) tuples received in one buffer."; 944 902 static PyObject *__pyx_f_4pcap_4pcap_readpkts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { … … 951 909 static char *__pyx_argnames[] = {0}; 952 910 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; 953 911 Py_INCREF(__pyx_v_self); 954 __pyx_v_pkts = Py_None; Py_INCREF( __pyx_v_pkts);912 __pyx_v_pkts = Py_None; Py_INCREF(Py_None); 955 913 956 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":261 */914 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":261 */ 957 915 __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; goto __pyx_L1;} 958 916 Py_DECREF(__pyx_v_pkts); 959 917 __pyx_v_pkts = __pyx_1; 960 918 __pyx_1 = 0; 961 919 962 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":262 */920 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":262 */ 963 921 __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_dispatch); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; goto __pyx_L1;} 964 922 __pyx_2 = PyInt_FromLong((-1)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; goto __pyx_L1;} 965 923 __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n___add_pkts); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; goto __pyx_L1;} … … 975 933 Py_DECREF(__pyx_4); __pyx_4 = 0; 976 934 Py_DECREF(__pyx_2); __pyx_2 = 0; 977 935 978 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":263 */936 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":263 */ 979 937 Py_INCREF(__pyx_v_pkts); 980 938 __pyx_r = __pyx_v_pkts; 981 939 goto __pyx_L0; 982 940 983 __pyx_r = Py_None; Py_INCREF( __pyx_r);941 __pyx_r = Py_None; Py_INCREF(Py_None); 984 942 goto __pyx_L0; 985 943 __pyx_L1:; 986 944 Py_XDECREF(__pyx_1); … … 995 953 return __pyx_r; 996 954 } 997 955 998 static PyObject *__pyx_n_exc_info;999 1000 956 static PyObject *__pyx_f_4pcap_4pcap_dispatch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 1001 957 static char __pyx_doc_4pcap_4pcap_dispatch[] = "Collect and process packets with a user callback,\n return the number of packets processed, or 0 for a savefile.\n \n Arguments:\n \n cnt -- number of packets to process;\n or 0 to process all packets until an error occurs,\n EOF is reached, or the read times out;\n or -1 to process all packets received in one buffer\n callback -- function with (timestamp, pkt, *args) prototype\n *args -- optional arguments passed to callback on execution\n "; 1002 958 static PyObject *__pyx_f_4pcap_4pcap_dispatch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { … … 1013 969 PyObject *__pyx_4 = 0; 1014 970 PyObject *__pyx_5 = 0; 1015 971 static char *__pyx_argnames[] = {"cnt","callback",0}; 1016 if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 2, &__pyx_v_args, 0 ) < 0) return 0;972 if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 2, &__pyx_v_args, 0, 0) < 0) return 0; 1017 973 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_cnt, &__pyx_v_callback)) { 1018 974 Py_XDECREF(__pyx_args); 1019 975 Py_XDECREF(__pyx_kwds); … … 1023 979 Py_INCREF(__pyx_v_self); 1024 980 Py_INCREF(__pyx_v_cnt); 1025 981 Py_INCREF(__pyx_v_callback); 1026 __pyx_v_exc = Py_None; Py_INCREF( __pyx_v_exc);982 __pyx_v_exc = Py_None; Py_INCREF(Py_None); 1027 983 1028 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":281 */1029 __pyx_v_ctx.callback = ((void (*))__pyx_v_callback);984 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":281 */ 985 __pyx_v_ctx.callback = ((void *)__pyx_v_callback); 1030 986 1031 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":282 */1032 __pyx_v_ctx.args = ((void (*))__pyx_v_args);987 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":282 */ 988 __pyx_v_ctx.args = ((void *)__pyx_v_args); 1033 989 1034 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":283 */990 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":283 */ 1035 991 __pyx_v_ctx.got_exc = 0; 1036 992 1037 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":284 */993 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":284 */ 1038 994 __pyx_1 = PyInt_AsLong(__pyx_v_cnt); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; goto __pyx_L1;} 1039 __pyx_v_n = pcap_dispatch(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,__pyx_1,__pyx_f_4pcap___pcap_handler,((unsigned char (*))(&__pyx_v_ctx)));995 __pyx_v_n = pcap_dispatch(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,__pyx_1,__pyx_f_4pcap___pcap_handler,((unsigned char *)(&__pyx_v_ctx))); 1040 996 1041 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":286 */997 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":286 */ 1042 998 __pyx_1 = __pyx_v_ctx.got_exc; 1043 999 if (__pyx_1) { 1044 1000 1045 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":287 */1001 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":287 */ 1046 1002 __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_sys); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;} 1047 1003 __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_exc_info); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;} 1048 1004 Py_DECREF(__pyx_2); __pyx_2 = 0; 1049 __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;} 1050 __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;} 1005 __pyx_2 = PyObject_CallObject(__pyx_3, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;} 1051 1006 Py_DECREF(__pyx_3); __pyx_3 = 0; 1052 Py_DECREF(__pyx_2); __pyx_2 = 0;1053 1007 Py_DECREF(__pyx_v_exc); 1054 __pyx_v_exc = __pyx_ 4;1055 __pyx_ 4= 0;1008 __pyx_v_exc = __pyx_2; 1009 __pyx_2 = 0; 1056 1010 1057 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":288 */1011 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":288 */ 1058 1012 __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} 1059 1013 __pyx_2 = PyObject_GetItem(__pyx_v_exc, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} 1060 1014 Py_DECREF(__pyx_3); __pyx_3 = 0; 1061 __pyx_4 = PyInt_FromLong(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} 1062 __pyx_3 = PyObject_GetItem(__pyx_v_exc, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} 1063 Py_DECREF(__pyx_4); __pyx_4 = 0; 1064 __pyx_4 = PyInt_FromLong(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} 1065 __pyx_5 = PyObject_GetItem(__pyx_v_exc, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} 1066 Py_DECREF(__pyx_4); __pyx_4 = 0; 1067 __Pyx_Raise(__pyx_2, __pyx_3, __pyx_5); 1068 Py_DECREF(__pyx_2); __pyx_2 = 0; 1015 __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} 1016 __pyx_4 = PyObject_GetItem(__pyx_v_exc, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} 1017 Py_DECREF(__pyx_3); __pyx_3 = 0; 1018 __pyx_3 = PyInt_FromLong(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} 1019 __pyx_5 = PyObject_GetItem(__pyx_v_exc, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} 1069 1020 Py_DECREF(__pyx_3); __pyx_3 = 0; 1021 __Pyx_Raise(__pyx_2, __pyx_4, __pyx_5); 1022 Py_DECREF(__pyx_2); __pyx_2 = 0; 1023 Py_DECREF(__pyx_4); __pyx_4 = 0; 1070 1024 Py_DECREF(__pyx_5); __pyx_5 = 0; 1071 1025 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;} 1072 1026 goto __pyx_L2; 1073 1027 } 1074 1028 __pyx_L2:; 1075 1029 1076 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":289 */1077 __pyx_ 4 = PyInt_FromLong(__pyx_v_n); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;}1078 __pyx_r = __pyx_ 4;1079 __pyx_ 4= 0;1030 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":289 */ 1031 __pyx_3 = PyInt_FromLong(__pyx_v_n); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;} 1032 __pyx_r = __pyx_3; 1033 __pyx_3 = 0; 1080 1034 goto __pyx_L0; 1081 1035 1082 __pyx_r = Py_None; Py_INCREF( __pyx_r);1036 __pyx_r = Py_None; Py_INCREF(Py_None); 1083 1037 goto __pyx_L0; 1084 1038 __pyx_L1:; 1085 1039 Py_XDECREF(__pyx_2); … … 1099 1053 return __pyx_r; 1100 1054 } 1101 1055 1102 static PyObject *__pyx_n_KeyboardInterrupt;1103 1104 1056 static PyObject *__pyx_f_4pcap_4pcap_loop(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 1105 1057 static char __pyx_doc_4pcap_4pcap_loop[] = "Loop forever, processing packets with a user callback.\n The loop can be exited with an exception, including KeyboardInterrupt.\n \n Arguments:\n\n callback -- function with (timestamp, pkt, *args) prototype\n *args -- optional arguments passed to callback on execution\n "; 1106 1058 static PyObject *__pyx_f_4pcap_4pcap_loop(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { 1107 1059 PyObject *__pyx_v_callback = 0; 1108 1060 PyObject *__pyx_v_args = 0; 1109 struct pcap_pkthdr (*__pyx_v_hdr);1110 char (*__pyx_v_pkt);1061 struct pcap_pkthdr *__pyx_v_hdr; 1062 char *__pyx_v_pkt; 1111 1063 int __pyx_v_n; 1112 1064 PyObject *__pyx_r; 1113 1065 long __pyx_1; … … 1116 1068 PyObject *__pyx_4 = 0; 1117 1069 PyObject *__pyx_5 = 0; 1118 1070 static char *__pyx_argnames[] = {"callback",0}; 1119 if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 1, &__pyx_v_args, 0 ) < 0) return 0;1071 if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 1, &__pyx_v_args, 0, 0) < 0) return 0; 1120 1072 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_callback)) { 1121 1073 Py_XDECREF(__pyx_args); 1122 1074 Py_XDECREF(__pyx_kwds); … … 1126 1078 Py_INCREF(__pyx_v_self); 1127 1079 Py_INCREF(__pyx_v_callback); 1128 1080 1129 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":303 */1081 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":303 */ 1130 1082 pcap_ex_setup(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap); 1131 1083 1132 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":304 */1084 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":304 */ 1133 1085 while (1) { 1134 __pyx_L2:;1135 1086 __pyx_1 = 1; 1136 1087 if (!__pyx_1) break; 1137 1088 1138 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":305 */1089 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":305 */ 1139 1090 Py_BEGIN_ALLOW_THREADS; 1140 1091 1141 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":306 */1092 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":306 */ 1142 1093 __pyx_v_n = pcap_ex_next(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,(&__pyx_v_hdr),(&__pyx_v_pkt)); 1143 1094 1144 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":307 */1095 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":307 */ 1145 1096 Py_END_ALLOW_THREADS; 1146 1097 1147 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":308 */1098 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":308 */ 1148 1099 __pyx_2 = (__pyx_v_n == 1); 1149 1100 if (__pyx_2) { 1150 1151 /* "/Users/dugsong/projects/pypcap/pcap.pyx":309 */1152 1101 __pyx_3 = PyFloat_FromDouble((__pyx_v_hdr->ts.tv_sec + (__pyx_v_hdr->ts.tv_usec / 1000000.0))); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; goto __pyx_L1;} 1153 1102 __pyx_4 = PyBuffer_FromMemory(__pyx_v_pkt,__pyx_v_hdr->caplen); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; goto __pyx_L1;} 1154 1103 __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; goto __pyx_L1;} … … 1167 1116 } 1168 1117 __pyx_2 = (__pyx_v_n == (-1)); 1169 1118 if (__pyx_2) { 1170 1171 /* "/Users/dugsong/projects/pypcap/pcap.pyx":312 */ 1172 __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_KeyboardInterrupt); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; goto __pyx_L1;} 1173 __Pyx_Raise(__pyx_3, 0, 0); 1174 Py_DECREF(__pyx_3); __pyx_3 = 0; 1119 __Pyx_Raise(PyExc_KeyboardInterrupt, 0, 0); 1175 1120 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; goto __pyx_L1;} 1176 1121 goto __pyx_L4; 1177 1122 } 1178 1123 __pyx_2 = (__pyx_v_n == (-2)); 1179 1124 if (__pyx_2) { 1180 1181 /* "/Users/dugsong/projects/pypcap/pcap.pyx":314 */1182 1125 goto __pyx_L3; 1183 1126 goto __pyx_L4; 1184 1127 } … … 1186 1129 } 1187 1130 __pyx_L3:; 1188 1131 1189 __pyx_r = Py_None; Py_INCREF( __pyx_r);1132 __pyx_r = Py_None; Py_INCREF(Py_None); 1190 1133 goto __pyx_L0; 1191 1134 __pyx_L1:; 1192 1135 Py_XDECREF(__pyx_3); … … 1211 1154 static char *__pyx_argnames[] = {0}; 1212 1155 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; 1213 1156 Py_INCREF(__pyx_v_self); 1214 1215 /* "/Users/dugsong/projects/pypcap/pcap.pyx":318 */1216 1157 __pyx_1 = PyString_FromString(pcap_geterr(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;} 1217 1158 __pyx_r = __pyx_1; 1218 1159 __pyx_1 = 0; 1219 1160 goto __pyx_L0; 1220 1161 1221 __pyx_r = Py_None; Py_INCREF( __pyx_r);1162 __pyx_r = Py_None; Py_INCREF(Py_None); 1222 1163 goto __pyx_L0; 1223 1164 __pyx_L1:; 1224 1165 Py_XDECREF(__pyx_1); … … 1243 1184 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; 1244 1185 Py_INCREF(__pyx_v_self); 1245 1186 1246 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":324 */1187 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":324 */ 1247 1188 __pyx_1 = (pcap_stats(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,(&__pyx_v_pstat)) < 0); 1248 1189 if (__pyx_1) { 1249 1250 /* "/Users/dugsong/projects/pypcap/pcap.pyx":325 */ 1251 __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; goto __pyx_L1;} 1252 __pyx_3 = PyString_FromString(pcap_geterr(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; goto __pyx_L1;} 1253 __Pyx_Raise(__pyx_2, __pyx_3, 0); 1190 __pyx_2 = PyString_FromString(pcap_geterr(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; goto __pyx_L1;} 1191 __Pyx_Raise(PyExc_OSError, __pyx_2, 0); 1254 1192 Py_DECREF(__pyx_2); __pyx_2 = 0; 1255 Py_DECREF(__pyx_3); __pyx_3 = 0;1256 1193 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; goto __pyx_L1;} 1257 1194 goto __pyx_L2; 1258 1195 } 1259 1196 __pyx_L2:; 1260 1197 1261 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":326 */1262 __pyx_2 = Py Int_FromLong(__pyx_v_pstat.ps_recv); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;}1263 __pyx_3 = Py Int_FromLong(__pyx_v_pstat.ps_drop); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;}1264 __pyx_4 = Py Int_FromLong(__pyx_v_pstat.ps_ifdrop); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;}1198 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":326 */ 1199 __pyx_2 = PyLong_FromUnsignedLong(__pyx_v_pstat.ps_recv); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} 1200 __pyx_3 = PyLong_FromUnsignedLong(__pyx_v_pstat.ps_drop); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} 1201 __pyx_4 = PyLong_FromUnsignedLong(__pyx_v_pstat.ps_ifdrop); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} 1265 1202 __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;} 1266 1203 PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2); 1267 1204 PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3); … … 1273 1210 __pyx_5 = 0; 1274 1211 goto __pyx_L0; 1275 1212 1276 __pyx_r = Py_None; Py_INCREF( __pyx_r);1213 __pyx_r = Py_None; Py_INCREF(Py_None); 1277 1214 goto __pyx_L0; 1278 1215 __pyx_L1:; 1279 1216 Py_XDECREF(__pyx_2); … … 1292 1229 PyObject *__pyx_r; 1293 1230 Py_INCREF(__pyx_v_self); 1294 1231 1295 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":329 */1232 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":329 */ 1296 1233 pcap_ex_setup(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap); 1297 1234 1298 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":330 */1235 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":330 */ 1299 1236 Py_INCREF(__pyx_v_self); 1300 1237 __pyx_r = __pyx_v_self; 1301 1238 goto __pyx_L0; 1302 1239 1303 __pyx_r = Py_None; Py_INCREF(__pyx_r); 1304 goto __pyx_L0; 1305 __pyx_L1:; 1306 __Pyx_AddTraceback("pcap.pcap.__iter__"); 1307 __pyx_r = 0; 1240 __pyx_r = Py_None; Py_INCREF(Py_None); 1308 1241 __pyx_L0:; 1309 1242 Py_DECREF(__pyx_v_self); 1310 1243 return __pyx_r; 1311 1244 } 1312 1245 1313 static PyObject *__pyx_n_StopIteration;1314 1315 1246 static PyObject *__pyx_f_4pcap_4pcap___next__(PyObject *__pyx_v_self); /*proto*/ 1316 1247 static PyObject *__pyx_f_4pcap_4pcap___next__(PyObject *__pyx_v_self) { 1317 struct pcap_pkthdr (*__pyx_v_hdr);1318 char (*__pyx_v_pkt);1248 struct pcap_pkthdr *__pyx_v_hdr; 1249 char *__pyx_v_pkt; 1319 1250 int __pyx_v_n; 1320 1251 PyObject *__pyx_r; 1321 1252 long __pyx_1; … … 1325 1256 PyObject *__pyx_5 = 0; 1326 1257 Py_INCREF(__pyx_v_self); 1327 1258 1328 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":336 */1259 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":336 */ 1329 1260 while (1) { 1330 __pyx_L2:;1331 1261 __pyx_1 = 1; 1332 1262 if (!__pyx_1) break; 1333 1263 1334 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":337 */1264 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":337 */ 1335 1265 Py_BEGIN_ALLOW_THREADS; 1336 1266 1337 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":338 */1267 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":338 */ 1338 1268 __pyx_v_n = pcap_ex_next(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,(&__pyx_v_hdr),(&__pyx_v_pkt)); 1339 1269 1340 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":339 */1270 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":339 */ 1341 1271 Py_END_ALLOW_THREADS; 1342 1272 1343 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":340 */1273 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":340 */ 1344 1274 __pyx_2 = (__pyx_v_n == 1); 1345 1275 if (__pyx_2) { 1346 1347 /* "/Users/dugsong/projects/pypcap/pcap.pyx":341 */1348 1276 __pyx_3 = PyFloat_FromDouble((__pyx_v_hdr->ts.tv_sec + (__pyx_v_hdr->ts.tv_usec / 1000000.0))); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; goto __pyx_L1;} 1349 1277 __pyx_4 = PyBuffer_FromMemory(__pyx_v_pkt,__pyx_v_hdr->caplen); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; goto __pyx_L1;} 1350 1278 __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; goto __pyx_L1;} … … 1359 1287 } 1360 1288 __pyx_2 = (__pyx_v_n == (-1)); 1361 1289 if (__pyx_2) { 1362 1363 /* "/Users/dugsong/projects/pypcap/pcap.pyx":344 */ 1364 __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_KeyboardInterrupt); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; goto __pyx_L1;} 1365 __Pyx_Raise(__pyx_3, 0, 0); 1366 Py_DECREF(__pyx_3); __pyx_3 = 0; 1290 __Pyx_Raise(PyExc_KeyboardInterrupt, 0, 0); 1367 1291 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; goto __pyx_L1;} 1368 1292 goto __pyx_L4; 1369 1293 } 1370 1294 __pyx_2 = (__pyx_v_n == (-2)); 1371 1295 if (__pyx_2) { 1372 1373 /* "/Users/dugsong/projects/pypcap/pcap.pyx":346 */ 1374 __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_StopIteration); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; goto __pyx_L1;} 1375 __Pyx_Raise(__pyx_4, 0, 0); 1376 Py_DECREF(__pyx_4); __pyx_4 = 0; 1296 __Pyx_Raise(PyExc_StopIteration, 0, 0); 1377 1297 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; goto __pyx_L1;} 1378 1298 goto __pyx_L4; 1379 1299 } 1380 1300 __pyx_L4:; 1381 1301 } 1382 __pyx_L3:;1383 1302 1384 __pyx_r = Py_None; Py_INCREF( __pyx_r);1303 __pyx_r = Py_None; Py_INCREF(Py_None); 1385 1304 goto __pyx_L0; 1386 1305 __pyx_L1:; 1387 1306 Py_XDECREF(__pyx_3); … … 1399 1318 int __pyx_1; 1400 1319 Py_INCREF(__pyx_v_self); 1401 1320 1402 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":349 */1321 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":349 */ 1403 1322 __pyx_1 = (((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__name != 0); 1404 1323 if (__pyx_1) { 1405 1406 /* "/Users/dugsong/projects/pypcap/pcap.pyx":350 */1407 1324 free(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__name); 1408 1325 goto __pyx_L2; 1409 1326 } 1410 1327 __pyx_L2:; 1411 1328 1412 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":351 */1329 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":351 */ 1413 1330 __pyx_1 = (((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__filter != 0); 1414 1331 if (__pyx_1) { 1415 1416 /* "/Users/dugsong/projects/pypcap/pcap.pyx":352 */1417 1332 free(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__filter); 1418 1333 goto __pyx_L3; 1419 1334 } 1420 1335 __pyx_L3:; 1421 1336 1422 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":353 */1337 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":353 */ 1423 1338 __pyx_1 = (((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap != 0); 1424 1339 if (__pyx_1) { 1425 1426 /* "/Users/dugsong/projects/pypcap/pcap.pyx":354 */1427 1340 pcap_close(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap); 1428 1341 goto __pyx_L4; 1429 1342 } 1430 1343 __pyx_L4:; 1431 1344 1432 goto __pyx_L0;1433 __pyx_L1:;1434 __Pyx_AddTraceback("pcap.pcap.__dealloc__");1435 __pyx_L0:;1436 1345 Py_DECREF(__pyx_v_self); 1437 1346 } 1438 1347 1439 1348 static PyObject *__pyx_f_4pcap_ex_name(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 1440 1349 static PyObject *__pyx_f_4pcap_ex_name(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { 1441 char (*__pyx_v_foo);1350 char *__pyx_v_foo; 1442 1351 PyObject *__pyx_r; 1443 1352 PyObject *__pyx_1 = 0; 1444 1353 static char *__pyx_argnames[] = {"foo",0}; 1445 1354 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "s", __pyx_argnames, &__pyx_v_foo)) return 0; 1446 1447 /* "/Users/dugsong/projects/pypcap/pcap.pyx":357 */1448 1355 __pyx_1 = PyString_FromString(pcap_ex_name(__pyx_v_foo)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; goto __pyx_L1;} 1449 1356 __pyx_r = __pyx_1; 1450 1357 __pyx_1 = 0; 1451 1358 goto __pyx_L0; 1452 1359 1453 __pyx_r = Py_None; Py_INCREF( __pyx_r);1360 __pyx_r = Py_None; Py_INCREF(Py_None); 1454 1361 goto __pyx_L0; 1455 1362 __pyx_L1:; 1456 1363 Py_XDECREF(__pyx_1); … … 1463 1370 static PyObject *__pyx_f_4pcap_lookupdev(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 1464 1371 static char __pyx_doc_4pcap_lookupdev[] = "Return the name of a network device suitable for sniffing."; 1465 1372 static PyObject *__pyx_f_4pcap_lookupdev(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { 1466 char (*__pyx_v_p);1467 char (__pyx_v_ebuf[256]);1373 char *__pyx_v_p; 1374 char __pyx_v_ebuf[256]; 1468 1375 PyObject *__pyx_r; 1469 1376 int __pyx_1; 1470 1377 PyObject *__pyx_2 = 0; 1471 PyObject *__pyx_3 = 0;1472 1378 static char *__pyx_argnames[] = {0}; 1473 1379 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; 1474 1380 1475 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":362 */1381 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":362 */ 1476 1382 __pyx_v_p = pcap_ex_lookupdev(__pyx_v_ebuf); 1477 1383 1478 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":363 */1479 __pyx_1 = (__pyx_v_p == 0);1384 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":363 */ 1385 __pyx_1 = (__pyx_v_p == NULL); 1480 1386 if (__pyx_1) { 1481 1482 /* "/Users/dugsong/projects/pypcap/pcap.pyx":364 */ 1483 __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; goto __pyx_L1;} 1484 __pyx_3 = PyString_FromString(__pyx_v_ebuf); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; goto __pyx_L1;} 1485 __Pyx_Raise(__pyx_2, __pyx_3, 0); 1387 __pyx_2 = PyString_FromString(__pyx_v_ebuf); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; goto __pyx_L1;} 1388 __Pyx_Raise(PyExc_OSError, __pyx_2, 0); 1486 1389 Py_DECREF(__pyx_2); __pyx_2 = 0; 1487 Py_DECREF(__pyx_3); __pyx_3 = 0;1488 1390 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; goto __pyx_L1;} 1489 1391 goto __pyx_L2; 1490 1392 } 1491 1393 __pyx_L2:; 1492 1394 1493 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":365 */1395 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":365 */ 1494 1396 __pyx_2 = PyString_FromString(__pyx_v_p); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; goto __pyx_L1;} 1495 1397 __pyx_r = __pyx_2; 1496 1398 __pyx_2 = 0; 1497 1399 goto __pyx_L0; 1498 1400 1499 __pyx_r = Py_None; Py_INCREF( __pyx_r);1401 __pyx_r = Py_None; Py_INCREF(Py_None); 1500 1402 goto __pyx_L0; 1501 1403 __pyx_L1:; 1502 1404 Py_XDECREF(__pyx_2); 1503 Py_XDECREF(__pyx_3);1504 1405 __Pyx_AddTraceback("pcap.lookupdev"); 1505 1406 __pyx_r = 0; 1506 1407 __pyx_L0:; 1507 1408 return __pyx_r; 1508 1409 } 1509 1410 1510 static __Pyx_InternTabEntry __pyx_intern_tab[] = {1511 {&__pyx_n_DLT_ARCNET, "DLT_ARCNET"},1512 {&__pyx_n_DLT_AX25, "DLT_AX25"},1513 {&__pyx_n_DLT_CHAOS, "DLT_CHAOS"},1514 {&__pyx_n_DLT_EN10MB, "DLT_EN10MB"},1515 {&__pyx_n_DLT_EN3MB, "DLT_EN3MB"},1516 {&__pyx_n_DLT_FDDI, "DLT_FDDI"},1517 {&__pyx_n_DLT_IEEE802, "DLT_IEEE802"},1518 {&__pyx_n_DLT_LINUX_SLL, "DLT_LINUX_SLL"},1519 {&__pyx_n_DLT_LOOP, "DLT_LOOP"},1520 {&__pyx_n_DLT_NULL, "DLT_NULL"},1521 {&__pyx_n_DLT_PFLOG, "DLT_PFLOG"},1522 {&__pyx_n_DLT_PFSYNC, "DLT_PFSYNC"},1523 {&__pyx_n_DLT_PPP, "DLT_PPP"},1524 {&__pyx_n_DLT_PRONET, "DLT_PRONET"},1525 {&__pyx_n_DLT_RAW, "DLT_RAW"},1526 {&__pyx_n_DLT_SLIP, "DLT_SLIP"},1527 {&__pyx_n_False, "False"},1528 {&__pyx_n_IOError, "IOError"},1529 {&__pyx_n_KeyError, "KeyError"},1530 {&__pyx_n_KeyboardInterrupt, "KeyboardInterrupt"},1531 {&__pyx_n_OSError, "OSError"},1532 {&__pyx_n_StopIteration, "StopIteration"},1533 {&__pyx_n_True, "True"},1534 {&__pyx_n___add_pkts, "__add_pkts"},1535 {&__pyx_n___author__, "__author__"},1536 {&__pyx_n___copyright__, "__copyright__"},1537 {&__pyx_n___license__, "__license__"},1538 {&__pyx_n___url__, "__url__"},1539 {&__pyx_n___version__, "__version__"},1540 {&__pyx_n_append, "append"},1541 {&__pyx_n_dispatch, "dispatch"},1542 {&__pyx_n_dltoff, "dltoff"},1543 {&__pyx_n_ex_name, "ex_name"},1544 {&__pyx_n_exc_info, "exc_info"},1545 {&__pyx_n_find, "find"},1546 {&__pyx_n_len, "len"},1547 {&__pyx_n_lookupdev, "lookupdev"},1548 {&__pyx_n_openbsd, "openbsd"},1549 {&__pyx_n_platform, "platform"},1550 {&__pyx_n_sys, "sys"},1551 {0, 0}1552 };1553 1554 static __Pyx_StringTabEntry __pyx_string_tab[] = {1555 {&__pyx_k6p, __pyx_k6, sizeof(__pyx_k6)},1556 {&__pyx_k7p, __pyx_k7, sizeof(__pyx_k7)},1557 {&__pyx_k8p, __pyx_k8, sizeof(__pyx_k8)},1558 {&__pyx_k9p, __pyx_k9, sizeof(__pyx_k9)},1559 {&__pyx_k10p, __pyx_k10, sizeof(__pyx_k10)},1560 {&__pyx_k21p, __pyx_k21, sizeof(__pyx_k21)},1561 {&__pyx_k23p, __pyx_k23, sizeof(__pyx_k23)},1562 {0, 0, 0}1563 };1564 1565 1411 static PyObject *__pyx_tp_new_4pcap_bpf(PyTypeObject *t, PyObject *a, PyObject *k) { 1566 1412 PyObject *o = (*t->tp_alloc)(t, 0); 1567 struct __pyx_obj_4pcap_bpf *p = (struct __pyx_obj_4pcap_bpf *)o;1413 if (!o) return 0; 1568 1414 return o; 1569 1415 } 1570 1416 1571 1417 static void __pyx_tp_dealloc_4pcap_bpf(PyObject *o) { 1572 struct __pyx_obj_4pcap_bpf *p = (struct __pyx_obj_4pcap_bpf *)o;1573 1418 { 1574 1419 PyObject *etype, *eval, *etb; 1575 1420 PyErr_Fetch(&etype, &eval, &etb); … … 1582 1427 (*o->ob_type->tp_free)(o); 1583 1428 } 1584 1429 1585 static int __pyx_tp_traverse_4pcap_bpf(PyObject *o, visitproc v, void *a) {1586 int e;1587 struct __pyx_obj_4pcap_bpf *p = (struct __pyx_obj_4pcap_bpf *)o;1588 return 0;1589 }1590 1591 static int __pyx_tp_clear_4pcap_bpf(PyObject *o) {1592 struct __pyx_obj_4pcap_bpf *p = (struct __pyx_obj_4pcap_bpf *)o;1593 return 0;1594 }1595 1596 1430 static struct PyMethodDef __pyx_methods_4pcap_bpf[] = { 1597 1431 {"filter", (PyCFunction)__pyx_f_4pcap_3bpf_filter, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4pcap_3bpf_filter}, 1598 1432 {0, 0, 0, 0} … … 1637 1471 0, /*nb_true_divide*/ 1638 1472 0, /*nb_inplace_floor_divide*/ 1639 1473 0, /*nb_inplace_true_divide*/ 1474 #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX 1475 0, /*nb_index*/ 1476 #endif 1640 1477 }; 1641 1478 1642 1479 static PySequenceMethods __pyx_tp_as_sequence_bpf = { … … 1665 1502 0, /*bf_getcharbuffer*/ 1666 1503 }; 1667 1504 1668 staticherePyTypeObject __pyx_type_4pcap_bpf = {1505 PyTypeObject __pyx_type_4pcap_bpf = { 1669 1506 PyObject_HEAD_INIT(0) 1670 1507 0, /*ob_size*/ 1671 1508 "pcap.bpf", /*tp_name*/ … … 1688 1525 &__pyx_tp_as_buffer_bpf, /*tp_as_buffer*/ 1689 1526 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/ 1690 1527 "bpf(filter, dlt=DLT_RAW) -> BPF filter object", /*tp_doc*/ 1691 __pyx_tp_traverse_4pcap_bpf, /*tp_traverse*/1692 __pyx_tp_clear_4pcap_bpf, /*tp_clear*/1528 0, /*tp_traverse*/ 1529 0, /*tp_clear*/ 1693 1530 0, /*tp_richcompare*/ 1694 1531 0, /*tp_weaklistoffset*/ 1695 1532 0, /*tp_iter*/ … … 1716 1553 1717 1554 static PyObject *__pyx_tp_new_4pcap_pcap(PyTypeObject *t, PyObject *a, PyObject *k) { 1718 1555 PyObject *o = (*t->tp_alloc)(t, 0); 1719 struct __pyx_obj_4pcap_pcap *p = (struct __pyx_obj_4pcap_pcap *)o;1556 if (!o) return 0; 1720 1557 return o; 1721 1558 } 1722 1559 1723 1560 static void __pyx_tp_dealloc_4pcap_pcap(PyObject *o) { 1724 struct __pyx_obj_4pcap_pcap *p = (struct __pyx_obj_4pcap_pcap *)o;1725 1561 { 1726 1562 PyObject *etype, *eval, *etb; 1727 1563 PyErr_Fetch(&etype, &eval, &etb); … … 1734 1570 (*o->ob_type->tp_free)(o); 1735 1571 } 1736 1572 1737 static int __pyx_tp_traverse_4pcap_pcap(PyObject *o, visitproc v, void *a) {1738 int e;1739 struct __pyx_obj_4pcap_pcap *p = (struct __pyx_obj_4pcap_pcap *)o;1740 return 0;1741 }1742 1743 static int __pyx_tp_clear_4pcap_pcap(PyObject *o) {1744 struct __pyx_obj_4pcap_pcap *p = (struct __pyx_obj_4pcap_pcap *)o;1745 return 0;1746 }1747 1748 1573 static PyObject *__pyx_getprop_4pcap_4pcap_name(PyObject *o, void *x) { 1749 1574 return __pyx_f_4pcap_4pcap_4name___get__(o); 1750 1575 } … … 1782 1607 }; 1783 1608 1784 1609 static struct PyGetSetDef __pyx_getsets_4pcap_pcap[] = { 1785 {"name", __pyx_getprop_4pcap_4pcap_name, 0, __pyx_k1 , 0},1786 {"snaplen", __pyx_getprop_4pcap_4pcap_snaplen, 0, __pyx_k 2, 0},1787 {"dloff", __pyx_getprop_4pcap_4pcap_dloff, 0, __pyx_k 3, 0},1788 {"filter", __pyx_getprop_4pcap_4pcap_filter, 0, __pyx_k 4, 0},1789 {"fd", __pyx_getprop_4pcap_4pcap_fd, 0, __pyx_k 5, 0},1610 {"name", __pyx_getprop_4pcap_4pcap_name, 0, __pyx_k10, 0}, 1611 {"snaplen", __pyx_getprop_4pcap_4pcap_snaplen, 0, __pyx_k11, 0}, 1612 {"dloff", __pyx_getprop_4pcap_4pcap_dloff, 0, __pyx_k12, 0}, 1613 {"filter", __pyx_getprop_4pcap_4pcap_filter, 0, __pyx_k13, 0}, 1614 {"fd", __pyx_getprop_4pcap_4pcap_fd, 0, __pyx_k14, 0}, 1790 1615 {0, 0, 0, 0, 0} 1791 1616 }; 1792 1617 … … 1829 1654 0, /*nb_true_divide*/ 1830 1655 0, /*nb_inplace_floor_divide*/ 1831 1656 0, /*nb_inplace_true_divide*/ 1657 #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX 1658 0, /*nb_index*/ 1659 #endif 1832 1660 }; 1833 1661 1834 1662 static PySequenceMethods __pyx_tp_as_sequence_pcap = { … … 1857 1685 0, /*bf_getcharbuffer*/ 1858 1686 }; 1859 1687 1860 staticherePyTypeObject __pyx_type_4pcap_pcap = {1688 PyTypeObject __pyx_type_4pcap_pcap = { 1861 1689 PyObject_HEAD_INIT(0) 1862 1690 0, /*ob_size*/ 1863 1691 "pcap.pcap", /*tp_name*/ … … 1880 1708 &__pyx_tp_as_buffer_pcap, /*tp_as_buffer*/ 1881 1709 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/ 1882 1710 "pcap(name=None, snaplen=65535, promisc=True, immediate=False) -> packet capture object\n \n Open a handle to a packet capture descriptor.\n \n Keyword arguments:\n name -- name of a network interface or dumpfile to open,\n or None to open the first available up interface\n snaplen -- maximum number of bytes to capture for each packet\n promisc -- boolean to specify promiscuous mode sniffing\n immediate -- disable buffering, if possible\n ", /*tp_doc*/ 1883 __pyx_tp_traverse_4pcap_pcap, /*tp_traverse*/1884 __pyx_tp_clear_4pcap_pcap, /*tp_clear*/1711 0, /*tp_traverse*/ 1712 0, /*tp_clear*/ 1885 1713 0, /*tp_richcompare*/ 1886 1714 0, /*tp_weaklistoffset*/ 1887 1715 __pyx_f_4pcap_4pcap___iter__, /*tp_iter*/ … … 1912 1740 {0, 0, 0, 0} 1913 1741 }; 1914 1742 1915 DL_EXPORT(void) initpcap(void); /*proto*/ 1916 DL_EXPORT(void) initpcap(void) { 1743 static void __pyx_init_filenames(void); /*proto*/ 1744 1745 PyMODINIT_FUNC initpcap(void); /*proto*/ 1746 PyMODINIT_FUNC initpcap(void) { 1917 1747 PyObject *__pyx_1 = 0; 1918 1748 PyObject *__pyx_2 = 0; 1919 1749 PyObject *__pyx_3 = 0; 1920 1750 int __pyx_4; 1921 1751 PyObject *__pyx_5 = 0; 1922 PyObject *__pyx_6 = 0; 1923 PyObject *__pyx_7 = 0; 1924 PyObject *__pyx_8 = 0; 1752 __pyx_init_filenames(); 1925 1753 __pyx_m = Py_InitModule4("pcap", __pyx_methods, __pyx_mdoc, 0, PYTHON_API_VERSION); 1926 1754 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;}; 1755 Py_INCREF(__pyx_m); 1927 1756 __pyx_b = PyImport_AddModule("__builtin__"); 1928 1757 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;}; 1929 1758 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;}; 1930 if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;};1931 1759 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;}; 1932 1760 if (PyType_Ready(&__pyx_type_4pcap_bpf) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;} 1933 1761 if (PyObject_SetAttrString(__pyx_m, "bpf", (PyObject *)&__pyx_type_4pcap_bpf) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;} … … 1936 1764 if (PyObject_SetAttrString(__pyx_m, "pcap", (PyObject *)&__pyx_type_4pcap_pcap) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; goto __pyx_L1;} 1937 1765 __pyx_ptype_4pcap_pcap = &__pyx_type_4pcap_pcap; 1938 1766 1939 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":13 */1940 if (PyObject_SetAttr(__pyx_m, __pyx_n___author__, __pyx_k 6p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;}1767 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":13 */ 1768 if (PyObject_SetAttr(__pyx_m, __pyx_n___author__, __pyx_k15p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; goto __pyx_L1;} 1941 1769 1942 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":14 */1943 if (PyObject_SetAttr(__pyx_m, __pyx_n___copyright__, __pyx_k 7p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1;}1770 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":14 */ 1771 if (PyObject_SetAttr(__pyx_m, __pyx_n___copyright__, __pyx_k17p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1;} 1944 1772 1945 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":15 */1946 if (PyObject_SetAttr(__pyx_m, __pyx_n___license__, __pyx_k 8p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;}1773 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":15 */ 1774 if (PyObject_SetAttr(__pyx_m, __pyx_n___license__, __pyx_k19p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;} 1947 1775 1948 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":16 */1949 if (PyObject_SetAttr(__pyx_m, __pyx_n___url__, __pyx_k 9p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L1;}1776 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":16 */ 1777 if (PyObject_SetAttr(__pyx_m, __pyx_n___url__, __pyx_k21p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L1;} 1950 1778 1951 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":17 */1952 if (PyObject_SetAttr(__pyx_m, __pyx_n___version__, __pyx_k 10p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;}1779 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":17 */ 1780 if (PyObject_SetAttr(__pyx_m, __pyx_n___version__, __pyx_k23p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;} 1953 1781 1954 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":19 */1782 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":19 */ 1955 1783 __pyx_1 = __Pyx_Import(__pyx_n_sys, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;} 1956 1784 if (PyObject_SetAttr(__pyx_m, __pyx_n_sys, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;} 1957 1785 Py_DECREF(__pyx_1); __pyx_1 = 0; 1958 1786 1959 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":102 */1787 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":102 */ 1960 1788 __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} 1961 1789 if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_NULL, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; goto __pyx_L1;} 1962 1790 Py_DECREF(__pyx_1); __pyx_1 = 0; 1963 1791 1964 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":103 */1792 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":103 */ 1965 1793 __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; goto __pyx_L1;} 1966 1794 if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_EN10MB, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; goto __pyx_L1;} 1967 1795 Py_DECREF(__pyx_1); __pyx_1 = 0; 1968 1796 1969 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":104 */1797 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":104 */ 1970 1798 __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; goto __pyx_L1;} 1971 1799 if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_EN3MB, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; goto __pyx_L1;} 1972 1800 Py_DECREF(__pyx_1); __pyx_1 = 0; 1973 1801 1974 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":105 */1802 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":105 */ 1975 1803 __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; goto __pyx_L1;} 1976 1804 if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_AX25, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; goto __pyx_L1;} 1977 1805 Py_DECREF(__pyx_1); __pyx_1 = 0; 1978 1806 1979 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":106 */1807 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":106 */ 1980 1808 __pyx_1 = PyInt_FromLong(4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; goto __pyx_L1;} 1981 1809 if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_PRONET, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; goto __pyx_L1;} 1982 1810 Py_DECREF(__pyx_1); __pyx_1 = 0; 1983 1811 1984 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":107 */1812 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":107 */ 1985 1813 __pyx_1 = PyInt_FromLong(5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; goto __pyx_L1;} 1986 1814 if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_CHAOS, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; goto __pyx_L1;} 1987 1815 Py_DECREF(__pyx_1); __pyx_1 = 0; 1988 1816 1989 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":108 */1817 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":108 */ 1990 1818 __pyx_1 = PyInt_FromLong(6); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; goto __pyx_L1;} 1991 1819 if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_IEEE802, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; goto __pyx_L1;} 1992 1820 Py_DECREF(__pyx_1); __pyx_1 = 0; 1993 1821 1994 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":109 */1822 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":109 */ 1995 1823 __pyx_1 = PyInt_FromLong(7); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; goto __pyx_L1;} 1996 1824 if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_ARCNET, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; goto __pyx_L1;} 1997 1825 Py_DECREF(__pyx_1); __pyx_1 = 0; 1998 1826 1999 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":110 */1827 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":110 */ 2000 1828 __pyx_1 = PyInt_FromLong(8); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; goto __pyx_L1;} 2001 1829 if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_SLIP, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; goto __pyx_L1;} 2002 1830 Py_DECREF(__pyx_1); __pyx_1 = 0; 2003 1831 2004 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":111 */1832 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":111 */ 2005 1833 __pyx_1 = PyInt_FromLong(9); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; goto __pyx_L1;} 2006 1834 if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_PPP, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; goto __pyx_L1;} 2007 1835 Py_DECREF(__pyx_1); __pyx_1 = 0; 2008 1836 2009 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":112 */1837 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":112 */ 2010 1838 __pyx_1 = PyInt_FromLong(10); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; goto __pyx_L1;} 2011 1839 if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_FDDI, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; goto __pyx_L1;} 2012 1840 Py_DECREF(__pyx_1); __pyx_1 = 0; 2013 1841 2014 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":114 */1842 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":114 */ 2015 1843 __pyx_1 = PyInt_FromLong(113); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;} 2016 1844 if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_LINUX_SLL, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; goto __pyx_L1;} 2017 1845 Py_DECREF(__pyx_1); __pyx_1 = 0; 2018 1846 2019 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":116 */1847 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":116 */ 2020 1848 __pyx_1 = PyInt_FromLong(117); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; goto __pyx_L1;} 2021 1849 if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_PFLOG, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; goto __pyx_L1;} 2022 1850 Py_DECREF(__pyx_1); __pyx_1 = 0; 2023 1851 2024 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":117 */1852 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":117 */ 2025 1853 __pyx_1 = PyInt_FromLong(18); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; goto __pyx_L1;} 2026 1854 if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_PFSYNC, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; goto __pyx_L1;} 2027 1855 Py_DECREF(__pyx_1); __pyx_1 = 0; 2028 1856 2029 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":118 */1857 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":118 */ 2030 1858 __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_sys); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; goto __pyx_L1;} 2031 1859 __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_platform); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; goto __pyx_L1;} 2032 1860 Py_DECREF(__pyx_1); __pyx_1 = 0; … … 2045 1873 Py_DECREF(__pyx_1); __pyx_1 = 0; 2046 1874 if (__pyx_4) { 2047 1875 2048 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":119 */1876 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":119 */ 2049 1877 __pyx_2 = PyInt_FromLong(12); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; goto __pyx_L1;} 2050 1878 if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_LOOP, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; goto __pyx_L1;} 2051 1879 Py_DECREF(__pyx_2); __pyx_2 = 0; 2052 1880 2053 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":120 */1881 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":120 */ 2054 1882 __pyx_3 = PyInt_FromLong(14); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;} 2055 1883 if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_RAW, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;} 2056 1884 Py_DECREF(__pyx_3); __pyx_3 = 0; … … 2058 1886 } 2059 1887 /*else*/ { 2060 1888 2061 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":122 */1889 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":122 */ 2062 1890 __pyx_1 = PyInt_FromLong(108); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; goto __pyx_L1;} 2063 1891 if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_LOOP, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; goto __pyx_L1;} 2064 1892 Py_DECREF(__pyx_1); __pyx_1 = 0; 2065 1893 2066 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":123 */1894 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":123 */ 2067 1895 __pyx_2 = PyInt_FromLong(12); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; goto __pyx_L1;} 2068 1896 if (PyObject_SetAttr(__pyx_m, __pyx_n_DLT_RAW, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; goto __pyx_L1;} 2069 1897 Py_DECREF(__pyx_2); __pyx_2 = 0; 2070 1898 } 2071 1899 __pyx_L3:; 2072 1900 2073 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":125 */1901 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":125 */ 2074 1902 __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; goto __pyx_L1;} 2075 1903 __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_DLT_NULL); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; goto __pyx_L1;} 2076 1904 __pyx_2 = PyInt_FromLong(4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; goto __pyx_L1;} … … 2135 1963 if (PyObject_SetAttr(__pyx_m, __pyx_n_dltoff, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; goto __pyx_L1;} 2136 1964 Py_DECREF(__pyx_3); __pyx_3 = 0; 2137 1965 2138 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":132 */1966 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":132 */ 2139 1967 __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_DLT_RAW); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; goto __pyx_L1;} 2140 __pyx_ k13= __pyx_1;1968 __pyx_d1 = __pyx_1; 2141 1969 __pyx_1 = 0; 2142 1970 2143 /* "/Users/ dugsong/projects/pypcap/pcap.pyx":163 */1971 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":163 */ 2144 1972 Py_INCREF(Py_None); 2145 __pyx_ k14= Py_None;1973 __pyx_d2 = Py_None; 2146 1974 __pyx_2 = PyInt_FromLong(65535); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; goto __pyx_L1;} 2147 __pyx_ k15= __pyx_2;1975 __pyx_d3 = __pyx_2; 2148 1976 __pyx_2 = 0; 2149 __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; goto __pyx_L1;} 2150 __pyx_k16 = __pyx_3; 1977 Py_INCREF(Py_True); 1978 __pyx_d4 = Py_True; 1979 __pyx_3 = PyInt_FromLong(500); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; goto __pyx_L1;} 1980 __pyx_d5 = __pyx_3; 2151 1981 __pyx_3 = 0; 2152 __pyx_5 = PyInt_FromLong(500); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; goto __pyx_L1;} 2153 __pyx_k17 = __pyx_5; 1982 Py_INCREF(Py_False); 1983 __pyx_d6 = Py_False; 1984 1985 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":218 */ 1986 __pyx_5 = PyInt_FromLong(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; goto __pyx_L1;} 1987 __pyx_d7 = __pyx_5; 2154 1988 __pyx_5 = 0; 2155 __pyx_6 = __Pyx_GetName(__pyx_b, __pyx_n_False); if (!__pyx_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; goto __pyx_L1;}2156 __pyx_k18 = __pyx_6;2157 __pyx_6 = 0;2158 2159 /* "/Users/dugsong/projects/pypcap/pcap.pyx":218 */2160 __pyx_7 = PyInt_FromLong(1); if (!__pyx_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; goto __pyx_L1;}2161 __pyx_k19 = __pyx_7;2162 __pyx_7 = 0;2163 2164 /* "/Users/dugsong/projects/pypcap/pcap.pyx":229 */2165 __pyx_8 = __Pyx_GetName(__pyx_b, __pyx_n_True); if (!__pyx_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; goto __pyx_L1;}2166 __pyx_k20 = __pyx_8;2167 __pyx_8 = 0;2168 1989 2169 /* "/Users/dugsong/projects/pypcap/pcap.pyx":359 */ 1990 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":229 */ 1991 Py_INCREF(Py_True); 1992 __pyx_d8 = Py_True; 1993 1994 /* "/Users/areusch/Build/pypcap-1.1/pcap.pyx":359 */ 2170 1995 return; 2171 1996 __pyx_L1:; 2172 1997 Py_XDECREF(__pyx_1); 2173 1998 Py_XDECREF(__pyx_2); 2174 1999 Py_XDECREF(__pyx_3); 2175 2000 Py_XDECREF(__pyx_5); 2176 Py_XDECREF(__pyx_6);2177 Py_XDECREF(__pyx_7);2178 Py_XDECREF(__pyx_8);2179 2001 __Pyx_AddTraceback("pcap"); 2180 2002 } 2181 2003 2182 2004 static char *__pyx_filenames[] = { 2183 2005 "pcap.pyx", 2184 2006 }; 2185 statichere char **__pyx_f = __pyx_filenames;2186 2007 2187 2008 /* Runtime support code */ 2188 2009 2010 static void __pyx_init_filenames(void) { 2011 __pyx_f = __pyx_filenames; 2012 } 2013 2014 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { 2015 if (value == Py_None) 2016 value = NULL; 2017 if (tb == Py_None) 2018 tb = NULL; 2019 Py_XINCREF(type); 2020 Py_XINCREF(value); 2021 Py_XINCREF(tb); 2022 if (tb && !PyTraceBack_Check(tb)) { 2023 PyErr_SetString(PyExc_TypeError, 2024 "raise: arg 3 must be a traceback or None"); 2025 goto raise_error; 2026 } 2027 #if PY_VERSION_HEX < 0x02050000 2028 if (!PyClass_Check(type)) 2029 #else 2030 if (!PyType_Check(type)) 2031 #endif 2032 { 2033 /* Raising an instance. The value should be a dummy. */ 2034 if (value) { 2035 PyErr_SetString(PyExc_TypeError, 2036 "instance exception may not have a separate value"); 2037 goto raise_error; 2038 } 2039 /* Normalize to raise <class>, <instance> */ 2040 value = type; 2041 #if PY_VERSION_HEX < 0x02050000 2042 if (PyInstance_Check(type)) { 2043 type = (PyObject*) ((PyInstanceObject*)type)->in_class; 2044 Py_INCREF(type); 2045 } 2046 else { 2047 PyErr_SetString(PyExc_TypeError, 2048 "raise: exception must be an old-style class or instance"); 2049 goto raise_error; 2050 } 2051 #else 2052 type = (PyObject*) type->ob_type; 2053 Py_INCREF(type); 2054 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { 2055 PyErr_SetString(PyExc_TypeError, 2056 "raise: exception class must be a subclass of BaseException"); 2057 goto raise_error; 2058 } 2059 #endif 2060 } 2061 PyErr_Restore(type, value, tb); 2062 return; 2063 raise_error: 2064 Py_XDECREF(value); 2065 Py_XDECREF(type); 2066 Py_XDECREF(tb); 2067 return; 2068 } 2069 2070 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) { 2071 PyObject *result; 2072 result = PyObject_GetAttr(dict, name); 2073 if (!result) 2074 PyErr_SetObject(PyExc_NameError, name); 2075 return result; 2076 } 2077 2189 2078 static int __Pyx_GetStarArgs( 2190 2079 PyObject **args, 2191 2080 PyObject **kwds, 2192 2081 char *kwd_list[], 2193 int nargs,2082 Py_ssize_t nargs, 2194 2083 PyObject **args2, 2195 PyObject **kwds2) 2084 PyObject **kwds2, 2085 char rqd_kwds[]) 2196 2086 { 2197 2087 PyObject *x = 0, *args1 = 0, *kwds1 = 0; 2088 int i; 2089 char **p; 2198 2090 2199 2091 if (args2) 2200 2092 *args2 = 0; … … 2205 2097 args1 = PyTuple_GetSlice(*args, 0, nargs); 2206 2098 if (!args1) 2207 2099 goto bad; 2208 *args2 = PyTuple_GetSlice(*args, nargs, PyTuple_ Size(*args));2100 *args2 = PyTuple_GetSlice(*args, nargs, PyTuple_GET_SIZE(*args)); 2209 2101 if (!*args2) 2210 2102 goto bad; 2211 2103 } 2104 else if (PyTuple_GET_SIZE(*args) > nargs) { 2105 int m = nargs; 2106 int n = PyTuple_GET_SIZE(*args); 2107 PyErr_Format(PyExc_TypeError, 2108 "function takes at most %d positional arguments (%d given)", 2109 m, n); 2110 goto bad; 2111 } 2212 2112 else { 2213 2113 args1 = *args; 2214 2114 Py_INCREF(args1); 2215 2115 } 2216 2116 2117 if (rqd_kwds && !*kwds) 2118 for (i = 0, p = kwd_list; *p; i++, p++) 2119 if (rqd_kwds[i]) 2120 goto missing_kwarg; 2121 2217 2122 if (kwds2) { 2218 2123 if (*kwds) { 2219 char **p;2220 2124 kwds1 = PyDict_New(); 2221 if (!kwds )2125 if (!kwds1) 2222 2126 goto bad; 2223 2127 *kwds2 = PyDict_Copy(*kwds); 2224 2128 if (!*kwds2) 2225 2129 goto bad; 2226 for ( p = kwd_list; *p;p++) {2130 for (i = 0, p = kwd_list; *p; i++, p++) { 2227 2131 x = PyDict_GetItemString(*kwds, *p); 2228 2132 if (x) { 2229 2133 if (PyDict_SetItemString(kwds1, *p, x) < 0) … … 2231 2135 if (PyDict_DelItemString(*kwds2, *p) < 0) 2232 2136 goto bad; 2233 2137 } 2138 else if (rqd_kwds && rqd_kwds[i]) 2139 goto missing_kwarg; 2234 2140 } 2235 2141 } 2236 2142 else { … … 2242 2148 else { 2243 2149 kwds1 = *kwds; 2244 2150 Py_XINCREF(kwds1); 2151 if (rqd_kwds && *kwds) 2152 for (i = 0, p = kwd_list; *p; i++, p++) 2153 if (rqd_kwds[i] && !PyDict_GetItemString(*kwds, *p)) 2154 goto missing_kwarg; 2245 2155 } 2246 2156 2247 2157 *args = args1; 2248 2158 *kwds = kwds1; 2249 2159 return 0; 2160 missing_kwarg: 2161 PyErr_Format(PyExc_TypeError, 2162 "required keyword argument '%s' is missing", *p); 2250 2163 bad: 2251 2164 Py_XDECREF(args1); 2252 2165 Py_XDECREF(kwds1); 2253 if ( *args2)2166 if (args2) { 2254 2167 Py_XDECREF(*args2); 2255 if (*kwds2) 2168 } 2169 if (kwds2) { 2256 2170 Py_XDECREF(*kwds2); 2171 } 2257 2172 return -1; 2258 2173 } 2259 2174 2175 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { 2176 while (t->p) { 2177 *t->p = PyString_FromStringAndSize(t->s, t->n - 1); 2178 if (!*t->p) 2179 return -1; 2180 if (t->i) 2181 PyString_InternInPlace(t->p); 2182 ++t; 2183 } 2184 return 0; 2185 } 2186 2260 2187 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) { 2261 2188 PyObject *__import__ = 0; 2262 2189 PyObject *empty_list = 0; … … 2290 2217 return module; 2291 2218 } 2292 2219 2293 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {2294 PyObject *result;2295 result = PyObject_GetAttr(dict, name);2296 if (!result)2297 PyErr_SetObject(PyExc_NameError, name);2298 return result;2299 }2300 2301 static PyObject *__Pyx_GetExcValue(void) {2302 PyObject *type = 0, *value = 0, *tb = 0;2303 PyObject *result = 0;2304 PyThreadState *tstate = PyThreadState_Get();2305 PyErr_Fetch(&type, &value, &tb);2306 PyErr_NormalizeException(&type, &value, &tb);2307 if (PyErr_Occurred())2308 goto bad;2309 if (!value) {2310 value = Py_None;2311 Py_INCREF(value);2312 }2313 Py_XDECREF(tstate->exc_type);2314 Py_XDECREF(tstate->exc_value);2315 Py_XDECREF(tstate->exc_traceback);2316 tstate->exc_type = type;2317 tstate->exc_value = value;2318 tstate->exc_traceback = tb;2319 result = value;2320 Py_XINCREF(result);2321 type = 0;2322 value = 0;2323 tb = 0;2324 bad:2325 Py_XDECREF(type);2326 Py_XDECREF(value);2327 Py_XDECREF(tb);2328 return result;2329 }2330 2331 static void __Pyx_WriteUnraisable(char *name) {2332 PyObject *old_exc, *old_val, *old_tb;2333 PyObject *ctx;2334 PyErr_Fetch(&old_exc, &old_val, &old_tb);2335 ctx = PyString_FromString(name);2336 PyErr_Restore(old_exc, old_val, old_tb);2337 if (!ctx)2338 ctx = Py_None;2339 PyErr_WriteUnraisable(ctx);2340 }2341 2342 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {2343 Py_XINCREF(type);2344 Py_XINCREF(value);2345 Py_XINCREF(tb);2346 /* First, check the traceback argument, replacing None with NULL. */2347 if (tb == Py_None) {2348 Py_DECREF(tb);2349 tb = 0;2350 }2351 else if (tb != NULL && !PyTraceBack_Check(tb)) {2352 PyErr_SetString(PyExc_TypeError,2353 "raise: arg 3 must be a traceback or None");2354 goto raise_error;2355 }2356 /* Next, replace a missing value with None */2357 if (value == NULL) {2358 value = Py_None;2359 Py_INCREF(value);2360 }2361 /* Next, repeatedly, replace a tuple exception with its first item */2362 while (PyTuple_Check(type) && PyTuple_Size(type) > 0) {2363 PyObject *tmp = type;2364 type = PyTuple_GET_ITEM(type, 0);2365 Py_INCREF(type);2366 Py_DECREF(tmp);2367 }2368 if (PyString_Check(type))2369 ;2370 else if (PyClass_Check(type))2371 ; /*PyErr_NormalizeException(&type, &value, &tb);*/2372 else if (PyInstance_Check(type)) {2373 /* Raising an instance. The value should be a dummy. */2374 if (value != Py_None) {2375 PyErr_SetString(PyExc_TypeError,2376 "instance exception may not have a separate value");2377 goto raise_error;2378 }2379 else {2380 /* Normalize to raise <class>, <instance> */2381 Py_DECREF(value);2382 value = type;2383 type = (PyObject*) ((PyInstanceObject*)type)->in_class;2384 Py_INCREF(type);2385 }2386 }2387 else {2388 /* Not something you can raise. You get an exception2389 anyway, just not what you specified :-) */2390 PyErr_Format(PyExc_TypeError,2391 "exceptions must be strings, classes, or "2392 "instances, not %s", type->ob_type->tp_name);2393 goto raise_error;2394 }2395 PyErr_Restore(type, value, tb);2396 return;2397 raise_error:2398 Py_XDECREF(value);2399 Py_XDECREF(type);2400 Py_XDECREF(tb);2401 return;2402 }2403 2404 static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) {2405 while (t->p) {2406 *t->p = PyString_InternFromString(t->s);2407 if (!*t->p)2408 return -1;2409 ++t;2410 }2411 return 0;2412 }2413 2414 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {2415 while (t->p) {2416 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);2417 if (!*t->p)2418 return -1;2419 ++t;2420 }2421 return 0;2422 }2423 2424 2220 #include "compile.h" 2425 2221 #include "frameobject.h" 2426 2222 #include "traceback.h"