/** * Initialize the nodes controller. Register callbacks in the backend. */ G_GNUC_COLD void nodes_gui_init(void) { unsigned i; GtkCList *clist; clist = GTK_CLIST(gui_main_window_lookup("clist_nodes")); gtk_clist_column_titles_passive(clist); for (i = 0; i < c_gnet_num; i++) { gtk_clist_set_column_name(clist, i, nodes_gui_column_title(i)); } clist_restore_visibility(clist, PROP_NODES_COL_VISIBLE); clist_restore_widths(clist, PROP_NODES_COL_WIDTHS); widget_add_popup_menu(GTK_WIDGET(clist), nodes_gui_get_popup_menu); hs_node_info_changed = hset_create_any(nid_hash, nid_hash2, nid_equal); hs_node_flags_changed = hset_create_any(nid_hash, nid_hash2, nid_equal); guc_node_add_node_added_listener(nodes_gui_node_added); guc_node_add_node_removed_listener(nodes_gui_node_removed); guc_node_add_node_info_changed_listener(nodes_gui_node_info_changed); guc_node_add_node_flags_changed_listener(nodes_gui_node_flags_changed); main_gui_add_timer(nodes_gui_timer); }
/** * Initialize the nodes controller. Register callbacks in the backend. */ void nodes_gui_init(void) { GtkTreeView *tv; tv = GTK_TREE_VIEW(gui_main_window_lookup( "treeview_nodes")); treeview_nodes = tv; tree_view_restore_widths(tv, PROP_NODES_COL_WIDTHS); tree_view_restore_visibility(tv, PROP_NODES_COL_VISIBLE); tree_view_set_fixed_height_mode(tv, TRUE); nodes_handles = htable_create_any(nid_hash, nid_hash2, nid_equal); ht_node_info_changed = hset_create_any(nid_hash, nid_hash2, nid_equal); ht_node_flags_changed = hset_create_any(nid_hash, nid_hash2, nid_equal); ht_pending_lookups = hset_create_any(nid_hash, nid_hash2, nid_equal); guc_node_add_node_added_listener(nodes_gui_node_added); guc_node_add_node_removed_listener(nodes_gui_node_removed); guc_node_add_node_info_changed_listener(nodes_gui_node_info_changed); guc_node_add_node_flags_changed_listener(nodes_gui_node_flags_changed); widget_add_popup_menu(GTK_WIDGET(tv), nodes_gui_get_popup_menu); gui_signal_connect(tv, "cursor-changed", on_cursor_changed, tv); gui_signal_connect(tv, "leave-notify-event", on_leave_notify, tv); tvm_nodes = tree_view_motion_set_callback(tv, update_tooltip, 400); main_gui_add_timer(nodes_gui_timer); }
static GSList * resolve_hostname(const char *host, enum net_type net) #ifdef HAS_GETADDRINFO { static const struct addrinfo zero_hints; struct addrinfo hints, *ai, *ai0 = NULL; hset_t *hs; GSList *sl_addr; int error; g_assert(host); hints = zero_hints; hints.ai_family = net_type_to_pf(net); error = getaddrinfo(host, NULL, &hints, &ai0); if (error) { g_message("getaddrinfo() failed for \"%s\": %s", host, gai_strerror(error)); return NULL; } sl_addr = NULL; hs = hset_create_any(host_addr_hash_func, NULL, host_addr_eq_func); for (ai = ai0; ai; ai = ai->ai_next) { host_addr_t addr; if (!ai->ai_addr) continue; addr = addrinfo_to_addr(ai); if (is_host_addr(addr) && !hset_contains(hs, &addr)) { host_addr_t *addr_copy; addr_copy = wcopy(&addr, sizeof addr); sl_addr = g_slist_prepend(sl_addr, addr_copy); hset_insert(hs, addr_copy); } } hset_free_null(&hs); if (ai0) freeaddrinfo(ai0); return g_slist_reverse(sl_addr); }
/** * Creates a new UDP TX scheduling layer. * * The layer can be attached to multiple TX layers, which will then share * the same bandwidth limitation. This is given by the "bws" parameter. * * The sockets are dynamically fetched, since the application can disable * them and recreate them depending on dynamic user reconfiguration. * * @param bws the bandwidth scheduler used for output * @param get_socket callback to get the UDP socket to write to * * @return a new scheduler. */ udp_sched_t * udp_sched_make( bsched_bws_t bws, udp_sched_socket_cb_t get_socket) { udp_sched_t *us; unsigned i; WALLOC0(us); us->magic = UDP_SCHED_MAGIC; us->txpool = pool_create("UDP TX descriptors", sizeof(struct udp_tx_desc), udp_tx_desc_alloc, udp_tx_desc_free, NULL); us->get_socket = get_socket; us->bws = bws; udp_sched_update_sockets(us); for (i = 0; i < N_ITEMS(us->lifo); i++) { eslist_init(&us->lifo[i], offsetof(struct udp_tx_desc, lnk)); } eslist_init(&us->tx_released, offsetof(struct udp_tx_desc, lnk)); us->seen = hset_create_any(gnet_host_hash, gnet_host_hash2, gnet_host_equal); us->stacks = hash_list_new(udp_tx_stack_hash, udp_tx_stack_eq); return us; }