Skip to content

Commit

Permalink
Add support for GTP IE's from 3GPP R7
Browse files Browse the repository at this point in the history
This adds support for the followng new GTP Information Elements:
	RAT_TYPE, USER_LOC, MS_TZ, IMEI_SV

Furthermore, it allows to specify those fields as sgsnemu command line
arguments.
  • Loading branch information
ybonnamy authored and laf0rge committed Oct 29, 2010
1 parent 87490d7 commit 944dce3
Show file tree
Hide file tree
Showing 7 changed files with 327 additions and 0 deletions.
17 changes: 17 additions & 0 deletions gtp/gtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,23 @@ extern int gtp_create_context_req(struct gsn_t *gsn, struct pdp_t *pdp,
gtpie_tlv(&packet, &length, GTP_MAX, GTPIE_OMC_ID,
pdp->omcid.l, pdp->omcid.v);

/* new R7 fields */
if (pdp->rattype_given == 1)
gtpie_tlv(&packet, &length, GTP_MAX, GTPIE_RAT_TYPE,
pdp->rattype.l, pdp->rattype.v);

if (pdp->userloc_given == 1)
gtpie_tlv(&packet, &length, GTP_MAX, GTPIE_USER_LOC,
pdp->userloc.l, pdp->userloc.v);

if (pdp->mstz_given == 1)
gtpie_tlv(&packet, &length, GTP_MAX, GTPIE_MS_TZ,
pdp->mstz.l, pdp->mstz.v);

if (pdp->imeisv_given == 1)
gtpie_tlv(&packet, &length, GTP_MAX, GTPIE_IMEI_SV,
pdp->imeisv.l, pdp->imeisv.v);

/* TODO hisaddr0 */
gtp_req(gsn, pdp->version, pdp, &packet, length, &pdp->hisaddr0, cbp);

Expand Down
4 changes: 4 additions & 0 deletions gtp/gtpie.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@ int gtpie_decaps(union gtpie_member* ie[], int version, void *pack, unsigned len
case GTPIE_TRIGGER_ID:
case GTPIE_OMC_ID:
case GTPIE_CHARGING_ADDR:
case GTPIE_RAT_TYPE:
case GTPIE_USER_LOC:
case GTPIE_MS_TZ:
case GTPIE_IMEI_SV:
case GTPIE_PRIVATE:
if (j<GTPIE_SIZE) {
ie[j] = (union gtpie_member*) p;
Expand Down
4 changes: 4 additions & 0 deletions gtp/gtpie.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ hton64(uint64_t q)
#define GTPIE_EXT_HEADER_T 141 /* Extension Header Type List */
#define GTPIE_TRIGGER_ID 142 /* Trigger Id */
#define GTPIE_OMC_ID 143 /* OMC Identity */
#define GTPIE_RAT_TYPE 151 /* Radio Access Technology Type */
#define GTPIE_USER_LOC 152 /* User Location Information */
#define GTPIE_MS_TZ 153 /* MS Time Zone */
#define GTPIE_IMEI_SV 154 /* IMEI Software Version */
/* 239-250 Reserved for the GPRS charging protocol (see GTP' in GSM 12.15) */
#define GTPIE_CHARGING_ADDR 251 /* Charging Gateway Address */
/* 252-254 Reserved for the GPRS charging protocol (see GTP' in GSM 12.15) */
Expand Down
8 changes: 8 additions & 0 deletions gtp/pdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,14 @@ struct pdp_t {
struct ul255_t pco_req; /* Requested packet control options. */
struct ul255_t pco_neg; /* Negotiated packet control options. */
uint32_t selmode; /* Selection mode. */
struct ul255_t rattype; /* Radio Access Technology Type */
int rattype_given; /* Radio Access Technology Type given*/
struct ul255_t userloc; /* User Location Information */
int userloc_given; /* User Location Information given*/
struct ul255_t mstz; /* MS Time Zone */
int mstz_given; /* MS Time Zone given*/
struct ul255_t imeisv; /* IMEI Software Version */
int imeisv_given; /* IMEI Software Version given*/

/* Additional parameters used by library */

Expand Down
69 changes: 69 additions & 0 deletions sgsnemu/cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ const char *gengetopt_args_info_help[] = {
" --gtpversion=INT GTP version to use (default=`1')",
" -a, --apn=STRING Access point name (default=`internet')",
" --selmode=INT Selection mode (default=`0x01')",
" --rattype=INT Radio Access Technology Type (optional-1to5)",
" --userloc=STRING User Location Information (optional-type.MCC.MNC.LAC.CIorSACorRAC)",
" --mstz=STRING MS Time Zone (optional- sign.NbQuartersOfAnHour.DSTAdjustment)",
" --imeisv=STRING IMEI(SV) International Mobile Equipment Identity (and Software Version) (optional,16 digits)",
" -i, --imsi=STRING IMSI (default=`240010123456789')",
" --nsapi=INT NSAPI (default=`0')",
" -m, --msisdn=STRING Mobile Station ISDN number (default=`46702123456')",
Expand Down Expand Up @@ -113,6 +117,10 @@ void clear_given (struct gengetopt_args_info *args_info)
args_info->gtpversion_given = 0 ;
args_info->apn_given = 0 ;
args_info->selmode_given = 0 ;
args_info->rattype_given = 0 ;
args_info->userloc_given = 0 ;
args_info->mstz_given = 0 ;
args_info->imeisv_given = 0 ;
args_info->imsi_given = 0 ;
args_info->nsapi_given = 0 ;
args_info->msisdn_given = 0 ;
Expand Down Expand Up @@ -158,6 +166,14 @@ void clear_args (struct gengetopt_args_info *args_info)
args_info->apn_orig = NULL;
args_info->selmode_arg = 0x01;
args_info->selmode_orig = NULL;
args_info->rattype_arg = "1";
args_info->rattype_orig = NULL;
args_info->userloc_arg = strdup("02509946241207");
args_info->userloc_orig = NULL;
args_info->mstz_arg = strdup("0");
args_info->mstz_orig = NULL;
args_info->imeisv_arg = strdup("2143658709214365");
args_info->imeisv_orig = NULL;
args_info->imsi_arg = gengetopt_strdup ("240010123456789");
args_info->imsi_orig = NULL;
args_info->nsapi_arg = 0;
Expand Down Expand Up @@ -768,6 +784,10 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf
{ "gtpversion", 1, NULL, 0 },
{ "apn", 1, NULL, 'a' },
{ "selmode", 1, NULL, 0 },
{ "rattype", 1, NULL, 0},
{ "userloc", 1, NULL, 0},
{ "mstz", 1, NULL, 0},
{ "imeisv", 1, NULL, 0},
{ "imsi", 1, NULL, 'i' },
{ "nsapi", 1, NULL, 0 },
{ "msisdn", 1, NULL, 'm' },
Expand Down Expand Up @@ -1143,6 +1163,55 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf
free (args_info->selmode_orig); /* free previous string */
args_info->selmode_orig = gengetopt_strdup (optarg);
}
/* Radio Access Technology Type. */
else if (strcmp (long_options[option_index].name, "rattype") == 0)
{
if (args_info->rattype_given)
{
fprintf (stderr, "%s: `--rattype' option given more than once\n", PACKAGE);
exit (EXIT_FAILURE);
}
args_info->rattype_given = 1;
/* args_info->rattype_arg = strtol (optarg,&stop_char,0); */
args_info->rattype_arg = strdup (optarg);
break;
}
/* User Location Information. */
else if (strcmp (long_options[option_index].name, "userloc") == 0)
{
if (args_info->userloc_given)
{
fprintf (stderr, "%s: `--userloc' option given more than once\n", PACKAGE);
exit (EXIT_FAILURE);
}
args_info->userloc_given = 1;
args_info->userloc_arg = strdup (optarg);
break;
}
/* MS Time Zone */
else if (strcmp (long_options[option_index].name, "mstz") == 0)
{
if (args_info->mstz_given)
{
fprintf (stderr, "%s: `--mstz' option given more than once\n", PACKAGE);
exit (EXIT_FAILURE);
}
args_info->mstz_given = 1;
args_info->mstz_arg = strdup (optarg);
break;
}
/* IMEI(SV) */
else if (strcmp (long_options[option_index].name, "imeisv") == 0)
{
if (args_info->imeisv_given)
{
fprintf (stderr, "%s: `--imeisv' option given more than once\n", PACKAGE);
exit (EXIT_FAILURE);
}
args_info->imeisv_given = 1;
args_info->imeisv_arg = strdup (optarg);
break;
}
/* NSAPI. */
else if (strcmp (long_options[option_index].name, "nsapi") == 0)
{
Expand Down
16 changes: 16 additions & 0 deletions sgsnemu/cmdline.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ struct gengetopt_args_info
int selmode_arg; /* Selection mode (default='0x01'). */
char * selmode_orig; /* Selection mode original value given at command line. */
const char *selmode_help; /* Selection mode help description. */
char * rattype_arg; /* Radio Access Technology Type (optional). */
char * rattype_orig;
char * rattype_help;
char * userloc_arg; /* User Location Information (optional). */
char * userloc_orig;
char * userloc_help;
char * mstz_arg; /* MS Time Zone (optional). */
char * mstz_orig;
char * mstz_help;
char * imeisv_arg; /* IMEI(SV) (optional). */
char * imeisv_orig;
char * imeisv_help;
char * imsi_arg; /* IMSI (default='240010123456789'). */
char * imsi_orig; /* IMSI original value given at command line. */
const char *imsi_help; /* IMSI help description. */
Expand Down Expand Up @@ -124,6 +136,10 @@ struct gengetopt_args_info
int gtpversion_given ; /* Whether gtpversion was given. */
int apn_given ; /* Whether apn was given. */
int selmode_given ; /* Whether selmode was given. */
int rattype_given ; /* Whether rattype was given. */
int userloc_given ; /* Whether userloc was given. */
int mstz_given ; /* Whether mstz was given. */
int imeisv_given ; /* Whether imeisv was given. */
int imsi_given ; /* Whether imsi was given. */
int nsapi_given ; /* Whether nsapi was given. */
int msisdn_given ; /* Whether msisdn was given. */
Expand Down
Loading

0 comments on commit 944dce3

Please sign in to comment.