Creates a new Packet instance and returns the object itself.
static VALUE rbpacket_new_s(VALUE class) { VALUE self; rbpacket_t *rbpacket; // need to make destructor do a pcap_close later self = Data_Make_Struct(class, rbpacket_t, 0, rbpacket_free, rbpacket); rb_obj_call_init(self, 0, 0); memset(rbpacket, 0, sizeof(rbpacket_t)); return self; }
Returns the integer length of capture len from the in the PCAP::Packet header
static VALUE rbpacket_caplen(VALUE self) { rbpacket_t* rbpacket; Data_Get_Struct(self, rbpacket_t, rbpacket); return INT2NUM(rbpacket->hdr->caplen); }
Returns the integer PCAP MINOR LIBRARY value unless capture
static VALUE rbpacket_data(VALUE self) { rbpacket_t* rbpacket; Data_Get_Struct(self, rbpacket_t, rbpacket); if(rbpacket->pkt == NULL) return Qnil; return rb_str_new((char *) rbpacket->pkt, rbpacket->hdr->caplen); }
Returns the integer length of packet length field from the in the PCAP::Packet header
static VALUE rbpacket_length(VALUE self) { rbpacket_t* rbpacket; Data_Get_Struct(self, rbpacket_t, rbpacket); return INT2NUM(rbpacket->hdr->len); }
Returns the tv_usec integer from the ts.tv_usec record in the PCAP::Packet header timestamp microseconds the microseconds when this packet was captured, as an offset to ts_sec. Beware: this value shouldn't reach 1 second (1 000 000), in this case ts_sec must be increased instead!
Ruby Microsecond Handling Time.at(946684800.2).usec #=> 200000 Time.now.usec
static VALUE rbpacket_microsec(VALUE self) { rbpacket_t* rbpacket; Data_Get_Struct(self, rbpacket_t, rbpacket); return INT2NUM(rbpacket->hdr->ts.tv_usec); }
Generated with the Darkfish Rdoc Generator 2.