Esempio n. 1
0
File: leak.c Progetto: s7ephen/leak
gboolean packet_received(GtkWidget *leak) {
	int i;
	char *buffer;
	struct tcphdr *tcp_hdr;
	struct udphdr *udp_hdr;
	struct ip *ip_hdr;
	int linkoff=14;


	buffer = (u_char *)pcap_next(pcap_d,&h);
	packetcount++;

	ip_hdr = (struct ip *)(buffer + linkoff);
	
	if (ip_hdr->ip_p == IPPROTO_TCP) {
		tcp_hdr=(struct tcphdr*)(((char*)ip_hdr)+(4*ip_hdr->ip_hl));

		switch ((tcp_hdr->th_flags)) {	

			case TH_ACK:		
				update_port(leak, ntohs(tcp_hdr->th_dport), 0, 255, 0);
				if (sound_onoff) {
					tone(ntohs(tcp_hdr->th_dport), 4000, 60);
				}
				break;

			case TH_SYN:
				update_port(leak, ntohs(tcp_hdr->th_dport), 255, 255, 0); if (sound_onoff) {
					tone(ntohs(tcp_hdr->th_dport), 4000, 60);
				}
				break;

			case TH_FIN:
				update_port(leak, ntohs(tcp_hdr->th_dport), 255, 0, 0);
				if (sound_onoff) {
					tone(ntohs(tcp_hdr->th_dport), 4000, 60);
				}
				break;

			default:
				break;

		}	
  	} else if (ip_hdr->ip_p == IPPROTO_UDP) {
		udp_hdr=(struct udphdr*)(((char*)ip_hdr)+(4*ip_hdr->ip_hl));

		update_port(leak, ntohs(udp_hdr->uh_dport), 0, 0, 255);
		if (sound_onoff) {
			tone(ntohs(udp_hdr->uh_dport), 4000, 60);
		}
	}
	
	
	return TRUE;
}
Esempio n. 2
0
static void
port_status_updated( void *user_data, const topology_port_status *status ) {
  assert( user_data != NULL );
  assert( status != NULL );

  broadcast_helper *broadcast_helper = user_data;

  debug( "Port status updated: dpid:%#" PRIx64 ", port:%u, %s, %s",
         status->dpid, status->port_no,
         ( status->status == TD_PORT_UP ? "up" : "down" ),
         ( status->external == TD_PORT_EXTERNAL ? "external" : "internal or inactive" ) );

  if ( status->port_no > OFPP_MAX && status->port_no != OFPP_LOCAL ) {
    warn( "Ignore this update ( port = %u )", status->port_no );
    return;
  }

  port_info *p = lookup_port( broadcast_helper->switches, status->dpid, status->port_no );

  if ( status->status == TD_PORT_UP ) {
    if ( p != NULL ) {
      update_port( p, status->external );
      return;
    }
    add_port( &broadcast_helper->switches, status->dpid, status->port_no, status->external );
  }
  else {
    if ( p == NULL ) {
      debug( "Ignore this update (not found nor already deleted)" );
      return;
    }
    delete_port( &broadcast_helper->switches, p );
  }
}
Esempio n. 3
0
void m6510_device::device_reset()
{
	m6502_device::device_reset();
	dir = 0x00;
	port = 0x00;
	drive = 0x00;
	update_port();
}
Esempio n. 4
0
void
add_port( list_element **switches, uint64_t dpid, uint16_t port_no, uint8_t external ) {
  assert( port_no != 0 );

  info( "Adding a port: dpid = %#" PRIx64 ", port = %u", dpid, port_no );

  // lookup switch
  switch_info *sw = lookup_switch( *switches, dpid );
  if ( sw == NULL ) {
    sw = allocate_switch( dpid );
    append_to_tail( switches, sw );
  }

  port_info *new_port = allocate_port( dpid, port_no );
  update_port( new_port, external );
  append_to_tail( &sw->ports, new_port );
}
Esempio n. 5
0
static void
port_status_updated( void *user_data, const topology_port_status *status ) {
  assert( user_data != NULL );
  assert( status != NULL );

  sliceable_switch *sliceable_switch = user_data;
  if ( sliceable_switch->second_stage_down == false ) {
    return;
  }

  debug( "Port status updated: dpid:%#" PRIx64 ", port:%u(%s), %s, %s",
         status->dpid, status->port_no, status->name,
         ( status->status == TD_PORT_UP ? "up" : "down" ),
         ( status->external == TD_PORT_EXTERNAL ? "external" : "internal or inactive" ) );

  if ( status->port_no > OFPP_MAX && status->port_no != OFPP_LOCAL ) {
    warn( "Ignore this update ( port = %u )", status->port_no );
    return;
  }

  port_info *p = lookup_port( sliceable_switch->switches, status->dpid, status->port_no );

  delete_fdb_entries( sliceable_switch->fdb, status->dpid, status->port_no );

  if ( status->status == TD_PORT_UP ) {
    if ( p != NULL ) {
      update_port( p, status->external );
      return;
    }
    add_port( &sliceable_switch->switches, status->dpid, status->port_no, status->name, status->external );
  }
  else {
    if ( p == NULL ) {
      debug( "Ignore this update (not found nor already deleted)" );
      return;
    }
    delete_port( &sliceable_switch->switches, p );
    struct ofp_match match;
    memset( &match, 0, sizeof( struct ofp_match ) );
    match.wildcards = OFPFW_ALL;
    match.wildcards &= ~OFPFW_IN_PORT;
    match.in_port = status->port_no;
    teardown_path_by_match( match );
  }
}
Esempio n. 6
0
static void
_handle_port_mod( uint32_t transaction_id, uint32_t port_no, uint8_t hw_addr[],
                  uint32_t config, uint32_t mask, uint32_t advertise, void *user_data ) {
  UNUSED( hw_addr );
  UNUSED( advertise );
  UNUSED( user_data );
  
  /*
   * the update_port_config() performs a port lookup.
   */
  OFDPE ret = update_port( port_no, config, mask );
  if ( ret != OFDPE_SUCCESS ) {
    uint16_t type = OFPET_PORT_MOD_FAILED;
    uint16_t code = OFPPMFC_EPERM;
    get_ofp_error( ret, &type, &code );
    send_error_message( transaction_id, type, code );
  }
}
Esempio n. 7
0
static int	test_arg(t_env *e, char **av)
{
	int		i;

	i = -1;
	if (ft_strequ(av[0], "-p"))
		i = update_port(e, av);
	else if (ft_strequ(av[0], "-x"))
		i = update_width(e, av);
	else if (ft_strequ(av[0], "-y"))
		i = update_height(e, av);
	else if (ft_strequ(av[0], "-n"))
		i = update_teams(e, av);
	else if (ft_strequ(av[0], "-c"))
		i = update_nb(e, av);
	else if (ft_strequ(av[0], "-t"))
		i = update_time(e, av);
	else
		usage();
	return (i);
}
Esempio n. 8
0
static
void update_ports(alsa_seqmidi_t *self)
{
	snd_seq_addr_t addr;
	snd_seq_port_info_t *info;
	int size;

	snd_seq_port_info_alloca(&info);

	while ((size = jack_ringbuffer_read(self->port_add, (char*)&addr, sizeof(addr)))) {

		int err;

		assert (size == sizeof(addr));
		assert (addr.client != self->client_id);
		if ((err=snd_seq_get_any_port_info(self->seq, addr.client, addr.port, info))>=0) {
			update_port(self, addr, info);
		} else {
			//port_setdead(self->stream[PORT_INPUT].ports, addr);
			//port_setdead(self->stream[PORT_OUTPUT].ports, addr);
		}
	}
}
Esempio n. 9
0
static
void add_existing_ports(alsa_seqmidi_t *self)
{
	snd_seq_addr_t addr;
	snd_seq_client_info_t *client_info;
	snd_seq_port_info_t *port_info;

	snd_seq_client_info_alloca(&client_info);
	snd_seq_port_info_alloca(&port_info);
	snd_seq_client_info_set_client(client_info, -1);
	while (snd_seq_query_next_client(self->seq, client_info) >= 0)
	{
		addr.client = snd_seq_client_info_get_client(client_info);
		if (addr.client == SND_SEQ_CLIENT_SYSTEM || addr.client == self->client_id)
			continue;
		snd_seq_port_info_set_client(port_info, addr.client);
		snd_seq_port_info_set_port(port_info, -1);
		while (snd_seq_query_next_port(self->seq, port_info) >= 0)
		{
			addr.port = snd_seq_port_info_get_port(port_info);
			update_port(self, addr, port_info);
		}
	}
}
Esempio n. 10
0
void m6510_device::dir_w(uint8_t data)
{
	dir = data;
	update_port();
}
Esempio n. 11
0
void m6510_device::port_w(uint8_t data)
{
	port = data;
	update_port();
}