sgsn: Do not 'commit' implicitely when executing 'insert'

Currently the gprs_subscr_update function is called when the
'update-subscriber ... insert ...' command is executed. This will
eventually notify the GMM layer which is rather the purpose of the
'commit' command.

This patch removes the call from update_subscr_insert.

Sponsored-by: On-Waves ehf
sgsn: Integrate Auth & Ciph into gsm48_gmm_authorize

Currently the Authentication and Ciphering procedure is not yet
invoked by the GMM layer.

This patch starts this procedure from within gsm48_gmm_authorize when
the mm->auth_state has been set to SGSN_AUTH_AUTHENTICATE and a call
to gsm0408_gprs_authenticate has been issued directly or indirectly
by the call to sgsn_auth_request.

Sponsored-by: On-Waves ehf
sgsn: Support subscriber based authentication

This commit mainly extends sgsn_auth.c to use and support the
auth_state SGSN_AUTH_AUTHENTICATE. It will be activated when IMSI and
IMEI are available, authentication is required
(subscr->sgsn_data->authenticate is set), but the MM context is not
marked as authenticated. If the state has been set to
SGSN_AUTH_AUTHENTICATE and sgsn_auth_update() is called, the GMM
layer will be informed by invoking gsm0408_gprs_authenticate().

Sponsored-by: On-Waves ehf
sgsn: Do not die in _bssgp_tx_dl_ud on TLLI mismatch (TODO)

Currently an OSMO_ASSERT fails, if the message's and the mmctx's
TLLIs do not match.

This commit turns the assertion into an ERROR log message and uses
the default values for IMSI, DRX, and RA CAP instead of the MM
context values in this case.

TODO:
  - find the real source for the problem
  - add test cases derived from what is being described in the ticket

Ticket: OW#1322
Sponsored-by: On-Waves ehf
sgsn: Added TODOs (TODO)

TODO:
  - fix and remove TODOs
  - add test cases for Detach(reattach)
  - add test cases for PDP context deletion (OW#1311)
  - add test cases for Cancel pending timer in sgsn_mm_ctx_free
  - remove this commit

Sponsored-by: On-Waves ehf
sgsn: Add support for authentication triplets (TODO)

TODO:
  - commit message
  - tests

Sponsored-by: On-Waves ehf
sgsn: Work on 2 phase authorization (WIP)

This implements the MAP way of subscriber validation when the MS
tries an Attach Request:
  1. perform authentication (optionally invoke the sendAuthInfo
  procedure), starts the AuthAndCiph procedure
  2. perform update location
  3. insert subscriber data
  4. finish the update location
  5. Attach Accept / Attach Reject

This is currently accessible via the VTY interface.

TODO:
  - Apply this to (periodic) RA Update Req
  - Delete Subscriber Data
  - Improve on procedure collisions (repeated Attach Req is sometimes
    not handled properly)
  - PDP info
  - Commit cleanup

Sponsored-by: On-Waves ehf
gprs: Move TLV parser functions to gprs_utils.c and rename them

Currently the parser functions for single information elements are
defined within gprs_gb_parse.c and not exported explicitely. In
addition they are named like libosmocore's TLV parser functions and
do not have a proper name prefix. Since it is planned to use them for
other protocols, they need to be globally accessible.

This patch moves them to gprs_utils.c and renames them.

The new names are:
    lv_shift             -> gprs_shift_lv
    v_fixed_shift        -> gprs_shift_v_fixed
    lv_shift             -> gprs_shift_lv
    v_fixed_shift        -> gprs_shift_v_fixed

In the long term, these functions should be moved to libosmocore (and
renamed again).

Sponsored-by: On-Waves ehf
gprs: Add gprs_shift_tlv function

This function is similar to gprs_match_tlv with the exception, that
the tag is not compared but returned in *tag instead.

Sponsored-by: On-Waves ehf
sgsn/doc: Add protocol specification for remote subscriber update

This is the first version of the specification for the GPRS
Subscriber Update Protocol.

Sponsored-by: On-Waves ehf
gprs: Add encoder/decoder for the Subscriber Update Protocol (WIP)

Status: compiles but is totally untested

TODO:
  - Add commit message
  - Add encoder
  - Test cases
  - Moved declarations to header file

Ticket: OW#????
Sponsored-by: On-Waves ehf