| #ifndef __CHL_AGT__ |
| #define __CHL_AGT__ |
| |
| #include "chl_agent_ubus.h" |
| #include "chl_agent_uci.h" |
| #include <chl.h> |
| |
| #define _FILE_ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) |
| |
| |
| enum AGT_LOG_LEVEL { |
| AGT_LOG_LEVEL_ERR, |
| AGT_LOG_LEVEL_WARN, |
| AGT_LOG_LEVEL_INFO, |
| AGT_LOG_LEVEL_DBG, |
| }; |
| |
| void print_console(enum AGT_LOG_LEVEL level, const char *fmt, ...); |
| |
| #ifdef AGT_USE_LOGCAT |
| #define AGT_PRINTF(f_, ...) RDBGMSG("%s:%d " f_, _FILE_ , \ |
| __LINE__, ##__VA_ARGS__) |
| #define AGT_DBG(f_, ...) RDBGMSG("%s:%d " f_, _FILE_ , __LINE__, ##__VA_ARGS__) |
| #define AGT_INFO(f_, ...) RINFOMSG("%s:%d " f_, _FILE_ , __LINE__, ##__VA_ARGS__) |
| #define AGT_WARN(f_, ...) RWARNMSG("%s:%d " f_, _FILE_ , __LINE__, ##__VA_ARGS__) |
| #define AGT_ERR(f_, ...) RERRMSG("%s:%d " f_, _FILE_ , __LINE__, ##__VA_ARGS__) |
| #else |
| |
| #define AGT_PRINTF(level, f_, ...) print_console(level,"%s:%d " f_, _FILE_ , __LINE__, ##__VA_ARGS__) |
| #define AGT_DBG(f_, ...) AGT_PRINTF(AGT_LOG_LEVEL_DBG, f_, ##__VA_ARGS__) |
| #define AGT_INFO(f_, ...) AGT_PRINTF(AGT_LOG_LEVEL_INFO, f_, ##__VA_ARGS__) |
| #define AGT_WARN(f_, ...) AGT_PRINTF(AGT_LOG_LEVEL_WARN, "WARNING: " f_, ##__VA_ARGS__) |
| #define AGT_ERR(f_, ...) AGT_PRINTF(AGT_LOG_LEVEL_ERR, "ERROR: " f_, ##__VA_ARGS__) |
| #endif |
| |
| #define max(a,b) \ |
| ({ __typeof__ (a) _a = (a); \ |
| __typeof__ (b) _b = (b); \ |
| _a > _b ? _a : _b; }) |
| |
| #define CMD_LEN 60 |
| |
| static inline char *pdp_action_to_str(enum pdp_action action) |
| { |
| switch(action) { |
| case ERR_VAL: |
| return "ERR_VAL"; |
| case DO_NOTHING: |
| return "DO_NOTHING"; |
| case CLOSE_PDP: |
| return "CLOSE_PDP"; |
| case OPEN_PDP: |
| return "OPEN_PDP"; |
| case CHECK_ROUTE: |
| return "CHECK_ROUTE"; |
| case CLOSE_OPEN_PDP: |
| return "CLOSE_OPEN_PDP"; |
| default: |
| return "Unknown"; |
| } |
| } |
| |
| int is_wifi_ld(); |
| int is_data_enabled(); |
| void print_configuration( struct agent_conf *conf); |
| void add_del_portforwarding( bool add , bool old_state, char *host_ip ); |
| void checkroute_pdps(struct agent_conf *new_conf); |
| void copy_pdps(struct agent_conf *new_conf); |
| void open_pdps(struct agent_conf *new_conf); |
| void close_pdps(); |
| void stop_agent(); |
| void ind_handler(int pdp_id, enum chl_nw_status nw_status); |
| void add_del_pdp_routes( struct agent_pdp *pdp, bool add); |
| int update_configuration(); |
| void update_routes(struct agent_pdp *new_pdp, |
| struct agent_pdp *cur_pdp); |
| enum pdp_action compare_pdp(struct agent_conf *new_conf,int i); |
| |
| int check_delta(struct agent_pdp *new_p, |
| struct agent_pdp *cur_p); |
| |
| #endif |