コード例 #1
0
ファイル: network.cpp プロジェクト: Devniz/Wififriend
void								wififriend_scan_network(GtkWidget* Widget, gpointer Data)
{
	DWORD							Error = ERROR_SUCCESS;
	PWLAN_AVAILABLE_NETWORK_LIST	Network = NULL;
	t_wifi							St;
	int								I;
	GtkWidget						*WinScan = NULL;
	GtkWidget						*ListOfWifi = NULL;

	I = 1;
	St = wififriend_create_handle();
	St = wififriend_retrieve_config(St);
	if((WlanGetAvailableNetworkList(St.MyHandle, &St.MyGuid, 0x00000001, NULL, &Network)) != ERROR_SUCCESS)
		error_scan(0);
	else
	{
		WinScan = create_window(236, 27, "Wifi scan");
		ListOfWifi = gtk_combo_box_new_text();
		while(I != Network->dwNumberOfItems)
		{
			gtk_combo_box_prepend_text(GTK_COMBO_BOX(ListOfWifi), (const gchar *)Network->Network[I].dot11Ssid.ucSSID);
			I++;
		}
		gtk_combo_box_set_active(GTK_COMBO_BOX(ListOfWifi), 0);
		gtk_container_add(GTK_CONTAINER(WinScan), ListOfWifi);
		g_signal_connect(G_OBJECT(ListOfWifi), "changed", G_CALLBACK(wififriend_connect_to_unsecure_network), (gpointer)ListOfWifi);
		display_interface(WinScan);
		WlanCloseHandle(St.MyHandle, NULL);
	}
}
コード例 #2
0
ファイル: sr_ip.c プロジェクト: ZubairNabi/bir
void ip_look_up_reply(byte* ip_packet, struct ip* ip_header, interface_t* intf) {
   printf(" ** ip_lookup_reply(..) called \n");
   // get ptr to global router instance
   struct sr_router* subsystem = (struct sr_router*)sr_get_subsystem(get_sr());
   // get dst ip object
   addr_ip_t dst_ip;
   memcpy(&dst_ip, &ip_header->ip_dst, 4);
   // look up in routing table
   route_info_t route_info = rrtable_find_route(subsystem->rtable, dst_ip);
   if(route_info.intf == NULL) {
      printf(" ** ip_lookup_reply(..)  Error! No route found \n");
   } else {
   // display output interface
   printf(" ** ip_lookup_reply(..) output interface for ip: %s\n", quick_ip_to_string(dst_ip));
   display_interface(route_info.intf);
      // check if destination same as ip of the source interface and packet didn't originate from one of my interfaces
   if(strcmp(route_info.intf->name, intf->name) == 0 && check_packet_source(ip_header->ip_src, subsystem) == FALSE) {
      printf(" ** make_ip_packet_reply(..) error! destination interface same as source \n");
     // send icmp destination host unreachable
     uint8_t code = ICMP_TYPE_CODE_DST_UNREACH_HOST;
     // reverse order
     ip_header->ip_len = ntohs((ip_header->ip_len));
     ip_header->ip_off = ntohs((ip_header->ip_off));
     ip_header->ip_id = ntohs((ip_header->ip_id));
     ip_header->ip_sum = ntohs((ip_header->ip_sum));
     uint16_t packet_len = ip_header->ip_len;
     icmp_type_dst_unreach_send(&code, ip_packet, &packet_len, ip_header);
   } else {
      // check if ttl expired
      if(ip_header->ip_ttl == 1) {
         printf(" ** ip_lookup_reply(..) ttl expired, sending ICMP ttl error message \n");
         // reverse order
         ip_header->ip_len = ntohs((ip_header->ip_len));
         ip_header->ip_off = ntohs((ip_header->ip_off));
         ip_header->ip_id = ntohs((ip_header->ip_id));
         ip_header->ip_sum = ntohs((ip_header->ip_sum));
         uint8_t code = ICMP_TYPE_CODE_TTL_TRANSIT;
         uint16_t len = ip_header->ip_len;
         icmp_type_ttl_send(&code, ip_packet, &len, ip_header);
      } else {
         printf(" ** ip_lookup_reply(..) decrementing ttl \n");
         // create new ip header
         struct ip* ip_header_ttl = (struct ip*) malloc_or_die(ip_header->ip_hl * 4);
         memcpy(ip_header_ttl, ip_header, ip_header->ip_hl * 4);
         // decrement ttl
         ip_header_ttl->ip_ttl = ip_header_ttl->ip_ttl - 1;
         // generate checksum
         ip_header_ttl->ip_sum = 0;
         ip_header_ttl->ip_sum = htons(htons(inet_chksum((void*)ip_header_ttl, ip_header_ttl->ip_hl * 4)));
         // get payload
         uint16_t payload_len = ntohs(ip_header_ttl->ip_len) - (ip_header_ttl->ip_hl * 4);
         printf(" ** ip_lookup_reply(..) Payload size %u bytes \n", payload_len);
         memcpy(ip_packet, ip_header_ttl, ip_header_ttl->ip_hl * 4);
         // make new ip packet
         send_ip_packet(ip_packet, ip_header_ttl, route_info);
      }
   }
   }
}
コード例 #3
0
ファイル: show.c プロジェクト: AngieB/devops_quiz
/**
 * Callback for the next function to display a new neighbor.
 */
static void
watchcb(lldpctl_conn_t *conn,
    lldpctl_change_t type,
    lldpctl_atom_t *interface,
    lldpctl_atom_t *neighbor,
    void *data)
{
	struct watcharg *wa = data;
	struct cmd_env *env = wa->env;
	struct writer *w = wa->w;
	const char *interfaces = cmdenv_get(env, "ports");
	const char *proto_str;
	int protocol = LLDPD_MODE_MAX;

	if (interfaces && !contains(interfaces, lldpctl_atom_get_str(interface,
		    lldpctl_k_interface_name)))
		return;

	/* user might have specified protocol to filter display results */
	proto_str = cmdenv_get(env, "protocol");

	if (proto_str) {
		log_debug("display", "filter protocol: %s ", proto_str);

		protocol = 0;	/* unsupported */
		for (lldpctl_map_t *protocol_map =
			 lldpctl_key_get_map(lldpctl_k_port_protocol);
		     protocol_map->string;
		     protocol_map++) {
			if (!strcasecmp(proto_str, protocol_map->string)) {
				protocol = protocol_map->value;
				break;
			}
		}
	}

	switch (type) {
	case lldpctl_c_deleted:
		tag_start(w, "lldp-deleted", "LLDP neighbor deleted");
		break;
	case lldpctl_c_updated:
		tag_start(w, "lldp-updated", "LLDP neighbor updated");
		break;
	case lldpctl_c_added:
		tag_start(w, "lldp-added", "LLDP neighbor added");
		break;
	default: return;
	}
	display_interface(conn, w, 1, interface, neighbor,
	    cmdenv_get(env, "summary")?DISPLAY_BRIEF:
	    cmdenv_get(env, "detailed")?DISPLAY_DETAILS:
	    DISPLAY_NORMAL, protocol);
	tag_end(w);
}
コード例 #4
0
ファイル: game.c プロジェクト: Antonito/Tekdoom
t_bunny_response	main_game_loop(t_data *data)
{
  display_interface(data);
  if (data->chat_toggle)
    {
      display_cursor(data);
      ++data->cursor_toggle;
    }
  if (++data->count >= MAX_COUNT)
    data->count = 0;
  if (data->player->knife.is_selected || !(data->count % 4))
    data->event.bits.shot = play_sound(data);
  if (!((data->count + 2) % 4) && data->player->rifle.is_selected &&
      data->event.bits.shoting)
    data->event.bits.shot = ((data->count + 2) % 4) || can_shot(data);
  return (GO_ON);
}
コード例 #5
0
ファイル: network.cpp プロジェクト: Devniz/Wififriend
void								wififriend_display_wifi_params(GtkWidget* Widget, gpointer Data)
{
	int								I = 0;
	PWLAN_INTERFACE_INFO_LIST		InterfaceList = NULL;
	t_wifi							St;
	GtkWidget						*Win = NULL;
	GtkWidget						*Vbox;
	GtkWidget						*NbInterface = NULL;
	GtkWidget						*NbInterfaceResult = NULL;
	GtkWidget						*Guid = NULL;
	GtkWidget						*GuidResult = NULL;
	GtkWidget						*State = NULL;
	GtkWidget						*StateResult = NULL;
	GtkWidget						*Description = NULL;
	GtkWidget						*DescriptionResult = NULL;
	gchar							*String = NULL;

	St = wififriend_create_handle();
	St = wififriend_retrieve_config(St);
	Win = create_window(300, 180, "Configuration Wifi");
	Vbox = gtk_vbox_new(FALSE, 0);
	if ((WlanEnumInterfaces(St.MyHandle, NULL, &InterfaceList)) != ERROR_SUCCESS)
		error_interface_wifi(0);
	else
	{
		NbInterface = gtk_label_new("- Nombre d'interface Wifi trouvee: ");
		gtk_box_pack_start(GTK_BOX(Vbox), NbInterface, FALSE, FALSE, 0);
		String = g_strdup_printf ("%d", InterfaceList->dwNumberOfItems);
		NbInterfaceResult = gtk_label_new(String);
		gtk_box_pack_start(GTK_BOX(Vbox), NbInterfaceResult, FALSE, FALSE, 2);
		Guid = gtk_label_new("- GUID de votre interface Wifi: ");
		gtk_box_pack_start(GTK_BOX(Vbox), Guid, FALSE, FALSE, 5);
		String = g_strdup_printf ("%d", InterfaceList->InterfaceInfo->InterfaceGuid);
		GuidResult = gtk_label_new(String);
		gtk_box_pack_start(GTK_BOX(Vbox), GuidResult, FALSE, FALSE, 2);
		State = gtk_label_new("- Etat de l'interface: ");
		gtk_box_pack_start(GTK_BOX(Vbox), State, FALSE, FALSE, 5);
		String = g_strdup_printf ("%d", InterfaceList->InterfaceInfo->isState);
		StateResult = gtk_label_new(String);
		gtk_box_pack_start(GTK_BOX(Vbox), StateResult, FALSE, FALSE, 2);
		gtk_container_add(GTK_CONTAINER(Win), Vbox);
		display_interface(Win);
		WlanCloseHandle(St.MyHandle, NULL);
	}
}
コード例 #6
0
ファイル: sr_ip.c プロジェクト: ZubairNabi/bir
void ip_look_up(byte* ip_packet, struct ip* ip_header) {
   printf(" ** ip_lookup(..) called \n");
   // get ptr to global router instance
   struct sr_router* subsystem = (struct sr_router*)sr_get_subsystem(get_sr());
   // get dst ip object
   addr_ip_t dst_ip;
   memcpy(&dst_ip, &ip_header->ip_dst, 4);
   // look up in routing table
   route_info_t route_info = rrtable_find_route(subsystem->rtable, dst_ip);
   if(route_info.intf == NULL) {
      printf(" ** ip_lookup(..) Error! No route found \n");
   } else {
   // display output interface
   printf(" ** ip_lookup(..) output interface for ip: %s\n", quick_ip_to_string(dst_ip));
   display_interface(route_info.intf);
   // set src ip as the ip of the output interface
   memcpy(&ip_header->ip_src, &route_info.intf->ip, 4);
   memcpy(ip_packet, ip_header, ip_header->ip_hl);
   // check if ttl expired
   if(ip_header->ip_ttl == 1) {
      printf(" ** ip_lookup(..) ttl expired, sending ICMP ttl error message \n");
      uint8_t code = ICMP_TYPE_CODE_TTL_TRANSIT;
      uint16_t len = ntohs(ip_header->ip_len);
      icmp_type_ttl_send(&code, ip_packet, &len, ip_header);
   } else {
      printf(" ** ip_lookup(..) decrementing ttl \n");
      // create new ip header
      struct ip* ip_header_ttl = (struct ip*) malloc_or_die(ip_header->ip_hl * 4);
      memcpy(ip_header_ttl, ip_header, ip_header->ip_hl * 4);
      // decrement ttl
      ip_header_ttl->ip_ttl = ip_header_ttl->ip_ttl - 1;
      // generate checksum
      ip_header_ttl->ip_sum = 0;
      ip_header_ttl->ip_sum = htons(htons(inet_chksum((void*)ip_header_ttl, ip_header_ttl->ip_hl * 4)));
      // get payload
      uint16_t payload_len = ntohs(ip_header_ttl->ip_len) - (ip_header_ttl->ip_hl * 4);
      printf(" ** ip_lookup(..) Payload size %u bytes \n", payload_len);
      memcpy(ip_packet, ip_header_ttl, ip_header_ttl->ip_hl * 4);
      // make new ip packet
      send_ip_packet(ip_packet, ip_header_ttl, route_info);

   }
   }
}
コード例 #7
0
ファイル: network.cpp プロジェクト: Devniz/Wififriend
void			wififriend_extract_profil(void)
{
	GtkWidget	*Win = NULL;
	GtkWidget	*Vbox = NULL;
	GtkWidget	*ProfilLabel = NULL;
	GtkWidget	*ProfilEntry = NULL;
	GtkWidget	*Button = NULL;

	Win = create_window(260, 100, "Extraire votre profile Wifi");
	Vbox = gtk_vbox_new(FALSE, 0);
	ProfilLabel = gtk_label_new("Nom de votre reseau Wifi");
	gtk_box_pack_start(GTK_BOX(Vbox), ProfilLabel, FALSE, FALSE, 5);
	ProfilEntry = gtk_entry_new();
	gtk_entry_set_max_length(GTK_ENTRY(ProfilEntry), 15);
	gtk_box_pack_start(GTK_BOX(Vbox), ProfilEntry, FALSE, FALSE, 15);
	Button = gtk_button_new_with_label("Extraire");
	gtk_container_add(GTK_CONTAINER(Vbox), Button);
	g_signal_connect(G_OBJECT(Button), "clicked", G_CALLBACK(wififriend_extract_next), (gpointer)ProfilEntry);
	gtk_container_add(GTK_CONTAINER(Win), Vbox);
	display_interface(Win);
}