VR-Link API Documentation for HLA 1516
vlDisSocket.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 ** Copyright (c) 1992-2010 VT MAK
00003 ** All rights reserved.
00004 *********************************************************************/
00009 #pragma once
00010 
00011 #include <vlutil/vlInetUdpSocket.h>
00012 #include <vlutil/vlInetSocketUtils.h>
00013 #include <vlutil/vlNetTimeStamp.h>
00014 #include <vlutil/vlList.h>
00015 #include <set>
00016 
00018 enum DtPduTestOperator {  DtPduTest_EQ, DtPduTest_NEQ } ;
00020 enum DtPduFilterType { DtPduFtInetAddr, DtPduFtNetU8 };
00021 
00022 #ifdef DtUSE_UTILITIES_NAMESPACE
00023 namespace DtUSE_UTILITIES_NAMESPACE
00024 {
00025 #endif
00026 
00027 #define DtDEFAULT_DIS_PORT 3000
00028 
00030 class DT_DLL_VLUTIL DtPduFilterTest
00031 {
00032   public:
00033     DtPduFilterTest() { disableTest();}
00034     virtual ~DtPduFilterTest() {}
00035 
00036     void disableTest()                              { setTest(DtPduTest_NEQ, 0, 0); }
00037     void setTest(DtPduTestOperator op, DtU32 value) { setTest(op, 1, &value);    }
00038     void extendTest(DtU32 value)                    { extendTest (1, &value);    }
00039     void reduceTest(DtU32 value)                    { reduceTest (1, &value);    }
00040     virtual void setOperator(DtPduTestOperator op);
00041     virtual void setTest(DtPduTestOperator op, int n, DtU32 *values);
00042     virtual void extendTest(int n, DtU32 *values);
00043     virtual void reduceTest(int n, DtU32 *values);
00044     
00045     virtual bool evalTest(void* buf, int offset, DtPduFilterType type);
00046 
00047   protected:
00048 
00049     virtual void clearList();
00050     DtPduTestOperator testOp;
00051     DtList values;
00052 };
00053 
00054 class DtDisSockPimpl;
00055 
00059 class DT_DLL_VLUTIL DtDisSocket : public DtInetUdpSocket
00060 {
00061 public:
00084    DtDisSocket( const DtInetEndpoint& dest, DtU16 localPort = 0, 
00085                 DtInetDevice* hostIf = NULL, DtU32 flags = DtDefaultSockOpts,
00086                 bool immediateOpen = true, 
00087                 bool suppressSelfReflectEnabled = false );
00088 
00090    virtual ~DtDisSocket();
00091 
00098    virtual bool openSocket();
00099 
00106    virtual bool closeSocket();
00107 
00113    virtual int send( caddr_t packet, size_t size, DtU32 flags = 0 );
00115    virtual int sendTo( caddr_t packet, size_t size,
00116                        DtInetEndpoint& dest, DtU32 flags = 0 );
00117 
00118    virtual int sendChain( DtInetBufferChain& packets, DtU32 flags = 0 );
00120    virtual int sendChainTo( DtInetBufferChain& packets,
00121                             DtInetEndpoint& dest, DtU32 flags = 0 );
00123 
00129    virtual DtInetSockRcvStatus recvFrom( caddr_t buff, size_t buffSize,
00130                                          DtInetEndpoint& src,
00131                                          DtU32 flags = 0 );
00132 
00136    virtual bool addDestination(const DtInetEndpoint& destination);
00137 
00140    virtual void removeDestination(const DtInetEndpoint& destination);
00141 
00142 
00148    virtual bool setSendSockNonBlockingOption( bool onOrOff );
00149    virtual bool setSendSockSendBuffSize( DtU32 size );
00150    virtual bool setSendSockRcvBuffSize( DtU32 size );
00151    virtual bool setSendSockBroadcastOption( bool onOrOff );
00152    virtual bool setSendSockReuseAddrOption( bool onOrOff );
00153    virtual bool setSendSockDoNotRouteOption( bool onOrOff );
00154    virtual bool setSendSockSendLowWatermark( DtU32 size );
00155    virtual bool setSendSockRcvLowWatermark( DtU32 size );
00156    virtual bool setSendSockMcastDevice( DtInetAddr devAddr );
00157    virtual bool setSendSockMcastDevice( DtInetDevice* hostIf );
00158 
00159    virtual DtU32 getSendSockSendBuffSize();
00160    virtual DtU32 getSendSockRcvBuffSize();
00161    virtual DtU32 getSendSockBytesAvailable();
00162    virtual bool  getSendSockBroadcastOption();
00163    virtual bool  getSendSockReuseAddrOption();
00164    virtual bool  getSendSockDoNotRouteOption();
00165    virtual DtU32 getSendSockSendLowWatermark();
00166    virtual DtU32 getSendSockRcvLowWatermark();
00168 
00177     virtual bool sendSockJoinMulticastGroup( DtInetAddr grpAddr, 
00178                                              DtInetDevice* device = NULL );
00179     virtual bool sendSockJoinMulticastGroup( DtInetEndpoint grpEndpoint, 
00180                                              DtInetDevice* device = NULL );
00181     virtual bool sendSockDropMulticastGroup( DtInetAddr grpAddr, 
00182                                              DtInetDevice* device = NULL );
00183     virtual bool sendSockDropMulticastGroup( DtInetEndpoint grpEndpoint, 
00184                                              DtInetDevice* device = NULL );
00187    virtual bool setSendSockMcastTtlOption( DtU32 ttl );
00189 
00192 
00196 
00201    virtual void setBundling( int maxBundleSize, bool enableUnbundling, 
00202       int minPacketSize, int sizeOffset, int sizeLength, bool testDisHeader );
00204    
00210    virtual bool setMaxBundleSize( int size );
00211    virtual int  getMaxBundleSize();
00212    virtual bool isBundling();
00214 
00219    virtual void setUnbundling( int onOrOff );
00220    virtual int  isUnbundling();
00222 
00227    virtual void setMinPacketSize( int size );   
00228    virtual int  minPacketSize();
00230    
00232    virtual DtPduFilterTest *exerciseId();
00233    virtual DtPduFilterTest *protocolVersion();
00234    virtual DtPduFilterTest *pduKind();
00235    virtual DtPduFilterTest *ipAddr();
00236 
00239    virtual DtInetEndpoint& localSenderEndpoint() const;
00240 
00242    virtual DtInetSockFlushStatus flush();
00243 
00248    virtual int addToBundle( int size, DtInetBufferChain& buffChain, 
00249                             DtInetEndpoint& ep );
00250    virtual int unbundle( int size, DtInetBufferChain& buffChain, 
00251                          DtInetEndpoint& ep, int* status );
00252    virtual int getNextBundle( int size, DtInetBufferChain& buffChain, 
00253                               DtInetEndpoint& ep, int* status );
00254    virtual DtInetSockFlushStatus flushBundle( DtInetEndpoint& ep );
00256 
00259    virtual int suppressSelfReflect( int size, DtInetBufferChain& buffChain, 
00260                                     DtInetEndpoint& ep, int* status );
00261 
00264    virtual int filterExercisePdus( int size, DtInetBufferChain& buffChain, 
00265                                    DtInetEndpoint& ep, int* status );
00266 
00267 protected:
00269    virtual void* disSendSocket();
00270 
00277    static int addToBundle( DtInetSocket* sock, int size,
00278                            DtInetBufferChain& buffChain, DtInetEndpoint& ep, 
00279                            void* usr );
00280    static int flushBundle( DtInetSocket* sock, int size,
00281                            DtInetBufferChain& buffChain, DtInetEndpoint& ep, 
00282                            void* usr );
00283    static int unbundle( DtInetSocket* sock, int size,
00284                         DtInetBufferChain& buffChain, DtInetEndpoint& ep, 
00285                         void* usr );
00286    static int getNextBundle( DtInetSocket* sock, int size,
00287                              DtInetBufferChain& buffChain, DtInetEndpoint& ep,
00288                              void* usr );
00290 
00293    static int suppressSelfReflect( DtInetSocket* sock, int size,
00294                                    DtInetBufferChain& buffChain, 
00295                                    DtInetEndpoint& ep, void* usr );
00296 
00299    static int filterExercisePdus( DtInetSocket* sock, int size,
00300                                   DtInetBufferChain& buffChain, 
00301                                   DtInetEndpoint& ep, void* usr );
00302 
00307    virtual DtInetDevice* findInterface( const DtInetAddr& dest );
00308 
00309    // Determine size of PDU during unbundling
00310    struct DtDisSocketPduHeader; // forward declaration. 
00311    virtual DtU16 getPduSize( DtDisSocketPduHeader* hdr, 
00312                      int hdrOffset, DtInetBufferChain::iterator current,
00313                      DtInetBufferChain::iterator end, int* status );
00314 
00315 
00316 private:
00318    DtDisSocket( const DtDisSocket& orig );
00319 
00321    DtDisSocket& operator=(const DtDisSocket& orig);
00322 
00324    friend class DtDisSockPimpl;
00325    DtDisSockPimpl* myAsyncSendSockPimpl;
00326 
00327 protected:
00328    // The send socket is only used when self-reflect filtering is enabled
00329    
00332    void*          mySendSocketIoService;
00333 
00336    void*          mySendSocket; 
00337 
00338    DtInetEndpoint mySendEndpoint;
00339    std::set<DtInetEndpoint> myAdditionalDestinations;
00340 
00341    bool mySuppressSelfReflect;
00342 
00343    // Bundle buffers and control members
00344    DtInetUtils::DtInetSockOutboundBundleMap   myOutboundBundles;
00345    DtInetUtils::DtInetSockInboundBundleQueue  myInboundBundles;
00346 
00347    int                               myMaxBundleSize; // outbound only
00348    int                               myMinBundleSize; // outbound only
00349    bool                              myUnbundlingEnabled;
00350 
00351    /* per Document IST-CR-93-15 Section 5.3.15 */
00352    struct DtDisSocketPduHeader
00353    {
00354       DtNetU8           version;
00355       DtNetU8           DtExercise;
00356       DtNetU8           DtKind;
00357       DtNetU8           family;
00358       DtNetTimeStamp    DtTime;
00359       DtNetU16          DtLength;
00360       DtNetU16          unused_16;
00361    };
00362 
00363     DtPduFilterTest myVersionFilter;
00364     DtPduFilterTest myExerciseFilter;
00365     DtPduFilterTest myKindFilter;
00366     DtPduFilterTest myAddrFilter;
00367 
00368 }; 
00369 // end of class DtDisSocket
00370 
00371 inline DtPduFilterTest *DtDisSocket::exerciseId()      
00372 { 
00373    return &myExerciseFilter; 
00374 }
00375 
00376 inline DtPduFilterTest *DtDisSocket::protocolVersion()
00377 { 
00378    return &myVersionFilter;  
00379 }
00380 
00381 inline DtPduFilterTest *DtDisSocket::pduKind()         
00382 { 
00383    return &myKindFilter;     
00384 }
00385 
00386 inline DtPduFilterTest *DtDisSocket::ipAddr()          
00387 { 
00388    return &myAddrFilter;     
00389 }
00390 
00391 
00392 #ifdef DtUSE_UTILITIES_NAMESPACE
00393 } 
00394 #endif
00395 

Document ID: Generated on Mon May 14 08:06:18 EDT 2012 from SVN revision 114750
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)