Commit changes to allow a default server and to improve peering config.
[trust_router.git] / include / tr_config.h
1 /*
2  * Copyright (c) 2012, JANET(UK)
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * 3. Neither the name of JANET(UK) nor the names of its contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31  * OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  */
34
35 #ifndef TR_CONFIG_H
36 #define TR_CONFIG_H
37
38 #include <stdio.h>
39 #include <dirent.h>
40 #include <jansson.h>
41
42 #include <tr.h>
43 #include <tr_rp.h>
44 #include <tr_idp.h>
45 #include <tr_comm.h>
46
47 #define TR_DEFAULT_MAX_TREE_DEPTH 12
48 #define TR_DEFAULT_TR_PORT 12308
49 #define TR_DEFAULT_TIDS_PORT 12309
50
51 typedef enum tr_cfg_rc {
52   TR_CFG_SUCCESS = 0,   /* No error */
53   TR_CFG_ERROR,         /* General processing error */
54   TR_CFG_BAD_PARAMS,    /* Bad parameters passed to tr_config function */
55   TR_CFG_NOPARSE,       /* Parsing error */
56   TR_CFG_NOMEM          /* Memory allocation error */
57 } TR_CFG_RC;
58
59 typedef struct tr_cfg_internal {
60   unsigned int max_tree_depth;
61   unsigned int tids_port;
62   const char *hostname;
63 } TR_CFG_INTERNAL;
64
65 typedef struct tr_cfg {
66   TR_CFG_INTERNAL *internal;            /* internal trust router config */
67   TR_IDP_REALM *idp_realms;             /* locally associated IDP Realms */
68   TR_RP_CLIENT *rp_clients;             /* locally associated RP Clients */
69   TR_COMM *comms;                       /* locally-known communities */
70   TR_AAA_SERVER *default_servers;       /* default server list */
71   /* TBD -- Global Filters */
72   /* TBD -- Trust Router Peers */
73   /* TBD -- Trust Links */
74 } TR_CFG;
75
76 int tr_find_config_files (struct dirent ***cfg_files);
77 TR_CFG_RC tr_parse_config (TR_INSTANCE *tr, struct dirent **cfg_files);
78 TR_CFG_RC tr_apply_new_config (TR_INSTANCE *tr);
79 TR_CFG_RC tr_cfg_validate (TR_CFG *trc);
80 void tr_cfg_free(TR_CFG *cfg);
81 void tr_print_config(FILE *stream, TR_CFG *cfg);
82
83 TR_IDP_REALM *tr_cfg_find_idp (TR_CFG *tr_cfg, TR_NAME *idp_id, TR_CFG_RC *rc);
84 TR_RP_CLIENT *tr_cfg_find_rp (TR_CFG *tr_cfg, TR_NAME *rp_gss, TR_CFG_RC *rc);
85 TR_RP_CLIENT *tr_rp_client_lookup(TR_INSTANCE *tr, TR_NAME *gss_name);
86
87 #endif