histogram.c File Reference

#include <stdlib.h>
#include <signal.h>
#include <getopt.h>
#include <unistd.h>
#include <string.h>
#include <asm/types.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include "owntypes.h"
#include <linux/filter.h>
#include <linux/wireless.h>
#include "debug.h"
#include "dyn_wireless.h"
#include "agentadv.h"

Include dependency graph for histogram.c:

Go to the source code of this file.

Defines

#define USAGE   "histogram -d <device> {-s|-g}"
#define DEBUG_FLAG   '6'
#define SETHIS   1
#define GETHIS   2
#define IFNAMSIZ   16
#define RANGE_VALUES   16

Functions

void clean_up (int dummy)
int main (int argc, char **argv)

Variables

int opt_debug
int sock
char ifname [IFNAMSIZ]


Define Documentation

#define DEBUG_FLAG   '6'

Definition at line 31 of file histogram.c.

#define GETHIS   2

Definition at line 33 of file histogram.c.

Referenced by main().

#define IFNAMSIZ   16

Definition at line 36 of file histogram.c.

Referenced by dyn_wireless_check_simulator(), dyn_wireless_get_ap_address(), dyn_wireless_get_channel(), dyn_wireless_get_ifname(), dyn_wireless_get_name(), dyn_wireless_get_range(), dyn_wireless_get_simulator(), dyn_wireless_his_get(), dyn_wireless_his_set(), dyn_wireless_iwspy_get(), dyn_wireless_iwspy_set(), dyn_wireless_set_channel(), dyn_wireless_set_simulator(), handle_api(), is_coloc_addr_foreign(), main(), mn_init(), monitor_api_get_ch(), monitor_get_dev(), send_gratuitous_arp(), stop_tunneling(), and update_fa_decaps_routes().

#define RANGE_VALUES   16

Referenced by main().

#define SETHIS   1

Definition at line 32 of file histogram.c.

Referenced by main().

#define USAGE   "histogram -d <device> {-s|-g}"

Definition at line 30 of file histogram.c.

Referenced by main(), and parse_pairs().


Function Documentation

void clean_up ( int  dummy  ) 

Definition at line 52 of file histogram.c.

Referenced by clean_up(), main(), and mn_init().

00053 {
00054         close(sock);
00055 }

int main ( int  argc,
char **  argv 
)

Definition at line 71 of file histogram.c.

References clean_up(), DEBUG(), DEBUG_FLAG, dyn_wireless_get_ifname(), dyn_wireless_his_get(), dyn_wireless_his_set(), GETHIS, ifname, opt_debug, optarg, optind, RANGE_VALUES, SETHIS, sock, and USAGE.

00072 {
00073         int ret = -1, c, oindex, command = -1, i, count = -1;
00074 #define RANGE_VALUES 16
00075         long history[RANGE_VALUES];
00076         char range[16];
00077         
00078         memset(history, 0, sizeof(history));
00079         memset(range, 0, sizeof(range));
00080         opt_debug = 1;
00081           
00082         /* parse arguments */
00083         while ((c = getopt_long(argc, argv, "d:sgc:", long_options, 
00084                                 &oindex)) != EOF) {
00085                 switch (c) {
00086                 case 's': /* set history */
00087                         DEBUG(DEBUG_FLAG, "option s (Set)\n");
00088                         if (command == GETHIS) {
00089                                 printf("Only one command at the time!\n");
00090                                 exit(1);
00091                         }
00092                         command = SETHIS;
00093                         break;
00094                 case 'g': /* get history */
00095                         DEBUG(DEBUG_FLAG, "option g (Get)\n");
00096                         if (command == SETHIS) {
00097                                 printf("Only one command at the time!\n");
00098                                 exit(1);
00099                         }
00100                         command = GETHIS;
00101                         break; 
00102                 case 'd': /* device */
00103                         DEBUG(DEBUG_FLAG, "option d (Device) with value"
00104                               " '%s'\n", optarg);
00105                         ret = dyn_wireless_get_ifname(optarg, ifname);
00106                         break;
00107                 default:
00108                         printf(USAGE);
00109                         return 1;
00110                 }
00111         }
00112 
00113         count = argc - optind;
00114         for (i = 0; optind < argc; optind++, i++) {
00115                 DEBUG(DEBUG_FLAG, "%d\n", (char)atoi(argv[optind]));
00116                 if (i >= 16) {
00117                         fprintf(stderr, "Only 16 first numbers are "
00118                                 "accepted for the range parameters\n");
00119                         exit(1);
00120                 }
00121                 range[i] = (char)atoi(argv[optind]);
00122         }
00123 
00124         /* interface given? */
00125         if (ret < 0) {
00126                 fprintf(stderr, "No device argument!\n");
00127                 printf(USAGE);
00128                 return 1;
00129         } 
00130 
00131         /* open sockets */
00132         if (init_sockets()) {
00133                 fprintf(stderr, "Open socket(s) failed\n");
00134                 return 3;
00135         }
00136 
00137         if (command == GETHIS) {
00138                 ret = dyn_wireless_his_get(sock, ifname, (char *)history);
00139                 for (i = 0; i < RANGE_VALUES; i++)
00140                         printf("%ld\n", history[i]);
00141         }
00142 
00143         if (command == SETHIS) {
00144                 DEBUG(DEBUG_FLAG, "==\n%d intervals [0..92]\n", count);
00145                 if (count < 0) {
00146                         fprintf(stderr, "You have to give ranges.\n");
00147                         clean_up(1);
00148                 }
00149                 ret = dyn_wireless_his_set(sock, ifname, range, sizeof(range));
00150         }
00151 
00152         if (ret != 0) {
00153                 printf("return value != 0\n");
00154         }
00155 
00156         clean_up(0);
00157         return 0;
00158 }

Here is the call graph for this function:


Variable Documentation

char ifname[IFNAMSIZ]

Definition at line 41 of file histogram.c.

Referenced by main(), and monitor_api_get_ch().

int opt_debug

Referenced by main().

int sock

Definition at line 40 of file histogram.c.

Referenced by clean_up(), dyn_wireless_create_socket(), main(), monitor_api_get_ch(), monitor_api_set_ch(), monitor_poll_ap_addresses(), and MONITOR_unregister_module().


Generated on Tue Jan 15 08:50:46 2008 for Virtual foreign agent generator version 0.1 by  doxygen 1.5.1