added subnets of CHILD_SAs to xml interface

a first design of Managers IKE_SA list page
This commit is contained in:
Martin Willi
2007-09-14 14:07:30 +00:00
parent 15a9d460c0
commit c01f7bf989
36 changed files with 3402 additions and 426 deletions
+16 -5
View File
@@ -59,13 +59,24 @@ struct controller_t {
char* (*get_name)(controller_t *this);
/**
* @brief Get the controllers handler function for an action name.
* @brief Handle a HTTP request for that controller.
*
* @param name name of the action
* @return controllers handler
* Request URLs are parsed in the form
* controller_name/p1/p2/p3/p4/p5 with a maximum of 5 parameters. Each
* parameter not found in the request URL is set to NULL.
*
* @param request HTTP request
* @param response HTTP response
* @param p1 first parameter
* @param p2 second parameter
* @param p3 third parameter
* @param p4 forth parameter
* @param p5 fifth parameter
* @return
*/
controller_handler_t (*get_handler)(controller_t *this, char *name);
void (*handle)(controller_t *this, request_t *request, response_t *response,
char *a1, char *a2, char *a3, char *a4, char *a5);
/**
* @brief Destroy the controller instance.
*/
+14 -9
View File
@@ -146,6 +146,7 @@ static session_entry_t *session_entry_create(private_dispatcher_t *this)
entry->waiting = 1;
pthread_cond_init(&entry->cond, NULL);
entry->session = load_session(this);
entry->used = time(NULL);
return entry;
}
@@ -208,16 +209,19 @@ static void dispatch(private_dispatcher_t *this)
iterator = this->sessions->create_iterator_locked(this->sessions, &this->mutex);
while (iterator->iterate(iterator, (void**)&current))
{
if (sid && streq(current->session->get_sid(current->session), sid))
{
found = current;
found->waiting++;
}
else if (current->waiting == 0 &&
current->used + this->timeout > now)
/* check all sessions for timeout */
if (current->waiting == 0 &&
current->used < now - this->timeout)
{
iterator->remove(iterator);
session_entry_destroy(current);
continue;
}
if (!found && sid &&
streq(current->session->get_sid(current->session), sid))
{
found = current;
found->waiting++;
}
}
iterator->destroy(iterator);
@@ -319,7 +323,8 @@ static void destroy(private_dispatcher_t *this)
/*
* see header file
*/
dispatcher_t *dispatcher_create(context_constructor_t constructor, void *param)
dispatcher_t *dispatcher_create(int timeout, context_constructor_t constructor,
void *param)
{
private_dispatcher_t *this = malloc_thing(private_dispatcher_t);
@@ -334,7 +339,7 @@ dispatcher_t *dispatcher_create(context_constructor_t constructor, void *param)
pthread_mutex_init(&this->mutex, NULL);
this->param = param;
this->fd = 0;
this->timeout = 180;
this->timeout = timeout;
FCGX_Init();
+6 -1
View File
@@ -40,6 +40,9 @@ struct dispatcher_t {
/**
* @brief Register a controller to the dispatcher.
*
* The first controller added serves as default controller. Client's
* get redirected to it if no other controller matches.
*
* @param constructor constructor function to the conntroller
* @param param param to pass to constructor
*/
@@ -70,9 +73,11 @@ struct dispatcher_t {
* The context constructor is invoked to create a session context for
* each session.
*
* @param timeout session timeout
* @param constructor construction function for session context
* @param param parameter to supply to context constructor
*/
dispatcher_t *dispatcher_create(context_constructor_t constructor, void *param);
dispatcher_t *dispatcher_create(int timeout,
context_constructor_t constructor, void *param);
#endif /* DISPATCHER_H_ */
+10
View File
@@ -186,6 +186,15 @@ static void redirect(private_response_t *this, char *location)
*location == '/' ? "" : "/", location);
}
/**
* Implementation of response_t.get_base.
*/
static char* get_base(private_response_t *this)
{
return FCGX_GetParam("SCRIPT_NAME", this->req->envp);
}
/**
* Implementation of response_t.destroy
*/
@@ -210,6 +219,7 @@ response_t *response_create(FCGX_Request *request)
this->public.set_content_type = (void(*)(response_t*, char *type))set_content_type;
this->public.add_cookie = (void(*)(response_t*, char *name, char *value))add_cookie;
this->public.redirect = (void(*)(response_t*, char *location))redirect;
this->public.get_base = (char*(*)(response_t*))get_base;
this->public.destroy = (void(*)(response_t*))destroy;
this->req = request;
+7
View File
@@ -78,6 +78,13 @@ struct response_t {
* @param location location to redirect to
*/
void (*redirect)(response_t *this, char *location);
/**
* @brief Get the base path of the application.
*
* @return base path
*/
char* (*get_base)(response_t *this);
/**
* @brief Destroy a response_t.
+11 -9
View File
@@ -91,7 +91,6 @@ static void process(private_session_t *this,
char *pos, *path, *controller, *action;
iterator_t *iterator;
bool handled = FALSE;
controller_handler_t handler;
controller_t *current;
if (this->sid == NULL)
@@ -126,12 +125,8 @@ static void process(private_session_t *this,
{
if (streq(current->get_name(current), controller))
{
handler = current->get_handler(current, action);
if (handler)
{
handler(current, request, response);
handled = TRUE;
}
current->handle(current, request, response, action, NULL, NULL, NULL, NULL);
handled = TRUE;
break;
}
}
@@ -140,8 +135,15 @@ static void process(private_session_t *this,
free(action);
if (!handled)
{
response->add_header(response, "Status", "400 Not Found");
response->printf(response, "<html><body><h1>Not Found</h1></body></html>\n");
if (this->controllers->get_first(this->controllers,
(void**)&current) == SUCCESS)
{
response->redirect(response, current->get_name(current));
}
else
{
response->printf(response, "No controllers loaded!\n");
}
}
}
+1 -1
View File
@@ -68,7 +68,7 @@ struct session_t {
/**
* @brief Create a session.
*
* @param context user defined session context instance
* @param context user defined session context instance
*/
session_t *session_create(context_t *context);
+2
View File
@@ -66,6 +66,8 @@ static void render(private_template_t *this, response_t *response)
NEOERR* err;
CSPARSE *parse;
hdf_set_value(this->hdf, "base", response->get_base(response));
err = cs_init(&parse, this->hdf);
if (!err)
{
+4
View File
@@ -55,6 +55,10 @@ struct template_t {
/**
* @brief Render a template to a response object.
*
* The render() function additionally sets a clearsilver variable "base"
* which points to the root of the web application and allows to point to
* other targets without to worry about path location.
*
* @param response response to render to
* @return rendered template string
*/