32 void sessionLookupStub(stream<rtlSessionLookupRequest>& lup_req, stream<rtlSessionLookupReply>& lup_rsp,
33 stream<rtlSessionUpdateRequest>& upd_req, stream<rtlSessionUpdateReply>& upd_rsp)
36 static std::map<fourTupleInternal, ap_uint<14> > lookupTable;
38 rtlSessionLookupRequest request;
39 rtlSessionUpdateRequest update;
41 std::map<fourTupleInternal, ap_uint<14> >::const_iterator findPos;
45 lup_req.read(request);
46 findPos = lookupTable.find(request.key);
47 if (findPos != lookupTable.end())
49 lup_rsp.write(rtlSessionLookupReply(
true, findPos->second, request.source));
53 lup_rsp.write(rtlSessionLookupReply(
false, request.source));
64 lookupTable[update.key] = update.value;
65 upd_rsp.write(rtlSessionUpdateReply(update.value,
INSERT, update.source));
71 lookupTable.erase(update.key);
72 upd_rsp.write(rtlSessionUpdateReply(update.value,
DELETE, update.source));
108 void updateRequestMerger(stream<rtlSessionUpdateRequest>& in1, stream<rtlSessionUpdateRequest>& in2, stream<rtlSessionUpdateRequest>&
out)
112 out.write(in1.read());
114 else if (!in2.empty())
116 out.write(in2.read());
122 stream<sessionLookupQuery> rxEng2sLookup_req;
123 stream<sessionLookupReply> sLookup2rxEng_rsp(
"sLookup2rxEng_rsp");
124 stream<ap_uint<16> > stateTable2sLookup_releaseSession;
125 stream<ap_uint<16> > sLookup2portTable_releasePort;
126 stream<fourTuple> txApp2sLookup_req;
127 stream<sessionLookupReply> sLookup2txApp_rsp;
128 stream<ap_uint<16> > txEng2sLookup_rev_req;
129 stream<fourTuple> sLookup2txEng_rev_rsp;
130 stream<rtlSessionLookupRequest> sessionLookup_req;
131 stream<rtlSessionLookupReply> sessionLookup_rsp(
"test_sessionLookup_rsp");
132 stream<rtlSessionUpdateRequest> sessionUpdate_req;
133 stream<rtlSessionUpdateReply> sessionUpdate_rsp(
"test_sessionUpdate_rsp");
135 stream<rtlSessionUpdateRequest> sessionInsert_req;
136 stream<rtlSessionUpdateRequest> sessionDelete_req;
142 ap_uint<16> regSessionCount;
146 tuple.
dstIp = 0x01010101;
148 tuple.
srcIp = 0x0101010a;
151 int lastSessionCount = 0;
156 rxEng2sLookup_req.write(sessionLookupQuery(tuple,
false));
161 rxEng2sLookup_req.write(sessionLookupQuery(tuple,
true));
166 txEng2sLookup_rev_req.write(0);
171 txApp2sLookup_req.write(tuple);
176 stateTable2sLookup_releaseSession,
177 sLookup2portTable_releasePort,
180 txEng2sLookup_rev_req,
181 sLookup2txEng_rev_rsp,
191 if ( lastSessionCount != regSessionCount)
193 std::cout <<
"SessionCount\t" << regSessionCount << std::endl;
194 lastSessionCount = regSessionCount;
196 sessionLookupStub(sessionLookup_req, sessionLookup_rsp, sessionUpdate_req, sessionUpdate_rsp);
200 sessionLookupReply reply;
201 while (!sLookup2rxEng_rsp.empty())
203 sLookup2rxEng_rsp.read(reply);
204 std::cout <<
"rxEng "<< reply.sessionID <<
"\t" << reply.hit << std::endl;
206 while (!sLookup2txApp_rsp.empty())
208 sLookup2txApp_rsp.read(reply);
209 std::cout <<
"txApp "<< reply.sessionID <<
"\t" << reply.hit << std::endl;
211 while (!sLookup2txEng_rev_rsp.empty())
213 sLookup2txEng_rev_rsp.read(tuple);
214 std::cout <<
"txEng " << tuple.
dstIp <<
":" << tuple.
dstPort <<
"\t " << tuple.
srcIp <<
":" << tuple.
srcPort << std::endl;
void session_lookup_controller(stream< SessionLookupQuery > &siRXe_SessLookupReq, stream< SessionLookupReply > &soRXe_SessLookupRep, stream< SessionId > &siSTt_SessReleaseCmd, stream< TcpPort > &soPRt_ClosePortCmd, stream< SocketPair > &siTAi_SessLookupReq, stream< SessionLookupReply > &soTAi_SessLookupRep, stream< SessionId > &siTXe_ReverseLkpReq, stream< fourTuple > &soTXe_ReverseLkpRep, stream< CamSessionLookupRequest > &soCAM_SessLookupReq, stream< CamSessionLookupReply > &siCAM_SessLookupRep, stream< CamSessionUpdateRequest > &soCAM_SessUpdateReq, stream< CamSessionUpdateReply > &siCAM_SessUpdateRep, stream< ap_uint< 16 > > &soSssRelCnt, stream< ap_uint< 16 > > &soSssRegCnt)
Session Lookup Controller (SLc)
void updateRequestMerger(stream< rtlSessionUpdateRequest > &in1, stream< rtlSessionUpdateRequest > &in2, stream< rtlSessionUpdateRequest > &out)
void sessionLookupStub(stream< rtlSessionLookupRequest > &lup_req, stream< rtlSessionLookupReply > &lup_rsp, stream< rtlSessionUpdateRequest > &upd_req, stream< rtlSessionUpdateReply > &upd_rsp)