784 * \brief Ask if the socket is currently passing information about IPv6 Hop Limit up the stack |
804 * \brief Ask if the socket is currently passing information about IPv6 Hop Limit up the stack |
785 * |
805 * |
786 * This method corresponds to using getsockopt () IPV6_RECVHOPLIMIT of real |
806 * This method corresponds to using getsockopt () IPV6_RECVHOPLIMIT of real |
787 * network or BSD sockets. |
807 * network or BSD sockets. |
788 * |
808 * |
789 * \return Wheter the IPV6_RECVHOPLIMIT is set |
809 * \return Whether the IPV6_RECVHOPLIMIT is set |
790 */ |
810 */ |
791 bool IsIpv6RecvHopLimit (void) const; |
811 bool IsIpv6RecvHopLimit (void) const; |
792 |
812 |
793 protected: |
813 protected: |
|
814 /** |
|
815 * \brief Notify through the callback (if set) that the connection has been |
|
816 * established. |
|
817 */ |
794 void NotifyConnectionSucceeded (void); |
818 void NotifyConnectionSucceeded (void); |
|
819 |
|
820 /** |
|
821 * \brief Notify through the callback (if set) that the connection has not been |
|
822 * established due to an error. |
|
823 */ |
795 void NotifyConnectionFailed (void); |
824 void NotifyConnectionFailed (void); |
|
825 |
|
826 /** |
|
827 * \brief Notify through the callback (if set) that the connection has been |
|
828 * closed. |
|
829 */ |
796 void NotifyNormalClose (void); |
830 void NotifyNormalClose (void); |
|
831 |
|
832 /** |
|
833 * \brief Notify through the callback (if set) that the connection has been |
|
834 * closed due to an error. |
|
835 */ |
797 void NotifyErrorClose (void); |
836 void NotifyErrorClose (void); |
|
837 |
|
838 /** |
|
839 * \brief Notify through the callback (if set) that an incoming connection |
|
840 * is being requested by a remote host. |
|
841 * |
|
842 * This function returns true by default (i.e., accept all the incoming connections). |
|
843 * The callback (if set) might restrict this behaviour by returning zero for a |
|
844 * connection that should be refused. |
|
845 * |
|
846 * \param from the address the connection is incoming from |
|
847 * \returns true if the connection must be accepted, false otherwise. |
|
848 */ |
798 bool NotifyConnectionRequest (const Address &from); |
849 bool NotifyConnectionRequest (const Address &from); |
|
850 |
|
851 /** |
|
852 * \brief Notify through the callback (if set) that a new connection has been |
|
853 * created. |
|
854 */ |
799 void NotifyNewConnectionCreated (Ptr<Socket> socket, const Address &from); |
855 void NotifyNewConnectionCreated (Ptr<Socket> socket, const Address &from); |
|
856 |
|
857 /** |
|
858 * \brief Notify through the callback (if set) that some data have been sent. |
|
859 * |
|
860 * \param size number of sent bytes. |
|
861 */ |
800 void NotifyDataSent (uint32_t size); |
862 void NotifyDataSent (uint32_t size); |
|
863 |
|
864 /** |
|
865 * \brief Notify through the callback (if set) that some data have been sent. |
|
866 * |
|
867 * \param spaceAvailable the number of bytes available in the transmission buffer. |
|
868 */ |
801 void NotifySend (uint32_t spaceAvailable); |
869 void NotifySend (uint32_t spaceAvailable); |
|
870 |
|
871 /** |
|
872 * \brief Notify through the callback (if set) that some data have been received. |
|
873 */ |
802 void NotifyDataRecv (void); |
874 void NotifyDataRecv (void); |
|
875 |
|
876 // inherited function, no doc necessary |
803 virtual void DoDispose (void); |
877 virtual void DoDispose (void); |
804 |
878 |
|
879 /** |
|
880 * \brief Checks if the socket has a specific IPv4 ToS set |
|
881 * |
|
882 * \returns true if the socket has a IPv4 ToS set, false otherwise. |
|
883 */ |
805 bool IsManualIpTos (void) const; |
884 bool IsManualIpTos (void) const; |
|
885 |
|
886 /** |
|
887 * \brief Checks if the socket has a specific IPv6 Tclass set |
|
888 * |
|
889 * \returns true if the socket has a IPv6 Tclass set, false otherwise. |
|
890 */ |
806 bool IsManualIpv6Tclass (void) const; |
891 bool IsManualIpv6Tclass (void) const; |
|
892 |
|
893 /** |
|
894 * \brief Checks if the socket has a specific IPv4 TTL set |
|
895 * |
|
896 * \returns true if the socket has a IPv4 TTL set, false otherwise. |
|
897 */ |
807 bool IsManualIpTtl (void) const; |
898 bool IsManualIpTtl (void) const; |
|
899 |
|
900 /** |
|
901 * \brief Checks if the socket has a specific IPv6 Hop Limit set |
|
902 * |
|
903 * \returns true if the socket has a IPv6 Hop Limit set, false otherwise. |
|
904 */ |
808 bool IsManualIpv6HopLimit (void) const; |
905 bool IsManualIpv6HopLimit (void) const; |
809 |
906 |
810 Ptr<NetDevice> m_boundnetdevice; |
907 Ptr<NetDevice> m_boundnetdevice; //!< the device this socket is bound to (might be null). |
811 bool m_recvPktInfo; |
908 bool m_recvPktInfo; //!< if the socket should add packet info tags to the packet forwarded to L4. |
812 |
909 |
813 private: |
910 private: |
814 Callback<void, Ptr<Socket> > m_connectionSucceeded; |
911 Callback<void, Ptr<Socket> > m_connectionSucceeded; //!< connection succeeded callback |
815 Callback<void, Ptr<Socket> > m_connectionFailed; |
912 Callback<void, Ptr<Socket> > m_connectionFailed; //!< connection failed callback |
816 Callback<void, Ptr<Socket> > m_normalClose; |
913 Callback<void, Ptr<Socket> > m_normalClose; //!< connection closed callback |
817 Callback<void, Ptr<Socket> > m_errorClose; |
914 Callback<void, Ptr<Socket> > m_errorClose; //!< connection closed due to errors callback |
818 Callback<bool, Ptr<Socket>, const Address &> m_connectionRequest; |
915 Callback<bool, Ptr<Socket>, const Address &> m_connectionRequest; //!< connection request callback |
819 Callback<void, Ptr<Socket>, const Address&> m_newConnectionCreated; |
916 Callback<void, Ptr<Socket>, const Address&> m_newConnectionCreated; //!< connection created callback |
820 Callback<void, Ptr<Socket>, uint32_t> m_dataSent; |
917 Callback<void, Ptr<Socket>, uint32_t> m_dataSent; //!< data sent callback |
821 Callback<void, Ptr<Socket>, uint32_t > m_sendCb; |
918 Callback<void, Ptr<Socket>, uint32_t > m_sendCb; //!< packet sent callback |
822 Callback<void, Ptr<Socket> > m_receivedData; |
919 Callback<void, Ptr<Socket> > m_receivedData; //!< data received callback |
823 |
920 |
824 //IPv4 options |
921 //IPv4 options |
825 bool m_manualIpTos; |
922 bool m_manualIpTos; //!< socket has IPv4 TOS set |
826 bool m_manualIpTtl; |
923 bool m_manualIpTtl; //!< socket has IPv4 TTL set |
827 bool m_ipRecvTos; |
924 bool m_ipRecvTos; //!< socket forwards IPv4 TOS tag to L4 |
828 bool m_ipRecvTtl; |
925 bool m_ipRecvTtl; //!< socket forwards IPv4 TTL tag to L4 |
829 |
926 |
830 uint8_t m_ipTos; |
927 uint8_t m_ipTos; //!< the socket IPv4 TOS |
831 uint8_t m_ipTtl; |
928 uint8_t m_ipTtl; //!< the socket IPv4 TTL |
832 |
929 |
833 //IPv6 options |
930 //IPv6 options |
834 bool m_manualIpv6Tclass; |
931 bool m_manualIpv6Tclass; //!< socket has IPv6 Tclass set |
835 bool m_manualIpv6HopLimit; |
932 bool m_manualIpv6HopLimit; //!< socket has IPv6 Hop Limit set |
836 bool m_ipv6RecvTclass; |
933 bool m_ipv6RecvTclass; //!< socket forwards IPv6 Tclass tag to L4 |
837 bool m_ipv6RecvHopLimit; |
934 bool m_ipv6RecvHopLimit; //!< socket forwards IPv6 Hop Limit tag to L4 |
838 |
935 |
839 uint8_t m_ipv6Tclass; |
936 uint8_t m_ipv6Tclass; //!< the socket IPv6 Tclass |
840 uint8_t m_ipv6HopLimit; |
937 uint8_t m_ipv6HopLimit; //!< the socket IPv6 Hop Limit |
841 }; |
938 }; |
842 |
939 |
843 /** |
940 /** |
844 * \brief This class implements a tag that carries an address |
941 * \brief This class implements a tag that carries an address |
845 * of a packet across the socket interface. |
942 * of a packet across the socket interface. |
846 */ |
943 */ |
847 class SocketAddressTag : public Tag |
944 class SocketAddressTag : public Tag |
848 { |
945 { |
849 public: |
946 public: |
850 SocketAddressTag (); |
947 SocketAddressTag (); |
|
948 |
|
949 /** |
|
950 * \brief Set the tag's address |
|
951 * |
|
952 * \param addr the address |
|
953 */ |
851 void SetAddress (Address addr); |
954 void SetAddress (Address addr); |
|
955 |
|
956 /** |
|
957 * \brief Get the tag's address |
|
958 * |
|
959 * \returns the address |
|
960 */ |
852 Address GetAddress (void) const; |
961 Address GetAddress (void) const; |
853 |
962 |
|
963 /** |
|
964 * \brief Get the type ID. |
|
965 * \return the object TypeId |
|
966 */ |
854 static TypeId GetTypeId (void); |
967 static TypeId GetTypeId (void); |
|
968 |
|
969 // inherited function, no need to doc. |
855 virtual TypeId GetInstanceTypeId (void) const; |
970 virtual TypeId GetInstanceTypeId (void) const; |
|
971 |
|
972 // inherited function, no need to doc. |
856 virtual uint32_t GetSerializedSize (void) const; |
973 virtual uint32_t GetSerializedSize (void) const; |
|
974 |
|
975 // inherited function, no need to doc. |
857 virtual void Serialize (TagBuffer i) const; |
976 virtual void Serialize (TagBuffer i) const; |
|
977 |
|
978 // inherited function, no need to doc. |
858 virtual void Deserialize (TagBuffer i); |
979 virtual void Deserialize (TagBuffer i); |
|
980 |
|
981 // inherited function, no need to doc. |
859 virtual void Print (std::ostream &os) const; |
982 virtual void Print (std::ostream &os) const; |
860 |
983 |
861 private: |
984 private: |
862 Address m_address; |
985 Address m_address; //!< the address carried by the tag |
863 }; |
986 }; |
864 |
987 |
865 /** |
988 /** |
866 * \brief This class implements a tag that carries the socket-specific |
989 * \brief This class implements a tag that carries the socket-specific |
867 * TTL of a packet to the IP layer |
990 * TTL of a packet to the IP layer |
868 */ |
991 */ |
869 class SocketIpTtlTag : public Tag |
992 class SocketIpTtlTag : public Tag |
870 { |
993 { |
871 public: |
994 public: |
872 SocketIpTtlTag (); |
995 SocketIpTtlTag (); |
|
996 |
|
997 /** |
|
998 * \brief Set the tag's TTL |
|
999 * |
|
1000 * \param ttl the TTL |
|
1001 */ |
873 void SetTtl (uint8_t ttl); |
1002 void SetTtl (uint8_t ttl); |
|
1003 |
|
1004 /** |
|
1005 * \brief Get the tag's TTL |
|
1006 * |
|
1007 * \returns the TTL |
|
1008 */ |
874 uint8_t GetTtl (void) const; |
1009 uint8_t GetTtl (void) const; |
875 |
1010 |
|
1011 /** |
|
1012 * \brief Get the type ID. |
|
1013 * \return the object TypeId |
|
1014 */ |
876 static TypeId GetTypeId (void); |
1015 static TypeId GetTypeId (void); |
|
1016 |
|
1017 // inherited function, no need to doc. |
877 virtual TypeId GetInstanceTypeId (void) const; |
1018 virtual TypeId GetInstanceTypeId (void) const; |
|
1019 |
|
1020 // inherited function, no need to doc. |
878 virtual uint32_t GetSerializedSize (void) const; |
1021 virtual uint32_t GetSerializedSize (void) const; |
|
1022 |
|
1023 // inherited function, no need to doc. |
879 virtual void Serialize (TagBuffer i) const; |
1024 virtual void Serialize (TagBuffer i) const; |
|
1025 |
|
1026 // inherited function, no need to doc. |
880 virtual void Deserialize (TagBuffer i); |
1027 virtual void Deserialize (TagBuffer i); |
|
1028 |
|
1029 // inherited function, no need to doc. |
881 virtual void Print (std::ostream &os) const; |
1030 virtual void Print (std::ostream &os) const; |
882 |
1031 |
883 private: |
1032 private: |
884 uint8_t m_ttl; |
1033 uint8_t m_ttl; //!< the ttl carried by the tag |
885 }; |
1034 }; |
886 |
1035 |
887 /** |
1036 /** |
888 * \brief This class implements a tag that carries the socket-specific |
1037 * \brief This class implements a tag that carries the socket-specific |
889 * HOPLIMIT of a packet to the IPv6 layer |
1038 * HOPLIMIT of a packet to the IPv6 layer |
890 */ |
1039 */ |
891 class SocketIpv6HopLimitTag : public Tag |
1040 class SocketIpv6HopLimitTag : public Tag |
892 { |
1041 { |
893 public: |
1042 public: |
894 SocketIpv6HopLimitTag (); |
1043 SocketIpv6HopLimitTag (); |
|
1044 |
|
1045 /** |
|
1046 * \brief Set the tag's Hop Limit |
|
1047 * |
|
1048 * \param hopLimit the Hop Limit |
|
1049 */ |
895 void SetHopLimit (uint8_t hopLimit); |
1050 void SetHopLimit (uint8_t hopLimit); |
|
1051 |
|
1052 /** |
|
1053 * \brief Get the tag's Hop Limit |
|
1054 * |
|
1055 * \returns the Hop Limit |
|
1056 */ |
896 uint8_t GetHopLimit (void) const; |
1057 uint8_t GetHopLimit (void) const; |
897 |
1058 |
|
1059 /** |
|
1060 * \brief Get the type ID. |
|
1061 * \return the object TypeId |
|
1062 */ |
898 static TypeId GetTypeId (void); |
1063 static TypeId GetTypeId (void); |
|
1064 |
|
1065 // inherited function, no need to doc. |
899 virtual TypeId GetInstanceTypeId (void) const; |
1066 virtual TypeId GetInstanceTypeId (void) const; |
|
1067 |
|
1068 // inherited function, no need to doc. |
900 virtual uint32_t GetSerializedSize (void) const; |
1069 virtual uint32_t GetSerializedSize (void) const; |
|
1070 |
|
1071 // inherited function, no need to doc. |
901 virtual void Serialize (TagBuffer i) const; |
1072 virtual void Serialize (TagBuffer i) const; |
|
1073 |
|
1074 // inherited function, no need to doc. |
902 virtual void Deserialize (TagBuffer i); |
1075 virtual void Deserialize (TagBuffer i); |
|
1076 |
|
1077 // inherited function, no need to doc. |
903 virtual void Print (std::ostream &os) const; |
1078 virtual void Print (std::ostream &os) const; |
904 |
1079 |
905 private: |
1080 private: |
906 uint8_t m_hopLimit; |
1081 uint8_t m_hopLimit; //!< the Hop Limit carried by the tag |
907 }; |
1082 }; |
908 |
1083 |
909 /** |
1084 /** |
910 * \brief indicated whether packets should be sent out with |
1085 * \brief indicates whether packets should be sent out with |
911 * the DF flag set. |
1086 * the DF (Don't Fragment) flag set. |
912 */ |
1087 */ |
913 class SocketSetDontFragmentTag : public Tag |
1088 class SocketSetDontFragmentTag : public Tag |
914 { |
1089 { |
915 public: |
1090 public: |
916 SocketSetDontFragmentTag (); |
1091 SocketSetDontFragmentTag (); |
|
1092 |
|
1093 /** |
|
1094 * \brief Enables the DF (Don't Fragment) flag |
|
1095 */ |
917 void Enable (void); |
1096 void Enable (void); |
|
1097 |
|
1098 /** |
|
1099 * \brief Disables the DF (Don't Fragment) flag |
|
1100 */ |
918 void Disable (void); |
1101 void Disable (void); |
|
1102 |
|
1103 /** |
|
1104 * \brief Checks if the DF (Don't Fragment) flag is set |
|
1105 * |
|
1106 * \returns true if DF is set. |
|
1107 */ |
919 bool IsEnabled (void) const; |
1108 bool IsEnabled (void) const; |
920 |
1109 |
|
1110 /** |
|
1111 * \brief Get the type ID. |
|
1112 * \return the object TypeId |
|
1113 */ |
921 static TypeId GetTypeId (void); |
1114 static TypeId GetTypeId (void); |
|
1115 |
|
1116 // inherited function, no need to doc. |
922 virtual TypeId GetInstanceTypeId (void) const; |
1117 virtual TypeId GetInstanceTypeId (void) const; |
|
1118 |
|
1119 // inherited function, no need to doc. |
923 virtual uint32_t GetSerializedSize (void) const; |
1120 virtual uint32_t GetSerializedSize (void) const; |
|
1121 |
|
1122 // inherited function, no need to doc. |
924 virtual void Serialize (TagBuffer i) const; |
1123 virtual void Serialize (TagBuffer i) const; |
|
1124 |
|
1125 // inherited function, no need to doc. |
925 virtual void Deserialize (TagBuffer i); |
1126 virtual void Deserialize (TagBuffer i); |
|
1127 |
|
1128 // inherited function, no need to doc. |
926 virtual void Print (std::ostream &os) const; |
1129 virtual void Print (std::ostream &os) const; |
927 private: |
1130 private: |
928 bool m_dontFragment; |
1131 bool m_dontFragment; //!< DF bit value for outgoing packets. |
929 }; |
1132 }; |
930 |
1133 |
931 /* |
1134 /** |
932 * \brief indicated whether the socket has IP_TOS set. |
1135 * \brief indicates whether the socket has IP_TOS set. |
933 * This tag is for IPv4 socket. |
1136 * This tag is for IPv4 socket. |
934 */ |
1137 */ |
935 class SocketIpTosTag : public Tag |
1138 class SocketIpTosTag : public Tag |
936 { |
1139 { |
937 public: |
1140 public: |
938 SocketIpTosTag (); |
1141 SocketIpTosTag (); |
|
1142 |
|
1143 /** |
|
1144 * \brief Set the tag's TOS |
|
1145 * |
|
1146 * \param tos the TOS |
|
1147 */ |
939 void SetTos (uint8_t tos); |
1148 void SetTos (uint8_t tos); |
|
1149 |
|
1150 /** |
|
1151 * \brief Get the tag's TOS |
|
1152 * |
|
1153 * \returns the TOS |
|
1154 */ |
940 uint8_t GetTos (void) const; |
1155 uint8_t GetTos (void) const; |
941 |
1156 |
|
1157 /** |
|
1158 * \brief Get the type ID. |
|
1159 * \return the object TypeId |
|
1160 */ |
942 static TypeId GetTypeId (void); |
1161 static TypeId GetTypeId (void); |
|
1162 |
|
1163 // inherited function, no need to doc. |
943 virtual TypeId GetInstanceTypeId (void) const; |
1164 virtual TypeId GetInstanceTypeId (void) const; |
|
1165 |
|
1166 // inherited function, no need to doc. |
944 virtual uint32_t GetSerializedSize (void) const; |
1167 virtual uint32_t GetSerializedSize (void) const; |
|
1168 |
|
1169 // inherited function, no need to doc. |
945 virtual void Serialize (TagBuffer i) const; |
1170 virtual void Serialize (TagBuffer i) const; |
|
1171 |
|
1172 // inherited function, no need to doc. |
946 virtual void Deserialize (TagBuffer i); |
1173 virtual void Deserialize (TagBuffer i); |
|
1174 |
|
1175 // inherited function, no need to doc. |
947 virtual void Print (std::ostream &os) const; |
1176 virtual void Print (std::ostream &os) const; |
948 private: |
1177 private: |
949 uint8_t m_ipTos; |
1178 uint8_t m_ipTos; //!< the TOS carried by the tag |
950 }; |
1179 }; |
951 |
1180 |
952 /* |
1181 /** |
953 * \brief indicated whether the socket has IPV6_TCLASS set. |
1182 * \brief indicates whether the socket has IPV6_TCLASS set. |
954 * This tag is for IPv6 socket. |
1183 * This tag is for IPv6 socket. |
955 */ |
1184 */ |
956 class SocketIpv6TclassTag : public Tag |
1185 class SocketIpv6TclassTag : public Tag |
957 { |
1186 { |
958 public: |
1187 public: |
959 SocketIpv6TclassTag (); |
1188 SocketIpv6TclassTag (); |
|
1189 |
|
1190 /** |
|
1191 * \brief Set the tag's Tclass |
|
1192 * |
|
1193 * \param tclass the Tclass |
|
1194 */ |
960 void SetTclass (uint8_t tclass); |
1195 void SetTclass (uint8_t tclass); |
|
1196 |
|
1197 /** |
|
1198 * \brief Get the tag's Tclass |
|
1199 * |
|
1200 * \returns the Tclass |
|
1201 */ |
961 uint8_t GetTclass (void) const; |
1202 uint8_t GetTclass (void) const; |
962 |
1203 |
|
1204 /** |
|
1205 * \brief Get the type ID. |
|
1206 * \return the object TypeId |
|
1207 */ |
963 static TypeId GetTypeId (void); |
1208 static TypeId GetTypeId (void); |
|
1209 |
|
1210 // inherited function, no need to doc. |
964 virtual TypeId GetInstanceTypeId (void) const; |
1211 virtual TypeId GetInstanceTypeId (void) const; |
|
1212 |
|
1213 // inherited function, no need to doc. |
965 virtual uint32_t GetSerializedSize (void) const; |
1214 virtual uint32_t GetSerializedSize (void) const; |
|
1215 |
|
1216 // inherited function, no need to doc. |
966 virtual void Serialize (TagBuffer i) const; |
1217 virtual void Serialize (TagBuffer i) const; |
|
1218 |
|
1219 // inherited function, no need to doc. |
967 virtual void Deserialize (TagBuffer i); |
1220 virtual void Deserialize (TagBuffer i); |
|
1221 |
|
1222 // inherited function, no need to doc. |
968 virtual void Print (std::ostream &os) const; |
1223 virtual void Print (std::ostream &os) const; |
969 private: |
1224 private: |
970 uint8_t m_ipv6Tclass; |
1225 uint8_t m_ipv6Tclass; //!< the Tclass carried by the tag |
971 }; |
1226 }; |
972 |
1227 |
973 } // namespace ns3 |
1228 } // namespace ns3 |
974 |
1229 |
975 #endif /* NS3_SOCKET_H */ |
1230 #endif /* NS3_SOCKET_H */ |