- comment cleanups

This commit is contained in:
Martin Willi
2005-12-11 17:36:37 +00:00
parent ba204bddc7
commit 2ed133a80f
2 changed files with 29 additions and 29 deletions
+21 -26
View File
@@ -39,6 +39,9 @@
typedef struct netlink_message_t netlink_message_t; typedef struct netlink_message_t netlink_message_t;
/**
* Representation of ANY netlink message used
*/
struct netlink_message_t { struct netlink_message_t {
/** /**
@@ -58,6 +61,9 @@ struct netlink_message_t {
typedef struct netlink_algo_t netlink_algo_t; typedef struct netlink_algo_t netlink_algo_t;
/**
* Add length and type to xfrm_algo
*/
struct netlink_algo_t { struct netlink_algo_t {
u_int16_t length; u_int16_t length;
u_int16_t type; u_int16_t type;
@@ -80,7 +86,6 @@ struct private_kernel_interface_t {
* Netlink communication socket. * Netlink communication socket.
*/ */
int socket; int socket;
int bc_socket;
pid_t pid; pid_t pid;
/** /**
@@ -107,7 +112,6 @@ struct private_kernel_interface_t {
* Condvar allows signaling of threads waiting for a reply. * Condvar allows signaling of threads waiting for a reply.
*/ */
pthread_cond_t condvar; pthread_cond_t condvar;
logger_t *logger;
/** /**
* Function for the thread, receives messages. * Function for the thread, receives messages.
@@ -115,7 +119,7 @@ struct private_kernel_interface_t {
void (*receive_messages) (private_kernel_interface_t *this); void (*receive_messages) (private_kernel_interface_t *this);
/** /**
* Sends a netlink_message_t down to the kernel. * Sends a netlink_message_t down to the kernel and wait for reply.
*/ */
status_t (*send_message) (private_kernel_interface_t *this, netlink_message_t *request, netlink_message_t **response); status_t (*send_message) (private_kernel_interface_t *this, netlink_message_t *request, netlink_message_t **response);
}; };
@@ -258,20 +262,12 @@ static status_t add_sa( private_kernel_interface_t *this,
allocator_free(response); allocator_free(response);
return FAILED; return FAILED;
} }
printf("received message type: %d\n", response->hdr.nlmsg_type);
if (response->hdr.nlmsg_type == NLMSG_ERROR)
{
printf("received error: %s\n", strerror(-response->e.error));
}
allocator_free(response); allocator_free(response);
return SUCCESS; return SUCCESS;
} }
static status_t send_message(private_kernel_interface_t *this, netlink_message_t *request, netlink_message_t **response) static status_t send_message(private_kernel_interface_t *this, netlink_message_t *request, netlink_message_t **response)
{ {
size_t length; size_t length;
@@ -311,17 +307,17 @@ static status_t send_message(private_kernel_interface_t *this, netlink_message_t
if (listed_response->hdr.nlmsg_seq == request->hdr.nlmsg_seq) if (listed_response->hdr.nlmsg_seq == request->hdr.nlmsg_seq)
{ {
/* matches our request, this is the reply */ /* matches our request, this is the reply */
*response = listed_response; *response = listed_response;
found = TRUE; found = TRUE;
break; break;
} }
} }
iterator->destroy(iterator); iterator->destroy(iterator);
if (found) if (found)
{ {
break; break;
} }
/* we should time out, if something goes wrong */ /* we should time out, if something goes wrong */
pthread_cond_wait(&(this->condvar), &(this->mutex)); pthread_cond_wait(&(this->condvar), &(this->mutex));
} }
@@ -363,14 +359,14 @@ static void receive_messages(private_kernel_interface_t *this)
} }
if (addr.nl_pid != 0) if (addr.nl_pid != 0)
{ {
/* not interested, try another one */ /* not from kernel. not interested, try another one */
continue; continue;
} }
break; break;
} }
/* got a valid message. /* got a valid message.
* requests are handled on or own, * requests are handled on our own,
* responses are listed for the requesters * responses are listed for the requesters
*/ */
if (response.hdr.nlmsg_flags & NLM_F_REQUEST) if (response.hdr.nlmsg_flags & NLM_F_REQUEST)
@@ -386,7 +382,7 @@ static void receive_messages(private_kernel_interface_t *this)
pthread_mutex_lock(&(this->mutex)); pthread_mutex_lock(&(this->mutex));
this->responses->insert_last(this->responses, (void*)listed_response); this->responses->insert_last(this->responses, (void*)listed_response);
pthread_mutex_unlock(&(this->mutex)); pthread_mutex_unlock(&(this->mutex));
/* signal LEVEL3 waiting threads */ /* signal ALL waiting threads */
pthread_cond_broadcast(&(this->condvar)); pthread_cond_broadcast(&(this->condvar));
} }
/* get the next one */ /* get the next one */
@@ -444,7 +440,6 @@ kernel_interface_t *kernel_interface_create()
charon->kill(charon, "Unable to create netlink thread"); charon->kill(charon, "Unable to create netlink thread");
} }
this->logger = charon->logger_manager->create_logger(charon->logger_manager, TESTER, NULL);
charon->logger_manager->enable_logger_level(charon->logger_manager, TESTER, FULL); charon->logger_manager->enable_logger_level(charon->logger_manager, TESTER, FULL);
return (&this->public); return (&this->public);
} }
+8 -3
View File
@@ -40,12 +40,18 @@ typedef struct kernel_interface_t kernel_interface_t;
struct kernel_interface_t { struct kernel_interface_t {
/** /**
* Not yet fully implemented! * @brief Get a SPI from the kernel
*
* @todo Fix spi range
*/ */
status_t (*get_spi) (kernel_interface_t *this, host_t *src, host_t *dest, protocol_id_t protocol, bool tunnel_mode, u_int32_t *spi); status_t (*get_spi) (kernel_interface_t *this, host_t *src, host_t *dest, protocol_id_t protocol, bool tunnel_mode, u_int32_t *spi);
/** /**
* Not yet fully implemented! * @brief Create an SA.
*
* @todo Fix reqid and replay_window params
*
* @todo Cleanup method params
*/ */
status_t (*add_sa)(kernel_interface_t *this, status_t (*add_sa)(kernel_interface_t *this,
host_t *me, host_t *me,
@@ -61,7 +67,6 @@ struct kernel_interface_t {
chunk_t int_key, chunk_t int_key,
bool replace); bool replace);
/** /**
* @brief Destroys a kernel_interface object. * @brief Destroys a kernel_interface object.
* *