cross_space.h
Go to the documentation of this file.
00001 /*------------------------------------------------------------------------
00002  *---------------------           RT-WMP              --------------------
00003  *------------------------------------------------------------------------
00004  *                                                         
00005  *
00006  *
00007  *  File: ./src/platforms/linux_ks/wmpInit.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/global.h"
00040 
00041 #include <linux/module.h>
00042 #include <linux/kernel.h>
00043 #include <asm/uaccess.h>
00044 
00045 int wmpReadConfiguration(Status * status) {
00046         struct file *f;
00047         char param[30], val[20], line[256];
00048    int exists;
00049 
00050         f = filp_open("/etc/rt-wmp/rt-wmp.cfg", O_RDONLY, 0);
00051         if (IS_ERR(f)) {
00052                 printk(KERN_INFO "File /etc/rt-wmp/rt-wmp.cfg not found...\n");
00053       printk(KERN_INFO "Using default values (timeout: %d).\n", status->TIMEOUT);
00054                 return -1;
00055         }
00056    printk(KERN_INFO "Reading /etc/rt-wmp/rt-wmp.cfg...\n");
00057         while (fgets(line,256,f) != NULL) {
00058                 if (line[0]<65 || line[0]>90){
00059                         continue;
00060                 }
00061                 sscanf(line,"%s %s",param,val);
00062                 exists = 0;
00063                 if (strcmp(param, "WMP_ADDRESS") == 0) {
00064                         status->id = atoi(val);
00065                         exists = 1;
00066                 } else if (strcmp(param, "N_NODES") == 0) {
00067                         status->N_NODES = atoi(val);
00068                         exists = 1;
00069                 } else if (strcmp(param, "QUIET") == 0) {
00070                         status->quiet = atoi(val);
00071                         exists = 1;
00072                 } else if (strcmp(param, "MAX_RSSI") == 0) {
00073                         status->max_rssi = atoi(val);
00074                         exists = 1;
00075                 } else if (strcmp(param, "TIMEOUT") == 0) {
00076                         exists = 1;
00077                         status->TIMEOUT = atoi(val);
00078                 } else if (strcmp(param, "HOLD_TIME") == 0) {
00079                         status->hold_time = atoi(val);
00080                         exists = 1;
00081                 } else if (strcmp(param, "MAX_PER_NODE_RETRIES") == 0) {
00082                         status->maxPerNodeRetries = atoi(val);
00083                         exists = 1;
00084                 } else if (strcmp(param, "MAX_TOTAL_RETRIES") == 0) {
00085                         status->maxTotalRetries = atoi(val);
00086                         exists = 1;
00087                 } else if (strcmp(param, "PER_HOP_DELAY") == 0) {
00088                         status->perHopDelay = atoi(val);
00089                         exists = 1;
00090                 } else if (strcmp(param, "MOBILE_AVERAGE_ELEMENTS") == 0) {
00091                         status->mobile_average_elements = atoi(val);
00092                         exists = 1;
00093                 } else if (strcmp(param, "QUEUE_ELEMENTS") == 0) {
00094                         status->queue_elements = atoi(val);
00095                         exists = 1;
00096                 } else if (strcmp(param, "RSSI_RISING_FACTOR") == 0) {
00097                         status->rssi_rising_factor=atoi(val);
00098                         exists = 1;
00099                 } else if (strcmp(param, "NET_ID") == 0) {
00100                         status->net_id = atoi(val);
00101                         exists = 1;
00102                 } else if (strcmp(param, "ETT_MULT") == 0){
00103          ATOF(val, &(status->ett_mult));
00104                         exists = 1;
00105                 } else if (strcmp(param, "ETT_MAX") == 0){
00106          ATOF(val, &(status->ett_max));
00107                         exists = 1;
00108                 } else if (strcmp(param, "USE_ETT") == 0){
00109                         status->use_ett = atoi(val);
00110                         exists = 1;
00111                 }
00112 
00113                 if (exists) {
00114                         printk(KERN_INFO "READ OPTION: %s = %s\n", param, val);
00115                 } else {
00116                         printk(KERN_INFO "*** UKNOWN OPTION %s = %s\n", param, val);
00117                 }
00118         }
00119         printk(KERN_INFO "Done.\n");
00120    filp_close(f,0);
00121         return 1;
00122 }


ros_rt_wmp
Author(s): Danilo Tardioli, dantard@unizar.es
autogenerated on Mon Oct 6 2014 08:27:09