VR-Link API Documentation for HLA 1.3
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 
31 {
32  public:
33  DtPduFilterTest() { disableTest();}
34  virtual ~DtPduFilterTest() {}
35 
36  void disableTest() { setTest(DtPduTest_NEQ, 0, 0); }
37  void setTest(DtPduTestOperator op, DtU32 value) { setTest(op, 1, &value); }
38  void extendTest(DtU32 value) { extendTest (1, &value); }
39  void reduceTest(DtU32 value) { reduceTest (1, &value); }
40  virtual void setOperator(DtPduTestOperator op);
41  virtual void setTest(DtPduTestOperator op, int n, DtU32 *values);
42  virtual void extendTest(int n, DtU32 *values);
43  virtual void reduceTest(int n, DtU32 *values);
44 
45  virtual bool evalTest(void* buf, int offset, DtPduFilterType type);
46 
47  protected:
48 
49  virtual void clearList();
52 };
53 
54 class DtDisSockPimpl;
55 
60 {
61 public:
84  DtDisSocket( const DtInetEndpoint& dest, DtU16 localPort = 0,
85  DtInetDevice* hostIf = NULL, DtU32 flags = DtDefaultSockOpts,
86  bool immediateOpen = true,
87  bool suppressSelfReflectEnabled = false );
88 
90  virtual ~DtDisSocket();
91 
98  virtual bool openSocket();
99 
106  virtual bool closeSocket();
107 
113  virtual int send( caddr_t packet, size_t size, DtU32 flags = 0 );
115  virtual int sendTo( caddr_t packet, size_t size,
116  DtInetEndpoint& dest, DtU32 flags = 0 );
117 
118  virtual int sendChain( DtInetBufferChain& packets, DtU32 flags = 0 );
120  virtual int sendChainTo( DtInetBufferChain& packets,
121  DtInetEndpoint& dest, DtU32 flags = 0 );
123 
129  virtual DtInetSockRcvStatus recvFrom( caddr_t buff, size_t buffSize,
130  DtInetEndpoint& src,
131  DtU32 flags = 0 );
132 
136  virtual bool addDestination(const DtInetEndpoint& destination);
137 
140  virtual void removeDestination(const DtInetEndpoint& destination);
141 
142 
148  virtual bool setSendSockNonBlockingOption( bool onOrOff );
149  virtual bool setSendSockSendBuffSize( DtU32 size );
150  virtual bool setSendSockRcvBuffSize( DtU32 size );
151  virtual bool setSendSockBroadcastOption( bool onOrOff );
152  virtual bool setSendSockReuseAddrOption( bool onOrOff );
153  virtual bool setSendSockDoNotRouteOption( bool onOrOff );
154  virtual bool setSendSockSendLowWatermark( DtU32 size );
155  virtual bool setSendSockRcvLowWatermark( DtU32 size );
156  virtual bool setSendSockMcastDevice( DtInetAddr devAddr );
157  virtual bool setSendSockMcastDevice( DtInetDevice* hostIf );
158 
159  virtual DtU32 getSendSockSendBuffSize();
160  virtual DtU32 getSendSockRcvBuffSize();
161  virtual DtU32 getSendSockBytesAvailable();
162  virtual bool getSendSockBroadcastOption();
163  virtual bool getSendSockReuseAddrOption();
164  virtual bool getSendSockDoNotRouteOption();
165  virtual DtU32 getSendSockSendLowWatermark();
166  virtual DtU32 getSendSockRcvLowWatermark();
168 
177  virtual bool sendSockJoinMulticastGroup( DtInetAddr grpAddr,
178  DtInetDevice* device = NULL );
179  virtual bool sendSockJoinMulticastGroup( DtInetEndpoint grpEndpoint,
180  DtInetDevice* device = NULL );
181  virtual bool sendSockDropMulticastGroup( DtInetAddr grpAddr,
182  DtInetDevice* device = NULL );
183  virtual bool sendSockDropMulticastGroup( DtInetEndpoint grpEndpoint,
184  DtInetDevice* device = NULL );
187  virtual bool setSendSockMcastTtlOption( DtU32 ttl );
189 
192 
196 
201  virtual void setBundling( int maxBundleSize, bool enableUnbundling,
202  int minPacketSize, int sizeOffset, int sizeLength, bool testDisHeader );
204 
210  virtual bool setMaxBundleSize( int size );
211  virtual int getMaxBundleSize();
212  virtual bool isBundling();
214 
219  virtual void setUnbundling( int onOrOff );
220  virtual int isUnbundling();
222 
227  virtual void setMinPacketSize( int size );
228  virtual int minPacketSize();
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 
267 protected:
269  virtual void* disSendSocket();
270 
277  static int addToBundle( DtInetSocket* sock, int size,
278  DtInetBufferChain& buffChain, DtInetEndpoint& ep,
279  void* usr );
280  static int flushBundle( DtInetSocket* sock, int size,
281  DtInetBufferChain& buffChain, DtInetEndpoint& ep,
282  void* usr );
283  static int unbundle( DtInetSocket* sock, int size,
284  DtInetBufferChain& buffChain, DtInetEndpoint& ep,
285  void* usr );
286  static int getNextBundle( DtInetSocket* sock, int size,
287  DtInetBufferChain& buffChain, DtInetEndpoint& ep,
288  void* usr );
290 
293  static int suppressSelfReflect( DtInetSocket* sock, int size,
294  DtInetBufferChain& buffChain,
295  DtInetEndpoint& ep, void* usr );
296 
299  static int filterExercisePdus( DtInetSocket* sock, int size,
300  DtInetBufferChain& buffChain,
301  DtInetEndpoint& ep, void* usr );
302 
307  virtual DtInetDevice* findInterface( const DtInetAddr& dest );
308 
309  // Determine size of PDU during unbundling
310  struct DtDisSocketPduHeader; // forward declaration.
311  virtual DtU16 getPduSize( DtDisSocketPduHeader* hdr,
312  int hdrOffset, DtInetBufferChain::iterator current,
313  DtInetBufferChain::iterator end, int* status );
314 
315 
316 private:
318  DtDisSocket( const DtDisSocket& orig );
319 
321  DtDisSocket& operator=(const DtDisSocket& orig);
322 
324  friend class DtDisSockPimpl;
325  DtDisSockPimpl* myAsyncSendSockPimpl;
326 
327 protected:
328  // The send socket is only used when self-reflect filtering is enabled
329 
333 
336  void* mySendSocket;
337 
339  std::set<DtInetEndpoint> myAdditionalDestinations;
340 
342 
343  // Bundle buffers and control members
346 
347  int myMaxBundleSize; // outbound only
348  int myMinBundleSize; // outbound only
350 
351  /* per Document IST-CR-93-15 Section 5.3.15 */
353  {
361  };
362 
367 
368 };
369 // end of class DtDisSocket
370 
372 {
373  return &myExerciseFilter;
374 }
375 
377 {
378  return &myVersionFilter;
379 }
380 
382 {
383  return &myKindFilter;
384 }
385 
387 {
388  return &myAddrFilter;
389 }
390 
391 
392 #ifdef DtUSE_UTILITIES_NAMESPACE
393 }
394 #endif
395 

Document ID: Generated on Wed Aug 14 15:35:11 EDT 2013 from SVN revision 130445
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)