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)
{
this->endpoint = host_create_from_chunk(addr_family, addr, port);
break;
+ case NO_FAMILY:
+ default:
+ this->endpoint = NULL;
+ break;
}
-
return SUCCESS;
}
}
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);
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;
}
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;
}
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 */
)
{
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;
* 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;
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);
{
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)
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;
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;
* 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;
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,
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;
{
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",
}
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;
}
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));
#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
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);
}
return this;
}
-// -----------------------------------------------------------------------------
-
/**
* Find an initiated connection by the peers' ids
*/
return status;
}
-// -----------------------------------------------------------------------------
-
-
/**
* Updates the state of the whole 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:
case CHECK_SUCCEEDED:
succeeded = TRUE;
break;
+ default:
+ break;
}
}
iterator->destroy(iterator);
{
iterator_t *iterator, *search;
endpoint_pair_t *current, *other;
- bool inserted = FALSE;
u_int32_t id = 0;
iterator = pairs->create_iterator(pairs, TRUE);
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);
prune_pairs(checklist->pairs);
}
-// -----------------------------------------------------------------------------
-
/**
* Processes the payloads of a connectivity check and returns the extracted data
*/
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);
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;
}
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;
}
}
}
- //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 */
}
/**
case CHECK_FAILED:
finish_checks(this, checklist);
break;
+ default:
+ break;
}
}
else
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;
}
}
check_destroy(check);
}
-// -----------------------------------------------------------------------------
-
/**
* Implementation of connect_manager_t.check_and_register.
*/
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));
#ifdef P2P
#include <sa/tasks/ike_p2p.h>
+#include <processing/jobs/initiate_mediation_job.h>
#endif
#ifndef RESOLV_CONF
#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);
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);
* 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;
* 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)
{
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);
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)
{
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));
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))
#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
};
-// -----------------------------------------------------------------------------
-
/**
* Adds a list of endpoints as notifies to a given 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);
iterator->destroy(iterator);
}
-// -----------------------------------------------------------------------------
-
/**
* Implementation of task_t.process for initiator
*/
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)
{
}
else
{
- // FIXME: should we make that configurable
+ /* FIXME: should we make that configurable */
message->add_notify(message, FALSE, P2P_CALLBACK, chunk_empty);
}
break;
}
+ default:
+ break;
}
-
return NEED_MORE;
}
}
DBG1(DBG_IKE, "received P2P_CONNECT");
-
break;
}
+ default:
+ break;
}
-
return NEED_MORE;
}
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,
return FAILED;
}
}
-
break;
}
+ default:
+ break;
}
return SUCCESS;
}
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;
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,
}
break;
}
+ default:
+ break;
}
return SUCCESS;
}
-// -----------------------------------------------------------------------------
-
/**
* Implementation of task_t.process for initiator (mediation server)
*/
}
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;
this->invalid_syntax = TRUE;
break;
}
-
break;
}
+ default:
+ break;
}
return NEED_MORE;
if (!peer_sa)
{
- // the peer is not online
+ /* the peer is not online */
message->add_notify(message, TRUE, P2P_CONNECT_FAILED, chunk_empty);
break;
}
break;
}
+ default:
+ break;
}
return SUCCESS;
}
*/
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
*/
}
else
{
- // mediation server
+ /* mediation server */
if (initiator)
{
this->public.task.build = (status_t(*)(task_t*,message_t*))build_i_ms;