Ejemplo n.º 1
0
/*
 * 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;
  }
}
Ejemplo n.º 2
0
/*
 * 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;
  }
}
Ejemplo n.º 3
0
/*
 * 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;
  }
}
Ejemplo n.º 4
0
/*
 * 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;
  }
}
Ejemplo n.º 5
0
/*
 * 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;
  }
}
Ejemplo n.º 6
0
/*
 * 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;
  }
}
Ejemplo n.º 7
0
/*
 * 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;
  }
}
Ejemplo n.º 8
0
/*
 * 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;
  }
}
Ejemplo n.º 9
0
/*
 * 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;
  }
}
Ejemplo n.º 10
0
/*
 * 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 );
}
Ejemplo n.º 11
0
/*
 * 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 );
}
Ejemplo n.º 12
0
/*
 * 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 );
}
Ejemplo n.º 13
0
/*
 * 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 );
}
Ejemplo n.º 14
0
/*
 * 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 );
}
Ejemplo n.º 15
0
/*
 * 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 );
}
Ejemplo n.º 16
0
/*
 * 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 );
}
Ejemplo n.º 17
0
/*
 * 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 );
}
Ejemplo n.º 18
0
/*
 * 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 );
}
Ejemplo n.º 19
0
/*
 * 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 );
}
Ejemplo n.º 20
0
/*
 * 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 );
}
Ejemplo n.º 21
0
/*
 * 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 );
}
Ejemplo n.º 22
0
/*
 * 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 );
}
Ejemplo n.º 23
0
/*
 * 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 );
}
Ejemplo n.º 24
0
/*
 * 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 );
}
Ejemplo n.º 25
0
/*
 * 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 );
}
Ejemplo n.º 26
0
/*
 * 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 );
}
Ejemplo n.º 27
0
/*
 * 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 );
}
Ejemplo n.º 28
0
/*
 * 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 );
}
Ejemplo n.º 29
0
/*
 * 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 );
}
Ejemplo n.º 30
0
/*
 * 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 );
}