accf_http.c revision 1.2.2.3 1 1.2.2.3 haad /* $NetBSD: accf_http.c,v 1.2.2.3 2008/12/13 01:15:26 haad Exp $ */
2 1.2.2.2 haad
3 1.2.2.2 haad /*-
4 1.2.2.2 haad * Copyright (c) 2000 Paycounter, Inc.
5 1.2.2.2 haad * Author: Alfred Perlstein <alfred (at) paycounter.com>, <alfred (at) FreeBSD.org>
6 1.2.2.2 haad * All rights reserved.
7 1.2.2.2 haad *
8 1.2.2.2 haad * Redistribution and use in source and binary forms, with or without
9 1.2.2.2 haad * modification, are permitted provided that the following conditions
10 1.2.2.2 haad * are met:
11 1.2.2.2 haad * 1. Redistributions of source code must retain the above copyright
12 1.2.2.2 haad * notice, this list of conditions and the following disclaimer.
13 1.2.2.2 haad * 2. Redistributions in binary form must reproduce the above copyright
14 1.2.2.2 haad * notice, this list of conditions and the following disclaimer in the
15 1.2.2.2 haad * documentation and/or other materials provided with the distribution.
16 1.2.2.2 haad *
17 1.2.2.2 haad * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 1.2.2.2 haad * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 1.2.2.2 haad * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 1.2.2.2 haad * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 1.2.2.2 haad * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 1.2.2.2 haad * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 1.2.2.2 haad * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 1.2.2.2 haad * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 1.2.2.2 haad * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 1.2.2.2 haad * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 1.2.2.2 haad * SUCH DAMAGE.
28 1.2.2.2 haad */
29 1.2.2.2 haad
30 1.2.2.2 haad #include <sys/cdefs.h>
31 1.2.2.3 haad __KERNEL_RCSID(0, "$NetBSD: accf_http.c,v 1.2.2.3 2008/12/13 01:15:26 haad Exp $");
32 1.2.2.2 haad
33 1.2.2.2 haad #define ACCEPT_FILTER_MOD
34 1.2.2.2 haad
35 1.2.2.2 haad #include <sys/param.h>
36 1.2.2.2 haad #include <sys/kernel.h>
37 1.2.2.2 haad #include <sys/mbuf.h>
38 1.2.2.3 haad #include <sys/module.h>
39 1.2.2.2 haad #include <sys/signalvar.h>
40 1.2.2.2 haad #include <sys/sysctl.h>
41 1.2.2.2 haad #include <sys/socket.h>
42 1.2.2.2 haad #include <sys/socketvar.h>
43 1.2.2.2 haad
44 1.2.2.2 haad #include <netinet/accept_filter.h>
45 1.2.2.2 haad
46 1.2.2.3 haad MODULE(MODULE_CLASS_MISC, accf_httpready, NULL);
47 1.2.2.3 haad
48 1.2.2.2 haad /* check for GET/HEAD */
49 1.2.2.2 haad static void sohashttpget(struct socket *so, void *arg, int waitflag);
50 1.2.2.2 haad /* check for HTTP/1.0 or HTTP/1.1 */
51 1.2.2.2 haad static void soparsehttpvers(struct socket *so, void *arg, int waitflag);
52 1.2.2.2 haad /* check for end of HTTP/1.x request */
53 1.2.2.2 haad static void soishttpconnected(struct socket *so, void *arg, int waitflag);
54 1.2.2.2 haad /* strcmp on an mbuf chain */
55 1.2.2.2 haad static int mbufstrcmp(struct mbuf *m, struct mbuf *npkt, int offset, const char *cmp);
56 1.2.2.2 haad /* strncmp on an mbuf chain */
57 1.2.2.2 haad static int mbufstrncmp(struct mbuf *m, struct mbuf *npkt, int offset,
58 1.2.2.2 haad int len, const char *cmp);
59 1.2.2.2 haad /* socketbuffer is full */
60 1.2.2.2 haad static int sbfull(struct sockbuf *sb);
61 1.2.2.2 haad
62 1.2.2.2 haad static struct accept_filter accf_http_filter = {
63 1.2.2.2 haad .accf_name = "httpready",
64 1.2.2.2 haad .accf_callback = sohashttpget,
65 1.2.2.2 haad };
66 1.2.2.2 haad
67 1.2.2.2 haad /*
68 1.2.2.2 haad * Names of HTTP Accept filter sysctl objects
69 1.2.2.2 haad */
70 1.2.2.2 haad
71 1.2.2.2 haad #define ACCFCTL_PARSEVER 1 /* Parse HTTP version */
72 1.2.2.2 haad
73 1.2.2.2 haad static int parse_http_version = 1;
74 1.2.2.2 haad
75 1.2.2.3 haad /* XXX pseudo-device */
76 1.2.2.3 haad void accf_httpattach(int);
77 1.2.2.3 haad
78 1.2.2.3 haad void
79 1.2.2.3 haad accf_httpattach(int junk)
80 1.2.2.3 haad {
81 1.2.2.3 haad
82 1.2.2.3 haad }
83 1.2.2.3 haad
84 1.2.2.3 haad static int
85 1.2.2.3 haad accf_httpready_modcmd(modcmd_t cmd, void *arg)
86 1.2.2.2 haad {
87 1.2.2.3 haad static struct sysctllog *clog;
88 1.2.2.3 haad int error;
89 1.2.2.3 haad
90 1.2.2.3 haad switch (cmd) {
91 1.2.2.3 haad case MODULE_CMD_INIT:
92 1.2.2.3 haad error = accept_filt_add(&accf_http_filter);
93 1.2.2.3 haad if (error != 0) {
94 1.2.2.3 haad return error;
95 1.2.2.3 haad }
96 1.2.2.3 haad sysctl_createv(&clog, 0, NULL, NULL,
97 1.2.2.2 haad CTLFLAG_PERMANENT,
98 1.2.2.2 haad CTLTYPE_NODE, "net", NULL,
99 1.2.2.2 haad NULL, 0, NULL, 0,
100 1.2.2.2 haad CTL_NET, CTL_EOL);
101 1.2.2.3 haad sysctl_createv(&clog, 0, NULL, NULL,
102 1.2.2.2 haad CTLFLAG_PERMANENT,
103 1.2.2.2 haad CTLTYPE_NODE, "inet", NULL,
104 1.2.2.2 haad NULL, 0, NULL, 0,
105 1.2.2.2 haad CTL_NET, PF_INET, CTL_EOL);
106 1.2.2.3 haad sysctl_createv(&clog, 0, NULL, NULL,
107 1.2.2.2 haad CTLFLAG_PERMANENT,
108 1.2.2.2 haad CTLTYPE_NODE, "accf", NULL,
109 1.2.2.2 haad NULL, 0, NULL, 0,
110 1.2.2.2 haad CTL_NET, PF_INET, SO_ACCEPTFILTER, CTL_EOL);
111 1.2.2.3 haad sysctl_createv(&clog, 0, NULL, NULL,
112 1.2.2.2 haad CTLFLAG_PERMANENT,
113 1.2.2.2 haad CTLTYPE_NODE, "http",
114 1.2.2.2 haad SYSCTL_DESCR("HTTP accept filter"),
115 1.2.2.2 haad NULL, 0, NULL, 0,
116 1.2.2.2 haad CTL_NET, PF_INET, SO_ACCEPTFILTER, ACCF_HTTP, CTL_EOL);
117 1.2.2.3 haad sysctl_createv(&clog, 0, NULL, NULL,
118 1.2.2.2 haad CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
119 1.2.2.2 haad CTLTYPE_INT, "parsehttpversion",
120 1.2.2.2 haad SYSCTL_DESCR("Parse http version so that non "
121 1.2.2.2 haad "1.x requests work"),
122 1.2.2.2 haad NULL, 0, &parse_http_version, 0,
123 1.2.2.2 haad CTL_NET, PF_INET, SO_ACCEPTFILTER, ACCF_HTTP,
124 1.2.2.2 haad ACCFCTL_PARSEVER, CTL_EOL);
125 1.2.2.3 haad return 0;
126 1.2.2.2 haad
127 1.2.2.3 haad case MODULE_CMD_FINI:
128 1.2.2.3 haad error = accept_filt_del(&accf_http_filter);
129 1.2.2.3 haad if (error != 0) {
130 1.2.2.3 haad return error;
131 1.2.2.3 haad }
132 1.2.2.3 haad sysctl_teardown(&clog);
133 1.2.2.3 haad return 0;
134 1.2.2.2 haad
135 1.2.2.3 haad default:
136 1.2.2.3 haad return ENOTTY;
137 1.2.2.3 haad }
138 1.2.2.2 haad }
139 1.2.2.2 haad
140 1.2.2.2 haad #ifdef ACCF_HTTP_DEBUG
141 1.2.2.2 haad #define DPRINT(fmt, args...) \
142 1.2.2.2 haad do { \
143 1.2.2.2 haad printf("%s:%d: " fmt "\n", __func__, __LINE__, ##args); \
144 1.2.2.2 haad } while (0)
145 1.2.2.2 haad #else
146 1.2.2.2 haad #define DPRINT(fmt, args...)
147 1.2.2.2 haad #endif
148 1.2.2.2 haad
149 1.2.2.2 haad static int
150 1.2.2.2 haad sbfull(struct sockbuf *sb)
151 1.2.2.2 haad {
152 1.2.2.2 haad
153 1.2.2.2 haad DPRINT("sbfull, cc(%ld) >= hiwat(%ld): %d, "
154 1.2.2.2 haad "mbcnt(%ld) >= mbmax(%ld): %d",
155 1.2.2.2 haad sb->sb_cc, sb->sb_hiwat, sb->sb_cc >= sb->sb_hiwat,
156 1.2.2.2 haad sb->sb_mbcnt, sb->sb_mbmax, sb->sb_mbcnt >= sb->sb_mbmax);
157 1.2.2.2 haad return (sb->sb_cc >= sb->sb_hiwat || sb->sb_mbcnt >= sb->sb_mbmax);
158 1.2.2.2 haad }
159 1.2.2.2 haad
160 1.2.2.2 haad /*
161 1.2.2.2 haad * start at mbuf m, (must provide npkt if exists)
162 1.2.2.2 haad * starting at offset in m compare characters in mbuf chain for 'cmp'
163 1.2.2.2 haad */
164 1.2.2.2 haad static int
165 1.2.2.2 haad mbufstrcmp(struct mbuf *m, struct mbuf *npkt, int offset, const char *cmp)
166 1.2.2.2 haad {
167 1.2.2.2 haad struct mbuf *n;
168 1.2.2.2 haad
169 1.2.2.2 haad for (; m != NULL; m = n) {
170 1.2.2.2 haad n = npkt;
171 1.2.2.2 haad if (npkt)
172 1.2.2.2 haad npkt = npkt->m_nextpkt;
173 1.2.2.2 haad for (; m; m = m->m_next) {
174 1.2.2.2 haad for (; offset < m->m_len; offset++, cmp++) {
175 1.2.2.2 haad if (*cmp == '\0')
176 1.2.2.2 haad return (1);
177 1.2.2.2 haad else if (*cmp != *(mtod(m, char *) + offset))
178 1.2.2.2 haad return (0);
179 1.2.2.2 haad }
180 1.2.2.2 haad if (*cmp == '\0')
181 1.2.2.2 haad return (1);
182 1.2.2.2 haad offset = 0;
183 1.2.2.2 haad }
184 1.2.2.2 haad }
185 1.2.2.2 haad return (0);
186 1.2.2.2 haad }
187 1.2.2.2 haad
188 1.2.2.2 haad /*
189 1.2.2.2 haad * start at mbuf m, (must provide npkt if exists)
190 1.2.2.2 haad * starting at offset in m compare characters in mbuf chain for 'cmp'
191 1.2.2.2 haad * stop at 'max' characters
192 1.2.2.2 haad */
193 1.2.2.2 haad static int
194 1.2.2.2 haad mbufstrncmp(struct mbuf *m, struct mbuf *npkt, int offset, int len, const char *cmp)
195 1.2.2.2 haad {
196 1.2.2.2 haad struct mbuf *n;
197 1.2.2.2 haad
198 1.2.2.2 haad for (; m != NULL; m = n) {
199 1.2.2.2 haad n = npkt;
200 1.2.2.2 haad if (npkt)
201 1.2.2.2 haad npkt = npkt->m_nextpkt;
202 1.2.2.2 haad for (; m; m = m->m_next) {
203 1.2.2.2 haad for (; offset < m->m_len; offset++, cmp++, len--) {
204 1.2.2.2 haad if (len == 0 || *cmp == '\0')
205 1.2.2.2 haad return (1);
206 1.2.2.2 haad else if (*cmp != *(mtod(m, char *) + offset))
207 1.2.2.2 haad return (0);
208 1.2.2.2 haad }
209 1.2.2.2 haad if (len == 0 || *cmp == '\0')
210 1.2.2.2 haad return (1);
211 1.2.2.2 haad offset = 0;
212 1.2.2.2 haad }
213 1.2.2.2 haad }
214 1.2.2.2 haad return (0);
215 1.2.2.2 haad }
216 1.2.2.2 haad
217 1.2.2.2 haad #define STRSETUP(sptr, slen, str) \
218 1.2.2.2 haad do { \
219 1.2.2.2 haad sptr = str; \
220 1.2.2.2 haad slen = sizeof(str) - 1; \
221 1.2.2.2 haad } while(0)
222 1.2.2.2 haad
223 1.2.2.2 haad static void
224 1.2.2.2 haad sohashttpget(struct socket *so, void *arg, int waitflag)
225 1.2.2.2 haad {
226 1.2.2.2 haad
227 1.2.2.2 haad if ((so->so_state & SS_CANTRCVMORE) == 0 && !sbfull(&so->so_rcv)) {
228 1.2.2.2 haad struct mbuf *m;
229 1.2.2.2 haad const char *cmp;
230 1.2.2.2 haad int cmplen, cc;
231 1.2.2.2 haad
232 1.2.2.2 haad m = so->so_rcv.sb_mb;
233 1.2.2.2 haad cc = so->so_rcv.sb_cc - 1;
234 1.2.2.2 haad if (cc < 1)
235 1.2.2.2 haad return;
236 1.2.2.2 haad switch (*mtod(m, char *)) {
237 1.2.2.2 haad case 'G':
238 1.2.2.2 haad STRSETUP(cmp, cmplen, "ET ");
239 1.2.2.2 haad break;
240 1.2.2.2 haad case 'H':
241 1.2.2.2 haad STRSETUP(cmp, cmplen, "EAD ");
242 1.2.2.2 haad break;
243 1.2.2.2 haad default:
244 1.2.2.2 haad goto fallout;
245 1.2.2.2 haad }
246 1.2.2.2 haad if (cc < cmplen) {
247 1.2.2.2 haad if (mbufstrncmp(m, m->m_nextpkt, 1, cc, cmp) == 1) {
248 1.2.2.2 haad DPRINT("short cc (%d) but mbufstrncmp ok", cc);
249 1.2.2.2 haad return;
250 1.2.2.2 haad } else {
251 1.2.2.2 haad DPRINT("short cc (%d) mbufstrncmp failed", cc);
252 1.2.2.2 haad goto fallout;
253 1.2.2.2 haad }
254 1.2.2.2 haad }
255 1.2.2.2 haad if (mbufstrcmp(m, m->m_nextpkt, 1, cmp) == 1) {
256 1.2.2.2 haad DPRINT("mbufstrcmp ok");
257 1.2.2.2 haad if (parse_http_version == 0)
258 1.2.2.2 haad soishttpconnected(so, arg, waitflag);
259 1.2.2.2 haad else
260 1.2.2.2 haad soparsehttpvers(so, arg, waitflag);
261 1.2.2.2 haad return;
262 1.2.2.2 haad }
263 1.2.2.2 haad DPRINT("mbufstrcmp bad");
264 1.2.2.2 haad }
265 1.2.2.2 haad
266 1.2.2.2 haad fallout:
267 1.2.2.2 haad DPRINT("fallout");
268 1.2.2.2 haad so->so_upcall = NULL;
269 1.2.2.2 haad so->so_rcv.sb_flags &= ~SB_UPCALL;
270 1.2.2.2 haad soisconnected(so);
271 1.2.2.2 haad return;
272 1.2.2.2 haad }
273 1.2.2.2 haad
274 1.2.2.2 haad static void
275 1.2.2.2 haad soparsehttpvers(struct socket *so, void *arg, int waitflag)
276 1.2.2.2 haad {
277 1.2.2.2 haad struct mbuf *m, *n;
278 1.2.2.2 haad int i, cc, spaces, inspaces;
279 1.2.2.2 haad
280 1.2.2.2 haad if ((so->so_state & SS_CANTRCVMORE) != 0 || sbfull(&so->so_rcv))
281 1.2.2.2 haad goto fallout;
282 1.2.2.2 haad
283 1.2.2.2 haad m = so->so_rcv.sb_mb;
284 1.2.2.2 haad cc = so->so_rcv.sb_cc;
285 1.2.2.2 haad inspaces = spaces = 0;
286 1.2.2.2 haad for (m = so->so_rcv.sb_mb; m; m = n) {
287 1.2.2.2 haad n = m->m_nextpkt;
288 1.2.2.2 haad for (; m; m = m->m_next) {
289 1.2.2.2 haad for (i = 0; i < m->m_len; i++, cc--) {
290 1.2.2.2 haad switch (*(mtod(m, char *) + i)) {
291 1.2.2.2 haad case ' ':
292 1.2.2.2 haad /* tabs? '\t' */
293 1.2.2.2 haad if (!inspaces) {
294 1.2.2.2 haad spaces++;
295 1.2.2.2 haad inspaces = 1;
296 1.2.2.2 haad }
297 1.2.2.2 haad break;
298 1.2.2.2 haad case '\r':
299 1.2.2.2 haad case '\n':
300 1.2.2.2 haad DPRINT("newline");
301 1.2.2.2 haad goto fallout;
302 1.2.2.2 haad default:
303 1.2.2.2 haad if (spaces != 2) {
304 1.2.2.2 haad inspaces = 0;
305 1.2.2.2 haad break;
306 1.2.2.2 haad }
307 1.2.2.2 haad
308 1.2.2.2 haad /*
309 1.2.2.2 haad * if we don't have enough characters
310 1.2.2.2 haad * left (cc < sizeof("HTTP/1.0") - 1)
311 1.2.2.2 haad * then see if the remaining ones
312 1.2.2.2 haad * are a request we can parse.
313 1.2.2.2 haad */
314 1.2.2.2 haad if (cc < sizeof("HTTP/1.0") - 1) {
315 1.2.2.2 haad if (mbufstrncmp(m, n, i, cc,
316 1.2.2.2 haad "HTTP/1.") == 1) {
317 1.2.2.2 haad DPRINT("ok");
318 1.2.2.2 haad goto readmore;
319 1.2.2.2 haad } else {
320 1.2.2.2 haad DPRINT("bad");
321 1.2.2.2 haad goto fallout;
322 1.2.2.2 haad }
323 1.2.2.2 haad } else if (
324 1.2.2.2 haad mbufstrcmp(m, n, i, "HTTP/1.0") ||
325 1.2.2.2 haad mbufstrcmp(m, n, i, "HTTP/1.1")) {
326 1.2.2.3 haad DPRINT("ok");
327 1.2.2.3 haad soishttpconnected(so,
328 1.2.2.3 haad arg, waitflag);
329 1.2.2.3 haad return;
330 1.2.2.2 haad } else {
331 1.2.2.2 haad DPRINT("bad");
332 1.2.2.2 haad goto fallout;
333 1.2.2.2 haad }
334 1.2.2.2 haad }
335 1.2.2.2 haad }
336 1.2.2.2 haad }
337 1.2.2.2 haad }
338 1.2.2.2 haad readmore:
339 1.2.2.2 haad DPRINT("readmore");
340 1.2.2.2 haad /*
341 1.2.2.2 haad * if we hit here we haven't hit something
342 1.2.2.2 haad * we don't understand or a newline, so try again
343 1.2.2.2 haad */
344 1.2.2.2 haad so->so_upcall = soparsehttpvers;
345 1.2.2.2 haad so->so_rcv.sb_flags |= SB_UPCALL;
346 1.2.2.2 haad return;
347 1.2.2.2 haad
348 1.2.2.2 haad fallout:
349 1.2.2.2 haad DPRINT("fallout");
350 1.2.2.2 haad so->so_upcall = NULL;
351 1.2.2.2 haad so->so_rcv.sb_flags &= ~SB_UPCALL;
352 1.2.2.2 haad soisconnected(so);
353 1.2.2.2 haad return;
354 1.2.2.2 haad }
355 1.2.2.2 haad
356 1.2.2.2 haad
357 1.2.2.2 haad #define NCHRS 3
358 1.2.2.2 haad
359 1.2.2.2 haad static void
360 1.2.2.2 haad soishttpconnected(struct socket *so, void *arg, int waitflag)
361 1.2.2.2 haad {
362 1.2.2.2 haad char a, b, c;
363 1.2.2.2 haad struct mbuf *m, *n;
364 1.2.2.2 haad int ccleft, copied;
365 1.2.2.2 haad
366 1.2.2.2 haad DPRINT("start");
367 1.2.2.2 haad if ((so->so_state & SS_CANTRCVMORE) != 0 || sbfull(&so->so_rcv))
368 1.2.2.2 haad goto gotit;
369 1.2.2.2 haad
370 1.2.2.2 haad /*
371 1.2.2.2 haad * Walk the socketbuffer and copy the last NCHRS (3) into a, b, and c
372 1.2.2.2 haad * copied - how much we've copied so far
373 1.2.2.2 haad * ccleft - how many bytes remaining in the socketbuffer
374 1.2.2.2 haad * just loop over the mbufs subtracting from 'ccleft' until we only
375 1.2.2.2 haad * have NCHRS left
376 1.2.2.2 haad */
377 1.2.2.2 haad copied = 0;
378 1.2.2.2 haad ccleft = so->so_rcv.sb_cc;
379 1.2.2.2 haad if (ccleft < NCHRS)
380 1.2.2.2 haad goto readmore;
381 1.2.2.2 haad a = b = c = '\0';
382 1.2.2.2 haad for (m = so->so_rcv.sb_mb; m; m = n) {
383 1.2.2.2 haad n = m->m_nextpkt;
384 1.2.2.2 haad for (; m; m = m->m_next) {
385 1.2.2.2 haad ccleft -= m->m_len;
386 1.2.2.2 haad if (ccleft <= NCHRS) {
387 1.2.2.2 haad char *src;
388 1.2.2.2 haad int tocopy;
389 1.2.2.2 haad
390 1.2.2.2 haad tocopy = (NCHRS - ccleft) - copied;
391 1.2.2.2 haad src = mtod(m, char *) + (m->m_len - tocopy);
392 1.2.2.2 haad
393 1.2.2.2 haad while (tocopy--) {
394 1.2.2.2 haad switch (copied++) {
395 1.2.2.2 haad case 0:
396 1.2.2.2 haad a = *src++;
397 1.2.2.2 haad break;
398 1.2.2.2 haad case 1:
399 1.2.2.2 haad b = *src++;
400 1.2.2.2 haad break;
401 1.2.2.2 haad case 2:
402 1.2.2.2 haad c = *src++;
403 1.2.2.2 haad break;
404 1.2.2.2 haad }
405 1.2.2.2 haad }
406 1.2.2.2 haad }
407 1.2.2.2 haad }
408 1.2.2.2 haad }
409 1.2.2.2 haad if (c == '\n' && (b == '\n' || (b == '\r' && a == '\n'))) {
410 1.2.2.2 haad /* we have all request headers */
411 1.2.2.2 haad goto gotit;
412 1.2.2.2 haad }
413 1.2.2.2 haad
414 1.2.2.2 haad readmore:
415 1.2.2.2 haad so->so_upcall = soishttpconnected;
416 1.2.2.2 haad so->so_rcv.sb_flags |= SB_UPCALL;
417 1.2.2.2 haad return;
418 1.2.2.2 haad
419 1.2.2.2 haad gotit:
420 1.2.2.2 haad so->so_upcall = NULL;
421 1.2.2.2 haad so->so_rcv.sb_flags &= ~SB_UPCALL;
422 1.2.2.2 haad soisconnected(so);
423 1.2.2.2 haad return;
424 1.2.2.2 haad }
425