Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mbed-os-example-blinky-gr-lychee GR-Boads_Camera_sample GR-Boards_Audio_Recoder GR-Boads_Camera_DisplayApp ... more
sn_coap_header_check.c
00001 /* 00002 * Copyright (c) 2011-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 00017 /** 00018 * \file sn_coap_header_check.c 00019 * 00020 * \brief CoAP Header validity checker 00021 * 00022 * Functionality: Checks validity of CoAP Header 00023 * 00024 */ 00025 00026 /* * * * INCLUDE FILES * * * */ 00027 #include "ns_types.h" 00028 #include "mbed-coap/sn_coap_header.h" 00029 #include "mbed-coap/sn_coap_protocol.h" 00030 #include "sn_coap_header_internal.h" 00031 #include "sn_coap_protocol_internal.h" 00032 00033 /** 00034 * \fn int8_t sn_coap_header_validity_check(sn_coap_hdr_s *src_coap_msg_ptr, coap_version_e coap_version) 00035 * 00036 * \brief Checks validity of given Header 00037 * 00038 * \param *src_coap_msg_ptr is source for building Packet data 00039 * \param coap_version is version of used CoAP specification 00040 * 00041 * \return Return value is status of validity check. In ok cases 0 and in 00042 * failure cases -1 00043 */ 00044 int8_t sn_coap_header_validity_check(sn_coap_hdr_s *src_coap_msg_ptr, coap_version_e coap_version) 00045 { 00046 /* * Check validity of CoAP Version * */ 00047 if (coap_version != COAP_VERSION_1) { 00048 return -1; 00049 } 00050 00051 /* * Check validity of Message type * */ 00052 switch (src_coap_msg_ptr->msg_type) { 00053 case COAP_MSG_TYPE_CONFIRMABLE: 00054 case COAP_MSG_TYPE_NON_CONFIRMABLE: 00055 case COAP_MSG_TYPE_ACKNOWLEDGEMENT: 00056 case COAP_MSG_TYPE_RESET: 00057 break; /* Ok cases */ 00058 default: 00059 return -1; /* Failed case */ 00060 } 00061 00062 /* * Check validity of Message code * */ 00063 switch (src_coap_msg_ptr->msg_code) { 00064 case COAP_MSG_CODE_EMPTY: 00065 case COAP_MSG_CODE_REQUEST_GET: 00066 case COAP_MSG_CODE_REQUEST_POST: 00067 case COAP_MSG_CODE_REQUEST_PUT: 00068 case COAP_MSG_CODE_REQUEST_DELETE: 00069 case COAP_MSG_CODE_RESPONSE_CREATED: 00070 case COAP_MSG_CODE_RESPONSE_DELETED: 00071 case COAP_MSG_CODE_RESPONSE_VALID: 00072 case COAP_MSG_CODE_RESPONSE_CHANGED: 00073 case COAP_MSG_CODE_RESPONSE_CONTENT: 00074 case COAP_MSG_CODE_RESPONSE_BAD_REQUEST: 00075 case COAP_MSG_CODE_RESPONSE_UNAUTHORIZED: 00076 case COAP_MSG_CODE_RESPONSE_BAD_OPTION: 00077 case COAP_MSG_CODE_RESPONSE_FORBIDDEN: 00078 case COAP_MSG_CODE_RESPONSE_NOT_FOUND: 00079 case COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED: 00080 case COAP_MSG_CODE_RESPONSE_NOT_ACCEPTABLE: 00081 case COAP_MSG_CODE_RESPONSE_REQUEST_ENTITY_INCOMPLETE: 00082 case COAP_MSG_CODE_RESPONSE_PRECONDITION_FAILED: 00083 case COAP_MSG_CODE_RESPONSE_REQUEST_ENTITY_TOO_LARGE: 00084 case COAP_MSG_CODE_RESPONSE_UNSUPPORTED_CONTENT_FORMAT: 00085 case COAP_MSG_CODE_RESPONSE_INTERNAL_SERVER_ERROR: 00086 case COAP_MSG_CODE_RESPONSE_NOT_IMPLEMENTED: 00087 case COAP_MSG_CODE_RESPONSE_BAD_GATEWAY: 00088 case COAP_MSG_CODE_RESPONSE_SERVICE_UNAVAILABLE: 00089 case COAP_MSG_CODE_RESPONSE_GATEWAY_TIMEOUT: 00090 case COAP_MSG_CODE_RESPONSE_PROXYING_NOT_SUPPORTED: 00091 case COAP_MSG_CODE_RESPONSE_CONTINUE: 00092 break; /* Ok cases */ 00093 default: 00094 return -1; /* Failed case */ 00095 } 00096 00097 /* Success */ 00098 return 0; 00099 }
Generated on Tue Jul 12 2022 11:02:31 by
1.7.2