]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSMacOSX/BonjourTop/source/CollectBy.h
mDNSResponder-878.1.1.tar.gz
[apple/mdnsresponder.git] / mDNSMacOSX / BonjourTop / source / CollectBy.h
1 //
2 // CollectBy.h
3 // TestTB
4 //
5 // Created by Terrin Eager on 3/17/13.
6 //
7 //
8
9 #ifndef __TestTB__CollectBy__
10 #define __TestTB__CollectBy__
11
12 #include <iostream>
13 #include "bjtypes.h"
14 #include "DNSFrame.h"
15 #include "bjstring.h"
16 #include "LLRBTree.h"
17
18
19 // Service request/Respond v4/v6 sameSubnet/DifferentSubnet
20
21 enum BJ_COLLECTBY_TYPE
22 {
23 CBT_NOT_SET,
24 CBT_SERVICE,
25 CBT_REQUEST_RESPONDS,
26 CBT_SAME_DIFF_SUBNET,
27 CBT_IP_ADDRESS_TYPE,
28 CBT_PACKET
29 };
30
31 class CollectByAbstract;
32 class Collection
33 {
34 public:
35 Collection() {m_pHeaderCollectBy = NULL;m_pFirstCollectBy = NULL;};
36
37 void Init(BJ_COLLECTBY_TYPE collectByList[]);
38 void ProcessFrame(CDNSFrame* pFrame);
39
40 void ExportCollection(BJString sFileName);
41 bool IsValid() { return (m_pFirstCollectBy != NULL);};
42 private:
43 CollectByAbstract* Factory(BJ_COLLECTBY_TYPE type);
44
45 BJ_COLLECTBY_TYPE m_CollectByList[20];
46 CollectByAbstract* m_pHeaderCollectBy;
47 CollectByAbstract* m_pFirstCollectBy;
48
49 };
50
51 class CollectByAbstract
52 {
53 public:
54 CollectByAbstract()
55 {
56 pNext = NULL;
57 }
58
59 virtual void Collect(CDNSFrame* pFrame,CollectByAbstract* nextCollectBy)=0;
60 virtual const char* GetTitle()=0;
61 virtual CollectByAbstract* Factory()=0;
62 virtual void Export(FILE* hFile,BJString sPrevColumns)=0;
63
64 CollectByAbstract* pNext;
65 };
66 /////////////
67 // Service
68 class CServiceNode : public CRBNode<BJString>
69 {
70 public:
71 CServiceNode() {pNext = NULL;};
72 CServiceNode(BJString* pKey){ m_Key = *pKey;};
73 ~CServiceNode(){};
74 inline virtual BJ_COMPARE Compare(BJString* pKey) { return m_Key.Compare(*pKey);};
75 inline virtual void CopyNode(CRBNode* pSource) {pNext = dynamic_cast<CServiceNode*>(pSource)->pNext;} ;
76 inline virtual void Init(){};
77 inline virtual void Clear() {};
78 void Export(FILE* hFile,BJString sPrevColumns);
79 CollectByAbstract* pNext;
80
81 };
82
83 class CServiceToCollectByMap : public CLLRBTree<BJString, CServiceNode>
84 {
85 public:
86
87
88 };
89
90 class CollectByService:public CollectByAbstract
91 {
92 public:
93 virtual void Collect(CDNSFrame* pFrame,CollectByAbstract* nextCollectBy);
94 virtual const char* GetTitle() {return "Service";};
95 virtual CollectByAbstract* Factory(){ return new CollectByService();};
96 virtual void Export(FILE* hFile,BJString sPrevColumns);
97 private:
98 CServiceToCollectByMap m_Cache;
99 };
100
101 class CollectByRequestResponds:public CollectByAbstract
102 {
103 public:
104 virtual void Collect(CDNSFrame* pFrame,CollectByAbstract* nextCollectBy);
105 virtual const char* GetTitle() {return "Request/Responds";};
106 virtual CollectByAbstract* Factory(){ return new CollectByRequestResponds();};
107 virtual void Export(FILE* hFile,BJString sPrevColumns);
108
109 private:
110 CollectByAbstract* pRequestNext;
111 CollectByAbstract* pRespondsNext;
112 };
113
114 class CollectByIPAddressType:public CollectByAbstract
115 {
116 public:
117 virtual void Collect(CDNSFrame* pFrame,CollectByAbstract* nextCollectBy);
118 virtual const char* GetTitle() {return "V4/V6";};
119 virtual CollectByAbstract* Factory(){ return new CollectByIPAddressType();};
120 virtual void Export(FILE* hFile,BJString sPrevColumns);
121 private:
122 CollectByAbstract* pIPv4Next;
123 CollectByAbstract* pIPv6Next;
124 };
125
126 class CollectBySameSubnetDiffSubnet:public CollectByAbstract
127 {
128 public:
129 virtual void Collect(CDNSFrame* pFrame,CollectByAbstract* nextCollectBy);
130 virtual const char* GetTitle() {return "SameSubnet/DiffSubnet";};
131 virtual CollectByAbstract* Factory(){ return new CollectBySameSubnetDiffSubnet();};
132 virtual void Export(FILE* hFile,BJString sPrevColumns);
133
134 static bool bSameSubnet;
135 private:
136 CollectByAbstract* pSameSubnetNext;
137 CollectByAbstract* pDiffSubnetNext;
138 };
139
140 class CollectByPacketCount:public CollectByAbstract
141 {
142
143 public:
144 virtual void Collect(CDNSFrame* pFrame,CollectByAbstract* nextCollectBy);
145 virtual const char* GetTitle() {return "Packets";};
146 virtual CollectByAbstract* Factory(){ return new CollectByPacketCount();};
147 virtual void Export(FILE* hFile,BJString sPrevColumns);
148
149 BJ_INT64 nFrameCount;
150 BJ_INT64 nLastFrameIndex;
151 static BJ_INT64 nFrameIndex;
152 };
153
154
155 #endif /* defined(__TestTB__CollectBy__) */