embkernel
 All Classes Functions Variables Typedefs Groups Pages
TlsSocket.cpp
1 //------------------------------------------------------------------------------
2 //This file is part of embKernel.
3 //See license.txt for the full license governing this code.
4 //------------------------------------------------------------------------------
5 
6 #include "TlsSocket.hpp"
7 
8 TlsSocket::TlsSocket() {
9 }
10 
11 TlsSocket::~TlsSocket() {
12 
13 }
14 
15 bool TlsSocket::connect(NetDefs::IP_ADDR& remoteIpAddr, uint16_t remotePort, uint16_t localPort) {
16  if (!mSocket.connect(remoteIpAddr, remotePort, localPort)) {
17  return false;
18  }
19 
20  Tls::RESULT result = mTls.handshake(mSocket, mSocket);
21 
22  if (result) {
23  return false;
24  }
25  return true;
26 }
27 
28 bool TlsSocket::accept(Rtos::TICK timeout) {
29  if (!mSocket.accept(timeout)) {
30  return false;
31  }
32  return true;
33 }
34 
35 int TlsSocket::read(void* buffer, int len, Rtos::TICK timeout) {
36  int result = mSocket.read(buffer, len, timeout);
37  return result;
38 }
39 
40 int TlsSocket::skip(int len, Rtos::TICK timeout) {
41  int result = mSocket.skip(len, timeout);
42  return result;
43 }
44 
45 int TlsSocket::write(const void* buffer, int len, Rtos::TICK timeout) {
46  int result = mSocket.write(buffer, len, timeout);
47  return result;
48 }
49 
50 int TlsSocket::writeByte(uint8_t value, Rtos::TICK timeout) {
51  int result = mSocket.writeByte(value, timeout);
52  return result;
53 }
54 
55 void TlsSocket::close() {
56  mSocket.close();
57 }
58