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
+22 -8
View File
@@ -51,6 +51,7 @@ static void login(private_auth_controller_t *this,
{
template_t *t = template_create("templates/auth/login.cs");
t->set(t, "action", "check");
t->set(t, "title", "Login");
t->render(t, response);
t->destroy(t);
}
@@ -65,7 +66,7 @@ static void check(private_auth_controller_t *this,
if (username && password &&
this->manager->login(this->manager, username, password))
{
response->redirect(response, "status/test");
response->redirect(response, "status/ikesalist");
}
else
{
@@ -89,14 +90,27 @@ static char* get_name(private_auth_controller_t *this)
}
/**
* Implementation of controller_t.get_handler
* Implementation of controller_t.handle
*/
static controller_handler_t get_handler(private_auth_controller_t *this, char *name)
static void handle(private_auth_controller_t *this,
request_t *request, response_t *response, char *action)
{
if (streq(name, "login")) return (controller_handler_t)login;
if (streq(name, "check")) return (controller_handler_t)check;
if (streq(name, "logout")) return (controller_handler_t)logout;
return NULL;
if (action)
{
if (streq(action, "login"))
{
return login(this, request, response);
}
else if (streq(action, "check"))
{
return check(this, request, response);
}
else if (streq(action, "logout"))
{
return logout(this, request, response);
}
}
response->redirect(response, "auth/login");
}
/**
@@ -115,7 +129,7 @@ controller_t *auth_controller_create(context_t *context, void *param)
private_auth_controller_t *this = malloc_thing(private_auth_controller_t);
this->public.controller.get_name = (char*(*)(controller_t*))get_name;
this->public.controller.get_handler = (controller_handler_t(*)(controller_t*,char*))get_handler;
this->public.controller.handle = (void(*)(controller_t*,request_t*,response_t*,char*,char*,char*,char*,char*))handle;
this->public.controller.destroy = (void(*)(controller_t*))destroy;
this->manager = (manager_t*)context;
+23 -17
View File
@@ -72,6 +72,7 @@ static void list(private_gateway_controller_t *this,
}
enumerator->destroy(enumerator);
t->set(t, "action", "select");
t->set(t, "title", "Choose gateway");
t->render(t, response);
t->destroy(t);
}
@@ -90,16 +91,7 @@ static void _select(private_gateway_controller_t *this,
return;
}
}
response->printf(response, "selecting dings failed: %s", id);
}
/**
* redirect to authentication login
*/
static void login(private_gateway_controller_t *this,
request_t *request, response_t *response)
{
response->redirect(response, "auth/login");
response->printf(response, "selecting gateway failed: %s", id);
}
/**
@@ -111,16 +103,30 @@ static char* get_name(private_gateway_controller_t *this)
}
/**
* Implementation of controller_t.get_handler
* Implementation of controller_t.handle
*/
static controller_handler_t get_handler(private_gateway_controller_t *this, char *name)
static void handle(private_gateway_controller_t *this,
request_t *request, response_t *response, char *action)
{
if (!this->manager->logged_in(this->manager)) return (controller_handler_t)login;
if (streq(name, "list")) return (controller_handler_t)list;
if (streq(name, "select")) return (controller_handler_t)_select;
return NULL;
if (!this->manager->logged_in(this->manager))
{
return response->redirect(response, "auth/login");
}
if (action)
{
if (streq(action, "list"))
{
return list(this, request, response);
}
else if (streq(action, "select"))
{
return _select(this, request, response);
}
}
response->redirect(response, "gateway/list");
}
/**
* Implementation of controller_t.destroy
*/
@@ -137,7 +143,7 @@ controller_t *gateway_controller_create(context_t *context, void *param)
private_gateway_controller_t *this = malloc_thing(private_gateway_controller_t);
this->public.controller.get_name = (char*(*)(controller_t*))get_name;
this->public.controller.get_handler = (controller_handler_t(*)(controller_t*,char*))get_handler;
this->public.controller.handle = (void(*)(controller_t*,request_t*,response_t*,char*,char*,char*,char*,char*))handle;
this->public.controller.destroy = (void(*)(controller_t*))destroy;
this->manager = (manager_t*)context;
-103
View File
@@ -1,103 +0,0 @@
/**
* @file static_controller.c
*
* @brief Implementation of static_controller_t.
*
*/
/*
* Copyright (C) 2007 Martin Willi
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include "static_controller.h"
#include "../manager.h"
#include "../gateway.h"
#include <template.h>
#include <library.h>
typedef struct private_static_controller_t private_static_controller_t;
/**
* private data of the task manager
*/
struct private_static_controller_t {
/**
* public functions
*/
static_controller_t public;
/**
* manager instance
*/
manager_t *manager;
};
/**
* serve style.css
*/
static void style(private_static_controller_t *this,
request_t *request, response_t *response)
{
template_t *t = template_create("templates/static/style.css");
response->set_content_type(response, "text/css");
t->render(t, response);
t->destroy(t);
}
/**
* Implementation of controller_t.get_name
*/
static char* get_name(private_static_controller_t *this)
{
return "static";
}
/**
* Implementation of controller_t.get_handler
*/
static controller_handler_t get_handler(private_static_controller_t *this, char *name)
{
if (streq(name, "style.css")) return (controller_handler_t)style;
return NULL;
}
/**
* Implementation of controller_t.destroy
*/
static void destroy(private_static_controller_t *this)
{
free(this);
}
/*
* see header file
*/
controller_t *static_controller_create(context_t *context, void *param)
{
private_static_controller_t *this = malloc_thing(private_static_controller_t);
this->public.controller.get_name = (char*(*)(controller_t*))get_name;
this->public.controller.get_handler = (controller_handler_t(*)(controller_t*,char*))get_handler;
this->public.controller.destroy = (void(*)(controller_t*))destroy;
this->manager = (manager_t*)context;
return &this->public.controller;
}
@@ -1,47 +0,0 @@
/**
* @file static_controller.h
*
* @brief Interface of static_controller_t.
*
*/
/*
* Copyright (C) 2007 Martin Willi
* Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#ifndef STATIC_CONTROLLER_H_
#define STATIC_CONTROLLER_H_
#include <controller.h>
typedef struct static_controller_t static_controller_t;
/**
* @brief Static controller, serves static files.
*/
struct static_controller_t {
/**
* Implements controller_t interface.
*/
controller_t controller;
};
/**
* @brief Create a static_controller controller instance.
*/
controller_t *static_controller_create(context_t *context, void *param);
#endif /* STATIC_CONTROLLER_H_ */
+54 -31
View File
@@ -53,9 +53,9 @@ static void ikesalist(private_status_controller_t *this,
{
char *str;
gateway_t *gateway;
xml_t *doc, *node;
enumerator_t *e1, *e2, *e3, *e4, *e5, *e6;
char *name, *value, *id, *section;
xml_t *node;
enumerator_t *e1, *e2, *e3, *e4, *e5, *e6, *e7, *e8;
char *name, *value, *id = "", *section;
gateway = this->manager->select_gateway(this->manager, 0);
str = gateway->request(gateway, "<message type=\"request\" id=\"1\">"
@@ -69,8 +69,8 @@ static void ikesalist(private_status_controller_t *this,
return;
}
doc = xml_create(str);
if (doc == NULL)
node = xml_create(str);
if (node == NULL)
{
response->printf(response, "parsing XML failed");
return;
@@ -78,7 +78,7 @@ static void ikesalist(private_status_controller_t *this,
template_t *t = template_create("templates/status/ikesalist.cs");
e1 = doc->children(doc);
e1 = node->children(node);
while (e1->enumerate(e1, &node, &name, &value))
{
if (streq(name, "message"))
@@ -116,6 +116,33 @@ static void ikesalist(private_status_controller_t *this,
}
e6->destroy(e6);
}
else if (streq(name, "childsalist"))
{
e6 = node->children(node);
while (e6->enumerate(e6, &node, &name, &value))
{
if (streq(name, "childsa"))
{
e7 = node->children(node);
while (e7->enumerate(e7, &node, &name, &value))
{
if (streq(name, "local") ||
streq(name, "remote"))
{
section = name;
e8 = node->children(node);
while (e8->enumerate(e8, &node, &name, &value))
{
t->setf(t, "ikesas.%s.childsas.%s.%s=%s", id, section, name, value);
}
e8->destroy(e8);
}
}
e7->destroy(e7);
}
}
e6->destroy(e6);
}
else
{
t->setf(t, "ikesas.%s.%s=%s", id, name, value);
@@ -135,29 +162,12 @@ static void ikesalist(private_status_controller_t *this,
}
e1->destroy(e1);
t->set(t, "title", "IKE SA overview");
t->render(t, response);
t->destroy(t);
free(str);
}
/**
* redirect to authentication login
*/
static void login(private_status_controller_t *this,
request_t *request, response_t *response)
{
response->redirect(response, "auth/login");
}
/**
* redirect to gateway selection
*/
static void selection(private_status_controller_t *this,
request_t *request, response_t *response)
{
response->redirect(response, "gateway/list");
}
/**
* Implementation of controller_t.get_name
*/
@@ -167,14 +177,27 @@ static char* get_name(private_status_controller_t *this)
}
/**
* Implementation of controller_t.get_handler
* Implementation of controller_t.handle
*/
static controller_handler_t get_handler(private_status_controller_t *this, char *name)
static void handle(private_status_controller_t *this,
request_t *request, response_t *response, char *action)
{
if (!this->manager->logged_in(this->manager)) return (controller_handler_t)login;
if (this->manager->select_gateway(this->manager, 0) == NULL) return (controller_handler_t)selection;
if (streq(name, "ikesalist")) return (controller_handler_t)ikesalist;
return NULL;
if (!this->manager->logged_in(this->manager))
{
return response->redirect(response, "auth/login");
}
if (this->manager->select_gateway(this->manager, 0) == NULL)
{
return response->redirect(response, "gateway/list");
}
if (action)
{
if (streq(action, "ikesalist"))
{
return ikesalist(this, request, response);
}
}
return response->redirect(response, "status/ikesalist");
}
/**
@@ -193,7 +216,7 @@ controller_t *status_controller_create(context_t *context, void *param)
private_status_controller_t *this = malloc_thing(private_status_controller_t);
this->public.controller.get_name = (char*(*)(controller_t*))get_name;
this->public.controller.get_handler = (controller_handler_t(*)(controller_t*,char*))get_handler;
this->public.controller.handle = (void(*)(controller_t*,request_t*,response_t*,char*,char*,char*,char*,char*))handle;
this->public.controller.destroy = (void(*)(controller_t*))destroy;
this->manager = (manager_t*)context;