blob: d07a524107b300f5ad179a4c644ee548455bc656 [file] [log] [blame]
b.liud440f9f2025-04-18 10:44:31 +08001/*-----------------------------------------------------------------------------------------------*/
2/**
3 @file ql_nf.h
4 @brief Network framework API
5*/
6/*-----------------------------------------------------------------------------------------------*/
7
8/*-------------------------------------------------------------------------------------------------
9 Copyright (c) 2018 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
10 Quectel Wireless Solution Proprietary and Confidential.
11-------------------------------------------------------------------------------------------------*/
12
13/*-------------------------------------------------------------------------------------------------
14 EDIT HISTORY
15 This section contains comments describing changes made to the file.
16 Notice that changes are listed in reverse chronological order.
17 $Header: $
18 when who what, where, why
19 -------- --- ----------------------------------------------------------
20 20181024 tyler.kuang Created .
21-------------------------------------------------------------------------------------------------*/
22
23#ifndef __QL_NF_H__
24#define __QL_NF_H__
25#include <sys/socket.h>
26#include <netinet/in.h>
27#include <arpa/inet.h>
28#include "ql_net_common.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34typedef struct {
35 char name[QL_NET_MAX_NAME_LEN];
36 char ifname[QL_NET_MAX_NAME_LEN];
37 char pre_status[16];
38 char status[16];
39 uint8_t has_addr;
40 ql_net_addr_t addr;
41 uint8_t has_addr6;
42 ql_net_addr6_t addr6;
43} ql_nf_interface_status_t;
44
45typedef void (*ql_nf_interface_status_ind_cb_f)(ql_nf_interface_status_t *p_msg);
46
47typedef void (*ql_nf_service_error_cb_f)(int error);
48
49/*-----------------------------------------------------------------------------------------------*/
50/**
51 @brief Initialize network service
52 @return
53 QL_ERR_OK - successful
54 QL_ERR_INVALID_ARG - as defined
55 QL_ERR_UNKNOWN - unknown error, failed to connect to service
56 QL_ERR_SERVICE_NOT_READY - service is not ready, need to retry
57 Other - error code defined by ql_type.h
58 */
59/*-----------------------------------------------------------------------------------------------*/
60int ql_nf_init(void);
61
62/*-----------------------------------------------------------------------------------------------*/
63/**
64 @brief Send a command and wait for a response
65 @param[in] cmd Command
66 @param[out] resp_buf Response
67 @param[in] resp_len Response buffer length
68 @return
69 QL_ERR_OK - successful
70 QL_ERR_INVALID_ARG - as defined
71 QL_ERR_UNKNOWN - unknown error, failed to connect to service
72 QL_ERR_SERVICE_NOT_READY - service is not ready, need to retry
73 Other - error code defined by ql_type.h
74 */
75/*-----------------------------------------------------------------------------------------------*/
76int ql_nf_cmd(const char *cmd, char *resp_buf, int resp_len);
77
78/*-----------------------------------------------------------------------------------------------*/
79/**
80 @brief Send a command and wait for a response
81 @param[in] cmd Command
82 @param[out] resp_buf Response
83 @param[in] resp_len Response buffer length
84 @return
85 QL_ERR_OK - successful
86 QL_ERR_INVALID_ARG - as defined
87 QL_ERR_UNKNOWN - unknown error, failed to connect to service
88 QL_ERR_SERVICE_NOT_READY - service is not ready, need to retry
89 Other - error code defined by ql_type.h
90 */
91/*-----------------------------------------------------------------------------------------------*/
92int ql_nf_cmd_json(const char *cmd, char *resp_buf, int resp_len);
93
94/*-----------------------------------------------------------------------------------------------*/
95/**
96 @brief Register NF interface status change event event
97 @param[in] cb
98 @return
99 QL_ERR_OK - successful
100 QL_ERR_NOT_INIT - uninitialized
101 QL_ERR_SERVICE_NOT_READY - service is not ready
102 QL_ERR_INVALID_ARG - Invalid arguments
103 Other - error code defined by ql_type.h
104 */
105/*-----------------------------------------------------------------------------------------------*/
106int ql_nf_set_interface_status_ind_cb(ql_nf_interface_status_ind_cb_f cb);
107
108/*-----------------------------------------------------------------------------------------------*/
109/**
110 @brief Registration server error callback. Currently, only if the server exits abnormally,
111 the callback function will be executed, and the error code is QL_ERR_ABORTED;
112 @param[in] cb Callback function
113 @return
114 QL_ERR_OK - successful
115 Other - error code defined by ql_type.h
116 */
117/*-----------------------------------------------------------------------------------------------*/
118int ql_nf_set_service_error_cb(ql_nf_service_error_cb_f cb);
119
120/*-----------------------------------------------------------------------------------------------*/
121/**
122 @brief Deinitialize the data call service
123 @return
124 QL_ERR_OK - successful
125 Other - error code defined by ql_type.h
126 */
127/*-----------------------------------------------------------------------------------------------*/
128int ql_nf_deinit(void);
129
130#ifdef __cplusplus
131}
132#endif
133
134#endif
135