Bug 213

Summary: Socket::RecvFrom come back
Product: ns-3 Reporter: Gustavo J. A. M. Carneiro <gjcarneiro>
Component: networkAssignee: ns-bugs <ns-bugs>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P1    
Version: pre-release   
Hardware: All   
OS: All   
Attachments: patch
patch with correct name
revised RecvFrom patch with additional cleanup

Description Gustavo J. A. M. Carneiro 2008-06-05 12:26:10 UTC
Thread here: http://www.nabble.com/Missing-Socket::RecvFrom-td17667357.html
Comment 1 Gustavo J. A. M. Carneiro 2008-06-05 12:26:28 UTC
Created attachment 149 [details]
patch
Comment 2 Tom Henderson 2008-06-06 02:02:57 UTC
but I thought it would be named RecvFrom() ?
Comment 3 Gustavo J. A. M. Carneiro 2008-06-06 06:36:00 UTC
(In reply to comment #2)
> but I thought it would be named RecvFrom() ?

So did I! :-S

It was a mistake; thanks for catching it! :-/
Comment 4 Gustavo J. A. M. Carneiro 2008-06-06 06:41:33 UTC
Created attachment 154 [details]
patch with correct name
Comment 5 Tom Henderson 2008-06-09 09:17:53 UTC
Created attachment 159 [details]
revised RecvFrom patch with additional cleanup

In the course of working on RecvFrom, I also did some additional cleanup which resulted in (IMO) minor API change:  addition of "flags" argument to some Send calls, and rename the Address tag to make it apply to sending and receiving calls.

The attached patch is big, so here is a brief summary of proposed socket API changes

--- ns-3-dev/src/node/socket.h  2008-06-07 07:20:22.000000000 -0700
+++ ns-3-dev-bug-213/src/node/socket.h  2008-06-07 07:09:33.000000000 -0700

1.  Add flags argument to Send and SendTo methods.  This will be needed
    to support MSG_DONTROUTE option in future.

-  virtual int Send (Ptr<Packet> p) = 0;
+  virtual int Send (Ptr<Packet> p, uint32_t flags) = 0;

-  virtual int SendTo (Ptr<Packet> p, const Address &address) = 0;
+  virtual int SendTo (Ptr<Packet> p, uint32_t flags,
+    const Address &toAddress) = 0;

-  int Send (const uint8_t* buf, uint32_t size);
+  int Send (const uint8_t* buf, uint32_t size, uint32_t flags);

-  int SendTo (const uint8_t* buf, uint32_t size, const Address &address);
+  int SendTo (const uint8_t* buf, uint32_t size, uint32_t flags,
+              const Address &toAddress);

2.  Restore previous API (for the Send() method), allowing for flags to
    be an optional argument if it is zero (typically)

+  int Send (Ptr<Packet> p);

3. Add RecvFrom()

+  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
+    Address &fromAddress) = 0;

+  int RecvFrom (uint8_t* buf, uint32_t size, uint32_t flags,
+                Address &fromAddress);

4.  Add version with no flags and maxSize arguments, similar to the
    Recv() variant.

+  Ptr<Packet> RecvFrom (Address &fromAddress);

5.  Rename SocketRxAddressTag to SocketAddressTag, since it could
    be used for sending an address

-class SocketRxAddressTag : public Tag
+class SocketAddressTag : public Tag
Comment 6 Tom Henderson 2008-06-09 09:42:15 UTC
add a repo for this
http://code.nsnam.org/tomh/ns-3-dev-bug-213
Comment 7 Mathieu Lacage 2008-06-13 20:22:38 UTC
merged tom's repo.