MACsec: Add driver_ops

This defines new driver_ops to be used with MACsec.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Hu Wang 2014-03-25 21:39:02 +02:00 committed by Jouni Malinen
parent 4e9528cce3
commit 7baec808ef
2 changed files with 401 additions and 0 deletions

View file

@ -1305,6 +1305,15 @@ enum tdls_peer_capability {
TDLS_PEER_WMM = BIT(2), TDLS_PEER_WMM = BIT(2),
}; };
#ifdef CONFIG_MACSEC
struct macsec_init_params {
Boolean always_include_sci;
Boolean use_es;
Boolean use_scb;
};
#endif /* CONFIG_MACSEC */
/** /**
* struct wpa_driver_ops - Driver interface API definition * struct wpa_driver_ops - Driver interface API definition
* *
@ -2786,6 +2795,203 @@ struct wpa_driver_ops {
* Returns: Length of written status information or -1 on failure * Returns: Length of written status information or -1 on failure
*/ */
int (*status)(void *priv, char *buf, size_t buflen); int (*status)(void *priv, char *buf, size_t buflen);
#ifdef CONFIG_MACSEC
int (*macsec_init)(void *priv, struct macsec_init_params *params);
int (*macsec_deinit)(void *priv);
/**
* enable_protect_frames - Set protect frames status
* @priv: Private driver interface data
* @enabled: TRUE = protect frames enabled
* FALSE = protect frames disabled
* Returns: 0 on success, -1 on failure (or if not supported)
*/
int (*enable_protect_frames)(void *priv, Boolean enabled);
/**
* set_replay_protect - Set replay protect status and window size
* @priv: Private driver interface data
* @enabled: TRUE = replay protect enabled
* FALSE = replay protect disabled
* @window: replay window size, valid only when replay protect enabled
* Returns: 0 on success, -1 on failure (or if not supported)
*/
int (*set_replay_protect)(void *priv, Boolean enabled, u32 window);
/**
* set_current_cipher_suite - Set current cipher suite
* @priv: Private driver interface data
* @cs: EUI64 identifier
* @cs_len: Length of the cs buffer in octets
* Returns: 0 on success, -1 on failure (or if not supported)
*/
int (*set_current_cipher_suite)(void *priv, const u8 *cs,
size_t cs_len);
/**
* enable_controlled_port - Set controlled port status
* @priv: Private driver interface data
* @enabled: TRUE = controlled port enabled
* FALSE = controlled port disabled
* Returns: 0 on success, -1 on failure (or if not supported)
*/
int (*enable_controlled_port)(void *priv, Boolean enabled);
/**
* get_receive_lowest_pn - Get receive lowest pn
* @priv: Private driver interface data
* @channel: secure channel
* @an: association number
* @lowest_pn: lowest accept pn
* Returns: 0 on success, -1 on failure (or if not supported)
*/
int (*get_receive_lowest_pn)(void *priv, u32 channel, u8 an,
u32 *lowest_pn);
/**
* get_transmit_next_pn - Get transmit next pn
* @priv: Private driver interface data
* @channel: secure channel
* @an: association number
* @next_pn: next pn
* Returns: 0 on success, -1 on failure (or if not supported)
*/
int (*get_transmit_next_pn)(void *priv, u32 channel, u8 an,
u32 *next_pn);
/**
* set_transmit_next_pn - Set transmit next pn
* @priv: Private driver interface data
* @channel: secure channel
* @an: association number
* @next_pn: next pn
* Returns: 0 on success, -1 on failure (or if not supported)
*/
int (*set_transmit_next_pn)(void *priv, u32 channel, u8 an,
u32 next_pn);
/**
* get_available_receive_sc - get available receive channel
* @priv: Private driver interface data
* @channel: secure channel
* Returns: 0 on success, -1 on failure (or if not supported)
*/
int (*get_available_receive_sc)(void *priv, u32 *channel);
/**
* 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
* @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 validation);
/**
* delete_receive_sc - delete secure connection for receiving
* @priv: private driver interface data from init()
* @channel: secure channel
* Returns: 0 on success, -1 on failure
*/
int (*delete_receive_sc)(void *priv, u32 channel);
/**
* 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
* Returns: 0 on success, -1 on failure
*/
int (*create_receive_sa)(void *priv, u32 channel, u8 an,
u32 lowest_pn, const u8 *sak);
/**
* enable_receive_sa - enable the SA for receive
* @priv: private driver interface data from init()
* @channel: secure channel
* @an: association number
* Returns: 0 on success, -1 on failure
*/
int (*enable_receive_sa)(void *priv, u32 channel, u8 an);
/**
* disable_receive_sa - disable SA for receive
* @priv: private driver interface data from init()
* @channel: secure channel index
* @an: association number
* Returns: 0 on success, -1 on failure
*/
int (*disable_receive_sa)(void *priv, u32 channel, u8 an);
/**
* get_available_transmit_sc - get available transmit channel
* @priv: Private driver interface data
* @channel: secure channel
* Returns: 0 on success, -1 on failure (or if not supported)
*/
int (*get_available_transmit_sc)(void *priv, u32 *channel);
/**
* create_transmit_sc - create secure connection for transmit
* @priv: private driver interface data from init()
* @channel: secure channel
* @sci_addr: secure channel identifier - address
* @sci_port: secure channel identifier - port
* Returns: 0 on success, -1 on failure
*/
int (*create_transmit_sc)(void *priv, u32 channel, const u8 *sci_addr,
u16 sci_port, unsigned int conf_offset);
/**
* delete_transmit_sc - delete secure connection for transmit
* @priv: private driver interface data from init()
* @channel: secure channel
* Returns: 0 on success, -1 on failure
*/
int (*delete_transmit_sc)(void *priv, u32 channel);
/**
* create_transmit_sa - create secure association for transmit
* @priv: private driver interface data from init()
* @channel: secure channel index
* @an: association number
* @next_pn: the packet number used as next transmit packet
* @confidentiality: True if the SA is to provide confidentiality
* as well as integrity
* @sak: the secure association key
* Returns: 0 on success, -1 on failure
*/
int (*create_transmit_sa)(void *priv, u32 channel, u8 an, u32 next_pn,
Boolean confidentiality, const u8 *sak);
/**
* enable_transmit_sa - enable SA for transmit
* @priv: private driver interface data from init()
* @channel: secure channel
* @an: association number
* Returns: 0 on success, -1 on failure
*/
int (*enable_transmit_sa)(void *priv, u32 channel, u8 an);
/**
* disable_transmit_sa - disable SA for transmit
* @priv: private driver interface data from init()
* @channel: secure channel
* @an: association number
* Returns: 0 on success, -1 on failure
*/
int (*disable_transmit_sa)(void *priv, u32 channel, u8 an);
#endif /* CONFIG_MACSEC */
}; };

View file

@ -632,4 +632,199 @@ static inline int wpa_drv_vendor_cmd(struct wpa_supplicant *wpa_s,
data, data_len, buf); data, data_len, buf);
} }
#ifdef CONFIG_MACSEC
static inline int wpa_drv_macsec_init(struct wpa_supplicant *wpa_s,
struct macsec_init_params *params)
{
if (!wpa_s->driver->macsec_init)
return -1;
return wpa_s->driver->macsec_init(wpa_s->drv_priv, params);
}
static inline int wpa_drv_macsec_deinit(struct wpa_supplicant *wpa_s)
{
if (!wpa_s->driver->macsec_deinit)
return -1;
return wpa_s->driver->macsec_deinit(wpa_s->drv_priv);
}
static inline int wpa_drv_enable_protect_frames(struct wpa_supplicant *wpa_s,
Boolean enabled)
{
if (!wpa_s->driver->enable_protect_frames)
return -1;
return wpa_s->driver->enable_protect_frames(wpa_s->drv_priv, enabled);
}
static inline int wpa_drv_set_replay_protect(struct wpa_supplicant *wpa_s,
Boolean enabled, u32 window)
{
if (!wpa_s->driver->set_replay_protect)
return -1;
return wpa_s->driver->set_replay_protect(wpa_s->drv_priv, enabled,
window);
}
static inline int wpa_drv_set_current_cipher_suite(struct wpa_supplicant *wpa_s,
const u8 *cs, size_t cs_len)
{
if (!wpa_s->driver->set_current_cipher_suite)
return -1;
return wpa_s->driver->set_current_cipher_suite(wpa_s->drv_priv, cs,
cs_len);
}
static inline int wpa_drv_enable_controlled_port(struct wpa_supplicant *wpa_s,
Boolean enabled)
{
if (!wpa_s->driver->enable_controlled_port)
return -1;
return wpa_s->driver->enable_controlled_port(wpa_s->drv_priv, enabled);
}
static inline int wpa_drv_get_receive_lowest_pn(struct wpa_supplicant *wpa_s,
u32 channel, u8 an,
u32 *lowest_pn)
{
if (!wpa_s->driver->get_receive_lowest_pn)
return -1;
return wpa_s->driver->get_receive_lowest_pn(wpa_s->drv_priv, channel,
an, lowest_pn);
}
static inline int wpa_drv_get_transmit_next_pn(struct wpa_supplicant *wpa_s,
u32 channel, u8 an,
u32 *next_pn)
{
if (!wpa_s->driver->get_transmit_next_pn)
return -1;
return wpa_s->driver->get_transmit_next_pn(wpa_s->drv_priv, channel,
an, next_pn);
}
static inline int wpa_drv_set_transmit_next_pn(struct wpa_supplicant *wpa_s,
u32 channel, u8 an,
u32 next_pn)
{
if (!wpa_s->driver->set_transmit_next_pn)
return -1;
return wpa_s->driver->set_transmit_next_pn(wpa_s->drv_priv, channel,
an, next_pn);
}
static inline int wpa_drv_get_available_receive_sc(struct wpa_supplicant *wpa_s,
u32 *channel)
{
if (!wpa_s->driver->get_available_receive_sc)
return -1;
return wpa_s->driver->get_available_receive_sc(wpa_s->drv_priv,
channel);
}
static inline int
wpa_drv_create_receive_sc(struct wpa_supplicant *wpa_s, u32 channel,
const u8 *sci_addr, u16 sci_port,
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);
}
static inline int wpa_drv_delete_receive_sc(struct wpa_supplicant *wpa_s,
u32 channel)
{
if (!wpa_s->driver->delete_receive_sc)
return -1;
return wpa_s->driver->delete_receive_sc(wpa_s->drv_priv, channel);
}
static inline int wpa_drv_create_receive_sa(struct wpa_supplicant *wpa_s,
u32 channel, u8 an,
u32 lowest_pn, const u8 *sak)
{
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);
}
static inline int wpa_drv_enable_receive_sa(struct wpa_supplicant *wpa_s,
u32 channel, u8 an)
{
if (!wpa_s->driver->enable_receive_sa)
return -1;
return wpa_s->driver->enable_receive_sa(wpa_s->drv_priv, channel, an);
}
static inline int wpa_drv_disable_receive_sa(struct wpa_supplicant *wpa_s,
u32 channel, u8 an)
{
if (!wpa_s->driver->disable_receive_sa)
return -1;
return wpa_s->driver->disable_receive_sa(wpa_s->drv_priv, channel, an);
}
static inline int
wpa_drv_get_available_transmit_sc(struct wpa_supplicant *wpa_s, u32 *channel)
{
if (!wpa_s->driver->get_available_transmit_sc)
return -1;
return wpa_s->driver->get_available_transmit_sc(wpa_s->drv_priv,
channel);
}
static inline int
wpa_drv_create_transmit_sc(struct wpa_supplicant *wpa_s, u32 channel,
const u8 *sci_addr, u16 sci_port,
unsigned int conf_offset)
{
if (!wpa_s->driver->create_transmit_sc)
return -1;
return wpa_s->driver->create_transmit_sc(wpa_s->drv_priv, channel,
sci_addr, sci_port,
conf_offset);
}
static inline int wpa_drv_delete_transmit_sc(struct wpa_supplicant *wpa_s,
u32 channel)
{
if (!wpa_s->driver->delete_transmit_sc)
return -1;
return wpa_s->driver->delete_transmit_sc(wpa_s->drv_priv, channel);
}
static inline int wpa_drv_create_transmit_sa(struct wpa_supplicant *wpa_s,
u32 channel, u8 an,
u32 next_pn,
Boolean confidentiality,
const u8 *sak)
{
if (!wpa_s->driver->create_transmit_sa)
return -1;
return wpa_s->driver->create_transmit_sa(wpa_s->drv_priv, channel, an,
next_pn, confidentiality, sak);
}
static inline int wpa_drv_enable_transmit_sa(struct wpa_supplicant *wpa_s,
u32 channel, u8 an)
{
if (!wpa_s->driver->enable_transmit_sa)
return -1;
return wpa_s->driver->enable_transmit_sa(wpa_s->drv_priv, channel, an);
}
static inline int wpa_drv_disable_transmit_sa(struct wpa_supplicant *wpa_s,
u32 channel, u8 an)
{
if (!wpa_s->driver->disable_transmit_sa)
return -1;
return wpa_s->driver->disable_transmit_sa(wpa_s->drv_priv, channel, an);
}
#endif /* CONFIG_MACSEC */
#endif /* DRIVER_I_H */ #endif /* DRIVER_I_H */