From 72403ecef7473cc414a32fe8e6867c9b092288dc Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 27 Apr 2013 20:43:35 +0300 Subject: [PATCH] WPS: Add builder functions for AP Channel and RF Bands attributes Signed-hostap: Jouni Malinen --- src/wps/wps_attr_build.c | 20 ++++++++++++++++++++ src/wps/wps_dev_attr.c | 6 +----- src/wps/wps_i.h | 2 ++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/wps/wps_attr_build.c b/src/wps/wps_attr_build.c index 336246eaf..666c98d20 100644 --- a/src/wps/wps_attr_build.c +++ b/src/wps/wps_attr_build.c @@ -449,3 +449,23 @@ int wps_build_mac_addr(struct wpabuf *msg, const u8 *addr) wpabuf_put_data(msg, addr, ETH_ALEN); return 0; } + + +int wps_build_rf_bands_attr(struct wpabuf *msg, u8 rf_bands) +{ + wpa_printf(MSG_DEBUG, "WPS: * RF Bands (%x)", rf_bands); + wpabuf_put_be16(msg, ATTR_RF_BANDS); + wpabuf_put_be16(msg, 1); + wpabuf_put_u8(msg, rf_bands); + return 0; +} + + +int wps_build_ap_channel(struct wpabuf *msg, u16 ap_channel) +{ + wpa_printf(MSG_DEBUG, "WPS: * AP Channel (%u)", ap_channel); + wpabuf_put_be16(msg, ATTR_AP_CHANNEL); + wpabuf_put_be16(msg, 2); + wpabuf_put_be16(msg, ap_channel); + return 0; +} diff --git a/src/wps/wps_dev_attr.c b/src/wps/wps_dev_attr.c index fe736f32f..87910b071 100644 --- a/src/wps/wps_dev_attr.c +++ b/src/wps/wps_dev_attr.c @@ -220,11 +220,7 @@ int wps_build_vendor_ext_m1(struct wps_device_data *dev, struct wpabuf *msg) int wps_build_rf_bands(struct wps_device_data *dev, struct wpabuf *msg, u8 rf_band) { - wpa_printf(MSG_DEBUG, "WPS: * RF Bands (%x)", dev->rf_bands); - wpabuf_put_be16(msg, ATTR_RF_BANDS); - wpabuf_put_be16(msg, 1); - wpabuf_put_u8(msg, rf_band ? rf_band : dev->rf_bands); - return 0; + return wps_build_rf_bands_attr(msg, rf_band ? rf_band : dev->rf_bands); } diff --git a/src/wps/wps_i.h b/src/wps/wps_i.h index dac125086..aa8a6fadb 100644 --- a/src/wps/wps_i.h +++ b/src/wps/wps_i.h @@ -173,6 +173,8 @@ int wps_build_oob_dev_pw(struct wpabuf *msg, u16 dev_pw_id, size_t dev_pw_len); struct wpabuf * wps_ie_encapsulate(struct wpabuf *data); int wps_build_mac_addr(struct wpabuf *msg, const u8 *addr); +int wps_build_rf_bands_attr(struct wpabuf *msg, u8 rf_bands); +int wps_build_ap_channel(struct wpabuf *msg, u16 ap_channel); /* wps_attr_process.c */ int wps_process_authenticator(struct wps_data *wps, const u8 *authenticator,