Esempio n. 1
0
static buffer *
parse_etherip( const buffer *data ) {
  packet_info *packet_info = data->user_data;
  if ( packet_info->etherip_version != ETHERIP_VERSION ) {
    error( "invalid etherip version 0x%04x.", packet_info->etherip_version );
    return NULL;
  }
  if ( packet_info->etherip_offset == 0 ) {
    debug( "too short etherip message" );
    return NULL;
  }

  buffer *copy = duplicate_buffer( data );
  if ( copy == NULL ) {
    error( "duplicate_buffer failed." );
    return NULL;
  }
  copy->user_data = NULL;
  remove_front_buffer( copy, packet_info->etherip_offset );

  if ( !parse_packet( copy ) ) {
    error( "parse_packet failed." );
    free_buffer( copy );
    return NULL;
  }

  debug( "Receive EtherIP packet." );

  return copy;
}
Esempio n. 2
0
int set_bp(libgdbr_t* g, ut64 address, const char* conditions, enum Breakpoint type) {
	char tmp[255] = {};
	int ret = 0;
	switch (type) {
	case BREAKPOINT:
		ret = snprintf (tmp, sizeof (tmp)-1,
			"%s,%"PFMT64x",1", CMD_BP, address);
		break;
	case HARDWARE_BREAKPOINT:
		ret = snprintf (tmp, sizeof (tmp)-1,
			"%s,%"PFMT64x",1", CMD_HBP, address);
		break;
	case WRITE_WATCHPOINT:
		break;
	case READ_WATCHPOINT:
		break;
	case ACCESS_WATCHPOINT:
		break;
	default:
		break;
	}
	if (ret < 0) return ret;
	ret = send_command (g, tmp);
	if (ret < 0) return ret;

	if (read_packet (g) > 0) {
		parse_packet (g, 0);
		return handle_setbp (g);
	}
	return 0;
}
Esempio n. 3
0
void
parse_message(unsigned char type, char *buf, int size)
{
    char *msgt;
    int i;
    struct iocblk *iocp;
    struct buffer *bp = Pty.inbuff;


    if (size != 0) {
	switch (Pty.state) {
	case PTY_CLOSED:
	case PTY_OPERRONLY:
	    SET_EVENT(EV_UP, EV_UPOPEN, 0, 0);
	    break;
	}
    }

    if (type == TIOCPKT_DATA) {
# ifdef TSR_MEASURE
	devreads++;
	devrbytes += size;
# endif
	if (size == 0) {
	    SET_EVENT(EV_UP, EV_UPCLOSE, 0, 0);
	}
	else {
	    COPY_TO_BUFFER(bp, buf, size);
	    SET_EVENT(EV_UP, EV_UPDATA, 0, 0);
	}
    }
    else {
	parse_packet((int) type);
    }
}
void rgetdir(){
	// prepare packet to be sent //
	send_pack(RGETDIR, command.arguments, sock);

	// receive positive/negative acknowledgement (whether the file exists or not) //
	strncpy(packet_str, "", PACK_SIZE);
	if(recv(sock, packet_str, PACK_SIZE, 0) < 0){
		error("recv");
	}
	
	parse_packet(packet_str, packet);
	if(packet.command_code == INVALID){
		fprintf(stderr, "The specified folder does not exist\n");
		return;
	}
	
	mkdir(command.arguments, S_IRWXU | S_IRWXG | S_IRWXO);
	
	/* send port number for data connection to server */
	send_data_port();
	
	// make socket and accept server's Data Connection (active)//
	makeDataConnection();
	fprintf(stderr, "rgetdir() : data connection accepted\n");
	
	// recieve files //
	receive_rgetdir_files();
	fprintf(stdout, "rgetdir() : files completely received\n");
	fflush(stdout);	
	
	// close the data connection //
	close(request->serverSocket);
	//close(sock_data);
}
Esempio n. 5
0
void rarch_remote_poll(rarch_remote_t *handle)
{
   unsigned user;
   settings_t *settings            = config_get_ptr();
   input_remote_state_t *ol_state  = input_remote_get_state_ptr();
   
   for(user = 0; user < settings->input.max_users; user++)
   {
      if (settings->network_remote_enable_user[user])
      {
#if defined(HAVE_NETWORK_GAMEPAD) && defined(HAVE_NETPLAY)
         char buf[8];
         ssize_t ret;
         fd_set fds;
         struct timeval tmp_tv = {0};

         if (handle->net_fd[user] < 0)
            return;

         FD_ZERO(&fds);
         FD_SET(handle->net_fd[user], &fds);

         ret = recvfrom(handle->net_fd[user], buf,
               sizeof(buf) - 1, 0, NULL, NULL);

         if (ret > 0)
            parse_packet(buf, sizeof(buf), user);
         else
#endif
            ol_state->buttons[user] = 0;
      }
   }
}
Esempio n. 6
0
/* thread reading entries form others babel daemons */
static int
babel_read_protocol (struct thread *thread)
{
    int rc;
    struct interface *ifp = NULL;
    struct sockaddr_in6 sin6;
    struct listnode *linklist_node = NULL;

    assert(babel_routing_process != NULL);
    assert(protocol_socket >= 0);

    rc = babel_recv(protocol_socket,
                    receive_buffer, receive_buffer_size,
                    (struct sockaddr*)&sin6, sizeof(sin6));
    if(rc < 0) {
        if(errno != EAGAIN && errno != EINTR) {
            zlog_err("recv: %s", safe_strerror(errno));
        }
    } else {
        FOR_ALL_INTERFACES(ifp, linklist_node) {
            if(!if_up(ifp))
                continue;
            if(ifp->ifindex == sin6.sin6_scope_id) {
                parse_packet((unsigned char*)&sin6.sin6_addr, ifp,
                             receive_buffer, rc);
                break;
            }
        }
    }

    /* re-add thread */
    babel_routing_process->t_read =
    thread_add_read(master, &babel_read_protocol, NULL, protocol_socket);
    return 0;
}
void receive_multiple_files(int no_files, char **file_list){
	int file_no = 0, buffer_byte = 0, file_byte = 0;
	char ch = ' ';
	FILE *file_ptr;
	
	while(recv(request->serverSocket, packet_str, PACK_SIZE, 0)){
		parse_packet(packet_str, packet);
		strcpy(buffer, packet.buffer);
		while(buffer_byte < BUF_SIZE && buffer_byte < strlen(buffer)){
			ch = buffer[buffer_byte++];
			if(!file_byte++){
				if(ch == '0')
					fprintf(stdout, "receive_multiple_files() : file number %d : %s : File Not Found\n", file_no, file_list[file_no]);
				else{
					file_ptr = fopen(file_list[file_no], "w");
				}
			}
			
			else if(ch == EOF){
				fclose(file_ptr);
					fprintf(stdout, "receive_multiple_files() : file number %d : %s : Downloaded\n", file_no, file_list[file_no]);
				file_byte = 0;
				file_no++;
			}
			else
				fputc((int)ch, file_ptr);
		}
	}
	fflush(stdout);
}
Esempio n. 8
0
static void
test_parse_packet_snap_succeeds() {
  const char filename[] = "./unittests/lib/test_packets/ipx.cap";
  buffer *buffer = store_packet_to_buffer( filename );

  assert_true( parse_packet( buffer ) );

  packet_info *packet_info = buffer->user_data;

  assert_int_equal( packet_info->format, ETH_8023_SNAP );

  u_char macda[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
  u_char macsa[] = { 0x00, 0x19, 0xdb, 0x17, 0xb9, 0x6f };
  assert_memory_equal( packet_info->eth_macda, macda, ETH_ADDRLEN );
  assert_memory_equal( packet_info->eth_macsa, macsa, ETH_ADDRLEN );
  assert_true( packet_info->eth_type < ETH_MTU );

  u_char llc[] = { 0xe0, 0xe0, 0x03 };
  u_char oui[] = { 0xff, 0xff, 0x00 };
  assert_memory_equal( packet_info->snap_llc, llc, SNAP_LLC_LENGTH );
  assert_memory_equal( packet_info->snap_oui, oui, SNAP_OUI_LENGTH );
  assert_int_equal( packet_info->snap_type, 0xb700 );

  uint16_t sample = ntohs( *( uint16_t * ) packet_info->l2_payload );
  assert_int_equal( sample, 0x0400 );

  assert_int_equal( packet_info->l2_payload_length, 0xb2 );

  free_buffer( buffer );
}
Esempio n. 9
0
int main (int argc, char *argv[]){
  pcap_t *handle;
  f = fopen("resultat.csv","w");
  fprintf(f,"Packet number,SEQ,delay\n");
  fclose(f);

  if(argc != 2) {
    printf("Provide a path to a .pcap file:\n%s filename", argv[0]);
    exit(1);
  }

  if((handle = pcap_open_offline(argv[1], errbuff)) != NULL) {
    strcpy(file, argv[1]);

    struct pcap_pkthdr header; // The header that pcap gives us 
    const u_char *packet; // The actual packet 
    int count = 0;

    strcpy(server_ip, determine_server_ip());

    while((packet = pcap_next(handle, &header))) {
      count++;
      parse_packet(packet, count);
    }

    printf("\n\ntotal packets : %d\nlate packets : %d\n\n", count, late_packets); 
  }
  else{
    printf("%s\n", errbuff);
  }

  return 0;
}
Esempio n. 10
0
static void
test_parse_packet_ipv6_succeeds() {
  const char filename[] = "./unittests/lib/test_packets/icmp6_echo_req.cap";
  buffer *buffer = store_packet_to_buffer( filename );

  assert_true( parse_packet( buffer ) );

  packet_info *packet_info = buffer->user_data;

  assert_int_equal( packet_info->ipv6_version, 6 );
  assert_int_equal( packet_info->ipv6_tc, 0 );
  assert_int_equal( packet_info->ipv6_flowlabel, 0 );
  assert_int_equal( packet_info->ipv6_plen, 0x40 );
  assert_int_equal( packet_info->ipv6_nexthdr, 0x3a );
  assert_int_equal( packet_info->ipv6_hoplimit, 0x40 );

  u_char saddr[] = { 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                     0x8e, 0x89, 0xa5, 0xff, 0xfe, 0x16, 0x22, 0x09 };
  u_char daddr[] = { 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                     0x8e, 0x89, 0xa5, 0xff, 0xfe, 0x15, 0x84, 0xcb };
  assert_memory_equal( packet_info->ipv6_saddr, saddr, IPV6_ADDRLEN );
  assert_memory_equal( packet_info->ipv6_daddr, daddr, IPV6_ADDRLEN );

  free_buffer( buffer );
}
Esempio n. 11
0
static void
test_parse_packet_igmp_query_v2_succeeds() {
  const char filename[] = "./unittests/lib/test_packets/igmp_query_v2.cap";
  buffer *buffer = store_packet_to_buffer( filename );

  assert_true( parse_packet( buffer ) );

  packet_info *packet_info = buffer->user_data;

  assert_int_equal( packet_info->format, ETH_IPV4_IGMP );

  u_char macda[] = { 0x01, 0x00, 0x5e, 0x00, 0x00, 0x01 };
  u_char macsa[] = { 0x8c, 0x89, 0xa5, 0x15, 0x84, 0xcb };
  assert_memory_equal( packet_info->eth_macda, macda, ETH_ADDRLEN );
  assert_memory_equal( packet_info->eth_macsa, macsa, ETH_ADDRLEN );

  assert_int_equal( packet_info->l2_payload_length, 32 );

  assert_int_equal( packet_info->igmp_type, IGMP_MEMBERSHIP_QUERY );
  assert_int_equal( packet_info->igmp_code, 100 );
  assert_int_equal( packet_info->igmp_checksum, 0xee9b );
  assert_int_equal( packet_info->igmp_group, 0 );

  assert_true( packet_type_igmp_membership_query( buffer ) );

  free_buffer( buffer );
}
Esempio n. 12
0
static void
test_parse_packet_arp_request_succeeds() {
  const char filename[] = "./unittests/lib/test_packets/arp_req.cap";
  buffer *buffer = store_packet_to_buffer( filename );

  assert_true( parse_packet( buffer ) );
  packet_info *packet_info = buffer->user_data;

  assert_int_equal( packet_info->format, ETH_ARP );

  u_char macda[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
  u_char macsa[] = { 0x8c, 0x89, 0xa5, 0x16, 0x22, 0x09 };
  assert_memory_equal( packet_info->eth_macda, macda, ETH_ADDRLEN );
  assert_memory_equal( packet_info->eth_macsa, macsa, ETH_ADDRLEN );
  assert_int_equal( packet_info->eth_type, ETH_ETHTYPE_ARP );

  assert_int_equal( packet_info->l2_payload_length, 46 );

  assert_int_equal( packet_info->arp_ar_hrd, 0x0001 );
  assert_int_equal( packet_info->arp_ar_pro, 0x0800 );
  assert_int_equal( packet_info->arp_ar_hln, 6 );
  assert_int_equal( packet_info->arp_ar_pln, 4 );
  assert_int_equal( packet_info->arp_ar_op, 1 );
  assert_int_equal( packet_info->arp_spa, 0xc0a8642c );
  assert_memory_equal( packet_info->arp_sha, macsa, ETH_ADDRLEN );
  assert_int_equal( packet_info->arp_tpa, 0xc0a8642b );
  u_char maczero[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
  assert_memory_equal( packet_info->arp_tha, maczero, ETH_ADDRLEN );

  assert_true( packet_type_arp_request( buffer ) );
  assert_false( packet_type_arp_reply( buffer ) );

  free_buffer( buffer );
}
Esempio n. 13
0
void
Comm::handle_comm (struct sockaddr_in &addr, const char *msg, int len)
  throw()
{
  if (len == static_cast<int>(strlen(TOOL_REQUEST_MSG)) &&
      memcmp(msg, TOOL_REQUEST_MSG, TOOL_REQUEST_LEN) == 0) {

    std::string robotName = getRobotName();
    const char *name = robotName.c_str();

    int len = TOOL_ACCEPT_LEN + 3 + strlen(name);
    char *response = (char *) malloc(len);

    memcpy(&response[0], TOOL_ACCEPT_MSG, TOOL_ACCEPT_LEN);
    response[TOOL_ACCEPT_LEN] = ':';
    response[TOOL_ACCEPT_LEN+1] = (char)strlen(name);
    response[TOOL_ACCEPT_LEN+2] = ':';
    memcpy(&response[TOOL_ACCEPT_LEN+3], name, strlen(name));

    struct sockaddr_in r_addr = addr;
    r_addr.sin_port = htons(TOOL_PORT);

    send(&response[0], len, r_addr);
    free(response);

  }else {

    // validate packet format, check packet timestamp, and parse data
    CommPacketHeader packet;
    if (validate_packet(msg, len, packet) && timer.check_packet(packet))
      parse_packet(packet, msg + sizeof(packet), len - sizeof(packet));

  }

}
Esempio n. 14
0
int reply_info_parse(sldns_buffer* pkt, struct alloc_cache* alloc,
        struct query_info* qinf, struct reply_info** rep, 
	struct regional* region, struct edns_data* edns)
{
	/* use scratch pad region-allocator during parsing. */
	struct msg_parse* msg;
	int ret;
	
	qinf->qname = NULL;
	*rep = NULL;
	if(!(msg = regional_alloc(region, sizeof(*msg)))) {
		return LDNS_RCODE_SERVFAIL;
	}
	memset(msg, 0, sizeof(*msg));
	
	sldns_buffer_set_position(pkt, 0);
	if((ret = parse_packet(pkt, msg, region)) != 0) {
		return ret;
	}
	if((ret = parse_extract_edns(msg, edns)) != 0)
		return ret;

	/* parse OK, allocate return structures */
	/* this also performs dname decompression */
	if(!parse_create_msg(pkt, msg, alloc, qinf, rep, NULL)) {
		query_info_clear(qinf);
		reply_info_parsedelete(*rep, alloc);
		*rep = NULL;
		return LDNS_RCODE_SERVFAIL;
	}
	return 0;
}
Esempio n. 15
0
int
load_from_file(const char* file)
{
    // PCAP file handler
    pcap_t *handle;
    // Error text (in case of file open error)
    char errbuf[PCAP_ERRBUF_SIZE];
    // The header that pcap gives us
    struct pcap_pkthdr header;
    // The actual packet
    const u_char *packet;

    // Open PCAP file
    if ((handle = pcap_open_offline(file, errbuf)) == NULL) {
        fprintf(stderr, "Couldn't open pcap file %s: %s\n", file, errbuf);
        return 1;
    }

    // Get datalink to parse packages correctly
    linktype = pcap_datalink(handle);

    // Loop through packages
    while ((packet = pcap_next(handle, &header))) {
        // Parse package
        parse_packet((u_char*)"Offline", &header, packet);
    }
    // Close PCAP file
    pcap_close(handle);
    return 0;
}
void get(){
	// Send command //
	send_pack(GET, command.arguments, sock);

	// receive positive/negative acknowledgement (whether the file exists or not) //
	if(recv(sock, packet_str, PACK_SIZE, 0) < 0){
		error("recv");
	}
	
	parse_packet(packet_str, packet);
	if(!(int)packet.command_code){
		fprintf(stderr, "The specified does not exist\n");
		return;
	}
	
	/* send port number for data connection to server */
	send_data_port();
	
	// make socket and accept server's Data Connection (active)//
	makeDataConnection();
	fprintf(stderr, "get() : data connection accepted\n");
	
	// recieve file //
	receive_file();

	fprintf(stdout, "get() : complete file received\n");
	fflush(stdout);	
	// close the data connection //
	close(request->serverSocket);
}
Esempio n. 17
0
/****************************************************************************
tdb traversal fn to find a matching 137 packet
  **************************************************************************/
static int traverse_match(TDB_CONTEXT *ttdb, TDB_DATA kbuf, TDB_DATA dbuf, void *state)
{
	struct unexpected_key key;
	struct packet_struct *p;

	if (kbuf.dsize != sizeof(key)) {
		return 0;
	}

	memcpy(&key, kbuf.dptr, sizeof(key));

	if (key.packet_type != match_type) return 0;

	p = parse_packet(dbuf.dptr, dbuf.dsize, match_type);

	if ((match_type == NMB_PACKET && 
	     p->packet.nmb.header.name_trn_id == match_id) ||
	    (match_type == DGRAM_PACKET && 
	     match_mailslot_name(p, match_name))) {
		matched_packet = p;
		return -1;
	}

	free_packet(p);

	return 0;
}
Esempio n. 18
0
void pcap_callback(uint8_t *args, const struct pcap_pkthdr *header, const uint8_t *packet)
{
	struct pkt	p;
	int	rc;

	bzero(&p, sizeof(p));

	p.raw_packet = (uint8_t *)packet;

	p.pos = (uint8_t *)packet;
	p.len = header->caplen;

	p.ifc = (struct iface_config *) args;
	p.pcap_header = header;

	rc = parse_packet(&p);

	if (rc < 0)
		return;

	if (p.arp) {
		if (!check_arp(&p))
		process_arp(&p);
	} else if (p.ns) {
		if (!check_ns(&p))
			process_ns(&p);
	} else if (p.na) {
		if (!check_na(&p))
			process_na(&p);
	}

}
Esempio n. 19
0
static bool obs_x264_encode(void *data, struct encoder_frame *frame,
		struct encoder_packet *packet, bool *received_packet)
{
	struct obs_x264 *obsx264 = data;
	x264_nal_t      *nals;
	int             nal_count;
	int             ret;
	x264_picture_t  pic, pic_out;

	if (!frame || !packet || !received_packet)
		return false;

	if (frame)
		init_pic_data(obsx264, &pic, frame);

	ret = x264_encoder_encode(obsx264->context, &nals, &nal_count,
			(frame ? &pic : NULL), &pic_out);
	if (ret < 0) {
		warn("encode failed");
		return false;
	}

	*received_packet = (nal_count != 0);
	parse_packet(obsx264, packet, nals, nal_count, &pic_out);

	return true;
}
Esempio n. 20
0
/* Parse the data stream for packets, and send out replies. */
static void parse_data(Octstr *in, Octstr *out) {
	int stx, etx;
	Octstr *packet;

	for (;;) {
		/* Look for start of packet.  Delete everything up to the start
		 * marker.  (CIMD2 section 3.1 says we can ignore any data
		 * transmitted between packets.) */
		stx = octstr_search_char(in, STX, 0);
		if (stx < 0)
			octstr_delete(in, 0, octstr_len(in));
		else if (stx > 0)
			octstr_delete(in, 0, stx);

		etx = octstr_search_char(in, ETX, 0);
		if (etx < 0)
			return;  /* Incomplete packet; wait for more data. */

		/* Copy the data between stx and etx */
		packet = octstr_copy(in, 1, etx - 1);
		/* Then cut the packet (including stx and etx) from inbuffer */
		octstr_delete(in, 0, etx + 1);

		parse_packet(packet, out);

		octstr_destroy(packet);
	}
}
Esempio n. 21
0
OFDPE
handle_received_frame( const switch_port *port, buffer *frame ) {
    assert( port != NULL );
    assert( frame != NULL );

    debug( "Handling received frame ( port_no = %u, frame = %p, user_data = %p ).", port->port_no, frame, frame->user_data );

    if ( frame->user_data == NULL ) {
        bool ret = parse_packet( frame );
        if ( !ret ) {
            warn( "Failed to parse a received frame ( port_no = %u, frame = %p ).", port->port_no, frame );
            return OFDPE_FAILED;
        }
    }

    assert( frame->user_data != NULL );
    ( ( packet_info * ) frame->user_data )->eth_in_port = port->port_no;
    ( ( packet_info * ) frame->user_data )->eth_in_phy_port = port->port_no;

    if ( !trylock_pipeline() ) {
        return ERROR_LOCK;
    }

    process_received_frame( port, frame );

    if ( !unlock_pipeline() ) {
        return ERROR_UNLOCK;
    }

    return OFDPE_SUCCESS;
}
Esempio n. 22
0
int remove_bp(libgdbr_t* g, uint64_t address, enum Breakpoint type) {
	char tmp[255] = {};
	int ret = 0;
	switch (type) {
		case BREAKPOINT:
			ret = snprintf (tmp, 255, "%s,%lx,1", CMD_RBP, address);
			break;
		case HARDWARE_BREAKPOINT:
			ret = snprintf (tmp, 255, "%s,%lx,1", CMD_RHBP, address);
			break;
		case WRITE_WATCHPOINT:
			break;
		case READ_WATCHPOINT:
			break;
		case ACCESS_WATCHPOINT:
			break;
		default:
			break;
	}
	if (ret < 0) return ret;
	ret = send_command (g, tmp);
	if (ret < 0) return ret;

	if (read_packet (g) > 0) {
		parse_packet (g, 0);
		return handle_removebp (g);
	}
	return 0;
}
Esempio n. 23
0
int gdbr_read_registers(libgdbr_t* g) {
	send_command (g, CMD_READREGS);
	if ( read_packet (g) > 0) {
		parse_packet (g, 0);
		return handle_g (g);
	}
	return -1;
}
Esempio n. 24
0
static void
test_parse_packet_fails_if_data_is_NULL() {
  buffer *null_data = alloc_buffer( );

  expect_assert_failure( parse_packet( null_data ) );

  free_buffer( null_data );
}
Esempio n. 25
0
static void
test_parse_packet_ether_ipv4_succeeds() {
  buffer *ipv4_buffer = setup_dummy_ether_ipv4_packet( );

  assert_int_equal( parse_packet( ipv4_buffer ), true );

  free_packet( ipv4_buffer );
}
Esempio n. 26
0
static VALUE
packet_in_alloc( VALUE klass ) {
  rb_packet_in *_packet_in = xmalloc( sizeof( rb_packet_in ) );
  memset( &_packet_in->packet_in, 0, sizeof( packet_in ) );
  _packet_in->data = alloc_buffer_with_length( 1 );
  parse_packet( _packet_in->data );
  _packet_in->packet_in.data = _packet_in->data;
  return Data_Wrap_Struct( klass, 0, packet_in_free, _packet_in );
}
Esempio n. 27
0
static void parse_header_block(indexer_dv_context *This, unsigned char *target)
{
	int i;
	for (i = 3; i < 80; i += 5) {
		if (target[i] != 0xff) {
			parse_packet(This, target + i);
		}
	}
}
Esempio n. 28
0
void
test_parse_ether_fails_if_version_is_no_ipv4() {
  buffer *ip_version = setup_dummy_ether_ipv4_packet( );
  ( ( ipv4_header_t * ) ( ( char * ) ( ip_version->data ) + sizeof( ether_header_t ) ) )->version = 6;

  assert_int_equal( parse_packet( ip_version ), false );

  free_packet( ip_version );
}
Esempio n. 29
0
static void
test_parse_packet_fails_if_arp_hw_type_is_no_ethernet_type() {
  buffer *arp_hw_type = setup_dummy_ether_arp_packet( );
  ( ( arp_header_t * ) ( ( char * ) ( arp_hw_type->data ) + sizeof( ether_header_t ) ) )->ar_hrd = ARPHRD_ETHER;

  assert_int_equal( parse_packet( arp_hw_type ), false );

  free_packet( arp_hw_type );
}
Esempio n. 30
0
static void
test_parse_packet_fails_if_packet_size_is_short_ethernet_size() {
  buffer *arp_short_ethernet_size = setup_dummy_ether_arp_packet( );
  arp_short_ethernet_size->length = sizeof( ether_header_t ) - ETH_ADDRLEN;

  assert_int_equal( parse_packet( arp_short_ethernet_size ), false );

  free_packet( arp_short_ethernet_size );
}