1 /* 2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited 3 */ 4 5 #ifndef NETMGR_CONN_H 6 #define NETGMR_CONN_H 7 #include <string.h> 8 #include <stdbool.h> 9 #include <stdlib.h> 10 #include <unistd.h> 11 #include <netmgr.h> 12 #include "sys/socket.h" 13 14 typedef struct netmgr_conn netmgr_conn_t; 15 struct netmgr_conn 16 { 17 netmgr_conn_t* next; 18 netmgr_hdl_t hdl; 19 void* netif; 20 void* saved_config; 21 netmgr_conn_state_t state; /* connection state */ 22 int type; /* link type eg:Wi-Fi, Cellular */ 23 bool auto_reconnect; /* Auto reconnect setting flag */ 24 int use_ip_mode; /* Ip mode: Auto, Static */ 25 ip_addr_t static_ip; 26 ip_addr_t static_mask; 27 ip_addr_t static_gw; 28 ip_addr_t static_dns; 29 int reconnect_task_running; /* reconnect task is running:true(running), false(stop) */ 30 int (*connected_cb)(netmgr_conn_t* conn); /* link connected callback */ 31 int (*failed_cb)(netmgr_conn_t* conn); /* failed callback */ 32 int (*obtaining_ip_cb)(netmgr_conn_t* conn); /* obtaining_ip callback */ 33 int (*network_connected_cb)(netmgr_conn_t* conn); /* network connected callback */ 34 int (*disconnecting_cb)(netmgr_conn_t* conn); /* disconnecting callback */ 35 int (*disconnected_cb)(netmgr_conn_t* conn); /* disconnected callback */ 36 void* msg_cb_list; /* msg callback list */ 37 }; 38 39 netmgr_conn_t* netmgr_conn_init(netmgr_type_t type); 40 int netmgr_conn_deinit(netmgr_conn_t* conn); 41 int netmgr_conn_state_change(netmgr_conn_t *conn, netmgr_conn_state_t new_state); 42 43 #endif /* NETMGR_CONN_H */ 44