forked from acouzens/open5gs
refine usrsctp
This commit is contained in:
parent
06f8e42173
commit
28f6d16ce2
|
@ -24,10 +24,6 @@
|
|||
|
||||
#include "sctp/sctp-config.h"
|
||||
|
||||
#if HAVE_NETINET_SCTP_H
|
||||
#include <netinet/sctp.h>
|
||||
#endif
|
||||
|
||||
#define OGS_SCTP_INSIDE
|
||||
|
||||
/* Nothing */
|
||||
|
@ -51,6 +47,7 @@ extern int __ogs_sctp_domain;
|
|||
#define OGS_SCTP_SGSAP_PPID 0
|
||||
|
||||
#if HAVE_USRSCTP
|
||||
|
||||
#undef MSG_NOTIFICATION
|
||||
#define MSG_NOTIFICATION 0x2000
|
||||
|
||||
|
@ -60,13 +57,22 @@ extern int __ogs_sctp_domain;
|
|||
#ifndef INET6
|
||||
#define INET6 1
|
||||
#endif
|
||||
|
||||
#include <usrsctp.h>
|
||||
|
||||
ogs_sockaddr_t *ogs_usrsctp_remote_addr(union sctp_sockstore *store);
|
||||
void ogs_sctp_destroy(ogs_sock_t *sock);
|
||||
ogs_sock_t *ogs_sctp_accept(ogs_sock_t *sock);
|
||||
|
||||
#else
|
||||
|
||||
#if HAVE_NETINET_SCTP_H
|
||||
#include <netinet/sctp.h>
|
||||
#endif
|
||||
|
||||
#define ogs_sctp_destroy ogs_sock_destroy
|
||||
#define ogs_sctp_accept ogs_sock_accept
|
||||
|
||||
#endif
|
||||
|
||||
#define DEFAULT_SCTP_MAX_NUM_OF_OSTREAMS 30
|
||||
|
|
|
@ -58,9 +58,10 @@ static int usrsctp_recv_handler(struct socket *sock,
|
|||
union sctp_sockstore store, void *data, size_t datalen,
|
||||
struct sctp_rcvinfo rcv, int flags, void *ulp_info)
|
||||
{
|
||||
ogs_sockaddr_t *addr = NULL;
|
||||
|
||||
if (data) {
|
||||
if (flags & MSG_NOTIFICATION) {
|
||||
ogs_sockaddr_t *addr = NULL;
|
||||
union sctp_notification *not = (union sctp_notification *)data;
|
||||
if (not->sn_header.sn_length == (uint32_t)datalen) {
|
||||
switch(not->sn_header.sn_type) {
|
||||
|
@ -77,8 +78,7 @@ static int usrsctp_recv_handler(struct socket *sock,
|
|||
SCTP_SHUTDOWN_COMP ||
|
||||
not->sn_assoc_change.sac_state ==
|
||||
SCTP_COMM_LOST) {
|
||||
ogs_sockaddr_t *addr =
|
||||
ogs_usrsctp_remote_addr(&store);
|
||||
addr = ogs_usrsctp_remote_addr(&store);
|
||||
ogs_assert(addr);
|
||||
|
||||
if (not->sn_assoc_change.sac_state ==
|
||||
|
@ -130,6 +130,14 @@ static int usrsctp_recv_handler(struct socket *sock,
|
|||
not->sn_paddr_change.spc_flags,
|
||||
not->sn_paddr_change.spc_error);
|
||||
break;
|
||||
case SCTP_ADAPTATION_INDICATION :
|
||||
ogs_info("SCTP_ADAPTATION_INDICATION:"
|
||||
"[T:%d, F:0x%x, S:%d, I:%d]",
|
||||
not->sn_adaptation_event.sai_type,
|
||||
not->sn_adaptation_event.sai_flags,
|
||||
not->sn_adaptation_event.sai_length,
|
||||
not->sn_adaptation_event.sai_adaptation_ind);
|
||||
break;
|
||||
case SCTP_REMOTE_ERROR:
|
||||
ogs_warn("SCTP_REMOTE_ERROR:[T:%d, F:0x%x, S:%d]",
|
||||
not->sn_remote_error.sre_type,
|
||||
|
@ -146,7 +154,6 @@ static int usrsctp_recv_handler(struct socket *sock,
|
|||
}
|
||||
} else if (flags & MSG_EOR) {
|
||||
ogs_pkbuf_t *pkbuf;
|
||||
ogs_sockaddr_t *addr = NULL;
|
||||
|
||||
pkbuf = ogs_pkbuf_alloc(NULL, OGS_MAX_SDU_LEN);
|
||||
ogs_pkbuf_put_data(pkbuf, data, datalen);
|
||||
|
|
|
@ -56,10 +56,11 @@ static int usrsctp_recv_handler(struct socket *sock,
|
|||
union sctp_sockstore store, void *data, size_t datalen,
|
||||
struct sctp_rcvinfo rcv, int flags, void *ulp_info)
|
||||
{
|
||||
ogs_sockaddr_t *addr = NULL;
|
||||
|
||||
if (data) {
|
||||
if (flags & MSG_NOTIFICATION) {
|
||||
union sctp_notification *not = (union sctp_notification *)data;
|
||||
ogs_sockaddr_t *addr = NULL;
|
||||
if (not->sn_header.sn_length == (uint32_t)datalen) {
|
||||
switch(not->sn_header.sn_type) {
|
||||
case SCTP_ASSOC_CHANGE :
|
||||
|
@ -98,6 +99,7 @@ static int usrsctp_recv_handler(struct socket *sock,
|
|||
}
|
||||
break;
|
||||
case SCTP_SHUTDOWN_EVENT :
|
||||
case SCTP_SEND_FAILED :
|
||||
addr = ogs_usrsctp_remote_addr(&store);
|
||||
ogs_assert(addr);
|
||||
|
||||
|
@ -145,7 +147,6 @@ static int usrsctp_recv_handler(struct socket *sock,
|
|||
}
|
||||
} else if (flags & MSG_EOR) {
|
||||
ogs_pkbuf_t *pkbuf;
|
||||
ogs_sockaddr_t *addr = NULL;
|
||||
|
||||
pkbuf = ogs_pkbuf_alloc(NULL, OGS_MAX_SDU_LEN);
|
||||
ogs_pkbuf_put_data(pkbuf, data, datalen);
|
||||
|
|
Loading…
Reference in New Issue