2 * @brief server side (frm_fwp) functions for communication
3 * resource manager - station
6 #include <frm_generic.h>
11 #include <fres_sa_scenario.h>
15 #include <ul_logreg.h>
19 #include "wifi_agent_idl.h"
20 #include "fwp_admctrl.h"
21 #include "wifi_agent.h"
24 UL_LOG_CUST(ulogd_fwp_wifi_agent_server);
25 ul_log_domain_t ulogd_fwp_wifi_agent_server = {UL_LOGL_MSG, "fwp_wifi_agent_server"};
26 UL_LOGREG_SINGLE_DOMAIN_INIT_FUNCTION(fwp_wifi_agent_server_logreg_domains, ulogd_fwp_wifi_agent_server);
28 struct forb_wifi_agent_idl_impl wifi_agent_impl = {
29 .add = wifi_agent_idl_add,
30 .print_state = wifi_agent_idl_print_state,
34 * Print list of stored stations
36 void wifi_agent_idl_print_state(wifi_agent_idl _obj, CORBA_Environment *ev)
39 struct frm_fwp_priv *frm_fwp_state = forb_instance_data(_obj);
41 ul_logmsg("Actual_list_of_stations\n");
42 ul_list_for_each(sta_list, &frm_fwp_state->sta_list, sta2){
43 ul_logmsg("%llu_-_%d\n", sta2->client_mac_addr, sta2->rate);
45 ul_logmsg("------------\n\n");
50 * Add information about STA (mac_address & bit rate)
52 CORBA_long wifi_agent_idl_add(wifi_agent_idl _obj, const CORBA_long rate, const CORBA_long_long client_mac_addr, CORBA_Environment *ev)
54 struct frm_fwp_priv *frm_fwp_state = forb_instance_data(_obj);
56 fwp_sta_t *new_to_add;
57 const frsh_resource_type_t restype = FRSH_RT_NETWORK;
58 const frsh_resource_id_t resid = 1;
59 CORBA_Environment env;
61 /*fill the linked list here*/
62 ul_list_for_each(sta_list, &frm_fwp_state->sta_list, sta){
63 /*client was sending info before*/
64 if(sta->client_mac_addr == client_mac_addr) {
65 /*mac address is the same change only rate*/
66 pthread_mutex_lock( &frm_fwp_state->mutex );
67 ul_logmsg("Mutex: locked - update station\n");
69 pthread_mutex_unlock( &frm_fwp_state->mutex );
70 ul_logmsg("Mutex: unlocked - update station\n");
72 fres_contract_broker_redistribute_spare_capacity(frm_fwp_state->fcb, restype, resid, &env);
73 if (forb_exception_occurred(&env)) {
74 ul_logerr("fres_contract_broker_redistribute_spare_capacity: %s\n", forb_strerror(&env));
75 return fres_forbex2err(&env);
80 new_to_add = (fwp_sta_t*)malloc(sizeof(fwp_sta_t));
81 /*client was not sending info yet*/
82 new_to_add->rate = rate;
83 new_to_add->client_mac_addr = client_mac_addr;
84 pthread_mutex_lock( &frm_fwp_state->mutex );
85 ul_logmsg("Mutex: locked - add new station\n");
86 sta_list_ins_tail(&frm_fwp_state->sta_list, new_to_add);
87 pthread_mutex_unlock( &frm_fwp_state->mutex );
88 ul_logmsg("Mutex: unlocked - add new station\n");