< Previous by Date Date Index Next by Date >
< Previous in Thread Thread Index Next in Thread >

Re: [reSIProcate-users] determineSourceInterface on Linux?


The best way to do this is to let the stack select the transport for the SIP message, then assuming your RTP will be handled on the same interface as SIP - you would use a MessageDecorator to modify the IP addresses in your SDP contents just before the message is sent out on the wire.  Use the setOutboundDecorator method of your profile in order to have the decorator invoked.

Sample SDP decorator class:
class SdpMessageDecorator : public MessageDecorator
{
public:
   virtual ~SdpMessageDecorator() {}
   virtual void decorateMessage(SipMessage &msg, 
                                const Tuple &source,
                                const Tuple &destination)
   {
      SdpContents* sdp = dynamic_cast<SdpContents*>(msg.getContents());
      if(sdp)
      {
         // Fill in IP and Port from source (if required)
         if(sdp->session().connection().getAddress() == Data("0.0.0.0"))
         {
            sdp->session().connection().setAddress(Tuple::inet_ntop(source), source.ipVersion() == V6 ? SdpContents::IP6 : SdpContents::IP4);
         }
         if(sdp->session().origin().getAddress() == Data("0.0.0.0"))
         {
            sdp->session().origin().setAddress(Tuple::inet_ntop(source), source.ipVersion() == V6 ? SdpContents::IP6 : SdpContents::IP4);
         }
         InfoLog( << "SdpMessageDecorator: src="" << source << ", dest=" << destination << ", msg=" << endl << msg);
      }
   }
   virtual void rollbackMessage(SipMessage& msg) {}  // Nothing to do
   virtual MessageDecorator* clone() const { return new SdpMessageDecorator; }
};

Scott

On Wed, Jun 3, 2009 at 4:02 AM, Richard Stellingwerff <remenic@xxxxxxxxx> wrote:
Hi,

When creating the contents of an SDP I need to embed the local IP address on which I will be listening for incoming RTP data. What is the best way to determine my local IP address based on the destination? For windows I noticed there is GenericIPAddress determineSourceInterface(const GenericIPAddress& destination); but I could not find a similar method for Linux.

Kind regards,
Richard Stellingwerff.

_______________________________________________
resiprocate-users mailing list
resiprocate-users@xxxxxxxxxxxxxxx
List Archive: http://list.resiprocate.org/archive/resiprocate-users/