mirror of
https://gitea.invidious.io/iv-org/litespeed-quic.git
synced 2024-08-15 00:53:43 +00:00
Fix Windows support
This commit is contained in:
parent
41d574f34c
commit
fb3e20e0bc
72 changed files with 912 additions and 475 deletions
|
@ -21,6 +21,16 @@ CHECK_SYMBOL_EXISTS(
|
|||
|
||||
INCLUDE(CheckIncludeFiles)
|
||||
|
||||
IF (MSVC AND PCRE_LIB)
|
||||
FIND_PATH(EVENT_INCLUDE_DIR NAMES pcreposix.h)
|
||||
IF (EVENT_INCLUDE_DIR)
|
||||
MESSAGE(STATUS "found pcreposix.h")
|
||||
SET(HAVE_REGEX 1)
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "event2/event.h was not found")
|
||||
ENDIF()
|
||||
ELSE()
|
||||
CHECK_INCLUDE_FILES(regex.h HAVE_REGEX)
|
||||
ENDIF()
|
||||
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test_config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/test_config.h)
|
||||
|
|
|
@ -9,11 +9,21 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifndef WIN32
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#define Read read
|
||||
#else
|
||||
#include "vc_compat.h"
|
||||
#include "getopt.h"
|
||||
#include <io.h>
|
||||
#define Read _read
|
||||
#define STDIN_FILENO 0
|
||||
#endif
|
||||
|
||||
#include <event2/event.h>
|
||||
|
||||
|
@ -69,12 +79,12 @@ struct lsquic_stream_ctx {
|
|||
|
||||
|
||||
static void
|
||||
read_stdin (int fd, short what, void *ctx)
|
||||
read_stdin (evutil_socket_t fd, short what, void *ctx)
|
||||
{
|
||||
ssize_t nr;
|
||||
lsquic_stream_ctx_t *st_h = ctx;
|
||||
|
||||
nr = read(fd, st_h->buf + st_h->buf_off++, 1);
|
||||
nr = Read(fd, st_h->buf + st_h->buf_off++, 1);
|
||||
LSQ_DEBUG("read %zd bytes from stdin", nr);
|
||||
if (0 == nr)
|
||||
{
|
||||
|
@ -217,6 +227,7 @@ main (int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
int flags = fcntl(STDIN_FILENO, F_GETFL);
|
||||
flags |= O_NONBLOCK;
|
||||
if (0 != fcntl(STDIN_FILENO, F_SETFL, flags))
|
||||
|
@ -224,6 +235,12 @@ main (int argc, char **argv)
|
|||
perror("fcntl");
|
||||
exit(1);
|
||||
}
|
||||
#else
|
||||
{
|
||||
u_long on = 1;
|
||||
ioctlsocket(STDIN_FILENO, FIONBIO, &on);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (0 != prog_prep(&prog))
|
||||
{
|
||||
|
|
|
@ -4,14 +4,19 @@
|
|||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <netinet/in.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/queue.h>
|
||||
#include <time.h>
|
||||
#ifndef WIN32
|
||||
#include <unistd.h>
|
||||
#include <netinet/in.h>
|
||||
#else
|
||||
#include "vc_compat.h"
|
||||
#include "getopt.h"
|
||||
#endif
|
||||
|
||||
#include "lsquic.h"
|
||||
#include "test_common.h"
|
||||
|
|
|
@ -531,18 +531,20 @@ static void
|
|||
send_headers (lsquic_stream_ctx_t *st_h)
|
||||
{
|
||||
const char *hostname = st_h->client_ctx->hostname;
|
||||
struct header_buf hbuf;
|
||||
if (!hostname)
|
||||
hostname = st_h->client_ctx->prog->prog_hostname;
|
||||
hbuf.off = 0;
|
||||
struct lsxpack_header headers_arr[7];
|
||||
#define V(v) (v), strlen(v)
|
||||
lsxpack_header_set_ptr(&headers_arr[0], V(":method"), V(st_h->client_ctx->method));
|
||||
lsxpack_header_set_ptr(&headers_arr[1], V(":scheme"), V("https"));
|
||||
lsxpack_header_set_ptr(&headers_arr[2], V(":path"), V(st_h->path));
|
||||
lsxpack_header_set_ptr(&headers_arr[3], V(":authority"), V(hostname));
|
||||
lsxpack_header_set_ptr(&headers_arr[4], V("user-agent"), V(st_h->client_ctx->prog->prog_settings.es_ua));
|
||||
header_set_ptr(&headers_arr[0], &hbuf, V(":method"), V(st_h->client_ctx->method));
|
||||
header_set_ptr(&headers_arr[1], &hbuf, V(":scheme"), V("https"));
|
||||
header_set_ptr(&headers_arr[2], &hbuf, V(":path"), V(st_h->path));
|
||||
header_set_ptr(&headers_arr[3], &hbuf, V(":authority"), V(hostname));
|
||||
header_set_ptr(&headers_arr[4], &hbuf, V("user-agent"), V(st_h->client_ctx->prog->prog_settings.es_ua));
|
||||
/* The following headers only gets sent if there is request payload: */
|
||||
lsxpack_header_set_ptr(&headers_arr[5], V("content-type"), V("application/octet-stream"));
|
||||
lsxpack_header_set_ptr(&headers_arr[6], V("content-length"), V( st_h->client_ctx->payload_size));
|
||||
header_set_ptr(&headers_arr[5], &hbuf, V("content-type"), V("application/octet-stream"));
|
||||
header_set_ptr(&headers_arr[6], &hbuf, V("content-length"), V( st_h->client_ctx->payload_size));
|
||||
lsquic_http_headers_t headers = {
|
||||
.count = sizeof(headers_arr) / sizeof(headers_arr[0]),
|
||||
.headers = headers_arr,
|
||||
|
@ -1072,11 +1074,11 @@ hset_dump (const struct hset *hset, FILE *out)
|
|||
const struct hset_elem *el;
|
||||
|
||||
STAILQ_FOREACH(el, hset, next)
|
||||
if (el->xhdr.flags & (LSXPACK_HPACK_IDX|LSXPACK_QPACK_IDX))
|
||||
if (el->xhdr.flags & (LSXPACK_HPACK_VAL_MATCHED|LSXPACK_QPACK_IDX))
|
||||
fprintf(out, "%.*s (%s static table idx %u): %.*s\n",
|
||||
(int) el->xhdr.name_len, lsxpack_header_get_name(&el->xhdr),
|
||||
el->xhdr.flags & LSXPACK_HPACK_IDX ? "hpack" : "qpack",
|
||||
el->xhdr.flags & LSXPACK_HPACK_IDX ? el->xhdr.hpack_index
|
||||
el->xhdr.flags & LSXPACK_HPACK_VAL_MATCHED ? "hpack" : "qpack",
|
||||
el->xhdr.flags & LSXPACK_HPACK_VAL_MATCHED ? el->xhdr.hpack_index
|
||||
: el->xhdr.qpack_index,
|
||||
(int) el->xhdr.val_len, lsxpack_header_get_value(&el->xhdr));
|
||||
else
|
||||
|
@ -1157,7 +1159,6 @@ qif_client_on_new_stream (void *stream_if_ctx, lsquic_stream_t *stream)
|
|||
struct lsxpack_header *header;
|
||||
static int reqno;
|
||||
size_t nalloc;
|
||||
int i;
|
||||
char *end, *tab, *line;
|
||||
char line_buf[0x1000];
|
||||
|
||||
|
@ -1215,20 +1216,11 @@ qif_client_on_new_stream (void *stream_if_ctx, lsquic_stream_t *stream)
|
|||
exit(1);
|
||||
}
|
||||
header = &ctx->headers.headers[ctx->headers.count++];
|
||||
lsxpack_header_set_ptr(header, (void *) ctx->qif_sz, tab - line,
|
||||
(void *) (ctx->qif_sz + (tab - line + 1)), end - tab - 1);
|
||||
|
||||
lsxpack_header_set_offset2(header, ctx->qif_str + ctx->qif_sz, 0,
|
||||
tab - line, tab - line + 1, end - tab - 1);
|
||||
ctx->qif_sz += end + 1 - line;
|
||||
}
|
||||
|
||||
for (i = 0; i < ctx->headers.count; ++i)
|
||||
{
|
||||
ctx->headers.headers[i].buf = ctx->qif_str
|
||||
+ (uintptr_t) ctx->headers.headers[i].buf;
|
||||
ctx->headers.headers[i].name_ptr = ctx->qif_str
|
||||
+ (uintptr_t) ctx->headers.headers[i].name_ptr;
|
||||
}
|
||||
|
||||
lsquic_stream_wantwrite(stream, 1);
|
||||
|
||||
if (!line)
|
||||
|
@ -1426,10 +1418,6 @@ main (int argc, char **argv)
|
|||
client_ctx.hcc_reset_after_nbytes = 0;
|
||||
client_ctx.hcc_retire_cid_after_nbytes = 0;
|
||||
client_ctx.prog = &prog;
|
||||
#ifdef WIN32
|
||||
WSADATA wsd;
|
||||
WSAStartup(MAKEWORD(2, 2), &wsd);
|
||||
#endif
|
||||
|
||||
prog_init(&prog, LSENG_HTTP, &sports, &http_client_if, &client_ctx);
|
||||
|
||||
|
|
|
@ -10,15 +10,20 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <regex.h>
|
||||
#include <netinet/in.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifndef WIN32
|
||||
#include <netinet/in.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#else
|
||||
#include "vc_compat.h"
|
||||
#include "getopt.h"
|
||||
#endif
|
||||
|
||||
#include <event2/event.h>
|
||||
|
||||
#include <openssl/md5.h>
|
||||
|
@ -29,12 +34,243 @@
|
|||
#include "test_common.h"
|
||||
#include "prog.h"
|
||||
|
||||
#if HAVE_REGEX
|
||||
#ifndef WIN32
|
||||
#include <regex.h>
|
||||
#else
|
||||
#include <pcreposix.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "../src/liblsquic/lsquic_logger.h"
|
||||
#include "../src/liblsquic/lsquic_int_types.h"
|
||||
#include "../src/liblsquic/lsquic_util.h"
|
||||
|
||||
static const char on_being_idle[];
|
||||
static const size_t IDLE_SIZE;
|
||||
#if HAVE_REGEX
|
||||
static const char on_being_idle[] =
|
||||
"ON BEING IDLE.\n"
|
||||
"\n"
|
||||
"Now, this is a subject on which I flatter myself I really am _au fait_.\n"
|
||||
"The gentleman who, when I was young, bathed me at wisdom's font for nine\n"
|
||||
"guineas a term--no extras--used to say he never knew a boy who could\n"
|
||||
"do less work in more time; and I remember my poor grandmother once\n"
|
||||
"incidentally observing, in the course of an instruction upon the use\n"
|
||||
"of the Prayer-book, that it was highly improbable that I should ever do\n"
|
||||
"much that I ought not to do, but that she felt convinced beyond a doubt\n"
|
||||
"that I should leave undone pretty well everything that I ought to do.\n"
|
||||
"\n"
|
||||
"I am afraid I have somewhat belied half the dear old lady's prophecy.\n"
|
||||
"Heaven help me! I have done a good many things that I ought not to have\n"
|
||||
"done, in spite of my laziness. But I have fully confirmed the accuracy\n"
|
||||
"of her judgment so far as neglecting much that I ought not to have\n"
|
||||
"neglected is concerned. Idling always has been my strong point. I take\n"
|
||||
"no credit to myself in the matter--it is a gift. Few possess it. There\n"
|
||||
"are plenty of lazy people and plenty of slow-coaches, but a genuine\n"
|
||||
"idler is a rarity. He is not a man who slouches about with his hands in\n"
|
||||
"his pockets. On the contrary, his most startling characteristic is that\n"
|
||||
"he is always intensely busy.\n"
|
||||
"\n"
|
||||
"It is impossible to enjoy idling thoroughly unless one has plenty of\n"
|
||||
"work to do. There is no fun in doing nothing when you have nothing to\n"
|
||||
"do. Wasting time is merely an occupation then, and a most exhausting\n"
|
||||
"one. Idleness, like kisses, to be sweet must be stolen.\n"
|
||||
"\n"
|
||||
"Many years ago, when I was a young man, I was taken very ill--I never\n"
|
||||
"could see myself that much was the matter with me, except that I had\n"
|
||||
"a beastly cold. But I suppose it was something very serious, for the\n"
|
||||
"doctor said that I ought to have come to him a month before, and that\n"
|
||||
"if it (whatever it was) had gone on for another week he would not have\n"
|
||||
"answered for the consequences. It is an extraordinary thing, but I\n"
|
||||
"never knew a doctor called into any case yet but what it transpired\n"
|
||||
"that another day's delay would have rendered cure hopeless. Our medical\n"
|
||||
"guide, philosopher, and friend is like the hero in a melodrama--he\n"
|
||||
"always comes upon the scene just, and only just, in the nick of time. It\n"
|
||||
"is Providence, that is what it is.\n"
|
||||
"\n"
|
||||
"Well, as I was saying, I was very ill and was ordered to Buxton for a\n"
|
||||
"month, with strict injunctions to do nothing whatever all the while\n"
|
||||
"that I was there. \"Rest is what you require,\" said the doctor, \"perfect\n"
|
||||
"rest.\"\n"
|
||||
"\n"
|
||||
"It seemed a delightful prospect. \"This man evidently understands my\n"
|
||||
"complaint,\" said I, and I pictured to myself a glorious time--a four\n"
|
||||
"weeks' _dolce far niente_ with a dash of illness in it. Not too much\n"
|
||||
"illness, but just illness enough--just sufficient to give it the flavor\n"
|
||||
"of suffering and make it poetical. I should get up late, sip chocolate,\n"
|
||||
"and have my breakfast in slippers and a dressing-gown. I should lie out\n"
|
||||
"in the garden in a hammock and read sentimental novels with a melancholy\n"
|
||||
"ending, until the books should fall from my listless hand, and I should\n"
|
||||
"recline there, dreamily gazing into the deep blue of the firmament,\n"
|
||||
"watching the fleecy clouds floating like white-sailed ships across\n"
|
||||
"its depths, and listening to the joyous song of the birds and the low\n"
|
||||
"rustling of the trees. Or, on becoming too weak to go out of doors,\n"
|
||||
"I should sit propped up with pillows at the open window of the\n"
|
||||
"ground-floor front, and look wasted and interesting, so that all the\n"
|
||||
"pretty girls would sigh as they passed by.\n"
|
||||
"\n"
|
||||
"And twice a day I should go down in a Bath chair to the Colonnade to\n"
|
||||
"drink the waters. Oh, those waters! I knew nothing about them then,\n"
|
||||
"and was rather taken with the idea. \"Drinking the waters\" sounded\n"
|
||||
"fashionable and Queen Anne-fied, and I thought I should like them. But,\n"
|
||||
"ugh! after the first three or four mornings! Sam Weller's description of\n"
|
||||
"them as \"having a taste of warm flat-irons\" conveys only a faint idea of\n"
|
||||
"their hideous nauseousness. If anything could make a sick man get well\n"
|
||||
"quickly, it would be the knowledge that he must drink a glassful of them\n"
|
||||
"every day until he was recovered. I drank them neat for six consecutive\n"
|
||||
"days, and they nearly killed me; but after then I adopted the plan of\n"
|
||||
"taking a stiff glass of brandy-and-water immediately on the top of them,\n"
|
||||
"and found much relief thereby. I have been informed since, by various\n"
|
||||
"eminent medical gentlemen, that the alcohol must have entirely\n"
|
||||
"counteracted the effects of the chalybeate properties contained in the\n"
|
||||
"water. I am glad I was lucky enough to hit upon the right thing.\n"
|
||||
"\n"
|
||||
"But \"drinking the waters\" was only a small portion of the torture I\n"
|
||||
"experienced during that memorable month--a month which was, without\n"
|
||||
"exception, the most miserable I have ever spent. During the best part of\n"
|
||||
"it I religiously followed the doctor's mandate and did nothing whatever,\n"
|
||||
"except moon about the house and garden and go out for two hours a day in\n"
|
||||
"a Bath chair. That did break the monotony to a certain extent. There is\n"
|
||||
"more excitement about Bath-chairing--especially if you are not used to\n"
|
||||
"the exhilarating exercise--than might appear to the casual observer. A\n"
|
||||
"sense of danger, such as a mere outsider might not understand, is ever\n"
|
||||
"present to the mind of the occupant. He feels convinced every minute\n"
|
||||
"that the whole concern is going over, a conviction which becomes\n"
|
||||
"especially lively whenever a ditch or a stretch of newly macadamized\n"
|
||||
"road comes in sight. Every vehicle that passes he expects is going to\n"
|
||||
"run into him; and he never finds himself ascending or descending a\n"
|
||||
"hill without immediately beginning to speculate upon his chances,\n"
|
||||
"supposing--as seems extremely probable--that the weak-kneed controller\n"
|
||||
"of his destiny should let go.\n"
|
||||
"\n"
|
||||
"But even this diversion failed to enliven after awhile, and the _ennui_\n"
|
||||
"became perfectly unbearable. I felt my mind giving way under it. It is\n"
|
||||
"not a strong mind, and I thought it would be unwise to tax it too far.\n"
|
||||
"So somewhere about the twentieth morning I got up early, had a good\n"
|
||||
"breakfast, and walked straight off to Hayfield, at the foot of the\n"
|
||||
"Kinder Scout--a pleasant, busy little town, reached through a lovely\n"
|
||||
"valley, and with two sweetly pretty women in it. At least they were\n"
|
||||
"sweetly pretty then; one passed me on the bridge and, I think, smiled;\n"
|
||||
"and the other was standing at an open door, making an unremunerative\n"
|
||||
"investment of kisses upon a red-faced baby. But it is years ago, and I\n"
|
||||
"dare say they have both grown stout and snappish since that time.\n"
|
||||
"Coming back, I saw an old man breaking stones, and it roused such strong\n"
|
||||
"longing in me to use my arms that I offered him a drink to let me take\n"
|
||||
"his place. He was a kindly old man and he humored me. I went for those\n"
|
||||
"stones with the accumulated energy of three weeks, and did more work in\n"
|
||||
"half an hour than he had done all day. But it did not make him jealous.\n"
|
||||
"\n"
|
||||
"Having taken the plunge, I went further and further into dissipation,\n"
|
||||
"going out for a long walk every morning and listening to the band in\n"
|
||||
"the pavilion every evening. But the days still passed slowly\n"
|
||||
"notwithstanding, and I was heartily glad when the last one came and I\n"
|
||||
"was being whirled away from gouty, consumptive Buxton to London with its\n"
|
||||
"stern work and life. I looked out of the carriage as we rushed through\n"
|
||||
"Hendon in the evening. The lurid glare overhanging the mighty city\n"
|
||||
"seemed to warm my heart, and when, later on, my cab rattled out of St.\n"
|
||||
"Pancras' station, the old familiar roar that came swelling up around me\n"
|
||||
"sounded the sweetest music I had heard for many a long day.\n"
|
||||
"\n"
|
||||
"I certainly did not enjoy that month's idling. I like idling when I\n"
|
||||
"ought not to be idling; not when it is the only thing I have to do. That\n"
|
||||
"is my pig-headed nature. The time when I like best to stand with my\n"
|
||||
"back to the fire, calculating how much I owe, is when my desk is heaped\n"
|
||||
"highest with letters that must be answered by the next post. When I like\n"
|
||||
"to dawdle longest over my dinner is when I have a heavy evening's work\n"
|
||||
"before me. And if, for some urgent reason, I ought to be up particularly\n"
|
||||
"early in the morning, it is then, more than at any other time, that I\n"
|
||||
"love to lie an extra half-hour in bed.\n"
|
||||
"\n"
|
||||
"Ah! how delicious it is to turn over and go to sleep again: \"just for\n"
|
||||
"five minutes.\" Is there any human being, I wonder, besides the hero of\n"
|
||||
"a Sunday-school \"tale for boys,\" who ever gets up willingly? There\n"
|
||||
"are some men to whom getting up at the proper time is an utter\n"
|
||||
"impossibility. If eight o'clock happens to be the time that they should\n"
|
||||
"turn out, then they lie till half-past. If circumstances change and\n"
|
||||
"half-past eight becomes early enough for them, then it is nine before\n"
|
||||
"they can rise. They are like the statesman of whom it was said that he\n"
|
||||
"was always punctually half an hour late. They try all manner of schemes.\n"
|
||||
"They buy alarm-clocks (artful contrivances that go off at the wrong time\n"
|
||||
"and alarm the wrong people). They tell Sarah Jane to knock at the door\n"
|
||||
"and call them, and Sarah Jane does knock at the door and does call them,\n"
|
||||
"and they grunt back \"awri\" and then go comfortably to sleep again. I\n"
|
||||
"knew one man who would actually get out and have a cold bath; and even\n"
|
||||
"that was of no use, for afterward he would jump into bed again to warm\n"
|
||||
"himself.\n"
|
||||
"\n"
|
||||
"I think myself that I could keep out of bed all right if I once got\n"
|
||||
"out. It is the wrenching away of the head from the pillow that I find so\n"
|
||||
"hard, and no amount of over-night determination makes it easier. I say\n"
|
||||
"to myself, after having wasted the whole evening, \"Well, I won't do\n"
|
||||
"any more work to-night; I'll get up early to-morrow morning;\" and I am\n"
|
||||
"thoroughly resolved to do so--then. In the morning, however, I feel less\n"
|
||||
"enthusiastic about the idea, and reflect that it would have been much\n"
|
||||
"better if I had stopped up last night. And then there is the trouble of\n"
|
||||
"dressing, and the more one thinks about that the more one wants to put\n"
|
||||
"it off.\n"
|
||||
"\n"
|
||||
"It is a strange thing this bed, this mimic grave, where we stretch our\n"
|
||||
"tired limbs and sink away so quietly into the silence and rest. \"O bed,\n"
|
||||
"O bed, delicious bed, that heaven on earth to the weary head,\" as sang\n"
|
||||
"poor Hood, you are a kind old nurse to us fretful boys and girls. Clever\n"
|
||||
"and foolish, naughty and good, you take us all in your motherly lap and\n"
|
||||
"hush our wayward crying. The strong man full of care--the sick man\n"
|
||||
"full of pain--the little maiden sobbing for her faithless lover--like\n"
|
||||
"children we lay our aching heads on your white bosom, and you gently\n"
|
||||
"soothe us off to by-by.\n"
|
||||
"\n"
|
||||
"Our trouble is sore indeed when you turn away and will not comfort us.\n"
|
||||
"How long the dawn seems coming when we cannot sleep! Oh! those hideous\n"
|
||||
"nights when we toss and turn in fever and pain, when we lie, like living\n"
|
||||
"men among the dead, staring out into the dark hours that drift so slowly\n"
|
||||
"between us and the light. And oh! those still more hideous nights when\n"
|
||||
"we sit by another in pain, when the low fire startles us every now and\n"
|
||||
"then with a falling cinder, and the tick of the clock seems a hammer\n"
|
||||
"beating out the life that we are watching.\n"
|
||||
"\n"
|
||||
"But enough of beds and bedrooms. I have kept to them too long, even for\n"
|
||||
"an idle fellow. Let us come out and have a smoke. That wastes time just\n"
|
||||
"as well and does not look so bad. Tobacco has been a blessing to us\n"
|
||||
"idlers. What the civil-service clerk before Sir Walter's time found\n"
|
||||
"to occupy their minds with it is hard to imagine. I attribute the\n"
|
||||
"quarrelsome nature of the Middle Ages young men entirely to the want of\n"
|
||||
"the soothing weed. They had no work to do and could not smoke, and\n"
|
||||
"the consequence was they were forever fighting and rowing. If, by any\n"
|
||||
"extraordinary chance, there was no war going, then they got up a deadly\n"
|
||||
"family feud with the next-door neighbor, and if, in spite of this, they\n"
|
||||
"still had a few spare moments on their hands, they occupied them with\n"
|
||||
"discussions as to whose sweetheart was the best looking, the arguments\n"
|
||||
"employed on both sides being battle-axes, clubs, etc. Questions of taste\n"
|
||||
"were soon decided in those days. When a twelfth-century youth fell in\n"
|
||||
"love he did not take three paces backward, gaze into her eyes, and tell\n"
|
||||
"her she was too beautiful to live. He said he would step outside and see\n"
|
||||
"about it. And if, when he got out, he met a man and broke his head--the\n"
|
||||
"other man's head, I mean--then that proved that his--the first\n"
|
||||
"fellow's--girl was a pretty girl. But if the other fellow broke _his_\n"
|
||||
"head--not his own, you know, but the other fellow's--the other fellow\n"
|
||||
"to the second fellow, that is, because of course the other fellow would\n"
|
||||
"only be the other fellow to him, not the first fellow who--well, if he\n"
|
||||
"broke his head, then _his_ girl--not the other fellow's, but the fellow\n"
|
||||
"who _was_ the--Look here, if A broke B's head, then A's girl was a\n"
|
||||
"pretty girl; but if B broke A's head, then A's girl wasn't a pretty\n"
|
||||
"girl, but B's girl was. That was their method of conducting art\n"
|
||||
"criticism.\n"
|
||||
"\n"
|
||||
"Nowadays we light a pipe and let the girls fight it out among\n"
|
||||
"themselves.\n"
|
||||
"\n"
|
||||
"They do it very well. They are getting to do all our work. They are\n"
|
||||
"doctors, and barristers, and artists. They manage theaters, and promote\n"
|
||||
"swindles, and edit newspapers. I am looking forward to the time when we\n"
|
||||
"men shall have nothing to do but lie in bed till twelve, read two novels\n"
|
||||
"a day, have nice little five-o'clock teas all to ourselves, and tax\n"
|
||||
"our brains with nothing more trying than discussions upon the latest\n"
|
||||
"patterns in trousers and arguments as to what Mr. Jones' coat was\n"
|
||||
"made of and whether it fitted him. It is a glorious prospect--for idle\n"
|
||||
"fellows.\n"
|
||||
"\n\n\n"
|
||||
;
|
||||
static const size_t IDLE_SIZE = sizeof(on_being_idle) - 1;
|
||||
#endif
|
||||
|
||||
/* This is the "LSWS" mode: first write is performed immediately, outside
|
||||
* of the on_write() callback. This makes it possible to play with buffered
|
||||
|
@ -43,11 +279,13 @@ static const size_t IDLE_SIZE;
|
|||
static int s_immediate_write;
|
||||
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define V(v) (v), strlen(v)
|
||||
|
||||
struct lsquic_conn_ctx;
|
||||
|
||||
static void interop_server_hset_destroy (void *);
|
||||
|
||||
|
||||
struct server_ctx {
|
||||
struct lsquic_conn_ctx *conn_h;
|
||||
lsquic_engine_t *engine;
|
||||
|
@ -278,12 +516,14 @@ static int
|
|||
send_headers (struct lsquic_stream *stream, lsquic_stream_ctx_t *st_h)
|
||||
{
|
||||
const char *content_type;
|
||||
struct header_buf hbuf;
|
||||
|
||||
content_type = select_content_type(st_h);
|
||||
struct lsxpack_header headers_arr[2];
|
||||
|
||||
lsxpack_header_set_ptr(&headers_arr[0], ":status", 7, "200", 3);
|
||||
lsxpack_header_set_ptr(&headers_arr[1], "content-type", 12,
|
||||
hbuf.off = 0;
|
||||
header_set_ptr(&headers_arr[0], &hbuf, ":status", 7, "200", 3);
|
||||
header_set_ptr(&headers_arr[1], &hbuf, "content-type", 12,
|
||||
content_type, strlen(content_type));
|
||||
lsquic_http_headers_t headers = {
|
||||
.count = sizeof(headers_arr) / sizeof(headers_arr[0]),
|
||||
|
@ -301,7 +541,7 @@ send_headers (struct lsquic_stream *stream, lsquic_stream_ctx_t *st_h)
|
|||
|
||||
|
||||
static void
|
||||
resume_response (int fd, short what, void *arg)
|
||||
resume_response (evutil_socket_t fd, short what, void *arg)
|
||||
{
|
||||
struct lsquic_stream_ctx *const st_h = arg;
|
||||
|
||||
|
@ -551,6 +791,7 @@ push_promise (lsquic_stream_ctx_t *st_h, lsquic_stream_t *stream)
|
|||
regex_t re;
|
||||
regmatch_t matches[2];
|
||||
struct hset_fm *hfm;
|
||||
struct header_buf hbuf;
|
||||
|
||||
s = regcomp(&re, "\r\nHost: *([[:alnum:].][[:alnum:].]*)\r\n",
|
||||
REG_EXTENDED|REG_ICASE);
|
||||
|
@ -577,16 +818,17 @@ push_promise (lsquic_stream_ctx_t *st_h, lsquic_stream_t *stream)
|
|||
}
|
||||
|
||||
#define V(v) (v), strlen(v)
|
||||
hbuf.off = 0;
|
||||
struct lsxpack_header headers_arr[6];
|
||||
lsxpack_header_set_ptr(&headers_arr[0], V(":method"), V("GET"));
|
||||
lsxpack_header_set_ptr(&headers_arr[1], V(":path"),
|
||||
header_set_ptr(&headers_arr[0], &hbuf, V(":method"), V("GET"));
|
||||
header_set_ptr(&headers_arr[1], &hbuf, V(":path"),
|
||||
V(st_h->server_ctx->push_path));
|
||||
lsxpack_header_set_ptr(&headers_arr[2], V(":authority"),
|
||||
header_set_ptr(&headers_arr[2], &hbuf, V(":authority"),
|
||||
st_h->req_buf + matches[1].rm_so, matches[1].rm_eo - matches[1].rm_so);
|
||||
lsxpack_header_set_ptr(&headers_arr[3], V(":scheme"), V("https"));
|
||||
lsxpack_header_set_ptr(&headers_arr[4], V("x-some-header"),
|
||||
header_set_ptr(&headers_arr[3], &hbuf, V(":scheme"), V("https"));
|
||||
header_set_ptr(&headers_arr[4], &hbuf, V("x-some-header"),
|
||||
V("x-some-value"));
|
||||
lsxpack_header_set_ptr(&headers_arr[5], V("x-kenny-status"),
|
||||
header_set_ptr(&headers_arr[5], &hbuf, V("x-kenny-status"),
|
||||
V("Oh my God! They killed Kenny!!! You bastards!"));
|
||||
lsquic_http_headers_t headers = {
|
||||
.count = sizeof(headers_arr) / sizeof(headers_arr[0]),
|
||||
|
@ -605,7 +847,6 @@ push_promise (lsquic_stream_ctx_t *st_h, lsquic_stream_t *stream)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
|
@ -641,7 +882,6 @@ static void
|
|||
http_server_on_read_regular (struct lsquic_stream *stream,
|
||||
lsquic_stream_ctx_t *st_h)
|
||||
{
|
||||
#if HAVE_OPEN_MEMSTREAM
|
||||
unsigned char buf[0x400];
|
||||
ssize_t nread;
|
||||
int s;
|
||||
|
@ -674,20 +914,22 @@ http_server_on_read_regular (struct lsquic_stream *stream,
|
|||
LSQ_ERROR("error reading: %s", strerror(errno));
|
||||
lsquic_stream_close(stream);
|
||||
}
|
||||
#else
|
||||
LSQ_ERROR("%s: open_memstream not supported\n", __func__);
|
||||
exit(1);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
http_server_on_read (struct lsquic_stream *stream, lsquic_stream_ctx_t *st_h)
|
||||
{
|
||||
#if HAVE_OPEN_MEMSTREAM
|
||||
if (lsquic_stream_is_pushed(stream))
|
||||
http_server_on_read_pushed(stream, st_h);
|
||||
else
|
||||
http_server_on_read_regular(stream, st_h);
|
||||
#else
|
||||
LSQ_ERROR("%s: open_memstream not supported\n", __func__);
|
||||
exit(1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -716,6 +958,7 @@ const struct lsquic_stream_if http_server_if = {
|
|||
};
|
||||
|
||||
|
||||
#if HAVE_REGEX
|
||||
struct req_map
|
||||
{
|
||||
enum method method;
|
||||
|
@ -848,12 +1091,12 @@ read_md5 (void *ctx, const unsigned char *buf, size_t sz, int fin)
|
|||
static void
|
||||
http_server_interop_on_read (lsquic_stream_t *stream, lsquic_stream_ctx_t *st_h)
|
||||
{
|
||||
#define ERROR_RESP(code, args...) do { \
|
||||
LSQ_WARN(args); \
|
||||
#define ERROR_RESP(code, ...) do { \
|
||||
LSQ_WARN(__VA_ARGS__); \
|
||||
st_h->interop_handler = IOH_ERROR; \
|
||||
st_h->resp_status = #code; \
|
||||
st_h->interop_u.err.resp.sz = snprintf(st_h->interop_u.err.buf, \
|
||||
sizeof(st_h->interop_u.err.buf), args); \
|
||||
sizeof(st_h->interop_u.err.buf), __VA_ARGS__); \
|
||||
if (st_h->interop_u.err.resp.sz >= sizeof(st_h->interop_u.err.buf)) \
|
||||
st_h->interop_u.err.resp.sz = sizeof(st_h->interop_u.err.buf) - 1; \
|
||||
st_h->interop_u.err.resp.buf = st_h->interop_u.err.buf; \
|
||||
|
@ -1047,14 +1290,16 @@ send_headers2 (struct lsquic_stream *stream, struct lsquic_stream_ctx *st_h,
|
|||
size_t content_len)
|
||||
{
|
||||
char clbuf[0x20];
|
||||
struct header_buf hbuf;
|
||||
|
||||
snprintf(clbuf, sizeof(clbuf), "%zd", content_len);
|
||||
|
||||
hbuf.off = 0;
|
||||
struct lsxpack_header headers_arr[4];
|
||||
lsxpack_header_set_ptr(&headers_arr[0], V(":status"), V(st_h->resp_status));
|
||||
lsxpack_header_set_ptr(&headers_arr[1], V("server"), V(LITESPEED_ID));
|
||||
lsxpack_header_set_ptr(&headers_arr[2], V("content-type"), V("text/html"));
|
||||
lsxpack_header_set_ptr(&headers_arr[3], V("content-length"), V(clbuf));
|
||||
header_set_ptr(&headers_arr[0], &hbuf, V(":status"), V(st_h->resp_status));
|
||||
header_set_ptr(&headers_arr[1], &hbuf, V("server"), V(LITESPEED_ID));
|
||||
header_set_ptr(&headers_arr[2], &hbuf, V("content-type"), V("text/html"));
|
||||
header_set_ptr(&headers_arr[3], &hbuf, V("content-length"), V(clbuf));
|
||||
lsquic_http_headers_t headers = {
|
||||
.count = sizeof(headers_arr) / sizeof(headers_arr[0]),
|
||||
.headers = headers_arr,
|
||||
|
@ -1070,7 +1315,7 @@ idle_read (void *lsqr_ctx, void *buf, size_t count)
|
|||
{
|
||||
struct gen_file_ctx *const gfc = lsqr_ctx;
|
||||
unsigned char *p = buf;
|
||||
unsigned char *const end = buf + count;
|
||||
unsigned char *const end = p + count;
|
||||
size_t towrite;
|
||||
|
||||
while (p < end && gfc->remain > 0)
|
||||
|
@ -1133,6 +1378,7 @@ idle_on_write (lsquic_stream_t *stream, lsquic_stream_ctx_t *st_h)
|
|||
struct lsquic_http_headers headers;
|
||||
struct req *req;
|
||||
ssize_t nw;
|
||||
struct header_buf hbuf;
|
||||
|
||||
if (st_h->flags & SH_HEADERS_SENT)
|
||||
{
|
||||
|
@ -1158,10 +1404,11 @@ idle_on_write (lsquic_stream_t *stream, lsquic_stream_ctx_t *st_h)
|
|||
{
|
||||
STAILQ_REMOVE_HEAD(&gfc->push_paths, next);
|
||||
LSQ_DEBUG("pushing promise for %s", push_path->path);
|
||||
lsxpack_header_set_ptr(&header_arr[0], V(":method"), V("GET"));
|
||||
lsxpack_header_set_ptr(&header_arr[1], V(":path"), V(push_path->path));
|
||||
lsxpack_header_set_ptr(&header_arr[2], V(":authority"), V(st_h->req->authority_str));
|
||||
lsxpack_header_set_ptr(&header_arr[3], V(":scheme"), V("https"));
|
||||
hbuf.off = 0;
|
||||
header_set_ptr(&header_arr[0], &hbuf, V(":method"), V("GET"));
|
||||
header_set_ptr(&header_arr[1], &hbuf, V(":path"), V(push_path->path));
|
||||
header_set_ptr(&header_arr[2], &hbuf, V(":authority"), V(st_h->req->authority_str));
|
||||
header_set_ptr(&header_arr[3], &hbuf, V(":scheme"), V("https"));
|
||||
headers.headers = header_arr;
|
||||
headers.count = sizeof(header_arr) / sizeof(header_arr[0]);
|
||||
req = new_req(GET, push_path->path, st_h->req->authority_str);
|
||||
|
@ -1243,6 +1490,7 @@ const struct lsquic_stream_if interop_http_server_if = {
|
|||
.on_write = http_server_interop_on_write,
|
||||
.on_close = http_server_on_close,
|
||||
};
|
||||
#endif /* HAVE_REGEX */
|
||||
|
||||
|
||||
static void
|
||||
|
@ -1308,6 +1556,23 @@ interop_server_hset_prepare_decode (void *hset_p, struct lsxpack_header *xhdr,
|
|||
}
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
char *
|
||||
strndup (const char *s, size_t n)
|
||||
{
|
||||
char *copy;
|
||||
|
||||
copy = malloc(n + 1);
|
||||
if (!copy)
|
||||
return NULL;
|
||||
|
||||
memcpy(copy, s, n);
|
||||
copy[n] = '\0';
|
||||
return copy;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static int
|
||||
interop_server_hset_add_header (void *hset_p, struct lsxpack_header *xhdr)
|
||||
{
|
||||
|
@ -1403,6 +1668,11 @@ main (int argc, char **argv)
|
|||
struct server_ctx server_ctx;
|
||||
struct prog prog;
|
||||
|
||||
#if !(HAVE_OPEN_MEMSTREAM || HAVE_REGEX)
|
||||
fprintf(stderr, "cannot run server without regex or open_memstream\n");
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
memset(&server_ctx, 0, sizeof(server_ctx));
|
||||
TAILQ_INIT(&server_ctx.sports);
|
||||
server_ctx.prog = &prog;
|
||||
|
@ -1425,11 +1695,13 @@ main (int argc, char **argv)
|
|||
perror("stat");
|
||||
exit(2);
|
||||
}
|
||||
#ifndef WIN32
|
||||
if (!S_ISDIR(st.st_mode))
|
||||
{
|
||||
fprintf(stderr, "`%s' is not a directory\n", optarg);
|
||||
exit(2);
|
||||
}
|
||||
#endif
|
||||
server_ctx.document_root = optarg;
|
||||
break;
|
||||
case 'w':
|
||||
|
@ -1450,11 +1722,16 @@ main (int argc, char **argv)
|
|||
|
||||
if (!server_ctx.document_root)
|
||||
{
|
||||
#if HAVE_REGEX
|
||||
LSQ_NOTICE("Document root is not set: start in Interop Mode");
|
||||
init_map_regexes();
|
||||
prog.prog_api.ea_stream_if = &interop_http_server_if;
|
||||
prog.prog_api.ea_hsi_if = &header_bypass_api;
|
||||
prog.prog_api.ea_hsi_ctx = NULL;
|
||||
#else
|
||||
LSQ_ERROR("Document root is not set: use -r option");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (0 != prog_prep(&prog))
|
||||
|
@ -1468,233 +1745,10 @@ main (int argc, char **argv)
|
|||
s = prog_run(&prog);
|
||||
prog_cleanup(&prog);
|
||||
|
||||
#if HAVE_REGEX
|
||||
if (!server_ctx.document_root)
|
||||
free_map_regexes();
|
||||
#endif
|
||||
|
||||
exit(0 == s ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
static const char on_being_idle[] =
|
||||
"ON BEING IDLE.\n"
|
||||
"\n"
|
||||
"Now, this is a subject on which I flatter myself I really am _au fait_.\n"
|
||||
"The gentleman who, when I was young, bathed me at wisdom's font for nine\n"
|
||||
"guineas a term--no extras--used to say he never knew a boy who could\n"
|
||||
"do less work in more time; and I remember my poor grandmother once\n"
|
||||
"incidentally observing, in the course of an instruction upon the use\n"
|
||||
"of the Prayer-book, that it was highly improbable that I should ever do\n"
|
||||
"much that I ought not to do, but that she felt convinced beyond a doubt\n"
|
||||
"that I should leave undone pretty well everything that I ought to do.\n"
|
||||
"\n"
|
||||
"I am afraid I have somewhat belied half the dear old lady's prophecy.\n"
|
||||
"Heaven help me! I have done a good many things that I ought not to have\n"
|
||||
"done, in spite of my laziness. But I have fully confirmed the accuracy\n"
|
||||
"of her judgment so far as neglecting much that I ought not to have\n"
|
||||
"neglected is concerned. Idling always has been my strong point. I take\n"
|
||||
"no credit to myself in the matter--it is a gift. Few possess it. There\n"
|
||||
"are plenty of lazy people and plenty of slow-coaches, but a genuine\n"
|
||||
"idler is a rarity. He is not a man who slouches about with his hands in\n"
|
||||
"his pockets. On the contrary, his most startling characteristic is that\n"
|
||||
"he is always intensely busy.\n"
|
||||
"\n"
|
||||
"It is impossible to enjoy idling thoroughly unless one has plenty of\n"
|
||||
"work to do. There is no fun in doing nothing when you have nothing to\n"
|
||||
"do. Wasting time is merely an occupation then, and a most exhausting\n"
|
||||
"one. Idleness, like kisses, to be sweet must be stolen.\n"
|
||||
"\n"
|
||||
"Many years ago, when I was a young man, I was taken very ill--I never\n"
|
||||
"could see myself that much was the matter with me, except that I had\n"
|
||||
"a beastly cold. But I suppose it was something very serious, for the\n"
|
||||
"doctor said that I ought to have come to him a month before, and that\n"
|
||||
"if it (whatever it was) had gone on for another week he would not have\n"
|
||||
"answered for the consequences. It is an extraordinary thing, but I\n"
|
||||
"never knew a doctor called into any case yet but what it transpired\n"
|
||||
"that another day's delay would have rendered cure hopeless. Our medical\n"
|
||||
"guide, philosopher, and friend is like the hero in a melodrama--he\n"
|
||||
"always comes upon the scene just, and only just, in the nick of time. It\n"
|
||||
"is Providence, that is what it is.\n"
|
||||
"\n"
|
||||
"Well, as I was saying, I was very ill and was ordered to Buxton for a\n"
|
||||
"month, with strict injunctions to do nothing whatever all the while\n"
|
||||
"that I was there. \"Rest is what you require,\" said the doctor, \"perfect\n"
|
||||
"rest.\"\n"
|
||||
"\n"
|
||||
"It seemed a delightful prospect. \"This man evidently understands my\n"
|
||||
"complaint,\" said I, and I pictured to myself a glorious time--a four\n"
|
||||
"weeks' _dolce far niente_ with a dash of illness in it. Not too much\n"
|
||||
"illness, but just illness enough--just sufficient to give it the flavor\n"
|
||||
"of suffering and make it poetical. I should get up late, sip chocolate,\n"
|
||||
"and have my breakfast in slippers and a dressing-gown. I should lie out\n"
|
||||
"in the garden in a hammock and read sentimental novels with a melancholy\n"
|
||||
"ending, until the books should fall from my listless hand, and I should\n"
|
||||
"recline there, dreamily gazing into the deep blue of the firmament,\n"
|
||||
"watching the fleecy clouds floating like white-sailed ships across\n"
|
||||
"its depths, and listening to the joyous song of the birds and the low\n"
|
||||
"rustling of the trees. Or, on becoming too weak to go out of doors,\n"
|
||||
"I should sit propped up with pillows at the open window of the\n"
|
||||
"ground-floor front, and look wasted and interesting, so that all the\n"
|
||||
"pretty girls would sigh as they passed by.\n"
|
||||
"\n"
|
||||
"And twice a day I should go down in a Bath chair to the Colonnade to\n"
|
||||
"drink the waters. Oh, those waters! I knew nothing about them then,\n"
|
||||
"and was rather taken with the idea. \"Drinking the waters\" sounded\n"
|
||||
"fashionable and Queen Anne-fied, and I thought I should like them. But,\n"
|
||||
"ugh! after the first three or four mornings! Sam Weller's description of\n"
|
||||
"them as \"having a taste of warm flat-irons\" conveys only a faint idea of\n"
|
||||
"their hideous nauseousness. If anything could make a sick man get well\n"
|
||||
"quickly, it would be the knowledge that he must drink a glassful of them\n"
|
||||
"every day until he was recovered. I drank them neat for six consecutive\n"
|
||||
"days, and they nearly killed me; but after then I adopted the plan of\n"
|
||||
"taking a stiff glass of brandy-and-water immediately on the top of them,\n"
|
||||
"and found much relief thereby. I have been informed since, by various\n"
|
||||
"eminent medical gentlemen, that the alcohol must have entirely\n"
|
||||
"counteracted the effects of the chalybeate properties contained in the\n"
|
||||
"water. I am glad I was lucky enough to hit upon the right thing.\n"
|
||||
"\n"
|
||||
"But \"drinking the waters\" was only a small portion of the torture I\n"
|
||||
"experienced during that memorable month--a month which was, without\n"
|
||||
"exception, the most miserable I have ever spent. During the best part of\n"
|
||||
"it I religiously followed the doctor's mandate and did nothing whatever,\n"
|
||||
"except moon about the house and garden and go out for two hours a day in\n"
|
||||
"a Bath chair. That did break the monotony to a certain extent. There is\n"
|
||||
"more excitement about Bath-chairing--especially if you are not used to\n"
|
||||
"the exhilarating exercise--than might appear to the casual observer. A\n"
|
||||
"sense of danger, such as a mere outsider might not understand, is ever\n"
|
||||
"present to the mind of the occupant. He feels convinced every minute\n"
|
||||
"that the whole concern is going over, a conviction which becomes\n"
|
||||
"especially lively whenever a ditch or a stretch of newly macadamized\n"
|
||||
"road comes in sight. Every vehicle that passes he expects is going to\n"
|
||||
"run into him; and he never finds himself ascending or descending a\n"
|
||||
"hill without immediately beginning to speculate upon his chances,\n"
|
||||
"supposing--as seems extremely probable--that the weak-kneed controller\n"
|
||||
"of his destiny should let go.\n"
|
||||
"\n"
|
||||
"But even this diversion failed to enliven after awhile, and the _ennui_\n"
|
||||
"became perfectly unbearable. I felt my mind giving way under it. It is\n"
|
||||
"not a strong mind, and I thought it would be unwise to tax it too far.\n"
|
||||
"So somewhere about the twentieth morning I got up early, had a good\n"
|
||||
"breakfast, and walked straight off to Hayfield, at the foot of the\n"
|
||||
"Kinder Scout--a pleasant, busy little town, reached through a lovely\n"
|
||||
"valley, and with two sweetly pretty women in it. At least they were\n"
|
||||
"sweetly pretty then; one passed me on the bridge and, I think, smiled;\n"
|
||||
"and the other was standing at an open door, making an unremunerative\n"
|
||||
"investment of kisses upon a red-faced baby. But it is years ago, and I\n"
|
||||
"dare say they have both grown stout and snappish since that time.\n"
|
||||
"Coming back, I saw an old man breaking stones, and it roused such strong\n"
|
||||
"longing in me to use my arms that I offered him a drink to let me take\n"
|
||||
"his place. He was a kindly old man and he humored me. I went for those\n"
|
||||
"stones with the accumulated energy of three weeks, and did more work in\n"
|
||||
"half an hour than he had done all day. But it did not make him jealous.\n"
|
||||
"\n"
|
||||
"Having taken the plunge, I went further and further into dissipation,\n"
|
||||
"going out for a long walk every morning and listening to the band in\n"
|
||||
"the pavilion every evening. But the days still passed slowly\n"
|
||||
"notwithstanding, and I was heartily glad when the last one came and I\n"
|
||||
"was being whirled away from gouty, consumptive Buxton to London with its\n"
|
||||
"stern work and life. I looked out of the carriage as we rushed through\n"
|
||||
"Hendon in the evening. The lurid glare overhanging the mighty city\n"
|
||||
"seemed to warm my heart, and when, later on, my cab rattled out of St.\n"
|
||||
"Pancras' station, the old familiar roar that came swelling up around me\n"
|
||||
"sounded the sweetest music I had heard for many a long day.\n"
|
||||
"\n"
|
||||
"I certainly did not enjoy that month's idling. I like idling when I\n"
|
||||
"ought not to be idling; not when it is the only thing I have to do. That\n"
|
||||
"is my pig-headed nature. The time when I like best to stand with my\n"
|
||||
"back to the fire, calculating how much I owe, is when my desk is heaped\n"
|
||||
"highest with letters that must be answered by the next post. When I like\n"
|
||||
"to dawdle longest over my dinner is when I have a heavy evening's work\n"
|
||||
"before me. And if, for some urgent reason, I ought to be up particularly\n"
|
||||
"early in the morning, it is then, more than at any other time, that I\n"
|
||||
"love to lie an extra half-hour in bed.\n"
|
||||
"\n"
|
||||
"Ah! how delicious it is to turn over and go to sleep again: \"just for\n"
|
||||
"five minutes.\" Is there any human being, I wonder, besides the hero of\n"
|
||||
"a Sunday-school \"tale for boys,\" who ever gets up willingly? There\n"
|
||||
"are some men to whom getting up at the proper time is an utter\n"
|
||||
"impossibility. If eight o'clock happens to be the time that they should\n"
|
||||
"turn out, then they lie till half-past. If circumstances change and\n"
|
||||
"half-past eight becomes early enough for them, then it is nine before\n"
|
||||
"they can rise. They are like the statesman of whom it was said that he\n"
|
||||
"was always punctually half an hour late. They try all manner of schemes.\n"
|
||||
"They buy alarm-clocks (artful contrivances that go off at the wrong time\n"
|
||||
"and alarm the wrong people). They tell Sarah Jane to knock at the door\n"
|
||||
"and call them, and Sarah Jane does knock at the door and does call them,\n"
|
||||
"and they grunt back \"awri\" and then go comfortably to sleep again. I\n"
|
||||
"knew one man who would actually get out and have a cold bath; and even\n"
|
||||
"that was of no use, for afterward he would jump into bed again to warm\n"
|
||||
"himself.\n"
|
||||
"\n"
|
||||
"I think myself that I could keep out of bed all right if I once got\n"
|
||||
"out. It is the wrenching away of the head from the pillow that I find so\n"
|
||||
"hard, and no amount of over-night determination makes it easier. I say\n"
|
||||
"to myself, after having wasted the whole evening, \"Well, I won't do\n"
|
||||
"any more work to-night; I'll get up early to-morrow morning;\" and I am\n"
|
||||
"thoroughly resolved to do so--then. In the morning, however, I feel less\n"
|
||||
"enthusiastic about the idea, and reflect that it would have been much\n"
|
||||
"better if I had stopped up last night. And then there is the trouble of\n"
|
||||
"dressing, and the more one thinks about that the more one wants to put\n"
|
||||
"it off.\n"
|
||||
"\n"
|
||||
"It is a strange thing this bed, this mimic grave, where we stretch our\n"
|
||||
"tired limbs and sink away so quietly into the silence and rest. \"O bed,\n"
|
||||
"O bed, delicious bed, that heaven on earth to the weary head,\" as sang\n"
|
||||
"poor Hood, you are a kind old nurse to us fretful boys and girls. Clever\n"
|
||||
"and foolish, naughty and good, you take us all in your motherly lap and\n"
|
||||
"hush our wayward crying. The strong man full of care--the sick man\n"
|
||||
"full of pain--the little maiden sobbing for her faithless lover--like\n"
|
||||
"children we lay our aching heads on your white bosom, and you gently\n"
|
||||
"soothe us off to by-by.\n"
|
||||
"\n"
|
||||
"Our trouble is sore indeed when you turn away and will not comfort us.\n"
|
||||
"How long the dawn seems coming when we cannot sleep! Oh! those hideous\n"
|
||||
"nights when we toss and turn in fever and pain, when we lie, like living\n"
|
||||
"men among the dead, staring out into the dark hours that drift so slowly\n"
|
||||
"between us and the light. And oh! those still more hideous nights when\n"
|
||||
"we sit by another in pain, when the low fire startles us every now and\n"
|
||||
"then with a falling cinder, and the tick of the clock seems a hammer\n"
|
||||
"beating out the life that we are watching.\n"
|
||||
"\n"
|
||||
"But enough of beds and bedrooms. I have kept to them too long, even for\n"
|
||||
"an idle fellow. Let us come out and have a smoke. That wastes time just\n"
|
||||
"as well and does not look so bad. Tobacco has been a blessing to us\n"
|
||||
"idlers. What the civil-service clerk before Sir Walter's time found\n"
|
||||
"to occupy their minds with it is hard to imagine. I attribute the\n"
|
||||
"quarrelsome nature of the Middle Ages young men entirely to the want of\n"
|
||||
"the soothing weed. They had no work to do and could not smoke, and\n"
|
||||
"the consequence was they were forever fighting and rowing. If, by any\n"
|
||||
"extraordinary chance, there was no war going, then they got up a deadly\n"
|
||||
"family feud with the next-door neighbor, and if, in spite of this, they\n"
|
||||
"still had a few spare moments on their hands, they occupied them with\n"
|
||||
"discussions as to whose sweetheart was the best looking, the arguments\n"
|
||||
"employed on both sides being battle-axes, clubs, etc. Questions of taste\n"
|
||||
"were soon decided in those days. When a twelfth-century youth fell in\n"
|
||||
"love he did not take three paces backward, gaze into her eyes, and tell\n"
|
||||
"her she was too beautiful to live. He said he would step outside and see\n"
|
||||
"about it. And if, when he got out, he met a man and broke his head--the\n"
|
||||
"other man's head, I mean--then that proved that his--the first\n"
|
||||
"fellow's--girl was a pretty girl. But if the other fellow broke _his_\n"
|
||||
"head--not his own, you know, but the other fellow's--the other fellow\n"
|
||||
"to the second fellow, that is, because of course the other fellow would\n"
|
||||
"only be the other fellow to him, not the first fellow who--well, if he\n"
|
||||
"broke his head, then _his_ girl--not the other fellow's, but the fellow\n"
|
||||
"who _was_ the--Look here, if A broke B's head, then A's girl was a\n"
|
||||
"pretty girl; but if B broke A's head, then A's girl wasn't a pretty\n"
|
||||
"girl, but B's girl was. That was their method of conducting art\n"
|
||||
"criticism.\n"
|
||||
"\n"
|
||||
"Nowadays we light a pipe and let the girls fight it out among\n"
|
||||
"themselves.\n"
|
||||
"\n"
|
||||
"They do it very well. They are getting to do all our work. They are\n"
|
||||
"doctors, and barristers, and artists. They manage theaters, and promote\n"
|
||||
"swindles, and edit newspapers. I am looking forward to the time when we\n"
|
||||
"men shall have nothing to do but lie in bed till twelve, read two novels\n"
|
||||
"a day, have nice little five-o'clock teas all to ourselves, and tax\n"
|
||||
"our brains with nothing more trying than discussions upon the latest\n"
|
||||
"patterns in trousers and arguments as to what Mr. Jones' coat was\n"
|
||||
"made of and whether it fitted him. It is a glorious prospect--for idle\n"
|
||||
"fellows.\n"
|
||||
"\n\n\n"
|
||||
;
|
||||
static const size_t IDLE_SIZE = sizeof(on_being_idle) - 1;
|
||||
|
|
|
@ -10,11 +10,17 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifndef WIN32
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#else
|
||||
#include "vc_compat.h"
|
||||
#include "getopt.h"
|
||||
#endif
|
||||
|
||||
#include <event2/event.h>
|
||||
#include <openssl/md5.h>
|
||||
|
|
17
bin/prog.c
17
bin/prog.c
|
@ -16,7 +16,8 @@
|
|||
#ifndef WIN32
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include <getopt.h>
|
||||
#include "vc_compat.h"
|
||||
#include "getopt.h"
|
||||
#pragma warning(disable:4028)
|
||||
#endif// WIN32
|
||||
|
||||
|
@ -47,11 +48,20 @@ static const struct lsquic_packout_mem_if pmi = {
|
|||
};
|
||||
|
||||
|
||||
void
|
||||
int
|
||||
prog_init (struct prog *prog, unsigned flags,
|
||||
struct sport_head *sports,
|
||||
const struct lsquic_stream_if *stream_if, void *stream_if_ctx)
|
||||
{
|
||||
#ifdef WIN32
|
||||
WSADATA wsd;
|
||||
int s = WSAStartup(MAKEWORD(2, 2), &wsd);
|
||||
if (s != 0)
|
||||
{
|
||||
LSQ_ERROR("WSAStartup failed: %d", s);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
/* prog-specific initialization: */
|
||||
memset(prog, 0, sizeof(*prog));
|
||||
prog->prog_engine_flags = flags;
|
||||
|
@ -82,6 +92,7 @@ prog_init (struct prog *prog, unsigned flags,
|
|||
LSQUIC_GLOBAL_CLIENT);
|
||||
lsquic_log_to_fstream(stderr, LLTS_HHMMSSMS);
|
||||
lsquic_logger_lopt("=notice");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -215,8 +226,10 @@ prog_print_common_options (const struct prog *prog, FILE *out)
|
|||
int
|
||||
prog_set_opt (struct prog *prog, int opt, const char *arg)
|
||||
{
|
||||
#ifndef WIN32
|
||||
struct stat st;
|
||||
int s;
|
||||
#endif
|
||||
|
||||
switch (opt)
|
||||
{
|
||||
|
|
|
@ -54,7 +54,7 @@ struct prog
|
|||
} prog_flags;
|
||||
};
|
||||
|
||||
void
|
||||
int
|
||||
prog_init (struct prog *, unsigned lsquic_engine_flags, struct sport_head *,
|
||||
const struct lsquic_stream_if *, void *stream_if_ctx);
|
||||
|
||||
|
|
|
@ -30,8 +30,13 @@
|
|||
#include <fcntl.h>
|
||||
|
||||
#include "test_config.h"
|
||||
|
||||
#if HAVE_REGEX
|
||||
#ifndef WIN32
|
||||
#include <regex.h>
|
||||
#else
|
||||
#include <pcreposix.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <event2/event.h>
|
||||
|
@ -39,6 +44,7 @@
|
|||
#include "test_common.h"
|
||||
#include "lsquic.h"
|
||||
#include "prog.h"
|
||||
#include "lsxpack_header.h"
|
||||
|
||||
#include "../src/liblsquic/lsquic_logger.h"
|
||||
|
||||
|
@ -49,16 +55,6 @@
|
|||
#define LSQUIC_USE_POOLS 1
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
# define SOCKET_TYPE int
|
||||
# define CLOSE_SOCKET close
|
||||
# define CHAR_CAST
|
||||
#else
|
||||
# define SOCKET_TYPE SOCKET
|
||||
# define CLOSE_SOCKET closesocket
|
||||
# define CHAR_CAST (char *)
|
||||
#endif
|
||||
|
||||
#if __linux__
|
||||
# define NDROPPED_SZ CMSG_SPACE(sizeof(uint32_t)) /* SO_RXQ_OVFL */
|
||||
#else
|
||||
|
@ -177,9 +173,10 @@ allocate_packets_in (SOCKET_TYPE fd)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
n_alloc = (unsigned) recvsz / MAX_PACKET_SZ * 2;
|
||||
n_alloc = (unsigned) recvsz / 1370;
|
||||
LSQ_INFO("socket buffer size: %d bytes; max # packets is set to %u",
|
||||
recvsz, n_alloc);
|
||||
recvsz += MAX_PACKET_SZ;
|
||||
|
||||
packs_in = malloc(sizeof(*packs_in));
|
||||
packs_in->data_sz = recvsz;
|
||||
|
@ -520,7 +517,9 @@ read_one_packet (struct read_iter *iter)
|
|||
packs_in->vecs[iter->ri_idx].len = MAX_PACKET_SZ;
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
top:
|
||||
#endif
|
||||
ctl_buf = packs_in->ctlmsg_data + iter->ri_idx * CTL_SZ;
|
||||
|
||||
#ifndef WIN32
|
||||
|
@ -799,7 +798,11 @@ sport_init_server (struct service_port *sport, struct lsquic_engine *engine,
|
|||
struct event_base *eb)
|
||||
{
|
||||
const struct sockaddr *sa_local = (struct sockaddr *) &sport->sas;
|
||||
int sockfd, saved_errno, flags, s, on;
|
||||
int sockfd, saved_errno, s;
|
||||
#ifndef WIN32
|
||||
int flags;
|
||||
#endif
|
||||
SOCKOPT_VAL on;
|
||||
socklen_t socklen;
|
||||
char addr_str[0x20];
|
||||
|
||||
|
@ -816,6 +819,9 @@ sport_init_server (struct service_port *sport, struct lsquic_engine *engine,
|
|||
return -1;
|
||||
}
|
||||
|
||||
#if WIN32
|
||||
getExtensionPtrs();
|
||||
#endif
|
||||
sockfd = socket(sa_local->sa_family, SOCK_DGRAM, 0);
|
||||
if (-1 == sockfd)
|
||||
return -1;
|
||||
|
@ -829,6 +835,7 @@ sport_init_server (struct service_port *sport, struct lsquic_engine *engine,
|
|||
}
|
||||
|
||||
/* Make socket non-blocking */
|
||||
#ifndef WIN32
|
||||
flags = fcntl(sockfd, F_GETFL);
|
||||
if (-1 == flags) {
|
||||
saved_errno = errno;
|
||||
|
@ -843,20 +850,33 @@ sport_init_server (struct service_port *sport, struct lsquic_engine *engine,
|
|||
errno = saved_errno;
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
{
|
||||
u_long on = 1;
|
||||
ioctlsocket(sockfd, FIONBIO, &on);
|
||||
}
|
||||
#endif
|
||||
|
||||
on = 1;
|
||||
if (AF_INET == sa_local->sa_family)
|
||||
s = setsockopt(sockfd, IPPROTO_IP,
|
||||
#if __linux__ && defined(IP_RECVORIGDSTADDR)
|
||||
IP_RECVORIGDSTADDR,
|
||||
#elif __linux__ || __APPLE__
|
||||
#elif __linux__ || __APPLE__ || defined(WIN32)
|
||||
IP_PKTINFO,
|
||||
#else
|
||||
IP_RECVDSTADDR,
|
||||
#endif
|
||||
&on, sizeof(on));
|
||||
CHAR_CAST &on, sizeof(on));
|
||||
else
|
||||
{
|
||||
#ifndef WIN32
|
||||
s = setsockopt(sockfd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &on, sizeof(on));
|
||||
#else
|
||||
s = setsockopt(sockfd, IPPROTO_IPV6, IPV6_PKTINFO, CHAR_CAST &on, sizeof(on));
|
||||
#endif
|
||||
}
|
||||
|
||||
if (0 != s)
|
||||
{
|
||||
saved_errno = errno;
|
||||
|
@ -865,12 +885,12 @@ sport_init_server (struct service_port *sport, struct lsquic_engine *engine,
|
|||
return -1;
|
||||
}
|
||||
|
||||
#if (__linux__ && !defined(IP_RECVORIGDSTADDR)) || __APPLE__
|
||||
#if (__linux__ && !defined(IP_RECVORIGDSTADDR)) || __APPLE__ || defined(WIN32)
|
||||
/* Need to set IP_PKTINFO for sending */
|
||||
if (AF_INET == sa_local->sa_family)
|
||||
{
|
||||
on = 1;
|
||||
s = setsockopt(sockfd, IPPROTO_IP, IP_PKTINFO, &on, sizeof(on));
|
||||
s = setsockopt(sockfd, IPPROTO_IP, IP_PKTINFO, CHAR_CAST &on, sizeof(on));
|
||||
if (0 != s)
|
||||
{
|
||||
saved_errno = errno;
|
||||
|
@ -932,7 +952,7 @@ sport_init_server (struct service_port *sport, struct lsquic_engine *engine,
|
|||
sizeof(on));
|
||||
#else
|
||||
on = 1;
|
||||
s = setsockopt(sockfd, IPPROTO_IP, IP_DONTFRAG, &on, sizeof(on));
|
||||
s = setsockopt(sockfd, IPPROTO_IP, IP_DONTFRAG, CHAR_CAST &on, sizeof(on));
|
||||
#endif
|
||||
if (0 != s)
|
||||
{
|
||||
|
@ -948,9 +968,9 @@ sport_init_server (struct service_port *sport, struct lsquic_engine *engine,
|
|||
#if ECN_SUPPORTED
|
||||
on = 1;
|
||||
if (AF_INET == sa_local->sa_family)
|
||||
s = setsockopt(sockfd, IPPROTO_IP, IP_RECVTOS, &on, sizeof(on));
|
||||
s = setsockopt(sockfd, IPPROTO_IP, IP_RECVTOS, CHAR_CAST &on, sizeof(on));
|
||||
else
|
||||
s = setsockopt(sockfd, IPPROTO_IPV6, IPV6_RECVTCLASS, &on, sizeof(on));
|
||||
s = setsockopt(sockfd, IPPROTO_IPV6, IPV6_RECVTCLASS, CHAR_CAST &on, sizeof(on));
|
||||
if (0 != s)
|
||||
{
|
||||
saved_errno = errno;
|
||||
|
@ -962,7 +982,7 @@ sport_init_server (struct service_port *sport, struct lsquic_engine *engine,
|
|||
|
||||
if (sport->sp_flags & SPORT_SET_SNDBUF)
|
||||
{
|
||||
s = setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, &sport->sp_sndbuf,
|
||||
s = setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, CHAR_CAST &sport->sp_sndbuf,
|
||||
sizeof(sport->sp_sndbuf));
|
||||
if (0 != s)
|
||||
{
|
||||
|
@ -975,7 +995,7 @@ sport_init_server (struct service_port *sport, struct lsquic_engine *engine,
|
|||
|
||||
if (sport->sp_flags & SPORT_SET_RCVBUF)
|
||||
{
|
||||
s = setsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, &sport->sp_rcvbuf,
|
||||
s = setsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, CHAR_CAST &sport->sp_rcvbuf,
|
||||
sizeof(sport->sp_rcvbuf));
|
||||
if (0 != s)
|
||||
{
|
||||
|
@ -1121,7 +1141,7 @@ sport_init_client (struct service_port *sport, struct lsquic_engine *engine,
|
|||
sizeof(on));
|
||||
#elif WIN32
|
||||
on = 1;
|
||||
s = setsockopt(sockfd, IPPROTO_IP, IP_DONTFRAGMENT, (char*)&on, sizeof(on));
|
||||
s = setsockopt(sockfd, IPPROTO_IP, IP_DONTFRAGMENT, CHAR_CAST &on, sizeof(on));
|
||||
#else
|
||||
on = 1;
|
||||
s = setsockopt(sockfd, IPPROTO_IP, IP_DONTFRAG, &on, sizeof(on));
|
||||
|
@ -1141,10 +1161,11 @@ sport_init_client (struct service_port *sport, struct lsquic_engine *engine,
|
|||
{
|
||||
int on = 1;
|
||||
if (AF_INET == sa_local->sa_family)
|
||||
s = setsockopt(sockfd, IPPROTO_IP, IP_RECVTOS, &on, sizeof(on));
|
||||
s = setsockopt(sockfd, IPPROTO_IP, IP_RECVTOS,
|
||||
CHAR_CAST &on, sizeof(on));
|
||||
else
|
||||
s = setsockopt(sockfd, IPPROTO_IPV6, IPV6_RECVTCLASS, &on,
|
||||
sizeof(on));
|
||||
s = setsockopt(sockfd, IPPROTO_IPV6, IPV6_RECVTCLASS,
|
||||
CHAR_CAST &on, sizeof(on));
|
||||
if (0 != s)
|
||||
{
|
||||
saved_errno = errno;
|
||||
|
@ -1527,6 +1548,7 @@ send_packets_one_by_one (const struct lsquic_out_spec *specs, unsigned count)
|
|||
#else
|
||||
DWORD bytes;
|
||||
WSAMSG msg;
|
||||
WSABUF wsaBuf;
|
||||
#endif
|
||||
union {
|
||||
/* cmsg(3) recommends union for proper alignment */
|
||||
|
@ -1589,12 +1611,14 @@ send_packets_one_by_one (const struct lsquic_out_spec *specs, unsigned count)
|
|||
msg.msg_iovlen = specs[n].iovlen;
|
||||
msg.msg_flags = 0;
|
||||
#else
|
||||
wsaBuf.buf = specs[n].iov->iov_base;
|
||||
wsaBuf.len = specs[n].iov->iov_len;
|
||||
msg.name = (void *) specs[n].dest_sa;
|
||||
msg.namelen = (AF_INET == specs[n].dest_sa->sa_family ?
|
||||
sizeof(struct sockaddr_in) :
|
||||
sizeof(struct sockaddr_in6)),
|
||||
msg.lpBuffers = specs[n].iov;
|
||||
msg.dwBufferCount = specs[n].iovlen;
|
||||
sizeof(struct sockaddr_in6));
|
||||
msg.dwBufferCount = 1;
|
||||
msg.lpBuffers = &wsaBuf;
|
||||
msg.dwFlags = 0;
|
||||
#endif
|
||||
if ((sport->sp_flags & SPORT_SERVER) && specs[n].local_sa->sa_family)
|
||||
|
@ -1748,13 +1772,13 @@ set_engine_option (struct lsquic_engine_settings *settings,
|
|||
settings->es_versions = 0;
|
||||
}
|
||||
enum lsquic_version ver = lsquic_str2ver(val, strlen(val));
|
||||
if (ver < N_LSQVER)
|
||||
if ((unsigned) ver < N_LSQVER)
|
||||
{
|
||||
settings->es_versions |= 1 << ver;
|
||||
return 0;
|
||||
}
|
||||
ver = lsquic_alpn2ver(val, strlen(val));
|
||||
if (ver < N_LSQVER)
|
||||
if ((unsigned) ver < N_LSQVER)
|
||||
{
|
||||
settings->es_versions |= 1 << ver;
|
||||
return 0;
|
||||
|
@ -2207,3 +2231,22 @@ sport_set_token (struct service_port *sport, const char *token_str)
|
|||
sport->sp_token_sz = len / 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
header_set_ptr (struct lsxpack_header *hdr, struct header_buf *header_buf,
|
||||
const char *name, size_t name_len,
|
||||
const char *val, size_t val_len)
|
||||
{
|
||||
if (header_buf->off + name_len + val_len <= sizeof(header_buf->buf))
|
||||
{
|
||||
memcpy(header_buf->buf + header_buf->off, name, name_len);
|
||||
memcpy(header_buf->buf + header_buf->off + name_len, val, val_len);
|
||||
lsxpack_header_set_offset2(hdr, header_buf->buf + header_buf->off,
|
||||
0, name_len, name_len, val_len);
|
||||
header_buf->off += name_len + val_len;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,11 @@
|
|||
# include <net/if.h> /* For IFNAMSIZ */
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
struct lsquic_engine;
|
||||
struct lsquic_engine_settings;
|
||||
struct lsquic_out_spec;
|
||||
|
@ -19,6 +24,19 @@ struct packets_in;
|
|||
struct lsquic_conn;
|
||||
struct prog;
|
||||
struct reader_ctx;
|
||||
struct lsxpack_header;
|
||||
|
||||
#ifndef WIN32
|
||||
# define SOCKOPT_VAL int
|
||||
# define SOCKET_TYPE int
|
||||
# define CLOSE_SOCKET close
|
||||
# define CHAR_CAST
|
||||
#else
|
||||
# define SOCKOPT_VAL DWORD
|
||||
# define SOCKET_TYPE SOCKET
|
||||
# define CLOSE_SOCKET closesocket
|
||||
# define CHAR_CAST (char *)
|
||||
#endif
|
||||
|
||||
enum sport_flags
|
||||
{
|
||||
|
@ -51,8 +69,8 @@ struct service_port {
|
|||
struct sockaddr_storage sp_local_addr;
|
||||
struct packets_in *packs_in;
|
||||
enum sport_flags sp_flags;
|
||||
int sp_sndbuf; /* If SPORT_SET_SNDBUF is set */
|
||||
int sp_rcvbuf; /* If SPORT_SET_RCVBUF is set */
|
||||
SOCKOPT_VAL sp_sndbuf; /* If SPORT_SET_SNDBUF is set */
|
||||
SOCKOPT_VAL sp_rcvbuf; /* If SPORT_SET_RCVBUF is set */
|
||||
struct prog *sp_prog;
|
||||
unsigned char *sp_token_buf;
|
||||
size_t sp_token_sz;
|
||||
|
@ -125,4 +143,15 @@ destroy_lsquic_reader_ctx (struct reader_ctx *ctx);
|
|||
#define LITESPEED_ID "lsquic" "/" TOSTRING(LSQUIC_MAJOR_VERSION) "." \
|
||||
TOSTRING(LSQUIC_MINOR_VERSION) "." TOSTRING(LSQUIC_PATCH_VERSION)
|
||||
|
||||
struct header_buf
|
||||
{
|
||||
unsigned off;
|
||||
char buf[UINT16_MAX];
|
||||
};
|
||||
|
||||
int
|
||||
header_set_ptr (struct lsxpack_header *hdr, struct header_buf *header_buf,
|
||||
const char *name, size_t name_len,
|
||||
const char *val, size_t val_len);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue