1 /*
2  * Copyright (C) 2021-2023 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 #define COAP_SERVICE_NOTIFICATION_URI "short_notification_message"
29 
30 typedef struct {
31     coap_proto_t proto;
32     const coap_address_t *dst;
33 } CoapServerParameter;
34 
35 coap_context_t *CoapGetContext(const char *node, const char *port, uint8_t needBind, const struct in_addr *ip);
36 coap_session_t *CoapGetSession(coap_context_t *ctx, const char *localAddr, const char *localPort,
37     const CoapServerParameter *coapServerParameter);
38 
39 int32_t CoapResolveAddress(const coap_str_const_t *server, struct sockaddr *dst);
40 coap_response_t CoapMessageHandler(coap_session_t *session,
41     const coap_pdu_t *sent, const coap_pdu_t *received, const coap_mid_t id);
42 
43 uint8_t IsCoapCtxEndpointSocket(const coap_context_t *ctx, int fd);
44 
45 #ifdef __cplusplus
46 }
47 #endif
48 #endif /* #ifndef COAP_CLIENT_H */
49