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

(-)a/src/internet/model/ipv4-raw-socket-impl.cc (+15 lines)
 Lines 130-135    Link Here 
130
  address = InetSocketAddress (m_src, 0);
130
  address = InetSocketAddress (m_src, 0);
131
  return 0;
131
  return 0;
132
}
132
}
133
int
134
Ipv4RawSocketImpl::GetPeerName (Address &address) const
135
{
136
  NS_LOG_FUNCTION (this << address);
137
138
  if (m_dst == Ipv4Address::GetAny ())
139
    {
140
      m_err = ERROR_NOTCONN;;
141
      return -1;
142
    }
143
144
  address = InetSocketAddress (m_dst, 0);
145
146
  return 0;
147
}
133
int 
148
int 
134
Ipv4RawSocketImpl::Close (void)
149
Ipv4RawSocketImpl::Close (void)
135
{
150
{
(-)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 133-138    Link Here 
133
  return 0;
133
  return 0;
134
}
134
}
135
135
136
int
137
Ipv6RawSocketImpl::GetPeerName (Address& address) const
138
{
139
  NS_LOG_FUNCTION (this << address);
140
141
  if (m_dst.IsAny ())
142
    {
143
      m_err = ERROR_NOTCONN;;
144
      return -1;
145
    }
146
147
  address = Inet6SocketAddress (m_dst, 0);
148
149
  return 0;
150
}
151
136
int Ipv6RawSocketImpl::Close ()
152
int Ipv6RawSocketImpl::Close ()
137
{
153
{
138
  NS_LOG_FUNCTION_NOARGS ();
154
  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 686-691    Link Here 
686
  return 0;
686
  return 0;
687
}
687
}
688
688
689
int
690
TcpSocketBase::GetPeerName (Address &address) const
691
{
692
  NS_LOG_FUNCTION (this << address);
693
694
  if (!m_connected)
695
    {
696
      m_errno = ERROR_NOTCONN;;
697
      return -1;
698
    }
699
700
  if (m_endPoint)
701
    {
702
      address = InetSocketAddress (m_endPoint->GetPeerAddress (),
703
                                   m_endPoint->GetPeerPort ());
704
    }
705
  else if (m_endPoint6)
706
    {
707
      address = Inet6SocketAddress (m_endPoint6->GetPeerAddress (),
708
                                    m_endPoint6->GetPeerPort ());
709
    }
710
  else
711
    {
712
      NS_ASSERT_MSG (false, "unexpected address type");
713
    }
714
715
  return 0;
716
}
717
689
/* Inherit from Socket class: Bind this socket to the specified NetDevice */
718
/* Inherit from Socket class: Bind this socket to the specified NetDevice */
690
void
719
void
691
TcpSocketBase::BindToNetDevice (Ptr<NetDevice> netdevice)
720
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 647-653    Link Here 
647
648
648
  // State-related attributes
649
  // State-related attributes
649
  TracedValue<TcpStates_t> m_state;         //!< TCP state
650
  TracedValue<TcpStates_t> m_state;         //!< TCP state
650
  enum SocketErrno         m_errno;         //!< Socket error code
651
  mutable enum SocketErrno m_errno;         //!< Socket error code
651
  bool                     m_closeNotified; //!< Told app to close socket
652
  bool                     m_closeNotified; //!< Told app to close socket
652
  bool                     m_closeOnEmpty;  //!< Close socket upon tx buffer emptied
653
  bool                     m_closeOnEmpty;  //!< Close socket upon tx buffer emptied
653
  bool                     m_shutdownSend;  //!< Send no longer allowed
654
  bool                     m_shutdownSend;  //!< Send no longer allowed
(-)a/src/internet/model/udp-socket-impl.cc (+33 lines)
 Lines 891-896    Link Here 
891
  return 0;
891
  return 0;
892
}
892
}
893
893
894
int
895
UdpSocketImpl::GetPeerName (Address &address) const
896
{
897
  NS_LOG_FUNCTION (this << address);
898
899
  if (!m_connected)
900
    {
901
      m_errno = ERROR_NOTCONN;;
902
      return -1;
903
    }
904
905
  if (InetSocketAddress::IsMatchingType (m_defaultAddress))
906
    {
907
      InetSocketAddress addr =
908
        InetSocketAddress::ConvertFrom (m_defaultAddress);
909
      addr.SetPort (m_defaultPort);
910
      address = addr;
911
    }
912
  else if (Inet6SocketAddress::IsMatchingType (m_defaultAddress))
913
    {
914
      Inet6SocketAddress addr =
915
        Inet6SocketAddress::ConvertFrom (m_defaultAddress);
916
      addr.SetPort (m_defaultPort);
917
      address = addr;
918
    }
919
  else
920
    {
921
      NS_ASSERT_MSG (false, "unexpected address type");
922
    }
923
924
  return 0;
925
}
926
894
int 
927
int 
895
UdpSocketImpl::MulticastJoinGroup (uint32_t interface, const Address &groupAddress)
928
UdpSocketImpl::MulticastJoinGroup (uint32_t interface, const Address &groupAddress)
896
{
929
{
(-)a/src/internet/model/udp-socket-impl.h (-1 / +2 lines)
 Lines 93-98    Link Here 
93
  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
93
  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
94
                                Address &fromAddress);
94
                                Address &fromAddress);
95
  virtual int GetSockName (Address &address) const; 
95
  virtual int GetSockName (Address &address) const; 
96
  virtual int GetPeerName (Address &address) const;
96
  virtual int MulticastJoinGroup (uint32_t interfaceIndex, const Address &groupAddress);
97
  virtual int MulticastJoinGroup (uint32_t interfaceIndex, const Address &groupAddress);
97
  virtual int MulticastLeaveGroup (uint32_t interfaceIndex, const Address &groupAddress);
98
  virtual int MulticastLeaveGroup (uint32_t interfaceIndex, const Address &groupAddress);
98
  virtual void BindToNetDevice (Ptr<NetDevice> netdevice);
99
  virtual void BindToNetDevice (Ptr<NetDevice> netdevice);
 Lines 227-233    Link Here 
227
  uint16_t m_defaultPort;   //!< Default port
228
  uint16_t m_defaultPort;   //!< Default port
228
  TracedCallback<Ptr<const Packet> > m_dropTrace; //!< Trace for dropped packets
229
  TracedCallback<Ptr<const Packet> > m_dropTrace; //!< Trace for dropped packets
229
230
230
  enum SocketErrno         m_errno;           //!< Socket error code
231
  mutable enum SocketErrno m_errno;           //!< Socket error code
231
  bool                     m_shutdownSend;    //!< Send no longer allowed
232
  bool                     m_shutdownSend;    //!< Send no longer allowed
232
  bool                     m_shutdownRecv;    //!< Receive no longer allowed
233
  bool                     m_shutdownRecv;    //!< Receive no longer allowed
233
  bool                     m_connected;       //!< Connection established
234
  bool                     m_connected;       //!< Connection established
(-)a/src/network/model/socket.h (+7 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
   * \brief Get peer address of connected socket.
565
   * \param address the address this socket is connected to.
566
   * \returns 0 if success, -1 otherwise
567
   */
568
  virtual int GetPeerName (Address &address) const = 0;
569
570
  /**
564
   * \brief Bind a socket to specific device.
571
   * \brief Bind a socket to specific device.
565
   *
572
   *
566
   * This method corresponds to using setsockopt() SO_BINDTODEVICE
573
   * 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 133-138    Link Here 
133
  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
133
  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
134
                                Address &fromAddress);
134
                                Address &fromAddress);
135
  virtual int GetSockName (Address &address) const; 
135
  virtual int GetSockName (Address &address) const; 
136
  virtual int GetPeerName (Address &address) const;
136
  virtual bool SetAllowBroadcast (bool allowBroadcast);
137
  virtual bool SetAllowBroadcast (bool allowBroadcast);
137
  virtual bool GetAllowBroadcast () const;
138
  virtual bool GetAllowBroadcast () const;
138
139
 Lines 177-183    Link Here 
177
  };
178
  };
178
179
179
  Ptr<Node> m_node;         //!< the associated node
180
  Ptr<Node> m_node;         //!< the associated node
180
  enum SocketErrno m_errno; //!< Socket error code
181
  mutable enum SocketErrno m_errno; //!< Socket error code
181
  bool m_shutdownSend;      //!< Send no longer allowed
182
  bool m_shutdownSend;      //!< Send no longer allowed
182
  bool m_shutdownRecv;      //!< Receive no longer allowed
183
  bool m_shutdownRecv;      //!< Receive no longer allowed
183
  enum State m_state;       //!< Socket state
184
  enum State m_state;       //!< Socket state

Return to bug 1835