possible bug with IPADDR()

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

possible bug with IPADDR()

456 Views
projektecarus
Contributor II

Hi,


we are using MQX Version 4.0. We have implemented network communication over UDP with RTCS. While developing our application we compared the ip address, that was returned by Sendto() with an static ip address. To enter the IP address we used the IPADDR() MACRO, that is defined in the rtcs.h as

#define IPADDR(a,b,c,d) (((uint_32)(a)&0xFF)<<24)|(((uint_32)(b)&0xFF)<<16)|(((uint_32)(c)&0xFF)<<8)|((uint_32)(d)&0xFF)

During debugging we noticed, that our comparison always evaluated as true. After some investigating we noticed that there are no brackets around the IPADDR macro, so the comparison compared the ip address with the first byte of the ip address with of course evaluated as false and the connected the other bytes of the ip address with the bit wise or operator. We think that this behavior might be undesirable and think that it could be considered a bug. We wanted to inform you about it and warn other users, so they will be able to save some debugging time, when they stumble upon the same problem. We currently have no way of telling if this problem is also present in the latest version of MQX.

Labels (1)
0 Kudos
Reply
1 Reply

328 Views
Martin_
NXP Employee
NXP Employee

Hello,

you're absolutely right, we recently met this issue and added brackets. MQX 4.1.0 has still this definition, but next versions will be fixed:

#define IPADDR(a,b,c,d)      ((((uint32_t)(a)&0xFF)<<24)|(((uint32_t)(b)&0xFF)<<16)|(((uint32_t)(c)&0xFF)<<8)|((uint32_t)(d)&0xFF))

Thanks for sharing !

Martin

0 Kudos
Reply