summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cleopatre/application/libspid/inc/defs.h2
-rw-r--r--cleopatre/application/libspid/inc/label.h3
-rw-r--r--cleopatre/devkit/plcd/inc/plcd_ctx.h10
-rw-r--r--cleopatre/devkit/plcd/src/plcd_files.c23
4 files changed, 34 insertions, 4 deletions
diff --git a/cleopatre/application/libspid/inc/defs.h b/cleopatre/application/libspid/inc/defs.h
index 6646753c22..c18155466d 100644
--- a/cleopatre/application/libspid/inc/defs.h
+++ b/cleopatre/application/libspid/inc/defs.h
@@ -63,6 +63,8 @@
/** Human-Friendly IDentifiers string maximum length (in bytes) */
#define LIBSPID_HPAV_CONF_HFID_MAX_LEN 64
+#define LIBSPID_HPAV_CONF_FORCE_ROLE_MAX_LEN 5
+
/* LIBSPID_HPAV_INFO_PATH */
/** PLC stack status string maximum length */
#define LIBSPID_HPAV_INFO_STATUS_MAX_LEN 16
diff --git a/cleopatre/application/libspid/inc/label.h b/cleopatre/application/libspid/inc/label.h
index 904448adf1..a8ecc02404 100644
--- a/cleopatre/application/libspid/inc/label.h
+++ b/cleopatre/application/libspid/inc/label.h
@@ -23,9 +23,12 @@
#define LIBSPID_HPAV_CONF_LABEL_SL "SL" /* security level */
#define LIBSPID_HPAV_CONF_LABEL_USER_HFID "USER_HFID" /* user human friendly identifier */
#define LIBSPID_HPAV_CONF_LABEL_AVLN_HFID "AVLN_HFID" /* AVLN friendly identifer */
+#define LIBSPID_HPAV_CONF_LABEL_FORCE_ROLE "FORCE_ROLE"
#define LIBSPID_HPAV_CONF_VALUE_SL_SC "sc" /* simple connect */
#define LIBSPID_HPAV_CONF_VALUE_SL_HS "hs" /* high security */
+#define LIBSPID_HPAV_CONF_VALUE_FORCE_ROLE_CCO "cco"
+#define LIBSPID_HPAV_CONF_VALUE_FORCE_ROLE_STA "sta"
/* LIBSPID_HPAV_INFO_PATH */
#define LIBSPID_HPAV_INFO_LABEL_STATUS "STATUS"
diff --git a/cleopatre/devkit/plcd/inc/plcd_ctx.h b/cleopatre/devkit/plcd/inc/plcd_ctx.h
index 2f7ec078fd..73fef9bac8 100644
--- a/cleopatre/devkit/plcd/inc/plcd_ctx.h
+++ b/cleopatre/devkit/plcd/inc/plcd_ctx.h
@@ -89,6 +89,14 @@ typedef struct
char tonemask[192];
} plcd_nvram_t;
+typedef enum
+{
+ /* NONE is set to 0 , for easy initialisation. */
+ PLCD_FORCE_ROLE_NONE = 0,
+ PLCD_FORCE_ROLE_CCO,
+ PLCD_FORCE_ROLE_STA,
+} plcd_force_role_t;
+
typedef struct
{
/* CCo preference */
@@ -105,6 +113,8 @@ typedef struct
char user_hfid[LIBSPID_HPAV_CONF_HFID_MAX_LEN];
/* AVLN HFID value */
char avln_hfid[LIBSPID_HPAV_CONF_HFID_MAX_LEN];
+
+ plcd_force_role_t force_role;
} plcd_hpav_conf_t;
typedef struct
diff --git a/cleopatre/devkit/plcd/src/plcd_files.c b/cleopatre/devkit/plcd/src/plcd_files.c
index 0f834726a1..d877bc47c1 100644
--- a/cleopatre/devkit/plcd/src/plcd_files.c
+++ b/cleopatre/devkit/plcd/src/plcd_files.c
@@ -23,12 +23,14 @@ plcd_files_read_hpavconf (plcd_ctx_t *ctx)
{
char is_cco_preferred_str[LIBSPID_BOOLEAN_STR_MAX_LEN];
char was_cco_str[LIBSPID_BOOLEAN_STR_MAX_LEN];
+ char force_role_str[LIBSPID_HPAV_CONF_FORCE_ROLE_MAX_LEN];
libspid_error_t libspid_ret;
PLCD_ASSERT (ctx);
memset (is_cco_preferred_str, 0, sizeof (is_cco_preferred_str));
memset (was_cco_str, 0, sizeof (was_cco_str));
+ memset (force_role_str, 0, sizeof (force_role_str));
/* Only NMK item is mandatory, other are optionals.
* There is no default value possible. */
@@ -46,14 +48,15 @@ plcd_files_read_hpavconf (plcd_ctx_t *ctx)
/* Optional items.
* Be careful, amount of labels, values and lens must be sync. */
-#define PLCD_HPAV_CONF_NB_ITEM 6
+#define PLCD_HPAV_CONF_NB_ITEM 7
const char * const hpav_conf_labels[PLCD_HPAV_CONF_NB_ITEM] = {
LIBSPID_HPAV_CONF_LABEL_CCO_PREFERRED,
LIBSPID_HPAV_CONF_LABEL_WAS_CCO,
LIBSPID_HPAV_CONF_LABEL_NID,
LIBSPID_HPAV_CONF_LABEL_SL,
LIBSPID_HPAV_CONF_LABEL_USER_HFID,
- LIBSPID_HPAV_CONF_LABEL_AVLN_HFID
+ LIBSPID_HPAV_CONF_LABEL_AVLN_HFID,
+ LIBSPID_HPAV_CONF_LABEL_FORCE_ROLE
};
char *hpav_conf_values[PLCD_HPAV_CONF_NB_ITEM] = {
is_cco_preferred_str,
@@ -61,7 +64,8 @@ plcd_files_read_hpavconf (plcd_ctx_t *ctx)
ctx->hpav_conf.nid_str,
ctx->hpav_conf.sl_str,
ctx->hpav_conf.user_hfid,
- ctx->hpav_conf.avln_hfid
+ ctx->hpav_conf.avln_hfid,
+ force_role_str
};
const int hpav_conf_len[PLCD_HPAV_CONF_NB_ITEM] = {
LIBSPID_BOOLEAN_STR_MAX_LEN,
@@ -69,7 +73,8 @@ plcd_files_read_hpavconf (plcd_ctx_t *ctx)
LIBSPID_HPAV_CONF_NID_STR_LEN,
LIBSPID_HPAV_CONF_SL_STR_MAX_LEN,
LIBSPID_HPAV_CONF_HFID_MAX_LEN,
- LIBSPID_HPAV_CONF_HFID_MAX_LEN
+ LIBSPID_HPAV_CONF_HFID_MAX_LEN,
+ LIBSPID_HPAV_CONF_FORCE_ROLE_MAX_LEN
};
libspid_ret = libspid_config_read_items (
@@ -102,6 +107,16 @@ plcd_files_read_hpavconf (plcd_ctx_t *ctx)
/* No default value for user_hfid and avln_hfid. */
+ /* Set force_role. Convert libspid string result to plcd enum value. */
+ if (!strcmp (LIBSPID_HPAV_CONF_VALUE_FORCE_ROLE_CCO,
+ force_role_str))
+ ctx->hpav_conf.force_role = PLCD_FORCE_ROLE_CCO;
+ else if (!strcmp (LIBSPID_HPAV_CONF_VALUE_FORCE_ROLE_STA,
+ force_role_str))
+ ctx->hpav_conf.force_role = PLCD_FORCE_ROLE_STA;
+ else
+ ctx->hpav_conf.force_role = PLCD_FORCE_ROLE_NONE;
+
return 0;
}