1 /* Westell 6100 multicast data collection utility. 2 * Shared code for wstart and wstop. 3 * 4 * Copyright: Josh Carroll (josh.carroll@gmail.com) 5 * 10/13/2004 6 * 7 * wtypes.h is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, version 2. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * 20 */ 21 22 /* defines common to wstop and wstart */ 23 /* make sure MAX_MODEL_NUMBER is updated when adding 24 * struct members to the wstart and/or wstop code. 25 * This implicitly requires that this value be the 26 * highest order index in EITHER wstop or wstart 27 * to work properly */ 28 #define MAX_MODEL_NUMBER 4 29 #define MAX_PACKET_SIZE 10 30 #define MAX_PACKET_COUNT 10 31 #define MAX_MCAST_COUNT 10 32 #define IGMP_PKT_SIZE (sizeof(struct ip) + sizeof(struct igmp)) 33 /* free macro to ensure we free only when a pointer is not NULL */ 34 #define wfree(ptr) if(ptr) { free(ptr); ptr = NULL; } 35 #define W_NO_DATA "n/a" 36 /* timeout after 3 seconds waiting for a poll from the modem */ 37 #define POLL_TIMEOUT 3 38 /* free macro to ensure we free only when a pointer is not NULL */ 39 #define wfree(ptr) if(ptr) { free(ptr); ptr = NULL; } 40 41 /* this enum holds the fields for the westell data and their decimal factors 42 -1 indicates no factoring */ 43 enum fields { TIMECTR = -1, SNR_UP = 10, PWR_UP = 10, ATTN_UP = 10, SYNCRATE_UP = -1, 44 SNR_DOWN = 10, PWR_DOWN = 10, ATTN_DOWN = 10, SYNCRATE_DOWN = -1, 45 FEC_ERRORS = -1, CRC_ERRORS = -1, HEC_ERRORS = -1, SIGNAL_LOST = -1, 46 FRAME_LOST = -1, TX_CELLS = -1, RX_CELLS = -1, DROPPED_CELLS = -1, 47 ETHERNET_RX = -1, ETHERNET_TX = -1, ETHERNET_DISCARD = -1 }; 48 49 typedef struct field { 50 int8_t offset; /* offset for this piece of data */ 51 int8_t size; /* size in bytes for this piece of data */ 52 } field_t; 53 54 /* this stores the offsets and sizes of a modem type */ 55 typedef struct model { 56 char model_number[10]; 57 field_t timectr; 58 field_t snr_up; 59 field_t pwr_up; 60 field_t attn_up; 61 field_t syncrate_up; 62 field_t snr_down; 63 field_t pwr_down; 64 field_t attn_down; 65 field_t syncrate_down; 66 field_t fec_errors; 67 field_t crc_errors; 68 field_t hec_errors; 69 field_t signal_lost; 70 field_t frame_lost; 71 field_t tx_cells; 72 field_t rx_cells; 73 field_t dropped_cells; 74 field_t ethernet_rx; 75 field_t ethernet_tx; 76 field_t ethernet_discard; 77 int server_port; 78 int packet_size; 79 char mcast_group [16]; 80 } wmodel_t; 81 82 /* this holds the actual information from the modem. 83 * we use a 32-bit size here, which is the greatest common 84 * size of the data. If in the future we need a 64-bit value 85 * in the data, we would have to change this accordingly */ 86 struct modemdata { 87 int32_t timectr; 88 int32_t snr_up; 89 int32_t pwr_up; 90 int32_t attn_up; 91 int32_t syncrate_up; 92 int32_t snr_down; 93 int32_t pwr_down; 94 int32_t attn_down; 95 int32_t syncrate_down; 96 int32_t fec_errors; 97 int32_t crc_errors; 98 int32_t hec_errors; 99 int32_t signal_lost; 100 int32_t frame_lost; 101 int32_t tx_cells; 102 int32_t rx_cells; 103 int32_t dropped_cells; 104 int32_t ethernet_rx; 105 int32_t ethernet_tx; 106 int32_t ethernet_discard; 107 }; 108 109 /* data structures common to wstop and wstart */ 110 typedef struct westell_packet { 111 unsigned short int src_port; 112 unsigned short int dst_port; 113 /* pad this will null values if we don't use up all the array */ 114 unsigned short int packet_length; 115 uint8_t data[MAX_PACKET_SIZE]; 116 } wpacket_t; 117 118 typedef struct westell_igmp_packet { 119 char mcast_dest[16]; 120 char mcast_group[16]; 121 } wmcast_t; 122 123 /* this stores the offsets and sizes of a modem type */ 124 typedef struct westell_model { 125 char model_number[10]; 126 unsigned short int num_packets; 127 wpacket_t packets[MAX_PACKET_COUNT]; 128 unsigned short int num_mcasts; 129 wmcast_t multicasts[MAX_MCAST_COUNT]; 130 char broadcast_ip[16]; 131 } pmodel_t; 132 133 /* this holds an array of model structs that 134 * defines the offsets and sizes for each modem type we know about 135 * It is currently setup for the 610010 and 610030 (which are the same, 136 * this is just for vebosity. Adding another modem should be trivial. 137 * All offstes and sizes are in bytes. If a field is not sent or 138 * is not included in a modem, set the offset and size to -1 139 */ 140 extern wmodel_t models[]; 141 142 143