/* * Is it an IGMP packet? * * @return [Boolean] whether the packet is an IGMP packet or not. */ static VALUE packet_in_is_igmp( VALUE self ) { if ( ( get_packet_in_info( self )->format & NW_IGMP ) ) { return Qtrue; } else { return Qfalse; } }
/* * Is it a TCP packet? * * @return [Boolean] whether the packet is a TCP packet or not. */ static VALUE packet_in_is_tcp( VALUE self ) { if ( ( get_packet_in_info( self )->format & TP_TCP ) ) { return Qtrue; } else { return Qfalse; } }
/* * The IGMP group address. * * @return [Trema::IP, nil] * the value of IGMP IP group address as a Trema::IP object * or nil if packet is not IGMP. */ static VALUE packet_in_igmp_group( VALUE self ) { if ( ( get_packet_in_info( self )->format & NW_IGMP ) ) { PACKET_IN_RETURN_IP( igmp_group ); } else { return Qnil; } }
/* * Is it an ICMPv4 packet? * * @return [Boolean] whether the packet is an ICMPv4 packet or not. */ static VALUE packet_in_is_icmpv4( VALUE self ) { if ( ( get_packet_in_info( self )->format & NW_ICMPV4 ) ) { return Qtrue; } else { return Qfalse; } }
/* * The ICMPv4 redirect message gateway IP address. * * @return [Trema::IP, nil] * the value of ICMPv4 redirect message IP gateway address as a Trema::IP * object or nil if packet is not ICMPv4. */ static VALUE packet_in_icmpv4_gateway( VALUE self ) { if ( ( get_packet_in_info( self )->format & NW_ICMPV4 ) ) { PACKET_IN_RETURN_IP( icmpv4_gateway ); } else { return Qnil; } }
/* * The ARP target protocol address of a packet. * * @return [Trema::IP] * the value of ARP target protocol address as a Trema::IP object or nil if * packet is not an ARP. */ static VALUE packet_in_arp_tpa( VALUE self ) { if ( ( get_packet_in_info( self )->format & NW_ARP ) ) { PACKET_IN_RETURN_IP( arp_tpa ); } else { return Qnil; } }
/* * The RARP target hardware address of a packet. * * @return [Mac] * the value of RARP target hardware address as a Mac object or nil if * packet is not an RARP. */ static VALUE packet_in_rarp_tha( VALUE self ) { if ( ( get_packet_in_info( self )->format & NW_RARP ) ) { PACKET_IN_RETURN_MAC( arp_tha ); } else { return Qnil; } }
/* * Is it an IEEE 802.1q packet? * * @return [Boolean] whether the packet is an IEEE 802.1q or not. */ static VALUE packet_in_is_vtag( VALUE self ) { if ( ( get_packet_in_info( self )->format & ETH_8021Q ) ) { return Qtrue; } else { return Qfalse; } }
/* * The IPV4 destination IP address of a packet. * * @return [Trema::IP, nil] * the value of IPv4 destination IP address as a Trema::IP object or nil if * packet is not an IPv4. */ static VALUE packet_in_ipv4_daddr( VALUE self ) { if ( ( get_packet_in_info( self )->format & NW_IPV4 ) ) { PACKET_IN_RETURN_IP( ipv4_daddr ); } else { return Qnil; } }
/* * The ethernet type. * * @return [Integer] the value of ethernet type. */ static VALUE packet_in_eth_type( VALUE self ) { return UINT2NUM( get_packet_in_info( self )->eth_type ); }
/* * A String that holds the UDP payload. * Length of data, total_len - 20 bytes. * * @return [String] the value of data. */ static VALUE packet_in_udp_payload( VALUE self ) { packet_info *cpacket = get_packet_in_info( self ); return rb_str_new( cpacket->l4_payload, ( long ) cpacket->l4_payload_length ); }
/* * 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 ); }
/* * 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 destination port. * * @return [Integer] udp_dst_port UDP port. */ static VALUE packet_in_udp_dst_port( VALUE self ) { return UINT2NUM( get_packet_in_info( self )->udp_dst_port ); }
/* * The ICMPv4 message code. * * @return [Integer] icmpv4_code The ICMPv4 message code. */ static VALUE packet_in_icmpv4_code( VALUE self ) { return UINT2NUM( ( unsigned int ) get_packet_in_info( self )->icmpv4_code ); }
/* * 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 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 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 source port. * * @return [Integer] tcp_src_port TCP port. */ static VALUE packet_in_tcp_src_port( VALUE self ) { return UINT2NUM( get_packet_in_info( self )->tcp_src_port ); }
/* * The IGMP message type. * * @return [Integer] igmp_type IGMP type. */ static VALUE packet_in_igmp_type( VALUE self ) { return UINT2NUM( ( unsigned int ) get_packet_in_info( self )->igmp_type ); }
/* * The sequence number of ICMPv4 echo. * * @return [Integer] icmpv4_id The sequence number of ICMPv4 echo. */ static VALUE packet_in_icmpv4_seq( VALUE self ) { return UINT2NUM( get_packet_in_info( self )->icmpv4_seq ); }
/* * 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 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 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 ARP operation code. * * @return [integer] arp_oper Operation code. */ static VALUE packet_in_arp_oper( VALUE self ) { return UINT2NUM( ( unsigned int ) get_packet_in_info( self )->arp_ar_op ); }
/* * 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 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 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 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 ); }
/* * The vlan vid. * * @return [integer] vlan_vid The vlan vid */ static VALUE packet_in_vlan_vid( VALUE self ) { return UINT2NUM( get_packet_in_info( self )->vlan_vid ); }