]> rtime.felk.cvut.cz Git - frescor/frsh-forb.git/blob - src/fwp/fwp/mngr/wifi_agent.c
Update of splitting forb executors
[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 struct forb_wifi_agent_idl_impl wifi_agent_impl = {
24         .add = wifi_agent_idl_add,
25         .print_state = wifi_agent_idl_print_state,
26 };
27
28 /**
29  *      Print list of stored stations
30  */
31 void wifi_agent_idl_print_state(wifi_agent_idl _obj, CORBA_Environment *ev)
32 {
33         fwp_sta_t *sta2;
34
35         dprintf(2, "Actual_list_of_stations\n");
36         ul_list_for_each(sta_list, &priv.sta_list, sta2){
37                 dprintf(2, "%llu_-_%d\n", sta2->client_mac_addr, sta2->rate);
38         }
39         dprintf(2, "------------\n\n");
40         
41 }
42
43 /**
44  *      Add information about AP (mac_address & bit rate)
45  */
46 CORBA_long wifi_agent_idl_add(wifi_agent_idl _obj, const CORBA_long rate, const CORBA_long_long client_mac_addr, CORBA_Environment *ev)
47 {
48         struct fwp_sta *ed = forb_instance_data(_obj);
49         fwp_sta_t *sta;
50         fwp_sta_t *new_to_add;
51
52         new_to_add = (fwp_sta_t*)malloc(sizeof(fwp_sta_t));
53
54         /*client transmission bitrate (wifi_agent -> fwp_manager)*/
55         ed->rate = rate;
56         ed->client_mac_addr = client_mac_addr;
57
58         /*fill the linked list here*/
59         ul_list_for_each(sta_list, &priv.sta_list, sta){
60                 
61                 /*client was sending info before*/
62                 if(sta->client_mac_addr == ed->client_mac_addr) {
63                         /*mac address is the same change only rate*/
64                         sta->rate = ed->rate;
65
66                         return 0;
67                 }
68         }
69         /*client was not sending info yet*/
70         new_to_add->rate = ed->rate;
71         new_to_add->client_mac_addr = ed->client_mac_addr;
72         
73         sta_list_ins_tail(&priv.sta_list, new_to_add);
74
75         return 0;
76 }
77