dd123eee601bc1f3595aefaa801c70b2db0c6f12
[vuplus_dvbapp] / lib / dvb_ci / dvbci_session.h
1 #ifndef __dvbci_dvbci_tc_h
2 #define __dvbci_dvbci_tc_h
3
4 #include <lib/base/ebase.h>
5 #include <lib/dvb_ci/dvbci.h>
6
7 #define SLMS    256
8
9 class eDVBCISession
10 {
11         static eDVBCISession *sessions[SLMS];
12         static eDVBCISession *eDVBCISession::createSession(eDVBCISlot *slot, const unsigned char *resource_identifier, unsigned char &status);
13         static void eDVBCISession::sendSPDU(eDVBCISlot *slot, unsigned char tag,const void *data, int len, unsigned short session_nb, const void *apdu=0,int alen=0);
14         static void sendOpenSessionResponse(eDVBCISlot *slot,unsigned char session_status, const unsigned char *resource_identifier,unsigned short session_nb);
15         void recvCreateSessionResponse(const unsigned char *data);
16         void recvCloseSessionRequest(const unsigned char *data);
17 protected:
18         int state;
19         int status;
20         int action;
21         eDVBCISlot *slot;               //base only
22         unsigned short session_nb;
23         virtual int receivedAPDU(const unsigned char *tag, const void *data, int len) = 0;
24         void eDVBCISession::sendAPDU(const unsigned char *tag, const void *data=0,int len=0);
25         void eDVBCISession::sendSPDU(unsigned char tag, const void *data, int len,const void *apdu=0, int alen=0);
26 public:
27         enum { stateInCreation, stateBusy, stateInDeletion, stateStarted, statePrivate};
28         
29         static int parseLengthField(const unsigned char *pkt, int &len);
30         static int buildLengthField(unsigned char *pkt, int len);
31
32         static void receiveData(eDVBCISlot *slot, const unsigned char *ptr, size_t len);
33         
34         int getState() { return state; }
35         int getStatus() { return status; }
36 };
37
38 #endif