LTKCPP-- LLRP Toolkit C Plus Plus Library
ltkcpp_connection.h
Go to the documentation of this file.
1 /*
2  *****************************************************************************
3  * *
4  * IMPINJ CONFIDENTIAL AND PROPRIETARY *
5  * *
6  * This source code is the sole property of Impinj, Inc. Reproduction or *
7  * utilization of this source code in whole or in part is forbidden without *
8  * the prior written consent of Impinj, Inc. *
9  * *
10  * (c) Copyright Impinj, Inc. 2007,2008. All rights reserved. *
11  * *
12  *****************************************************************************/
13 #ifndef __LTKCPP_CONNECTION_H__
14 #define __LTKCPP_CONNECTION_H__
15 
16 // Forward declaration for OpenSSL's BIO object.
17 struct bio_st;
18 
27 namespace LLRP
28 {
29 
60 {
61  public:
62  CConnection (
63  const CTypeRegistry * pTypeRegistry,
64  unsigned int nBufferSize);
65 
66  ~CConnection (void);
67 
68  int
70  const char * pReaderHostName);
71 
72  int
73  openSecureConnectionToReader(const char* pReaderHostName);
74 
75  const char *
76  getConnectError (void);
77 
78  int
80 
81  CMessage *
82  transact (
83  CMessage * pSendMessage,
84  int nMaxMS);
85 
86  const CErrorDetails *
87  getTransactError (void);
88 
90  sendMessage (
91  CMessage * pMessage);
92 
93  const CErrorDetails *
94  getSendError (void);
95 
96  CMessage *
97  recvMessage (
98  int nMaxMS);
99 
100  CMessage *
101  recvResponse (
102  int nMaxMS,
103  const CTypeDescriptor * pResponseType,
104  llrp_u32_t ResponseMessageID);
105 
106  const CErrorDetails *
107  getRecvError (void);
108 
109  private:
110  enum E_LLRP_CONNECTION_TYPE
111  {
112  E_LLRP_CONNECTION_TYPE_UNSECURE,
113  E_LLRP_CONNECTION_TYPE_SSL
114  };
115 
117  struct bio_st * m_pBio;
118 
120  const char * m_pConnectErrorStr;
121 
123  const CTypeRegistry * m_pTypeRegistry;
124 
126  std::list<CMessage *> m_listInputQueue;
127 
129  unsigned int m_nBufferSize;
130 
132  struct RecvState
133  {
135  llrp_byte_t * pBuffer;
136 
138  unsigned int nBuffer;
139 
143  int bFrameValid;
144 
146  CFrameExtract FrameExtract;
147 
149  CErrorDetails ErrorDetails;
150  } m_Recv;
151 
153  struct SendState
154  {
156  llrp_byte_t * pBuffer;
157 
159  unsigned int nBuffer;
160 
162  CErrorDetails ErrorDetails;
163  } m_Send;
164 
165 private:
166  int initializeSslBio(bio_st** ppBio);
167  int initializeSocketBio(bio_st** ppBio);
168  int openConnectionToReader(const char* pReaderHostName, E_LLRP_CONNECTION_TYPE eType);
169 
171  recvAdvance (
172  int nMaxMS,
173  time_t timeLimit);
174 
175  time_t
176  calculateTimeLimit (
177  int nMaxMS);
178 
179  void initializeOpenSSL();
180 };
181 
182 }; /* namespace LLRP */
183 
184 #endif // __LTKCPP_CONNECTION_H__
CMessage * recvResponse(int nMaxMS, const CTypeDescriptor *pResponseType, llrp_u32_t ResponseMessageID)
Receive a specific message from a connection.
CConnection(const CTypeRegistry *pTypeRegistry, unsigned int nBufferSize)
Construct a new LLRP connection instance.
EResultCode
Error result codes for LTK operations.
Definition: ltkcpp_base.h:583
int closeConnectionToReader(void)
Close connection to reader, allow reuse of instance.
A collection of pointers to CTypeDescriptors.
Definition: ltkcpp_base.h:885
const CErrorDetails * getTransactError(void)
Get the details that explains transact() error.
CMessage * recvMessage(int nMaxMS)
Receive a message from a connection.
CMessage * transact(CMessage *pSendMessage, int nMaxMS)
Transact a LLRP request and response to a connection.
const CErrorDetails * getRecvError(void)
Get the details that explains recvMessage() or recvResponse() error.
int openConnectionToReader(const char *pReaderHostName)
Open a connection to the reader over an unencrypted socket.
EResultCode sendMessage(CMessage *pMessage)
Send a LLRP message to a connection.
Class to return error details in LTKCPP operations.
Definition: ltkcpp_base.h:631
Base Class for All LLRP LTK Messages.
Definition: ltkcpp_base.h:1088
const char * getConnectError(void)
Get the string that explains openReaderConnection() error.
~CConnection(void)
Destruct a LLRP connection instance.
int openSecureConnectionToReader(const char *pReaderHostName)
Open a connection to the reader over an encrypted socket.
LLRP connection class.
Describes a message or parameter type.
Definition: ltkcpp_base.h:755
const CErrorDetails * getSendError(void)
Get the details that explains sendMessage() error.