/src/open62541/tests/testing-plugins/testing_networklayers.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
2 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | | |
5 | | #include "testing_networklayers.h" |
6 | | |
7 | | UA_ByteString *testConnectionLastSentBuf; |
8 | | |
9 | | static UA_StatusCode |
10 | | testOpenConnection(UA_ConnectionManager *cm, |
11 | | const UA_KeyValueMap *params, |
12 | | void *application, void *context, |
13 | 0 | UA_ConnectionManager_connectionCallback connectionCallback) { |
14 | 0 | return UA_STATUSCODE_BADNOTCONNECTED; |
15 | 0 | } |
16 | | |
17 | | static UA_StatusCode |
18 | | testSendWithConnection(UA_ConnectionManager *cm, uintptr_t connectionId, |
19 | | const UA_KeyValueMap *params, |
20 | 0 | UA_ByteString *buf) { |
21 | 0 | if(testConnectionLastSentBuf) { |
22 | 0 | UA_ByteString_clear(testConnectionLastSentBuf); |
23 | 0 | *testConnectionLastSentBuf = *buf; |
24 | 0 | UA_ByteString_init(buf); |
25 | 0 | } else { |
26 | 0 | UA_ByteString_clear(buf); |
27 | 0 | } |
28 | 0 | return UA_STATUSCODE_GOOD; |
29 | 0 | } |
30 | | |
31 | | static UA_StatusCode |
32 | 0 | testCloseConnection(UA_ConnectionManager *cm, uintptr_t connectionId) { |
33 | 0 | return UA_STATUSCODE_GOOD; |
34 | 0 | } |
35 | | |
36 | | static UA_StatusCode |
37 | | testAllocNetworkBuffer(UA_ConnectionManager *cm, uintptr_t connectionId, |
38 | 0 | UA_ByteString *buf, size_t bufSize) { |
39 | 0 | return UA_ByteString_allocBuffer(buf, bufSize); |
40 | 0 | } |
41 | | |
42 | | static void |
43 | | testFreeNetworkBuffer(UA_ConnectionManager *cm, uintptr_t connectionId, |
44 | 0 | UA_ByteString *buf) { |
45 | 0 | UA_ByteString_clear(buf); |
46 | 0 | } |
47 | | |
48 | | UA_ConnectionManager testConnectionManagerTCP = { |
49 | | {0}, /* eventSource */ |
50 | | UA_STRING_STATIC("tcp"), |
51 | | testOpenConnection, |
52 | | testSendWithConnection, |
53 | | testCloseConnection, |
54 | | testAllocNetworkBuffer, |
55 | | testFreeNetworkBuffer |
56 | | }; |