Exemplo n.º 1
0
void
free_packet_info( buffer *buf ) {
  die_if_NULL( buf );
  die_if_NULL( buf->user_data );

  xfree( buf->user_data );
  buf->user_data = NULL;
  buf->user_data_free_function = NULL;
}
Exemplo n.º 2
0
bool
packet_type_ether( const buffer *frame ) {
  die_if_NULL( frame );
  return ( if_packet_type( frame, ETH_DIX ) |
           if_packet_type( frame, ETH_8023_RAW ) |
           if_packet_type( frame, ETH_8023_LLC ) |
           if_packet_type( frame, ETH_8023_SNAP ) );
}
Exemplo n.º 3
0
void
calloc_packet_info( buffer *buf ) {
  die_if_NULL( buf );

  void *user_data = xcalloc( 1, sizeof( packet_info ) );
  assert( user_data != NULL );

  memset( user_data, 0, sizeof( packet_info ) );

  buf->user_data = user_data;
  buf->user_data_free_function = free_packet_info;
}
Exemplo n.º 4
0
uint16_t
fill_ether_padding( buffer *buf ) {
  die_if_NULL( buf );
  size_t padding_length = 0;

  if ( buf->length + ETH_FCS_LENGTH < ETH_MINIMUM_LENGTH ) {
    padding_length = ETH_MINIMUM_LENGTH - buf->length - ETH_FCS_LENGTH;
    debug( "Adding %u octets padding ( original frame length = %u ).", 
           buf->length, padding_length );
    append_back_buffer( buf, padding_length );
  }
  return ( uint16_t ) padding_length;
}
Exemplo n.º 5
0
packet_info
get_packet_info( const buffer *frame ) {
  die_if_NULL( frame );

  packet_info info;

  if ( frame->user_data != NULL ) {
    info = *( packet_info * ) frame->user_data;
  }
  else {
    memset( &info, 0, sizeof( info ) );
  }

  return info;
}
Exemplo n.º 6
0
static bool
if_igmp_type( const buffer *frame, const uint32_t type ) {
  die_if_NULL( frame );
  packet_info packet_info = get_packet_info( frame );
  return ( packet_info.igmp_type == type );
}
Exemplo n.º 7
0
bool
packet_type_icmpv4_echo_request( const buffer *frame ) {
  die_if_NULL( frame );
  return ( if_packet_type( frame, NW_ICMPV4 ) &
           if_icmpv4_type( frame, ICMP_TYPE_ECHOREQ ) );
}
Exemplo n.º 8
0
bool
packet_type_lldp( const buffer *frame ) {
  die_if_NULL( frame );
  return if_packet_type( frame, NW_LLDP );
}
Exemplo n.º 9
0
bool
packet_type_eth_raw( const buffer *frame ) {
  die_if_NULL( frame );
  return if_packet_type( frame, ETH_8023_RAW );
}
Exemplo n.º 10
0
bool
packet_type_eth_dix( const buffer *frame ) {
  die_if_NULL( frame );
  return if_packet_type( frame, ETH_DIX );
}
Exemplo n.º 11
0
static bool
if_arp_opcode( const buffer *frame, const uint32_t opcode ) {
  die_if_NULL( frame );
  packet_info packet_info = get_packet_info( frame );
  return ( packet_info.arp_ar_op == opcode );
}
Exemplo n.º 12
0
bool
packet_type_igmp_v3_membership_report( const buffer *frame ) {
  die_if_NULL( frame );
  return ( if_packet_type( frame, NW_IGMP ) &
           if_igmp_type( frame, IGMP_TYPE_V3_MEMBERSHIP_REPORT ) );
}
Exemplo n.º 13
0
bool
packet_type_ipv6_udp( const buffer *frame ) {
  die_if_NULL( frame );
  return if_packet_type( frame, NW_IPV6 | TP_UDP );
}
Exemplo n.º 14
0
bool
packet_type_ipv4_etherip( const buffer *frame ) {
  die_if_NULL( frame );
  return if_packet_type( frame, NW_IPV4 | TP_ETHERIP );
}
Exemplo n.º 15
0
bool
packet_type_ipv4_tcp( const buffer *frame ) {
  die_if_NULL( frame );
  return if_packet_type( frame, NW_IPV4 | TP_TCP );
}
Exemplo n.º 16
0
bool
packet_type_igmp( const buffer *frame ) {
  die_if_NULL( frame );
  return if_packet_type( frame, NW_IGMP );
}
Exemplo n.º 17
0
bool
packet_type_icmpv4( const buffer *frame ) {
  die_if_NULL( frame );
  return if_packet_type( frame, NW_ICMPV4 );
}
Exemplo n.º 18
0
bool
packet_type_igmp_membership_query( const buffer *frame ) {
  die_if_NULL( frame );
  return ( if_packet_type( frame, NW_IGMP ) &
           if_igmp_type( frame, IGMP_TYPE_MEMBERSHIP_QUERY ) );
}
Exemplo n.º 19
0
bool
packet_type_arp_request( const buffer *frame ) {
  die_if_NULL( frame );
  return ( if_packet_type( frame, NW_ARP ) &
           if_arp_opcode( frame, ARP_OP_REQUEST ) );
}
Exemplo n.º 20
0
bool
packet_type_igmp_v2_leave_group( const buffer *frame ) {
  die_if_NULL( frame );
  return ( if_packet_type( frame, NW_IGMP ) &
           if_igmp_type( frame, IGMP_TYPE_V2_LEAVE_GROUP ) );
}
Exemplo n.º 21
0
bool
packet_type_rarp_reply( const buffer *frame ) {
  die_if_NULL( frame );
  return ( if_packet_type( frame, NW_RARP ) &
           if_arp_opcode( frame, ARP_OP_RREPLY ) );
}
Exemplo n.º 22
0
bool
packet_type_eth_snap( const buffer *frame ) {
  die_if_NULL( frame );
  return if_packet_type( frame, ETH_8023_SNAP );
}
Exemplo n.º 23
0
bool
packet_type_rarp( const buffer *frame ) {
  die_if_NULL( frame );
  return if_packet_type( frame, NW_RARP );
}
Exemplo n.º 24
0
static bool
if_packet_type( const buffer *frame, const uint32_t type ) {
  die_if_NULL( frame );
  packet_info packet_info = get_packet_info( frame );
  return ( ( packet_info.format & type ) == type );
}
Exemplo n.º 25
0
bool
packet_type_icmpv4_dst_unreach( const buffer *frame ) {
  die_if_NULL( frame );
  return ( if_packet_type( frame, NW_ICMPV4 ) &
           if_icmpv4_type( frame, ICMP_TYPE_UNREACH ) );
}
Exemplo n.º 26
0
bool
packet_type_eth_vtag( const buffer *frame ) {
  die_if_NULL( frame );
  return if_packet_type( frame, ETH_8021Q );
}
Exemplo n.º 27
0
bool
packet_type_icmpv4_redirect( const buffer *frame ) {
  die_if_NULL( frame );
  return ( if_packet_type( frame, NW_ICMPV4 ) &
           if_icmpv4_type( frame, ICMP_TYPE_REDIRECT ) );
}
Exemplo n.º 28
0
bool
packet_type_eth_llc( const buffer *frame ) {
  die_if_NULL( frame );
  return if_packet_type( frame, ETH_8023_LLC );
}
Exemplo n.º 29
0
bool
packet_type_ipv6( const buffer *frame ) {
  die_if_NULL( frame );
  return if_packet_type( frame, NW_IPV6 );
}