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) 1992-2010 VT MAK
3 ** All rights reserved.
4 *********************************************************************/
9 #pragma once
10 
11 #include <vlutil/vlInetUdpSocket.h>
13 #include <vlutil/vlNetTimeStamp.h>
14 #include <vlutil/vlList.h>
15 #include <set>
16 
21 
22 #ifdef DtUSE_UTILITIES_NAMESPACE
23 namespace DtUSE_UTILITIES_NAMESPACE
24 {
25 #endif
26 
27 #define DtDEFAULT_DIS_PORT 3000
28 
29 #define DtDIS_HEADER_PROTOCOL_VERSION_BYTE_OFFSET 0
30 #define DtDIS_HEADER_EXERCISE_IDENTIFIER_BYTE_OFFSET 1
31 #define DtDIS_HEADER_PDU_TYPE_BYTE_OFFSET 2
32 #define DtDIS_HEADER_PROTOCOL_FAMILY_BYTE_OFFSET 3
33 #define DtDIS_HEADER_TIMESTAMP_BYTE_OFFSET 4
34 #define DtDIS_HEADER_LENGTH_BYTE_OFFSET 8
35 #define DtDIS_HEADER_PDU_STATUS_BYTE_OFFSET 10
36 
37 // Mask to extract the Coupled Extension Indicator from bit 3 (00001000)
38 #define DtDIS_HEADER_CEI_QUERY_MASK 0x8
39 
42 {
43  public:
44  DtPduFilterTest() { disableTest();}
45  virtual ~DtPduFilterTest() {}
46 
47  void disableTest() { setTest(DtPduTest_NEQ, 0, 0); }
48  void setTest(DtPduTestOperator op, DtU32 value) { setTest(op, 1, &value); }
49  void extendTest(DtU32 value) { extendTest (1, &value); }
50  void reduceTest(DtU32 value) { reduceTest (1, &value); }
51  virtual void setOperator(DtPduTestOperator op);
52  virtual void setTest(DtPduTestOperator op, int n, DtU32 *values);
53  virtual void extendTest(int n, DtU32 *values);
54  virtual void reduceTest(int n, DtU32 *values);
55 
56  virtual bool evalTest(void* buf, int offset, DtPduFilterType type);
57 
58  protected:
59 
60  virtual void clearList();
63 };
64 
65 class DtDisSockPimpl;
66 
71 {
72 public:
95  DtDisSocket( const DtInetEndpoint& dest, DtU16 localPort = 0,
96  DtInetDevice* hostIf = NULL, DtU32 flags = DtDefaultSockOpts,
97  bool immediateOpen = true,
98  bool suppressSelfReflectEnabled = false );
99 
101  virtual ~DtDisSocket();
102 
109  virtual bool openSocket();
110 
117  virtual bool closeSocket();
118 
124  virtual int send( caddr_t packet, size_t size, DtU32 flags = 0 );
126  virtual int sendTo( caddr_t packet, size_t size,
127  DtInetEndpoint& dest, DtU32 flags = 0 );
128 
129  virtual int sendChain( DtInetBufferChain& packets, DtU32 flags = 0 );
131  virtual int sendChainTo( DtInetBufferChain& packets,
132  DtInetEndpoint& dest, DtU32 flags = 0 );
134 
140  virtual DtInetSockRcvStatus recvFrom( caddr_t buff, size_t buffSize,
141  DtInetEndpoint& src,
142  DtU32 flags = 0 );
143 
147  virtual bool addDestination(const DtInetEndpoint& destination);
148 
151  virtual void removeDestination(const DtInetEndpoint& destination);
152 
153 
159  virtual bool setSendSockNonBlockingOption( bool onOrOff );
160  virtual bool setSendSockSendBuffSize( DtU32 size );
161  virtual bool setSendSockRcvBuffSize( DtU32 size );
162  virtual bool setSendSockBroadcastOption( bool onOrOff );
163  virtual bool setSendSockReuseAddrOption( bool onOrOff );
164  virtual bool setSendSockDoNotRouteOption( bool onOrOff );
165  virtual bool setSendSockSendLowWatermark( DtU32 size );
166  virtual bool setSendSockRcvLowWatermark( DtU32 size );
167  virtual bool setSendSockMcastDevice( DtInetAddr devAddr );
168  virtual bool setSendSockMcastDevice( DtInetDevice* hostIf );
169 
170  virtual DtU32 getSendSockSendBuffSize();
171  virtual DtU32 getSendSockRcvBuffSize();
172  virtual DtU32 getSendSockBytesAvailable();
173  virtual bool getSendSockBroadcastOption();
174  virtual bool getSendSockReuseAddrOption();
175  virtual bool getSendSockDoNotRouteOption();
176  virtual DtU32 getSendSockSendLowWatermark();
177  virtual DtU32 getSendSockRcvLowWatermark();
179 
188  virtual bool sendSockJoinMulticastGroup( DtInetAddr grpAddr,
189  DtInetDevice* device = NULL );
190  virtual bool sendSockJoinMulticastGroup( DtInetEndpoint grpEndpoint,
191  DtInetDevice* device = NULL );
192  virtual bool sendSockDropMulticastGroup( DtInetAddr grpAddr,
193  DtInetDevice* device = NULL );
194  virtual bool sendSockDropMulticastGroup( DtInetEndpoint grpEndpoint,
195  DtInetDevice* device = NULL );
198  virtual bool setSendSockMcastTtlOption( DtU32 ttl );
200 
203 
207 
212  virtual void setBundling( int maxBundleSize, int sizeOffset, int sizeLength,
213  bool testDisHeader );
215 
221  virtual bool setMaxBundleSize( int size );
222  virtual int getMaxBundleSize();
223  virtual bool isBundling();
225 
230  virtual void setMinPacketSize( int size );
231  virtual int minPacketSize();
233 
236  virtual void setBundleByteAlignment( DtU32 size );
237  virtual DtU32 sendBundleByteAlignment();
238  // Return the bundle by alignment for the given protocol version
239  virtual DtU32 receiveBundleByteAlignment(int protocolVersion);
241 
243  virtual DtPduFilterTest *exerciseId();
244  virtual DtPduFilterTest *protocolVersion();
245  virtual DtPduFilterTest *pduKind();
246  virtual DtPduFilterTest *ipAddr();
247 
250  virtual DtInetEndpoint& localSenderEndpoint() const;
251 
253  virtual DtInetSockFlushStatus flush();
254 
259  virtual int addToBundle( int size, DtInetBufferChain& buffChain,
260  DtInetEndpoint& ep );
261  virtual int unbundle( int size, DtInetBufferChain& buffChain,
262  DtInetEndpoint& ep, int* status );
263  virtual int getNextBundle( int size, DtInetBufferChain& buffChain,
264  DtInetEndpoint& ep, int* status );
265  virtual DtInetSockFlushStatus flushBundle( DtInetEndpoint& ep );
267 
270  virtual int suppressSelfReflect( int size, DtInetBufferChain& buffChain,
271  DtInetEndpoint& ep, int* status );
272 
275  virtual int filterExercisePdus( int size, DtInetBufferChain& buffChain,
276  DtInetEndpoint& ep, int* status );
277 
279  virtual int minSizeFilter( int size, DtInetBufferChain& buffChain,
280  DtInetEndpoint& ep, int* status);
281 
282 protected:
284  virtual void* disSendSocket();
285 
292  static int addToBundle( DtInetSocket* sock, int size,
293  DtInetBufferChain& buffChain, DtInetEndpoint& ep,
294  void* usr );
295  static int flushBundle( DtInetSocket* sock, int size,
296  DtInetBufferChain& buffChain, DtInetEndpoint& ep,
297  void* usr );
298  static int unbundle( DtInetSocket* sock, int size,
299  DtInetBufferChain& buffChain, DtInetEndpoint& ep,
300  void* usr );
301  static int getNextBundle( DtInetSocket* sock, int size,
302  DtInetBufferChain& buffChain, DtInetEndpoint& ep,
303  void* usr );
305 
308  static int suppressSelfReflect( DtInetSocket* sock, int size,
309  DtInetBufferChain& buffChain,
310  DtInetEndpoint& ep, void* usr );
311 
314  static int filterExercisePdus( DtInetSocket* sock, int size,
315  DtInetBufferChain& buffChain,
316  DtInetEndpoint& ep, void* usr );
317 
319  static int minSizeFilter( DtInetSocket* sock, int size,
320  DtInetBufferChain& buffChain,
321  DtInetEndpoint& ep, void* usr );
322 
323  // Determine size of PDU during unbundling
324  struct DtDisSocketPduHeader; // forward declaration.
325  virtual DtU16 getPduSize( DtDisSocketPduHeader* hdr,
326  int hdrOffset, DtInetBufferChain::iterator current,
327  DtInetBufferChain::iterator end, int* status, bool& isCoupling, bool expectAttributePdu = false);
328 
329  // Determine size of a Coupled PDU during unbundling
330  virtual DtU16 getCoupledAttributePduSize( DtDisSocketPduHeader* hdr,
331  int hdrOffset, DtInetBufferChain::iterator current,
332  DtInetBufferChain::iterator end, int* status, int pduLengthAndPadding );
333 
334  // From the given iterator walk through chain for the given offset number of bytes.
335  // Return an iterator to the buffer containing the offset or end if offset past end of chain.
336  virtual DtInetBufferChain::iterator advanceToOffset(DtU16& offset,
337  DtInetBufferChain::iterator chainIter, DtInetBufferChain::iterator chainEnd);
338 
339 
340 private:
342  DtDisSocket( const DtDisSocket& orig );
343 
345  DtDisSocket& operator=(const DtDisSocket& orig);
347  friend class DtDisSockPimpl;
348  DtDisSockPimpl* myAsyncSendSockPimpl;
349 
350 protected:
351  // The send socket is only used when self-reflect filtering is enabled
352 
356 
359  void* mySendSocket;
360 
362  std::set<DtInetEndpoint> myAdditionalDestinations;
363 
365 
366  // Bundle buffers and control members
369 
370  int myMaxBundleSize; // outbound only
372  int myMinPacketSize; // inbound only
373 
374  /* per Document IST-CR-93-15 Section 5.3.15 */
376  {
385  };
386 
391 
392 };
393 // end of class DtDisSocket
394 
396 {
397  return &myExerciseFilter;
398 }
399 
401 {
402  return &myVersionFilter;
403 }
404 
406 {
407  return &myKindFilter;
408 }
409 
411 {
412  return &myAddrFilter;
413 }
414 
415 
416 #ifdef DtUSE_UTILITIES_NAMESPACE
417 }
418 #endif
419 

Document ID: Generated on Wed Jan 7 13:31:29 EST 2015 from SVN revision 149162
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)