Changeset 77ba31d for swig


Ignore:
Timestamp:
09/21/04 13:45:44 (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:
6f34090
Parents:
2980487
Message:

poink

Location:
swig
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • swig/Makefile

    r4e194bc r77ba31d  
    1414clean:
    1515        rm -f libtrace_wrap.c libtrace_wrap.o _libtrace.so
     16
     17veryclean: clean
     18        rm -f core libtrace.pyc libtrace.py
  • swig/libtrace.i

    r2980487 r77ba31d  
    153153
    154154%rename (Packet) libtrace_packet_t;
    155 struct libtrace_packet_t {};
     155struct libtrace_packet_t
     156{
     157        struct libtrace_t *trace;
     158        char *buffer;
     159        size_t size;
     160        uint8_t status;
     161};
    156162
    157163%extend libtrace_packet_t {
    158164        libtrace_packet_t() {
    159                 struct libtrace_packet_t *packet = malloc(sizeof(struct libtrace_packet_t));
     165                struct libtrace_packet_t *packet = 0;
     166                packet = malloc(sizeof(struct libtrace_packet_t));
     167                packet->buffer = malloc(sizeof(char) * 65536);
    160168                return packet;
    161169                }
    162         ~libtrace_packet_t() {free(self);}
     170        ~libtrace_packet_t() { free(self->buffer); free(self);}
    163171        struct libtrace_ip *trace_get_ip() {
    164172                return trace_get_ip(self);
  • swig/libtrace_wrap.c

    r2980487 r77ba31d  
    691691#define  SWIGTYPE_p_libtrace_icmp_un_frag swig_types[5]
    692692#define  SWIGTYPE_p_libtrace_t swig_types[6]
    693 #define  SWIGTYPE_p_libtrace_udp swig_types[7]
    694 #define  SWIGTYPE_p_libtrace_tcp swig_types[8]
    695 #define  SWIGTYPE_p_libtrace_icmp_un swig_types[9]
    696 static swig_type_info *swig_types[11];
     693#define  SWIGTYPE_p_size_t swig_types[7]
     694#define  SWIGTYPE_p_libtrace_udp swig_types[8]
     695#define  SWIGTYPE_p_libtrace_tcp swig_types[9]
     696#define  SWIGTYPE_p_libtrace_icmp_un swig_types[10]
     697static swig_type_info *swig_types[12];
    697698
    698699/* -------- TYPES TABLE (END) -------- */
     
    780781
    781782struct libtrace_packet_t *new_libtrace_packet_t(){
    782                 struct libtrace_packet_t *packet = malloc(sizeof(struct libtrace_packet_t));
     783                struct libtrace_packet_t *packet = 0;
     784                packet = malloc(sizeof(struct libtrace_packet_t));
     785                packet->buffer = malloc(sizeof(char) * 65536);
    783786                return packet;
    784787                }
    785 void delete_libtrace_packet_t(struct libtrace_packet_t *self){free(self);}
     788void delete_libtrace_packet_t(struct libtrace_packet_t *self){ free(self->buffer); free(self);}
    786789struct libtrace_ip *libtrace_packet_t_trace_get_ip(struct libtrace_packet_t *self){
    787790                return trace_get_ip(self);
     
    21152118    return Py_BuildValue((char *)"");
    21162119}
     2120static PyObject *_wrap_Packet_trace_set(PyObject *self, PyObject *args) {
     2121    PyObject *resultobj;
     2122    struct libtrace_packet_t *arg1 = (struct libtrace_packet_t *) 0 ;
     2123    struct libtrace_t *arg2 = (struct libtrace_t *) 0 ;
     2124    PyObject * obj0 = 0 ;
     2125    PyObject * obj1 = 0 ;
     2126   
     2127    if(!PyArg_ParseTuple(args,(char *)"OO:Packet_trace_set",&obj0,&obj1)) goto fail;
     2128    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_libtrace_packet_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     2129    if ((SWIG_ConvertPtr(obj1,(void **) &arg2, SWIGTYPE_p_libtrace_t,SWIG_POINTER_EXCEPTION | SWIG_POINTER_DISOWN )) == -1) SWIG_fail;
     2130    if (arg1) (arg1)->trace = arg2;
     2131   
     2132    Py_INCREF(Py_None); resultobj = Py_None;
     2133    return resultobj;
     2134    fail:
     2135    return NULL;
     2136}
     2137
     2138
     2139static PyObject *_wrap_Packet_trace_get(PyObject *self, PyObject *args) {
     2140    PyObject *resultobj;
     2141    struct libtrace_packet_t *arg1 = (struct libtrace_packet_t *) 0 ;
     2142    struct libtrace_t *result;
     2143    PyObject * obj0 = 0 ;
     2144   
     2145    if(!PyArg_ParseTuple(args,(char *)"O:Packet_trace_get",&obj0)) goto fail;
     2146    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_libtrace_packet_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     2147    result = (struct libtrace_t *) ((arg1)->trace);
     2148   
     2149    resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_libtrace_t, 0);
     2150    return resultobj;
     2151    fail:
     2152    return NULL;
     2153}
     2154
     2155
     2156static PyObject *_wrap_Packet_buffer_set(PyObject *self, PyObject *args) {
     2157    PyObject *resultobj;
     2158    struct libtrace_packet_t *arg1 = (struct libtrace_packet_t *) 0 ;
     2159    char *arg2 ;
     2160    PyObject * obj0 = 0 ;
     2161   
     2162    if(!PyArg_ParseTuple(args,(char *)"Os:Packet_buffer_set",&obj0,&arg2)) goto fail;
     2163    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_libtrace_packet_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     2164    {
     2165        if (arg1->buffer) free((char*)arg1->buffer);
     2166        if (arg2) {
     2167            arg1->buffer = (char *) malloc(strlen(arg2)+1);
     2168            strcpy((char*)arg1->buffer,arg2);
     2169        } else {
     2170            arg1->buffer = 0;
     2171        }
     2172    }
     2173    Py_INCREF(Py_None); resultobj = Py_None;
     2174    return resultobj;
     2175    fail:
     2176    return NULL;
     2177}
     2178
     2179
     2180static PyObject *_wrap_Packet_buffer_get(PyObject *self, PyObject *args) {
     2181    PyObject *resultobj;
     2182    struct libtrace_packet_t *arg1 = (struct libtrace_packet_t *) 0 ;
     2183    char *result;
     2184    PyObject * obj0 = 0 ;
     2185   
     2186    if(!PyArg_ParseTuple(args,(char *)"O:Packet_buffer_get",&obj0)) goto fail;
     2187    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_libtrace_packet_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     2188    result = (char *) ((arg1)->buffer);
     2189   
     2190    resultobj = result ? PyString_FromString(result) : Py_BuildValue((char*)"");
     2191    return resultobj;
     2192    fail:
     2193    return NULL;
     2194}
     2195
     2196
     2197static PyObject *_wrap_Packet_size_set(PyObject *self, PyObject *args) {
     2198    PyObject *resultobj;
     2199    struct libtrace_packet_t *arg1 = (struct libtrace_packet_t *) 0 ;
     2200    size_t arg2 ;
     2201    PyObject * obj0 = 0 ;
     2202    PyObject * obj1 = 0 ;
     2203   
     2204    if(!PyArg_ParseTuple(args,(char *)"OO:Packet_size_set",&obj0,&obj1)) goto fail;
     2205    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_libtrace_packet_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     2206    arg2 = (size_t) PyInt_AsLong(obj1);
     2207    if (PyErr_Occurred()) SWIG_fail;
     2208    if (arg1) (arg1)->size = arg2;
     2209   
     2210    Py_INCREF(Py_None); resultobj = Py_None;
     2211    return resultobj;
     2212    fail:
     2213    return NULL;
     2214}
     2215
     2216
     2217static PyObject *_wrap_Packet_size_get(PyObject *self, PyObject *args) {
     2218    PyObject *resultobj;
     2219    struct libtrace_packet_t *arg1 = (struct libtrace_packet_t *) 0 ;
     2220    size_t result;
     2221    PyObject * obj0 = 0 ;
     2222   
     2223    if(!PyArg_ParseTuple(args,(char *)"O:Packet_size_get",&obj0)) goto fail;
     2224    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_libtrace_packet_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     2225    result =  ((arg1)->size);
     2226   
     2227    resultobj = PyInt_FromLong((long)result);
     2228    return resultobj;
     2229    fail:
     2230    return NULL;
     2231}
     2232
     2233
     2234static PyObject *_wrap_Packet_status_set(PyObject *self, PyObject *args) {
     2235    PyObject *resultobj;
     2236    struct libtrace_packet_t *arg1 = (struct libtrace_packet_t *) 0 ;
     2237    uint8_t arg2 ;
     2238    PyObject * obj0 = 0 ;
     2239    PyObject * obj1 = 0 ;
     2240   
     2241    if(!PyArg_ParseTuple(args,(char *)"OO:Packet_status_set",&obj0,&obj1)) goto fail;
     2242    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_libtrace_packet_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     2243    arg2 = (uint8_t) PyInt_AsLong(obj1);
     2244    if (PyErr_Occurred()) SWIG_fail;
     2245    if (arg1) (arg1)->status = arg2;
     2246   
     2247    Py_INCREF(Py_None); resultobj = Py_None;
     2248    return resultobj;
     2249    fail:
     2250    return NULL;
     2251}
     2252
     2253
     2254static PyObject *_wrap_Packet_status_get(PyObject *self, PyObject *args) {
     2255    PyObject *resultobj;
     2256    struct libtrace_packet_t *arg1 = (struct libtrace_packet_t *) 0 ;
     2257    uint8_t result;
     2258    PyObject * obj0 = 0 ;
     2259   
     2260    if(!PyArg_ParseTuple(args,(char *)"O:Packet_status_get",&obj0)) goto fail;
     2261    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_libtrace_packet_t,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     2262    result = (uint8_t) ((arg1)->status);
     2263   
     2264    resultobj = PyInt_FromLong((long)result);
     2265    return resultobj;
     2266    fail:
     2267    return NULL;
     2268}
     2269
     2270
    21172271static PyObject *_wrap_new_Packet(PyObject *self, PyObject *args) {
    21182272    PyObject *resultobj;
     
    23742528         { (char *)"libtrace_icmp_un_echo_sequence_get", _wrap_libtrace_icmp_un_echo_sequence_get, METH_VARARGS },
    23752529         { (char *)"libtrace_icmp_un_echo_swigregister", libtrace_icmp_un_echo_swigregister, METH_VARARGS },
     2530         { (char *)"Packet_trace_set", _wrap_Packet_trace_set, METH_VARARGS },
     2531         { (char *)"Packet_trace_get", _wrap_Packet_trace_get, METH_VARARGS },
     2532         { (char *)"Packet_buffer_set", _wrap_Packet_buffer_set, METH_VARARGS },
     2533         { (char *)"Packet_buffer_get", _wrap_Packet_buffer_get, METH_VARARGS },
     2534         { (char *)"Packet_size_set", _wrap_Packet_size_set, METH_VARARGS },
     2535         { (char *)"Packet_size_get", _wrap_Packet_size_get, METH_VARARGS },
     2536         { (char *)"Packet_status_set", _wrap_Packet_status_set, METH_VARARGS },
     2537         { (char *)"Packet_status_get", _wrap_Packet_status_get, METH_VARARGS },
    23762538         { (char *)"new_Packet", _wrap_new_Packet, METH_VARARGS },
    23772539         { (char *)"delete_Packet", _wrap_delete_Packet, METH_VARARGS },
     
    23992561static 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}};
    24002562static swig_type_info _swigt__p_libtrace_t[] = {{"_p_libtrace_t", 0, "libtrace_t *", 0},{"_p_libtrace_t"},{0}};
     2563static swig_type_info _swigt__p_size_t[] = {{"_p_size_t", 0, "size_t *", 0},{"_p_size_t"},{0}};
    24012564static swig_type_info _swigt__p_libtrace_udp[] = {{"_p_libtrace_udp", 0, "struct libtrace_udp *", 0},{"_p_libtrace_udp"},{0}};
    24022565static swig_type_info _swigt__p_libtrace_tcp[] = {{"_p_libtrace_tcp", 0, "struct libtrace_tcp *", 0},{"_p_libtrace_tcp"},{0}};
     
    24112574_swigt__p_libtrace_icmp_un_frag,
    24122575_swigt__p_libtrace_t,
     2576_swigt__p_size_t,
    24132577_swigt__p_libtrace_udp,
    24142578_swigt__p_libtrace_tcp,
  • swig/python/check.py

    r2980487 r77ba31d  
    88
    99
     10packet = libtrace.Packet()
    1011
    1112while 1:
    12         packet = libtrace.Packet()
    1313        trace.trace_read_packet(packet)
    1414        if not packet:
    1515                break
    16         ippacket = packet.trace_get_ip()
    17         if not ippacket:
    18                 continue
     16        #ippacket = packet.trace_get_ip()
     17        #if not ippacket:
     18#               continue
    1919
    20         print ippacket.ip_src,'->',ippacket.ip_dst
     20        print packet.size
     21        #print ippacket.ip_src,'->',ippacket.ip_dst
    2122
  • swig/python/libtrace.py

    r2980487 r77ba31d  
    295295    def __repr__(self):
    296296        return "<C libtrace_packet_t instance at %s>" % (self.this,)
     297    __swig_setmethods__["trace"] = _libtrace.Packet_trace_set
     298    __swig_getmethods__["trace"] = _libtrace.Packet_trace_get
     299    if _newclass:trace = property(_libtrace.Packet_trace_get, _libtrace.Packet_trace_set)
     300    __swig_setmethods__["buffer"] = _libtrace.Packet_buffer_set
     301    __swig_getmethods__["buffer"] = _libtrace.Packet_buffer_get
     302    if _newclass:buffer = property(_libtrace.Packet_buffer_get, _libtrace.Packet_buffer_set)
     303    __swig_setmethods__["size"] = _libtrace.Packet_size_set
     304    __swig_getmethods__["size"] = _libtrace.Packet_size_get
     305    if _newclass:size = property(_libtrace.Packet_size_get, _libtrace.Packet_size_set)
     306    __swig_setmethods__["status"] = _libtrace.Packet_status_set
     307    __swig_getmethods__["status"] = _libtrace.Packet_status_get
     308    if _newclass:status = property(_libtrace.Packet_status_get, _libtrace.Packet_status_set)
    297309    def __init__(self, *args):
    298310        _swig_setattr(self, Packet, 'this', _libtrace.new_Packet(*args))
Note: See TracChangeset for help on using the changeset viewer.