WIP: send xid window size

lynxis_xid_windows
Alexander Couzens 6 years ago
parent 388a33ca9c
commit 37b372601a
  1. 5
      siu/l2tp/l2tpd.h
  2. 36
      siu/l2tp/l2tpd_fsm.c
  3. 36
      siu/l2tp/l2tpd_lapd.c
  4. 1
      siu/l2tp/l2tpd_lapd.h

@ -8,6 +8,7 @@
#include <osmocom/core/logging.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/select.h>
#include <osmocom/core/timer.h>
#include "l2tpd_socket.h"
@ -71,8 +72,10 @@ struct l2tpd_session {
uint8_t remote_end_id;
/* finite state machine for call/session */
struct osmo_fsm_inst *fsm;
/* send every X ms a xid request with window size */
struct osmo_timer_list xid_timer;
/* TODO: sockets for TRAU and PCU */
};
struct traffic_channel {

@ -1,10 +1,12 @@
#include <osmocom/core/fsm.h>
#include <osmocom/core/timer.h>
#include "l2tp_protocol.h"
#include "l2tpd.h"
#include "l2tpd_packet.h"
#include "l2tpd_lapd.h"
#include "l2tpd_data.h"
#include "l2tpd_fsm.h"
@ -320,6 +322,38 @@ static void l2tp_ic_s_established(struct osmo_fsm_inst *fi, uint32_t event, void
/* FIXME: remove old session if it got dealloc from l2i->trau.session etc. */
}
static void established_timer_cb(void *priv)
{
struct l2tpd_session *l2s = priv;
switch (l2s->remote_end_id) {
case TC_GROUP_PGSL:
break;
case TC_GROUP_RSL_OML:
// lapd_send_xid(l2i, l2s, 00, 01);
// lapd_send_xid(l2i, l2s, 62, 62);
// lapd_send_xid(l2i, l2s, 62, 01);
break;
case TC_GROUP_TRAU:
break;
}
osmo_timer_schedule(&l2s->xid_timer, 0, 500 * 1000);
}
static void l2tp_ic_s_established_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
struct l2tpd_session *l2s = (struct l2tpd_session *) fi->priv;
osmo_timer_schedule(&l2s->xid_timer, 0, 500 * 1000);
l2s->xid_timer.cb = established_timer_cb;
l2s->xid_timer.data = l2s;
/* start XID until received */
}
static void l2tp_ic_s_established_onleave(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
;
}
static const struct value_string l2tp_ic_names[] = {
{ L2IC_E_RX_ICRQ, "RX-InCall-Req" },
@ -348,6 +382,8 @@ static const struct osmo_fsm_state l2tp_ic_states[] = {
.out_state_mask = 0,
.name = "ESTABLISHED",
.action = l2tp_ic_s_established,
.onenter = l2tp_ic_s_established_onenter,
.onleave = l2tp_ic_s_established_onleave,
},
};

@ -206,6 +206,42 @@ int lapd_ehdlc_to_lapd(struct l2tpd_instance *l2i, struct l2tpd_session *l2s, st
}
/*!
* \brief fill_xid write a ehdlc xid window request into msgb
* \param msg
* \param csapi
* \param ctei
* \return 0 on success
*/
int lapd_send_xid(struct l2tpd_instance *l2i, struct l2tpd_session *l2s, int sapi, int tei)
{
struct msgb *msg = l2tp_msgb_alloc();
uint16_t ehdlc_compressed = 0;
int rc = 0;
uint8_t xid[14] = {
0xaf, 0x82, 0x80, /* U, XID, Unnumbered, */
0x00, 0x09, /* length */
0x07, 0x01, 0x10, /* transmit window size */
0x09, 0x01, 0x0e, /* timer (ms) */
0x08, 0x01, 0x03 }; /* receive window */
int length = ARRAY_SIZE(xid) + 2; /* add 2 byte for the ehdlc header itself */
int cr = 1;
ehdlc_compressed |= (sapi_to_csapi(sapi, cr) << EHDLC_CSAPI_SHIFT) & EHDLC_CSAPI_MASK;
ehdlc_compressed |= (tei_to_ctei(tei) << EHDLC_CTEI_SHIFT) & EHDLC_CTEI_MASK;
ehdlc_compressed |= length & EHDLC_LENGTH_MASK;
msgb_put_u16(msg, ehdlc_compressed);
memcpy(msgb_put(msg, ARRAY_SIZE(xid)), xid, ARRAY_SIZE(xid));
msg->dst = l2s;
rc = l2tp_tx_data(msg);
msgb_free(msg);
return rc;
}
/*!
* \brief rsl_oml_cb called when data arrived on the unix socket
* \param fd

@ -2,6 +2,7 @@
int lapd_lapd_to_ehdlc(struct l2tpd_instance *l2i, struct msgb *msg);
int lapd_ehdlc_to_lapd(struct l2tpd_instance *l2i, struct l2tpd_session *session, struct msgb *msg);
int lapd_send_xid(struct l2tpd_instance *l2i, struct l2tpd_session *l2s, int sapi, int tei);
int unix_rsl_oml_cb(struct osmo_fd *fd);
int unix_trau_cb(struct osmo_fd *fd);
int unix_pgsl_cb(struct osmo_fd *fd);

Loading…
Cancel
Save