Merge branch 'lynxis' into master
This commit is contained in:
commit
2d97ca9467
|
@ -191,7 +191,7 @@ int lapd_ehdlc_to_lapd(struct l2tpd_instance *l2i, struct l2tpd_session *l2s, st
|
|||
return 0;
|
||||
}
|
||||
|
||||
send_msg = msgb_alloc(length + 128, "lapd frame");
|
||||
send_msg = l2tp_msgb_alloc();
|
||||
memcpy(msgb_data(send_msg), msgb_data(msg), length);
|
||||
msgb_pull(msg, length);
|
||||
msgb_put(send_msg, length);
|
||||
|
@ -205,6 +205,38 @@ int lapd_ehdlc_to_lapd(struct l2tpd_instance *l2i, struct l2tpd_session *l2s, st
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief lapd_switch_altc try to parse the msg, if valid it change the ALTC type to the requested
|
||||
* \param l2i
|
||||
* \param msg
|
||||
* \return 1 if valid and parsed, 0 if should passthrough to the siu
|
||||
*/
|
||||
int lapd_switch_altc(struct l2tpd_instance *l2i, struct msgb *msg)
|
||||
{
|
||||
struct l2tpd_session *l2s = msg->dst;
|
||||
|
||||
/* magic 0x23004200 (4 byte) + value (1 byte) */
|
||||
if (msgb_length(msg) != (4 + 1))
|
||||
return 0;
|
||||
|
||||
/* skip lapd header */
|
||||
if (osmo_load32be(msgb_data(msg)) != 0x23004200)
|
||||
return 0;
|
||||
|
||||
/* pull data pointer to next object */
|
||||
msgb_pull(msg, 4);
|
||||
|
||||
if (msgb_pull_u8(msg)) {
|
||||
LOGP(DL2TP, LOGL_INFO, "ALTCRQ -> SuperChannel requested\n");
|
||||
l2tp_tx_altc_rq_superchannel(l2s->connection);
|
||||
} else {
|
||||
LOGP(DL2TP, LOGL_INFO, "ALTCRQ -> TimeSlot requested\n");
|
||||
l2tp_tx_altc_rq_timeslot(l2s->connection);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* \brief rsl_oml_cb called when data arrived on the unix socket
|
||||
|
@ -223,15 +255,15 @@ int unix_rsl_oml_cb(struct osmo_fd *fd)
|
|||
rc = read(fd->fd, msg->data, msg->data_len);
|
||||
if (rc < 0) {
|
||||
LOGP(DL2TP, LOGL_ERROR, "read failed %s\n", strerror(errno));
|
||||
msgb_free(msg);
|
||||
return rc;
|
||||
} else if (rc == 0) {
|
||||
LOGP(DL2TP, LOGL_ERROR, "closing socket because read 0 bytes\n");
|
||||
msgb_free(msg);
|
||||
l2tp_sock_cleanup(fd);
|
||||
return 0;
|
||||
}
|
||||
if (rc > 3) {
|
||||
LOGP(DL2TP, LOGL_ERROR, "read %d\n", rc);
|
||||
}
|
||||
|
||||
msgb_put(msg, rc);
|
||||
msg->dst = channel->session;
|
||||
|
||||
|
@ -241,11 +273,18 @@ int unix_rsl_oml_cb(struct osmo_fd *fd)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* check if this packet is for us */
|
||||
if (lapd_switch_altc(l2i, msg)) {
|
||||
msgb_free(msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
rc = lapd_lapd_to_ehdlc(l2i, msg);
|
||||
if (rc) {
|
||||
LOGP(DL2TP, LOGL_NOTICE, "lapd_to_ehlc returned != 0: %d.\n", rc);
|
||||
}
|
||||
|
||||
msgb_free(msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -851,7 +851,13 @@ static int l2tp_rcvmsg_control(struct msgb *msg)
|
|||
l2c = l2tpd_cc_find_by_l_cc_id(l2i, ch->ccid);
|
||||
if (!l2c) {
|
||||
LOGP(DL2TP, LOGL_ERROR, "l2tp: can not find a connection for ccid %d\n", ch->ccid);
|
||||
l2tp_tx_stop_ccn_msg(msg);
|
||||
/* ignore acks */
|
||||
if (first_avp->vendor_id != VENDOR_IETF ||
|
||||
first_avp->type != AVP_IETF_CTRL_MSG ||
|
||||
msg_type != IETF_CTRLMSG_ACK) {
|
||||
l2tp_tx_stop_ccn_msg(msg);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -942,7 +948,6 @@ int l2tp_rcvmsg(struct msgb *msg)
|
|||
return l2tp_rcvmsg_control(msg);
|
||||
} else {
|
||||
l2tp_rcvmsg_data(msg);
|
||||
LOGP(DL2TP, LOGL_ERROR, "Received session %d data.\n", session);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue