forked from acouzens/open5gs
update it
This commit is contained in:
parent
b1f84eed5d
commit
6dc54ce7ba
|
@ -80,41 +80,10 @@ status_t gtp_send(net_sock_t *sock, gtp_node_t *gnode, pkbuf_t *pkbuf)
|
|||
char buf[INET_ADDRSTRLEN];
|
||||
ssize_t sent;
|
||||
|
||||
typedef struct _gtpv2c_header_t {
|
||||
ED4(c_uint8_t version:3;,
|
||||
c_uint8_t piggybacked:1;,
|
||||
c_uint8_t teid_presence:1;,
|
||||
c_uint8_t spare1:3;)
|
||||
c_uint8_t type;
|
||||
c_uint16_t length;
|
||||
union {
|
||||
struct {
|
||||
c_uint32_t teid;
|
||||
/* sqn : 31bit ~ 8bit, spare : 7bit ~ 0bit */
|
||||
#define GTP_XID_TO_SQN(__xid) ((__xid) << 8)
|
||||
#define GTP_SQN_TO_XID(__sqn) ((__sqn) >> 8)
|
||||
c_uint32_t sqn;
|
||||
};
|
||||
/* sqn : 31bit ~ 8bit, spare : 7bit ~ 0bit */
|
||||
c_uint32_t spare2;
|
||||
};
|
||||
} __attribute__ ((packed)) gtpv2c_header_t;
|
||||
gtpv2c_header_t *h;
|
||||
|
||||
d_assert(sock, return CORE_ERROR, "Null param");
|
||||
d_assert(gnode, return CORE_ERROR, "Null param");
|
||||
d_assert(pkbuf, return CORE_ERROR, "Null param");
|
||||
|
||||
pkbuf_header(pkbuf, 12);
|
||||
|
||||
h = pkbuf->payload;
|
||||
memset(h, 0, 12);
|
||||
h->version = 2;
|
||||
h->teid_presence = 1;
|
||||
h->type = 32;
|
||||
h->length = htons(pkbuf->len - 4);
|
||||
h->sqn = 1;
|
||||
|
||||
sent = net_sendto(sock, pkbuf->payload, pkbuf->len,
|
||||
gnode->addr, gnode->port);
|
||||
d_trace(1,"Sent %d->%d bytes to [%s:%d]\n", pkbuf->len, sent,
|
||||
|
|
|
@ -149,27 +149,46 @@ status_t gtp_xact_delete(gtp_xact_t *xact)
|
|||
return CORE_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the transaction with the new packet to be sent for the next step
|
||||
*/
|
||||
status_t gtp_xact_update_tx(gtp_xact_t *xact, pkbuf_t *pkb)
|
||||
{
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the transaction with the new received packet for the next step
|
||||
*/
|
||||
status_t gtp_xact_update_rx(gtp_xact_t *xact)
|
||||
{
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply and commit the updated of the transcation
|
||||
*/
|
||||
status_t gtp_xact_commit(gtp_xact_t *xact)
|
||||
{
|
||||
status_t rv;
|
||||
net_sock_t *sock = NULL;
|
||||
gtp_node_t *gnode = NULL;
|
||||
pkbuf_t *pkbuf = NULL;
|
||||
gtpv2c_header_t *h = NULL;
|
||||
|
||||
d_assert(xact, return CORE_ERROR, "Null param");
|
||||
d_assert(xact->tm_wait, return CORE_ERROR, "Null param");
|
||||
|
||||
sock = xact->sock;
|
||||
d_assert(sock, return CORE_ERROR, "Null param");
|
||||
gnode = xact->gnode;
|
||||
d_assert(gnode, return CORE_ERROR, "Null param");
|
||||
pkbuf = xact->pkbuf;
|
||||
d_assert(pkbuf, return CORE_ERROR, "Null param");
|
||||
|
||||
pkbuf_header(pkbuf, GTPV2C_HEADER_LEN);
|
||||
h = pkbuf->payload;
|
||||
d_assert(h, return CORE_ERROR, "Null param");
|
||||
|
||||
h->version = 2;
|
||||
h->teid_presence = 1;
|
||||
h->type = xact->type;
|
||||
h->length = htons(pkbuf->len - 4);
|
||||
h->sqn = GTP_XID_TO_SQN(xact->xid);
|
||||
|
||||
rv = gtp_send(sock, gnode, pkbuf);
|
||||
if (rv != CORE_OK)
|
||||
{
|
||||
d_error("failed to send GTP message");
|
||||
return CORE_ERROR;
|
||||
}
|
||||
|
||||
tm_start(xact->tm_wait);
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -80,10 +80,16 @@ status_t mme_s11_close()
|
|||
return CORE_OK;
|
||||
}
|
||||
|
||||
#include "gtp_tlv.h"
|
||||
status_t mme_s11_send_to_sgw(void *sgw, pkbuf_t *pkbuf)
|
||||
{
|
||||
gtp_xact_t *xact = NULL;
|
||||
|
||||
d_assert(sgw, return CORE_ERROR, "Null param");
|
||||
d_assert(pkbuf, return CORE_ERROR, "Null param");
|
||||
|
||||
return gtp_send(mme_self()->s11_sock, sgw, pkbuf);
|
||||
xact = gtp_xact_new_local(&mme_self()->gtp_xact_ctx,
|
||||
GTP_CREATE_SESSION_REQUEST_TYPE,
|
||||
mme_self()->s11_sock, sgw, pkbuf);
|
||||
return gtp_xact_commit(xact);
|
||||
}
|
||||
|
|
|
@ -10,8 +10,5 @@ void sgw_handle_create_session_request(
|
|||
gtp_xact_t *xact, gtp_create_session_request_t *req)
|
||||
{
|
||||
d_info("sgw_handle_create_session_request");
|
||||
d_print_hex(req->imsi.data, req->imsi.len);
|
||||
d_print_hex(req->msisdn.data, req->msisdn.len);
|
||||
d_print_hex(req->me_identity.data, req->me_identity.len);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue