Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ws_eapol_relay_lib.c Source File

ws_eapol_relay_lib.c

00001 /*
00002  * Copyright (c) 2018-2019, 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 <string.h>
00020 #include "ns_types.h"
00021 #include "ns_list.h"
00022 #include "ns_trace.h"
00023 #include "socket_api.h"
00024 #include "6LoWPAN/ws/ws_config.h"
00025 #include "6LoWPAN/ws/ws_eapol_relay_lib.h"
00026 
00027 #ifdef HAVE_WS
00028 
00029 #define TRACE_GROUP "wsrl"
00030 
00031 int8_t ws_eapol_relay_lib_send_to_relay(const uint8_t socket_id, const uint8_t *eui_64, const ns_address_t *dest_addr, const void *data, uint16_t data_len)
00032 {
00033     ns_address_t addr = *dest_addr;
00034 
00035     ns_iovec_t msg_iov[2];
00036     ns_msghdr_t msghdr;
00037     //Set messages name buffer
00038     msghdr.msg_name = &addr;
00039     msghdr.msg_namelen = sizeof(addr);
00040     msghdr.msg_iov = &msg_iov[0];
00041     msghdr.msg_iovlen = 2;
00042     msghdr.msg_control = NULL;
00043     msghdr.msg_controllen = 0;
00044     msg_iov[0].iov_base = (void *)eui_64;
00045     msg_iov[0].iov_len = 8;
00046     msg_iov[1].iov_base = (void *)data;
00047     msg_iov[1].iov_len = data_len;
00048     socket_sendmsg(socket_id, &msghdr, NS_MSG_LEGACY0);
00049     return 0;
00050 }
00051 
00052 #endif /* HAVE_WS */
00053