Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
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 }