fixup Tunnel
This commit is contained in:
parent
40974e78dd
commit
d776ea007c
|
@ -198,19 +198,29 @@ METHOD(osmo_epdg_gsup_client_t, tunnel_request, osmo_epdg_gsup_response_t*,
|
|||
private_osmo_epdg_gsup_client_t *this, char *imsi, char *apn)
|
||||
{
|
||||
struct osmo_gsup_message gsup_msg = {0};
|
||||
struct osmo_gsup_pdp_info *pdp;
|
||||
struct msgb *msg;
|
||||
bool timedout;
|
||||
|
||||
DBG1(DBG_NET, "Tunnel Request Request for %s", imsi);
|
||||
gsup_msg.message_type = OSMO_GSUP_MSGT_EPDG_TUNNEL_REQUEST;
|
||||
gsup_msg.current_rat_type = OSMO_RAT_EUTRAN_SGS;
|
||||
|
||||
if (!imsi || strlen(imsi) == 0)
|
||||
{
|
||||
/* TODO: inval imsi! */
|
||||
return NULL;
|
||||
}
|
||||
strncpy(gsup_msg.imsi, imsi, sizeof(gsup_msg.imsi));
|
||||
strncpy(gsup_msg.imsi, imsi, sizeof(gsup_msg.imsi))
|
||||
|
||||
if (apn && strlen(apn) > 0)
|
||||
{
|
||||
gsup_msg->num_pdp_infos = 1;
|
||||
pdp = gsup_msg.pdp_infos[0];
|
||||
pdp->context_id = 1;
|
||||
pdp->have_info = 1;
|
||||
pdp->apn_enc = apn;
|
||||
pdp->apn_enc_len = strlen(apn);
|
||||
}
|
||||
|
||||
msg = encode_to_msgb(&gsup_msg);
|
||||
if (!msg)
|
||||
|
@ -219,8 +229,7 @@ METHOD(osmo_epdg_gsup_client_t, tunnel_request, osmo_epdg_gsup_response_t*,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* TODO: add APN! */
|
||||
gsup_request_t *req = gsup_request_create(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, msg);
|
||||
gsup_request_t *req = gsup_request_create(OSMO_GSUP_MSGT_EPDG_TUNNEL_REQUEST, msg);
|
||||
osmo_epdg_gsup_response_t *resp = NULL;
|
||||
timedout = enqueue(this, req, 5000);
|
||||
if (timedout)
|
||||
|
|
|
@ -84,6 +84,8 @@ METHOD(listener_t, authorize, bool,
|
|||
private_osmo_epdg_listener_t *this, ike_sa_t *ike_sa,
|
||||
bool final, bool *success)
|
||||
{
|
||||
int ret;
|
||||
char apn[APN_MAXLEN];
|
||||
DBG1(DBG_NET, "Authorized: uniq 0x%08x, name %s final: %d, eap: %d!",
|
||||
ike_sa->get_unique_id(ike_sa),
|
||||
ike_sa->get_name(ike_sa),
|
||||
|
@ -95,10 +97,18 @@ METHOD(listener_t, authorize, bool,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
osmo_epdg_gsup_response_t *resp = this->gsup->tunnel_request(this->gsup, imsi, apn);
|
||||
apn[0] = 0;
|
||||
ret = get_apn(sa, apn, APN_MAXLEN);
|
||||
if (!ret && ret != -EINVAL)
|
||||
{
|
||||
DBG1(DBG_NET, "epdg_listener: Tunnel Request: Couldn't get APN!");
|
||||
goto err;
|
||||
}
|
||||
|
||||
osmo_epdg_gsup_response_t *resp = this->gsup->tunnel_request(this->gsup, imsi, apn, strlen(apn));
|
||||
if (!resp)
|
||||
{
|
||||
DBG1(DBG_NET, "epdg: GSUP: couldn't send Tunnel Requeset.");
|
||||
DBG1(DBG_NET, "epdg_listener: Tunnel Request: GSUP: couldn't send.");
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
@ -109,7 +119,7 @@ METHOD(listener_t, authorize, bool,
|
|||
}
|
||||
else if (resp->gsup.message_type != OSMO_GSUP_MSGT_EPDG_TUNNEL_RESULT)
|
||||
{
|
||||
DBG1(DBG_NET, "epdg_listener: Tunnel unexpected message type: %02x", resp->gsup.message_type);
|
||||
DBG1(DBG_NET, "epdg_listener: Tunnel Response: unexpected message type: %02x", resp->gsup.message_type);
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,6 +82,7 @@ int get_apn(ike_sa_t *sa, char *apn, size_t apn_len)
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
strncpy(apn, apn_chunk.ptr, apn_len);
|
||||
memcpy(apn, apn_chunk.ptr, apn_chunk.len);
|
||||
apn[apn_chunk_len] = 0;
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue