📄 westell.c
字号:
/* Westell 6100 multicast data collection utility * Copyright: Josh Carroll (josh.carroll@gmail.com) * 10/13/2004 * * Thanks to LSorensen, mith, rkeene, and bgr on EFNet * #Linux for the help with my rusty C skills, and thanks * to dmonnier, Yock, no_strings, freerock, hondje, * shenion, and shray on #ATU freenode. * * Also thanks to aedinius on #c on EFNet for helping clean the code * up. * * westell.c is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 2. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA **/#include "common.h"/* main program */int main(int argc, char *argv[]) { unsigned char *packet; int packet_size, gopt, decimal_print = 0; /* optional listen address */ char *listen_addr = NULL; /* pointer to the current model for writing the stats */ wmodel_t *pmodel; /* modem model information */ struct modemdata wdata; /* for the config file */ wconf_t conf; /* model number passed on the command line */ /* default to a value it will complain about to check * for a valid number */ int model = -1; /* first look to see if the person has a config file. if so, use any values specified there */ if(read_config(&conf) == 0) { model = conf.model; decimal_print = conf.decimal; listen_addr = conf.laddr; } /* requires the modem type */ if(argv[1] == NULL && model == -1) usage(argv[0]); /* use getopt to get command line arguments */ while((gopt = getopt(argc, argv, "m:dl:")) != EOF) { switch (gopt) { case 'm': model = atoi(optarg); break; case 'd': decimal_print = 1; break; case 'l': listen_addr = optarg; break; } } if(model == -1) usage(argv[0]); /* check for valid modem model number */ if(model < 0 || model > MAX_MODEL_NUMBER) { printf("Invalid model type!\n"); usage(argv[0]); } packet_size = models[model].packet_size; packet = malloc(packet_size); if(listen_for_mcast(model, packet, packet_size, listen_addr) == 0) { pmodel = &models[model]; wdata.timectr = getfield(packet, &pmodel->timectr); wdata.snr_up = getfield(packet, &pmodel->snr_up); wdata.pwr_up = getfield(packet, &pmodel->pwr_up); wdata.attn_up = getfield(packet, &pmodel->attn_up); wdata.syncrate_up = getfield(packet, &pmodel->syncrate_up); wdata.snr_down = getfield(packet, &pmodel->snr_down); wdata.pwr_down = getfield(packet, &pmodel->pwr_down); wdata.attn_down = getfield(packet, &pmodel->attn_down); wdata.syncrate_down = getfield(packet, &pmodel->syncrate_down); wdata.fec_errors = getfield(packet, &pmodel->fec_errors); wdata.crc_errors = getfield(packet, &pmodel->crc_errors); wdata.hec_errors = getfield(packet, &pmodel->hec_errors); wdata.signal_lost = getfield(packet, &pmodel->signal_lost); wdata.frame_lost = getfield(packet, &pmodel->frame_lost); wdata.tx_cells = getfield(packet, &pmodel->tx_cells); wdata.rx_cells = getfield(packet, &pmodel->rx_cells); wdata.dropped_cells = getfield(packet, &pmodel->dropped_cells); wdata.ethernet_rx = getfield(packet, &pmodel->ethernet_rx); wdata.ethernet_tx = getfield(packet, &pmodel->ethernet_tx); wdata.ethernet_discard = getfield(packet, &pmodel->ethernet_discard); /* free the memory in the packet buffer */ wfree(packet); /* now print the data collected */ print_data(wdata, decimal_print); } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -