View | Details | Raw Unified | Return to bug 1835
Collapse All | Expand All

(-)a/src/internet/model/ipv4-raw-socket-impl.cc (+15 lines)
 Lines 131-136    Link Here 
131
  address = InetSocketAddress (m_src, 0);
131
  address = InetSocketAddress (m_src, 0);
132
  return 0;
132
  return 0;
133
}
133
}
134
int
135
Ipv4RawSocketImpl::GetPeerName (Address &address) const
136
{
137
  NS_LOG_FUNCTION (this << address);
138
139
  if (m_dst == Ipv4Address::GetAny ())
140
    {
141
      m_err = ERROR_NOTCONN;;
142
      return -1;
143
    }
144
145
  address = InetSocketAddress (m_dst, 0);
146
147
  return 0;
148
}
134
int 
149
int 
135
Ipv4RawSocketImpl::Close (void)
150
Ipv4RawSocketImpl::Close (void)
136
{
151
{
(-)a/src/internet/model/ipv4-raw-socket-impl.h (-1 / +2 lines)
 Lines 53-58    Link Here 
53
  virtual int Bind ();
53
  virtual int Bind ();
54
  virtual int Bind6 ();
54
  virtual int Bind6 ();
55
  virtual int GetSockName (Address &address) const; 
55
  virtual int GetSockName (Address &address) const; 
56
  virtual int GetPeerName (Address &address) const;
56
  virtual int Close (void);
57
  virtual int Close (void);
57
  virtual int ShutdownSend (void);
58
  virtual int ShutdownSend (void);
58
  virtual int ShutdownRecv (void);
59
  virtual int ShutdownRecv (void);
 Lines 98-104    Link Here 
98
    uint16_t fromProtocol;   /**< Protocol used */
99
    uint16_t fromProtocol;   /**< Protocol used */
99
  };
100
  };
100
101
101
  enum Socket::SocketErrno m_err;   //!< Last error number.
102
  mutable enum Socket::SocketErrno m_err; //!< Last error number.
102
  Ptr<Node> m_node;                 //!< Node
103
  Ptr<Node> m_node;                 //!< Node
103
  Ipv4Address m_src;                //!< Source address.
104
  Ipv4Address m_src;                //!< Source address.
104
  Ipv4Address m_dst;                //!< Destination address.
105
  Ipv4Address m_dst;                //!< Destination address.
(-)a/src/internet/model/ipv6-raw-socket-impl.cc (+16 lines)
 Lines 136-141    Link Here 
136
  return 0;
136
  return 0;
137
}
137
}
138
138
139
int
140
Ipv6RawSocketImpl::GetPeerName (Address& address) const
141
{
142
  NS_LOG_FUNCTION (this << address);
143
144
  if (m_dst.IsAny ())
145
    {
146
      m_err = ERROR_NOTCONN;;
147
      return -1;
148
    }
149
150
  address = Inet6SocketAddress (m_dst, 0);
151
152
  return 0;
153
}
154
139
int Ipv6RawSocketImpl::Close ()
155
int Ipv6RawSocketImpl::Close ()
140
{
156
{
141
  NS_LOG_FUNCTION_NOARGS ();
157
  NS_LOG_FUNCTION_NOARGS ();
(-)a/src/internet/model/ipv6-raw-socket-impl.h (-1 / +2 lines)
 Lines 95-100    Link Here 
95
  virtual int Bind6 ();
95
  virtual int Bind6 ();
96
96
97
  virtual int GetSockName (Address& address) const;
97
  virtual int GetSockName (Address& address) const;
98
  virtual int GetPeerName (Address& address) const;
98
99
99
  virtual int Close ();
100
  virtual int Close ();
100
  virtual int ShutdownSend ();
101
  virtual int ShutdownSend ();
 Lines 183-189    Link Here 
183
  /**
184
  /**
184
   * \brief Last error number.
185
   * \brief Last error number.
185
   */
186
   */
186
  enum Socket::SocketErrno m_err;
187
  mutable enum Socket::SocketErrno m_err;
187
188
188
  /**
189
  /**
189
   * \brief Node.
190
   * \brief Node.
(-)a/src/internet/model/tcp-socket-base.cc (+29 lines)
 Lines 645-650    Link Here 
645
  return 0;
645
  return 0;
646
}
646
}
647
647
648
int
649
TcpSocketBase::GetPeerName (Address &address) const
650
{
651
  NS_LOG_FUNCTION (this << address);
652
653
  if (!m_connected)
654
    {
655
      m_errno = ERROR_NOTCONN;;
656
      return -1;
657
    }
658
659
  if (m_endPoint)
660
    {
661
      address = InetSocketAddress (m_endPoint->GetPeerAddress (),
662
                                   m_endPoint->GetPeerPort ());
663
    }
664
  else if (m_endPoint6)
665
    {
666
      address = Inet6SocketAddress (m_endPoint6->GetPeerAddress (),
667
                                    m_endPoint6->GetPeerPort ());
668
    }
669
  else
670
    {
671
      NS_ASSERT_MSG (false, "unexpected address type");
672
    }
673
674
  return 0;
675
}
676
648
/* Inherit from Socket class: Bind this socket to the specified NetDevice */
677
/* Inherit from Socket class: Bind this socket to the specified NetDevice */
649
void
678
void
650
TcpSocketBase::BindToNetDevice (Ptr<NetDevice> netdevice)
679
TcpSocketBase::BindToNetDevice (Ptr<NetDevice> netdevice)
(-)a/src/internet/model/tcp-socket-base.h (-1 / +2 lines)
 Lines 120-125    Link Here 
120
  virtual uint32_t GetTxAvailable (void) const; // Available Tx buffer size
120
  virtual uint32_t GetTxAvailable (void) const; // Available Tx buffer size
121
  virtual uint32_t GetRxAvailable (void) const; // Available-to-read data size, i.e. value of m_rxAvailable
121
  virtual uint32_t GetRxAvailable (void) const; // Available-to-read data size, i.e. value of m_rxAvailable
122
  virtual int GetSockName (Address &address) const; // Return local addr:port in address
122
  virtual int GetSockName (Address &address) const; // Return local addr:port in address
123
  virtual int GetPeerName (Address &address) const;
123
  virtual void BindToNetDevice (Ptr<NetDevice> netdevice); // NetDevice with my m_endPoint
124
  virtual void BindToNetDevice (Ptr<NetDevice> netdevice); // NetDevice with my m_endPoint
124
125
125
protected:
126
protected:
 Lines 588-594    Link Here 
588
589
589
  // State-related attributes
590
  // State-related attributes
590
  TracedValue<TcpStates_t> m_state;         //!< TCP state
591
  TracedValue<TcpStates_t> m_state;         //!< TCP state
591
  enum SocketErrno         m_errno;         //!< Socket error code
592
  mutable enum SocketErrno m_errno;         //!< Socket error code
592
  bool                     m_closeNotified; //!< Told app to close socket
593
  bool                     m_closeNotified; //!< Told app to close socket
593
  bool                     m_closeOnEmpty;  //!< Close socket upon tx buffer emptied
594
  bool                     m_closeOnEmpty;  //!< Close socket upon tx buffer emptied
594
  bool                     m_shutdownSend;  //!< Send no longer allowed
595
  bool                     m_shutdownSend;  //!< Send no longer allowed
(-)a/src/internet/model/udp-socket-impl.cc (+33 lines)
 Lines 912-917    Link Here 
912
  return 0;
912
  return 0;
913
}
913
}
914
914
915
int
916
UdpSocketImpl::GetPeerName (Address &address) const
917
{
918
  NS_LOG_FUNCTION (this << address);
919
920
  if (!m_connected)
921
    {
922
      m_errno = ERROR_NOTCONN;;
923
      return -1;
924
    }
925
926
  if (InetSocketAddress::IsMatchingType(m_defaultAddress))
927
    {
928
      InetSocketAddress addr =
929
        InetSocketAddress::ConvertFrom (m_defaultAddress);
930
      addr.SetPort (m_defaultPort);
931
      address = addr;
932
    }
933
  else if (Inet6SocketAddress::IsMatchingType(m_defaultAddress))
934
    {
935
      Inet6SocketAddress addr =
936
        Inet6SocketAddress::ConvertFrom (m_defaultAddress);
937
      addr.SetPort (m_defaultPort);
938
      address = addr;
939
    }
940
  else
941
    {
942
      NS_ASSERT_MSG (false, "unexpected address type");
943
    }
944
945
  return 0;
946
}
947
915
int 
948
int 
916
UdpSocketImpl::MulticastJoinGroup (uint32_t interface, const Address &groupAddress)
949
UdpSocketImpl::MulticastJoinGroup (uint32_t interface, const Address &groupAddress)
917
{
950
{
(-)a/src/internet/model/udp-socket-impl.h (-1 / +2 lines)
 Lines 91-96    Link Here 
91
  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
91
  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
92
                                Address &fromAddress);
92
                                Address &fromAddress);
93
  virtual int GetSockName (Address &address) const; 
93
  virtual int GetSockName (Address &address) const; 
94
  virtual int GetPeerName (Address &address) const;
94
  virtual int MulticastJoinGroup (uint32_t interfaceIndex, const Address &groupAddress);
95
  virtual int MulticastJoinGroup (uint32_t interfaceIndex, const Address &groupAddress);
95
  virtual int MulticastLeaveGroup (uint32_t interfaceIndex, const Address &groupAddress);
96
  virtual int MulticastLeaveGroup (uint32_t interfaceIndex, const Address &groupAddress);
96
  virtual void BindToNetDevice (Ptr<NetDevice> netdevice);
97
  virtual void BindToNetDevice (Ptr<NetDevice> netdevice);
 Lines 225-231    Link Here 
225
  uint16_t m_defaultPort;   //!< Default port
226
  uint16_t m_defaultPort;   //!< Default port
226
  TracedCallback<Ptr<const Packet> > m_dropTrace; //!< Trace for dropped packets
227
  TracedCallback<Ptr<const Packet> > m_dropTrace; //!< Trace for dropped packets
227
228
228
  enum SocketErrno         m_errno;           //!< Socket error code
229
  mutable enum SocketErrno m_errno;           //!< Socket error code
229
  bool                     m_shutdownSend;    //!< Send no longer allowed
230
  bool                     m_shutdownSend;    //!< Send no longer allowed
230
  bool                     m_shutdownRecv;    //!< Receive no longer allowed
231
  bool                     m_shutdownRecv;    //!< Receive no longer allowed
231
  bool                     m_connected;       //!< Connection established
232
  bool                     m_connected;       //!< Connection established
(-)a/src/network/model/socket.h (+6 lines)
 Lines 561-566    Link Here 
561
  virtual int GetSockName (Address &address) const = 0; 
561
  virtual int GetSockName (Address &address) const = 0; 
562
562
563
  /**
563
  /**
564
   * \param address the address this socket is connected to.
565
   * \returns 0 if success, -1 otherwise
566
   */
567
  virtual int GetPeerName (Address &address) const = 0;
568
569
  /**
564
   * \brief Bind a socket to specific device.
570
   * \brief Bind a socket to specific device.
565
   *
571
   *
566
   * This method corresponds to using setsockopt() SO_BINDTODEVICE
572
   * This method corresponds to using setsockopt() SO_BINDTODEVICE
(-)a/src/network/utils/packet-socket.cc (+16 lines)
 Lines 487-492    Link Here 
487
  return 0;
487
  return 0;
488
}
488
}
489
489
490
int
491
PacketSocket::GetPeerName (Address &address) const
492
{
493
  NS_LOG_FUNCTION (this << address);
494
495
  if (m_state != STATE_CONNECTED)
496
    {
497
      m_errno = ERROR_NOTCONN;;
498
      return -1;
499
    }
500
501
  address = m_destAddr;
502
503
  return 0;
504
}
505
490
bool
506
bool
491
PacketSocket::SetAllowBroadcast (bool allowBroadcast)
507
PacketSocket::SetAllowBroadcast (bool allowBroadcast)
492
{
508
{
(-)a/src/network/utils/packet-socket.h (-1 / +2 lines)
 Lines 104-109    Link Here 
104
  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
104
  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
105
                                Address &fromAddress);
105
                                Address &fromAddress);
106
  virtual int GetSockName (Address &address) const; 
106
  virtual int GetSockName (Address &address) const; 
107
  virtual int GetPeerName (Address &address) const;
107
  virtual bool SetAllowBroadcast (bool allowBroadcast);
108
  virtual bool SetAllowBroadcast (bool allowBroadcast);
108
  virtual bool GetAllowBroadcast () const;
109
  virtual bool GetAllowBroadcast () const;
109
110
 Lines 122-128    Link Here 
122
    STATE_CLOSED
123
    STATE_CLOSED
123
  };
124
  };
124
  Ptr<Node> m_node;
125
  Ptr<Node> m_node;
125
  enum SocketErrno m_errno;
126
  mutable enum SocketErrno m_errno;
126
  bool m_shutdownSend;
127
  bool m_shutdownSend;
127
  bool m_shutdownRecv;
128
  bool m_shutdownRecv;
128
  enum State m_state;
129
  enum State m_state;

Return to bug 1835