VR-Link API Documentation for HLA Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vlDisSocket.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (c) 2015 VT MAK
3  * All rights reserved.
4  ****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vlutil/vlInetUdpSocket.h>
14 #include <vlutil/vlNetTimeStamp.h>
15 #include <vlutil/vlList.h>
16 #include <set>
17 
20 
23 
24 
25 #ifdef DtUSE_UTILITIES_NAMESPACE
26 namespace DtUSE_UTILITIES_NAMESPACE
27 {
28 #endif
29 
30 #define DtDEFAULT_DIS_PORT 3000
31 
32 #define DtDIS_HEADER_PROTOCOL_VERSION_BYTE_OFFSET 0
33 #define DtDIS_HEADER_EXERCISE_IDENTIFIER_BYTE_OFFSET 1
34 #define DtDIS_HEADER_PDU_TYPE_BYTE_OFFSET 2
35 #define DtDIS_HEADER_PROTOCOL_FAMILY_BYTE_OFFSET 3
36 #define DtDIS_HEADER_TIMESTAMP_BYTE_OFFSET 4
37 #define DtDIS_HEADER_LENGTH_BYTE_OFFSET 8
38 #define DtDIS_HEADER_PDU_STATUS_BYTE_OFFSET 10
39 
40 // Mask to extract the Coupled Extension Indicator from bit 3 (00001000)
41 #define DtDIS_HEADER_CEI_QUERY_MASK 0x8
42 
45 {
46  public:
47  DtPduFilterTest() { disableTest();}
48  virtual ~DtPduFilterTest() {}
49 
50  void disableTest() { setTest(DtPduTest_NEQ, 0, 0); }
51  void setTest(DtPduTestOperator op, DtU32 value) { setTest(op, 1, &value); }
52  void extendTest(DtU32 value) { extendTest (1, &value); }
53  void reduceTest(DtU32 value) { reduceTest (1, &value); }
54  virtual void setOperator(DtPduTestOperator op);
55  virtual void setTest(DtPduTestOperator op, int n, DtU32 *values);
56  virtual void extendTest(int n, DtU32 *values);
57  virtual void reduceTest(int n, DtU32 *values);
58 
59  virtual bool evalTest(void* buf, int offset, DtPduFilterType type);
60 
61  protected:
62 
63  virtual void clearList();
66 };
67 
68 class DtDisSockPimpl;
69 
74 {
75 public:
98  DtDisSocket( const DtInetEndpoint& dest, DtU16 localPort = 0,
99  DtInetDevice* hostIf = NULL, DtU32 flags = DtDefaultSockOpts,
100  bool immediateOpen = true,
101  bool suppressSelfReflectEnabled = false );
102 
104  virtual ~DtDisSocket();
105 
112  virtual bool openSocket();
113 
120  virtual bool closeSocket();
121 
127  virtual int send( caddr_t packet, size_t size, DtU32 flags = 0 );
129  virtual int sendTo( caddr_t packet, size_t size,
130  DtInetEndpoint& dest, DtU32 flags = 0 );
131 
132  virtual int sendChain( DtInetBufferChain& packets, DtU32 flags = 0 );
134  virtual int sendChainTo( DtInetBufferChain& packets,
135  DtInetEndpoint& dest, DtU32 flags = 0 );
137 
143  virtual DtInetSockRcvStatus recvFrom( caddr_t buff, size_t buffSize,
144  DtInetEndpoint& src,
145  DtU32 flags = 0 );
146 
150  virtual bool addDestination(const DtInetEndpoint& destination);
151 
154  virtual void removeDestination(const DtInetEndpoint& destination);
155 
160 
161  virtual bool setNonBlockingOption( bool onOrOff );
162  virtual bool setSendBufferSize( DtU32 size );
163  virtual bool setReceiveBufferSize( DtU32 size );
164  virtual bool setBroadcastOption( bool onOrOff );
165  virtual bool setReuseAddressOption( bool onOrOff );
166  virtual bool setDoNotRouteOption( bool onOrOff );
167  virtual bool setSendLowWatermark( DtU32 size );
168  virtual bool setReceiveLowWatermark( DtU32 size );
169  virtual bool setMcastDevice( const DtInetAddr& devAddr );
170  virtual bool setMcastTtlOption( DtU32 ttl );
171 
173 
182 
183  virtual bool sendSockJoinMulticastGroup( DtInetAddr grpAddr, DtInetDevice* device = NULL );
184  virtual bool sendSockJoinMulticastGroup( DtInetEndpoint grpEndpoint, DtInetDevice* device = NULL );
185  virtual bool sendSockDropMulticastGroup( DtInetAddr grpAddr, DtInetDevice* device = NULL );
186  virtual bool sendSockDropMulticastGroup( DtInetEndpoint grpEndpoint, DtInetDevice* device = NULL );
187 
189 
192 
196 
201  virtual void setBundling( int maxBundleSize, int sizeOffset, int sizeLength,
202  bool testDisHeader );
204 
210  virtual bool setMaxBundleSize( int size );
211  virtual int getMaxBundleSize();
212  virtual bool isBundling();
214 
219  virtual void setMinPacketSize( int size );
220  virtual int minPacketSize();
222 
225  virtual void setBundleByteAlignment( DtU32 size );
226  virtual DtU32 sendBundleByteAlignment();
227  // Return the bundle by alignment for the given protocol version
228  virtual DtU32 receiveBundleByteAlignment(int protocolVersion);
230 
232  virtual DtPduFilterTest *exerciseId();
233  virtual DtPduFilterTest *protocolVersion();
234  virtual DtPduFilterTest *pduKind();
235  virtual DtPduFilterTest *ipAddr();
236 
239  virtual DtInetEndpoint& localSenderEndpoint() const;
240 
242  virtual DtInetSockFlushStatus flush();
243 
248  virtual int addToBundle( int size, DtInetBufferChain& buffChain,
249  DtInetEndpoint& ep );
250  virtual int unbundle( int size, DtInetBufferChain& buffChain,
251  DtInetEndpoint& ep, int* status );
252  virtual int getNextBundle( int size, DtInetBufferChain& buffChain,
253  DtInetEndpoint& ep, int* status );
254  virtual DtInetSockFlushStatus flushBundle( DtInetEndpoint& ep );
256 
259  virtual int suppressSelfReflect( int size, DtInetBufferChain& buffChain,
260  DtInetEndpoint& ep, int* status );
261 
264  virtual int filterExercisePdus( int size, DtInetBufferChain& buffChain,
265  DtInetEndpoint& ep, int* status );
266 
268  virtual int minSizeFilter( int size, DtInetBufferChain& buffChain,
269  DtInetEndpoint& ep, int* status);
270 
271 protected:
273  virtual void* disSendSocket();
274 
281  static int addToBundle( DtInetSocket* sock, int size,
282  DtInetBufferChain& buffChain, DtInetEndpoint& ep,
283  void* usr );
284  static int flushBundle( DtInetSocket* sock, int size,
285  DtInetBufferChain& buffChain, DtInetEndpoint& ep,
286  void* usr );
287  static int unbundle( DtInetSocket* sock, int size,
288  DtInetBufferChain& buffChain, DtInetEndpoint& ep,
289  void* usr );
290  static int getNextBundle( DtInetSocket* sock, int size,
291  DtInetBufferChain& buffChain, DtInetEndpoint& ep,
292  void* usr );
294 
297  static int suppressSelfReflect( DtInetSocket* sock, int size,
298  DtInetBufferChain& buffChain,
299  DtInetEndpoint& ep, void* usr );
300 
303  static int filterExercisePdus( DtInetSocket* sock, int size,
304  DtInetBufferChain& buffChain,
305  DtInetEndpoint& ep, void* usr );
306 
308  static int minSizeFilter( DtInetSocket* sock, int size,
309  DtInetBufferChain& buffChain,
310  DtInetEndpoint& ep, void* usr );
311 
312  // Determine size of PDU during unbundling
313  struct DtDisSocketPduHeader; // forward declaration.
314  virtual DtU16 getPduSize( DtDisSocketPduHeader* hdr,
315  int hdrOffset, DtInetBufferChain::iterator current,
316  DtInetBufferChain::iterator end, int* status, bool& isCoupling, bool expectAttributePdu = false);
317 
318  // Determine size of a Coupled PDU during unbundling
319  virtual DtU16 getCoupledAttributePduSize( DtDisSocketPduHeader* hdr,
320  int hdrOffset, DtInetBufferChain::iterator current,
321  DtInetBufferChain::iterator end, int* status, int pduLengthAndPadding );
322 
323  // From the given iterator walk through chain for the given offset number of bytes.
324  // Return an iterator to the buffer containing the offset or end if offset past end of chain.
325  virtual DtInetBufferChain::iterator advanceToOffset(DtU16& offset,
326  DtInetBufferChain::iterator chainIter, DtInetBufferChain::iterator chainEnd);
327 
328 
329 private:
331  DtDisSocket( const DtDisSocket& orig );
332 
334  DtDisSocket& operator=(const DtDisSocket& orig);
336  friend class DtDisSockPimpl;
337  DtDisSockPimpl* myAsyncSendSockPimpl;
338 
339 protected:
340  // The send socket is only used when self-reflect filtering is enabled
341 
345 
349 
351  std::set<DtInetEndpoint> myAdditionalDestinations;
352 
354 
355  // Bundle buffers and control members
358 
359  int myMaxBundleSize; // outbound only
361  int myMinPacketSize; // inbound only
362 
363  /* per Document IST-CR-93-15 Section 5.3.15 */
365  {
374  };
375 
380 
383 
384 };
385 // end of class DtDisSocket
386 
388 {
389  return &myExerciseFilter;
390 }
391 
393 {
394  return &myVersionFilter;
395 }
396 
398 {
399  return &myKindFilter;
400 }
401 
403 {
404  return &myAddrFilter;
405 }
406 
407 
408 #ifdef DtUSE_UTILITIES_NAMESPACE
409 }
410 #endif
411 

Document ID: Generated on Fri Dec 2 02:42:08 EST 2016 from SVN revision 171416
Copyright © 2005-2016 VT MÄK. All Rights Reserved (www.mak.com)