]> rtime.felk.cvut.cz Git - frescor/frsh-forb.git/blob - src/fwp/fwp/mngr/wifi_agent.c
frm_fwp: Global variable correction
[frescor/frsh-forb.git] / src / fwp / fwp / mngr / wifi_agent.c
1 /*
2  *      @brief server side (frm_fwp) functions for communication 
3  *      resource manager - station
4  */
5
6 #include <frm_generic.h>
7 #include <forb.h>
8 #include <error.h>
9 #include <errno.h>
10 #include <getopt.h>
11 #include <fres_sa_scenario.h>
12 #include <stdbool.h>
13 #include <ul_list.h>
14 #include <ul_log.h>
15 #include <ul_logreg.h>
16 #include <fwp_res.h>
17 #include <stdio.h>
18 #include <string.h>
19 #include "wifi_agent_idl.h"
20 #include "fwp_admctrl.h"
21 #include "wifi_agent.h"
22
23 UL_LOG_CUST(ulogd_fwp_wifi_agent_server);
24 ul_log_domain_t ulogd_fwp_wifi_agent_server = {UL_LOGL_MSG, "fwp_wifi_agent_server"};
25 UL_LOGREG_SINGLE_DOMAIN_INIT_FUNCTION(fwp_wifi_agent_server_logreg_domains, ulogd_fwp_wifi_agent_server);
26
27 struct forb_wifi_agent_idl_impl wifi_agent_impl = {
28         .add = wifi_agent_idl_add,
29         .print_state = wifi_agent_idl_print_state,
30 };
31
32 /**
33  *      Print list of stored stations
34  */
35 void wifi_agent_idl_print_state(wifi_agent_idl _obj, CORBA_Environment *ev)
36 {
37         fwp_sta_t *sta2;
38         struct frm_fwp_priv *frm_fwp_state = forb_instance_data(_obj);
39
40         ul_logmsg("Actual_list_of_stations\n");
41         ul_list_for_each(sta_list, &frm_fwp_state->sta_list, sta2){
42                 ul_logmsg("%llu_-_%d\n", sta2->client_mac_addr, sta2->rate);
43         }
44         ul_logmsg("------------\n\n");
45         
46 }
47
48 /**
49  *      Add information about STA (mac_address & bit rate)
50  */
51 CORBA_long wifi_agent_idl_add(wifi_agent_idl _obj, const CORBA_long rate, const CORBA_long_long client_mac_addr, CORBA_Environment *ev)
52 {
53                 
54         struct frm_fwp_priv *frm_fwp_state = forb_instance_data(_obj);
55         fwp_sta_t *sta;
56         fwp_sta_t *new_to_add;
57
58         /*fill the linked list here*/
59         ul_list_for_each(sta_list, &frm_fwp_state->sta_list, sta){
60                 /*client was sending info before*/
61                 if(sta->client_mac_addr == client_mac_addr) {
62                         /*mac address is the same change only rate*/
63                         sta->rate = rate;
64                         return 0;
65                 }
66         }
67         new_to_add = (fwp_sta_t*)malloc(sizeof(fwp_sta_t));
68         /*client was not sending info yet*/
69         new_to_add->rate = rate;
70         new_to_add->client_mac_addr = client_mac_addr;
71         sta_list_ins_tail(&frm_fwp_state->sta_list, new_to_add);
72
73         return 0;
74 }
75