BA
/
BaBoRo1
Embed:
(wiki syntax)
Show/hide line numbers
coap_security_handler_stub.c
00001 /* 00002 * Copyright (c) 2015-2017, Arm Limited and affiliates. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #include <string.h> 00019 #include <time.h> 00020 #include <stdlib.h> 00021 #include "ns_trace.h" 00022 #include "nsdynmemLIB.h" 00023 #include "coap_connection_handler.h" 00024 #include "coap_security_handler_stub.h" 00025 00026 thread_sec_def coap_security_handler_stub; 00027 00028 struct coap_security_s { 00029 bool _is_started; 00030 }; 00031 00032 coap_security_t *coap_security_create(int8_t socket_id, int8_t timer_id, void *handle, SecureConnectionMode mode, 00033 int (*send_cb)(int8_t socket_id, void *handle, const void *, size_t), 00034 int (*receive_cb)(int8_t socket_id, unsigned char *, size_t), 00035 void (*start_timer_cb)(int8_t timer_id, uint32_t min, uint32_t fin), 00036 int (*timer_status_cb)(int8_t timer_id)) 00037 { 00038 coap_security_handler_stub.send_cb = send_cb; 00039 coap_security_handler_stub.receive_cb = receive_cb; 00040 coap_security_handler_stub.start_timer_cb = start_timer_cb; 00041 coap_security_handler_stub.timer_status_cb = timer_status_cb; 00042 return coap_security_handler_stub.sec_obj; 00043 } 00044 00045 coap_security_t *coap_security_handler_stub_alloc(void) 00046 { 00047 return calloc(1, sizeof(coap_security_t)); 00048 } 00049 00050 00051 void coap_security_destroy(coap_security_t *sec) 00052 { 00053 00054 } 00055 00056 int coap_security_handler_connect_non_blocking(coap_security_t *sec, bool is_server, SecureSocketMode sock_mode, coap_security_keys_t keys, uint32_t timeout_min, uint32_t timeout_max) 00057 { 00058 sec->_is_started = true; 00059 if( coap_security_handler_stub.counter >= 0){ 00060 return coap_security_handler_stub.values[coap_security_handler_stub.counter--]; 00061 } 00062 return coap_security_handler_stub.int_value; 00063 } 00064 00065 int coap_security_handler_continue_connecting(coap_security_t *sec) 00066 { 00067 if( coap_security_handler_stub.counter >= 0){ 00068 return coap_security_handler_stub.values[coap_security_handler_stub.counter--]; 00069 } 00070 00071 return coap_security_handler_stub.int_value; 00072 } 00073 00074 00075 int coap_security_handler_send_message(coap_security_t *sec, unsigned char *message, size_t len) 00076 { 00077 if( coap_security_handler_stub.counter >= 0){ 00078 return coap_security_handler_stub.values[coap_security_handler_stub.counter--]; 00079 } 00080 return coap_security_handler_stub.int_value; 00081 } 00082 00083 int coap_security_send_close_alert(coap_security_t *sec) 00084 { 00085 if( coap_security_handler_stub.counter >= 0){ 00086 return coap_security_handler_stub.values[coap_security_handler_stub.counter--]; 00087 } 00088 return coap_security_handler_stub.int_value; 00089 } 00090 00091 int coap_security_handler_read(coap_security_t *sec, unsigned char* buffer, size_t len) 00092 { 00093 if( coap_security_handler_stub.counter >= 0){ 00094 return coap_security_handler_stub.values[coap_security_handler_stub.counter--]; 00095 } 00096 return coap_security_handler_stub.int_value; 00097 } 00098 00099 bool coap_security_handler_is_started(const coap_security_t *sec) 00100 { 00101 return sec->_is_started; 00102 } 00103 00104 const void *coap_security_handler_keyblock(const coap_security_t *sec) 00105 { 00106 return NULL; 00107 }
Generated on Tue Jul 12 2022 12:21:47 by
