Changeset 2980487 for swig


Ignore:
Timestamp:
09/21/04 13:11:41 (16 years ago)
Author:
Daniel Lawson <dlawson@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
77ba31d
Parents:
4e194bc
Message:

new version

Location:
swig
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • swig/libtrace.i

    r4e194bc r2980487  
    3737    }
    3838  };
     39
     40%extend libtrace_ip {
     41        ~libtrace_ip() { free(self); }
     42}
    3943
    4044%{
     
    8690};
    8791
     92%extend libtrace_tcp {
     93        ~libtrace_tcp() { free(self); }
     94}
     95
    8896%{
    8997 MAKE_NTOHS(libtrace_tcp,source)
     
    107115  }
    108116};
     117
     118%extend libtrace_udp {
     119        ~libtrace_udp() { free(self); }
     120}
    109121
    110122%{
     
    136148};
    137149
    138 %{
    139 typedef struct Packet {
    140         struct libtrace_t *libtrace;
    141         void *buffer;
    142         int status;
    143         int len;
    144 } Packet;
    145 %}
     150%extend libtrace_icmp {
     151        ~libtrace_icmp() { free(self); }
     152}
    146153
    147 %nodefault;
    148 typedef struct Packet {
    149         void *buffer;
    150         int status;
    151         int len;
    152 } Packet;
     154%rename (Packet) libtrace_packet_t;
     155struct libtrace_packet_t {};
    153156
    154 %extend Packet {
    155         struct libtrace_ip *get_ip() {
    156                 return get_ip(self->libtrace,self->buffer,self->len);
     157%extend libtrace_packet_t {
     158        libtrace_packet_t() {
     159                struct libtrace_packet_t *packet = malloc(sizeof(struct libtrace_packet_t));
     160                return packet;
     161                }
     162        ~libtrace_packet_t() {free(self);}
     163        struct libtrace_ip *trace_get_ip() {
     164                return trace_get_ip(self);
    157165        }
    158         struct libtrace_tcp *get_tcp() {
    159                 return get_tcp(self->libtrace,self->buffer,self->len);
     166        struct libtrace_tcp *trace_get_tcp() {
     167                return trace_get_tcp(self);
    160168        }
    161         struct libtrace_udp *get_udp() {
    162                 return get_udp(self->libtrace,self->buffer,self->len);
     169        struct libtrace_udp *trace_get_udp() {
     170                return trace_get_udp(self);
    163171        }
    164         struct libtrace_icmp *get_icmp() {
    165                 return get_icmp(self->libtrace,self->buffer,self->len);
     172        struct libtrace_icmp *trace_get_icmp() {
     173                return trace_get_icmp(self);
    166174        }
    167         double get_seconds() {
    168                 return get_seconds(self->libtrace,self->buffer,self->len);
     175        double trace_get_seconds() {
     176                return trace_get_seconds(self);
    169177        }
    170178};
     
    174182
    175183%extend libtrace_t {
    176         libtrace_t(char *uri) { return create_trace(uri); };
    177         ~libtrace_t() { destroy_trace(self); }
    178         Packet *read_packet() {
    179                 Packet *buffer = malloc(sizeof(Packet));
    180                 buffer->buffer = malloc(1600);
    181                 buffer->len=libtrace_read_packet(self,buffer->buffer,1600,&buffer->status);
    182                 buffer->libtrace = self;
    183                 if (buffer->len == 0) {
    184                         free(buffer);
    185                         return NULL;
    186                 }
    187                 return buffer;
     184        libtrace_t(char *uri) { return trace_create(uri); };
     185        ~libtrace_t() { trace_destroy(self); }
     186        int trace_read_packet(struct libtrace_packet_t *packet) {
     187                return trace_read_packet(self,packet);
    188188        }
    189189};
    190190
    191 /*
    192 void *get_link(struct libtrace_t *libtrace, void *buffer, int buflen);
    193 int get_capture_length(struct libtrace_t *libtrace, void *buffer, int buflen);
    194 int get_wire_length(struct libtrace_t *libtrace, void *buffer, int buflen);
    195 libtrace_linktype_t get_link_type(
    196         struct libtrace_t *libtrace, void *buffer, int buflen);
    197 uint8_t *get_destination_mac(struct libtrace_t *libtrace,
    198          void *buffer, int buflen);
    199 uint8_t *get_source_mac(struct libtrace_t *libtrace,
    200         void *buffer, int buflen);
    201 libtrace_event_t libtrace_event(struct libtrace_t *trace,
    202                         int *fd,double *seconds,
    203                         void *buffer, int *size);
    204 */
  • swig/libtrace_wrap.c

    r4e194bc r2980487  
    685685
    686686#define  SWIGTYPE_p_in_addr swig_types[0]
    687 #define  SWIGTYPE_p_Packet swig_types[1]
    688 #define  SWIGTYPE_p_libtrace_icmp swig_types[2]
    689 #define  SWIGTYPE_p_libtrace_icmp_un_echo swig_types[3]
     687#define  SWIGTYPE_p_libtrace_icmp swig_types[1]
     688#define  SWIGTYPE_p_libtrace_icmp_un_echo swig_types[2]
     689#define  SWIGTYPE_p_libtrace_packet_t swig_types[3]
    690690#define  SWIGTYPE_p_libtrace_ip swig_types[4]
    691691#define  SWIGTYPE_p_libtrace_icmp_un_frag swig_types[5]
    692692#define  SWIGTYPE_p_libtrace_t swig_types[6]
    693693#define  SWIGTYPE_p_libtrace_udp swig_types[7]
    694 #define  SWIGTYPE_p_void swig_types[8]
    695 #define  SWIGTYPE_p_libtrace_tcp swig_types[9]
    696 #define  SWIGTYPE_p_libtrace_icmp_un swig_types[10]
    697 static swig_type_info *swig_types[12];
     694#define  SWIGTYPE_p_libtrace_tcp swig_types[8]
     695#define  SWIGTYPE_p_libtrace_icmp_un swig_types[9]
     696static swig_type_info *swig_types[11];
    698697
    699698/* -------- TYPES TABLE (END) -------- */
     
    710709#include "libtrace.h"
    711710
     711void delete_libtrace_ip(struct libtrace_ip *self){ free(self); }
    712712
    713713#define MAKE_NTOHS(class,member) \
     
    732732            }
    733733
     734void delete_libtrace_tcp(struct libtrace_tcp *self){ free(self); }
    734735
    735736 MAKE_NTOHS(libtrace_tcp,source)
     
    742743 MAKE_NTOHL(libtrace_tcp,ack_seq)
    743744
     745void delete_libtrace_udp(struct libtrace_udp *self){ free(self); }
    744746
    745747 MAKE_NTOHS(libtrace_udp,source)
     
    762764
    763765
     766void delete_libtrace_icmp(struct libtrace_icmp *self){ free(self); }
    764767
    765768typedef struct {
     
    776779
    777780
    778 
    779 typedef struct Packet {
    780         struct libtrace_t *libtrace;
    781         void *buffer;
    782         int status;
    783         int len;
    784 } Packet;
    785 
    786 struct libtrace_ip *Packet_get_ip(Packet *self){
    787                 return get_ip(self->libtrace,self->buffer,self->len);
     781struct libtrace_packet_t *new_libtrace_packet_t(){
     782                struct libtrace_packet_t *packet = malloc(sizeof(struct libtrace_packet_t));
     783                return packet;
     784                }
     785void delete_libtrace_packet_t(struct libtrace_packet_t *self){free(self);}
     786struct libtrace_ip *libtrace_packet_t_trace_get_ip(struct libtrace_packet_t *self){
     787                return trace_get_ip(self);
    788788        }
    789 struct libtrace_tcp *Packet_get_tcp(Packet *self){
    790                 return get_tcp(self->libtrace,self->buffer,self->len);
     789struct libtrace_tcp *libtrace_packet_t_trace_get_tcp(struct libtrace_packet_t *self){
     790                return trace_get_tcp(self);
    791791        }
    792 struct libtrace_udp *Packet_get_udp(Packet *self){
    793                 return get_udp(self->libtrace,self->buffer,self->len);
     792struct libtrace_udp *libtrace_packet_t_trace_get_udp(struct libtrace_packet_t *self){
     793                return trace_get_udp(self);
    794794        }
    795 struct libtrace_icmp *Packet_get_icmp(Packet *self){
    796                 return get_icmp(self->libtrace,self->buffer,self->len);
     795struct libtrace_icmp *libtrace_packet_t_trace_get_icmp(struct libtrace_packet_t *self){
     796                return trace_get_icmp(self);
    797797        }
    798 double Packet_get_seconds(Packet *self){
    799                 return get_seconds(self->libtrace,self->buffer,self->len);
     798double libtrace_packet_t_trace_get_seconds(struct libtrace_packet_t *self){
     799                return trace_get_seconds(self);
    800800        }
    801 struct libtrace_t *new_libtrace_t(char *uri){ return create_trace(uri); }
    802 void delete_libtrace_t(struct libtrace_t *self){ destroy_trace(self); }
    803 Packet *libtrace_t_read_packet(struct libtrace_t *self){
    804                 Packet *buffer = malloc(sizeof(Packet));
    805                 buffer->buffer = malloc(1600);
    806                 buffer->len=libtrace_read_packet(self,buffer->buffer,1600,&buffer->status);
    807                 buffer->libtrace = self;
    808                 if (buffer->len == 0) {
    809                         free(buffer);
    810                         return NULL;
    811                 }
    812                 return buffer;
     801struct libtrace_t *new_libtrace_t(char *uri){ return trace_create(uri); }
     802void delete_libtrace_t(struct libtrace_t *self){ trace_destroy(self); }
     803int libtrace_t_trace_read_packet(struct libtrace_t *self,struct libtrace_packet_t *packet){
     804                return trace_read_packet(self,packet);
    813805        }
    814806#ifdef __cplusplus
     
    11431135
    11441136
     1137static PyObject *_wrap_delete_libtrace_ip(PyObject *self, PyObject *args) {
     1138    PyObject *resultobj;
     1139    struct libtrace_ip *arg1 = (struct libtrace_ip *) 0 ;
     1140    PyObject * obj0 = 0 ;
     1141   
     1142    if(!PyArg_ParseTuple(args,(char *)"O:delete_libtrace_ip",&obj0)) goto fail;
     1143    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_libtrace_ip,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     1144    delete_libtrace_ip(arg1);
     1145   
     1146    Py_INCREF(Py_None); resultobj = Py_None;
     1147    return resultobj;
     1148    fail:
     1149    return NULL;
     1150}
     1151
     1152
    11451153static PyObject * libtrace_ip_swigregister(PyObject *self, PyObject *args) {
    11461154    PyObject *obj;
     
    16021610
    16031611
     1612static PyObject *_wrap_delete_libtrace_tcp(PyObject *self, PyObject *args) {
     1613    PyObject *resultobj;
     1614    struct libtrace_tcp *arg1 = (struct libtrace_tcp *) 0 ;
     1615    PyObject * obj0 = 0 ;
     1616   
     1617    if(!PyArg_ParseTuple(args,(char *)"O:delete_libtrace_tcp",&obj0)) goto fail;
     1618    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_libtrace_tcp,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     1619    delete_libtrace_tcp(arg1);
     1620   
     1621    Py_INCREF(Py_None); resultobj = Py_None;
     1622    return resultobj;
     1623    fail:
     1624    return NULL;
     1625}
     1626
     1627
    16041628static PyObject * libtrace_tcp_swigregister(PyObject *self, PyObject *args) {
    16051629    PyObject *obj;
     
    16771701
    16781702
     1703static PyObject *_wrap_delete_libtrace_udp(PyObject *self, PyObject *args) {
     1704    PyObject *resultobj;
     1705    struct libtrace_udp *arg1 = (struct libtrace_udp *) 0 ;
     1706    PyObject * obj0 = 0 ;
     1707   
     1708    if(!PyArg_ParseTuple(args,(char *)"O:delete_libtrace_udp",&obj0)) goto fail;
     1709    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_libtrace_udp,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     1710    delete_libtrace_udp(arg1);
     1711   
     1712    Py_INCREF(Py_None); resultobj = Py_None;
     1713    return resultobj;
     1714    fail:
     1715    return NULL;
     1716}
     1717
     1718
    16791719static PyObject * libtrace_udp_swigregister(PyObject *self, PyObject *args) {
    16801720    PyObject *obj;
     
    18121852
    18131853
     1854static PyObject *_wrap_delete_libtrace_icmp(PyObject *self, PyObject *args) {
     1855    PyObject *resultobj;
     1856    struct libtrace_icmp *arg1 = (struct libtrace_icmp *) 0 ;
     1857    PyObject * obj0 = 0 ;
     1858   
     1859    if(!PyArg_ParseTuple(args,(char *)"O:delete_libtrace_icmp",&obj0)) goto fail;
     1860    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_libtrace_icmp,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     1861    delete_libtrace_icmp(arg1);
     1862   
     1863    Py_INCREF(Py_None); resultobj = Py_None;
     1864    return resultobj;
     1865    fail:
     1866    return NULL;
     1867}
     1868
     1869
    18141870static PyObject * libtrace_icmp_swigregister(PyObject *self, PyObject *args) {
    18151871    PyObject *obj;
     
    20592115    return Py_BuildValue((char *)"");
    20602116}
    2061 static PyObject *_wrap_Packet_buffer_set(PyObject *self, PyObject *args) {
    2062     PyObject *resultobj;
    2063     Packet *arg1 = (Packet *) 0 ;
    2064     void *arg2 = (void *) 0 ;
    2065     PyObject * obj0 = 0 ;
    2066     PyObject * obj1 = 0 ;
    2067    
    2068     if(!PyArg_ParseTuple(args,(char *)"OO:Packet_buffer_set",&obj0,&obj1)) goto fail;
    2069     if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
    2070     if ((SWIG_ConvertPtr(obj1,(void **) &arg2, 0, SWIG_POINTER_EXCEPTION | SWIG_POINTER_DISOWN )) == -1) SWIG_fail;
    2071     if (arg1) (arg1)->buffer = arg2;
    2072    
    2073     Py_INCREF(Py_None); resultobj = Py_None;
    2074     return resultobj;
    2075     fail:
    2076     return NULL;
    2077 }
    2078 
    2079 
    2080 static PyObject *_wrap_Packet_buffer_get(PyObject *self, PyObject *args) {
    2081     PyObject *resultobj;
    2082     Packet *arg1 = (Packet *) 0 ;
    2083     void *result;
    2084     PyObject * obj0 = 0 ;
    2085    
    2086     if(!PyArg_ParseTuple(args,(char *)"O:Packet_buffer_get",&obj0)) goto fail;
    2087     if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
    2088     result = (void *) ((arg1)->buffer);
    2089    
    2090     resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_void, 0);
    2091     return resultobj;
    2092     fail:
    2093     return NULL;
    2094 }
    2095 
    2096 
    2097 static PyObject *_wrap_Packet_status_set(PyObject *self, PyObject *args) {
    2098     PyObject *resultobj;
    2099     Packet *arg1 = (Packet *) 0 ;
    2100     int arg2 ;
    2101     PyObject * obj0 = 0 ;
    2102    
    2103     if(!PyArg_ParseTuple(args,(char *)"Oi:Packet_status_set",&obj0,&arg2)) goto fail;
    2104     if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
    2105     if (arg1) (arg1)->status = arg2;
    2106    
    2107     Py_INCREF(Py_None); resultobj = Py_None;
    2108     return resultobj;
    2109     fail:
    2110     return NULL;
    2111 }
    2112 
    2113 
    2114 static PyObject *_wrap_Packet_status_get(PyObject *self, PyObject *args) {
    2115     PyObject *resultobj;
    2116     Packet *arg1 = (Packet *) 0 ;
    2117     int result;
    2118     PyObject * obj0 = 0 ;
    2119    
    2120     if(!PyArg_ParseTuple(args,(char *)"O:Packet_status_get",&obj0)) goto fail;
    2121     if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
    2122     result = (int) ((arg1)->status);
    2123    
    2124     resultobj = PyInt_FromLong((long)result);
    2125     return resultobj;
    2126     fail:
    2127     return NULL;
    2128 }
    2129 
    2130 
    2131 static PyObject *_wrap_Packet_len_set(PyObject *self, PyObject *args) {
    2132     PyObject *resultobj;
    2133     Packet *arg1 = (Packet *) 0 ;
    2134     int arg2 ;
    2135     PyObject * obj0 = 0 ;
    2136    
    2137     if(!PyArg_ParseTuple(args,(char *)"Oi:Packet_len_set",&obj0,&arg2)) goto fail;
    2138     if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
    2139     if (arg1) (arg1)->len = arg2;
    2140    
    2141     Py_INCREF(Py_None); resultobj = Py_None;
    2142     return resultobj;
    2143     fail:
    2144     return NULL;
    2145 }
    2146 
    2147 
    2148 static PyObject *_wrap_Packet_len_get(PyObject *self, PyObject *args) {
    2149     PyObject *resultobj;
    2150     Packet *arg1 = (Packet *) 0 ;
    2151     int result;
    2152     PyObject * obj0 = 0 ;
    2153    
    2154     if(!PyArg_ParseTuple(args,(char *)"O:Packet_len_get",&obj0)) goto fail;
    2155     if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
    2156     result = (int) ((arg1)->len);
    2157    
    2158     resultobj = PyInt_FromLong((long)result);
    2159     return resultobj;
    2160     fail:
    2161     return NULL;
    2162 }
    2163 
    2164 
    2165 static PyObject *_wrap_Packet_get_ip(PyObject *self, PyObject *args) {
    2166     PyObject *resultobj;
    2167     Packet *arg1 = (Packet *) 0 ;
     2117static PyObject *_wrap_new_Packet(PyObject *self, PyObject *args) {
     2118    PyObject *resultobj;
     2119    struct libtrace_packet_t *result;
     2120   
     2121    if(!PyArg_ParseTuple(args,(char *)":new_Packet")) goto fail;
     2122    result = (struct libtrace_packet_t *)new_libtrace_packet_t();
     2123   
     2124    resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_libtrace_packet_t, 1);
     2125    return resultobj;
     2126    fail:
     2127    return NULL;
     2128}
     2129
     2130
     2131static PyObject *_wrap_delete_Packet(PyObject *self, PyObject *args) {
     2132    PyObject *resultobj;
     2133    struct libtrace_packet_t *arg1 = (struct libtrace_packet_t *) 0 ;
     2134    PyObject * obj0 = 0 ;
     2135   
     2136    if(!PyArg_ParseTuple(args,(char *)"O:delete_Packet",&obj0)) goto fail;
     2137    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_libtrace_packet_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     2138    delete_libtrace_packet_t(arg1);
     2139   
     2140    Py_INCREF(Py_None); resultobj = Py_None;
     2141    return resultobj;
     2142    fail:
     2143    return NULL;
     2144}
     2145
     2146
     2147static PyObject *_wrap_Packet_trace_get_ip(PyObject *self, PyObject *args) {
     2148    PyObject *resultobj;
     2149    struct libtrace_packet_t *arg1 = (struct libtrace_packet_t *) 0 ;
    21682150    struct libtrace_ip *result;
    21692151    PyObject * obj0 = 0 ;
    21702152   
    2171     if(!PyArg_ParseTuple(args,(char *)"O:Packet_get_ip",&obj0)) goto fail;
    2172     if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
    2173     result = (struct libtrace_ip *)Packet_get_ip(arg1);
     2153    if(!PyArg_ParseTuple(args,(char *)"O:Packet_trace_get_ip",&obj0)) goto fail;
     2154    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_libtrace_packet_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     2155    result = (struct libtrace_ip *)libtrace_packet_t_trace_get_ip(arg1);
    21742156   
    21752157    resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_libtrace_ip, 0);
     
    21802162
    21812163
    2182 static PyObject *_wrap_Packet_get_tcp(PyObject *self, PyObject *args) {
    2183     PyObject *resultobj;
    2184     Packet *arg1 = (Packet *) 0 ;
     2164static PyObject *_wrap_Packet_trace_get_tcp(PyObject *self, PyObject *args) {
     2165    PyObject *resultobj;
     2166    struct libtrace_packet_t *arg1 = (struct libtrace_packet_t *) 0 ;
    21852167    struct libtrace_tcp *result;
    21862168    PyObject * obj0 = 0 ;
    21872169   
    2188     if(!PyArg_ParseTuple(args,(char *)"O:Packet_get_tcp",&obj0)) goto fail;
    2189     if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
    2190     result = (struct libtrace_tcp *)Packet_get_tcp(arg1);
     2170    if(!PyArg_ParseTuple(args,(char *)"O:Packet_trace_get_tcp",&obj0)) goto fail;
     2171    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_libtrace_packet_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     2172    result = (struct libtrace_tcp *)libtrace_packet_t_trace_get_tcp(arg1);
    21912173   
    21922174    resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_libtrace_tcp, 0);
     
    21972179
    21982180
    2199 static PyObject *_wrap_Packet_get_udp(PyObject *self, PyObject *args) {
    2200     PyObject *resultobj;
    2201     Packet *arg1 = (Packet *) 0 ;
     2181static PyObject *_wrap_Packet_trace_get_udp(PyObject *self, PyObject *args) {
     2182    PyObject *resultobj;
     2183    struct libtrace_packet_t *arg1 = (struct libtrace_packet_t *) 0 ;
    22022184    struct libtrace_udp *result;
    22032185    PyObject * obj0 = 0 ;
    22042186   
    2205     if(!PyArg_ParseTuple(args,(char *)"O:Packet_get_udp",&obj0)) goto fail;
    2206     if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
    2207     result = (struct libtrace_udp *)Packet_get_udp(arg1);
     2187    if(!PyArg_ParseTuple(args,(char *)"O:Packet_trace_get_udp",&obj0)) goto fail;
     2188    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_libtrace_packet_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     2189    result = (struct libtrace_udp *)libtrace_packet_t_trace_get_udp(arg1);
    22082190   
    22092191    resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_libtrace_udp, 0);
     
    22142196
    22152197
    2216 static PyObject *_wrap_Packet_get_icmp(PyObject *self, PyObject *args) {
    2217     PyObject *resultobj;
    2218     Packet *arg1 = (Packet *) 0 ;
     2198static PyObject *_wrap_Packet_trace_get_icmp(PyObject *self, PyObject *args) {
     2199    PyObject *resultobj;
     2200    struct libtrace_packet_t *arg1 = (struct libtrace_packet_t *) 0 ;
    22192201    struct libtrace_icmp *result;
    22202202    PyObject * obj0 = 0 ;
    22212203   
    2222     if(!PyArg_ParseTuple(args,(char *)"O:Packet_get_icmp",&obj0)) goto fail;
    2223     if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
    2224     result = (struct libtrace_icmp *)Packet_get_icmp(arg1);
     2204    if(!PyArg_ParseTuple(args,(char *)"O:Packet_trace_get_icmp",&obj0)) goto fail;
     2205    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_libtrace_packet_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     2206    result = (struct libtrace_icmp *)libtrace_packet_t_trace_get_icmp(arg1);
    22252207   
    22262208    resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_libtrace_icmp, 0);
     
    22312213
    22322214
    2233 static PyObject *_wrap_Packet_get_seconds(PyObject *self, PyObject *args) {
    2234     PyObject *resultobj;
    2235     Packet *arg1 = (Packet *) 0 ;
     2215static PyObject *_wrap_Packet_trace_get_seconds(PyObject *self, PyObject *args) {
     2216    PyObject *resultobj;
     2217    struct libtrace_packet_t *arg1 = (struct libtrace_packet_t *) 0 ;
    22362218    double result;
    22372219    PyObject * obj0 = 0 ;
    22382220   
    2239     if(!PyArg_ParseTuple(args,(char *)"O:Packet_get_seconds",&obj0)) goto fail;
    2240     if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_Packet,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
    2241     result = (double)Packet_get_seconds(arg1);
     2221    if(!PyArg_ParseTuple(args,(char *)"O:Packet_trace_get_seconds",&obj0)) goto fail;
     2222    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_libtrace_packet_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     2223    result = (double)libtrace_packet_t_trace_get_seconds(arg1);
    22422224   
    22432225    resultobj = PyFloat_FromDouble(result);
     
    22512233    PyObject *obj;
    22522234    if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL;
    2253     SWIG_TypeClientData(SWIGTYPE_p_Packet, obj);
     2235    SWIG_TypeClientData(SWIGTYPE_p_libtrace_packet_t, obj);
    22542236    Py_INCREF(obj);
    22552237    return Py_BuildValue((char *)"");
     
    22862268
    22872269
    2288 static PyObject *_wrap_Trace_read_packet(PyObject *self, PyObject *args) {
     2270static PyObject *_wrap_Trace_trace_read_packet(PyObject *self, PyObject *args) {
    22892271    PyObject *resultobj;
    22902272    struct libtrace_t *arg1 = (struct libtrace_t *) 0 ;
    2291     Packet *result;
    2292     PyObject * obj0 = 0 ;
    2293    
    2294     if(!PyArg_ParseTuple(args,(char *)"O:Trace_read_packet",&obj0)) goto fail;
     2273    struct libtrace_packet_t *arg2 = (struct libtrace_packet_t *) 0 ;
     2274    int result;
     2275    PyObject * obj0 = 0 ;
     2276    PyObject * obj1 = 0 ;
     2277   
     2278    if(!PyArg_ParseTuple(args,(char *)"OO:Trace_trace_read_packet",&obj0,&obj1)) goto fail;
    22952279    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_libtrace_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
    2296     result = (Packet *)libtrace_t_read_packet(arg1);
    2297    
    2298     resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_Packet, 0);
     2280    if ((SWIG_ConvertPtr(obj1,(void **) &arg2, SWIGTYPE_p_libtrace_packet_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     2281    result = (int)libtrace_t_trace_read_packet(arg1,arg2);
     2282   
     2283    resultobj = PyInt_FromLong((long)result);
    22992284    return resultobj;
    23002285    fail:
     
    23302315         { (char *)"libtrace_ip_ip_src_get", _wrap_libtrace_ip_ip_src_get, METH_VARARGS },
    23312316         { (char *)"libtrace_ip_ip_dst_get", _wrap_libtrace_ip_ip_dst_get, METH_VARARGS },
     2317         { (char *)"delete_libtrace_ip", _wrap_delete_libtrace_ip, METH_VARARGS },
    23322318         { (char *)"libtrace_ip_swigregister", libtrace_ip_swigregister, METH_VARARGS },
    23332319         { (char *)"libtrace_tcp_res1_set", _wrap_libtrace_tcp_res1_set, METH_VARARGS },
     
    23562342         { (char *)"libtrace_tcp_seq_get", _wrap_libtrace_tcp_seq_get, METH_VARARGS },
    23572343         { (char *)"libtrace_tcp_ack_seq_get", _wrap_libtrace_tcp_ack_seq_get, METH_VARARGS },
     2344         { (char *)"delete_libtrace_tcp", _wrap_delete_libtrace_tcp, METH_VARARGS },
    23582345         { (char *)"libtrace_tcp_swigregister", libtrace_tcp_swigregister, METH_VARARGS },
    23592346         { (char *)"libtrace_udp_source_get", _wrap_libtrace_udp_source_get, METH_VARARGS },
     
    23612348         { (char *)"libtrace_udp_len_get", _wrap_libtrace_udp_len_get, METH_VARARGS },
    23622349         { (char *)"libtrace_udp_check_get", _wrap_libtrace_udp_check_get, METH_VARARGS },
     2350         { (char *)"delete_libtrace_udp", _wrap_delete_libtrace_udp, METH_VARARGS },
    23632351         { (char *)"libtrace_udp_swigregister", libtrace_udp_swigregister, METH_VARARGS },
    23642352         { (char *)"libtrace_icmp_type_set", _wrap_libtrace_icmp_type_set, METH_VARARGS },
     
    23692357         { (char *)"libtrace_icmp_checksum_get", _wrap_libtrace_icmp_checksum_get, METH_VARARGS },
    23702358         { (char *)"libtrace_icmp_un_get", _wrap_libtrace_icmp_un_get, METH_VARARGS },
     2359         { (char *)"delete_libtrace_icmp", _wrap_delete_libtrace_icmp, METH_VARARGS },
    23712360         { (char *)"libtrace_icmp_swigregister", libtrace_icmp_swigregister, METH_VARARGS },
    23722361         { (char *)"libtrace_icmp_un_gateway_set", _wrap_libtrace_icmp_un_gateway_set, METH_VARARGS },
     
    23852374         { (char *)"libtrace_icmp_un_echo_sequence_get", _wrap_libtrace_icmp_un_echo_sequence_get, METH_VARARGS },
    23862375         { (char *)"libtrace_icmp_un_echo_swigregister", libtrace_icmp_un_echo_swigregister, METH_VARARGS },
    2387          { (char *)"Packet_buffer_set", _wrap_Packet_buffer_set, METH_VARARGS },
    2388          { (char *)"Packet_buffer_get", _wrap_Packet_buffer_get, METH_VARARGS },
    2389          { (char *)"Packet_status_set", _wrap_Packet_status_set, METH_VARARGS },
    2390          { (char *)"Packet_status_get", _wrap_Packet_status_get, METH_VARARGS },
    2391          { (char *)"Packet_len_set", _wrap_Packet_len_set, METH_VARARGS },
    2392          { (char *)"Packet_len_get", _wrap_Packet_len_get, METH_VARARGS },
    2393          { (char *)"Packet_get_ip", _wrap_Packet_get_ip, METH_VARARGS },
    2394          { (char *)"Packet_get_tcp", _wrap_Packet_get_tcp, METH_VARARGS },
    2395          { (char *)"Packet_get_udp", _wrap_Packet_get_udp, METH_VARARGS },
    2396          { (char *)"Packet_get_icmp", _wrap_Packet_get_icmp, METH_VARARGS },
    2397          { (char *)"Packet_get_seconds", _wrap_Packet_get_seconds, METH_VARARGS },
     2376         { (char *)"new_Packet", _wrap_new_Packet, METH_VARARGS },
     2377         { (char *)"delete_Packet", _wrap_delete_Packet, METH_VARARGS },
     2378         { (char *)"Packet_trace_get_ip", _wrap_Packet_trace_get_ip, METH_VARARGS },
     2379         { (char *)"Packet_trace_get_tcp", _wrap_Packet_trace_get_tcp, METH_VARARGS },
     2380         { (char *)"Packet_trace_get_udp", _wrap_Packet_trace_get_udp, METH_VARARGS },
     2381         { (char *)"Packet_trace_get_icmp", _wrap_Packet_trace_get_icmp, METH_VARARGS },
     2382         { (char *)"Packet_trace_get_seconds", _wrap_Packet_trace_get_seconds, METH_VARARGS },
    23982383         { (char *)"Packet_swigregister", Packet_swigregister, METH_VARARGS },
    23992384         { (char *)"new_Trace", _wrap_new_Trace, METH_VARARGS },
    24002385         { (char *)"delete_Trace", _wrap_delete_Trace, METH_VARARGS },
    2401          { (char *)"Trace_read_packet", _wrap_Trace_read_packet, METH_VARARGS },
     2386         { (char *)"Trace_trace_read_packet", _wrap_Trace_trace_read_packet, METH_VARARGS },
    24022387         { (char *)"Trace_swigregister", Trace_swigregister, METH_VARARGS },
    24032388         { NULL, NULL }
     
    24082393
    24092394static swig_type_info _swigt__p_in_addr[] = {{"_p_in_addr", 0, "in_addr *", 0},{"_p_in_addr"},{0}};
    2410 static swig_type_info _swigt__p_Packet[] = {{"_p_Packet", 0, "Packet *", 0},{"_p_Packet"},{0}};
    24112395static swig_type_info _swigt__p_libtrace_icmp[] = {{"_p_libtrace_icmp", 0, "struct libtrace_icmp *", 0},{"_p_libtrace_icmp"},{0}};
    24122396static swig_type_info _swigt__p_libtrace_icmp_un_echo[] = {{"_p_libtrace_icmp_un_echo", 0, "libtrace_icmp_un_echo *", 0},{"_p_libtrace_icmp_un_echo"},{0}};
     2397static swig_type_info _swigt__p_libtrace_packet_t[] = {{"_p_libtrace_packet_t", 0, "struct libtrace_packet_t *", 0},{"_p_libtrace_packet_t"},{0}};
    24132398static swig_type_info _swigt__p_libtrace_ip[] = {{"_p_libtrace_ip", 0, "struct libtrace_ip *", 0},{"_p_libtrace_ip"},{0}};
    24142399static swig_type_info _swigt__p_libtrace_icmp_un_frag[] = {{"_p_libtrace_icmp_un_frag", 0, "libtrace_icmp_un_frag *", 0},{"_p_libtrace_icmp_un_frag"},{0}};
    24152400static swig_type_info _swigt__p_libtrace_t[] = {{"_p_libtrace_t", 0, "libtrace_t *", 0},{"_p_libtrace_t"},{0}};
    24162401static swig_type_info _swigt__p_libtrace_udp[] = {{"_p_libtrace_udp", 0, "struct libtrace_udp *", 0},{"_p_libtrace_udp"},{0}};
    2417 static swig_type_info _swigt__p_void[] = {{"_p_void", 0, "void *", 0},{"_p_void"},{0}};
    24182402static swig_type_info _swigt__p_libtrace_tcp[] = {{"_p_libtrace_tcp", 0, "struct libtrace_tcp *", 0},{"_p_libtrace_tcp"},{0}};
    24192403static swig_type_info _swigt__p_libtrace_icmp_un[] = {{"_p_libtrace_icmp_un", 0, "libtrace_icmp_un *", 0},{"_p_libtrace_icmp_un"},{0}};
     
    24212405static swig_type_info *swig_types_initial[] = {
    24222406_swigt__p_in_addr,
    2423 _swigt__p_Packet,
    24242407_swigt__p_libtrace_icmp,
    24252408_swigt__p_libtrace_icmp_un_echo,
     2409_swigt__p_libtrace_packet_t,
    24262410_swigt__p_libtrace_ip,
    24272411_swigt__p_libtrace_icmp_un_frag,
    24282412_swigt__p_libtrace_t,
    24292413_swigt__p_libtrace_udp,
    2430 _swigt__p_void,
    24312414_swigt__p_libtrace_tcp,
    24322415_swigt__p_libtrace_icmp_un,
  • swig/python/check.py

    r4e194bc r2980487  
    77print "trace=",trace
    88
    9 packet = trace.read_packet()
    109
    11 print "packet=",packet
    1210
    1311while 1:
    14         packet = trace.read_packet()
     12        packet = libtrace.Packet()
     13        trace.trace_read_packet(packet)
    1514        if not packet:
    1615                break
    17         print packet.get_ip().ip_src,'->',packet.get_ip().ip_dst
     16        ippacket = packet.trace_get_ip()
     17        if not ippacket:
     18                continue
    1819
     20        print ippacket.ip_src,'->',ippacket.ip_dst
     21
  • swig/python/libtrace.py

    r4e194bc r2980487  
    8585    __swig_getmethods__["ip_dst"] = _libtrace.libtrace_ip_ip_dst_get
    8686    if _newclass:ip_dst = property(_libtrace.libtrace_ip_ip_dst_get)
     87    def __del__(self, destroy=_libtrace.delete_libtrace_ip):
     88        try:
     89            if self.thisown: destroy(self)
     90        except: pass
    8791
    8892class libtrace_ipPtr(libtrace_ip):
     
    146150    __swig_getmethods__["ack_seq"] = _libtrace.libtrace_tcp_ack_seq_get
    147151    if _newclass:ack_seq = property(_libtrace.libtrace_tcp_ack_seq_get)
     152    def __del__(self, destroy=_libtrace.delete_libtrace_tcp):
     153        try:
     154            if self.thisown: destroy(self)
     155        except: pass
    148156
    149157class libtrace_tcpPtr(libtrace_tcp):
     
    170178    __swig_getmethods__["check"] = _libtrace.libtrace_udp_check_get
    171179    if _newclass:check = property(_libtrace.libtrace_udp_check_get)
     180    def __del__(self, destroy=_libtrace.delete_libtrace_udp):
     181        try:
     182            if self.thisown: destroy(self)
     183        except: pass
    172184
    173185class libtrace_udpPtr(libtrace_udp):
     
    197209    __swig_getmethods__["un"] = _libtrace.libtrace_icmp_un_get
    198210    if _newclass:un = property(_libtrace.libtrace_icmp_un_get)
     211    def __del__(self, destroy=_libtrace.delete_libtrace_icmp):
     212        try:
     213            if self.thisown: destroy(self)
     214        except: pass
    199215
    200216class libtrace_icmpPtr(libtrace_icmp):
     
    277293    __swig_getmethods__ = {}
    278294    __getattr__ = lambda self, name: _swig_getattr(self, Packet, name)
    279     def __init__(self): raise RuntimeError, "No constructor defined"
    280     def __repr__(self):
    281         return "<C Packet instance at %s>" % (self.this,)
    282     __swig_setmethods__["buffer"] = _libtrace.Packet_buffer_set
    283     __swig_getmethods__["buffer"] = _libtrace.Packet_buffer_get
    284     if _newclass:buffer = property(_libtrace.Packet_buffer_get, _libtrace.Packet_buffer_set)
    285     __swig_setmethods__["status"] = _libtrace.Packet_status_set
    286     __swig_getmethods__["status"] = _libtrace.Packet_status_get
    287     if _newclass:status = property(_libtrace.Packet_status_get, _libtrace.Packet_status_set)
    288     __swig_setmethods__["len"] = _libtrace.Packet_len_set
    289     __swig_getmethods__["len"] = _libtrace.Packet_len_get
    290     if _newclass:len = property(_libtrace.Packet_len_get, _libtrace.Packet_len_set)
    291     def get_ip(*args): return _libtrace.Packet_get_ip(*args)
    292     def get_tcp(*args): return _libtrace.Packet_get_tcp(*args)
    293     def get_udp(*args): return _libtrace.Packet_get_udp(*args)
    294     def get_icmp(*args): return _libtrace.Packet_get_icmp(*args)
    295     def get_seconds(*args): return _libtrace.Packet_get_seconds(*args)
     295    def __repr__(self):
     296        return "<C libtrace_packet_t instance at %s>" % (self.this,)
     297    def __init__(self, *args):
     298        _swig_setattr(self, Packet, 'this', _libtrace.new_Packet(*args))
     299        _swig_setattr(self, Packet, 'thisown', 1)
     300    def __del__(self, destroy=_libtrace.delete_Packet):
     301        try:
     302            if self.thisown: destroy(self)
     303        except: pass
     304    def trace_get_ip(*args): return _libtrace.Packet_trace_get_ip(*args)
     305    def trace_get_tcp(*args): return _libtrace.Packet_trace_get_tcp(*args)
     306    def trace_get_udp(*args): return _libtrace.Packet_trace_get_udp(*args)
     307    def trace_get_icmp(*args): return _libtrace.Packet_trace_get_icmp(*args)
     308    def trace_get_seconds(*args): return _libtrace.Packet_trace_get_seconds(*args)
    296309
    297310class PacketPtr(Packet):
     
    316329            if self.thisown: destroy(self)
    317330        except: pass
    318     def read_packet(*args): return _libtrace.Trace_read_packet(*args)
     331    def trace_read_packet(*args): return _libtrace.Trace_trace_read_packet(*args)
    319332
    320333class TracePtr(Trace):
Note: See TracChangeset for help on using the changeset viewer.