Adjusted mac address 'to number' converter.
Added test for checking right of handling with list of
stations.
Added function for printing list of stations.
+shared_LIBRARIES += wifi_agent_functions
+wifi_agent_functions_SOURCES = wifi_agent.c
+wifi_agent_functions_SERVER_IDL = wifi_agent_idl.idl
+include_HEADERS = wifi_agent.h
+include_GEN_HEADERS = wifi_agent_idl.h
+
bin_PROGRAMS = frm_fwp
frm_fwp_SOURCES = fwp_mngr.c fwp_admctrl.c wifi_agent.c
-frm_fwp_LIBS = frm forb contract fosa rt ulut fcb_client
+frm_fwp_LIBS = frm forb contract fosa rt ulut wifi_agent_functions
include_HEADERS = wifi_agent.h
CFLAGS += -D_FWP_INTERNALS_
lib_LOADLIBES+= frsh forb fosa pthread rt ulut
-frm_fwp_SERVER_IDL = wifi_agent_idl.idl
-include_GEN_HEADERS = wifi_agent_idl.h
+SUBDIRS = test
wifi_agent_idl wai; //wifi agent interface
struct fwp_sta intern_data;
-
if (getenv("FWP_BYPASS"))
priv.bypass = true;
ret = -1;
goto destroy_and_error;
}
-
+
forb_daemon_ready();
ret = forb_executor_run(&executor);
CFLAGS += -DWVTEST_CONFIGURED
-wvtest_SCRIPTS += adm-test.sh
+#wvtest_SCRIPTS += adm-test.sh
+
+wvtest_SCRIPTS += list_of_stations_test.sh
+test_PROGRAMS += list_of_stations_test
+list_of_stations_test_SOURCES = list_of_stations_test.c
+list_of_stations_test_LIBS += wvtest forb ulut wifi_agent_functions
+
--- /dev/null
+#include <forb.h>
+#include <error.h>
+#include <errno.h>
+#include <getopt.h>
+#include <fres_sa_scenario.h>
+#include <stdbool.h>
+#include <ul_list.h>
+#include <ul_log.h>
+#include <ul_logreg.h>
+#include <fwp_res.h>
+#include <stdio.h>
+#include <string.h>
+#include "wifi_agent_idl.h"
+#include "wifi_agent.h"
+#include "wvtest.h"
+
+typedef struct fwp_sta {
+ long long client_mac_addr;
+ int rate; //mbps
+ bool erp_ofdm;
+ bool short_preamble;
+ bool bypass;
+ ul_list_node_t sta_node;
+} fwp_sta_t;
+
+typedef struct fwp_sta_list {
+ ul_list_head_t requests;
+} fwp_sta_list_t;
+
+struct frm_fwp_priv {
+ int rate_mbps;
+ bool erp_ofdm;
+ bool short_preamble;
+ bool bypass;
+ fwp_sta_list_t sta_list;
+};
+
+UL_LIST_CUST_DEC(sta_list, // cust_prefix
+ fwp_sta_list_t, // cust_head_t
+ fwp_sta_t, // cust_item_t
+ requests, // cust_head_field
+ sta_node); // cust_node_field
+
+struct forb_wifi_agent_idl_impl wifi_agent_impl;
+
+struct frm_fwp_priv priv = {
+ .rate_mbps = 1,
+ .erp_ofdm = false,
+ .short_preamble = false,
+// .list_head = NULL,//head of linked list initialized in main function
+};
+
+//WVTEST_MAIN("list-of-stations-test")
+int main(void)
+{
+ forb_orb orb;
+ int ret;
+ bool opt_daemon = false;
+ char *opt_pidfile = NULL;
+
+ forb_executor_t executor;
+
+ wifi_agent_idl wai; //wifi agent interface
+ struct fwp_sta intern_data;
+ CORBA_Environment env;
+
+ if (getenv("FWP_BYPASS"))
+ priv.bypass = true;
+
+ if (opt_daemon)
+ forb_daemon_prepare(opt_pidfile);
+
+ orb = forb_init(NULL, NULL, NULL);
+ if (!orb) return 1;
+
+ wai = forb_wifi_agent_idl_new(orb, &wifi_agent_impl, &intern_data);
+
+ forb_register_reference(wai, "net.sourceforge.frsh-forb.wai");
+
+ sta_list_init_head(&priv.sta_list);
+
+ ret = forb_executor_init(&executor);
+ if (ret) return 1;
+
+ ret = forb_executor_register_object(&executor, wai);
+ if (ret) return 1;
+
+ wifi_agent_idl_add(wai, 10, 120976291, &env);
+ wifi_agent_idl_add(wai, 12, 120976291, &env);
+ wifi_agent_idl_add(wai, 20, 80976291, &env);
+ //wifi_agent_idl_add(wai, 64, 80955472, &env);
+ //wifi_agent_idl_add(wai, 1, 80976291, &env);
+ //wifi_agent_idl_add(wai, 10, 120976291, &env);
+
+ return 0;
+}
+
--- /dev/null
+#!/bin/bash
+
+. $(dirname $0)/wvtest.sh
+
+wvtest_cleanup() {
+ WVPASS kill `cat fcb.pid`
+ WVPASS rm fcb.pid
+}
+
+WVPASS fcb -dfcb.pid
+
+cat > expected << EOF
+Added new station
+Actual list of all stations
+[mac address (dec) - rate]
+120976291 - 10
+------------
+
+Changed rate in a station 120976291
+Actual list of all stations
+[mac address (dec) - rate]
+120976291 - 12
+------------
+
+Added new station
+Actual list of all stations
+[mac address (dec) - rate]
+120976291 - 12
+80976291 - 20
+------------
+
+EOF
+
+WVPASS sh -c "list_of_stations_test > actual"&
+R1=$!
+
+WVPASS diff -u expected actual
+
+kill $R1
+
-#include "wifi_agent_idl.h"
-//#include "wifi_agent_idl.h"
#include <frm_generic.h>
#include <forb.h>
#include <error.h>
.add = wifi_agent_idl_add,
};
+void print_list_of_stations(void)
+{
+ fwp_sta_t *sta2;
+
+ ul_list_for_each(sta_list, &priv.sta_list, sta2){
+ printf("%llu -", sta2->client_mac_addr);
+ printf(" %d\n", sta2->rate);
+ }
+ printf("------------\n\n");
+
+}
+
/**
* Add information about AP (mac_address & bit rate)
*/
fwp_sta_t *new_to_add;
new_to_add = (fwp_sta_t*)malloc(sizeof(fwp_sta_t));
-
+
//client transmission bitrate (wifi_agent -> fwp_manager)
ed->rate = rate;
ed->client_mac_addr = client_mac_addr;
+
//fill the linked list here
//for each list
ul_list_for_each(sta_list, &priv.sta_list, sta){
//client was sending info before
+
if(sta->client_mac_addr == ed->client_mac_addr) {
//mac address is the same change only rate
sta->rate = ed->rate;
+
+ printf("Changed rate in a station %d\n", sta->client_mac_addr);
+ printf("Actual list of all stations\n[mac address (dec) - rate]\n");
+ print_list_of_stations();
+
return 0;
}
}
new_to_add->client_mac_addr = ed->client_mac_addr;
sta_list_ins_tail(&priv.sta_list, new_to_add);
-
+
+ printf("Added new station\n");
+ printf("Actual list of all stations\n[mac address (dec) - rate]\n");
+ print_list_of_stations();
+
return 0;
}
+
#define WAI_SERVER_ID (forb_server_id){ .uuid = { 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 } }
#define WAI_TCP_PORT 24943
-extern struct forb_wifi_agent_idl_impl wifi_agent_impl ;
+extern struct forb_wifi_agent_idl_impl wifi_agent_impl;
#endif
long long help;
int ix;
int ix2;
+ char mac_num[12];
+
+ mac_num[0] = mac[0];
+ mac_num[1] = mac[1];
+ mac_num[2] = mac[3];
+ mac_num[3] = mac[4];
+ mac_num[4] = mac[6];
+ mac_num[5] = mac[7];
+ mac_num[6] = mac[9];
+ mac_num[7] = mac[10];
+ mac_num[8] = mac[12];
+ mac_num[9] = mac[13];
+ mac_num[10] = mac[15];
+ mac_num[11] = mac[16];
number = 0;
- for(ix = 0; ix <= 17 ; ix++)
+ for(ix = 0; ix <= 12 ; ix++)
{
- if(mac[ix] == ':')
- continue;
- else
- {
- help = 1;
- for(ix2 = 1; ix2 < 12 - ix; ix2++)
- help *= 16;
- number += atoint(mac[ix]) * help;
- }
- }
+ help = 1;
+ for(ix2 = 1; ix2 < 12 - ix; ix2++)
+ help *= 16;
+ number += atoint(mac_num[ix]) * help;
+ }
+
+ printf("%llu \n", number);
return number;
}
fwp_orb = forb_init(&argc, &argv, NULL); /* FORB initialization */
/* Find our implementation */
- wai = forb_resolve_reference(fwp_orb, "wai");
+ wai = forb_resolve_reference(fwp_orb, "net.sourceforge.frsh-forb.wai");
if(wai == NULL)
fprintf(stderr, "failed to create connection\n");
/* Call server functions and send wifi info */
if(wai != NULL)
- wifi_agent_idl_add(wai, rate_glob, mac_addr_string_to_number(mac_addr_glob), &env);
-
+ { printf("%d \n", rate_glob);
+ wifi_agent_idl_add(wai, rate_glob / 10, mac_addr_string_to_number(mac_addr_glob), &env);
+ }
//TODO: Optimalize sending interval
delay(10000);
}