1 /*
2  * MDNS Dependecy injection -- preincluded to inject interface test functions into static variables
3  *
4  */
5 
6 #include "mdns.h"
7 #include "mdns_private.h"
8 
9 void              (*mdns_test_static_execute_action)(mdns_action_t *) = NULL;
10 mdns_srv_item_t * (*mdns_test_static_mdns_get_service_item)(const char * service, const char * proto) = NULL;
11 mdns_search_once_t * (*mdns_test_static_search_init)(const char * name, const char * service, const char * proto, uint16_t type, uint32_t timeout, uint8_t max_results) = NULL;
12 esp_err_t         (*mdns_test_static_send_search_action)(mdns_action_type_t type, mdns_search_once_t * search) = NULL;
13 void              (*mdns_test_static_search_free)(mdns_search_once_t * search) = NULL;
14 
15 static void _mdns_execute_action(mdns_action_t * action);
16 static mdns_srv_item_t * _mdns_get_service_item(const char * service, const char * proto);
17 static mdns_search_once_t * _mdns_search_init(const char * name, const char * service, const char * proto, uint16_t type, uint32_t timeout, uint8_t max_results);
18 static esp_err_t _mdns_send_search_action(mdns_action_type_t type, mdns_search_once_t * search);
19 static void _mdns_search_free(mdns_search_once_t * search);
20 
mdns_test_init_di(void)21 void mdns_test_init_di(void)
22 {
23     mdns_test_static_execute_action = _mdns_execute_action;
24     mdns_test_static_mdns_get_service_item = _mdns_get_service_item;
25     mdns_test_static_search_init = _mdns_search_init;
26     mdns_test_static_send_search_action = _mdns_send_search_action;
27     mdns_test_static_search_free = _mdns_search_free;
28 }
29 
mdns_test_execute_action(void * action)30 void mdns_test_execute_action(void * action)
31 {
32     mdns_test_static_execute_action((mdns_action_t *)action);
33 }
34 
mdns_test_search_free(mdns_search_once_t * search)35 void mdns_test_search_free(mdns_search_once_t * search)
36 {
37     return mdns_test_static_search_free(search);
38 }
39 
mdns_test_send_search_action(mdns_action_type_t type,mdns_search_once_t * search)40 esp_err_t mdns_test_send_search_action(mdns_action_type_t type, mdns_search_once_t * search)
41 {
42     return mdns_test_static_send_search_action(type, search);
43 }
44 
mdns_test_search_init(const char * name,const char * service,const char * proto,uint16_t type,uint32_t timeout,uint8_t max_results)45 mdns_search_once_t * mdns_test_search_init(const char * name, const char * service, const char * proto, uint16_t type, uint32_t timeout, uint8_t max_results)
46 {
47     return mdns_test_static_search_init(name, service, proto, type, timeout, max_results);
48 }
49 
mdns_test_mdns_get_service_item(const char * service,const char * proto)50 mdns_srv_item_t * mdns_test_mdns_get_service_item(const char * service, const char * proto)
51 {
52     return mdns_test_static_mdns_get_service_item(service, proto);
53 }
54