14e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
24e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @{
34e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @file
44e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
54e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * <!-- Copyright Giesecke & Devrient GmbH 2009 - 2012 -->
67b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim *
74e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Redistribution and use in source and binary forms, with or without
84e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * modification, are permitted provided that the following conditions
94e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * are met:
104e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * 1. Redistributions of source code must retain the above copyright
114e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *    notice, this list of conditions and the following disclaimer.
124e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * 2. Redistributions in binary form must reproduce the above copyright
134e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *    notice, this list of conditions and the following disclaimer in the
144e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *    documentation and/or other materials provided with the distribution.
154e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * 3. The name of the author may not be used to endorse or promote
164e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *    products derived from this software without specific prior
174e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *    written permission.
184e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
194e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
204e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
214e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
224e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
234e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
244e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
254e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
264e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
274e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
284e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
294e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
304e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park */
314e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#ifndef TRUSTLETSESSION_H_
324e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#define TRUSTLETSESSION_H_
334e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
344e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#include "NotificationQueue.h"
357b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#include "CWsm.h"
364e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#include "Connection.h"
374e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#include <queue>
387b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim#include <map>
394e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
404e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
417b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kimclass TrustletSession
427b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim{
437b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kimprivate:
447b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    std::queue<notification_t> notifications;
457b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    std::map<uint32_t, CWsm_ptr> buffers;
464e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
474e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Parkpublic:
487b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    uint32_t sessionId;
497b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    uint32_t sessionMagic; // Random data
507b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    Connection *deviceConnection;
517b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    Connection *notificationConnection;
524e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
537b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    TrustletSession(Connection *deviceConnection, uint32_t sessionId);
544e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
557b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    ~TrustletSession(void);
567b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim
577b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    void queueNotification(notification_t *notification);
587b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim
597b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    void processQueuedNotifications(void);
607b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim
617b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    bool addBulkBuff(CWsm_ptr pWsm);
627b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim
637b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    bool removeBulkBuff(uint32_t handle);
647b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim
657b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    CWsm_ptr popBulkBuff();
664e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
674e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park};
684e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
697b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kimtypedef std::list<TrustletSession *> trustletSessionList_t;
704e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Parktypedef trustletSessionList_t::iterator trustletSessionIterator_t;
714e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
724e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#endif /* TRUSTLETSESSION_H_ */
734e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
744e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/** @} */
75