Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sn_coap_protocol_stub.c Source File

sn_coap_protocol_stub.c

00001 /*
00002  * Copyright (c) 2011-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 
00019 #include <stdio.h>
00020 #include <stdlib.h> /* For libary malloc() */
00021 #include <string.h> /* For memset() and memcpy() */
00022 #ifdef __linux__
00023 #include <time.h>
00024 #endif
00025 
00026 #include "ns_types.h"
00027 #include "sn_coap_protocol.h"
00028 #include "sn_coap_header_internal.h"
00029 #include "sn_coap_protocol_internal.h"
00030 #include "sn_coap_protocol_stub.h"
00031 
00032 uint16_t                sn_coap_block_data_size                             = 0;
00033 
00034 uint8_t                 sn_coap_resending_queue_msgs                        = 0;
00035 uint8_t                 sn_coap_resending_queue_bytes                       = 0;
00036 uint8_t                 sn_coap_resending_count                             = 0;
00037 uint8_t                 sn_coap_resending_intervall                         = 0;
00038 
00039 uint8_t                 sn_coap_duplication_buffer_size                     = 0;
00040 
00041 sn_coap_protocol_stub_def sn_coap_protocol_stub;
00042 
00043 int8_t sn_coap_protocol_destroy(struct coap_s *handle)
00044 {
00045     return sn_coap_protocol_stub.expectedInt8;
00046 }
00047 
00048 struct coap_s *sn_coap_protocol_init(void *(*used_malloc_func_ptr)(uint16_t), void (*used_free_func_ptr)(void *),
00049                                      uint8_t (*used_tx_callback_ptr)(uint8_t *, uint16_t, sn_nsdl_addr_s *, void *),
00050                                      int8_t (*used_rx_callback_ptr)(sn_coap_hdr_s *, sn_nsdl_addr_s *, void *param))
00051 {
00052     if( sn_coap_protocol_stub.expectedCoap ){
00053         sn_coap_protocol_stub.expectedCoap->sn_coap_protocol_free = used_free_func_ptr;
00054         sn_coap_protocol_stub.expectedCoap->sn_coap_protocol_malloc = used_malloc_func_ptr;
00055         sn_coap_protocol_stub.expectedCoap->sn_coap_rx_callback = used_rx_callback_ptr;
00056         sn_coap_protocol_stub.expectedCoap->sn_coap_tx_callback = used_tx_callback_ptr;
00057     }
00058     return sn_coap_protocol_stub.expectedCoap;
00059 }
00060 
00061 int8_t sn_coap_protocol_set_block_size(struct coap_s *handle, uint16_t block_size)
00062 {
00063     return sn_coap_protocol_stub.expectedInt8;
00064 }
00065 
00066 int8_t sn_coap_protocol_set_duplicate_buffer_size(struct coap_s *handle, uint8_t size)
00067 {
00068     return sn_coap_protocol_stub.expectedInt8;
00069 }
00070 
00071 int8_t sn_coap_protocol_set_retransmission_parameters(struct coap_s *handle, uint8_t resending_count, uint8_t resending_intervall)
00072 {
00073     return sn_coap_protocol_stub.expectedInt8;
00074 }
00075 
00076 int8_t sn_coap_protocol_set_retransmission_buffer(struct coap_s *handle, uint8_t buffer_size_messages, uint16_t buffer_size_bytes)
00077 {
00078     return sn_coap_protocol_stub.expectedInt8;
00079 }
00080 
00081 void sn_coap_protocol_clear_retransmission_buffer(struct coap_s *handle)
00082 {
00083 }
00084 
00085 
00086 int16_t sn_coap_protocol_build(struct coap_s *handle, sn_nsdl_addr_s *dst_addr_ptr,
00087                                uint8_t *dst_packet_data_ptr, sn_coap_hdr_s *src_coap_msg_ptr, void *param)
00088 {
00089     //TODO: check if needed here
00090     src_coap_msg_ptr->msg_id = 2;
00091     return sn_coap_protocol_stub.expectedInt16;
00092 }
00093 
00094 sn_coap_hdr_s *sn_coap_protocol_parse(struct coap_s *handle, sn_nsdl_addr_s *src_addr_ptr, uint16_t packet_data_len, uint8_t *packet_data_ptr, void *param)
00095 {
00096     return sn_coap_protocol_stub.expectedHeader;
00097 }
00098 
00099 int8_t sn_coap_protocol_exec(struct coap_s *handle, uint32_t current_time)
00100 {
00101     return sn_coap_protocol_stub.expectedInt8;
00102 }
00103 
00104 coap_send_msg_s *sn_coap_protocol_allocate_mem_for_msg(struct coap_s *handle, sn_nsdl_addr_s *dst_addr_ptr, uint16_t packet_data_len)
00105 {
00106     return sn_coap_protocol_stub.expectedSendMsg;
00107 }
00108 
00109 int8_t sn_coap_protocol_delete_retransmission(struct coap_s *handle, uint16_t msg_id)
00110 {
00111     return 0;
00112 }