CTR Pia  4.11.3
Game Communication Engine
transport_StationLocation.h
1 /*---------------------------------------------------------------------------*
2  Project: Pia
3  File: transport_StationLocation.h
4 
5  Copyright Nintendo. All rights reserved.
6 
7  These coded instructions, statements, and computer programs contain
8  proprietary information of Nintendo of America Inc. and/or Nintendo
9  Company Ltd., and are protected by Federal copyright law. They may
10  not be disclosed to third parties or copied or duplicated in any form,
11  in whole or in part, without the prior written consent of Nintendo.
12  *---------------------------------------------------------------------------*/
13 
14 
15 #pragma once
16 
17 #include <pia/transport/transport_definitions.h>
18 #include <pia/common/common_StationAddress.h>
19 
20 #if !NN_PIA_NEX_3
21 namespace nn
22 {
23 namespace nex
24 {
25 class InetAddress;
26 class StationURL;
27 }
28 }
29 #endif // end of !NN_PIA_NEX_3
30 
31 namespace nn
32 {
33 namespace pia
34 {
35 namespace inet
36 {
37 class NexFacade;
38 }
39 }
40 }
41 
42 namespace nn
43 {
44 namespace pia
45 {
46 namespace transport
47 {
48 
49 // Forward declaration.
50 class StationConnectionInfo;
51 
52 /*!
53 @brief Represents an address used to uniquely identify stations.
54 
55 @date 2012-11-29 Revised code so that the <tt>StationLocation</tt> class does not depend on NEX in NEX 3.X environments.
56 @date 2012-06-28 Clearly indicated which functions are thread-safe.
57 @date 2012-04-06 Initial version.
58 */
60 {
61  friend class StationConnectionInfo;
62  friend class inet::NexFacade;
63 
64 public:
65 #if !NN_PIA_NEX_3
66 /*!
67 @brief Converts an NEX <tt>InetAddress</tt> to a Pia <tt>InetAddress</tt>.
68 
69 @details This function is thread-safe. This function is deprecated.
70 
71 @param[in] nexAddress Specifies the NEX <tt>InetAddress</tt>.
72 @param[out] pAddress Specifies the Pia <tt>InetAddress</tt>.
73 */
74  static void ConvertNexInetAddressToInetAddress(const nn::nex::InetAddress& nexAddress, nn::pia::common::InetAddress* pAddress);
75 
76 /*!
77 @brief Converts a Pia <tt>InetAddress</tt> to an NEX <tt>InetAddress</tt>.
78 
79 @details This function is thread-safe. This function is deprecated.
80 
81 @param[in] address Specifies the Pia <tt>InetAddress</tt>.
82 @param[out] pNexAddress Specifies the NEX <tt>InetAddress</tt>.
83 */
84  static void ConvertInetAddressToNexInetAddress(const nn::pia::common::InetAddress& address, nn::nex::InetAddress* pNexAddress);
85 
86  static void TraceNexAddress(u64 uiTraceFlag, const nn::nex::InetAddress& nexAddress);
87 #endif // end of !NN_PIA_NEX_3
88 
89 /*!
90 @brief Instantiates the object.
91 */
92  StationLocation(void);
93 
94 
95 /*!
96 @brief Instantiates a copy of the object.
97 */
99 
100 
101 /*!
102 @brief Destroys the object.
103 */
104  virtual ~StationLocation(void);
105 
106  void SetStationLocation(const StationLocation& o);
107 
108 /*!
109 @brief This is the assignment operator.
110 
111 @return Returns a reference to the <tt>this</tt> object.
112 */
113  StationLocation& operator=(const StationLocation& o);
114 
115  bool operator==(const StationLocation& o) const;
116 
117  bool operator!=(const StationLocation& o) const
118  {
119  return !(*this == o);
120  }
121 
122  bool IsSameAddress(const StationLocation& o) const
123  {
124  return m_Address.GetInetAddress().GetAddress() == o.m_Address.GetInetAddress().GetAddress();
125  }
126 
127  bool IsSameServerCIdAndUdsNodeId(const StationLocation& o) const
128  {
129  return (m_ServiceConnectionId == o.m_ServiceConnectionId) &&
130  (m_Address.GetExtensionId() == o.m_Address.GetExtensionId());
131  }
132 
133 /*!
134 
135 @brief Gets a <tt>const</tt> reference to the <tt>nn::pia::common::StationAddress</tt> instance.
136 
137 @return Returns a <tt>const</tt> reference to the <tt>nn::pia::common::StationAddress</tt> instance.
138 */
140  {
141  return m_Address;
142  }
143 
144 /*!
145 @brief Gets a reference to the <tt>nn::pia::common::StationAddress</tt> instance.
146 
147 @return Returns a reference to the <tt>nn::pia::common::StationAddress</tt> instance.
148 */
150  {
151  return m_Address;
152  }
153 
154 /*!
155 @brief Sets the <tt>nn::pia::common::StationAddress</tt> instance.
156 
157 @param[in] addr Specifies the Internet address to set.
158 */
159  void SetStationAddress(const nn::pia::common::StationAddress& addr);
160 
161 #if !NN_PIA_NEX_3
162 /*!
163 @brief Gets an <tt>nn::nex::StationURL</tt> object.
164 This function is deprecated.
165 @param[out] pUrl Specifies a pointer to the retrieved <tt>StationURL</tt>.
166 */
167  void GetStationURL(nn::nex::StationURL* pUrl) const;
168 
169 /*!
170 @brief Sets an <tt>nn::nex::StationURL</tt> object.
171 This function is deprecated.
172 @param[in] url Specifies the <tt>StationURL</tt> to set.
173 */
174  void SetStationURL(const nn::nex::StationURL& url);
175 #endif // end of !NN_PIA_NEX_3
176 
177  virtual size_t GetSerializedSize(void) const;
178  virtual nn::Result Serialize(bit8* pBuffer, size_t* pSerializedSize, size_t bufferSize) const;
179  virtual nn::Result Deserialize(const bit8* pData);
180 
181  void SetNexServerConnectionId(u32 o)
182  {
183  m_ServiceConnectionId = o;
184  }
185 
186  u32 GetNexServerConnectionId() const
187  {
188  return m_ServiceConnectionId;
189  }
190 
191  void SetNexUrlType(u8 o)
192  {
193  m_NexUrlType = o;
194  }
195 
196  u8 GetNexUrlType() const
197  {
198  return m_NexUrlType;
199  }
200 
201  void SetProbeRequestInitiation(u8 o)
202  {
203  m_IsProbeRequestInitiation = o;
204  }
205 
206  u8 IsProbeRequestInitiation() const
207  {
208  return m_IsProbeRequestInitiation;
209  }
210 
211  void SetNatTypeFlag(u8 flags)
212  {
213  m_NatTypeFlags = flags;
214  }
215 
216  u8 GetNatTypeFlag() const
217  {
218  return m_NatTypeFlags;
219  }
220 
221  bool IsNatTypeFlagSet(u8 flag) const
222  {
223  return (m_NatTypeFlags & flag) == flag;
224  }
225 
226  void GetLocationString(common::String* pString) const;
227 
228  void SetPrincipalID(u32 principalId)
229  {
230  m_NexPrincipalId = principalId;
231  }
232 
233  u32 GetPrincipalID() const
234  {
235  return m_NexPrincipalId;
236  }
237 
238  void SetNatMapping(u8 o)
239  {
240  m_NatMapping = o;
241  }
242 
243  u8 GetNatMapping() const
244  {
245  return m_NatMapping;
246  }
247 
248  void SetNatFiltering(u8 o)
249  {
250  m_NatFiltering = o;
251  }
252 
253  u8 GetNatFiltering() const
254  {
255  return m_NatFiltering;
256  }
257 
258  void SetNexConnectionId(u32 o)
259  {
260  m_NexConnectionId = o;
261  }
262 
263  u32 GetNexConnectionId() const
264  {
265  return m_NexConnectionId;
266  }
267 
268  void SetNexStreamId(u8 o)
269  {
270  m_NexStreamId = o;
271  }
272 
273  u8 GetNexStreamId() const
274  {
275  return m_NexStreamId;
276  }
277 
278  void SetNexStreamType(u8 o)
279  {
280  m_NexStreamType = o;
281  }
282 
283  u8 GetNexStreamType() const
284  {
285  return m_NexStreamType;
286  }
287 
288 /*!
289 @brief Prints information that is useful for debugging.
290 
291 @param[in] flag Specifies the bitwise OR of trace flags. For more information, see the <tt>@ref TraceFlag</tt> type.
292 */
293  virtual void Trace(u64 flag) const;
294 
295 private:
296  common::StationAddress m_Address;
297 
298  //n1589: Can avoid NEX dependency by making these a different type
299  // nn::nex::PrincipalID
300  u32 m_NexPrincipalId;
301  // nn::nex::ConnectionID
302  u32 m_NexConnectionId;
303  // nn::nex::ConnectionID
304  u32 m_ServiceConnectionId;
305 
306  // nn::nex::StationURL::URLType
307  u8 m_NexUrlType;
308  // nn::nex::Stream::ID
309  u8 m_NexStreamId;
310  // nn::nex::Stream::Type
311  u8 m_NexStreamType;
312 
313  // nn::nex::NATProperties::MappingProperties
314  u8 m_NatMapping;
315  // nn::nex::NATProperties::FilteringProperties
316  u8 m_NatFiltering;
317 
318  u8 m_NatTypeFlags;
319 
320  u8 m_IsProbeRequestInitiation;
321 };
322 }
323 }
324 }
Definition: assert.h:115
const nn::pia::common::StationAddress & GetStationAddress(void) const
Gets a const reference to the nn::pia::common::StationAddress instance.
Definition: transport_StationLocation.h:139
Class for representing strings.
Definition: common_String.h:35
u32 GetAddress() const
Gets the IP address in host byte order.
Definition: common_InetAddress.h:111
const nn::pia::common::InetAddress & GetInetAddress(void) const
Gets a const reference to an nn::pia::common::InetAddress instance.
Definition: common_StationAddress.h:132
Represents an address used to uniquely identify stations. .
Definition: common_StationAddress.h:43
Represents an address used to uniquely identify stations.
Definition: transport_StationConnectionInfo.h:35
nn::pia::common::StationAddress & GetStationAddress(void)
Gets a reference to the nn::pia::common::StationAddress instance.
Definition: transport_StationLocation.h:149
Represents the NEX library facade (interface wrapper) class.
Definition: inet_NexFacade.h:136
Class that represents an Internet address.
Definition: common_InetAddress.h:52
Represents an address used to uniquely identify stations.
Definition: transport_StationLocation.h:59
This is the common base class used inside the Pia library.
Definition: common_RootObject.h:40