9
0
Fork 0

Charging option

This commit is contained in:
jjako 2004-05-27 20:06:36 +00:00
parent b62c3dd3c4
commit 7e051d37bb
5 changed files with 59 additions and 12 deletions

View File

@ -19,7 +19,7 @@
.\" IP indented paragraph
.\" TP hanging label
.TH sgsnemu 8 "July 2003"
.TH sgsnemu 8 "May 2004"
.SH NAME
sgsnemu \- Serving GPRS Support Node Emulator
.SH SYNOPSIS
@ -61,6 +61,8 @@ sgsnemu \- Serving GPRS Support Node Emulator
] [
.BI \-\-qos " qos"
] [
.BI \-\-charging " charging"
] [
.BI \-\-uid " uid"
] [
.BI \-\-pwd " pwd"
@ -241,6 +243,13 @@ to use when connecting to the GGSN (default = 0x0b921f). QoS is an
abbreviation of Quality of Service. See 3GPP specification 09.60 for
the format of this string.
.TP
.BI --charging " charging"
Charging characteristics to use when connecting to the GGSN (default =
0x0800). 0x0800 = Normal, 0x0400 = Prepaid, 0x0200 = Flat rate, 0x0100
= Hot billing. See 3GPP specification 32.015 for the format of this
field.
.TP
.BI --uid " uid"
User ID to send to GGSN as protocol configuration option.
@ -368,7 +377,7 @@ can be found at
.SH COPYRIGHT
Copyright (C) 2002, 2003 by Mondru AB.
Copyright (C) 2002, 2003, 2004 by Mondru AB.
The contents of this file may be used under the terms of the GNU
General Public License Version 2, provided that the above copyright

View File

@ -1,7 +1,7 @@
/*
File autogenerated by gengetopt version 2.8
generated with the following command:
gengetopt --conf-parser
/mnt/hda5/bin/gengetopt --conf-parser
The developers of gengetopt consider the fixed text that goes in all
gengetopt output files to be in the public domain:
@ -56,9 +56,10 @@ cmdline_parser_print_help (void)
printf(" --gtpversion=INT GTP version to use (default='1')\n");
printf(" -aSTRING --apn=STRING Access point name (default='internet')\n");
printf(" -iSTRING --imsi=STRING IMSI (default='240010123456789')\n");
printf(" --nsapi=INT NSAPI (default='1')\n");
printf(" --nsapi=INT NSAPI (default='0')\n");
printf(" -mSTRING --msisdn=STRING Mobile Station ISDN number (default='46702123456')\n");
printf(" -qINT --qos=INT Requested quality of service (default='0x0b921f')\n");
printf(" --charging=INT Charging characteristics (default='0x0800')\n");
printf(" -uSTRING --uid=STRING Login user ID (default='mig')\n");
printf(" -pSTRING --pwd=STRING Login password (default='hemmelig')\n");
printf(" --createif Create local network interface (default=off)\n");
@ -111,6 +112,7 @@ cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_i
args_info->nsapi_given = 0 ;
args_info->msisdn_given = 0 ;
args_info->qos_given = 0 ;
args_info->charging_given = 0 ;
args_info->uid_given = 0 ;
args_info->pwd_given = 0 ;
args_info->createif_given = 0 ;
@ -136,9 +138,10 @@ cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_i
args_info->gtpversion_arg = 1 ;\
args_info->apn_arg = strdup("internet") ;\
args_info->imsi_arg = strdup("240010123456789") ;\
args_info->nsapi_arg = 1 ;\
args_info->nsapi_arg = 0 ;\
args_info->msisdn_arg = strdup("46702123456") ;\
args_info->qos_arg = 0x0b921f ;\
args_info->charging_arg = 0x0800 ;\
args_info->uid_arg = strdup("mig") ;\
args_info->pwd_arg = strdup("hemmelig") ;\
args_info->createif_flag = 0;\
@ -182,6 +185,7 @@ cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_i
{ "nsapi", 1, NULL, 0 },
{ "msisdn", 1, NULL, 'm' },
{ "qos", 1, NULL, 'q' },
{ "charging", 1, NULL, 0 },
{ "uid", 1, NULL, 'u' },
{ "pwd", 1, NULL, 'p' },
{ "createif", 0, NULL, 0 },
@ -427,6 +431,19 @@ cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_i
args_info->nsapi_arg = strtol (optarg,&stop_char,0);
break;
}
/* Charging characteristics. */
else if (strcmp (long_options[option_index].name, "charging") == 0)
{
if (args_info->charging_given)
{
fprintf (stderr, "%s: `--charging' option given more than once\n", PACKAGE);
clear_args ();
exit (EXIT_FAILURE);
}
args_info->charging_given = 1;
args_info->charging_arg = strtol (optarg,&stop_char,0);
break;
}
/* Create local network interface. */
else if (strcmp (long_options[option_index].name, "createif") == 0)
{
@ -850,6 +867,22 @@ cmdline_parser_configfile (char * const filename, struct gengetopt_args_info *ar
}
continue;
}
if (!strcmp(fopt, "charging"))
{
if (override || !args_info->charging_given)
{
args_info->charging_given = 1;
if (fnum == 2)
args_info->charging_arg = strtol (farg,&stop_char,0);
else
{
fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
filename, line_num);
exit (EXIT_FAILURE);
}
}
continue;
}
if (!strcmp(fopt, "uid"))
{
if (override || !args_info->uid_given)

View File

@ -34,6 +34,7 @@ option "imsi" i "IMSI" string default="240010
option "nsapi" - "NSAPI" int default="0" no
option "msisdn" m "Mobile Station ISDN number" string default="46702123456" no
option "qos" q "Requested quality of service" int default="0x0b921f" no
option "charging" - "Charging characteristics" int default="0x0800" no
option "uid" u "Login user ID" string default="mig" no
option "pwd" p "Login password" string default="hemmelig" no

View File

@ -32,9 +32,10 @@ struct gengetopt_args_info
int gtpversion_arg; /* GTP version to use (default='1'). */
char * apn_arg; /* Access point name (default='internet'). */
char * imsi_arg; /* IMSI (default='240010123456789'). */
int nsapi_arg; /* NSAPI (default='1'). */
int nsapi_arg; /* NSAPI (default='0'). */
char * msisdn_arg; /* Mobile Station ISDN number (default='46702123456'). */
int qos_arg; /* Requested quality of service (default='0x0b921f'). */
int charging_arg; /* Charging characteristics (default='0x0800'). */
char * uid_arg; /* Login user ID (default='mig'). */
char * pwd_arg; /* Login password (default='hemmelig'). */
int createif_flag; /* Create local network interface (default=off). */
@ -65,6 +66,7 @@ struct gengetopt_args_info
int nsapi_given ; /* Whether nsapi was given. */
int msisdn_given ; /* Whether msisdn was given. */
int qos_given ; /* Whether qos was given. */
int charging_given ; /* Whether charging was given. */
int uid_given ; /* Whether uid was given. */
int pwd_given ; /* Whether pwd was given. */
int createif_given ; /* Whether createif was given. */

View File

@ -106,6 +106,7 @@ struct {
int gtpversion;
struct ul255_t pco;
struct ul255_t qos;
uint16_t cch;
struct ul255_t apn;
struct ul16_t msisdn;
} options;
@ -224,6 +225,7 @@ int process_options(int argc, char **argv) {
printf("debug: %d\n", args_info.debug_flag);
if (args_info.imsi_arg) printf("imsi: %s\n", args_info.imsi_arg);
printf("qos: %#08x\n", args_info.qos_arg);
printf("charging: %#04x\n", args_info.charging_arg);
if (args_info.apn_arg) printf("apn: %s\n", args_info.apn_arg);
if (args_info.msisdn_arg) printf("msisdn: %s\n", args_info.msisdn_arg);
if (args_info.uid_arg) printf("uid: %s\n", args_info.uid_arg);
@ -257,6 +259,7 @@ int process_options(int argc, char **argv) {
printf("debug: %d\n", args_info.debug_flag);
if (args_info.imsi_arg) printf("imsi: %s\n", args_info.imsi_arg);
printf("qos: %#08x\n", args_info.qos_arg);
printf("charging: %#04x\n", args_info.charging_arg);
if (args_info.apn_arg) printf("apn: %s\n", args_info.apn_arg);
if (args_info.msisdn_arg) printf("msisdn: %s\n", args_info.msisdn_arg);
if (args_info.uid_arg) printf("uid: %s\n", args_info.uid_arg);
@ -411,6 +414,9 @@ int process_options(int argc, char **argv) {
options.qos.v[2] = (args_info.qos_arg) & 0xff;
options.qos.v[1] = ((args_info.qos_arg) >> 8) & 0xff;
options.qos.v[0] = ((args_info.qos_arg) >> 16) & 0xff;
/* charging */
options.cch = args_info.charging_arg;
/* contexts */
if (args_info.contexts_arg > MAXCONTEXTS) {
@ -1168,12 +1174,8 @@ int main(int argc, char **argv)
pdp->hisaddr0 = options.remote;
pdp->hisaddr1 = options.remote;
/* TODO: This could be an option */
pdp->cch_pdp = 2048; /* Normal charging 3GPP 32.015 */
/* 2048 = Normal
1024 = Prepaid
0512 = Flat rate
0256 = Hot billing */
pdp->cch_pdp = options.cch; /* 2048 = Normal, 1024 = Prepaid,
512 = Flat rate, 256 = Hot billing */
/* Create context */
/* We send this of once. Retransmissions are handled by gtplib */