VirtualBox

source: vbox/trunk/src/VBox/Devices/Network/slirp/udp.c@ 94264

Last change on this file since 94264 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 19.3 KB
Line 
1/* $Id: udp.c 93115 2022-01-01 11:31:46Z vboxsync $ */
2/** @file
3 * NAT - UDP protocol.
4 */
5
6/*
7 * Copyright (C) 2006-2022 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18/*
19 * This code is based on:
20 *
21 * Copyright (c) 1982, 1986, 1988, 1990, 1993
22 * The Regents of the University of California. All rights reserved.
23 *
24 * Redistribution and use in source and binary forms, with or without
25 * modification, are permitted provided that the following conditions
26 * are met:
27 * 1. Redistributions of source code must retain the above copyright
28 * notice, this list of conditions and the following disclaimer.
29 * 2. Redistributions in binary form must reproduce the above copyright
30 * notice, this list of conditions and the following disclaimer in the
31 * documentation and/or other materials provided with the distribution.
32 * 3. All advertising materials mentioning features or use of this software
33 * must display the following acknowledgement:
34 * This product includes software developed by the University of
35 * California, Berkeley and its contributors.
36 * 4. Neither the name of the University nor the names of its contributors
37 * may be used to endorse or promote products derived from this software
38 * without specific prior written permission.
39 *
40 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
41 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
44 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
45 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
46 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
48 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
49 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50 * SUCH DAMAGE.
51 *
52 * @(#)udp_usrreq.c 8.4 (Berkeley) 1/21/94
53 * udp_usrreq.c,v 1.4 1994/10/02 17:48:45 phk Exp
54 */
55
56/*
57 * Changes and additions relating to SLiRP
58 * Copyright (c) 1995 Danny Gasparovski.
59 *
60 * Please read the file COPYRIGHT for the
61 * terms and conditions of the copyright.
62 */
63
64#include <slirp.h>
65#include "ip_icmp.h"
66
67
68/*
69 * UDP protocol implementation.
70 * Per RFC 768, August, 1980.
71 */
72#define udpcksum 1
73
74void
75udp_init(PNATState pData)
76{
77 udp_last_so = &udb;
78 udb.so_next = udb.so_prev = &udb;
79}
80
81/* m->m_data points at ip packet header
82 * m->m_len length ip packet
83 * ip->ip_len length data (IPDU)
84 */
85void
86udp_input(PNATState pData, register struct mbuf *m, int iphlen)
87{
88 register struct ip *ip;
89 register struct udphdr *uh;
90 int len;
91 struct ip save_ip;
92 struct socket *so;
93 int ret;
94 int ttl, tos;
95
96 LogFlowFunc(("ENTER: m = %p, iphlen = %d\n", m, iphlen));
97 ip = mtod(m, struct ip *);
98 Log2(("%RTnaipv4 iphlen = %d\n", ip->ip_dst, iphlen));
99
100 udpstat.udps_ipackets++;
101
102 /*
103 * Strip IP options, if any; should skip this,
104 * make available to user, and use on returned packets,
105 * but we don't yet have a way to check the checksum
106 * with options still present.
107 */
108 if (iphlen > sizeof(struct ip))
109 {
110 ip_stripoptions(m, (struct mbuf *)0);
111 iphlen = sizeof(struct ip);
112 }
113
114 /*
115 * Get IP and UDP header together in first mbuf.
116 */
117 ip = mtod(m, struct ip *);
118 uh = (struct udphdr *)((caddr_t)ip + iphlen);
119
120 /*
121 * Make mbuf data length reflect UDP length.
122 * If not enough data to reflect UDP length, drop.
123 */
124 len = RT_N2H_U16((u_int16_t)uh->uh_ulen);
125 Assert(ip->ip_len + iphlen == (ssize_t)m_length(m, NULL));
126
127 if (ip->ip_len != len)
128 {
129 if (len > ip->ip_len)
130 {
131 udpstat.udps_badlen++;
132 Log3(("NAT: IP(id: %hd) has bad size\n", ip->ip_id));
133 goto bad_free_mbuf;
134 }
135 m_adj(m, len - ip->ip_len);
136 ip->ip_len = len;
137 }
138
139 /*
140 * Save a copy of the IP header in case we want restore it
141 * for sending an ICMP error message in response.
142 */
143 save_ip = *ip;
144 save_ip.ip_len+= iphlen; /* tcp_input subtracts this */
145
146 /*
147 * Checksum extended UDP header and data.
148 */
149 if (udpcksum && uh->uh_sum)
150 {
151 memset(((struct ipovly *)ip)->ih_x1, 0, 9);
152 ((struct ipovly *)ip)->ih_len = uh->uh_ulen;
153#if 0
154 /* keep uh_sum for ICMP reply */
155 uh->uh_sum = cksum(m, len + sizeof (struct ip));
156 if (uh->uh_sum)
157 {
158
159#endif
160 if (cksum(m, len + iphlen))
161 {
162 udpstat.udps_badsum++;
163 Log3(("NAT: IP(id: %hd) has bad (udp) cksum\n", ip->ip_id));
164 goto bad_free_mbuf;
165 }
166 }
167#if 0
168 }
169#endif
170
171 /*
172 * handle DHCP/BOOTP
173 */
174 if (uh->uh_dport == RT_H2N_U16_C(BOOTP_SERVER))
175 {
176 bootp_input(pData, m);
177 goto done_free_mbuf;
178 }
179
180 LogFunc(("uh src: %RTnaipv4:%d, dst: %RTnaipv4:%d\n",
181 ip->ip_src.s_addr, RT_N2H_U16(uh->uh_sport),
182 ip->ip_dst.s_addr, RT_N2H_U16(uh->uh_dport)));
183
184 /*
185 * handle DNS host resolver without creating a socket
186 */
187 if ( pData->fUseHostResolver
188 && uh->uh_dport == RT_H2N_U16_C(53)
189 && CTL_CHECK(ip->ip_dst.s_addr, CTL_DNS))
190 {
191 struct sockaddr_in dst, src;
192
193 src.sin_addr.s_addr = ip->ip_dst.s_addr;
194 src.sin_port = uh->uh_dport;
195 dst.sin_addr.s_addr = ip->ip_src.s_addr;
196 dst.sin_port = uh->uh_sport;
197
198 m_adj(m, sizeof(struct udpiphdr));
199
200 m = hostresolver(pData, m, ip->ip_src.s_addr, uh->uh_sport);
201 if (m == NULL)
202 goto done_free_mbuf;
203
204 slirpMbufTagService(pData, m, CTL_DNS);
205
206 udp_output2(pData, NULL, m, &src, &dst, IPTOS_LOWDELAY);
207 LogFlowFuncLeave();
208 return;
209 }
210
211 /*
212 * handle TFTP
213 */
214 if ( uh->uh_dport == RT_H2N_U16_C(TFTP_SERVER)
215 && CTL_CHECK(ip->ip_dst.s_addr, CTL_TFTP))
216 {
217 if (pData->pvTftpSessions)
218 slirpTftpInput(pData, m);
219 goto done_free_mbuf;
220 }
221
222 /*
223 * XXX: DNS proxy currently relies on the fact that each socket
224 * only serves one request.
225 */
226 if ( pData->fUseDnsProxy
227 && CTL_CHECK(ip->ip_dst.s_addr, CTL_DNS)
228 && (uh->uh_dport == RT_H2N_U16_C(53)))
229 {
230 so = NULL;
231 goto new_socket;
232 }
233
234 /*
235 * Drop UDP packets destind for CTL_ALIAS (i.e. the hosts loopback interface)
236 * if it is disabled.
237 */
238 if ( CTL_CHECK(ip->ip_dst.s_addr, CTL_ALIAS)
239 && !pData->fLocalhostReachable)
240 goto done_free_mbuf;
241
242 /*
243 * Locate pcb for datagram.
244 */
245 so = udp_last_so;
246 if ( so->so_lport != uh->uh_sport
247 || so->so_laddr.s_addr != ip->ip_src.s_addr)
248 {
249 struct socket *tmp;
250
251 for (tmp = udb.so_next; tmp != &udb; tmp = tmp->so_next)
252 {
253 if ( tmp->so_lport == uh->uh_sport
254 && tmp->so_laddr.s_addr == ip->ip_src.s_addr)
255 {
256 so = tmp;
257 break;
258 }
259 }
260 if (tmp == &udb)
261 so = NULL;
262 else
263 {
264 udpstat.udpps_pcbcachemiss++;
265 udp_last_so = so;
266 }
267 }
268
269 new_socket:
270 if (so == NULL)
271 {
272 /*
273 * If there's no socket for this packet,
274 * create one
275 */
276 if ((so = socreate()) == NULL)
277 {
278 Log2(("NAT: IP(id: %hd) failed to create socket\n", ip->ip_id));
279 goto bad_free_mbuf;
280 }
281
282 /*
283 * Setup fields
284 */
285 so->so_laddr = ip->ip_src;
286 so->so_lport = uh->uh_sport;
287 so->so_iptos = ip->ip_tos;
288
289 if (udp_attach(pData, so) <= 0)
290 {
291 Log2(("NAT: IP(id: %hd) udp_attach errno = %d (%s)\n",
292 ip->ip_id, errno, strerror(errno)));
293 sofree(pData, so);
294 goto bad_free_mbuf;
295 }
296
297 /* udp_last_so = so; */
298 /*
299 * XXXXX Here, check if it's in udpexec_list,
300 * and if it is, do the fork_exec() etc.
301 */
302 }
303
304 so->so_faddr = ip->ip_dst; /* XXX */
305 so->so_fport = uh->uh_dport; /* XXX */
306 Assert(so->so_type == IPPROTO_UDP);
307
308 /*
309 * DNS proxy
310 */
311 if ( pData->fUseDnsProxy
312 && CTL_CHECK(ip->ip_dst.s_addr, CTL_DNS)
313 && (uh->uh_dport == RT_H2N_U16_C(53)))
314 {
315 dnsproxy_query(pData, so, m, iphlen);
316 goto done_free_mbuf;
317 }
318
319 iphlen += sizeof(struct udphdr);
320 m->m_len -= iphlen;
321 m->m_data += iphlen;
322
323 ttl = ip->ip_ttl = save_ip.ip_ttl;
324 if (ttl != so->so_sottl) {
325 ret = setsockopt(so->s, IPPROTO_IP, IP_TTL,
326 (char *)&ttl, sizeof(ttl));
327 if (RT_LIKELY(ret == 0))
328 so->so_sottl = ttl;
329 }
330
331 tos = save_ip.ip_tos;
332 if (tos != so->so_sotos) {
333 ret = setsockopt(so->s, IPPROTO_IP, IP_TOS,
334 (char *)&tos, sizeof(tos));
335 if (RT_LIKELY(ret == 0))
336 so->so_sotos = tos;
337 }
338
339 {
340 /*
341 * Different OSes have different socket options for DF. We
342 * can't use IP_HDRINCL here as it's only valid for SOCK_RAW.
343 */
344# define USE_DF_OPTION(_Optname) \
345 const int dfopt = _Optname
346#if defined(IP_MTU_DISCOVER)
347 USE_DF_OPTION(IP_MTU_DISCOVER);
348#elif defined(IP_DONTFRAG) /* Solaris 11+, FreeBSD */
349 USE_DF_OPTION(IP_DONTFRAG);
350#elif defined(IP_DONTFRAGMENT) /* Windows */
351 USE_DF_OPTION(IP_DONTFRAGMENT);
352#else
353 USE_DF_OPTION(0);
354#endif
355 if (dfopt) {
356 int df = (save_ip.ip_off & IP_DF) != 0;
357#if defined(IP_MTU_DISCOVER)
358 df = df ? IP_PMTUDISC_DO : IP_PMTUDISC_DONT;
359#endif
360 if (df != so->so_sodf) {
361 ret = setsockopt(so->s, IPPROTO_IP, dfopt,
362 (char *)&df, sizeof(df));
363 if (RT_LIKELY(ret == 0))
364 so->so_sodf = df;
365 }
366 }
367 }
368
369 if ( sosendto(pData, so, m) == -1
370 && ( !soIgnorableErrorCode(errno)
371 && errno != ENOTCONN))
372 {
373 m->m_len += iphlen;
374 m->m_data -= iphlen;
375 *ip = save_ip;
376 Log2(("NAT: UDP tx errno = %d (%s) on sent to %RTnaipv4\n",
377 errno, strerror(errno), ip->ip_dst));
378 icmp_error(pData, m, ICMP_UNREACH, ICMP_UNREACH_NET, 0, strerror(errno));
379 so->so_m = NULL;
380 LogFlowFuncLeave();
381 return;
382 }
383
384 if (so->so_m)
385 m_freem(pData, so->so_m); /* used for ICMP if error on sorecvfrom */
386
387 /* restore the orig mbuf packet */
388 m->m_len += iphlen;
389 m->m_data -= iphlen;
390 *ip = save_ip;
391 so->so_m = m; /* ICMP backup */
392 LogFlowFuncLeave();
393 return;
394
395bad_free_mbuf:
396 Log2(("NAT: UDP(id: %hd) datagram to %RTnaipv4 with size(%d) claimed as bad\n",
397 ip->ip_id, &ip->ip_dst, ip->ip_len));
398
399done_free_mbuf:
400 /* some services like bootp(built-in), dns(buildt-in) and dhcp don't need sockets
401 * and create new m'buffers to send them to guest, so we'll free their incomming
402 * buffers here.
403 */
404 if (m != NULL)
405 m_freem(pData, m);
406 LogFlowFuncLeave();
407 return;
408}
409
410/**
411 * Output a UDP packet.
412 *
413 * @note This function will finally free m!
414 */
415int udp_output2(PNATState pData, struct socket *so, struct mbuf *m,
416 struct sockaddr_in *saddr, struct sockaddr_in *daddr,
417 int iptos)
418{
419 register struct udpiphdr *ui;
420 int error;
421 int mlen = 0;
422
423 LogFlowFunc(("ENTER: so = %R[natsock], m = %p, saddr = %RTnaipv4, daddr = %RTnaipv4\n",
424 so, m, saddr->sin_addr.s_addr, daddr->sin_addr.s_addr));
425
426 /* in case of built-in service so might be NULL */
427 if (so) Assert(so->so_type == IPPROTO_UDP);
428
429 /*
430 * Adjust for header
431 */
432 m->m_data -= sizeof(struct udpiphdr);
433 m->m_len += sizeof(struct udpiphdr);
434 mlen = m_length(m, NULL);
435
436 /*
437 * Fill in mbuf with extended UDP header
438 * and addresses and length put into network format.
439 */
440 ui = mtod(m, struct udpiphdr *);
441 memset(ui->ui_x1, 0, 9);
442 ui->ui_pr = IPPROTO_UDP;
443 ui->ui_len = RT_H2N_U16((uint16_t)(mlen - sizeof(struct ip)));
444 /* XXXXX Check for from-one-location sockets, or from-any-location sockets */
445 ui->ui_src = saddr->sin_addr;
446 ui->ui_dst = daddr->sin_addr;
447 ui->ui_sport = saddr->sin_port;
448 ui->ui_dport = daddr->sin_port;
449 ui->ui_ulen = ui->ui_len;
450
451 /*
452 * Stuff checksum and output datagram.
453 */
454 ui->ui_sum = 0;
455 if (udpcksum)
456 {
457 if ((ui->ui_sum = cksum(m, /* sizeof (struct udpiphdr) + */ mlen)) == 0)
458 ui->ui_sum = 0xffff;
459 }
460 ((struct ip *)ui)->ip_len = mlen;
461 ((struct ip *)ui)->ip_ttl = ip_defttl;
462 ((struct ip *)ui)->ip_tos = iptos;
463
464 udpstat.udps_opackets++;
465
466 error = ip_output(pData, so, m);
467
468 return error;
469}
470
471/**
472 * @note This function will free m!
473 */
474int udp_output(PNATState pData, struct socket *so, struct mbuf *m,
475 struct sockaddr_in *addr)
476{
477 struct sockaddr_in saddr, daddr;
478
479 Assert(so->so_type == IPPROTO_UDP);
480 LogFlowFunc(("ENTER: so = %R[natsock], m = %p, saddr = %RTnaipv4\n", so, m, addr->sin_addr.s_addr));
481
482 if (so->so_laddr.s_addr == INADDR_ANY)
483 {
484 if (pData->guest_addr_guess.s_addr != INADDR_ANY)
485 {
486 LogRel2(("NAT: port-forward: using %RTnaipv4 for %R[natsock]\n",
487 pData->guest_addr_guess.s_addr, so));
488 so->so_laddr = pData->guest_addr_guess;
489 }
490 else
491 {
492 LogRel2(("NAT: port-forward: guest address unknown for %R[natsock]\n", so));
493 m_freem(pData, m);
494 return 0;
495 }
496 }
497
498 saddr = *addr;
499 if ((so->so_faddr.s_addr & RT_H2N_U32(pData->netmask)) == pData->special_addr.s_addr)
500 {
501 saddr.sin_addr.s_addr = so->so_faddr.s_addr;
502 if (slirpIsWideCasting(pData, so->so_faddr.s_addr))
503 {
504 /**
505 * We haven't got real firewall but have got its submodule libalias.
506 */
507 m->m_flags |= M_SKIP_FIREWALL;
508 /**
509 * udp/137 port is Name Service in NetBIOS protocol. for some reasons Windows guest rejects
510 * accept data from non-aliased server.
511 */
512 if ( (so->so_fport == so->so_lport)
513 && (so->so_fport == RT_H2N_U16(137)))
514 saddr.sin_addr.s_addr = alias_addr.s_addr;
515 else
516 saddr.sin_addr.s_addr = addr->sin_addr.s_addr;
517 so->so_faddr.s_addr = addr->sin_addr.s_addr;
518 }
519 }
520
521 /* Any UDP packet to the loopback address must be translated to be from
522 * the forwarding address, i.e. 10.0.2.2. */
523 if ( (saddr.sin_addr.s_addr & RT_H2N_U32_C(IN_CLASSA_NET))
524 == RT_H2N_U32_C(INADDR_LOOPBACK & IN_CLASSA_NET))
525 saddr.sin_addr.s_addr = alias_addr.s_addr;
526
527 daddr.sin_addr = so->so_laddr;
528 daddr.sin_port = so->so_lport;
529
530 return udp_output2(pData, so, m, &saddr, &daddr, so->so_iptos);
531}
532
533int
534udp_attach(PNATState pData, struct socket *so)
535{
536 struct sockaddr sa_addr;
537 socklen_t socklen = sizeof(struct sockaddr);
538 int status;
539 int opt = 1;
540
541 AssertReturn(so->so_type == 0, -1);
542 so->so_type = IPPROTO_UDP;
543
544 so->s = socket(AF_INET, SOCK_DGRAM, 0);
545 if (so->s == -1)
546 goto error;
547 fd_nonblock(so->s);
548
549 so->so_sottl = 0;
550 so->so_sotos = 0;
551 so->so_sodf = -1;
552
553 status = sobind(pData, so);
554 if (status != 0)
555 return status;
556
557 /* success, insert in queue */
558 so->so_expire = curtime + SO_EXPIRE;
559
560 /* enable broadcast for later use */
561 setsockopt(so->s, SOL_SOCKET, SO_BROADCAST, (const char *)&opt, sizeof(opt));
562
563 status = getsockname(so->s, &sa_addr, &socklen);
564 if (status == 0)
565 {
566 Assert(sa_addr.sa_family == AF_INET);
567 so->so_hlport = ((struct sockaddr_in *)&sa_addr)->sin_port;
568 so->so_hladdr.s_addr = ((struct sockaddr_in *)&sa_addr)->sin_addr.s_addr;
569 }
570
571 SOCKET_LOCK_CREATE(so);
572 QSOCKET_LOCK(udb);
573 insque(pData, so, &udb);
574 NSOCK_INC();
575 QSOCKET_UNLOCK(udb);
576 return so->s;
577error:
578 Log2(("NAT: can't create datagram socket\n"));
579 return -1;
580}
581
582void
583udp_detach(PNATState pData, struct socket *so)
584{
585 if (so != &pData->icmp_socket)
586 {
587 Assert(so->so_type == IPPROTO_UDP);
588 QSOCKET_LOCK(udb);
589 SOCKET_LOCK(so);
590 QSOCKET_UNLOCK(udb);
591 closesocket(so->s);
592 sofree(pData, so);
593 SOCKET_UNLOCK(so);
594 }
595}
596
597struct socket *
598udp_listen(PNATState pData, u_int32_t bind_addr, u_int port, u_int32_t laddr, u_int lport, int flags)
599{
600 struct sockaddr_in addr;
601 struct socket *so;
602 socklen_t addrlen = sizeof(struct sockaddr_in);
603 int opt = 1;
604 LogFlowFunc(("ENTER: bind_addr:%RTnaipv4, port:%d, laddr:%RTnaipv4, lport:%d, flags:%x\n",
605 bind_addr, RT_N2H_U16(port), laddr, RT_N2H_U16(lport), flags));
606
607 if ((so = socreate()) == NULL)
608 {
609 LogFlowFunc(("LEAVE: NULL\n"));
610 return NULL;
611 }
612
613 so->s = socket(AF_INET, SOCK_DGRAM, 0);
614 if (so->s == -1)
615 {
616 LogRel(("NAT: can't create datagram socket\n"));
617 RTMemFree(so);
618 LogFlowFunc(("LEAVE: NULL\n"));
619 return NULL;
620 }
621 so->so_expire = curtime + SO_EXPIRE;
622 so->so_type = IPPROTO_UDP;
623 fd_nonblock(so->s);
624 so->so_sottl = 0;
625 so->so_sotos = 0;
626 so->so_sodf = -1;
627 SOCKET_LOCK_CREATE(so);
628 QSOCKET_LOCK(udb);
629 insque(pData, so, &udb);
630 NSOCK_INC();
631 QSOCKET_UNLOCK(udb);
632
633 memset(&addr, 0, sizeof(addr));
634#ifdef RT_OS_DARWIN
635 addr.sin_len = sizeof(addr);
636#endif
637 addr.sin_family = AF_INET;
638 addr.sin_addr.s_addr = bind_addr;
639 addr.sin_port = port;
640
641 if (bind(so->s,(struct sockaddr *)&addr, addrlen) < 0)
642 {
643 LogRel(("NAT: udp bind to %RTnaipv4:%d failed, error %d\n",
644 addr.sin_addr, RT_N2H_U16(port), errno));
645 udp_detach(pData, so);
646 LogFlowFunc(("LEAVE: NULL\n"));
647 return NULL;
648 }
649 setsockopt(so->s, SOL_SOCKET, SO_REUSEADDR,(char *)&opt, sizeof(int));
650/* setsockopt(so->s, SOL_SOCKET, SO_OOBINLINE,(char *)&opt, sizeof(int)); */
651
652 getsockname(so->s,(struct sockaddr *)&addr,&addrlen);
653 so->so_hladdr = addr.sin_addr;
654 so->so_hlport = addr.sin_port;
655
656 /* XXX: wtf are we setting so_faddr/so_fport here? */
657 so->so_fport = addr.sin_port;
658#if 0
659 /* The original check was completely broken, as the commented out
660 * if statement was always true (INADDR_ANY=0). */
661 /** @todo vvl - alias_addr should be set (if required)
662 * later by liabalias module.
663 */
664 if (addr.sin_addr.s_addr == 0 || addr.sin_addr.s_addr == loopback_addr.s_addr)
665 so->so_faddr = alias_addr;
666 else
667#endif
668 so->so_faddr = addr.sin_addr;
669
670 so->so_lport = lport;
671 so->so_laddr.s_addr = laddr;
672 if (flags != SS_FACCEPTONCE)
673 so->so_expire = 0;
674
675 so->so_state = SS_ISFCONNECTED;
676
677 LogFlowFunc(("LEAVE: %R[natsock]\n", so));
678 return so;
679}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette