Exemplo n.º 1
0
static void console_dump(palProfilerNode* node, int depth) {
  for(int i = 0; i < depth; i++) {
    palPrintf("  ");
  }

  palPrintf(": %s %.2f\n", node->name, palTimerGetSeconds(node->enter_to_exit_time) * 1000.0f);

  if (node->child) {
    console_dump(node->child, depth+1);
  }
  if (node->sibling) {
    console_dump(node->sibling, depth);
  }
}
Exemplo n.º 2
0
void console_print_keys(char *out_buffer, int buffer_len, char *args) {
	char *tok;
	net_id_t id;
	int store_index;
	
	tok = strtok(args, " \n");
	if (tok == NULL) {
		return;
	}

	parse_id(id, tok);

	int routing_entry = lnp_routing_entry_lock(id);
	if (routing_entry == NULL_SLOT) {
		console_printf(out_buffer, buffer_len, "no routing entry.\n");
		return;
	}
	store_index = routing_table[routing_entry].store_index;
	if (store_index == NULL_SLOT) {
		console_printf(out_buffer, buffer_len, "no keys.\n");
		return;
	}
	lnp_key_entry_t *entry = &lnp_key_store[store_index];
	if (entry->handshake_state == LNP_HANDSHAKE_CONNECTED) {
		console_printf(out_buffer, buffer_len, "   cipher_in_key:");
		console_dump(out_buffer, buffer_len, 
				entry->cipher_in_key,
				entry->cipher->key_length);

		console_printf(out_buffer, buffer_len, "   cipher_out_key:");
		console_dump(out_buffer, buffer_len, 
				entry->cipher_out_key,
				entry->cipher->key_length);

		console_printf(out_buffer, buffer_len, "   cipher_in_iv:");
		console_dump(out_buffer, buffer_len, 
				entry->cipher_in_iv,
				entry->cipher->iv_length);

		console_printf(out_buffer, buffer_len, "   cipher_out_iv:");
		console_dump(out_buffer, buffer_len, 
				entry->cipher_out_iv,
				entry->cipher->iv_length);

		console_printf(out_buffer, buffer_len, "   mac_in_key:");
		console_dump(out_buffer, buffer_len, 
				entry->mac_in_key, 
				entry->mac->key_length);

		console_printf(out_buffer, buffer_len, "   mac_out_key:");
		console_dump(out_buffer, buffer_len, 
				entry->mac_out_key, 
				entry->mac->key_length);
	} else {
		console_printf(out_buffer, buffer_len, "session not established yet\n");
	}
	
	lnp_routing_entry_unlock(routing_entry);
}
Exemplo n.º 3
0
void console_read_data(char *out_buffer, int buffer_len, char *args) {
	int session;
	int return_value;
	u_char buffer[1000]; // TODO, colocar constante FTU

	return_value = llp_read(&session, buffer, sizeof(buffer));
	if (return_value == LINK_ERROR) {
		console_printf(out_buffer, buffer_len, "Error reading.\n");
	} else {
		console_printf(out_buffer, buffer_len, 
				"Message read from session %d.\n", session);
		console_dump(out_buffer, buffer_len, buffer, return_value);
	}
}
Exemplo n.º 4
0
void console_print_keys(char *out_buffer, int buffer_len, char *args) {
	int session;
	char *tok;
	char *endptr;
	
	tok = strtok(args, " \n");
	if (tok == NULL) {
		return;
	}

	session = strtol(tok, &endptr, 10);
	if (*tok=='\0' || *endptr!='\0') {
		return;
	}
	
	llp_lock_session(session);

	if (llp_sessions[session].state == LLP_STATE_ESTABLISHED) {
		console_printf(out_buffer, buffer_len, "   cipher_in_key:");
		console_dump(out_buffer, buffer_len, 
				llp_sessions[session].cipher_in_key,
				llp_sessions[session].cipher->key_length);

		console_printf(out_buffer, buffer_len, "   cipher_out_key:");
		console_dump(out_buffer, buffer_len, 
				llp_sessions[session].cipher_out_key,
				llp_sessions[session].cipher->key_length);

		console_printf(out_buffer, buffer_len, "   cipher_in_iv:");
		console_dump(out_buffer, buffer_len, 
				llp_sessions[session].cipher_in_iv,
				llp_sessions[session].cipher->iv_length);

		console_printf(out_buffer, buffer_len, "   cipher_out_iv:");
		console_dump(out_buffer, buffer_len, 
				llp_sessions[session].cipher_out_iv,
				llp_sessions[session].cipher->iv_length);

		console_printf(out_buffer, buffer_len, "   mac_in_key:");
		console_dump(out_buffer, buffer_len, 
				llp_sessions[session].mac_in_key, 
				llp_sessions[session].mac->key_length);

		console_printf(out_buffer, buffer_len, "   mac_out_key:");
		console_dump(out_buffer, buffer_len, 
				llp_sessions[session].mac_out_key, 
				llp_sessions[session].mac->key_length);
	} else {
		console_printf(out_buffer, buffer_len, "session not established yet\n");
	}
	
	llp_unlock_session(session);
}
Exemplo n.º 5
0
void console_print_dh_params(char *out_buffer, int buffer_len, char *args) {
	int session;
	char *tok;
	char *endptr;
	
	tok = strtok(args, " \n");
	if (tok == NULL) {
		return;
	}

	session = strtol(tok, &endptr, 10);
	if (*tok=='\0' || *endptr!='\0') {
		return;
	}

	llp_lock_session(session);
	
	if (llp_sessions[session].state == LLP_STATE_ESTABLISHED) {
		console_printf(out_buffer, buffer_len, "   y_in:");
		console_dump(out_buffer, buffer_len, 
				llp_sessions[session].y_in, 
				MPINT_LENGTH(llp_sessions[session].y_in) + MPINT_SIZE_LENGTH);
				
		console_printf(out_buffer, buffer_len, "   y_out:");
		console_dump(out_buffer, buffer_len, 
				llp_sessions[session].y_out, 
				MPINT_LENGTH(llp_sessions[session].y_out) + MPINT_SIZE_LENGTH);
				
		console_printf(out_buffer, buffer_len, "   z:");
		console_dump(out_buffer, buffer_len, 
				llp_sessions[session].z, 
				MPINT_LENGTH(llp_sessions[session].z) + MPINT_SIZE_LENGTH);
				
		console_printf(out_buffer, buffer_len, "   h_in:");
		console_dump(out_buffer, buffer_len, 
				llp_sessions[session].h_in, 
				LLP_H_LENGTH);
				
		console_printf(out_buffer, buffer_len, "   h_out:");
		console_dump(out_buffer, buffer_len, 
				llp_sessions[session].h_out, 
				LLP_H_LENGTH);
				
		console_printf(out_buffer, buffer_len, "   close_verifier:");
		console_dump(out_buffer, buffer_len, 
				llp_sessions[session].verifier, 
				llp_sessions[session].hash->length);
	} else {
		console_printf(out_buffer, buffer_len, "session not established yet\n");
	}
	
	llp_unlock_session(session);
}
Exemplo n.º 6
0
void console_read(char *out_buffer, int buffer_len, char *args) {
	net_id_t id;
	int return_value;
	u_char buffer[1000]; // TODO, colocar constante FTU

	return_value = lnp_read(id, buffer, sizeof(buffer), LNP_PROTOCOL_UNRELIABLE);
	if (return_value == NET_ERROR) {
		console_printf(out_buffer, buffer_len, "Error reading.\n");
	} else {
		console_printf(out_buffer, buffer_len, 
				"Message read from id: ");

		console_print_id(out_buffer, buffer_len, id);
		console_printf(out_buffer, buffer_len, "\nMSG(%d): ", return_value);
		console_dump(out_buffer, buffer_len, buffer, return_value);
		console_printf(out_buffer, buffer_len, "\n");
	}
}
Exemplo n.º 7
0
void palProfiler::ConsoleDump() {
  console_dump(&root_, 0);
}