removed c++ style comments
fixed compiler warnings
This commit is contained in:
@@ -159,14 +159,10 @@ static status_t parse_notification_data(private_endpoint_notify_t *this, chunk_t
|
||||
|
||||
switch(this->family)
|
||||
{
|
||||
case NO_FAMILY:
|
||||
this->endpoint = NULL;
|
||||
break;
|
||||
|
||||
case IPv6:
|
||||
addr_family = AF_INET6;
|
||||
addr.len = 16;
|
||||
// fall-through
|
||||
/* fall-through */
|
||||
case IPv4:
|
||||
if (parse_uint16(&cur, top, &port) != SUCCESS)
|
||||
{
|
||||
@@ -184,8 +180,11 @@ static status_t parse_notification_data(private_endpoint_notify_t *this, chunk_t
|
||||
|
||||
this->endpoint = host_create_from_chunk(addr_family, addr, port);
|
||||
break;
|
||||
case NO_FAMILY:
|
||||
default:
|
||||
this->endpoint = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -220,7 +219,7 @@ static chunk_t build_notification_data(private_endpoint_notify_t *this)
|
||||
}
|
||||
port_chunk = chunk_from_thing(port);
|
||||
|
||||
// data = prio | family | type | port | addr
|
||||
/* data = prio | family | type | port | addr */
|
||||
data = chunk_cat("ccccc", prio_chunk, family_chunk, type_chunk,
|
||||
port_chunk, addr_chunk);
|
||||
DBG3(DBG_IKE, "p2p_endpoint_data %B", &data);
|
||||
@@ -375,13 +374,15 @@ endpoint_notify_t *endpoint_notify_create_from_host(p2p_endpoint_type_t type, ho
|
||||
this->priority = pow(2, 16) * P2P_PRIO_PEER;
|
||||
break;
|
||||
case RELAYED:
|
||||
default:
|
||||
this->priority = pow(2, 16) * P2P_PRIO_RELAY;
|
||||
break;
|
||||
}
|
||||
|
||||
this->priority += 65535;
|
||||
|
||||
if (!host) {
|
||||
if (!host)
|
||||
{
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
@@ -394,7 +395,8 @@ endpoint_notify_t *endpoint_notify_create_from_host(p2p_endpoint_type_t type, ho
|
||||
this->family = IPv6;
|
||||
break;
|
||||
default:
|
||||
// unsupported family type, we do not set the hsot (family is set to NO_FAMILY)
|
||||
/* unsupported family type, we do not set the hsot
|
||||
* (family is set to NO_FAMILY) */
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -192,7 +192,8 @@ static status_t verify(private_ike_header_t *this)
|
||||
|
||||
if (this->initiator_spi == 0
|
||||
#ifdef P2P
|
||||
// we allow zero spi for INFORMATIONAL exchanges, to allow P2P connectivity checks
|
||||
/* we allow zero spi for INFORMATIONAL exchanges,
|
||||
* to allow P2P connectivity checks */
|
||||
&& this->exchange_type != INFORMATIONAL
|
||||
#endif /* P2P */
|
||||
)
|
||||
|
||||
@@ -73,7 +73,7 @@ static bool initiate_callback(private_initiate_mediation_job_t *this, signal_t s
|
||||
{
|
||||
if (signal == CHILD_UP_SUCCESS)
|
||||
{
|
||||
// mediation connection is up
|
||||
/* mediation connection is up */
|
||||
this->mediation_sa_id = ike_sa->get_id(ike_sa);
|
||||
this->mediation_sa_id = this->mediation_sa_id->clone(this->mediation_sa_id);
|
||||
return FALSE;
|
||||
@@ -85,7 +85,7 @@ static bool initiate_callback(private_initiate_mediation_job_t *this, signal_t s
|
||||
* Implementation of job_t.execute.
|
||||
*/
|
||||
static void initiate(private_initiate_mediation_job_t *this)
|
||||
{//FIXME: check the logging
|
||||
{ /* FIXME: check the logging */
|
||||
ike_sa_t *mediated_sa, *mediation_sa;
|
||||
peer_cfg_t *mediated_cfg, *mediation_cfg;
|
||||
|
||||
@@ -94,7 +94,8 @@ static void initiate(private_initiate_mediation_job_t *this)
|
||||
if (mediated_sa)
|
||||
{
|
||||
mediated_cfg = mediated_sa->get_peer_cfg(mediated_sa);
|
||||
mediated_cfg->get_ref(mediated_cfg); // get_peer_cfg returns an internal object
|
||||
/* get_peer_cfg returns an internal object */
|
||||
mediated_cfg->get_ref(mediated_cfg);
|
||||
|
||||
charon->ike_sa_manager->checkin(charon->ike_sa_manager, mediated_sa);
|
||||
|
||||
@@ -107,18 +108,19 @@ static void initiate(private_initiate_mediation_job_t *this)
|
||||
{
|
||||
mediated_cfg->destroy(mediated_cfg);
|
||||
mediation_cfg->destroy(mediation_cfg);
|
||||
charon->bus->set_sa(charon->bus, mediated_sa); // this pointer should still be valid
|
||||
/* this pointer should still be valid */
|
||||
charon->bus->set_sa(charon->bus, mediated_sa);
|
||||
DBG1(DBG_IKE, "mediation with the same peer is already in progress, queued");
|
||||
destroy(this);
|
||||
return;
|
||||
}
|
||||
|
||||
mediation_cfg->get_ref(mediation_cfg); // we need an additional reference because initiate consumes one
|
||||
/* we need an additional reference because initiate consumes one */
|
||||
mediation_cfg->get_ref(mediation_cfg);
|
||||
|
||||
// this function call blocks until the connection is up or failed
|
||||
// we do not check the status, but NEED_MORE would be returned on success
|
||||
// because the registered callback returns FALSE then
|
||||
// this->mediation_sa_id is set in the callback
|
||||
/* this function call blocks until the connection is up or failed
|
||||
* we do not check the status, but NEED_MORE would be returned on success
|
||||
* because the registered callback returns FALSE then
|
||||
* this->mediation_sa_id is set in the callback */
|
||||
charon->interfaces->initiate(charon->interfaces,
|
||||
mediation_cfg, NULL, (interface_manager_cb_t)initiate_callback, this);
|
||||
if (!this->mediation_sa_id)
|
||||
@@ -127,7 +129,7 @@ static void initiate(private_initiate_mediation_job_t *this)
|
||||
mediation_cfg->get_name(mediation_cfg));
|
||||
mediation_cfg->destroy(mediation_cfg);
|
||||
mediated_cfg->destroy(mediated_cfg);
|
||||
charon->bus->set_sa(charon->bus, mediated_sa); // this pointer should still be valid
|
||||
charon->bus->set_sa(charon->bus, mediated_sa);
|
||||
SIG(IKE_UP_FAILED, "mediation failed");
|
||||
destroy(this);
|
||||
return;
|
||||
@@ -146,7 +148,7 @@ static void initiate(private_initiate_mediation_job_t *this)
|
||||
mediated_cfg->destroy(mediated_cfg);
|
||||
charon->ike_sa_manager->checkin_and_destroy(charon->ike_sa_manager, mediation_sa);
|
||||
|
||||
charon->bus->set_sa(charon->bus, mediated_sa); // this pointer should still be valid
|
||||
charon->bus->set_sa(charon->bus, mediated_sa);
|
||||
SIG(IKE_UP_FAILED, "mediation failed");
|
||||
destroy(this);
|
||||
return;
|
||||
@@ -164,7 +166,7 @@ static void initiate(private_initiate_mediation_job_t *this)
|
||||
* Implementation of job_t.execute.
|
||||
*/
|
||||
static void reinitiate(private_initiate_mediation_job_t *this)
|
||||
{//FIXME: check the logging
|
||||
{ /* FIXME: check the logging */
|
||||
ike_sa_t *mediated_sa, *mediation_sa;
|
||||
peer_cfg_t *mediated_cfg;
|
||||
|
||||
@@ -173,7 +175,7 @@ static void reinitiate(private_initiate_mediation_job_t *this)
|
||||
if (mediated_sa)
|
||||
{
|
||||
mediated_cfg = mediated_sa->get_peer_cfg(mediated_sa);
|
||||
mediated_cfg->get_ref(mediated_cfg); // get_peer_cfg returns an internal object
|
||||
mediated_cfg->get_ref(mediated_cfg);
|
||||
charon->ike_sa_manager->checkin(charon->ike_sa_manager, mediated_sa);
|
||||
|
||||
mediation_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager,
|
||||
@@ -187,7 +189,7 @@ static void reinitiate(private_initiate_mediation_job_t *this)
|
||||
mediated_cfg->destroy(mediated_cfg);
|
||||
charon->ike_sa_manager->checkin_and_destroy(charon->ike_sa_manager, mediation_sa);
|
||||
|
||||
charon->bus->set_sa(charon->bus, mediated_sa); // this pointer should still be valid
|
||||
charon->bus->set_sa(charon->bus, mediated_sa);
|
||||
SIG(IKE_UP_FAILED, "mediation failed");
|
||||
destroy(this);
|
||||
return;
|
||||
|
||||
@@ -104,7 +104,7 @@ static void execute(private_mediation_job_t *this)
|
||||
{
|
||||
if (this->callback)
|
||||
{
|
||||
// send callback to a peer
|
||||
/* send callback to a peer */
|
||||
if (target_sa->callback(target_sa, this->source) != SUCCESS)
|
||||
{
|
||||
DBG1(DBG_JOB, "callback for '%D' to '%D' failed",
|
||||
@@ -116,14 +116,14 @@ static void execute(private_mediation_job_t *this)
|
||||
}
|
||||
else
|
||||
{
|
||||
// normal mediation between two peers
|
||||
/* normal mediation between two peers */
|
||||
if (target_sa->relay(target_sa, this->source, this->session_id,
|
||||
this->session_key, this->endpoints, this->response) != SUCCESS)
|
||||
{
|
||||
DBG1(DBG_JOB, "mediation between '%D' and '%D' failed",
|
||||
this->source, this->target);
|
||||
charon->ike_sa_manager->checkin(charon->ike_sa_manager, target_sa);
|
||||
// FIXME: notify the initiator
|
||||
/* FIXME: notify the initiator */
|
||||
destroy(this);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -60,12 +60,13 @@ static void execute(private_process_message_job_t *this)
|
||||
ike_sa_t *ike_sa;
|
||||
|
||||
#ifdef P2P
|
||||
// if this is an unencrypted INFORMATIONAL exchange it is likely a
|
||||
// connectivity check
|
||||
/* if this is an unencrypted INFORMATIONAL exchange it is likely a
|
||||
* connectivity check. */
|
||||
if (this->message->get_exchange_type(this->message) == INFORMATIONAL &&
|
||||
this->message->get_first_payload_type(this->message) != ENCRYPTED)
|
||||
{
|
||||
// theoretically this could also be an error message see RFC 4306, section 1.5.
|
||||
/* theoretically this could also be an error message
|
||||
* see RFC 4306, section 1.5. */
|
||||
DBG1(DBG_NET, "received unencrypted informational: from %#H to %#H",
|
||||
this->message->get_source(this->message),
|
||||
this->message->get_destination(this->message));
|
||||
|
||||
@@ -32,13 +32,13 @@
|
||||
#include <processing/jobs/initiate_mediation_job.h>
|
||||
#include <encoding/payloads/endpoint_notify.h>
|
||||
|
||||
// base timeout
|
||||
// the sending interval is P2P_INTERVAL * active checklists (N)
|
||||
// retransmission timeout is P2P_INTERVAL * N * checks in waiting state (NW)
|
||||
#define P2P_INTERVAL 20 // 20 ms
|
||||
// min retransmission timeout (RTO is P2P_INTERVAL * N * checks in waiting state)
|
||||
#define P2P_RTO_MIN 100 // 100 ms
|
||||
// max number of retransmissions (+ the initial check)
|
||||
/* base timeout
|
||||
* the sending interval is P2P_INTERVAL * active checklists (N)
|
||||
* retransmission timeout is P2P_INTERVAL * N * checks in waiting state (NW) */
|
||||
#define P2P_INTERVAL 20 /* ms */
|
||||
/* min retransmission timeout (RTO is P2P_INTERVAL * N * checks in waiting state) */
|
||||
#define P2P_RTO_MIN 100 /* ms */
|
||||
/* max number of retransmissions (+ the initial check) */
|
||||
#define P2P_MAX_RETRANS 2
|
||||
|
||||
|
||||
@@ -212,7 +212,8 @@ static void check_list_destroy(check_list_t *this)
|
||||
DESTROY_OFFSET_IF(this->responder.endpoints, offsetof(endpoint_notify_t, destroy));
|
||||
|
||||
DESTROY_FUNCTION_IF(this->pairs, (void*)endpoint_pair_destroy);
|
||||
DESTROY_IF(this->triggered); // this list contains some of the same elements as contained in this->pairs
|
||||
/* this list contains some of the same elements as contained in this->pairs */
|
||||
DESTROY_IF(this->triggered);
|
||||
|
||||
free(this);
|
||||
}
|
||||
@@ -489,8 +490,6 @@ static initiate_data_t *initiate_data_create(check_list_t *checklist, initiated_
|
||||
return this;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Find an initiated connection by the peers' ids
|
||||
*/
|
||||
@@ -641,9 +640,6 @@ static status_t endpoints_contain(linked_list_t *endpoints, host_t *host, endpoi
|
||||
return status;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* Updates the state of the whole checklist
|
||||
*/
|
||||
@@ -659,7 +655,8 @@ static void update_checklist_state(check_list_t *checklist)
|
||||
switch(current->state)
|
||||
{
|
||||
case CHECK_WAITING:
|
||||
// at least one is still waiting -> checklist remains in waiting state
|
||||
/* at least one is still waiting -> checklist remains
|
||||
* in waiting state */
|
||||
iterator->destroy(iterator);
|
||||
return;
|
||||
case CHECK_IN_PROGRESS:
|
||||
@@ -668,6 +665,8 @@ static void update_checklist_state(check_list_t *checklist)
|
||||
case CHECK_SUCCEEDED:
|
||||
succeeded = TRUE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
@@ -832,7 +831,6 @@ static void prune_pairs(linked_list_t *pairs)
|
||||
{
|
||||
iterator_t *iterator, *search;
|
||||
endpoint_pair_t *current, *other;
|
||||
bool inserted = FALSE;
|
||||
u_int32_t id = 0;
|
||||
|
||||
iterator = pairs->create_iterator(pairs, TRUE);
|
||||
@@ -851,10 +849,10 @@ static void prune_pairs(linked_list_t *pairs)
|
||||
if (current->local->equals(current->local, other->local) &&
|
||||
current->remote->equals(current->remote, other->remote))
|
||||
{
|
||||
// since the list of pairs is sorted by priority in descending
|
||||
// order, and we iterate the list from the beginning, we are
|
||||
// sure that the priority of 'other' is lower than that of
|
||||
// 'current', remove it
|
||||
/* since the list of pairs is sorted by priority in descending
|
||||
* order, and we iterate the list from the beginning, we are
|
||||
* sure that the priority of 'other' is lower than that of
|
||||
* 'current', remove it */
|
||||
DBG1(DBG_IKE, "pruning endpoint pair %H - %H with priority %d",
|
||||
other->local, other->remote, other->priority);
|
||||
search->remove(search);
|
||||
@@ -896,8 +894,6 @@ static void build_pairs(check_list_t *checklist)
|
||||
prune_pairs(checklist->pairs);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Processes the payloads of a connectivity check and returns the extracted data
|
||||
*/
|
||||
@@ -1000,9 +996,6 @@ static chunk_t build_signature(private_connect_manager_t *this,
|
||||
return sig_hash;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// forward declarations
|
||||
static void queue_retransmission(private_connect_manager_t *this, chunk_t session_id, u_int32_t mid);
|
||||
static void schedule_checks(private_connect_manager_t *this, check_list_t *checklist, u_int32_t time);
|
||||
static void finish_checks(private_connect_manager_t *this, check_list_t *checklist);
|
||||
@@ -1061,11 +1054,13 @@ retransmit_end:
|
||||
case CHECK_FAILED:
|
||||
finish_checks(this, checklist);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&(this->mutex));
|
||||
|
||||
// we reschedule it manually
|
||||
/* we reschedule it manually */
|
||||
return JOB_REQUEUE_NONE;
|
||||
}
|
||||
|
||||
@@ -1192,13 +1187,13 @@ static job_requeue_t sender(sender_data_t *data)
|
||||
|
||||
check_destroy(check);
|
||||
|
||||
// schedule this job again
|
||||
/* schedule this job again */
|
||||
u_int32_t N = this->checklists->get_count(this->checklists);
|
||||
schedule_checks(this, checklist, P2P_INTERVAL * N);
|
||||
|
||||
pthread_mutex_unlock(&(this->mutex));
|
||||
|
||||
// we reschedule it manually
|
||||
/* we reschedule it manually */
|
||||
return JOB_REQUEUE_NONE;
|
||||
}
|
||||
|
||||
@@ -1272,9 +1267,10 @@ static void finish_checks(private_connect_manager_t *this, check_list_t *checkli
|
||||
}
|
||||
}
|
||||
|
||||
//remove_checklist(this, checklist);
|
||||
//check_list_destroy(checklist);
|
||||
// FIXME: we should do this ^^^ after a specific timeout on the responder side
|
||||
/* remove_checklist(this, checklist);
|
||||
* check_list_destroy(checklist);
|
||||
* FIXME: we should do this ^^^ after a specific timeout on the
|
||||
* responder side */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1315,6 +1311,8 @@ static void process_response(private_connect_manager_t *this, check_t *check,
|
||||
case CHECK_FAILED:
|
||||
finish_checks(this, checklist);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1345,16 +1343,16 @@ static void process_request(private_connect_manager_t *this, check_t *check,
|
||||
switch(pair->state)
|
||||
{
|
||||
case CHECK_IN_PROGRESS:
|
||||
pair->retransmitted = P2P_MAX_RETRANS; // prevent retransmissions
|
||||
// FIXME: we should wait to the next rto to send the triggered check
|
||||
// fall-through
|
||||
/* prevent retransmissions */
|
||||
pair->retransmitted = P2P_MAX_RETRANS;
|
||||
/* FIXME: we should wait to the next rto to send the triggered check
|
||||
* fall-through */
|
||||
case CHECK_WAITING:
|
||||
case CHECK_FAILED:
|
||||
queue_triggered_check(checklist, pair);
|
||||
break;
|
||||
case CHECK_SUCCEEDED:
|
||||
default:
|
||||
// do nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1453,8 +1451,6 @@ static void process_check(private_connect_manager_t *this, message_t *message)
|
||||
check_destroy(check);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Implementation of connect_manager_t.check_and_register.
|
||||
*/
|
||||
@@ -1570,7 +1566,8 @@ static status_t set_responder_data(private_connect_manager_t *this,
|
||||
|
||||
build_pairs(checklist);
|
||||
|
||||
schedule_checks(this, checklist, 0); // send the first check immediately
|
||||
/* send the first check immediately */
|
||||
schedule_checks(this, checklist, 0);
|
||||
|
||||
pthread_mutex_unlock(&(this->mutex));
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
|
||||
#ifdef P2P
|
||||
#include <sa/tasks/ike_p2p.h>
|
||||
#include <processing/jobs/initiate_mediation_job.h>
|
||||
#endif
|
||||
|
||||
#ifndef RESOLV_CONF
|
||||
@@ -1041,7 +1042,7 @@ static status_t initiate(private_ike_sa_t *this, child_cfg_t *child_cfg)
|
||||
#ifdef P2P
|
||||
if (this->peer_cfg->get_mediated_by(this->peer_cfg))
|
||||
{
|
||||
// mediated connection, initiate mediation process
|
||||
/* mediated connection, initiate mediation process */
|
||||
job_t *job = (job_t*)initiate_mediation_job_create(this->ike_sa_id, child_cfg);
|
||||
child_cfg->destroy(child_cfg);
|
||||
charon->processor->queue_job(charon->processor, job);
|
||||
@@ -1050,14 +1051,14 @@ static status_t initiate(private_ike_sa_t *this, child_cfg_t *child_cfg)
|
||||
else if (this->peer_cfg->is_mediation(this->peer_cfg))
|
||||
{
|
||||
if (this->state == IKE_ESTABLISHED)
|
||||
{// FIXME: we should try to find a better solution to this
|
||||
{ /* FIXME: we should try to find a better solution to this */
|
||||
SIG(CHILD_UP_SUCCESS, "mediation connection is already up and running");
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif /* P2P */
|
||||
{
|
||||
// normal IKE_SA with CHILD_SA
|
||||
/* normal IKE_SA with CHILD_SA */
|
||||
task = (task_t*)child_create_create(&this->public, child_cfg);
|
||||
child_cfg->destroy(child_cfg);
|
||||
this->task_manager->queue_task(this->task_manager, task);
|
||||
@@ -1070,7 +1071,7 @@ static status_t initiate(private_ike_sa_t *this, child_cfg_t *child_cfg)
|
||||
* Implementation of ike_sa_t.acquire.
|
||||
*/
|
||||
static status_t acquire(private_ike_sa_t *this, u_int32_t reqid)
|
||||
{// FIXME: P2P-NAT-T
|
||||
{ /* FIXME: P2P-NAT-T */
|
||||
child_cfg_t *child_cfg;
|
||||
iterator_t *iterator;
|
||||
child_sa_t *current, *child_sa = NULL;
|
||||
@@ -1396,7 +1397,7 @@ static status_t process_message(private_ike_sa_t *this, message_t *message)
|
||||
* Implementation of ike_sa_t.retransmit.
|
||||
*/
|
||||
static status_t retransmit(private_ike_sa_t *this, u_int32_t message_id)
|
||||
{// FIXME: P2P-NAT-T
|
||||
{ /* FIXME: P2P-NAT-T */
|
||||
this->time.outbound = time(NULL);
|
||||
if (this->task_manager->retransmit(this->task_manager, message_id) != SUCCESS)
|
||||
{
|
||||
@@ -2288,7 +2289,7 @@ static void destroy(private_ike_sa_t *this)
|
||||
if (this->peer_cfg && this->peer_cfg->is_mediation(this->peer_cfg) &&
|
||||
!this->ike_sa_id->is_initiator(this->ike_sa_id))
|
||||
{
|
||||
// mediation server
|
||||
/* mediation server */
|
||||
charon->mediation_manager->remove(charon->mediation_manager, this->ike_sa_id);
|
||||
}
|
||||
DESTROY_IF(this->server_reflexive_host);
|
||||
|
||||
@@ -240,7 +240,7 @@ static void update_sa_id(private_mediation_manager_t *this, identification_t *pe
|
||||
DBG2(DBG_IKE, "changing registered IKE_SA ID of peer '%D'", peer_id);
|
||||
peer->ike_sa_id = ike_sa_id ? ike_sa_id->clone(ike_sa_id) : NULL;
|
||||
|
||||
// send callbacks to registered peers
|
||||
/* send callbacks to registered peers */
|
||||
identification_t *requester;
|
||||
while(peer->requested_by->remove_last(peer->requested_by, (void**)&requester) == SUCCESS)
|
||||
{
|
||||
@@ -295,7 +295,7 @@ static ike_sa_id_t *check_and_register(private_mediation_manager_t *this,
|
||||
|
||||
if (!peer->ike_sa_id)
|
||||
{
|
||||
// the peer is not online
|
||||
/* the peer is not online */
|
||||
DBG2(DBG_IKE, "requested peer '%D' is offline, registering peer '%D'", peer_id, requester);
|
||||
register_peer(peer, requester);
|
||||
pthread_mutex_unlock(&(this->mutex));
|
||||
|
||||
@@ -706,7 +706,7 @@ static status_t process_request(private_task_manager_t *this,
|
||||
break;
|
||||
}
|
||||
case CREATE_CHILD_SA:
|
||||
{//FIXME: we should prevent this on mediation connections
|
||||
{ /* FIXME: we should prevent this on mediation connections */
|
||||
bool notify_found = FALSE, ts_found = FALSE;
|
||||
iterator = message->get_payload_iterator(message);
|
||||
while (iterator->iterate(iterator, (void**)&payload))
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#define P2P_SESSIONID_LEN 8
|
||||
#define P2P_SESSIONKEY_LEN 16
|
||||
|
||||
// FIXME: proposed values
|
||||
/* FIXME: proposed values */
|
||||
#define P2P_SESSIONID_MIN_LEN 4
|
||||
#define P2P_SESSIONID_MAX_LEN 16
|
||||
#define P2P_SESSIONKEY_MIN_LEN 8
|
||||
@@ -119,8 +119,6 @@ struct private_ike_p2p_t {
|
||||
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Adds a list of endpoints as notifies to a given message
|
||||
*/
|
||||
@@ -146,7 +144,7 @@ static void gather_and_add_endpoints(private_ike_p2p_t *this, message_t *message
|
||||
host_t *addr, *host;
|
||||
u_int16_t port;
|
||||
|
||||
// get the port that is used to communicate with the ms
|
||||
/* get the port that is used to communicate with the ms */
|
||||
host = this->ike_sa->get_my_host(this->ike_sa);
|
||||
port = host->get_port(host);
|
||||
|
||||
@@ -254,8 +252,6 @@ static void process_payloads(private_ike_p2p_t *this, message_t *message)
|
||||
iterator->destroy(iterator);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Implementation of task_t.process for initiator
|
||||
*/
|
||||
@@ -297,8 +293,8 @@ static status_t build_i(private_ike_p2p_t *this, message_t *message)
|
||||
|
||||
if (!this->response)
|
||||
{
|
||||
// only the initiator creates a session ID. the responder returns
|
||||
// the session ID that it received from the initiator
|
||||
/* only the initiator creates a session ID. the responder returns
|
||||
* the session ID that it received from the initiator */
|
||||
if (rand->allocate_pseudo_random_bytes(rand,
|
||||
P2P_SESSIONID_LEN, &this->session_id) != SUCCESS)
|
||||
{
|
||||
@@ -327,7 +323,7 @@ static status_t build_i(private_ike_p2p_t *this, message_t *message)
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME: should we make that configurable
|
||||
/* FIXME: should we make that configurable */
|
||||
message->add_notify(message, FALSE, P2P_CALLBACK, chunk_empty);
|
||||
}
|
||||
|
||||
@@ -335,8 +331,9 @@ static status_t build_i(private_ike_p2p_t *this, message_t *message)
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return NEED_MORE;
|
||||
}
|
||||
|
||||
@@ -388,11 +385,11 @@ static status_t process_r(private_ike_p2p_t *this, message_t *message)
|
||||
}
|
||||
|
||||
DBG1(DBG_IKE, "received P2P_CONNECT");
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return NEED_MORE;
|
||||
}
|
||||
|
||||
@@ -421,16 +418,16 @@ static status_t build_r(private_ike_p2p_t *this, message_t *message)
|
||||
|
||||
if (this->response)
|
||||
{
|
||||
// FIXME: handle result of set_responder_data
|
||||
// as initiator, upon receiving a response from another peer,
|
||||
// update the checklist and start sending checks
|
||||
/* FIXME: handle result of set_responder_data
|
||||
* as initiator, upon receiving a response from another peer,
|
||||
* update the checklist and start sending checks */
|
||||
charon->connect_manager->set_responder_data(charon->connect_manager,
|
||||
this->session_id, this->session_key, this->remote_endpoints);
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME: handle result of set_initiator_data
|
||||
// as responder, create a checklist with the initiator's data
|
||||
/* FIXME: handle result of set_initiator_data
|
||||
* as responder, create a checklist with the initiator's data */
|
||||
charon->connect_manager->set_initiator_data(charon->connect_manager,
|
||||
this->peer_id, this->ike_sa->get_my_id(this->ike_sa),
|
||||
this->session_id, this->session_key, this->remote_endpoints,
|
||||
@@ -441,9 +438,10 @@ static status_t build_r(private_ike_p2p_t *this, message_t *message)
|
||||
return FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -470,19 +468,19 @@ static status_t process_i(private_ike_p2p_t *this, message_t *message)
|
||||
case IKE_AUTH:
|
||||
{
|
||||
process_payloads(this, message);
|
||||
|
||||
//FIXME: we should update the server reflexive endpoint somehow, if mobike notices a change
|
||||
|
||||
/* FIXME: we should update the server reflexive endpoint somehow,
|
||||
* if mobike notices a change */
|
||||
endpoint_notify_t *reflexive;
|
||||
if (this->remote_endpoints->get_first(this->remote_endpoints, (void**)&reflexive) == SUCCESS &&
|
||||
reflexive->get_type(reflexive) == SERVER_REFLEXIVE)
|
||||
{//FIXME: should we accept this endpoint even if we did not send a request?
|
||||
if (this->remote_endpoints->get_first(this->remote_endpoints,
|
||||
(void**)&reflexive) == SUCCESS &&
|
||||
reflexive->get_type(reflexive) == SERVER_REFLEXIVE)
|
||||
{ /* FIXME: should we accept this endpoint even if we did not send
|
||||
* a request? */
|
||||
host_t *endpoint = reflexive->get_host(reflexive);
|
||||
|
||||
this->ike_sa->set_server_reflexive_host(this->ike_sa, endpoint->clone(endpoint));
|
||||
}
|
||||
|
||||
// FIXME: what if it failed? e.g. AUTH failure
|
||||
/* FIXME: what if it failed? e.g. AUTH failure */
|
||||
SIG(CHILD_UP_SUCCESS, "established mediation connection without CHILD_SA successfully");
|
||||
|
||||
break;
|
||||
@@ -494,22 +492,23 @@ static status_t process_i(private_ike_p2p_t *this, message_t *message)
|
||||
if (this->failed)
|
||||
{
|
||||
DBG1(DBG_IKE, "peer '%D' is not online", this->peer_id);
|
||||
// FIXME: notify the mediated connection (job?)
|
||||
// FIXME: probably delete the created checklist, at least as responder
|
||||
/* FIXME: notify the mediated connection (job?)
|
||||
* FIXME: probably delete the created checklist, at least as
|
||||
* responder */
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this->response)
|
||||
{
|
||||
// FIXME: handle result of set_responder_data
|
||||
// as responder, we update the checklist and start sending checks
|
||||
/* FIXME: handle result of set_responder_data.
|
||||
* as responder, we update the checklist and start sending checks */
|
||||
charon->connect_manager->set_responder_data(charon->connect_manager,
|
||||
this->session_id, this->session_key, this->local_endpoints);
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME: handle result of set_initiator_data
|
||||
// as initiator, we create a checklist and set the initiator's data
|
||||
/* FIXME: handle result of set_initiator_data
|
||||
* as initiator, we create a checklist and set the initiator's data */
|
||||
charon->connect_manager->set_initiator_data(charon->connect_manager,
|
||||
this->ike_sa->get_my_id(this->ike_sa), this->peer_id,
|
||||
this->session_id, this->session_key, this->local_endpoints,
|
||||
@@ -518,12 +517,12 @@ static status_t process_i(private_ike_p2p_t *this, message_t *message)
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Implementation of task_t.process for initiator (mediation server)
|
||||
*/
|
||||
@@ -542,21 +541,19 @@ static status_t build_i_ms(private_ike_p2p_t *this, message_t *message)
|
||||
}
|
||||
else
|
||||
{
|
||||
notify_payload_t *notify;
|
||||
|
||||
if (this->response)
|
||||
{
|
||||
message->add_notify(message, FALSE, P2P_RESPONSE, chunk_empty);
|
||||
}
|
||||
|
||||
}
|
||||
message->add_notify(message, FALSE, P2P_SESSIONID, this->session_id);
|
||||
message->add_notify(message, FALSE, P2P_SESSIONKEY, this->session_key);
|
||||
|
||||
add_endpoints_to_message(message, this->remote_endpoints);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return NEED_MORE;
|
||||
@@ -614,9 +611,10 @@ static status_t process_r_ms(private_ike_p2p_t *this, message_t *message)
|
||||
this->invalid_syntax = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return NEED_MORE;
|
||||
@@ -679,7 +677,7 @@ static status_t build_r_ms(private_ike_p2p_t *this, message_t *message)
|
||||
|
||||
if (!peer_sa)
|
||||
{
|
||||
// the peer is not online
|
||||
/* the peer is not online */
|
||||
message->add_notify(message, TRUE, P2P_CONNECT_FAILED, chunk_empty);
|
||||
break;
|
||||
}
|
||||
@@ -691,6 +689,8 @@ static status_t build_r_ms(private_ike_p2p_t *this, message_t *message)
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -700,18 +700,9 @@ static status_t build_r_ms(private_ike_p2p_t *this, message_t *message)
|
||||
*/
|
||||
static status_t process_i_ms(private_ike_p2p_t *this, message_t *message)
|
||||
{
|
||||
switch(message->get_exchange_type(message))
|
||||
{
|
||||
case P2P_CONNECT:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Implementation of ike_p2p.connect
|
||||
*/
|
||||
@@ -813,7 +804,7 @@ ike_p2p_t *ike_p2p_create(ike_sa_t *ike_sa, bool initiator)
|
||||
}
|
||||
else
|
||||
{
|
||||
// mediation server
|
||||
/* mediation server */
|
||||
if (initiator)
|
||||
{
|
||||
this->public.task.build = (status_t(*)(task_t*,message_t*))build_i_ms;
|
||||
|
||||
Reference in New Issue
Block a user