Menu

#51 VOS: change underlying function for vos_dottedIP

1.2.0.0
closed
mike
None
2014-10-08
2014-07-24
mike
No

vos_dottedIP uses inet_addr() to convert form dooted decimal string to uint32_t. This involves the risk to get -1 returned in case of invalid addresses given in the string. Please check inet_aton() as replacement - see manpage excerpt below:

   inet_aton() converts the Internet host address  cp  from  the  standard
   numbers-and-dots  notation into binary data and stores it in the struc-
   ture that inp points to. inet_aton() returns non-zero if the address is
   valid, zero if not.

   The  inet_addr()  function  converts  the Internet host address cp from
   numbers-and-dots notation into binary data in network byte  order.   If
   the input is invalid, INADDR_NONE (usually -1) is returned.  This is an
   obsolete interface to inet_aton(), described immediately above;  it  is
   obsolete   because   -1  is  a  valid  address  (255.255.255.255),  and
   inet_aton() provides a cleaner way to indicate error return.

Discussion

  • Bernd Löhr

    Bernd Löhr - 2014-08-25
    • status: open --> pending
     
  • Bernd Löhr

    Bernd Löhr - 2014-08-25

    Resolved for Posix-path, only. Windows does not seem to have inet_aton()? What about vxWorks?

     
  • Bernd Löhr

    Bernd Löhr - 2014-08-25
    • assigned_to: Bernd Löhr --> mike
     
  • mike

    mike - 2014-09-22

    A prototype for getting around the 255.255.255.255 problem induced by negative return value "-1" is given for MS Windows, POSIX and vxWorks in [r1332].

    Got also some comments in for all parties interested in the differences between the worlds.

    Did not invest time on the whereabouts/history of the const qualifier (missing in vxWorks).

     

    Related

    Commit: [r1332]

  • mike

    mike - 2014-10-08
    • status: pending --> closed
     
  • mike

    mike - 2014-10-08

    Closing this ticket after revisting the code changes a 2nd time.

     

Log in to post a comment.

MongoDB Logo MongoDB