]> rtime.felk.cvut.cz Git - frescor/frsh-forb.git/commitdiff
Merge remote branch 'origin/master' into wifi-adaptive
authorTuka Martin <tukamart@fel.cvut.cz>
Tue, 29 Mar 2011 10:05:48 +0000 (12:05 +0200)
committerTuka Martin <tukamart@fel.cvut.cz>
Tue, 29 Mar 2011 10:05:48 +0000 (12:05 +0200)
Conflicts:
src/fwp/fwp/mngr/fwp_mngr.c
src/fwp/fwp/mngr/wifi_agent.h

1  2 
src/fwp/fwp/mngr/Makefile.omk
src/fwp/fwp/mngr/fwp_admctrl.h
src/fwp/fwp/mngr/fwp_mngr.c
src/fwp/fwp/mngr/fwp_mngr.c.orig
src/fwp/fwp/mngr/wifi_agent.c
src/fwp/fwp/mngr/wifi_agent.h
src/fwp/fwp/mngr/wifi_agent.h.orig

index 25afd7666740a312cf5569a7ec08b83bb56f6c98,3b0f6b3bf10ccade73ac4026d2ab152423bf8f8d..49d16f53208ebe5bd3630d758862b1e942936f0b
@@@ -1,10 -1,7 +1,10 @@@
  bin_PROGRAMS = frm_fwp
 -frm_fwp_SOURCES = fwp_mngr.c fwp_admctrl.c
 +frm_fwp_SOURCES = fwp_mngr.c fwp_admctrl.c wifi_agent.c
  frm_fwp_LIBS = frm forb contract fosa rt ulut fcb_client
  
#include_HEADERS = res_fwp.h
include_HEADERS = wifi_agent.h
  CFLAGS += -D_FWP_INTERNALS_
 -lib_LOADLIBES+= frsh 
 +lib_LOADLIBES+= frsh forb fosa pthread rt ulut
 +
 +frm_fwp_SERVER_IDL = wifi_agent_idl.idl
 +include_GEN_HEADERS = wifi_agent_idl.h
index 662dc1b48312c5453beae38a369b9d708627fd95,ae4207c4a672c300553ebe9fa04a6113f94b00d4..8f947e063bba431525a78e310a742f01403d31a9
  #define _FWP_ADMCTRL_H
  
  #include <frsh_distributed.h>
 +#include <ul_list.h>
 +
 +#define SIZE_MAC_ADDR 20
 +
 +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;
  };
  
- extern 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
- };
++extern struct frm_fwp_priv priv;
 +
 +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 */
 +
  int fwp_admctrl_utilization(struct fres_sa_scenario *scenario, void *priv,
                                  bool *schedulable);
  
index f80e6a89d00e8a8202e0f4f1df7cb1984e04532c,5fd03a017bd80862a6e05ca46d774328df52cea4..6a76b1aa140574c8be440ac7676e041935e6b873
  #include <ul_logreg.h>
  #include <fwp_res.h>
  #include <stdio.h>
 +#include <string.h>
 +#include "wifi_agent_idl.h"
  #include "fwp_admctrl.h"
 -#include <wifi_agent.h>
 +#include "wifi_agent.h"
++#include "priv.h"
  
  #if 0
  static
@@@ -88,10 -85,6 +89,7 @@@ int dummy_admission_test(struct fres_sa
  }
  #endif
  
- struct forb_wifi_agent_idl_impl wifi_impl = {
-       .add = wifi_agent_idl_add, 
- };
 +
  struct frm_fwp_priv priv = {
        .rate_mbps = 1,
        .erp_ofdm = false,
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..1173f6c0502b39a885a572acb933f9c8602476f0
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,225 @@@
++/**************************************************************************/
++/* ---------------------------------------------------------------------- */
++/* Copyright (C) 2006 - 2008 FRESCOR consortium partners:               */
++/*                                                                      */
++/*   Universidad de Cantabria,              SPAIN                       */
++/*   University of York,                    UK                                  */
++/*   Scuola Superiore Sant'Anna,            ITALY                       */
++/*   Kaiserslautern University,             GERMANY                     */
++/*   Univ. Politécnica  Valencia,           SPAIN                      */
++/*   Czech Technical University in Prague,  CZECH REPUBLIC              */
++/*   ENEA                                   SWEDEN                      */
++/*   Thales Communication S.A.              FRANCE                      */
++/*   Visual Tools S.A.                      SPAIN                       */
++/*   Rapita Systems Ltd                     UK                                  */
++/*   Evidence                               ITALY                       */
++/*                                                                      */
++/*   See http://www.frescor.org for a link to partners' websites        */
++/*                                                                      */
++/*          FRESCOR project (FP6/2005/IST/5-034026) is funded           */
++/*       in part by the European Union Sixth Framework Programme        */
++/*       The European Union is not liable of any use that may be        */
++/*       made of this code.                                             */
++/*                                                                      */
++/*                                                                      */
++/*  This file is part of FWP (Frescor WLAN Protocol)                    */
++/*                                                                      */
++/* FWP is free software; you can redistribute it and/or modify it       */
++/* under terms of the GNU General Public License as published by the    */
++/* Free Software Foundation; either version 2, or (at your option) any          */
++/* later version.  FWP is distributed in the hope that it will be       */
++/* useful, but WITHOUT ANY WARRANTY; without even the implied warranty          */
++/* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU          */
++/* General Public License for more details. You should have received a          */
++/* copy of the GNU General Public License along with FWP; see file      */
++/* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,  */
++/* Cambridge, MA 02139, USA.                                            */
++/*                                                                      */
++/* As a special exception, including FWP header files in a file,        */
++/* instantiating FWP generics or templates, or linking other files      */
++/* with FWP objects to produce an executable application, does not      */
++/* by itself cause the resulting executable application to be covered   */
++/* by the GNU General Public License. This exception does not           */
++/* however invalidate any other reasons why the executable file might be  */
++/* covered by the GNU Public License.                                   */
++/**************************************************************************/
++#include <frm_generic.h>
++#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 "fwp_admctrl.h"
++<<<<<<< HEAD
++#include "wifi_agent.h"
++=======
++#include <wifi_agent.h>
++>>>>>>> origin/master
++
++#if 0
++static
++int dummy_admission_test(struct fres_sa_scenario *scenario, void *priv, 
++                              bool *schedulable)
++{
++      struct fres_sa_contract *c;
++
++      printf("Dummy admission test:\n");
++
++      fres_sa_scenario_for_each_no_cancel_contract(scenario, c) {
++              fres_block_basic *basic;
++              char id[40];
++              fres_contract_id_to_string(id, &c->contract->id, sizeof(id));
++              basic = fres_contract_get_basic(c->contract);
++
++              printf("  processing: id=%s, period=%ld ms, budget=%ld ms\n",
++                     id,
++                     fosa_rel_time_to_msec(basic->period),
++                     fosa_rel_time_to_msec(basic->budget));
++
++      }
++      *schedulable = scenario->num_contracts <= 3;
++      printf("=> %s\n", schedulable?"schedulable":"not schedulable");
++              
++      return 0;
++}
++#endif
++
++struct forb_wifi_agent_idl_impl wifi_impl = {
++      .add = wifi_agent_idl_add, 
++};
++
++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
++};
++
++static const struct fres_res_manager frm = {
++      .res_type = FRSH_RT_NETWORK,
++      .res_id = FRSH_NETPF_FWP,
++      //.admission_test = dummy_admission_test,
++      .name = "WLAN",
++      .admission_test = fwp_admctrl_utilization,
++      .priv = &priv,
++};
++
++static struct option long_opts[] = {
++    { "loglevel",         required_argument, 0, 'l' },
++    { "bitrate",        required_argument, 0, 'b' },
++    { "ofdm",                   no_argument,       0, 'o' },
++    { "short-preamble",  no_argument,              0, 's' },
++    { 0, 0, 0, 0}
++};
++
++static void
++usage(void)
++{
++      printf("usage: fwpmngr [ options ]\n");
++      printf("  -l, --loglevel <number>|<domain>=<number>,...\n");
++      printf("  -b, --bitrate <mbits/s>\n");
++      printf("  -o, --ofdm\n");
++      printf("  -s, --short-preamble\n");
++      printf("  -h, --help\n");
++}
++
++int main(int argc, char *argv[])
++{
++      forb_orb orb;
++      int ret;
++      forb_init_attr_t attr = { .orb_id = "org.frescor.frm.fwp",
++                                .fixed_tcp_port = WAI_TCP_PORT,
++      };
++      int  opt;
++      bool opt_daemon = false;
++      char *opt_pidfile = NULL;
++
++      forb_executor_t executor;
++      fres_resource_manager frm_ret;
++      struct frm_data frm_data;
++
++      wifi_agent_idl wai;     //wifi agent interface
++      struct fwp_sta intern_data;
++      
++
++      if (getenv("FWP_BYPASS"))
++              priv.bypass = true;
++
++
++      while ((opt = getopt_long(argc, argv, "b:d:hl:os", &long_opts[0], NULL)) != EOF) {
++              switch (opt) {
++                      case 'd':
++                              opt_daemon = true;
++                              opt_pidfile = optarg;
++                              break;
++                      case 'l':
++                              ul_log_domain_arg2levels(optarg);
++                              break;
++                      case 'b':
++                              priv.rate_mbps = atol(optarg);
++                              break;
++                      case 's':
++                              priv.short_preamble = true;
++                              break;
++                      case 'o':
++                              priv.erp_ofdm = true;
++                              break;
++                      case 'h':
++                      /*default:*/
++                              usage();
++                              exit(opt == 'h' ? 0 : 1);
++              }
++      }
++
++      if (opt_daemon)
++              forb_daemon_prepare(opt_pidfile);
++
++      orb = forb_init(&argc, &argv, &attr);
++      if (!orb) error(1, errno, "forb_init");
++      
++      /* Cration of an object implementing myinterface */
++        wai = forb_wifi_agent_idl_new(orb, &wifi_impl, &intern_data);
++        
++      /* We can register our object under a name, so that other
++         * processes can use it. */
++        forb_register_reference(wai, "net.sourceforge.frsh-forb.wai");
++
++      /* Initialize head of linked list */
++      sta_list_init_head(&priv.sta_list);
++      
++      //create executor and register 2 interfaces
++      ret = forb_executor_init(&executor);
++      if (ret) goto error;
++      
++              //1. interface - forb_execute_object(wai); execute      
++              ret = forb_executor_register_object(&executor, wai);
++              if (ret) goto destroy_and_error;
++
++              //2. interface - frm_register_and_run(orb, &frm); execute
++              fres_block_register_fwp();
++
++              frm_ret = frm_register(orb, &frm_data, &executor, &frm);
++              if (!frm_ret) {
++                      ret = -1;
++                      goto destroy_and_error;
++              }
++              
++              forb_daemon_ready();
++      
++      ret = forb_executor_run(&executor);
++
++destroy_and_error:
++      forb_executor_destroy(&executor);
++error:
++      error(1, errno, "frm_generic_run");
++      
++      return 0;
++}
index 5ef3dafa63f9468f39b2eabfcb6dd5b250acf468,0000000000000000000000000000000000000000..71339c221983c18964a3d3f26e02e763cef537bd
mode 100644,000000..100644
--- /dev/null
@@@ -1,52 -1,0 +1,55 @@@
 +
 +#include "wifi_agent_idl.h"
 +//#include "wifi_agent_idl.h"
 +#include <frm_generic.h>
 +#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 "fwp_admctrl.h"
 +
++struct forb_wifi_agent_idl_impl wifi_agent_impl = {
++      .add = wifi_agent_idl_add, 
++};
 +
 +/**
 + *    Add information about AP (mac_address & bit rate)
 + */
 +CORBA_long wifi_agent_idl_add(wifi_agent_idl _obj, const CORBA_long rate, const CORBA_long_long client_mac_addr, CORBA_Environment *ev)
 +{
 +      struct fwp_sta *ed = forb_instance_data(_obj);
 +      fwp_sta_t *sta;
 +      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;
 +                      return 0;
 +              }
 +      }
 +      //client was not sending info yet
 +      new_to_add->rate = ed->rate;
 +      new_to_add->client_mac_addr = ed->client_mac_addr;
 +      
 +      sta_list_ins_tail(&priv.sta_list, new_to_add);
 +      
 +      return 0;
 +}
index 1692099f5dc2e6b9cfdf32938affe0cacda87cd9,cc45e922494ed1388cb772f2f368efd167381054..44ccb9149802e2ea09f31989ffc5df4c377db709
@@@ -1,20 -1,7 +1,12 @@@
+ #ifndef WIFI_AGENT_H
+ #define WIFI_AGENT_H
  
- #include <frm_generic.h>
- #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 "fwp_admctrl.h"
 +#include "wifi_agent_idl.h"
- CORBA_long wifi_agent_idl_add(wifi_agent_idl _obj, const CORBA_long rate, const CORBA_long_long client_mac_addr, CORBA_Environment *ev);
 +
+ #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 ;
++
+ #endif
 +
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..90e092ffec3667bac20ff66c1891317fe7080545
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,30 @@@
++<<<<<<< HEAD
++
++#include "wifi_agent_idl.h"
++#include <frm_generic.h>
++#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 "fwp_admctrl.h"
++
++CORBA_long wifi_agent_idl_add(wifi_agent_idl _obj, const CORBA_long rate, const CORBA_long_long client_mac_addr, CORBA_Environment *ev);
++
++=======
++#ifndef WIFI_AGENT_H
++#define WIFI_AGENT_H
++
++#define WAI_SERVER_ID (forb_server_id){ .uuid = { 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 } }
++#define WAI_TCP_PORT 24943
++
++#endif
++>>>>>>> origin/master