Menu

#171 Wrong socket binding for multicast request messages

1.4.0.0
closed
None
2018-05-02
2017-08-28
No

It is not defined in the standard, but if you have a source address 0 for publishing, "appHandle->realIP" is used instead in your code. This is not the case for sending requests, this means that if tlp_request is sent with a source address of 0, a socket bound to address 0 is opened.
This may work in the case where the destination address is an unicast address, but in the case of a multicast it is not known on which interface the packet needs to be sent. It can be fixed with a small change:

In trdp_if.c, in the function "tlp_request":

            ret = trdp_requestSocket(appHandle->iface,
                                     appHandle->pdDefault.port,
                                     (pSendParam != NULL) ? pSendParam : &appHandle->pdDefault.sendParam,
                                     srcIpAddr,
                                     0u,
                                     TRDP_SOCK_PD,
                                     appHandle->option,
                                     FALSE,
                                     -1,
                                     &pReqElement->socketIdx,
                                     0u);

should be:

                ret = trdp_requestSocket(appHandle->iface,
                                         appHandle->pdDefault.port,
                                         (pSendParam != NULL) ? pSendParam : &appHandle->pdDefault.sendParam,
                                         (srcIpAddr == VOS_INADDR_ANY) ? appHandle->realIP : srcIpAddr,
                                         0u,
                                         TRDP_SOCK_PD,
                                         appHandle->option,
                                         FALSE,
                                         -1,
                                         &pReqElement->socketIdx,
                                         0u);

Discussion

  • Bernd Löhr

    Bernd Löhr - 2017-08-29

    Yes, you're right; actually I don't like this parameter at all - the application session defines the interface (or IP) to be used already. I'm not sure about any use case - may be redundancy, but currently the second IP in openSession is not used either...

     
  • Bernd Löhr

    Bernd Löhr - 2017-09-13
    • status: unread --> accepted
    • assigned_to: Bernd Löhr
     
  • Bernd Löhr

    Bernd Löhr - 2017-09-13

    Actually, the source IP for any outgoing telegram should be defined through the session's IP address (i.e. interface). With only one interface this would be INADDR_ANY.
    The only use case I can think of why you want to send on a different interface than the session was opened on, would be manual redundancy.
    Nevertheless, the source IP is in the API and should be correctly supported.

     
  • Bernd Löhr

    Bernd Löhr - 2017-11-09
    • status: accepted --> pending
     
  • Bernd Löhr

    Bernd Löhr - 2017-11-09

    Changing the srcIpAddr parameter must be done for all later uses (e.g. finding existing entries etc.). srcIpAddr when publishing must be handled accordingly!

     
  • Bernd Löhr

    Bernd Löhr - 2018-05-02
    • status: pending --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB