ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: Re: [Wireshark-dev] packet-lorawan.c compile error because of stuff added yester

From: Richard Sharpe <realrichardsharpe@xxxxxxxxx>
Date: Tue, 13 Jun 2017 15:58:10 -0700
On Tue, Jun 13, 2017 at 3:15 PM, Richard Sharpe
<realrichardsharpe@xxxxxxxxx> wrote:
> On Tue, Jun 13, 2017 at 1:50 PM, Pascal Quantin
> <pascal.quantin@xxxxxxxxx> wrote:
>>
>>
>> 2017-06-13 22:33 GMT+02:00 Pascal Quantin <pascal.quantin@xxxxxxxxx>:
>>>
>>> Hi Richard,
>>>
>>> 2017-06-13 22:29 GMT+02:00 Richard Sharpe <realrichardsharpe@xxxxxxxxx>:
>>>>
>>>> Hi folks,
>>>>
>>>> After I did a git pull, I started getting this error:
>>>>
>>>>   CC       packet-lorawan.lo
>>>> packet-lorawan.c: In function 'dissect_lorawan':
>>>> packet-lorawan.c:657:7: error: variable 'frame_length' set but not
>>>> used [-Werror=unused-but-set-variable]
>>>>   gint frame_length;
>>>>
>>>> Seems to be related to this:
>>>>
>>>>         frame_length = current_offset;
>>>> +#if GCRYPT_VERSION_NUMBER >= 0x010600 /* 1.6.0 */
>>>>         if (encryption_keys) {
>>>>                 guint8 *msg = (guint8
>>>> *)wmem_alloc0(wmem_packet_scope(), frame_length + 16);
>>>>                 msg[0] = 0x49;
>>>> @@ -824,7 +833,9 @@ dissect_lorawan(tvbuff_t *tvb, packet_info *pinfo,
>>>> proto_tree *tree _U_, void *d
>>>>                 if (calculate_mic(msg, frame_length + 16,
>>>> encryption_keys->nwkskey->data) != tvb_get_guint32(tvb,
>>>> current_offset, ENC_LITTLE_ENDIAN)) {
>>>>                         proto_tree_add_expert_format(lorawan_tree,
>>>> pinfo, &ei_lorawan_invalid_crc, tvb, current_offset, 4, "Invalid
>>>> CRC");
>>>>                 }
>>>> -       } else {
>>>> +       } else
>>>> +#endif
>>>> +       {
>>>>
>>>> It's a bit rude to cause build errors just because I don't have gcrypt
>>>> 1.6.0 or above.
>>>
>>>
>>> This is currently under process:
>>> https://code.wireshark.org/review/#/c/22098
>>
>>
>> Could you check is the latest patch iteration works on your machine?
>
> OK, I will now that I have finished the little bit of development I
> was doing ...

Hmmm, it still seems to be there with the latest in the repository,
but I have not checked what's in Gerrit that has not been committed.

I fixed it with this:

-------------------------------
diff --git a/epan/dissectors/packet-lorawan.c b/epan/dissectors/packet-lorawan.c
index fbbc2dd..9a45bda 100644
--- a/epan/dissectors/packet-lorawan.c
+++ b/epan/dissectors/packet-lorawan.c
@@ -654,7 +654,9 @@ dissect_lorawan(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree _U_, void *d
        guint8 fport;
        guint32 dev_address;
        guint32 fcnt;
+#if GCRYPT_VERSION_NUMBER >= 0x010600 /* 1.6.0 */
        gint frame_length;
+#endif
        gboolean uplink = TRUE;
        device_encryption_keys_t *encryption_keys = NULL;

@@ -820,8 +822,8 @@ dissect_lorawan(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree _U_, void *d
         * MIC = cmac[0..3]
         * B0 = 0x49 | 0x00 | 0x00 | 0x00 | 0x00 | dir | devAddr |
fcntup/fcntdown | len(msg)
         */
-       frame_length = current_offset;
 #if GCRYPT_VERSION_NUMBER >= 0x010600 /* 1.6.0 */
+       frame_length = current_offset;
        if (encryption_keys) {
                guint8 *msg = (guint8
*)wmem_alloc0(wmem_packet_scope(), frame_length + 16);
                msg[0] = 0x49;
------------------------------------

Maybe something like that is already under review.

-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)