ruby/trema/packet_in.c in trema-0.1.3 vs ruby/trema/packet_in.c in trema-0.1.3.1
- old
+ new
@@ -139,22 +139,22 @@
*
* @return [Number] the value of in_port.
*/
static VALUE
packet_in_in_port( VALUE self ) {
- return INT2NUM( get_packet_in( self )->in_port );
+ return UINT2NUM( get_packet_in( self )->in_port );
}
/*
* The full length of the received frame.
*
* @return [Number] the value of total_len.
*/
static VALUE
packet_in_total_len( VALUE self ) {
- return INT2NUM( get_packet_in( self )->total_len );
+ return UINT2NUM( get_packet_in( self )->total_len );
}
/*
* A String that holds the entire or portion of the received frame.
@@ -174,11 +174,11 @@
*
* @return [Number] the value of reason.
*/
static VALUE
packet_in_reason( VALUE self ) {
- return INT2NUM( get_packet_in( self )->reason );
+ return UINT2NUM( ( unsigned int ) get_packet_in( self )->reason );
}
/*
* The MAC source address.
@@ -299,10 +299,109 @@
}
}
/*
+ * The IPv4 version number.
+ *
+ * @return [Integer] ipv4_version The IPv4 version number.
+ */
+static VALUE
+packet_in_ipv4_version( VALUE self ) {
+ return UINT2NUM( ( unsigned int ) get_packet_in_info( self )->ipv4_version );
+}
+
+
+/*
+ * The IPv4 internet header length.
+ *
+ * @return [Integer] ipv4_ihl The IPv4 internet header length.
+ */
+static VALUE
+packet_in_ipv4_ihl( VALUE self ) {
+ return UINT2NUM( ( unsigned int ) get_packet_in_info( self )->ipv4_ihl );
+}
+
+
+/*
+ * The IPv4 tos value.
+ *
+ * @return [Integer] ipv4_tos The IPv4 tos value.
+ */
+static VALUE
+packet_in_ipv4_tos( VALUE self ) {
+ return UINT2NUM( ( unsigned int ) get_packet_in_info( self )->ipv4_tos );
+}
+
+
+/*
+ * The IPv4 total length.
+ *
+ * @return [Integer] ipv4_tot_len The IPv4 total length.
+ */
+static VALUE
+packet_in_ipv4_tot_len( VALUE self ) {
+ return UINT2NUM( get_packet_in_info( self )->ipv4_tot_len );
+}
+
+
+/*
+ * The IPv4 identifier.
+ *
+ * @return [Integer] ipv4_id The IPv4 identifier.
+ */
+static VALUE
+packet_in_ipv4_id( VALUE self ) {
+ return UINT2NUM( get_packet_in_info( self )->ipv4_id );
+}
+
+
+/*
+ * The IPv4 fragment offset.
+ *
+ * @return [Integer] ipv4_frag_off The IPv4 fragment offset.
+ */
+static VALUE
+packet_in_ipv4_frag_off( VALUE self ) {
+ return UINT2NUM( get_packet_in_info( self )->ipv4_frag_off );
+}
+
+
+/*
+ * The IPv4 ttl value.
+ *
+ * @return [Integer] ipv4_ttl The IPv4 ttl value.
+ */
+static VALUE
+packet_in_ipv4_ttl( VALUE self ) {
+ return UINT2NUM( ( unsigned int ) get_packet_in_info( self )->ipv4_ttl );
+}
+
+
+/*
+ * The IPv4 protocol number.
+ *
+ * @return [Integer] ipv4_protocol The IPv4 protocol number.
+ */
+static VALUE
+packet_in_ipv4_protocol( VALUE self ) {
+ return UINT2NUM( ( unsigned int ) get_packet_in_info( self )->ipv4_protocol );
+}
+
+
+/*
+ * The IPv4 checksum.
+ *
+ * @return [Integer] ipv4_checksum The IPv4 checksum.
+ */
+static VALUE
+packet_in_ipv4_checksum( VALUE self ) {
+ return UINT2NUM( get_packet_in_info( self )->ipv4_checksum );
+}
+
+
+/*
* The IPV4 source protocol address.
*
* @return [Trema::IP] ipv4_saddr IP protocol address.
*/
static VALUE
@@ -343,22 +442,22 @@
*
* @return [Integer] icmpv4_type The ICMPv4 message type.
*/
static VALUE
packet_in_icmpv4_type( VALUE self ) {
- return get_packet_in_info( self )->icmpv4_type;
+ return UINT2NUM( ( unsigned int ) get_packet_in_info( self )->icmpv4_type );
}
/*
* The ICMPv4 message code.
*
* @return [Integer] icmpv4_code The ICMPv4 message code.
*/
static VALUE
packet_in_icmpv4_code( VALUE self ) {
- return get_packet_in_info( self )->icmpv4_code;
+ return UINT2NUM( ( unsigned int ) get_packet_in_info( self )->icmpv4_code );
}
/*
* The ICMPv4 message checksum.
@@ -505,11 +604,11 @@
*
* @return [Integer] igmp_type IGMP type.
*/
static VALUE
packet_in_igmp_type( VALUE self ) {
- return UINT2NUM( get_packet_in_info( self )->igmp_type );
+ return UINT2NUM( ( unsigned int ) get_packet_in_info( self )->igmp_type );
}
/*
* The IGMP group address.
@@ -543,26 +642,103 @@
*
* @return [Integer] tcp_src_port TCP port.
*/
static VALUE
packet_in_tcp_src_port( VALUE self ) {
- return ULONG2NUM( get_packet_in_info( self )->tcp_src_port );
+ return UINT2NUM( get_packet_in_info( self )->tcp_src_port );
}
/*
* The TCP destination port.
*
* @return [Integer] tcp_dst_port TCP port.
*/
static VALUE
packet_in_tcp_dst_port( VALUE self ) {
- return ULONG2NUM( get_packet_in_info( self )->tcp_dst_port );
+ return UINT2NUM( get_packet_in_info( self )->tcp_dst_port );
}
/*
+ * The TCP sequence number.
+ *
+ * @return [Integer] tcp_seq_no a TCP sequence number.
+ */
+static VALUE
+packet_in_tcp_seq_no( VALUE self ) {
+ return ULONG2NUM( get_packet_in_info( self )->tcp_seq_no );
+}
+
+
+/*
+ * The TCP acknowledge number.
+ *
+ * @return [Integer] tcp_ack_no a TCP acknowkedge number.
+ */
+static VALUE
+packet_in_tcp_ack_no( VALUE self ) {
+ return ULONG2NUM( get_packet_in_info( self )->tcp_ack_no );
+}
+
+
+/*
+ * The TCP offset.
+ *
+ * @return [Integer] tcp_offset a TCP offset.
+ */
+static VALUE
+packet_in_tcp_offset( VALUE self ) {
+ return UINT2NUM( ( unsigned int ) get_packet_in_info( self )->tcp_offset );
+}
+
+
+/*
+ * The TCP flags.
+ *
+ * @return [Integer] tcp_flags TCP flags.
+ */
+static VALUE
+packet_in_tcp_flags( VALUE self ) {
+ return UINT2NUM( ( unsigned int ) get_packet_in_info( self )->tcp_flags );
+}
+
+
+/*
+ * The TCP window.
+ *
+ * @return [Integer] tcp_window a TCP window.
+ */
+static VALUE
+packet_in_tcp_window( VALUE self ) {
+ return UINT2NUM( get_packet_in_info( self )->tcp_window );
+}
+
+
+/*
+ * The TCP checksum.
+ *
+ * @return [Integer] tcp_checksum a TCP checksum.
+ */
+static VALUE
+packet_in_tcp_checksum( VALUE self ) {
+ return UINT2NUM( get_packet_in_info( self )->tcp_checksum );
+}
+
+
+/*
+ * The TCP urgent.
+ *
+ * @return [Integer] tcp_urgent a TCP urgent.
+ */
+static VALUE
+packet_in_tcp_urgent( VALUE self ) {
+ return UINT2NUM( get_packet_in_info( self )->tcp_urgent );
+}
+
+
+/*
* Is an UDP packet?
*
* @return [bool] udp? Is an UDP packet?
*/
static VALUE
@@ -594,25 +770,47 @@
*
* @return [Integer] udp_src_port UDP port.
*/
static VALUE
packet_in_udp_src_port( VALUE self ) {
- return ULONG2NUM( get_packet_in_info( self )->udp_src_port );
+ return UINT2NUM( get_packet_in_info( self )->udp_src_port );
}
/*
* The UDP destination port.
*
* @return [Integer] udp_dst_port UDP port.
*/
static VALUE
packet_in_udp_dst_port( VALUE self ) {
- return ULONG2NUM( get_packet_in_info( self )->udp_dst_port );
+ return UINT2NUM( get_packet_in_info( self )->udp_dst_port );
}
+/*
+ * The UDP length.
+ *
+ * @return [Integer] udp_len a UDP length.
+ */
+static VALUE
+packet_in_udp_len( VALUE self ) {
+ return UINT2NUM( get_packet_in_info( self )->udp_len );
+}
+
+
+/*
+ * The UDP checksum.
+ *
+ * @return [Integer] udp_checksum a UDP checksum.
+ */
+static VALUE
+packet_in_udp_checksum( VALUE self ) {
+ return UINT2NUM( get_packet_in_info( self )->udp_checksum );
+}
+
+
void
Init_packet_in() {
rb_require( "trema/ip" );
rb_require( "trema/mac" );
cPacketIn = rb_define_class_under( mTrema, "PacketIn", rb_cObject );
@@ -650,10 +848,19 @@
rb_define_method( mPacketInARP, "arp_spa", packet_in_arp_spa, 0 );
rb_define_method( mPacketInARP, "arp_tha", packet_in_arp_tha, 0 );
rb_define_method( mPacketInARP, "arp_tpa", packet_in_arp_tpa, 0 );
mPacketInIPv4 = rb_define_module_under( mTrema, "PacketInIPv4" );
+ rb_define_method( mPacketInIPv4, "ipv4_version", packet_in_ipv4_version, 0 );
+ rb_define_method( mPacketInIPv4, "ipv4_ihl", packet_in_ipv4_ihl, 0 );
+ rb_define_method( mPacketInIPv4, "ipv4_tos", packet_in_ipv4_tos, 0 );
+ rb_define_method( mPacketInIPv4, "ipv4_tot_len", packet_in_ipv4_tot_len, 0 );
+ rb_define_method( mPacketInIPv4, "ipv4_id", packet_in_ipv4_id, 0 );
+ rb_define_method( mPacketInIPv4, "ipv4_frag_off", packet_in_ipv4_frag_off, 0 );
+ rb_define_method( mPacketInIPv4, "ipv4_ttl", packet_in_ipv4_ttl, 0 );
+ rb_define_method( mPacketInIPv4, "ipv4_protocol", packet_in_ipv4_protocol, 0 );
+ rb_define_method( mPacketInIPv4, "ipv4_checksum", packet_in_ipv4_checksum, 0 );
rb_define_method( mPacketInIPv4, "ipv4_saddr", packet_in_ipv4_saddr, 0 );
rb_define_method( mPacketInIPv4, "ipv4_daddr", packet_in_ipv4_daddr, 0 );
mPacketInICMPv4 = rb_define_module_under( mTrema, "PacketInICMPv4" );
rb_define_method( mPacketInICMPv4, "icmpv4_type", packet_in_icmpv4_type, 0 );
@@ -673,14 +880,23 @@
rb_define_method( mPacketInIGMP, "igmp_v3_membership_report?", packet_in_is_igmp_v3_membership_report, 0 );
mPacketInTCP = rb_define_module_under( mTrema, "PacketInTCP" );
rb_define_method( mPacketInTCP, "tcp_src_port", packet_in_tcp_src_port, 0 );
rb_define_method( mPacketInTCP, "tcp_dst_port", packet_in_tcp_dst_port, 0 );
+ rb_define_method( mPacketInTCP, "tcp_seq_no", packet_in_tcp_seq_no, 0 );
+ rb_define_method( mPacketInTCP, "tcp_ack_no", packet_in_tcp_ack_no, 0 );
+ rb_define_method( mPacketInTCP, "tcp_offset", packet_in_tcp_offset, 0 );
+ rb_define_method( mPacketInTCP, "tcp_flags", packet_in_tcp_flags, 0 );
+ rb_define_method( mPacketInTCP, "tcp_window", packet_in_tcp_window, 0 );
+ rb_define_method( mPacketInTCP, "tcp_checksum", packet_in_tcp_checksum, 0 );
+ rb_define_method( mPacketInTCP, "tcp_urgent", packet_in_tcp_urgent, 0 );
mPacketInUDP = rb_define_module_under( mTrema, "PacketInUDP" );
rb_define_method( mPacketInUDP, "udp_payload", packet_in_udp_payload, 0 );
rb_define_method( mPacketInUDP, "udp_src_port", packet_in_udp_src_port, 0 );
rb_define_method( mPacketInUDP, "udp_dst_port", packet_in_udp_dst_port, 0 );
+ rb_define_method( mPacketInUDP, "udp_checksum", packet_in_udp_checksum, 0 );
+ rb_define_method( mPacketInUDP, "udp_len", packet_in_udp_len, 0 );
}
/*
* Handler called when +OFPT_PACKET_IN+ message is received.