00001 #ifndef __NQPEERLIST_H_INCLUDED__
00002 #define __NQPEERLIST_H_INCLUDED__
00003
00004 #include "PlatformSW.h"
00005 #include "NQLockMechanism.h"
00006 #include "NQDeclarations.h"
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 typedef struct
00032 {
00033 bool enabled;
00034 UINT32 ip_host;
00035 UINT16 port_host;
00036 bool receive_last_packet_index_set;
00037 UINT16 receive_last_packet_index;
00038 UINT16 send_packet_index;
00039 } NQ_PEER_ENTRY_INT;
00040
00041
00042 class CNQPeerList: public CNQLockMechanism
00043 {
00044 public:
00045 CNQPeerList();
00046 virtual ~CNQPeerList();
00047
00048 UINT32 getLastError();
00049
00050
00051 bool add( UINT32 ip, UINT16 port );
00052 bool remove( UINT32 ip, UINT16 port );
00053 bool removeAll();
00054
00055 bool isAllowed(UINT32 ip, UINT16 port);
00056
00057 bool getReceivePacketIndex( UINT32 ip, UINT16 port, UINT16 &packetindex);
00058 bool setReceivePacketIndex( UINT32 ip, UINT16 port, UINT16 packetindex);
00059
00060 bool getSendPacketIndex( UINT32 ip, UINT16 port, UINT16 &aNextPacketIndex);
00061 bool incSendPacketIndex( UINT32 ip, UINT16 port);
00062
00063
00064
00065
00066 UINT32 count();
00067
00068 bool add( UINT32 ip, UINT16 port, UINT32 &lasterr);
00069 bool remove( UINT32 ip, UINT16 port, UINT32 &lasterr );
00070 bool removeAll( UINT32 &lasterr );
00071
00072
00073 bool isAllowed(UINT32 ip, UINT16 port, UINT32 &lasterr);
00074
00075
00076 bool getReceivePacketIndex( UINT32 ip, UINT16 port, UINT16 &packetindex, UINT32 &lasterr);
00077 bool setReceivePacketIndex( UINT32 ip, UINT16 port, UINT16 packetindex, UINT32 &lasterr);
00078
00079 bool getSendPacketIndex( UINT32 ip, UINT16 port, UINT16 &aNextPacketIndex, UINT32 &lasterr );
00080 bool incSendPacketIndex( UINT32 ip, UINT16 port, UINT32 &lasterr);
00081
00082 private:
00083 INT32 m_iQueueFirstElement;
00084 INT32 m_iQueueLastElement;
00085 INT32 m_iQueueNumElements;
00086
00087
00088 NQ_PEER_ENTRY_INT *m_pQueueValue;
00089 INT32 *m_iQueueNextElement;
00090
00091 INT32 m_iQueueMaxSize;
00092
00093 UINT32 m_iLastError;
00094 };
00095
00096
00097
00098 #endif // __NQPEERLIST_H_INCLUDED__