GTP: Replace recently introduced imsi_str2gtp()
Replace with the version from osmo-sgsn, renamed so as not to collide with that version. Change-Id: I910d5339a823332277ce7b5854d5c943ed69ea81
This commit is contained in:
parent
568ac5ee8e
commit
fb2a7298e0
|
@ -899,7 +899,7 @@ DEFUN(show_pdpctx_imsi, show_pdpctx_imsi_cmd,
|
|||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
imsi = imsi_str2gtp(argv[1]);
|
||||
imsi = gtp_imsi_str2gtp(argv[1]);
|
||||
|
||||
if (argc > 2) {
|
||||
nsapi = atoi(argv[2]);
|
||||
|
|
31
gtp/gtp.c
31
gtp/gtp.c
|
@ -3493,16 +3493,25 @@ const char *imsi_gtp2str(const uint64_t *imsi)
|
|||
return buf;
|
||||
}
|
||||
|
||||
/* Encode an IMSI with gtp encoding according to TS 29.060 - the
|
||||
reverse of imsi_gtp2str(). The hash index used for context
|
||||
lookups is generated from the IMSI in gtp format. User input
|
||||
in the vty (for example) needs to be converted to match. */
|
||||
const uint64_t imsi_str2gtp(const char *imsi)
|
||||
/* Generate the GTP IMSI IE according to 09.60 Section 7.9.2 */
|
||||
uint64_t gtp_imsi_str2gtp(const char *str)
|
||||
{
|
||||
uint64_t ret = 0xf000000000000000ull;
|
||||
unsigned int i, imsi_length = strlen(imsi);
|
||||
uint64_t imsi64 = 0;
|
||||
unsigned int n;
|
||||
unsigned int imsi_len = strlen(str);
|
||||
|
||||
for (i = 0; i < imsi_length; i++)
|
||||
ret |= ((uint64_t) (imsi[i] - '0')) << (i * 4);
|
||||
return ret;
|
||||
}
|
||||
if (imsi_len > 16) {
|
||||
LOGP(DLGTP, LOGL_NOTICE, "IMSI length > 16 not supported!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (n = 0; n < 16; n++) {
|
||||
uint64_t val;
|
||||
if (n < imsi_len)
|
||||
val = (str[n]-'0') & 0xf;
|
||||
else
|
||||
val = 0xf;
|
||||
imsi64 |= (val << (n*4));
|
||||
}
|
||||
return imsi64;
|
||||
}
|
||||
|
|
|
@ -441,6 +441,6 @@ extern int eua2ipv4(struct in_addr *dst, struct ul66_t *eua);
|
|||
extern int gsna2in_addr(struct in_addr *dst, struct ul16_t *gsna);
|
||||
extern int in_addr2gsna(struct ul16_t *gsna, struct in_addr *src);
|
||||
extern const char *imsi_gtp2str(const uint64_t *imsi);
|
||||
extern const uint64_t imsi_str2gtp(const char *imsi);
|
||||
extern uint64_t gtp_imsi_str2gtp(const char *str);
|
||||
|
||||
#endif /* !_GTP_H */
|
||||
|
|
|
@ -497,7 +497,7 @@ static int process_options(int argc, char **argv)
|
|||
return -1;
|
||||
}
|
||||
|
||||
options.imsi = imsi_str2gtp(args_info.imsi_arg);
|
||||
options.imsi = gtp_imsi_str2gtp(args_info.imsi_arg);
|
||||
|
||||
printf("IMSI is: %s (%#08llx)\n",
|
||||
args_info.imsi_arg, options.imsi);
|
||||
|
|
Loading…
Reference in New Issue