diff options
author | Sander Vrijders <[email protected]> | 2016-04-16 11:41:48 +0200 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2016-04-16 11:41:48 +0200 |
commit | 9687ace9a1faf752672774ae49a6428b378fa409 (patch) | |
tree | 046635cd3ca941f0debad37fa0865357b5b62a41 /src/tools/irm | |
parent | 1d5c9ae5c7c77f200e9670bbee714adad983136e (diff) | |
parent | 9906ac98c45530e530d7aa439937aedf526c3508 (diff) | |
download | ouroboros-9687ace9a1faf752672774ae49a6428b378fa409.tar.gz ouroboros-9687ace9a1faf752672774ae49a6428b378fa409.zip |
Merge branch 'be' of bitbucket.org:sandervrijders/ouroboros into be
Diffstat (limited to 'src/tools/irm')
-rw-r--r-- | src/tools/irm/irm_bootstrap_ipcp.c | 112 | ||||
-rw-r--r-- | src/tools/irm/irm_create_ipcp.c | 21 |
2 files changed, 123 insertions, 10 deletions
diff --git a/src/tools/irm/irm_bootstrap_ipcp.c b/src/tools/irm/irm_bootstrap_ipcp.c index 03a913fb..78a09362 100644 --- a/src/tools/irm/irm_bootstrap_ipcp.c +++ b/src/tools/irm/irm_bootstrap_ipcp.c @@ -22,43 +22,141 @@ #include <stdio.h> #include <stdlib.h> +#include <string.h> +#include <arpa/inet.h> + #include <ouroboros/irm.h> -#include <ouroboros/common.h> +#include <ouroboros/dif_config.h> #include "irm_ops.h" #include "irm_utils.h" +#define NORMAL "normal" +#define SHIM_UDP "shim-udp" + +#define DEFAULT_ADDR_SIZE 4 +#define DEFAULT_CEP_ID_SIZE 2 +#define DEFAULT_PDU_LEN_SIZE 2 +#define DEFAULT_QOS_ID_SIZE 1 +#define DEFAULT_SEQ_NO_SIZE 4 +#define DEFAULT_TTL_SIZE 1 +#define DEFAULT_CHK_SIZE 2 +#define DEFAULT_MIN_PDU_SIZE 0 +#define DEFAULT_MAX_PDU_SIZE 9000 + static void usage() { /* FIXME: Add dif_config stuff */ printf("Usage: irm bootstrap_ipcp\n" " ap <application process name>\n" - " [api <application process instance>]\n"); + " [api <application process instance>]\n" + " dif <DIF name>\n" + " type [TYPE]\n\n" + "where TYPE = {" NORMAL " " SHIM_UDP "}\n\n" + "if TYPE == " NORMAL "\n" + " [addr <address size> (default: %d)]\n" + " [cep_id <CEP-id size> (default: %d)]\n" + " [pdu_len <PDU length size> (default: %d)]\n" + " [qos_id <QoS-id size> (default: %d)]\n" + " [seqno <sequence number size> (default: %d)]\n" + " [ttl <time to live size> (default: %d)]\n" + " [chk <checksum size> (default: %d)]\n" + " [min_pdu <minimum PDU size> (default: %d)]\n" + " [max_pdu <maximum PDU size> (default: %d)]\n" + "if TYPE == " SHIM_UDP "\n" + " ip <IP address in dotted notation>\n", + DEFAULT_ADDR_SIZE, DEFAULT_CEP_ID_SIZE, + DEFAULT_PDU_LEN_SIZE, DEFAULT_QOS_ID_SIZE, + DEFAULT_SEQ_NO_SIZE, DEFAULT_TTL_SIZE, + DEFAULT_CHK_SIZE, DEFAULT_MIN_PDU_SIZE, + DEFAULT_MAX_PDU_SIZE); } - int do_bootstrap_ipcp(int argc, char ** argv) { - instance_name_t api = {NULL, 0}; + instance_name_t api = {NULL, 0}; struct dif_config conf; + uint8_t addr_size = DEFAULT_ADDR_SIZE; + uint8_t cep_id_size = DEFAULT_CEP_ID_SIZE; + uint8_t pdu_length_size = DEFAULT_PDU_LEN_SIZE; + uint8_t qos_id_size = DEFAULT_QOS_ID_SIZE; + uint8_t seqno_size = DEFAULT_SEQ_NO_SIZE; + uint8_t ttl_size = DEFAULT_TTL_SIZE; + uint8_t chk_size = DEFAULT_CHK_SIZE; + uint32_t min_pdu_size = DEFAULT_MIN_PDU_SIZE; + uint32_t max_pdu_size = DEFAULT_MAX_PDU_SIZE; + uint32_t ip_addr = 0; + char * ipcp_type = NULL; + char * dif_name = NULL; while (argc > 0) { - if (matches(*argv, "ap") == 0) { + if (matches(*argv, "type") == 0) { + ipcp_type = *(argv + 1); + } else if (matches(*argv, "dif") == 0) { + dif_name = *(argv + 1); + } else if (matches(*argv, "ap") == 0) { api.name = *(argv + 1); } else if (matches(*argv, "api") == 0) { api.id = atoi(*(argv + 1)); + } else if (matches(*argv, "ip") == 0) { + if (inet_pton (AF_INET, *(argv + 1), &ip_addr) != 1) { + usage(); + return -1; + } + } else if (matches(*argv, "addr") == 0) { + addr_size = atoi(*(argv + 1)); + } else if (matches(*argv, "cep_id") == 0) { + cep_id_size = atoi(*(argv + 1)); + } else if (matches(*argv, "pdu_len") == 0) { + pdu_length_size = atoi(*(argv + 1)); + } else if (matches(*argv, "qos_id") == 0) { + qos_id_size = atoi(*(argv + 1)); + } else if (matches(*argv, "seqno") == 0) { + seqno_size = atoi(*(argv + 1)); + } else if (matches(*argv, "ttl") == 0) { + ttl_size = atoi(*(argv + 1)); + } else if (matches(*argv, "chk") == 0) { + chk_size = atoi(*(argv + 1)); + } else if (matches(*argv, "min_pdu") == 0) { + min_pdu_size = atoi(*(argv + 1)); + } else if (matches(*argv, "max_pdu") == 0) { + max_pdu_size = atoi(*(argv + 1)); } else { printf("\"%s\" is unknown, try \"irm " "destroy_ipcp\".\n", *argv); return -1; } - argc -= 2; argv += 2; } - if (api.name == NULL) { + if (api.name == NULL || dif_name == NULL || ipcp_type == NULL) { + usage(); + return -1; + } + + conf.dif_name = dif_name; + + if (strcmp(ipcp_type, NORMAL) == 0) { + conf.type = IPCP_NORMAL; + conf.addr_size = addr_size; + conf.cep_id_size = cep_id_size; + conf.pdu_length_size = pdu_length_size; + conf.qos_id_size = qos_id_size; + conf.seqno_size = seqno_size; + conf.ttl_size = ttl_size; + conf.chk_size = chk_size; + conf.min_pdu_size = min_pdu_size; + conf.max_pdu_size = max_pdu_size; + } else if (strcmp(ipcp_type, SHIM_UDP) == 0) { + conf.type = IPCP_SHIM_UDP; + if (ip_addr == 0) { + usage(); + return -1; + } + conf.ip_addr = ip_addr; + } else { usage(); return -1; } diff --git a/src/tools/irm/irm_create_ipcp.c b/src/tools/irm/irm_create_ipcp.c index 73d20dce..08b55259 100644 --- a/src/tools/irm/irm_create_ipcp.c +++ b/src/tools/irm/irm_create_ipcp.c @@ -20,10 +20,11 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <stdio.h> #include <ouroboros/irm.h> #include <ouroboros/common.h> #include <ouroboros/instance_name.h> + +#include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> @@ -31,18 +32,23 @@ #include "irm_ops.h" #include "irm_utils.h" +#define NORMAL "normal" +#define SHIM_UDP "shim-udp" + static void usage() { printf("Usage: irm create_ipcp\n" " ap <application process name>\n" " [api <application process instance>]\n" - " type <ipc process type>\n"); + " type [TYPE]\n\n" + "where TYPE = {" NORMAL " " SHIM_UDP "}\n"); } int do_create_ipcp(int argc, char ** argv) { char * ipcp_type = NULL; instance_name_t api = {NULL, 0}; + enum ipcp_type type = 0; while (argc > 0) { if (matches(*argv, "type") == 0) { @@ -66,5 +72,14 @@ int do_create_ipcp(int argc, char ** argv) return -1; } - return irm_create_ipcp(&api, ipcp_type); + if (strcmp(ipcp_type, NORMAL) == 0) + type = IPCP_NORMAL; + else if (strcmp(ipcp_type, SHIM_UDP) == 0) + type = IPCP_SHIM_UDP; + else { + usage(); + return -1; + } + + return irm_create_ipcp(&api, type); } |