dhgdh
Dependencies: MAX44000 PWM_Tone_Library nexpaq_mdk
Fork of LED_Demo by
common_stub.cpp
00001 /* 00002 * Copyright (c) 2015 ARM Limited. All rights reserved. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * Licensed under the Apache License, Version 2.0 (the License); you may 00005 * not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 00012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #include "common_stub.h" 00017 #include "sn_grs.h" 00018 #include <sys/socket.h> 00019 00020 socket_error_t common_stub::error; 00021 socket_event_t * common_stub::event; 00022 socket_addr * common_stub::addr; 00023 void * common_stub::void_value; 00024 bool common_stub::visited; 00025 bool common_stub::bool_value; 00026 int common_stub::int_value; 00027 int common_stub::int2_value; 00028 addrinfo* common_stub::addrinfo; 00029 uint16_t common_stub::uint_value; 00030 omalw_certificate_list_t *common_stub::cert; 00031 sn_coap_hdr_s *common_stub::coap_header; 00032 sn_nsdl_resource_info_s *common_stub::resource; 00033 pthread_t common_stub::thread; 00034 const char* common_stub::char_value; 00035 00036 using namespace mbed; 00037 using namespace mbed::Sockets::v0; 00038 00039 void common_stub::clear() 00040 { 00041 int_value = -1; 00042 int2_value = -1; 00043 uint_value = 0; 00044 error = SOCKET_ERROR_NONE; 00045 event = NULL; 00046 addr = NULL; 00047 void_value = NULL; 00048 cert = NULL; 00049 visited = false; 00050 bool_value= false; 00051 coap_header = NULL; 00052 resource = NULL; 00053 addrinfo = NULL; 00054 char_value = NULL; 00055 } 00056 00057 UDPSocket::UDPSocket(socket_stack_t stack) :Socket(stack) 00058 { 00059 } 00060 00061 UDPSocket::~UDPSocket() 00062 { 00063 } 00064 00065 socket_error_t UDPSocket::connect(const SocketAddr *, const uint16_t ) 00066 { 00067 return common_stub::error; 00068 } 00069 00070 //SocketAddr 00071 00072 void SocketAddr::setAddr(const struct socket_addr *) 00073 { 00074 } 00075 00076 void SocketAddr::setAddr(const SocketAddr *) 00077 { 00078 } 00079 00080 bool SocketAddr::SocketAddr::is_v4() 00081 { 00082 return common_stub::bool_value; 00083 } 00084 00085 void mbed::Ticker::detach() 00086 { 00087 common_stub::visited = true; 00088 } 00089 00090 00091 // SN_NSDL_LIB 00092 00093 struct nsdl_s *sn_nsdl_init (uint8_t (*sn_nsdl_tx_cb)(struct nsdl_s *, sn_nsdl_capab_e , uint8_t *, uint16_t, sn_nsdl_addr_s *), 00094 uint8_t (*sn_nsdl_rx_cb)(struct nsdl_s *, sn_coap_hdr_s *, sn_nsdl_addr_s *), 00095 void *(*sn_nsdl_alloc)(uint16_t),void (*sn_nsdl_free)(void *)) 00096 { 00097 return NULL; 00098 } 00099 00100 uint16_t sn_nsdl_register_endpoint(struct nsdl_s *, sn_nsdl_ep_parameters_s *) 00101 { 00102 return common_stub::uint_value; 00103 } 00104 00105 uint16_t sn_nsdl_unregister_endpoint(struct nsdl_s *) 00106 { 00107 return common_stub::uint_value; 00108 } 00109 00110 uint16_t sn_nsdl_update_registration(struct nsdl_s *,uint8_t *, uint8_t) 00111 { 00112 return common_stub::uint_value; 00113 } 00114 00115 uint16_t sn_nsdl_send_observation_notification_with_uri_path(struct nsdl_s *, uint8_t *, uint8_t, 00116 uint8_t *, uint16_t, 00117 uint8_t *, uint8_t, 00118 sn_coap_msg_type_e , uint8_t, 00119 uint8_t *, uint16_t) 00120 { 00121 return common_stub::uint_value; 00122 } 00123 uint16_t sn_nsdl_send_observation_notification(struct nsdl_s *, uint8_t *, uint8_t, 00124 uint8_t *, uint16_t, 00125 uint8_t *, uint8_t, 00126 sn_coap_msg_type_e , uint8_t) 00127 { 00128 return common_stub::uint_value; 00129 } 00130 00131 int8_t sn_nsdl_set_endpoint_location(struct nsdl_s *, uint8_t *, uint8_t) 00132 { 00133 return common_stub::int_value; 00134 } 00135 00136 int8_t sn_nsdl_destroy(struct nsdl_s *handle) 00137 { 00138 return common_stub::int_value; 00139 } 00140 00141 sn_coap_hdr_s *sn_nsdl_build_response(struct nsdl_s *, sn_coap_hdr_s *, uint8_t ) 00142 { 00143 return common_stub::coap_header; 00144 } 00145 00146 sn_nsdl_resource_info_s *sn_nsdl_get_resource(struct nsdl_s *, uint16_t, uint8_t *) 00147 { 00148 return common_stub::resource; 00149 } 00150 00151 int8_t sn_nsdl_process_coap(struct nsdl_s *, uint8_t *, uint16_t , sn_nsdl_addr_s *) 00152 { 00153 return common_stub::int_value; 00154 } 00155 00156 int8_t sn_nsdl_exec(struct nsdl_s *, uint32_t) 00157 { 00158 return common_stub::int_value; 00159 } 00160 00161 int8_t sn_nsdl_set_retransmission_parameters(struct nsdl_s *, uint8_t, uint8_t) 00162 { 00163 return common_stub::int_value; 00164 } 00165 00166 void sn_nsdl_release_allocated_coap_msg_mem(struct nsdl_s *, sn_coap_hdr_s *header) 00167 { 00168 if(header && header != common_stub::coap_header){ 00169 if( header->content_type_ptr ){ 00170 free(header->content_type_ptr); 00171 header->content_type_ptr = NULL; 00172 } 00173 if( header->options_list_ptr){ 00174 free(header->options_list_ptr); 00175 header->options_list_ptr = NULL; 00176 } 00177 free(header); 00178 header = NULL; 00179 } 00180 } 00181 00182 int8_t sn_nsdl_create_resource(struct nsdl_s *, sn_nsdl_resource_info_s *) 00183 { 00184 return common_stub::int_value; 00185 } 00186 00187 int8_t sn_nsdl_delete_resource(struct nsdl_s *, uint16_t , uint8_t *) 00188 { 00189 return common_stub::int_value; 00190 } 00191 00192 int8_t sn_nsdl_send_coap_message(struct nsdl_s *, sn_nsdl_addr_s *, sn_coap_hdr_s *) 00193 { 00194 return common_stub::int_value; 00195 } 00196 00197 int8_t sn_nsdl_update_resource(struct nsdl_s *, sn_nsdl_resource_info_s *) 00198 { 00199 return common_stub::int_value; 00200 } 00201 00202 int8_t set_NSP_address(struct nsdl_s *, uint8_t *, uint16_t, sn_nsdl_addr_type_e) 00203 { 00204 return common_stub::int_value; 00205 } 00206 00207 uint16_t sn_nsdl_oma_bootstrap(struct nsdl_s *, sn_nsdl_addr_s *, 00208 sn_nsdl_ep_parameters_s *, 00209 sn_nsdl_bs_ep_info_t *) 00210 { 00211 return common_stub::uint_value; 00212 } 00213 00214 omalw_certificate_list_t *sn_nsdl_get_certificates(struct nsdl_s *) 00215 { 00216 return common_stub::cert; 00217 } 00218 00219 int8_t sn_nsdl_update_certificates(struct nsdl_s *, omalw_certificate_list_t*, uint8_t) 00220 { 00221 return common_stub::int_value; 00222 } 00223 00224 int8_t sn_nsdl_create_oma_device_object(struct nsdl_s *, sn_nsdl_oma_device_t *) 00225 { 00226 return common_stub::int_value; 00227 } 00228 00229 //Coap Headers 00230 00231 sn_coap_hdr_s *sn_coap_build_response(struct coap_s *, sn_coap_hdr_s *, uint8_t ) 00232 { 00233 return common_stub::coap_header; 00234 } 00235 00236 void sn_coap_parser_release_allocated_coap_msg_mem(struct coap_s *, sn_coap_hdr_s *) 00237 { 00238 } 00239 00240 int8_t sn_coap_protocol_set_retransmission_parameters(uint8_t, uint8_t) 00241 { 00242 return common_stub::int_value; 00243 } 00244 00245 // IP6String.h 00246 uint_fast8_t ip6tos(const void *ip6addr, char *p) 00247 { 00248 // Just set at least something there, or the valgrind will scream when 00249 // client tries to use the result string. 00250 p[0] = '\0'; 00251 return 0; 00252 } 00253 00254 //Socket 00255 Socket::Socket(const socket_stack_t ) : _irq(this) 00256 { 00257 _socket.api = NULL; 00258 } 00259 00260 Socket::~Socket() 00261 { 00262 } 00263 00264 socket_error_t Socket::open(const socket_address_family_t , const socket_proto_family_t ) 00265 { 00266 return common_stub::error; 00267 } 00268 00269 bool Socket::error_check(socket_error_t ) 00270 { 00271 return common_stub::bool_value; 00272 } 00273 00274 void Socket::_eventHandler(struct socket_event *) 00275 { 00276 } 00277 00278 void Socket::setOnError(const ErrorHandler_t &) 00279 { 00280 } 00281 00282 void Socket::setOnReadable(const ReadableHandler_t &) 00283 { 00284 } 00285 00286 void Socket::setOnSent(const SentHandler_t & ) 00287 { 00288 } 00289 00290 void Socket::_nvEventHandler(void * ) 00291 { 00292 } 00293 00294 socket_error_t Socket::getLocalAddr(SocketAddr *) const 00295 { 00296 return common_stub::error; 00297 } 00298 00299 socket_error_t Socket::getLocalPort(uint16_t *) const 00300 { 00301 return common_stub::error; 00302 } 00303 00304 socket_error_t Socket::getRemoteAddr(SocketAddr *) const 00305 { 00306 return common_stub::error; 00307 } 00308 00309 socket_error_t Socket::getRemotePort(uint16_t *) const 00310 { 00311 return common_stub::error; 00312 } 00313 00314 socket_error_t Socket::resolve(const char* , const DNSHandler_t & ) 00315 { 00316 return common_stub::error; 00317 } 00318 00319 socket_error_t Socket::bind(const char * , const uint16_t ) 00320 { 00321 return common_stub::error; 00322 } 00323 socket_error_t Socket::bind(const SocketAddr * , const uint16_t ) 00324 { 00325 return common_stub::error; 00326 } 00327 00328 socket_error_t Socket::close() 00329 { 00330 return common_stub::error; 00331 } 00332 00333 socket_error_t Socket::recv(void * , size_t *) 00334 { 00335 return common_stub::error; 00336 } 00337 socket_error_t Socket::recv_from(void * , size_t *, SocketAddr *, uint16_t *) 00338 { 00339 return common_stub::error; 00340 } 00341 00342 socket_error_t Socket::send(const void * , const size_t ) 00343 { 00344 return common_stub::error; 00345 } 00346 socket_error_t Socket::send_to(const void * , const size_t , const SocketAddr *, uint16_t ) 00347 { 00348 return common_stub::error; 00349 } 00350 00351 bool Socket::isConnected() const { 00352 return common_stub::error; 00353 } 00354 00355 // pthread 00356 int pthread_equal (pthread_t , pthread_t ) __THROW 00357 { 00358 return common_stub::int2_value; 00359 } 00360 00361 pthread_t pthread_self (void) __THROW 00362 { 00363 return common_stub::thread; 00364 } 00365 00366 int pthread_detach (pthread_t) __THROW 00367 { 00368 return common_stub::int_value; 00369 } 00370 00371 int pthread_create (pthread_t * , 00372 const pthread_attr_t *, 00373 void *(*__start_routine) (void *), 00374 void *) __THROWNL 00375 { 00376 __start_routine(NULL); 00377 return common_stub::int_value; 00378 } 00379 00380 int pthread_cancel (pthread_t) 00381 { 00382 return common_stub::int_value; 00383 } 00384 00385 int pthread_join (pthread_t , void **) 00386 { 00387 return common_stub::int_value; 00388 } 00389 00390 void pthread_exit (void *__retval)/* __attribute__ ((__noreturn__))*/ 00391 { 00392 00393 } 00394 00395 // sys/socket 00396 #ifndef __SOCKADDR_ARG 00397 # define __SOCKADDR_ARG struct sockaddr *__restrict 00398 #endif 00399 00400 #ifndef __CONST_SOCKADDR_ARG 00401 # define __CONST_SOCKADDR_ARG const struct sockaddr * 00402 #endif 00403 00404 #ifndef __socklen_t_defined 00405 typedef __socklen_t socklen_t; 00406 # define __socklen_t_defined 00407 #endif 00408 00409 int bind (int , __CONST_SOCKADDR_ARG , socklen_t ) 00410 __THROW 00411 { 00412 return common_stub::int_value; 00413 } 00414 00415 ssize_t sendto (int , const void *, size_t , 00416 int , __CONST_SOCKADDR_ARG , 00417 socklen_t ) 00418 { 00419 return common_stub::int_value; 00420 } 00421 00422 ssize_t recvfrom (int , void * , size_t , 00423 int , __SOCKADDR_ARG , 00424 socklen_t * ) 00425 { 00426 return common_stub::int_value; 00427 } 00428 00429 int getaddrinfo (const char *__restrict, 00430 const char *__restrict, 00431 const struct addrinfo *__restrict, 00432 struct addrinfo **__restrict addr) 00433 { 00434 //*addr = (addrinfo*)malloc(sizeof(addrinfo)); 00435 //(*addr)->ai_addr = (sockaddr*)malloc(sizeof(sockaddr)); 00436 *addr = common_stub::addrinfo; 00437 return common_stub::int_value; 00438 } 00439 00440 void freeaddrinfo (struct addrinfo * addr) 00441 __THROW 00442 { 00443 // free(addr->ai_addr); 00444 // free(addr); 00445 } 00446 00447 const char *inet_ntop (int, const void *__restrict, 00448 char *__restrict, socklen_t) 00449 __THROW 00450 { 00451 return common_stub::char_value; 00452 } 00453 00454 int connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len) 00455 { 00456 return common_stub::int_value; 00457 } 00458
Generated on Tue Jul 12 2022 11:01:45 by
1.7.2
