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.
Fork of OmniWheels by
pana_header.c
00001 /* 00002 * Copyright (c) 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 "nsconfig.h" 00019 #include "ns_types.h" 00020 #include "common_functions.h" 00021 #include "Security/PANA/pana_header.h" 00022 00023 #ifdef PANA 00024 #define PANA_HEADER_START 0x0000 00025 00026 00027 00028 bool pana_header_parse(uint8_t *ptr, uint16_t data_length, pana_header_t *header) 00029 { 00030 if (data_length < 16) { 00031 return false; 00032 } 00033 00034 if (common_read_16_bit(ptr) != PANA_HEADER_START) { 00035 return false; 00036 } 00037 00038 header->payload_len = common_read_16_bit(ptr + 2); 00039 ptr += 4; 00040 if (header->payload_len != data_length) { 00041 return false; 00042 } 00043 00044 header->flags = common_read_16_bit(ptr); 00045 header->type = common_read_16_bit(ptr + 2); 00046 ptr += 4; 00047 header->session_id = common_read_32_bit(ptr); 00048 ptr += 4; 00049 header->seq = common_read_32_bit(ptr); 00050 00051 return true; 00052 } 00053 00054 uint8_t *pana_header_write(uint8_t *ptr, const pana_header_t *header) 00055 { 00056 ptr = common_write_16_bit(PANA_HEADER_START, ptr); 00057 ptr = common_write_16_bit(header->payload_len, ptr); 00058 ptr = common_write_16_bit(header->flags, ptr); 00059 ptr = common_write_16_bit(header->type, ptr); 00060 ptr = common_write_32_bit(header->session_id, ptr); 00061 return common_write_32_bit(header->seq, ptr); 00062 } 00063 #endif
Generated on Fri Jul 22 2022 04:53:58 by
 1.7.2
 1.7.2 
    