network - Move socket from netmsg ext to netmsg header, add port to socket
[dragonfly.git] / sys / netinet6 / ip6_demux.c
CommitLineData
e9f8c2a6
SZ
1/*
2 * Copyright (c) 2003, 2004 Jeffrey M. Hsu. All rights reserved.
3 * Copyright (c) 2003, 2004 The DragonFly Project. All rights reserved.
4 *
5 * This code is derived from software contributed to The DragonFly Project
6 * by Jeffrey M. Hsu.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of The DragonFly Project nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific, prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#include "opt_inet6.h"
35
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/kernel.h>
39#include <sys/socket.h>
40#include <sys/socketvar.h>
41
42#include <netinet/tcp_var.h>
43#include <netinet6/tcp6_var.h>
44
45lwkt_port_t
48e7b118 46tcp6_soport(struct socket *so, struct sockaddr *nam, struct mbuf **m0)
e9f8c2a6
SZ
47{
48 struct inpcb *inp;
49
50 /*
48e7b118 51 * Use IPv6 default tcp soport (tcp protocol thread on cpu 0) if:
e9f8c2a6
SZ
52 * - No socket yet
53 * - No inp, connection reset by peer
54 * - IPv6 only
55 * - Not IPv4 mapped
56 */
57 if (so == NULL || (inp = so->so_pcb) == NULL ||
58 (inp->inp_flags & IN6P_IPV6_V6ONLY) ||
48e7b118
MD
59 (inp->inp_vflag & INP_IPV4) == 0) {
60 return tcp6_addrport();
61 }
e9f8c2a6
SZ
62
63 /* IPv4 mapped, fall back to IPv4 tcp_soport */
48e7b118 64 return tcp_soport(so, nam, m0);
e9f8c2a6 65}
65f3e756
MD
66
67/*
68 * XXX hack
69 */
70lwkt_port_t
71tcp6_addrport(void)
72{
73 return(tcp_addrport0());
74}