/home/travis/build/open62541/open62541/include/ua_connection.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2014 the contributors as stated in the AUTHORS file
00003  *
00004  * This file is part of open62541. open62541 is free software: you can
00005  * redistribute it and/or modify it under the terms of the GNU Lesser General
00006  * Public License, version 3 (as published by the Free Software Foundation) with
00007  * a static linking exception as stated in the LICENSE file provided with
00008  * open62541.
00009  *
00010  * open62541 is distributed in the hope that it will be useful, but WITHOUT ANY
00011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
00012  * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
00013  * details.
00014  */
00015 
00016 #ifndef UA_CONNECTION_H_
00017 #define UA_CONNECTION_H_
00018 
00019 #ifdef __cplusplus
00020 extern "C" {
00021 #endif
00022 
00023 #include "ua_types.h"
00024 
00031 typedef enum UA_ConnectionState {
00032     UA_CONNECTION_OPENING, 
00033     UA_CONNECTION_ESTABLISHED, 
00034     UA_CONNECTION_CLOSED, 
00035 } UA_ConnectionState;
00036 
00037 typedef struct UA_ConnectionConfig {
00038     UA_UInt32 protocolVersion;
00039     UA_UInt32 sendBufferSize;
00040     UA_UInt32 recvBufferSize;
00041     UA_UInt32 maxMessageSize;
00042     UA_UInt32 maxChunkCount;
00043 } UA_ConnectionConfig;
00044 
00045 extern const UA_EXPORT UA_ConnectionConfig UA_ConnectionConfig_standard;
00046 
00047 /* Forward declaration */
00048 struct UA_SecureChannel;
00049 typedef struct UA_SecureChannel UA_SecureChannel;
00050 
00051 struct UA_Connection;
00052 typedef struct UA_Connection UA_Connection;
00053 
00059 struct UA_Connection {
00060     UA_ConnectionState state;
00061     UA_ConnectionConfig localConf;
00062     UA_ConnectionConfig remoteConf;
00063     UA_SecureChannel *channel; 
00064     UA_Int32 sockfd; 
00065     void *handle; 
00066     UA_ByteString incompleteMessage; 
00067     UA_StatusCode (*getBuffer)(UA_Connection *connection, UA_ByteString *buf, size_t minSize); 
00068     void (*releaseBuffer)(UA_Connection *connection, UA_ByteString *buf); 
00069     UA_StatusCode (*write)(UA_Connection *connection, const UA_ByteString *buf); 
00070 
00078     UA_StatusCode (*recv)(UA_Connection *connection, UA_ByteString *response, UA_UInt32 timeout);
00079     void (*close)(UA_Connection *connection);
00080 };
00081 
00082 void UA_EXPORT UA_Connection_init(UA_Connection *connection);
00083 void UA_EXPORT UA_Connection_deleteMembers(UA_Connection *connection);
00084 
00085 void UA_EXPORT UA_Connection_detachSecureChannel(UA_Connection *connection);
00086 void UA_EXPORT UA_Connection_attachSecureChannel(UA_Connection *connection, UA_SecureChannel *channel);
00087 
00090 UA_ByteString UA_EXPORT UA_Connection_completeMessages(UA_Connection *connection, UA_ByteString received);
00091 
00094 #ifdef __cplusplus
00095 } // extern "C"
00096 #endif
00097 
00098 #endif /* UA_CONNECTION_H_ */