ll_com.c
Go to the documentation of this file.
00001 /*------------------------------------------------------------------------
00002  *---------------------           RT-WMP              --------------------
00003  *------------------------------------------------------------------------
00004  *
00005  *
00006  *
00007  *  File: ./src/platforms/linux_ks/hwi/ath5k_raw/ll_com.c
00008  *  Authors: Rubén Durán
00009  *           Danilo Tardioli
00010  *  ----------------------------------------------------------------------
00011  *  Copyright (C) 2000-2011, Universidad de Zaragoza, SPAIN
00012  *
00013  *  Contact Addresses: Danilo Tardioli                   dantard@unizar.es
00014  *
00015  *  RT-WMP is free software; you can  redistribute it and/or  modify it
00016  *  under the terms of the GNU General Public License  as published by the
00017  *  Free Software Foundation;  either  version 2, or (at  your option) any
00018  *  later version.
00019  *
00020  *  RT-WMP  is distributed  in the  hope  that  it will be   useful, but
00021  *  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
00022  *  MERCHANTABILITY  or  FITNESS FOR A  PARTICULAR PURPOSE.    See the GNU
00023  *  General Public License for more details.
00024  *
00025  *  You should have received  a  copy of  the  GNU General Public  License
00026  *  distributed with RT-WMP;  see file COPYING.   If not,  write to the
00027  *  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
00028  *  02111-1307, USA.
00029  *
00030  *  As a  special exception, if you  link this  unit  with other  files to
00031  *  produce an   executable,   this unit  does  not  by  itself cause  the
00032  *  resulting executable to be covered by the  GNU General Public License.
00033  *  This exception does  not however invalidate  any other reasons why the
00034  *  executable file might be covered by the GNU Public License.
00035  *
00036  *----------------------------------------------------------------------*/
00037 
00038 #include "config/compiler.h"
00039 #include "core/include/definitions.h"
00040 #include "core/include/frames.h"
00041 
00042 #include "core/interface/wmp_interface.h"
00043 #include "core/include/wmp_misc.h"
00044 #include "core/include/ml_com.h"
00045 
00046 #include <linux/if.h>
00047 #include <linux/if_packet.h>
00048 #include <linux/if_ether.h>
00049 #include <linux/if_ether.h>
00050 
00051 #include <linux/netdevice.h>
00052 #include <linux/etherdevice.h>
00053 #include <net/mac80211.h>
00054 #include <net/ieee80211_radiotap.h>
00055 
00056 
00057 
00058 int ieee80211_rtwmp_init(char * dev_name);
00059 int ieee80211_rtwmp_timed_receive(char * buff, rxInfo * ret, int ms);
00060 void ieee80211_rtwmp_finish(void);
00061 int ieee80211_rtwmp_send(char * buff, int size);
00062 
00063 
00064 //static struct net_device *interfaz;
00065 static char devname[20];
00066 static char param[256], val[256];
00067 
00068 static short freq;
00069 static short rate;
00070 static unsigned char txpower_dbm;
00071 static int antenna_mode;
00072 
00073 int readllcfg(void) {
00074         struct file *f;
00075         char line[256];
00076         int exists;
00077 
00078         /* Set default values */
00079         freq = 2412;
00080         rate = 110;
00081         txpower_dbm = 20;
00082         antenna_mode = 1;
00083 
00084         f = filp_open("/etc/rt-wmp/linux_ks-mac80211_mod.ll", O_RDONLY, 0);
00085 
00086         if (!IS_ERR(f)) {
00087                 WMP_MSG(stderr, "Reading Low Level Configuration file (/etc/rt-wmp/linux_ks-mac80211_mod.ll)... \n");
00088                 while (fgets(line, 256, f) != NULL) {
00089                         if (line[0] < 65 || line[0] > 90) {
00090                                 continue;
00091                         }
00092                         sscanf(line, "%s %s", param, val);
00093                         exists = 0;
00094                         if (strcmp(param, "DEVICE") == 0) {
00095                                 strcpy(devname, val);
00096                                 exists = 1;
00097                         }
00098                         else if (strcmp(param, "FREQ") == 0) {
00099                                 freq = atoi(val);
00100                                 exists = 1;
00101                         } else if (strcmp(param, "RATE") == 0) {
00102                                 rate = atoi(val);
00103                                 exists = 1;
00104                         } else if (strcmp(param, "TXPOWER_DBM") == 0) {
00105                                 txpower_dbm = atoi(val);
00106                                 exists = 1;
00107                         }
00108                         if (exists) {
00109                                 WMP_MSG(stderr, "READ OPTION: %s = %s\n", param, val);
00110                         } else {
00111                                 WMP_MSG(stderr, "WARNING ::: UKNOWN OPTION %s\n", param);
00112                         }
00113                 }
00114                 WMP_MSG(stderr, "Done.\n");
00115                 filp_close(f, 0);
00116         } else{
00117                 WMP_MSG(stderr, "File /etc/rt-wmp/linux_ks-mac80211_mod.ll not found, using default values.\n");
00118         }
00119         return 0;
00120 }
00121 
00122 void closeLowLevelCom(void) {
00123         ieee80211_rtwmp_finish();
00124 }
00125 
00126 int configure_interface(struct net_device *dev) {
00127         return 1;
00128 }
00129 
00130 int initLowLevelCom(void) {
00131         char name[10];
00132 
00133         //XXX: To be implemented
00134         // ieee80211_rtwmp_configure_interface(freq, rate, txpower_dbm);
00135 
00136         sprintf(name,"%s","wlan");
00137         if (ieee80211_rtwmp_init(name)){
00138                 WMP_ERROR(stderr, "Low level com init ok.\n");
00139                 return 1;
00140         }else{
00141                 return 0;
00142         }
00143 }
00144 
00145 int llsend(char * f, int size) {
00146         return ieee80211_rtwmp_send(f, size);
00147 }
00148 
00149 rxInfo llreceive(char *f, int timeout) {
00150         rxInfo ret;
00151         memset(&ret, 0, sizeof(ret));
00152         if (ieee80211_rtwmp_timed_receive(f, &ret, timeout)) {
00153                 ret.rssi = 96 + ret.rssi;
00154                 ret.rssi = ret.rssi > 100 ? 100 : ret.rssi;
00155                 ret.rssi = ret.rssi > 0 ? ret.rssi  : 1;
00156         }
00157         return ret;
00158 }
00159 
00160 


ros_rt_wmp
Author(s): Danilo Tardioli, dantard@unizar.es
autogenerated on Fri Jan 3 2014 12:07:55