]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
mka: Pass full structures down to macsec drivers' receive SA ops
authorSabrina Dubroca <sd@queasysnail.net>
Tue, 20 Sep 2016 07:43:09 +0000 (09:43 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 3 Oct 2016 10:26:26 +0000 (13:26 +0300)
Clean up the driver interface by passing pointers to struct receive_sa
down the stack to the {create,enable,disable}_receive_sa() ops, instead
of passing the individual properties of the SA.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
src/drivers/driver.h
src/drivers/driver_macsec_qca.c
src/pae/ieee802_1x_kay.h
src/pae/ieee802_1x_secy_ops.c
wpa_supplicant/driver_i.h
wpa_supplicant/wpas_kay.c

index bb2d1d2497b5a28018d9d931d4b1496f720e14ab..f1915fcafe9fa97e7bf33c78e8894d47807f868d 100644 (file)
@@ -3391,32 +3391,26 @@ struct wpa_driver_ops {
        /**
         * create_receive_sa - create secure association for receive
         * @priv: private driver interface data from init()
-        * @channel: secure channel
-        * @an: association number
-        * @lowest_pn: the lowest packet number can be received
-        * @sak: the secure association key
+        * @sa: secure association
         * Returns: 0 on success, -1 on failure
         */
-       int (*create_receive_sa)(void *priv, u32 channel, u8 an,
-                                u32 lowest_pn, const u8 *sak);
+       int (*create_receive_sa)(void *priv, struct receive_sa *sa);
 
        /**
         * enable_receive_sa - enable the SA for receive
         * @priv: private driver interface data from init()
-        * @channel: secure channel
-        * @an: association number
+        * @sa: secure association
         * Returns: 0 on success, -1 on failure
         */
-       int (*enable_receive_sa)(void *priv, u32 channel, u8 an);
+       int (*enable_receive_sa)(void *priv, struct receive_sa *sa);
 
        /**
         * disable_receive_sa - disable SA for receive
         * @priv: private driver interface data from init()
-        * @channel: secure channel index
-        * @an: association number
+        * @sa: secure association
         * Returns: 0 on success, -1 on failure
         */
-       int (*disable_receive_sa)(void *priv, u32 channel, u8 an);
+       int (*disable_receive_sa)(void *priv, struct receive_sa *sa);
 
        /**
         * get_available_transmit_sc - get available transmit channel
index 9bfc9a474c34264607d6012a80d26c027a8d75f1..2867c318e95e6b317151498c695d3ec35388a777 100644 (file)
@@ -667,49 +667,57 @@ static int macsec_qca_delete_receive_sc(void *priv, u32 channel)
 }
 
 
-static int macsec_qca_create_receive_sa(void *priv, u32 channel, u8 an,
-                                       u32 lowest_pn, const u8 *sak)
+static int macsec_qca_create_receive_sa(void *priv, struct receive_sa *sa)
 {
        struct macsec_qca_data *drv = priv;
        int ret = 0;
        fal_rx_sak_t rx_sak;
        int i = 0;
+       u32 channel = sa->sc->channel;
 
        wpa_printf(MSG_DEBUG, "%s, channel=%d, an=%d, lpn=0x%x",
-                  __func__, channel, an, lowest_pn);
+                  __func__, channel, sa->an, sa->lowest_pn);
 
        os_memset(&rx_sak, 0, sizeof(rx_sak));
        for (i = 0; i < 16; i++)
-               rx_sak.sak[i] = sak[15 - i];
+               rx_sak.sak[i] = sa->pkey->key[15 - i];
 
-       ret += nss_macsec_secy_rx_sa_create(drv->secy_id, channel, an);
-       ret += nss_macsec_secy_rx_sak_set(drv->secy_id, channel, an, &rx_sak);
+       ret += nss_macsec_secy_rx_sa_create(drv->secy_id, channel, sa->an);
+       ret += nss_macsec_secy_rx_sak_set(drv->secy_id, channel, sa->an,
+                                         &rx_sak);
 
        return ret;
 }
 
 
-static int macsec_qca_enable_receive_sa(void *priv, u32 channel, u8 an)
+static int macsec_qca_enable_receive_sa(void *priv, struct receive_sa *sa)
 {
        struct macsec_qca_data *drv = priv;
        int ret = 0;
+       u32 channel = sa->sc->channel;
+
 
-       wpa_printf(MSG_DEBUG, "%s: channel=%d, an=%d", __func__, channel, an);
+       wpa_printf(MSG_DEBUG, "%s: channel=%d, an=%d", __func__, channel,
+                  sa->an);
 
-       ret += nss_macsec_secy_rx_sa_en_set(drv->secy_id, channel, an, TRUE);
+       ret += nss_macsec_secy_rx_sa_en_set(drv->secy_id, channel, sa->an,
+                                           TRUE);
 
        return ret;
 }
 
 
-static int macsec_qca_disable_receive_sa(void *priv, u32 channel, u8 an)
+static int macsec_qca_disable_receive_sa(void *priv, struct receive_sa *sa)
 {
        struct macsec_qca_data *drv = priv;
        int ret = 0;
+       u32 channel = sa->sc->channel;
 
-       wpa_printf(MSG_DEBUG, "%s: channel=%d, an=%d", __func__, channel, an);
+       wpa_printf(MSG_DEBUG, "%s: channel=%d, an=%d", __func__, channel,
+                  sa->an);
 
-       ret += nss_macsec_secy_rx_sa_en_set(drv->secy_id, channel, an, FALSE);
+       ret += nss_macsec_secy_rx_sa_en_set(drv->secy_id, channel, sa->an,
+                                           FALSE);
 
        return ret;
 }
index 36a7bd6871caff1fce645c02f21247c675e6640e..8ee5860b3a59046b4d622cc8d6be77e46aa6e697 100644 (file)
@@ -151,10 +151,9 @@ struct ieee802_1x_kay_ctx {
                                 enum validate_frames vf,
                                 enum confidentiality_offset co);
        int (*delete_receive_sc)(void *ctx, u32 channel);
-       int (*create_receive_sa)(void *ctx, u32 channel, u8 an, u32 lowest_pn,
-                                const u8 *sak);
-       int (*enable_receive_sa)(void *ctx, u32 channel, u8 an);
-       int (*disable_receive_sa)(void *ctx, u32 channel, u8 an);
+       int (*create_receive_sa)(void *ctx, struct receive_sa *sa);
+       int (*enable_receive_sa)(void *ctx, struct receive_sa *sa);
+       int (*disable_receive_sa)(void *ctx, struct receive_sa *sa);
        int (*get_available_transmit_sc)(void *ctx, u32 *channel);
        int (*create_transmit_sc)(void *ctx, u32 channel,
                                  const struct ieee802_1x_mka_sci *sci,
index 8c31ca95b7456d7870c5857419b0c590a174211a..fb376df1c8bc7dbcd00932169fd3da96ae610ef1 100644 (file)
@@ -253,8 +253,7 @@ int secy_create_receive_sa(struct ieee802_1x_kay *kay, struct receive_sa *rxsa)
                return -1;
        }
 
-       return ops->create_receive_sa(ops->ctx, rxsa->sc->channel, rxsa->an,
-                                     rxsa->lowest_pn, rxsa->pkey->key);
+       return ops->create_receive_sa(ops->ctx, rxsa);
 }
 
 
@@ -276,7 +275,7 @@ int secy_enable_receive_sa(struct ieee802_1x_kay *kay, struct receive_sa *rxsa)
 
        rxsa->enable_receive = TRUE;
 
-       return ops->enable_receive_sa(ops->ctx, rxsa->sc->channel, rxsa->an);
+       return ops->enable_receive_sa(ops->ctx, rxsa);
 }
 
 
@@ -298,7 +297,7 @@ int secy_disable_receive_sa(struct ieee802_1x_kay *kay, struct receive_sa *rxsa)
 
        rxsa->enable_receive = FALSE;
 
-       return ops->disable_receive_sa(ops->ctx, rxsa->sc->channel, rxsa->an);
+       return ops->disable_receive_sa(ops->ctx, rxsa);
 }
 
 
index e2c2bd762fb52fd02667737be6433698c9cce503..666798be404f21bd3c40ffcdaa37eccbb6b2320f 100644 (file)
@@ -802,29 +802,27 @@ static inline int wpa_drv_delete_receive_sc(struct wpa_supplicant *wpa_s,
 }
 
 static inline int wpa_drv_create_receive_sa(struct wpa_supplicant *wpa_s,
-                                           u32 channel, u8 an,
-                                           u32 lowest_pn, const u8 *sak)
+                                           struct receive_sa *sa)
 {
        if (!wpa_s->driver->create_receive_sa)
                return -1;
-       return wpa_s->driver->create_receive_sa(wpa_s->drv_priv, channel, an,
-                                               lowest_pn, sak);
+       return wpa_s->driver->create_receive_sa(wpa_s->drv_priv, sa);
 }
 
 static inline int wpa_drv_enable_receive_sa(struct wpa_supplicant *wpa_s,
-                                           u32 channel, u8 an)
+                                           struct receive_sa *sa)
 {
        if (!wpa_s->driver->enable_receive_sa)
                return -1;
-       return wpa_s->driver->enable_receive_sa(wpa_s->drv_priv, channel, an);
+       return wpa_s->driver->enable_receive_sa(wpa_s->drv_priv, sa);
 }
 
 static inline int wpa_drv_disable_receive_sa(struct wpa_supplicant *wpa_s,
-                                            u32 channel, u8 an)
+                                            struct receive_sa *sa)
 {
        if (!wpa_s->driver->disable_receive_sa)
                return -1;
-       return wpa_s->driver->disable_receive_sa(wpa_s->drv_priv, channel, an);
+       return wpa_s->driver->disable_receive_sa(wpa_s->drv_priv, sa);
 }
 
 static inline int
index 4b74112b1899a80aab74044fa7e9bfef2e844aaa..344c59e53d5dee8069e54959690884f0de6eb0f0 100644 (file)
@@ -117,22 +117,21 @@ static int wpas_delete_receive_sc(void *wpa_s, u32 channel)
 }
 
 
-static int wpas_create_receive_sa(void *wpa_s, u32 channel, u8 an,
-                                 u32 lowest_pn, const u8 *sak)
+static int wpas_create_receive_sa(void *wpa_s, struct receive_sa *sa)
 {
-       return wpa_drv_create_receive_sa(wpa_s, channel, an, lowest_pn, sak);
+       return wpa_drv_create_receive_sa(wpa_s, sa);
 }
 
 
-static int wpas_enable_receive_sa(void *wpa_s, u32 channel, u8 an)
+static int wpas_enable_receive_sa(void *wpa_s, struct receive_sa *sa)
 {
-       return wpa_drv_enable_receive_sa(wpa_s, channel, an);
+       return wpa_drv_enable_receive_sa(wpa_s, sa);
 }
 
 
-static int wpas_disable_receive_sa(void *wpa_s, u32 channel, u8 an)
+static int wpas_disable_receive_sa(void *wpa_s, struct receive_sa *sa)
 {
-       return wpa_drv_disable_receive_sa(wpa_s, channel, an);
+       return wpa_drv_disable_receive_sa(wpa_s, sa);
 }