1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef COAP_CLIENT_H 17 #define COAP_CLIENT_H 18 19 #include <coap3/coap.h> 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 #define COAP_DEVICE_DISCOVER_URI "device_discover" 26 #define COAP_SERVICE_DISCOVER_URI "service_discover" 27 #define COAP_SERVICE_MSG_URI "service_msg" 28 29 typedef struct { 30 coap_proto_t proto; 31 const coap_address_t *dst; 32 } CoapServerParameter; 33 34 coap_context_t *CoapGetContext(const char *node, const char *port, uint8_t needBind, const struct in_addr *ip); 35 coap_session_t *CoapGetSession(coap_context_t *ctx, const char *localAddr, const char *localPort, 36 const CoapServerParameter *coapServerParameter); 37 38 int32_t CoapResolveAddress(const coap_str_const_t *server, struct sockaddr *dst); 39 coap_response_t CoapMessageHandler(coap_session_t *session, 40 const coap_pdu_t *sent, const coap_pdu_t *received, const coap_mid_t id); 41 42 uint8_t IsCoapCtxEndpointSocket(const coap_context_t *ctx, int fd); 43 44 #ifdef __cplusplus 45 } 46 #endif 47 #endif /* #ifndef COAP_CLIENT_H */ 48