PAE: Use sci->port more consistently
authorJouni Malinen <j@w1.fi>
Fri, 24 Jun 2016 14:48:27 +0000 (17:48 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 24 Jun 2016 16:02:58 +0000 (19:02 +0300)
This is now annotated as be16, so use it as such in all cases instead of
first storing host byte order value and then swapping that to big endian
in other instances of the same structure. This gets rid of number of
sparse warnings.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/pae/ieee802_1x_kay.c
wpa_supplicant/wpas_kay.c

index 415946f..07720a0 100644 (file)
@@ -682,7 +682,7 @@ ieee802_1x_mka_encode_basic_body(
 
        os_memcpy(body->actor_sci.addr, kay->actor_sci.addr,
                  sizeof(kay->actor_sci.addr));
-       body->actor_sci.port = host_to_be16(kay->actor_sci.port);
+       body->actor_sci.port = kay->actor_sci.port;
 
        os_memcpy(body->actor_mi, participant->mi, sizeof(body->actor_mi));
        participant->mn = participant->mn + 1;
@@ -738,7 +738,7 @@ ieee802_1x_mka_decode_basic_body(struct ieee802_1x_kay *kay, const u8 *mka_msg,
        participant->current_peer_id.mn =  be_to_host32(body->actor_mn);
        os_memcpy(participant->current_peer_sci.addr, body->actor_sci.addr,
                  sizeof(participant->current_peer_sci.addr));
-       participant->current_peer_sci.port = be_to_host16(body->actor_sci.port);
+       participant->current_peer_sci.port = body->actor_sci.port;
 
        /* handler peer */
        peer = ieee802_1x_kay_get_peer(participant, body->actor_mi);
@@ -3152,7 +3152,7 @@ ieee802_1x_kay_init(struct ieee802_1x_kay_ctx *ctx, enum macsec_policy policy,
 
        os_strlcpy(kay->if_name, ifname, IFNAMSIZ);
        os_memcpy(kay->actor_sci.addr, addr, ETH_ALEN);
-       kay->actor_sci.port = 0x0001;
+       kay->actor_sci.port = host_to_be16(0x0001);
        kay->actor_priority = DEFAULT_PRIO_NOT_KEY_SERVER;
 
        /* While actor acts as a key server, shall distribute sakey */
index 354decf..0b87600 100644 (file)
@@ -109,7 +109,8 @@ static int wpas_create_receive_sc(void *wpa_s, u32 channel,
                                  enum validate_frames vf,
                                  enum confidentiality_offset co)
 {
-       return wpa_drv_create_receive_sc(wpa_s, channel, sci->addr, sci->port,
+       return wpa_drv_create_receive_sc(wpa_s, channel, sci->addr,
+                                        be_to_host16(sci->port),
                                         conf_offset_val(co), vf);
 }
 
@@ -150,7 +151,8 @@ wpas_create_transmit_sc(void *wpa_s, u32 channel,
                        const struct ieee802_1x_mka_sci *sci,
                        enum confidentiality_offset co)
 {
-       return wpa_drv_create_transmit_sc(wpa_s, channel, sci->addr, sci->port,
+       return wpa_drv_create_transmit_sc(wpa_s, channel, sci->addr,
+                                         be_to_host16(sci->port),
                                          conf_offset_val(co));
 }