Ejemplo n.º 1
0
/**
 * repad_net_free - Do a free in Repa net module structures
 *
 * @param signo		The signal to send to threads
 * @return			<0 for errors
 */
int repad_net_free(int signo) {
	/* Destroy pc_prod_cons packets receiver */
	pc_destroy(repad_attr.pc_receive_packets);
	repad_attr.pc_receive_packets = NULL;

	/* Destroy list of all ifaces */
	dll_destroy_all(repad_attr.list_all_ifaces);
	repad_attr.list_all_ifaces = NULL;

	/* Delete packets list */
	dll_destroy_all(repad_attr.list_pkt_without_match);
	repad_attr.list_pkt_without_match = NULL;

	/* Delete hashmap memory message */
	hmap_destroy(repad_attr.hm_memory_message);
	repad_attr.hm_memory_message = NULL;

	/* Stop Raw socket module */
	if (repad_attr.bl_raw_socket_enable) {
		repad_net_free_raw_socket(signo);
	}

	/* Stop UDP socket module */
	if (repad_attr.bl_udp_socket_enable) {
		repad_net_free_udp_socket(signo);
	}

	/* Stop Overlay module */
	if (repad_attr.bl_overlay_enable) {
		repad_net_free_overlay(signo);
	}

	return 0;
}
Ejemplo n.º 2
0
static PyObject* getNodesInNetwork(PyObject* self, PyObject* args) {
	PyObject *pylist = NULL;
	repa_sock_t sock;
	int i;
	struct dllist *list = NULL;
	struct dll_node *aux = NULL;

	if (PyArg_ParseTuple(args, "(ii)", &sock.sock_send, &sock.sock_recv)) {
		dll_create(list); // Create a linkedlist

		// Get the list of nodes in network in a linkedlist and parse to python's list
		if (repa_get_nodes_in_network(sock, list) >= 0) {
			// Create a list in python with the same size of linkedlist
			pylist = PyTuple_New(list->num_elements);

			// Put all the objects in the linkedlist into a python's list
			for (aux = list->head, i = 0; aux != NULL; aux = aux->next, i++) {
				PyTuple_SetItem(pylist, i, PyInt_FromLong((int)*((prefix_addr_t*)aux->data)));
			}
		}

		dll_destroy_all(list); // Destroy the linkedlist
	} else {
		PyErr_SetString(RepaError, "Error on read parameters");
		return NULL;
	}

    return pylist;
}