📄 histogram.c
字号:
/* $Id: histogram.c,v 1.3 2000/04/06 07:26:52 jm Exp $ * Dynamics signal quality history management module * * Dynamic hierarchial IP tunnel * Copyright (C) 1998-2000, Dynamics group * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. See README and COPYING for * more details. */#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"#define USAGE "histogram -d <device> {-s|-g}"#define DEBUG_FLAG '6'#define SETHIS 1#define GETHIS 2#ifndef IFNAMSIZ#define IFNAMSIZ 16#endifextern int opt_debug;int sock;char ifname[IFNAMSIZ];static struct option const long_options[] ={ {"device", required_argument, NULL, 'd'}, {"get-history", 0, NULL, 'g'}, {"set-history", 0, NULL, 's'}, {0, 0, 0, 0}};void clean_up(int dummy){ close(sock);}static int init_sockets(void){ __u32 filter = 0; filter = ICMP_FILTER_MN; sock = dyn_wireless_create_socket(); if (sock < 0) return 1; return 0;}int main(int argc, char **argv){ int ret = -1, c, oindex, command = -1, i, count = -1;#define RANGE_VALUES 16 long history[RANGE_VALUES]; char range[16]; memset(history, 0, sizeof(history)); memset(range, 0, sizeof(range)); opt_debug = 1; /* parse arguments */ while ((c = getopt_long(argc, argv, "d:sgc:", long_options, &oindex)) != EOF) { switch (c) { case 's': /* set history */ DEBUG(DEBUG_FLAG, "option s (Set)\n"); if (command == GETHIS) { printf("Only one command at the time!\n"); exit(1); } command = SETHIS; break; case 'g': /* get history */ DEBUG(DEBUG_FLAG, "option g (Get)\n"); if (command == SETHIS) { printf("Only one command at the time!\n"); exit(1); } command = GETHIS; break; case 'd': /* device */ DEBUG(DEBUG_FLAG, "option d (Device) with value" " '%s'\n", optarg); ret = dyn_wireless_get_ifname(optarg, ifname); break; default: printf(USAGE); return 1; } } count = argc - optind; for (i = 0; optind < argc; optind++, i++) { DEBUG(DEBUG_FLAG, "%d\n", (char)atoi(argv[optind])); if (i >= 16) { fprintf(stderr, "Only 16 first numbers are " "accepted for the range parameters\n"); exit(1); } range[i] = (char)atoi(argv[optind]); } /* interface given? */ if (ret < 0) { fprintf(stderr, "No device argument!\n"); printf(USAGE); return 1; } /* open sockets */ if (init_sockets()) { fprintf(stderr, "Open socket(s) failed\n"); return 3; } if (command == GETHIS) { ret = dyn_wireless_his_get(sock, ifname, (char *)history); for (i = 0; i < RANGE_VALUES; i++) printf("%ld\n", history[i]); } if (command == SETHIS) { DEBUG(DEBUG_FLAG, "==\n%d intervals [0..92]\n", count); if (count < 0) { fprintf(stderr, "You have to give ranges.\n"); clean_up(1); } ret = dyn_wireless_his_set(sock, ifname, range, sizeof(range)); } if (ret != 0) { printf("return value != 0\n"); } clean_up(0); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -