summaryrefslogtreecommitdiff
path: root/accel-pppd/ctrl/sstp/sstp.c
diff options
context:
space:
mode:
authorVladislav Grishenko <themiron@mail.ru>2017-12-31 02:11:33 +0500
committerVladislav Grishenko <themiron@mail.ru>2018-01-05 18:26:01 +0500
commit3bf08b872e9a9640db468b823358523ec74cc178 (patch)
treee274852a47d7aa9a68f53fd887de0c471c0b4f0a /accel-pppd/ctrl/sstp/sstp.c
parentc9d32e8baefb2784a8ab7e1052df704273135ff6 (diff)
downloadaccel-ppp-xebd-3bf08b872e9a9640db468b823358523ec74cc178.tar.gz
accel-ppp-xebd-3bf08b872e9a9640db468b823358523ec74cc178.zip
sstp: possible sync ppp mode fix
Diffstat (limited to 'accel-pppd/ctrl/sstp/sstp.c')
-rw-r--r--accel-pppd/ctrl/sstp/sstp.c49
1 files changed, 31 insertions, 18 deletions
diff --git a/accel-pppd/ctrl/sstp/sstp.c b/accel-pppd/ctrl/sstp/sstp.c
index 763c90f..a390cd9 100644
--- a/accel-pppd/ctrl/sstp/sstp.c
+++ b/accel-pppd/ctrl/sstp/sstp.c
@@ -725,11 +725,13 @@ static int ppp_allocate_pty(int *master, int *slave, int flags)
goto error;
}
-// value = N_HDLC;
-// if (ioctl(mfd, TIOCSETD, &value) < 0) {
-// log_ppp_error("sstp: ppp: set pty line discipline: %s\n", strerror(errno));
-// goto error;
-// }
+#if PPP_SYNC
+ value = N_HDLC;
+ if (ioctl(mfd, TIOCSETD, &value) < 0) {
+ log_ppp_error("sstp: ppp: set pty line discipline: %s\n", strerror(errno));
+ goto error;
+ }
+#endif
if ((value = fcntl(mfd, F_GETFL)) < 0 || fcntl(mfd, F_SETFL, value | flags) < 0 ||
(value = fcntl(sfd, F_GETFL)) < 0 || fcntl(sfd, F_SETFL, value | flags) < 0) {
@@ -782,11 +784,10 @@ static int ppp_read(struct triton_md_handler_t *h)
struct sstp_conn_t *conn = container_of(h, typeof(*conn), ppp_hnd);
struct buffer_t *buf;
struct sstp_hdr *hdr;
- uint8_t pppbuf[PPP_BUF_SIZE];
- int n;
+ uint8_t pppbuf[PPP_BUF_SIZE], *src;
+ int i, n;
#if !PPP_SYNC
- uint8_t *src, byte;
- int i;
+ uint8_t byte;
buf = conn->ppp_in;
#endif
@@ -813,18 +814,30 @@ static int ppp_read(struct triton_md_handler_t *h)
continue;
}
+ src = pppbuf;
#if PPP_SYNC
- buf = alloc_buf(n + sizeof(*hdr));
- if (!buf) {
- log_ppp_error("sstp: ppp: no memory\n");
- goto drop;
+ while (n > 0) {
+ if (src[0] == PPP_ALLSTATIONS)
+ i = conn->ppp.mtu + 4 - (src[2] & 1);
+ else
+ i = conn->ppp.mtu + 2 - (src[0] & 1);
+ if (i > n)
+ i = n;
+
+ buf = alloc_buf(i + sizeof(*hdr));
+ if (!buf) {
+ log_ppp_error("sstp: ppp: no memory\n");
+ goto drop;
+ }
+ hdr = buf_put(buf, sizeof(*hdr));
+ buf_put_data(buf, src, i);
+ INIT_SSTP_DATA_HDR(hdr, buf->len);
+ sstp_queue(conn, buf);
+
+ n -= i;
+ src += i;
}
- hdr = buf_put(buf, sizeof(*hdr));
- buf_put_data(buf, pppbuf, n);
- INIT_SSTP_DATA_HDR(hdr, buf->len);
- sstp_queue(conn, buf);
#else
- src = pppbuf;
if (!buf) {
alloc:
conn->ppp_in = buf = alloc_buf(SSTP_MAX_PACKET_SIZE + PPP_FCSLEN);