• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "nstackx_inet.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #define COAP_DEVICE_DISCOVER_URI "device_discover"
27 #define COAP_SERVICE_DISCOVER_URI "service_discover"
28 #define COAP_SERVICE_MSG_URI "service_msg"
29 #define COAP_SERVICE_NOTIFICATION_URI "short_notification_message"
30 
31 typedef struct {
32     coap_proto_t proto;
33     const coap_address_t *dst;
34 } CoapServerParameter;
35 
36 coap_context_t *CoapGetContext(const char *node, const char *port,
37     uint8_t af, const union InetAddr *ip);
38 coap_session_t *CoapGetSession(coap_context_t *ctx, const char *localAddr, const char *localPort,
39     const CoapServerParameter *coapServerParameter);
40 
41 int32_t CoapResolveAddress(const coap_str_const_t *server, struct sockaddr *dst);
42 coap_response_t CoapMessageHandler(coap_session_t *session,
43     const coap_pdu_t *sent, const coap_pdu_t *received, const coap_mid_t id);
44 
45 uint8_t IsCoapCtxEndpointSocket(const coap_context_t *ctx, int fd);
46 
47 #ifdef __cplusplus
48 }
49 #endif
50 #endif /* #ifndef COAP_CLIENT_H */
51