VR-Link API Documentation for HLA 1.3
 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 
13 #include <vlutil/vlInetUdpSocket.h>
15 #include <vlutil/vlNetTimeStamp.h>
16 #include <vlutil/vlList.h>
17 #include <set>
18 
19 
22 
25 
26 
27 #ifdef DtUSE_UTILITIES_NAMESPACE
28 namespace DtUSE_UTILITIES_NAMESPACE
29 {
30 #endif
31 
32 #define DtDEFAULT_DIS_PORT 3000
33 
34 #define DtDIS_HEADER_PROTOCOL_VERSION_BYTE_OFFSET 0
35 #define DtDIS_HEADER_EXERCISE_IDENTIFIER_BYTE_OFFSET 1
36 #define DtDIS_HEADER_PDU_TYPE_BYTE_OFFSET 2
37 #define DtDIS_HEADER_PROTOCOL_FAMILY_BYTE_OFFSET 3
38 #define DtDIS_HEADER_TIMESTAMP_BYTE_OFFSET 4
39 #define DtDIS_HEADER_LENGTH_BYTE_OFFSET 8
40 #define DtDIS_HEADER_PDU_STATUS_BYTE_OFFSET 10
41 
42 // Mask to extract the Coupled Extension Indicator from bit 3 (00001000)
43 #define DtDIS_HEADER_CEI_QUERY_MASK 0x8
44 
47 {
48  public:
49  DtPduFilterTest() { disableTest();}
50  virtual ~DtPduFilterTest() {}
51 
52  void disableTest() { setTest(DtPduTest_NEQ, 0, 0); }
53  void setTest(DtPduTestOperator op, DtU32 value) { setTest(op, 1, &value); }
54  void extendTest(DtU32 value) { extendTest (1, &value); }
55  void reduceTest(DtU32 value) { reduceTest (1, &value); }
56  virtual void setOperator(DtPduTestOperator op);
57  virtual void setTest(DtPduTestOperator op, int n, DtU32 *values);
58  virtual void extendTest(int n, DtU32 *values);
59  virtual void reduceTest(int n, DtU32 *values);
60 
61  virtual bool evalTest(void* buf, int offset, DtPduFilterType type);
62 
63  protected:
64 
65  virtual void clearList();
68 };
69 
70 class DtDisSockPimpl;
71 
76 {
77 public:
100  DtDisSocket( const DtInetEndpoint& dest, DtU16 localPort = 0,
101  DtInetDevice* hostIf = NULL, DtU32 flags = DtDefaultSockOpts,
102  bool immediateOpen = true,
103  bool suppressSelfReflectEnabled = false );
104 
106  virtual ~DtDisSocket();
107 
114  virtual bool openSocket();
115 
122  virtual bool closeSocket();
123 
129  virtual int send( caddr_t packet, size_t size, DtU32 flags = 0 );
131  virtual int sendTo( caddr_t packet, size_t size,
132  DtInetEndpoint& dest, DtU32 flags = 0 );
133 
134  virtual int sendChain( DtInetBufferChain& packets, DtU32 flags = 0 );
136  virtual int sendChainTo( DtInetBufferChain& packets,
137  DtInetEndpoint& dest, DtU32 flags = 0 );
139 
145  virtual DtInetSockRcvStatus recvFrom( caddr_t buff, size_t buffSize,
146  DtInetEndpoint& src,
147  DtU32 flags = 0 );
148 
152  virtual bool addDestination(const DtInetEndpoint& destination);
153 
156  virtual void removeDestination(const DtInetEndpoint& destination);
157 
162 
163  virtual bool setNonBlockingOption( bool onOrOff );
164  virtual bool setSendBufferSize( DtU32 size );
165  virtual bool setReceiveBufferSize( DtU32 size );
166  virtual bool setBroadcastOption( bool onOrOff );
167  virtual bool setReuseAddressOption( bool onOrOff );
168  virtual bool setDoNotRouteOption( bool onOrOff );
169  virtual bool setSendLowWatermark( DtU32 size );
170  virtual bool setReceiveLowWatermark( DtU32 size );
171  virtual bool setSendMcastDevice( const DtInetAddr& devAddr );
172  virtual bool setMcastTtlOption( DtU32 ttl );
173 
175 
184 
185  virtual bool sendSockJoinMulticastGroup( DtInetAddr grpAddr, DtInetDevice* device = NULL );
186  virtual bool sendSockJoinMulticastGroup( DtInetEndpoint grpEndpoint, DtInetDevice* device = NULL );
187  virtual bool sendSockDropMulticastGroup( DtInetAddr grpAddr, DtInetDevice* device = NULL );
188  virtual bool sendSockDropMulticastGroup( DtInetEndpoint grpEndpoint, DtInetDevice* device = NULL );
189 
191 
194 
198 
203  virtual void setBundling( int maxBundleSize, int sizeOffset, int sizeLength,
204  bool testDisHeader );
206 
212  virtual bool setMaxBundleSize( int size );
213  virtual int getMaxBundleSize();
214  virtual bool isBundling();
216 
221  virtual void setMinPacketSize( int size );
222  virtual int minPacketSize();
224 
227  virtual void setBundleByteAlignment( DtU32 size );
228  virtual DtU32 sendBundleByteAlignment();
229  // Return the bundle by alignment for the given protocol version
230  virtual DtU32 receiveBundleByteAlignment(int protocolVersion);
232 
234  virtual DtPduFilterTest *exerciseId();
235  virtual DtPduFilterTest *protocolVersion();
236  virtual DtPduFilterTest *pduKind();
237  virtual DtPduFilterTest *ipAddr();
238 
241  virtual DtInetEndpoint& localSenderEndpoint() const;
242 
244  virtual DtInetSockFlushStatus flush();
245 
250  virtual int addToBundle( int size, DtInetBufferChain& buffChain,
251  DtInetEndpoint& ep );
252  virtual int unbundle( int size, DtInetBufferChain& buffChain,
253  DtInetEndpoint& ep, int* status );
254  virtual int getNextBundle( int size, DtInetBufferChain& buffChain,
255  DtInetEndpoint& ep, int* status );
256  virtual DtInetSockFlushStatus flushBundle( DtInetEndpoint& ep );
258 
261  virtual int suppressSelfReflect( int size, DtInetBufferChain& buffChain,
262  DtInetEndpoint& ep, int* status );
263 
266  virtual int filterExercisePdus( int size, DtInetBufferChain& buffChain,
267  DtInetEndpoint& ep, int* status );
268 
270  virtual int minSizeFilter( int size, DtInetBufferChain& buffChain,
271  DtInetEndpoint& ep, int* status);
272 
274  virtual void setAttributePduStrategy(DtAttributePduStrategy strat);
275  virtual DtAttributePduStrategy attributePduStrategy() const;
276 
277 protected:
279  virtual void* disSendSocket();
280 
287  static int addToBundle( DtInetSocket* sock, int size,
288  DtInetBufferChain& buffChain, DtInetEndpoint& ep,
289  void* usr );
290  static int flushBundle( DtInetSocket* sock, int size,
291  DtInetBufferChain& buffChain, DtInetEndpoint& ep,
292  void* usr );
293  static int unbundle( DtInetSocket* sock, int size,
294  DtInetBufferChain& buffChain, DtInetEndpoint& ep,
295  void* usr );
296  static int getNextBundle( DtInetSocket* sock, int size,
297  DtInetBufferChain& buffChain, DtInetEndpoint& ep,
298  void* usr );
300 
303  static int suppressSelfReflect( DtInetSocket* sock, int size,
304  DtInetBufferChain& buffChain,
305  DtInetEndpoint& ep, void* usr );
306 
309  static int filterExercisePdus( DtInetSocket* sock, int size,
310  DtInetBufferChain& buffChain,
311  DtInetEndpoint& ep, void* usr );
312 
314  static int minSizeFilter( DtInetSocket* sock, int size,
315  DtInetBufferChain& buffChain,
316  DtInetEndpoint& ep, void* usr );
317 
318  // Determine size of PDU during unbundling
319  struct DtDisSocketPduHeader; // forward declaration.
320  virtual DtU16 getPduSize( DtDisSocketPduHeader* hdr,
321  int hdrOffset, DtInetBufferChain::iterator current,
322  DtInetBufferChain::iterator end, int* status, bool& isCoupling, bool expectAttributePdu = false);
323 
324  // Determine size of a Coupled PDU during unbundling
325  virtual DtU16 getCoupledAttributePduSize( DtDisSocketPduHeader* hdr,
326  int hdrOffset, DtInetBufferChain::iterator current,
327  DtInetBufferChain::iterator end, int* status, int pduLengthAndPadding, unsigned int size);
328 
329  // From the given iterator walk through chain for the given offset number of bytes.
330  // Return an iterator to the buffer containing the offset or end if offset past end of chain.
331  virtual DtInetBufferChain::iterator advanceToOffset(DtU16& offset,
332  DtInetBufferChain::iterator chainIter, DtInetBufferChain::iterator chainEnd);
333 
334 private:
336  DtDisSocket( const DtDisSocket& orig );
337 
339  DtDisSocket& operator=(const DtDisSocket& orig);
341  friend class DtDisSockPimpl;
342  DtDisSockPimpl* myAsyncSendSockPimpl;
343 
344 protected:
345  // The send socket is only used when self-reflect filtering is enabled
346 
350 
354 
356  std::set<DtInetEndpoint> myAdditionalDestinations;
357 
359 
360  // Bundle buffers and control members
363 
364  int myMaxBundleSize; // outbound only
366  int myMinPacketSize; // inbound only
367 
368  /* per Document IST-CR-93-15 Section 5.3.15 */
370  {
379  };
380 
385 
388 
390 };
391 // end of class DtDisSocket
392 
394 {
395  return &myExerciseFilter;
396 }
397 
399 {
400  return &myVersionFilter;
401 }
402 
404 {
405  return &myKindFilter;
406 }
407 
409 {
410  return &myAddrFilter;
411 }
412 
413 
414 #ifdef DtUSE_UTILITIES_NAMESPACE
415 }
416 #endif
417 

Document ID: Generated on Mon Apr 8 04:49:21 EDT 2019 from SVN revision 197403
Copyright © 2005-2016 VT MÄK. All Rights Reserved (www.mak.com)