diff options
author | Sander Vrijders <sander.vrijders@ugent.be> | 2017-09-21 14:58:07 +0000 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@ugent.be> | 2017-09-21 14:58:07 +0000 |
commit | e2d3b18ab787ebe090cd958cc63be655be86f42c (patch) | |
tree | a51f0260c4445ddf35fb190e605704669e84bb94 /src | |
parent | e5336f1309c42da770ef7aa603b463ad4d24e2c9 (diff) | |
parent | f6071ecf0cd3768eaed9a847f676433c120ea89e (diff) | |
download | ouroboros-e2d3b18ab787ebe090cd958cc63be655be86f42c.tar.gz ouroboros-e2d3b18ab787ebe090cd958cc63be655be86f42c.zip |
Merged in sandervrijders/ouroboros/be-lfa-pff (pull request #607)
ipcpd: normal: Add alternate hop PFF
Diffstat (limited to 'src')
-rw-r--r-- | src/ipcpd/normal/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/ipcpd/normal/addr_auth.c | 2 | ||||
-rw-r--r-- | src/ipcpd/normal/pff.c | 13 | ||||
-rw-r--r-- | src/ipcpd/normal/pol/alternate_pff.c | 402 | ||||
-rw-r--r-- | src/ipcpd/normal/pol/alternate_pff.h | 61 | ||||
-rw-r--r-- | src/ipcpd/normal/pol/simple_pff.c | 14 | ||||
-rw-r--r-- | src/ipcpd/normal/routing.c | 2 | ||||
-rw-r--r-- | src/lib/hashtable.c | 46 | ||||
-rw-r--r-- | src/lib/tests/hashtable_test.c | 23 | ||||
-rw-r--r-- | src/tools/irm/irm_ipcp_bootstrap.c | 76 |
10 files changed, 569 insertions, 71 deletions
diff --git a/src/ipcpd/normal/CMakeLists.txt b/src/ipcpd/normal/CMakeLists.txt index ebb413a8..8dbe4820 100644 --- a/src/ipcpd/normal/CMakeLists.txt +++ b/src/ipcpd/normal/CMakeLists.txt @@ -41,6 +41,7 @@ set(SOURCE_FILES routing.c sdu_sched.c # Add policies last + pol/alternate_pff.c pol/flat.c pol/link_state.c pol/graph.c diff --git a/src/ipcpd/normal/addr_auth.c b/src/ipcpd/normal/addr_auth.c index c7c744c7..d438f98f 100644 --- a/src/ipcpd/normal/addr_auth.c +++ b/src/ipcpd/normal/addr_auth.c @@ -36,7 +36,7 @@ int addr_auth_init(enum pol_addr_auth type, const void * info) { switch (type) { - case FLAT_RANDOM: + case ADDR_AUTH_FLAT_RANDOM: ops = &flat_ops; break; default: diff --git a/src/ipcpd/normal/pff.c b/src/ipcpd/normal/pff.c index 27ff17f7..3d114aa1 100644 --- a/src/ipcpd/normal/pff.c +++ b/src/ipcpd/normal/pff.c @@ -24,6 +24,7 @@ #include "pff.h" #include "pol-pff-ops.h" +#include "pol/alternate_pff.h" #include "pol/simple_pff.h" struct pff { @@ -40,16 +41,20 @@ struct pff * pff_create(enum pol_pff pol) return NULL; switch (pol) { - case SIMPLE_PFF: + case PFF_ALTERNATE: + pff->ops = &alternate_pff_ops; + break; + case PFF_SIMPLE: pff->ops = &simple_pff_ops; - pff->pff_i = pff->ops->create(); - if (pff->pff_i == NULL) - goto err; break; default: goto err; } + pff->pff_i = pff->ops->create(); + if (pff->pff_i == NULL) + goto err; + return pff; err: free(pff); diff --git a/src/ipcpd/normal/pol/alternate_pff.c b/src/ipcpd/normal/pol/alternate_pff.c new file mode 100644 index 00000000..3952bc82 --- /dev/null +++ b/src/ipcpd/normal/pol/alternate_pff.c @@ -0,0 +1,402 @@ +/* + * Ouroboros - Copyright (C) 2016 - 2017 + * + * Policy for PFF with alternate next hops + * + * Dimitri Staessens <dimitri.staessens@ugent.be> + * Sander Vrijders <sander.vrijders@ugent.be> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., http://www.fsf.org/about/contact/. + */ + +#define _POSIX_C_SOURCE 200112L + +#include "config.h" + +#include <ouroboros/hashtable.h> +#include <ouroboros/errno.h> +#include <ouroboros/list.h> + +#include <string.h> +#include <assert.h> +#include <pthread.h> + +#include "alternate_pff.h" + +struct nhop { + struct list_head next; + int fd; +}; + +struct addr { + struct list_head next; + uint64_t addr; +}; + +struct pff_i { + struct htable * table; + + struct list_head addrs; + + struct list_head nhops_down; + + pthread_rwlock_t lock; +}; + +struct pol_pff_ops alternate_pff_ops = { + .create = alternate_pff_create, + .destroy = alternate_pff_destroy, + .lock = alternate_pff_lock, + .unlock = alternate_pff_unlock, + .add = alternate_pff_add, + .update = alternate_pff_update, + .del = alternate_pff_del, + .flush = alternate_pff_flush, + .nhop = alternate_pff_nhop, + .flow_state_change = alternate_flow_state_change +}; + +static int add_addr(struct pff_i * pff_i, + uint64_t addr) +{ + struct addr * a; + + a = malloc(sizeof(*a)); + if (a == NULL) + return -1; + + a->addr = addr; + + list_add(&a->next, &(pff_i->addrs)); + + return 0; +} + +static void del_addr(struct pff_i * pff_i, + uint64_t addr) +{ + struct list_head * pos = NULL; + struct list_head * n = NULL; + + list_for_each_safe(pos, n, &(pff_i->addrs)) { + struct addr * e = list_entry(pos, struct addr, next); + if (e->addr == addr) { + list_del(&e->next); + free(e); + return; + } + } +} + +static void del_addrs(struct pff_i * pff_i) +{ + struct list_head * pos = NULL; + struct list_head * n = NULL; + + list_for_each_safe(pos, n, &(pff_i->addrs)) { + struct addr * e = list_entry(pos, struct addr, next); + list_del(&e->next); + free(e); + } +} + +static void del_nhops_down(struct pff_i * pff_i) +{ + struct list_head * pos = NULL; + struct list_head * n = NULL; + + list_for_each_safe(pos, n, &(pff_i->nhops_down)) { + struct nhop * e = list_entry(pos, struct nhop, next); + list_del(&e->next); + free(e); + } +} + +static int del_nhop_down(struct pff_i * pff_i, + int fd) +{ + struct list_head * pos = NULL; + struct list_head * n = NULL; + + list_for_each_safe(pos, n, &(pff_i->nhops_down)) { + struct nhop * e = list_entry(pos, struct nhop, next); + if (e->fd == fd) { + list_del(&e->next); + free(e); + return 0; + } + } + + return -1; +} + +static int add_nhop_down(struct pff_i * pff_i, + int fd) +{ + struct nhop * nhop; + + nhop = malloc(sizeof(*nhop)); + if (nhop == NULL) + return -1; + + nhop->fd = fd; + + list_add(&nhop->next, &(pff_i->nhops_down)); + + return 0; +} + +static bool nhops_down_has(struct pff_i * pff_i, + int fd) +{ + struct list_head * pos = NULL; + + list_for_each(pos, &pff_i->nhops_down) { + struct nhop * e = list_entry(pos, struct nhop, next); + if (e->fd == fd) + return true; + } + + return false; +} + +static int add_to_htable(struct pff_i * pff_i, + uint64_t addr, + int * fd, + size_t len) +{ + int * val; + + assert(pff_i); + assert(len > 0); + + val = malloc(sizeof(*val) * (len + 1)); + if (val == NULL) + goto fail_malloc; + + memcpy(val, fd, len * sizeof(*val)); + /* Put primary hop again at the end */ + val[len] = val[0]; + + if (htable_insert(pff_i->table, addr, val, len)) + goto fail_insert; + + return 0; + + fail_insert: + free(val); + fail_malloc: + return -1; +} + +struct pff_i * alternate_pff_create(void) +{ + struct pff_i * tmp; + + tmp = malloc(sizeof(*tmp)); + if (tmp == NULL) + goto fail_malloc; + + if (pthread_rwlock_init(&tmp->lock, NULL)) + goto fail_lock; + + tmp->table = htable_create(PFT_SIZE, false); + if (tmp->table == NULL) + goto fail_table; + + list_head_init(&tmp->nhops_down); + list_head_init(&tmp->addrs); + + return tmp; + + fail_table: + pthread_rwlock_destroy(&tmp->lock); + fail_lock: + free(tmp); + fail_malloc: + return NULL; +} + +void alternate_pff_destroy(struct pff_i * pff_i) +{ + assert(pff_i); + + htable_destroy(pff_i->table); + del_nhops_down(pff_i); + pthread_rwlock_destroy(&pff_i->lock); + free(pff_i); +} + +void alternate_pff_lock(struct pff_i * pff_i) +{ + pthread_rwlock_wrlock(&pff_i->lock); +} + +void alternate_pff_unlock(struct pff_i * pff_i) +{ + pthread_rwlock_unlock(&pff_i->lock); +} + +int alternate_pff_add(struct pff_i * pff_i, + uint64_t addr, + int * fd, + size_t len) +{ + assert(pff_i); + assert(len > 0); + + if (add_to_htable(pff_i, addr, fd, len)) + return -1; + + if (add_addr(pff_i, addr)) { + htable_delete(pff_i->table, addr); + return -1; + } + + return 0; +} + +int alternate_pff_update(struct pff_i * pff_i, + uint64_t addr, + int * fd, + size_t len) +{ + assert(pff_i); + assert(len > 0); + + if (htable_delete(pff_i->table, addr)) + return -1; + + if (add_to_htable(pff_i, addr, fd, len)) + return -1; + + return 0; +} + +int alternate_pff_del(struct pff_i * pff_i, + uint64_t addr) +{ + assert(pff_i); + + del_addr(pff_i, addr); + + if (htable_delete(pff_i->table, addr)) + return -1; + + return 0; +} + +void alternate_pff_flush(struct pff_i * pff_i) +{ + assert(pff_i); + + htable_flush(pff_i->table); + + del_nhops_down(pff_i); + + del_addrs(pff_i); +} + +int alternate_pff_nhop(struct pff_i * pff_i, + uint64_t addr) +{ + int fd = -1; + size_t len; + void * el; + + assert(pff_i); + + pthread_rwlock_rdlock(&pff_i->lock); + + if (htable_lookup(pff_i->table, addr, &el, &len)) { + pthread_rwlock_unlock(&pff_i->lock); + return -1; + } + + fd = *((int *) el); + + pthread_rwlock_unlock(&pff_i->lock); + + return fd; +} + +int alternate_flow_state_change(struct pff_i * pff_i, + int fd, + bool up) +{ + struct list_head * pos = NULL; + size_t len; + void * el; + int * fds; + size_t i; + int tmp; + + assert(pff_i); + + pthread_rwlock_wrlock(&pff_i->lock); + + if (up) { + if (del_nhop_down(pff_i, fd)) { + pthread_rwlock_unlock(&pff_i->lock); + return -1; + } + } else { + if (add_nhop_down(pff_i, fd)) { + pthread_rwlock_unlock(&pff_i->lock); + return -1; + } + } + + list_for_each(pos, &pff_i->addrs) { + struct addr * e = list_entry(pos, struct addr, next); + if (htable_lookup(pff_i->table, e->addr, &el, &len)) { + pthread_rwlock_unlock(&pff_i->lock); + return -1; + } + + fds = (int *) el; + + if (up) { + /* It is using an alternate */ + if (fds[len] == fd && fds[0] != fd) { + for (i = 0 ; i < len; i++) { + /* Found the primary */ + if (fds[i] == fd) { + tmp = fds[0]; + fds[0] = fds[i]; + fds[i] = tmp; + break; + } + } + } + } else { + /* Need to switch to a (different) alternate */ + if (fds[0] == fd) { + for (i = 0 ; i < len; i++) { + /* Usable alternate */ + if (!nhops_down_has(pff_i, fds[i])) { + tmp = fds[0]; + fds[0] = fds[i]; + fds[i] = tmp; + break; + } + } + } + } + } + + pthread_rwlock_unlock(&pff_i->lock); + + return 0; +} diff --git a/src/ipcpd/normal/pol/alternate_pff.h b/src/ipcpd/normal/pol/alternate_pff.h new file mode 100644 index 00000000..8fa2d514 --- /dev/null +++ b/src/ipcpd/normal/pol/alternate_pff.h @@ -0,0 +1,61 @@ +/* + * Ouroboros - Copyright (C) 2016 - 2017 + * + * Policy for PFF with alternate next hops + * + * Dimitri Staessens <dimitri.staessens@ugent.be> + * Sander Vrijders <sander.vrijders@ugent.be> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., http://www.fsf.org/about/contact/. + */ + +#ifndef OUROBOROS_IPCPD_NORMAL_ALTERNATE_PFF_H +#define OUROBOROS_IPCPD_NORMAL_ALTERNATE_PFF_H + +#include "pol-pff-ops.h" + +struct pff_i * alternate_pff_create(void); + +void alternate_pff_destroy(struct pff_i * pff_i); + +void alternate_pff_lock(struct pff_i * pff_i); + +void alternate_pff_unlock(struct pff_i * pff_i); + +int alternate_pff_add(struct pff_i * pff_i, + uint64_t addr, + int * fd, + size_t len); + +int alternate_pff_update(struct pff_i * pff_i, + uint64_t addr, + int * fd, + size_t len); + +int alternate_pff_del(struct pff_i * pff_i, + uint64_t addr); + +void alternate_pff_flush(struct pff_i * pff_i); + +/* Returns fd towards next hop */ +int alternate_pff_nhop(struct pff_i * pff_i, + uint64_t addr); + +int alternate_flow_state_change(struct pff_i * pff_i, + int fd, + bool up); + +struct pol_pff_ops alternate_pff_ops; + +#endif /* OUROBOROS_IPCPD_NORMAL_ALTERNATE_PFF_H */ diff --git a/src/ipcpd/normal/pol/simple_pff.c b/src/ipcpd/normal/pol/simple_pff.c index 28f7aa2e..7af4663c 100644 --- a/src/ipcpd/normal/pol/simple_pff.c +++ b/src/ipcpd/normal/pol/simple_pff.c @@ -109,7 +109,7 @@ int simple_pff_add(struct pff_i * pff_i, *val = fd[0]; - if (htable_insert(pff_i->table, addr, val)) { + if (htable_insert(pff_i->table, addr, val, 1)) { free(val); return -1; } @@ -137,7 +137,7 @@ int simple_pff_update(struct pff_i * pff_i, return -1; } - if (htable_insert(pff_i->table, addr, val)) { + if (htable_insert(pff_i->table, addr, val, 1)) { free(val); return -1; } @@ -166,16 +166,16 @@ void simple_pff_flush(struct pff_i * pff_i) int simple_pff_nhop(struct pff_i * pff_i, uint64_t addr) { - int * j; - int fd = -1; + void * j; + size_t len; + int fd = -1; assert(pff_i); pthread_rwlock_rdlock(&pff_i->lock); - j = (int *) htable_lookup(pff_i->table, addr); - if (j != NULL) - fd = *j; + if (!htable_lookup(pff_i->table, addr, &j, &len)) + fd = *((int *) j); pthread_rwlock_unlock(&pff_i->lock); diff --git a/src/ipcpd/normal/routing.c b/src/ipcpd/normal/routing.c index 47ce3518..afef23a2 100644 --- a/src/ipcpd/normal/routing.c +++ b/src/ipcpd/normal/routing.c @@ -32,7 +32,7 @@ struct pol_routing_ops * r_ops; int routing_init(enum pol_routing pr) { switch (pr) { - case LINK_STATE: + case ROUTING_LINK_STATE: r_ops = &link_state_ops; break; default: diff --git a/src/lib/hashtable.c b/src/lib/hashtable.c index 2aa248ba..d0d46598 100644 --- a/src/lib/hashtable.c +++ b/src/lib/hashtable.c @@ -23,6 +23,7 @@ #include <ouroboros/hashtable.h> #include <ouroboros/list.h> #include <ouroboros/errno.h> +#include <ouroboros/hash.h> #include <assert.h> @@ -30,6 +31,7 @@ struct htable_entry { struct list_head next; uint64_t key; void * val; + size_t len; }; struct htable { @@ -104,16 +106,25 @@ void htable_flush(struct htable * table) } } -static uint64_t hash(uint64_t x) +static uint64_t hash(uint64_t key) { - x = (x ^ (x >> 30)) * UINT64_C(0xbf58476d1ce4e5b9); - x = (x ^ (x >> 27)) * UINT64_C(0x94d049bb133111eb); - x = x ^ (x >> 31); + void * res; + uint64_t ret; + uint8_t keys[4]; - return x; + memcpy(keys, &key, 4); + + mem_hash(HASH_MD5, &res, keys, 4); + + ret = (* (uint64_t *) res); + + free(res); + + return ret; } -static uint64_t calc_key(struct htable * table, uint64_t key) +static uint64_t calc_key(struct htable * table, + uint64_t key) { if (table->hash_key == true) key = hash(key); @@ -121,7 +132,10 @@ static uint64_t calc_key(struct htable * table, uint64_t key) return (key & (table->buckets_size - 1)); } -int htable_insert(struct htable * table, uint64_t key, void * val) +int htable_insert(struct htable * table, + uint64_t key, + void * val, + size_t len) { struct htable_entry * entry; uint64_t lookup_key; @@ -143,6 +157,7 @@ int htable_insert(struct htable * table, uint64_t key, void * val) entry->key = key; entry->val = val; + entry->len = len; list_head_init(&entry->next); list_add(&entry->next, &(table->buckets[lookup_key])); @@ -150,7 +165,10 @@ int htable_insert(struct htable * table, uint64_t key, void * val) return 0; } -void * htable_lookup(struct htable * table, uint64_t key) +int htable_lookup(struct htable * table, + uint64_t key, + void ** val, + size_t * len) { struct htable_entry * entry; struct list_head * pos = NULL; @@ -162,14 +180,18 @@ void * htable_lookup(struct htable * table, uint64_t key) list_for_each(pos, &(table->buckets[lookup_key])) { entry = list_entry(pos, struct htable_entry, next); - if (entry->key == key) - return entry->val; + if (entry->key == key) { + *val = entry->val; + *len = entry->len; + return 0; + } } - return NULL; + return -1; } -int htable_delete(struct htable * table, uint64_t key) +int htable_delete(struct htable * table, + uint64_t key) { struct htable_entry * entry; uint64_t lookup_key; diff --git a/src/lib/tests/hashtable_test.c b/src/lib/tests/hashtable_test.c index 9d5917f4..36f68ebf 100644 --- a/src/lib/tests/hashtable_test.c +++ b/src/lib/tests/hashtable_test.c @@ -30,8 +30,10 @@ int hashtable_test(int argc, char ** argv) { struct htable * table; - int i; - int * j; + int i; + int * j; + void * el; + size_t len; (void) argc; (void) argv; @@ -59,20 +61,20 @@ int hashtable_test(int argc, char ** argv) } *j = i; - if (htable_insert(table, i, (void *) j)) { + if (htable_insert(table, i, (void *) j, 1)) { printf("Failed to insert.\n"); htable_destroy(table); return -1; } } - j = (int *) htable_lookup(table, INT_TEST); - if (j == NULL) { + if (htable_lookup(table, INT_TEST, &el, &len)) { printf("Failed to lookup.\n"); htable_destroy(table); return -1; } + j = (int *) el; if (*j != INT_TEST) { printf("Lookup returned wrong value (%d != %d).\n", INT_TEST, *j); @@ -80,13 +82,13 @@ int hashtable_test(int argc, char ** argv) return -1; } - j = (int *) htable_lookup(table, HASHTABLE_SIZE + INT_TEST); - if (j == NULL) { + if (htable_lookup(table, HASHTABLE_SIZE + INT_TEST, &el, &len)) { printf("Failed to lookup.\n"); htable_destroy(table); return -1; } + j = (int *) el; if (*j != HASHTABLE_SIZE + INT_TEST) { printf("Lookup returned wrong value (%d != %d).\n", INT_TEST, *j); @@ -100,20 +102,19 @@ int hashtable_test(int argc, char ** argv) return -1; } - j = (int *) htable_lookup(table, INT_TEST); - if (j != NULL) { + if (htable_lookup(table, INT_TEST, &el, &len) == 0) { printf("Failed to delete properly.\n"); htable_destroy(table); return -1; } - j = (int *) htable_lookup(table, HASHTABLE_SIZE + INT_TEST); - if (j == NULL) { + if (htable_lookup(table, HASHTABLE_SIZE + INT_TEST, &el, &len)) { printf("Failed to lookup after deletion.\n"); htable_destroy(table); return -1; } + j = (int *) el; if (*j != HASHTABLE_SIZE + INT_TEST) { printf("Lookup returned wrong value (%d != %d).\n", INT_TEST, *j); diff --git a/src/tools/irm/irm_ipcp_bootstrap.c b/src/tools/irm/irm_ipcp_bootstrap.c index 07a0fabb..9812f860 100644 --- a/src/tools/irm/irm_ipcp_bootstrap.c +++ b/src/tools/irm/irm_ipcp_bootstrap.c @@ -33,27 +33,28 @@ #include "irm_ops.h" #include "irm_utils.h" -#define NORMAL "normal" -#define SHIM_UDP "shim-udp" -#define SHIM_ETH_LLC "shim-eth-llc" -#define LOCAL "local" - -#define MD5 "MD5" -#define SHA3_224 "SHA3_224" -#define SHA3_256 "SHA3_256" -#define SHA3_384 "SHA3_384" -#define SHA3_512 "SHA3_512" - -#define DEFAULT_ADDR_SIZE 4 -#define DEFAULT_FD_SIZE 2 -#define DEFAULT_DDNS 0 -#define DEFAULT_ADDR_AUTH FLAT_RANDOM -#define DEFAULT_ROUTING LINK_STATE -#define DEFAULT_PFF SIMPLE_PFF -#define DEFAULT_HASH_ALGO DIR_HASH_SHA3_256 -#define ADDR_AUTH_FLAT "flat" -#define ROUTING_LINK_STATE "link_state" -#define PFF_SIMPLE_PFF "simple_pff" +#define NORMAL "normal" +#define SHIM_UDP "shim-udp" +#define SHIM_ETH_LLC "shim-eth-llc" +#define LOCAL "local" + +#define MD5 "MD5" +#define SHA3_224 "SHA3_224" +#define SHA3_256 "SHA3_256" +#define SHA3_384 "SHA3_384" +#define SHA3_512 "SHA3_512" + +#define DEFAULT_ADDR_SIZE 4 +#define DEFAULT_FD_SIZE 2 +#define DEFAULT_DDNS 0 +#define DEFAULT_ADDR_AUTH ADDR_AUTH_FLAT_RANDOM +#define DEFAULT_ROUTING ROUTING_LINK_STATE +#define DEFAULT_PFF PFF_SIMPLE +#define DEFAULT_HASH_ALGO DIR_HASH_SHA3_256 +#define FLAT_RANDOM_ADDR_AUTH "flat" +#define LINK_STATE_ROUTING "link_state" +#define SIMPLE_PFF "simple" +#define ALTERNATE_PFF "alternate" static void usage(void) { @@ -68,20 +69,23 @@ static void usage(void) " [addr <address size> (default: %d)]\n" " [fd <fd size> (default: %d)]\n" " [ttl (add time to live value in the PCI)]\n" - " [addr_auth <address policy> (default: %s)]\n" - " [routing <routing policy> (default: %s)]\n" - " [pff <pff policy> (default: %s)]\n" + " [addr_auth <ADDRESS_POLICY> (default: %s)]\n" + " [routing <ROUTING_POLICY> (default: %s)]\n" + " [pff [PFF_POLICY] (default: %s)]\n" " [hash [ALGORITHM] (default: %s)]\n" - "where ALGORITHM = {" SHA3_224 " " SHA3_256 " " - SHA3_384 " " SHA3_512 "}\n" + "where ADDRESS_POLICY = {"FLAT_RANDOM_ADDR_AUTH"}\n" + " ROUTING_POLICY = {"LINK_STATE_ROUTING"}\n" + " PFF_POLICY = {" SIMPLE_PFF " " ALTERNATE_PFF "}\n" + " ALGORITHM = {" SHA3_224 " " SHA3_256 " " + SHA3_384 " " SHA3_512 "}\n\n" "if TYPE == " SHIM_UDP "\n" " ip <IP address in dotted notation>\n" " [dns <DDNS IP address in dotted notation>" - " (default: none)]\n" + " (default: none)]\n\n" "if TYPE == " SHIM_ETH_LLC "\n" " if_name <interface name>\n", - DEFAULT_ADDR_SIZE, DEFAULT_FD_SIZE, ADDR_AUTH_FLAT, - ROUTING_LINK_STATE, PFF_SIMPLE_PFF, SHA3_256); + DEFAULT_ADDR_SIZE, DEFAULT_FD_SIZE, FLAT_RANDOM_ADDR_AUTH, + LINK_STATE_ROUTING, SIMPLE_PFF, SHA3_256); } int do_bootstrap_ipcp(int argc, char ** argv) @@ -140,18 +144,20 @@ int do_bootstrap_ipcp(int argc, char ** argv) argc++; argv--; } else if (matches(*argv, "addr_auth") == 0) { - if (strcmp(ADDR_AUTH_FLAT, *(argv + 1)) == 0) - addr_auth_type = FLAT_RANDOM; + if (strcmp(FLAT_RANDOM_ADDR_AUTH, *(argv + 1)) == 0) + addr_auth_type = ADDR_AUTH_FLAT_RANDOM; else goto unknown_param; } else if (matches(*argv, "routing") == 0) { - if (strcmp(ROUTING_LINK_STATE, *(argv + 1)) == 0) - routing_type = LINK_STATE; + if (strcmp(LINK_STATE_ROUTING, *(argv + 1)) == 0) + routing_type = ROUTING_LINK_STATE; else goto unknown_param; } else if (matches(*argv, "pff") == 0) { - if (strcmp(PFF_SIMPLE_PFF, *(argv + 1)) == 0) - pff_type = SIMPLE_PFF; + if (strcmp(SIMPLE_PFF, *(argv + 1)) == 0) + pff_type = PFF_SIMPLE; + else if (strcmp(ALTERNATE_PFF, *(argv + 1)) == 0) + pff_type = PFF_ALTERNATE; else goto unknown_param; } else { |