1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
/*
Copyright (C) 1997,1998,1999 Dimitrios P. Bouras
This program 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; either version 2 of the License, or
(at your option) any later version.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
For author contact information, look in the README file.
*/
/* Constants relevant to the PTT data structures */
#define MAXNUM_PTT 33 /* known PPT's for call cost calculation */
#define MAXLEN_PTTNAME 32 /* characters reserved for PTT name */
#define MAXLEN_CURRENCY 16 /* max length of national currency name */
#define MAXNUM_ZONES 16 /* maximum number of price zones for a PTT */
#define MAXLEN_ZNAME 48 /* characters reserved for zone description */
#define MAXNUM_CATEGORY 64 /* maximum number of categories within each zone */
#define MAXVAL_MINUNITS 32 /* max value of minimum units */
#define MAXVAL_MINCOST 100000 /* max value of minimum cost */
#define MAXVAL_COSTQUANTUM 10000 /* max value of cost quantum */
#define MAXNUM_DECIMALS 3 /* max number of decimals for printouts */
#define MAXVAL_TARIFF 100000 /* maximum tariff value */
#define MAXSEC_MINCOSTLEN 3600 /* max seconds of minimum cost length */
#define MINVAL_RELDATE -300 /* relative date minimun value */
#define MAXVAL_RELDATE +300 /* relative date maximun value */
/* Identifiers for the known PTT's */
#define PTT_AT 0 /* Oesterreichische Telekom, Austria */
#define PTT_BE 1 /* BelgaCom, Belgium */
#define PTT_BT 2 /* British Telecom, United Kingdom */
#define PTT_CAMBRIDGE 3 /* Cambridge Cable Phone Company, Cambridge, UK */
#define PTT_CH 4 /* Swiss PTT */
#define PTT_CZ 5 /* SPT TELECOM, a.s., CZ */
#define PTT_DT 6 /* Deutsche Telekom A.G., Germany */
#define PTT_NETCOLOGNE 7 /* Netcologne GmbH, Germany */
#define PTT_ARCOR 8 /* Arcor Online, Germany */
#define PTT_BOL_EUR 9 /* Business Online AG (EUR), Germany */
#define PTT_BOL_DM 10 /* Business Online AG (DM), Germany */
#define PTT_ES 11 /* Telefnica de Espaa, Spain */
#define PTT_FT 12 /* France Telekom, France */
#define PTT_GR 13 /* OTE A.E., Hellas */
#define PTT_GR_EPAK 14 /* OTE A.E. (EAK), Hellas */
#define PTT_IT 15 /* Italian PTT */
#define PTT_MATAV 16 /* MATAV, Hungary */
#define PTT_NL 17 /* Dutch PTT, the Netherlands */
#define PTT_NTT 18 /* NTT, Japan */
#define PTT_PL 19 /* Telekom. Polska S.A., Poland */
#define PTT_PT 20 /* Portuguese PTT */
#define PTT_SAT 21 /* Telkom, South Africa */
#define PTT_SIT 22 /* Slovene Telekom */
#define PTT_TDK 23 /* TeleDanmark, Denmark */
#define PTT_CARNET 24 /* CARNet, Croatia */
#define PTT_HINET 25 /* HINET, Croatia */
#define PTT_ISKON 26 /* ISKON, Croatia */
#define PTT_IBMCR 27 /* IBM Net, Croatia */
#define PTT_HPY 28 /* HPY, Helsinki Telephone Corp. */
#define PTT_TELENOR 29 /* Telenor, Norway */
#define PTT_INETSERV 30 /* Inetservice, Germany */
#define PTT_KOMTEL 31 /* Komtel, Germany */
#define PTT_MOBILKOM 32 /* Mobilkom, Germany */
/* PTT attribute masks */
#define PTT_BY_UNIT 0x01
#define PTT_PER_MINUTE 0x02
#define PTT_PER_SECS 0x04
#define PTT_CUR_AFTER_COST 0x08
#define PTT_NONLINEAR_MIN 0x10
/* Rule types (possible 0-3F) and type flags */
#define RULE_DEFAULT 0
#define RULE_WEEKALL 1
#define RULE_WEEKDAY 2
#define RULE_SATURDAY 3
#define RULE_SUNDAY 4
#define RULE_WEEKEND 5
#define RULE_RHOLIDAY 6
#define RULE_AHOLIDAY 7
#define RULE_SPECIAL_WEEKDAY 8
#define RULE_SPECIAL_WEEKEND 9
#define DISCOUNT_PERMITTED 0x40
#define DEFEAT_MIN_TIME_LEN 0x80
/* The PTT information data structures */
typedef struct ruledate_struct {
unsigned char mon; /* month field */
unsigned char day; /* day field */
} ruledate_t;
typedef struct ruletime_struct {
unsigned char h; /* hour field */
unsigned char m; /* minute field */
unsigned char s; /* second field */
} ruletime_t;
typedef struct rule_struct {
unsigned char type; /* rule type */
ruledate_t adate; /* absolute or starting date */
ruledate_t edate; /* end date for date ranges */
int rdate; /* date relative to Easter Sunday */
ruletime_t start; /* rule start time */
ruletime_t end; /* rule end time */
float tariff; /* rule tariff */
} rule_t;
typedef struct discount_struct {
float percent; /* discount percentage */
ruletime_t start; /* discount exclusion interval */
ruletime_t end; /* start and end times */
} discount_t;
typedef struct ptt_struct {
char name[MAXLEN_PTTNAME+1]; /* the PTT name string */
unsigned char num_zones; /* # of charging zones */
unsigned char current_zone; /* currently selected zone */
unsigned char num_categories; /* # of tariff rules/zone */
unsigned int attribs; /* PTT attributes */
unsigned char min_units; /* minimum units charged */
float min_cost; /* minimum cost charged */
unsigned char charge_period; /* time charging period */
float cost_quantum; /* sec/unit or cost/minute */
char currency[MAXLEN_CURRENCY+1]; /* local currency string */
unsigned char decimals; /* decimals for printouts */
float dflt_tariff[MAXNUM_ZONES]; /* zone default tariffs */
unsigned int min_cost_len[MAXNUM_ZONES]; /* min-cost length in sec */
char zone_name[MAXNUM_ZONES][MAXLEN_ZNAME+1]; /* zone names */
discount_t discount[MAXNUM_ZONES]; /* special zone discount */
rule_t rule[MAXNUM_ZONES][MAXNUM_CATEGORY]; /* zone tariff rules */
} ptt_t;
#define PTT_DEFAULT {{0}, 0, 0, 0, PTT_BY_UNIT, 0, 0.0, 60, 0.0, \
{0}, 0, {0.0}, {0}, {{0}}, {{0.0,{0,0,0},{24,0,0}}}, \
{{{RULE_WEEKALL,{0,1},{11,31},0,{0,0,0},{24,0,0},0.0}}}}
typedef struct xispPTTs_struct {
} xispPTTs_t;
/* Module interface routines */
int initLogFnames(glob_t *global);
void logs_init(glob_t *global, char *logdirname,
char *costfname, char *logfname, char *pttfname);
void costCalcReset(ptt_t *ptt, time_t upTime);
float callCost(ptt_t* ptt, unsigned long onLineSecs,
unsigned long *onLineUnits);
void readXispCost(unsigned long *totalTime, unsigned long *totalUnits);
#define restartXispCost(a,b) readXispCost(a,b)
void writeXispCost(unsigned long totalTime, unsigned long totalUnits);
void writeXispLog(int up, ptt_t *ptt, char *ts, char *ISPn, char *IPs,
char *speed, unsigned long onLineSecs, float onLineCost,
unsigned long pTXed, unsigned long pRXed);
int buildStats(glob_t *global, unsigned int *current,
unsigned long *tblTime, unsigned long *tblUnits);
void initXispPTT(ptt_t *);
void readXispPTTs(ptt_t **pttdataptr, glob_t *global);
void writeXispPTTs(ptt_t *pttdata, glob_t *global);
|