diff mbox

[5/8] mka: pass full structures down to macsec drivers' receive SC ops

Message ID 2bafb7212eb90919a09ff0f3ea3fe356b6ad0cae.1474298427.git.sd@queasysnail.net
State Changes Requested
Headers show

Commit Message

Sabrina Dubroca Sept. 20, 2016, 7:43 a.m. UTC
Clean up the driver interface by passing pointers to struct receive_sc
down the stack to the {create,delete}_recevie_sc ops, instead
of passing the individual properties of the SC.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
---
 src/drivers/driver.h            | 12 +++++-------
 src/drivers/driver_macsec_qca.c |  9 ++++++---
 src/pae/ieee802_1x_kay.h        |  5 ++---
 src/pae/ieee802_1x_secy_ops.c   |  5 ++---
 wpa_supplicant/driver_i.h       | 12 +++++-------
 wpa_supplicant/wpas_kay.c       | 11 ++++-------
 6 files changed, 24 insertions(+), 30 deletions(-)

Comments

Jouni Malinen Oct. 3, 2016, 10:20 a.m. UTC | #1
On Tue, Sep 20, 2016 at 09:43:08AM +0200, Sabrina Dubroca wrote:
> Clean up the driver interface by passing pointers to struct receive_sc
> down the stack to the {create,delete}_recevie_sc ops, instead
> of passing the individual properties of the SC.

This has the same issue with conf_offset enum vs. int:

> diff --git a/src/drivers/driver.h b/src/drivers/driver.h
> -	int (*create_receive_sc)(void *priv, u32 channel, const u8 *sci_addr,
> -				 u16 sci_port, unsigned int conf_offset,
> +	int (*create_receive_sc)(void *priv, struct receive_sc *sc,
> +				 enum confidentiality_offset conf_offset,
>  				 int validation);

> diff --git a/src/drivers/driver_macsec_qca.c b/src/drivers/driver_macsec_qca.c
> -static int macsec_qca_create_receive_sc(void *priv, u32 channel,
> -					const u8 *sci_addr, u16 sci_port,
> +static int macsec_qca_create_receive_sc(void *priv, struct receive_sc *sc,
>  					unsigned int conf_offset,
>  					int validation)

> diff --git a/wpa_supplicant/wpas_kay.c b/wpa_supplicant/wpas_kay.c

> -static int wpas_create_receive_sc(void *wpa_s, u32 channel,
> -				  struct ieee802_1x_mka_sci *sci,
> +static int wpas_create_receive_sc(void *wpa_s, struct receive_sc *sc,
>  				  enum validate_frames vf,
>  				  enum confidentiality_offset co)
>  {
> -	return wpa_drv_create_receive_sc(wpa_s, channel, sci->addr,
> -					 be_to_host16(sci->port),
> -					 conf_offset_val(co), vf);
> +	return wpa_drv_create_receive_sc(wpa_s, sc, conf_offset_val(co), vf);
>  }
diff mbox

Patch

diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index d015b73a4ad0..b21714448e92 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -3368,25 +3368,23 @@  struct wpa_driver_ops {
 	/**
 	 * create_receive_sc - create secure channel for receiving
 	 * @priv: Private driver interface data
-	 * @channel: secure channel
-	 * @sci_addr: secure channel identifier - address
-	 * @sci_port: secure channel identifier - port
+	 * @sc: secure channel
 	 * @conf_offset: confidentiality offset (0, 30, or 50)
 	 * @validation: frame validation policy (0 = Disabled, 1 = Checked,
 	 *	2 = Strict)
 	 * Returns: 0 on success, -1 on failure (or if not supported)
 	 */
-	int (*create_receive_sc)(void *priv, u32 channel, const u8 *sci_addr,
-				 u16 sci_port, unsigned int conf_offset,
+	int (*create_receive_sc)(void *priv, struct receive_sc *sc,
+				 enum confidentiality_offset conf_offset,
 				 int validation);
 
 	/**
 	 * delete_receive_sc - delete secure connection for receiving
 	 * @priv: private driver interface data from init()
-	 * @channel: secure channel
+	 * @sc: secure channel
 	 * Returns: 0 on success, -1 on failure
 	 */
-	int (*delete_receive_sc)(void *priv, u32 channel);
+	int (*delete_receive_sc)(void *priv, struct receive_sc *sc);
 
 	/**
 	 * create_receive_sa - create secure association for receive
diff --git a/src/drivers/driver_macsec_qca.c b/src/drivers/driver_macsec_qca.c
index c63f78780f6f..96430acd9670 100644
--- a/src/drivers/driver_macsec_qca.c
+++ b/src/drivers/driver_macsec_qca.c
@@ -602,8 +602,7 @@  static int macsec_qca_get_available_receive_sc(void *priv, u32 *channel)
 }
 
 
-static int macsec_qca_create_receive_sc(void *priv, u32 channel,
-					const u8 *sci_addr, u16 sci_port,
+static int macsec_qca_create_receive_sc(void *priv, struct receive_sc *sc,
 					unsigned int conf_offset,
 					int validation)
 {
@@ -612,6 +611,9 @@  static int macsec_qca_create_receive_sc(void *priv, u32 channel,
 	fal_rx_prc_lut_t entry;
 	fal_rx_sc_validate_frame_e vf;
 	enum validate_frames validate_frames = validation;
+	u32 channel = sc->channel;
+	const u8 *sci_addr = sc->sci.addr;
+	u16 sci_port = be_to_host16(sc->sci.port);
 
 	wpa_printf(MSG_DEBUG, "%s: channel=%d", __func__, channel);
 
@@ -650,11 +652,12 @@  static int macsec_qca_create_receive_sc(void *priv, u32 channel,
 }
 
 
-static int macsec_qca_delete_receive_sc(void *priv, u32 channel)
+static int macsec_qca_delete_receive_sc(void *priv, struct receive_sc *sc)
 {
 	struct macsec_qca_data *drv = priv;
 	int ret = 0;
 	fal_rx_prc_lut_t entry;
+	u32 channel = sc->channel;
 
 	wpa_printf(MSG_DEBUG, "%s: channel=%d", __func__, channel);
 
diff --git a/src/pae/ieee802_1x_kay.h b/src/pae/ieee802_1x_kay.h
index 95b55dbf4192..d1404ebc9129 100644
--- a/src/pae/ieee802_1x_kay.h
+++ b/src/pae/ieee802_1x_kay.h
@@ -146,15 +146,14 @@  struct ieee802_1x_kay_ctx {
 	int (*get_transmit_next_pn)(void *ctx, struct transmit_sa *sa);
 	int (*set_transmit_next_pn)(void *ctx, struct transmit_sa *sa);
 	int (*get_available_receive_sc)(void *ctx, u32 *channel);
-	int (*create_receive_sc)(void *ctx, u32 channel,
-				 struct ieee802_1x_mka_sci *sci,
+	int (*create_receive_sc)(void *ctx, struct receive_sc *sc,
 				 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 (*delete_receive_sc)(void *ctx, struct receive_sc *sc);
 	int (*get_available_transmit_sc)(void *ctx, u32 *channel);
 	int (*create_transmit_sc)(void *ctx, struct transmit_sc *sc,
 				  enum confidentiality_offset co);
diff --git a/src/pae/ieee802_1x_secy_ops.c b/src/pae/ieee802_1x_secy_ops.c
index ff7700adcb78..5277894aec52 100644
--- a/src/pae/ieee802_1x_secy_ops.c
+++ b/src/pae/ieee802_1x_secy_ops.c
@@ -212,8 +212,7 @@  int secy_create_receive_sc(struct ieee802_1x_kay *kay, struct receive_sc *rxsc)
 		return -1;
 	}
 
-	return ops->create_receive_sc(ops->ctx, rxsc->channel, &rxsc->sci,
-				      kay->vf, kay->co);
+	return ops->create_receive_sc(ops->ctx, rxsc, kay->vf, kay->co);
 }
 
 
@@ -233,7 +232,7 @@  int secy_delete_receive_sc(struct ieee802_1x_kay *kay, struct receive_sc *rxsc)
 		return -1;
 	}
 
-	return ops->delete_receive_sc(ops->ctx, rxsc->channel);
+	return ops->delete_receive_sc(ops->ctx, rxsc);
 }
 
 
diff --git a/wpa_supplicant/driver_i.h b/wpa_supplicant/driver_i.h
index 2b6851b3e110..45c13f367dc3 100644
--- a/wpa_supplicant/driver_i.h
+++ b/wpa_supplicant/driver_i.h
@@ -782,23 +782,21 @@  static inline int wpa_drv_get_available_receive_sc(struct wpa_supplicant *wpa_s,
 }
 
 static inline int
-wpa_drv_create_receive_sc(struct wpa_supplicant *wpa_s, u32 channel,
-			  const u8 *sci_addr, u16 sci_port,
+wpa_drv_create_receive_sc(struct wpa_supplicant *wpa_s, struct receive_sc *sc,
 			  unsigned int conf_offset, int validation)
 {
 	if (!wpa_s->driver->create_receive_sc)
 		return -1;
-	return wpa_s->driver->create_receive_sc(wpa_s->drv_priv, channel,
-						sci_addr, sci_port, conf_offset,
-						validation);
+	return wpa_s->driver->create_receive_sc(wpa_s->drv_priv, sc,
+						conf_offset, validation);
 }
 
 static inline int wpa_drv_delete_receive_sc(struct wpa_supplicant *wpa_s,
-					    u32 channel)
+					    struct receive_sc *sc)
 {
 	if (!wpa_s->driver->delete_receive_sc)
 		return -1;
-	return wpa_s->driver->delete_receive_sc(wpa_s->drv_priv, channel);
+	return wpa_s->driver->delete_receive_sc(wpa_s->drv_priv, sc);
 }
 
 static inline int wpa_drv_create_receive_sa(struct wpa_supplicant *wpa_s,
diff --git a/wpa_supplicant/wpas_kay.c b/wpa_supplicant/wpas_kay.c
index 86f2cc31aaf8..0b027a9b233c 100644
--- a/wpa_supplicant/wpas_kay.c
+++ b/wpa_supplicant/wpas_kay.c
@@ -100,20 +100,17 @@  static unsigned int conf_offset_val(enum confidentiality_offset co)
 }
 
 
-static int wpas_create_receive_sc(void *wpa_s, u32 channel,
-				  struct ieee802_1x_mka_sci *sci,
+static int wpas_create_receive_sc(void *wpa_s, struct receive_sc *sc,
 				  enum validate_frames vf,
 				  enum confidentiality_offset co)
 {
-	return wpa_drv_create_receive_sc(wpa_s, channel, sci->addr,
-					 be_to_host16(sci->port),
-					 conf_offset_val(co), vf);
+	return wpa_drv_create_receive_sc(wpa_s, sc, conf_offset_val(co), vf);
 }
 
 
-static int wpas_delete_receive_sc(void *wpa_s, u32 channel)
+static int wpas_delete_receive_sc(void *wpa_s, struct receive_sc *sc)
 {
-	return wpa_drv_delete_receive_sc(wpa_s, channel);
+	return wpa_drv_delete_receive_sc(wpa_s, sc);
 }