]> rtime.felk.cvut.cz Git - frescor/frsh-forb.git/blob - src/fwp/fwp/mngr/wifi_agent.c
Warnings corrections
[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         //TODO: Initially here was print to descriptor 2 - find posix equivalent / test if it's working
36         //dprintf(2, "Actual_list_of_stations\n");
37         printf("Actual_list_of_stations\n");
38         ul_list_for_each(sta_list, &priv.sta_list, sta2){
39                 printf("%llu_-_%d\n", sta2->client_mac_addr, sta2->rate);
40         }
41         printf("------------\n\n");
42         
43 }
44
45 /**
46  *      Add information about AP (mac_address & bit rate)
47  */
48 CORBA_long wifi_agent_idl_add(wifi_agent_idl _obj, const CORBA_long rate, const CORBA_long_long client_mac_addr, CORBA_Environment *ev)
49 {
50         struct fwp_sta *ed = forb_instance_data(_obj);
51         fwp_sta_t *sta;
52         fwp_sta_t *new_to_add;
53
54         new_to_add = (fwp_sta_t*)malloc(sizeof(fwp_sta_t));
55
56         /*client transmission bitrate (wifi_agent -> fwp_manager)*/
57         ed->rate = rate;
58         ed->client_mac_addr = client_mac_addr;
59
60         /*fill the linked list here*/
61         ul_list_for_each(sta_list, &priv.sta_list, sta){
62                 
63                 /*client was sending info before*/
64                 if(sta->client_mac_addr == ed->client_mac_addr) {
65                         /*mac address is the same change only rate*/
66                         sta->rate = ed->rate;
67
68                         return 0;
69                 }
70         }
71         /*client was not sending info yet*/
72         new_to_add->rate = ed->rate;
73         new_to_add->client_mac_addr = ed->client_mac_addr;
74         
75         sta_list_ins_tail(&priv.sta_list, new_to_add);
76
77         return 0;
78 }
79