summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvenaas <venaas>2008-08-21 11:53:50 +0000
committervenaas <venaas@e88ac4ed-0b26-0410-9574-a7f39faa03bf>2008-08-21 11:53:50 +0000
commit1e644137c84f95ac4c3701ee765e637cae55f4fd (patch)
tree0dcfb7ad1703e7508201ae5bbe3953c5d92baf89
parent924eb6a12fa17c4ebbff5c8a15bd266358c16b09 (diff)
changed rewrite configs to hash
git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@353 e88ac4ed-0b26-0410-9574-a7f39faa03bf
-rw-r--r--radsecproxy.c39
-rw-r--r--radsecproxy.h5
2 files changed, 10 insertions, 34 deletions
diff --git a/radsecproxy.c b/radsecproxy.c
index c1154ea..1eee674 100644
--- a/radsecproxy.c
+++ b/radsecproxy.c
@@ -72,8 +72,8 @@
static struct options options;
static struct list *clconfs, *srvconfs;
-struct list *realms, *rewriteconfs;
-struct hash *tlsconfs;
+struct list *realms;
+struct hash *tlsconfs, *rewriteconfs;
static struct addrinfo *srcprotores[4] = { NULL, NULL, NULL, NULL };
@@ -2836,27 +2836,16 @@ int vattrname2val(char *attrname, uint32_t *vendor, uint32_t *type) {
}
struct rewrite *getrewrite(char *alt1, char *alt2) {
- struct list_node *entry;
- struct rewriteconf *r, *r1 = NULL, *r2 = NULL;
-
- for (entry = list_first(rewriteconfs); entry; entry = list_next(entry)) {
- r = (struct rewriteconf *)entry->data;
- if (!strcasecmp(r->name, alt1)) {
- r1 = r;
- break;
- }
- if (!r2 && alt2 && !strcasecmp(r->name, alt2))
- r2 = r;
- }
+ struct rewrite *r;
- r = (r1 ? r1 : r2);
- if (!r)
- return NULL;
- return r->rewrite;
+ if ((r = hash_read(rewriteconfs, alt1, strlen(alt1))))
+ return r;
+ if ((r = hash_read(rewriteconfs, alt2, strlen(alt2))))
+ return r;
+ return NULL;
}
void addrewrite(char *value, char **attrs, char **vattrs) {
- struct rewriteconf *new;
struct rewrite *rewrite = NULL;
int i, n;
uint8_t *a = NULL;
@@ -2902,16 +2891,8 @@ void addrewrite(char *value, char **attrs, char **vattrs) {
rewrite->removevendorattrs = va;
}
- new = malloc(sizeof(struct rewriteconf));
- if (!new || !list_push(rewriteconfs, new))
+ if (!hash_insert(rewriteconfs, value, strlen(value), rewrite))
debugx(1, DBG_ERR, "malloc failed");
-
- memset(new, 0, sizeof(struct rewriteconf));
- new->name = stringcopy(value, 0);
- if (!new->name)
- debugx(1, DBG_ERR, "malloc failed");
-
- new->rewrite = rewrite;
debug(DBG_DBG, "addrewrite: added rewrite block %s", value);
}
@@ -3319,7 +3300,7 @@ void getmainconfig(const char *configfile) {
if (!tlsconfs)
debugx(1, DBG_ERR, "malloc failed");
- rewriteconfs = list_create();
+ rewriteconfs = hash_create();
if (!rewriteconfs)
debugx(1, DBG_ERR, "malloc failed");
diff --git a/radsecproxy.h b/radsecproxy.h
index f3c0742..ee85c79 100644
--- a/radsecproxy.h
+++ b/radsecproxy.h
@@ -170,11 +170,6 @@ struct rewrite {
uint32_t *removevendorattrs;
};
-struct rewriteconf {
- char *name;
- struct rewrite *rewrite;
-};
-
struct protodefs {
char *name;
char *secretdefault;