mka: Get rid of struct ieee802_1x_cp_conf
authorSabrina Dubroca <sd@queasysnail.net>
Fri, 12 Aug 2016 13:07:35 +0000 (15:07 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 28 Aug 2016 18:56:17 +0000 (21:56 +0300)
Instead of copying from kay to a temporary struct, and then from the
struct to the sm, just copy from kay to cp.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
src/pae/ieee802_1x_cp.c
src/pae/ieee802_1x_cp.h
src/pae/ieee802_1x_kay.c
src/pae/ieee802_1x_kay.h

index 43046f5..e294e64 100644 (file)
@@ -184,16 +184,13 @@ SM_STATE(CP, AUTHENTICATED)
 
 SM_STATE(CP, SECURED)
 {
 
 SM_STATE(CP, SECURED)
 {
-       struct ieee802_1x_cp_conf conf;
-
        SM_ENTRY(CP, SECURED);
 
        sm->chgd_server = FALSE;
 
        SM_ENTRY(CP, SECURED);
 
        sm->chgd_server = FALSE;
 
-       ieee802_1x_kay_cp_conf(sm->kay, &conf);
-       sm->protect_frames = conf.protect;
-       sm->replay_protect = conf.replay_protect;
-       sm->validate_frames = conf.validate;
+       sm->protect_frames = sm->kay->macsec_protect;
+       sm->replay_protect = sm->kay->macsec_replay_protect;
+       sm->validate_frames = sm->kay->macsec_validate;
 
        /* NOTE: now no other than default cipher suite (AES-GCM-128) */
        sm->current_cipher_suite = sm->cipher_suite;
 
        /* NOTE: now no other than default cipher suite (AES-GCM-128) */
        sm->current_cipher_suite = sm->cipher_suite;
@@ -426,9 +423,7 @@ SM_STEP(CP)
 /**
  * ieee802_1x_cp_sm_init -
  */
 /**
  * ieee802_1x_cp_sm_init -
  */
-struct ieee802_1x_cp_sm * ieee802_1x_cp_sm_init(
-       struct ieee802_1x_kay *kay,
-       struct ieee802_1x_cp_conf *pcp_conf)
+struct ieee802_1x_cp_sm * ieee802_1x_cp_sm_init(struct ieee802_1x_kay *kay)
 {
        struct ieee802_1x_cp_sm *sm;
 
 {
        struct ieee802_1x_cp_sm *sm;
 
@@ -444,10 +439,10 @@ struct ieee802_1x_cp_sm * ieee802_1x_cp_sm_init(
 
        sm->chgd_server = FALSE;
 
 
        sm->chgd_server = FALSE;
 
-       sm->protect_frames = pcp_conf->protect;
-       sm->validate_frames = pcp_conf->validate;
-       sm->replay_protect = pcp_conf->replay_protect;
-       sm->replay_window = pcp_conf->replay_window;
+       sm->protect_frames = kay->macsec_protect;
+       sm->validate_frames = kay->macsec_validate;
+       sm->replay_protect = kay->macsec_replay_protect;
+       sm->replay_window = kay->macsec_replay_window;
 
        sm->controlled_port_enabled = FALSE;
 
 
        sm->controlled_port_enabled = FALSE;
 
index 4ed63df..695629e 100644 (file)
@@ -16,17 +16,7 @@ struct ieee802_1x_cp_sm;
 struct ieee802_1x_kay;
 struct ieee802_1x_mka_ki;
 
 struct ieee802_1x_kay;
 struct ieee802_1x_mka_ki;
 
-struct ieee802_1x_cp_conf {
-       Boolean protect;
-       Boolean replay_protect;
-       enum validate_frames validate;
-       u32 replay_window;
-};
-
-
-struct ieee802_1x_cp_sm *
-ieee802_1x_cp_sm_init(struct ieee802_1x_kay *kay,
-                     struct ieee802_1x_cp_conf *pcp_conf);
+struct ieee802_1x_cp_sm * ieee802_1x_cp_sm_init(struct ieee802_1x_kay *kay);
 void ieee802_1x_cp_sm_deinit(struct ieee802_1x_cp_sm *sm);
 void ieee802_1x_cp_sm_step(void *cp_ctx);
 void ieee802_1x_cp_connect_pending(void *cp_ctx);
 void ieee802_1x_cp_sm_deinit(struct ieee802_1x_cp_sm *sm);
 void ieee802_1x_cp_sm_step(void *cp_ctx);
 void ieee802_1x_cp_connect_pending(void *cp_ctx);
index 9bb4a94..824288e 100644 (file)
@@ -2828,38 +2828,6 @@ int ieee802_1x_kay_enable_new_info(struct ieee802_1x_kay *kay)
 
 
 /**
 
 
 /**
- * ieee802_1x_kay_cp_conf -
- */
-int ieee802_1x_kay_cp_conf(struct ieee802_1x_kay *kay,
-                          struct ieee802_1x_cp_conf *pconf)
-{
-       pconf->protect = kay->macsec_protect;
-       pconf->replay_protect = kay->macsec_replay_protect;
-       pconf->validate = kay->macsec_validate;
-
-       return 0;
-}
-
-
-/**
- * ieee802_1x_kay_alloc_cp_sm -
- */
-static struct ieee802_1x_cp_sm *
-ieee802_1x_kay_alloc_cp_sm(struct ieee802_1x_kay *kay)
-{
-       struct ieee802_1x_cp_conf conf;
-
-       os_memset(&conf, 0, sizeof(conf));
-       conf.protect = kay->macsec_protect;
-       conf.replay_protect = kay->macsec_replay_protect;
-       conf.validate = kay->macsec_validate;
-       conf.replay_window = kay->macsec_replay_window;
-
-       return ieee802_1x_cp_sm_init(kay, &conf);
-}
-
-
-/**
  * ieee802_1x_kay_mkpdu_sanity_check -
  *     sanity check specified in clause 11.11.2 of IEEE802.1X-2010
  */
  * ieee802_1x_kay_mkpdu_sanity_check -
  *     sanity check specified in clause 11.11.2 of IEEE802.1X-2010
  */
@@ -3178,7 +3146,7 @@ ieee802_1x_kay_init(struct ieee802_1x_kay_ctx *ctx, enum macsec_policy policy,
        wpa_printf(MSG_DEBUG, "KaY: secy init macsec done");
 
        /* init CP */
        wpa_printf(MSG_DEBUG, "KaY: secy init macsec done");
 
        /* init CP */
-       kay->cp = ieee802_1x_kay_alloc_cp_sm(kay);
+       kay->cp = ieee802_1x_cp_sm_init(kay);
        if (kay->cp == NULL) {
                ieee802_1x_kay_deinit(kay);
                return NULL;
        if (kay->cp == NULL) {
                ieee802_1x_kay_deinit(kay);
                return NULL;
index 3f918d6..afbaa33 100644 (file)
@@ -14,7 +14,6 @@
 #include "common/ieee802_1x_defs.h"
 
 struct macsec_init_params;
 #include "common/ieee802_1x_defs.h"
 
 struct macsec_init_params;
-struct ieee802_1x_cp_conf;
 
 #define MI_LEN                 12
 #define MAX_KEY_LEN            32  /* 32 bytes, 256 bits */
 
 #define MI_LEN                 12
 #define MAX_KEY_LEN            32  /* 32 bytes, 256 bits */
@@ -186,7 +185,5 @@ int ieee802_1x_kay_enable_tx_sas(struct ieee802_1x_kay *kay,
 int ieee802_1x_kay_enable_rx_sas(struct ieee802_1x_kay *kay,
                                 struct ieee802_1x_mka_ki *lki);
 int ieee802_1x_kay_enable_new_info(struct ieee802_1x_kay *kay);
 int ieee802_1x_kay_enable_rx_sas(struct ieee802_1x_kay *kay,
                                 struct ieee802_1x_mka_ki *lki);
 int ieee802_1x_kay_enable_new_info(struct ieee802_1x_kay *kay);
-int ieee802_1x_kay_cp_conf(struct ieee802_1x_kay *kay,
-                          struct ieee802_1x_cp_conf *pconf);
 
 #endif /* IEEE802_1X_KAY_H */
 
 #endif /* IEEE802_1X_KAY_H */