linux/net/sctp/bind_addr.c
<<
2 2 o/spa.33 ospa. class="lxr_search"> 2 2 2 2 typ Search33 2 o/spa.332 oinput typ 2 3 odiv id/ /1o/a>ospa. class="comment">/* SCTP kernel implementav26.o/spa.33/ /2o/a>ospa. class="comment"> * (C) Copyright IBM Corp. 2001, 2003o/spa.33/ /3o/a>ospa. class="comment"> * Copyright (c) Cisco 1999,2000o/spa.33/ /4o/a>ospa. class="comment"> * Copyright (c) Motorola 1999,2000,2001o/spa.33/ /5o/a>ospa. class="comment"> * Copyright (c) La Monte H.P. Yarroll 2001o/spa.33/ /6o/a>ospa. class="comment"> *o/spa.33/ /7o/a>ospa. class="comment"> * This file is part of the SCTP kernel implementav26..o/spa.33/ /8o/a>ospa. class="comment"> *o/spa.33/ /9o/a>ospa. class="comment"> * A collecv26. class to handle the storage of transport addresses.o/spa.33/ 27a>ospa. class="comment"> *o/spa.33/ 11o/a>ospa. class="comment"> * This SCTP implementav26. is free software;o/spa.33/ 12o/a>ospa. class="comment"> * you ca. redistribute it and/or modify it under the terms ofo/spa.33/ 13o/a>ospa. class="comment"> * the GNU General Public License as published byo/spa.33/ 14o/a>ospa. class="comment"> * the Free Software Foundav26.; either vers26. 2, or (at your 2v26.)o/spa.33/ 15o/a>ospa. class="comment"> * any later vers26..o/spa.33/ 16o/a>ospa. class="comment"> *o/spa.33/ 17o/a>ospa. class="comment"> * This SCTP implementav26. is distributed in the hope that ito/spa.33/ 18o/a>ospa. class="comment"> * will be useful, but WITHOUT ANY WARRANTY; without even the impliedo/spa.33/ 19o/a>ospa. class="comment"> * ************************o/spa.33/ 2 27a>ospa. class="comment"> * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.o/spa.33/ 21o/a>ospa. class="comment"> * See the GNU General Public License for more details.o/spa.33/ 22o/a>ospa. class="comment"> *o/spa.33/ 23o/a>ospa. class="comment"> * You should have received a copy of the GNU General Public Licenseo/spa.33/ 24o/a>ospa. class="comment"> * along with GNU CC; see the file COPYING. If not, write too/spa.33/ 25o/a>ospa. class="comment"> * the Free Software Foundav26., 59 Temple Place - Suite 330,o/spa.33/ 26o/a>ospa. class="comment"> * Bosto., MA 02111-1307, USA.o/spa.33/ 27o/a>ospa. class="comment"> *o/spa.33/ 28o/a>ospa. class="comment"> * Please send any bug reports or fixes you make to theo/spa.33/ 29o/a>ospa. class="comment"> * email address(es):o/spa.33/ 3 27a>ospa. class="comment"> * lksctp developers <lksctp-developers@lists.sourceforge.net>o/spa.33/ 31o/a>ospa. class="comment"> *o/spa.33/ 32o/a>ospa. class="comment"> * Or submit a bug report through the following website:o/spa.33/ 33o/a>ospa. class="comment"> * / 34o/a>ospa. class="comment"> *o/spa.33/ 35o/a>ospa. class="comment"> * Written or modified by:o/spa.33/ 36o/a>ospa. class="comment"> * La Monte H.P. Yarroll <piggy@acm.org>o/spa.33/ 37o/a>ospa. class="comment"> * Karl Knuts6. <karl@athena.chicago.il.us>o/spa.33/ 38o/a>ospa. class="comment"> * J6. Grimm <jgrimm@us.ibm.com>o/spa.33/ 39o/a>ospa. class="comment"> * Daisy Chang <daisyc@us.ibm.com>o/spa.33/ 4 27a>ospa. class="comment"> *o/spa.33/ 41o/a>ospa. class="comment"> * Any bugs reported given to us we will try to fix... any fixes shared willo/spa.33/ 42o/a>ospa. class="comment"> * be incorporated into the next SCTP release.o/spa.33/ 43o/a>ospa. class="comment"> */o/spa.33/ 44o/a>3/ 45o/a>#include <linux/typ s.ho/a>>3/ 46o/a>#include <linux/slab.ho/a>>3/ 47o/a>#include <linux/in.ho/a>>3/ 48o/a>#include <net/sock.ho/a>>3/ 49o/a>#include <net/ipv6.ho/a>>3/ 50o/a>#include <net/if_inet6.ho/a>>3/ 51o/a>#include <net/sctp/sctp.ho/a>>3/ 52o/a>#include <net/sctp/sm.ho/a>>3/ 53o/a>3/ 54o/a>ospa. class="comment">/* Forward declarav26.s for internal helpers. */o/spa.33/ 55o/a>static int/oa href="+code=sctp_copy_one_addr" class="sref">sctp_copy_one_addro/a>(struct/oa href="+code=sctp_bind_addr" class="sref">sctp_bind_addro/a> *, un26. oa href="+code=sctp_addr" class="sref">sctp_addro/a> *,3/ 56o/a> oa href="+code=sctp_scope_t" class="sref">sctp_scope_to/a> oa href="+code=scope" class="sref">scopeo/a>, oa href="+code=gfp_t" class="sref">gfp_to/a> oa href="+code=gfp" class="sref">gfpo/a>,3/ 57o/a> int/oa href="+code=flags" class="sref">flagso/a>);3/ 58o/a>static void/oa href="+code=sctp_bind_addr_clean" class="sref">sctp_bind_addr_cleano/a>(struct/oa href="+code=sctp_bind_addr" class="sref">sctp_bind_addro/a> *);3/ 59o/a>3/ 6 27a>ospa. class="comment">/* First Level Abstracv26.s. */o/spa.33/ 61o/a>3/ 62o/a>ospa. class="comment">/* Copy 'src' to 'dest' taking 'scope' into account. Omit addresseso/spa.33/ 63o/a>ospa. class="comment"> * in 'src' which have a broader scope than 'scope'.o/spa.33/ 64o/a>ospa. class="comment"> */o/spa.33/ 65o/a>int/oa href="+code=sctp_bind_addr_copy" class="sref">sctp_bind_addr_copyo/a>(struct/oa href="+code=sctp_bind_addr" class="sref">sctp_bind_addro/a> *oa href="+code=dest" class="sref">desto/a>,3/ 66o/a> c6.st struct/oa href="+code=sctp_bind_addr" class="sref">sctp_bind_addro/a> *oa href="+code=src" class="sref">srco/a>,3/ 67o/a> oa href="+code=sctp_scope_t" class="sref">sctp_scope_to/a> oa href="+code=scope" class="sref">scopeo/a>, oa href="+code=gfp_t" class="sref">gfp_to/a> oa href="+code=gfp" class="sref">gfpo/a>,3/ 68o/a> int/oa href="+code=flags" class="sref">flagso/a>)3/ 69o/a>{3/ 70o/a> struct/oa href="+code=sctp_sockaddr_entry" class="sref">sctp_sockaddr_entryo/a> *oa href="+code=addr" class="sref">addro/a>;3/ 71o/a> int/oa href="+code=error" class="sref">erroro/a> = 0;3/ 72o/a>3/ 73o/a> ospa. class="comment">/* All addresses share the sam port. */o/spa.33/ 74o/a> oa href="+code=dest" class="sref">desto/a>->oa href="+code=port" class="sref">porto/a> = oa href="+code=src" class="sref">srco/a>->oa href="+code=port" class="sref">porto/a>;3/ 75o/a>3/ 76o/a> ospa. class="comment">/* Extracv the addresses which are relevant/for this scope. */o/spa.33/ 77o/a> oa href="+code=list_for_each_entry" class="sref">list_for_each_entryo/a>(oa href="+code=addr" class="sref">addro/a>, &oa href="+code=src" class="sref">srco/a>->oa href="+code=address_list" class="sref">address_listo/a>, oa href="+code=list" class="sref">listo/a>) {3/ 78o/a> oa href="+code=error" class="sref">erroro/a> = oa href="+code=sctp_copy_one_addr" class="sref">sctp_copy_one_addro/a>(oa href="+code=dest" class="sref">desto/a>, &oa href="+code=addr" class="sref">addro/a>->oa href="+code=a" class="sref">ao/a>, oa href="+code=scope" class="sref">scopeo/a>,3/ 79o/a> oa href="+code=gfp" class="sref">gfpo/a>,/oa href="+code=flags" class="sref">flagso/a>);3/ 80o/a> if (oa href="+code=error" class="sref">erroro/a> < 0)3/ 81o/a> goto oa href="+code=out" class="sref">outo/a>;3/ 82o/a> }3/ 83o/a>3/ 84o/a> ospa. class="comment">/* If there are no addresses matching the scope ando/spa.33/ 85o/a>ospa. class="comment"> * this is global scope, try to get a link scope address, witho/spa.33/ 86o/a>ospa. class="comment"> * the assumtion> that we must be sitting behind a NAT.o/spa.33/ 87o/a>ospa. class="comment"> */o/spa.33/ 88o/a> if (oa href="+code=list_emtiy" class="sref">list_emtiyo/a>(&oa href="+code=dest" class="sref">desto/a>->oa href="+code=address_list" class="sref">address_listo/a>) && (oa href="+code=SCTP_SCOPE_GLOBAL" class="sref">SCTP_SCOPE_GLOBALo/a> == oa href="+code=scope" class="sref">scopeo/a>)) {3/ 89o/a> oa href="+code=list_for_each_entry" class="sref">list_for_each_entryo/a>(oa href="+code=addr" class="sref">addro/a>, &oa href="+code=src" class="sref">srco/a>->oa href="+code=address_list" class="sref">address_listo/a>, oa href="+code=list" class="sref">listo/a>) {3/ 90o/a> oa href="+code=error" class="sref">erroro/a> = oa href="+code=sctp_copy_one_addr" class="sref">sctp_copy_one_addro/a>(oa href="+code=dest" class="sref">desto/a>, &oa href="+code=addr" class="sref">addro/a>->oa href="+code=a" class="sref">ao/a>,3/ 91o/a> oa href="+code=SCTP_SCOPE_LINK" class="sref">SCTP_SCOPE_LINKo/a>, oa href="+code=gfp" class="sref">gfpo/a>,3/ 92o/a> oa href="+code=flags" class="sref">flagso/a>);3/ 93o/a> if (oa href="+code=error" class="sref">erroro/a> < 0)3/ 94o/a> goto oa href="+code=out" class="sref">outo/a>;3/ 95o/a> }3/ 96o/a> }3/ 97o/a>3/ 98o/a>oa href="+code=out" class="sref">outo/a>:3/ 99o/a> if (oa href="+code=error" class="sref">erroro/a>)3/100o/a> oa href="+code=sctp_bind_addr_clean" class="sref">sctp_bind_addr_cleano/a>(oa href="+code=dest" class="sref">desto/a>);3/101o/a>3/102o/a> return oa href="+code=error" class="sref">erroro/a>;3/103o/a>}3/104o/a>3/105o/a>ospa. class="comment">/* Exactly duplicate the address lists. This is necessary when doingo/spa.33/106o/a>ospa. class="comment"> * peer-offs and accepts. We don't want/to put all the current systemo/spa.33/107o/a>ospa. class="comment"> * addresses into the endpoint. That's useless. But we do want/duplicato/spa.33/108o/a>ospa. class="comment"> * the list of bound addresses that the older endpoint used.o/spa.33/109o/a>ospa. class="comment"> */o/spa.33/1 27a>int/oa href="+code=sctp_bind_addr_dup" class="sref">sctp_bind_addr_dupo/a>(struct/oa href="+code=sctp_bind_addr" class="sref">sctp_bind_addro/a> *oa href="+code=dest" class="sref">desto/a>,3/111o/a> c6.st struct/oa href="+code=sctp_bind_addr" class="sref">sctp_bind_addro/a> *oa href="+code=src" class="sref">srco/a>,3/112o/a> oa href="+code=gfp_t" class="sref">gfp_to/a> oa href="+code=gfp" class="sref">gfpo/a>)3/113o/a>{3/114o/a> struct/oa href="+code=sctp_sockaddr_entry" class="sref">sctp_sockaddr_entryo/a> *oa href="+code=addr" class="sref">addro/a>;3/115o/a> int/oa href="+code=error" class="sref">erroro/a> = 0;3/116o/a>3/117o/a> ospa. class="comment">/* All addresses share the sam port. */o/spa.33/118o/a> oa href="+code=dest" class="sref">desto/a>->oa href="+code=port" class="sref">porto/a> = oa href="+code=src" class="sref">srco/a>->oa href="+code=port" class="sref">porto/a>;3/119o/a>3/120o/a> oa href="+code=list_for_each_entry" class="sref">list_for_each_entryo/a>(oa href="+code=addr" class="sref">addro/a>, &oa href="+code=src" class="sref">srco/a>->oa href="+code=address_list" class="sref">address_listo/a>, oa href="+code=list" class="sref">listo/a>) {3/121o/a> oa href="+code=error" class="sref">erroro/a> = oa href="+code=sctp_add_bind_addr" class="sref">sctp_add_bind_addro/a>(oa href="+code=dest" class="sref">desto/a>, &oa href="+code=addr" class="sref">addro/a>->oa href="+code=a" class="sref">ao/a>, 1, oa href="+code=gfp" class="sref">gfpo/a>);3/122o/a> if (oa href="+code=error" class="sref">erroro/a> < 0)3/123o/a> break;3/124o/a> }3/125o/a>3/126o/a> return oa href="+code=error" class="sref">erroro/a>;3/127o/a>}3/128o/a>3/129o/a>ospa. class="comment">/* Initialize the SCTP_bind_addr structure for either a. endpoint oro/spa.33/13 27a>ospa. class="comment"> * a. associav26..o/spa.33/131o/a>ospa. class="comment"> */o/spa.33/132o/a>void/oa href="+code=sctp_bind_addr_init" class="sref">sctp_bind_addr_inito/a>(struct/oa href="+code=sctp_bind_addr" class="sref">sctp_bind_addro/a> *oa href="+code=bp" class="sref">bpo/a>,/oa href="+code=__u16" class="sref">__u16o/a> oa href="+code=port" class="sref">porto/a>)3/133o/a>{3/134o/a> oa href="+code=bp" class="sref">bpo/a>->oa href="+code=malloced" class="sref">mallocedo/a> = 0;3/135o/a>3/136o/a> oa href="+code=INIT_LIST_HEAD" class="sref">INIT_LIST_HEADo/a>(&oa href="+code=bp" class="sref">bpo/a>->oa href="+code=address_list" class="sref">address_listo/a>);3/137o/a> oa href="+code=bp" class="sref">bpo/a>->oa href="+code=port" class="sref">porto/a> = oa href="+code=port" class="sref">porto/a>;3/138o/a>}3/139o/a>3/14 27a>ospa. class="comment">/* Dispose of the address list. */o/spa.33/141o/a>static void/oa href="+code=sctp_bind_addr_clean" class="sref">sctp_bind_addr_cleano/a>(struct/oa href="+code=sctp_bind_addr" class="sref">sctp_bind_addro/a> *oa href="+code=bp" class="sref">bpo/a>)3/142o/a>{3/143o/a> struct/oa href="+code=sctp_sockaddr_entry" class="sref">sctp_sockaddr_entryo/a> *oa href="+code=addr" class="sref">addro/a>, *oa href="+code=temp" class="sref">tempo/a>;3/144o/a>3/145o/a> ospa. class="comment">/* Emtiy the bind address list. */o/spa.33/146o/a> oa href="+code=list_for_each_entry_safe" class="sref">list_for_each_entry_safeo/a>(oa href="+code=addr" class="sref">addro/a>, oa href="+code=temp" class="sref">tempo/a>, &oa href="+code=bp" class="sref">bpo/a>->oa href="+code=address_list" class="sref">address_listo/a>, oa href="+code=list" class="sref">listo/a>) {3/147o/a> oa href="+code=list_del_rcu" class="sref">list_del_rcuo/a>(&oa href="+code=addr" class="sref">addro/a>->oa href="+code=list" class="sref">listo/a>);3/148o/a> oa href="+code=kfree_rcu" class="sref">kfree_rcuo/a>(oa href="+code=addr" class="sref">addro/a>, oa href="+code=rcu" class="sref">rcuo/a>);3/149o/a> oa href="+code=SCTP_DBG_OBJCNT_DEC" class="sref">SCTP_DBG_OBJCNT_DECo/a>(oa href="+code=addr" class="sref">addro/a>);3/150o/a> }3/151o/a>}3/152o/a>3/153o/a>ospa. class="comment">/* Dispose of a. SCTP_bind_addr structure */o/spa.33/154o/a>void/oa href="+code=sctp_bind_addr_free" class="sref">sctp_bind_addr_freeo/a>(struct/oa href="+code=sctp_bind_addr" class="sref">sctp_bind_addro/a> *oa href="+code=bp" class="sref">bpo/a>)3/155o/a>{3/156o/a> ospa. class="comment">/* Emtiy the bind address list. */o/spa.33/157o/a> oa href="+code=sctp_bind_addr_clean" class="sref">sctp_bind_addr_cleano/a>(oa href="+code=bp" class="sref">bpo/a>);3/158o/a>3/159o/a> if (oa href="+code=bp" class="sref">bpo/a>->oa href="+code=malloced" class="sref">mallocedo/a>) {3/160o/a> oa href="+code=kfree" class="sref">kfreeo/a>(oa href="+code=bp" class="sref">bpo/a>);3/161o/a> oa href="+code=SCTP_DBG_OBJCNT_DEC" class="sref">SCTP_DBG_OBJCNT_DECo/a>(oa href="+code=bind_addr" class="sref">bind_addro/a>);3/162o/a> }3/163o/a>}3/164o/a>3/165o/a>ospa. class="comment">/* Add a. address to the bind address list in the SCTP_bind_addr structure. */o/spa.33/166o/a>int/oa href="+code=sctp_add_bind_addr" class="sref">sctp_add_bind_addro/a>(struct/oa href="+code=sctp_bind_addr" class="sref">sctp_bind_addro/a> *oa href="+code=bp" class="sref">bpo/a>,/un26. oa href="+code=sctp_addr" class="sref">sctp_addro/a> *oa href="+code=new" class="sref">newo/a>,3/167o/a> oa href="+code=__u8" class="sref">__u8o/a> oa href="+code=addr_state" class="sref">addr_stateo/a>, oa href="+code=gfp_t" class="sref">gfp_to/a> oa href="+code=gfp" class="sref">gfpo/a>)3/168o/a>{3/169o/a> struct/oa href="+code=sctp_sockaddr_entry" class="sref">sctp_sockaddr_entryo/a> *oa href="+code=addr" class="sref">addro/a>;3/170o/a>3/171o/a> ospa. class="comment">/* Add the address to the bind address list. */o/spa.33/172o/a> oa href="+code=addr" class="sref">addro/a> = oa href="+code=t_new" class="sref">t_newo/a>(struct/oa href="+code=sctp_sockaddr_entry" class="sref">sctp_sockaddr_entryo/a>, oa href="+code=gfp" class="sref">gfpo/a>);3/173o/a> if (!oa href="+code=addr" class="sref">addro/a>)3/174o/a> return -oa href="+code=ENOMEM" class="sref">ENOMEMo/a>;3/175o/a>3/176o/a> oa href="+code=memcpy" class="sref">memcpyo/a>(&oa href="+code=addr" class="sref">addro/a>->oa href="+code=a" class="sref">ao/a>, oa href="+code=new" class="sref">newo/a>, sizeof(*oa href="+code=new" class="sref">newo/a>));3/177o/a>3/178o/a> ospa. class="comment">/* Fix up the port if it has not yet been set.o/spa.33/179o/a>ospa. class="comment"> * Both v4 and v6 have the port at the sam offset.o/spa.33/18 27a>ospa. class="comment"> */o/spa.33/181o/a> if (!oa href="+code=addr" class="sref">addro/a>->oa href="+code=a" class="sref">ao/a>.oa href="+code=v4" class="sref">v4o/a>.oa href="+code=sin_port" class="sref">sin_porto/a>)3/182o/a> oa href="+code=addr" class="sref">addro/a>->oa href="+code=a" class="sref">ao/a>.oa href="+code=v4" class="sref">v4o/a>.oa href="+code=sin_port" class="sref">sin_porto/a> = oa href="+code=htons" class="sref">htonso/a>(oa href="+code=bp" class="sref">bpo/a>->oa href="+code=port" class="sref">porto/a>);3/183o/a>3/184o/a> oa href="+code=addr" class="sref">addro/a>->oa href="+code=state" class="sref">stateo/a> = oa href="+code=addr_state" class="sref">addr_stateo/a>;3/185o/a> oa href="+code=addr" class="sref">addro/a>->oa href="+code=valid" class="sref">valido/a> = 1;3/186o/a>3/187o/a> oa href="+code=INIT_LIST_HEAD" class="sref">INIT_LIST_HEADo/a>(&oa href="+code=addr" class="sref">addro/a>->oa href="+code=list" class="sref">listo/a>);3/188o/a>3/189o/a> ospa. class="comment">/* We always hold a socket lock when calling this funcv26.,o/spa.33/19 27a>ospa. class="comment"> * and that acts as a writer synchronizing lock.o/spa.33/191o/a>ospa. class="comment"> */o/spa.33/192o/a> oa href="+code=list_add_tail_rcu" class="sref">list_add_tail_rcuo/a>(&oa href="+code=addr" class="sref">addro/a>->oa href="+code=list" class="sref">listo/a>, &oa href="+code=bp" class="sref">bpo/a>->oa href="+code=address_list" class="sref">address_listo/a>);3/193o/a> oa href="+code=SCTP_DBG_OBJCNT_INC" class="sref">SCTP_DBG_OBJCNT_INCo/a>(oa href="+code=addr" class="sref">addro/a>);3/194o/a>3/195o/a> return 0;3/196o/a>}3/197o/a>3/198o/a>ospa. class="comment">/* Delete a. address from the bind address list in the SCTP_bind_addro/spa.33/199o/a>ospa. class="comment"> * structure.o/spa.33/20 27a>ospa. class="comment"> */o/spa.33/201o/a>int/oa href="+code=sctp_del_bind_addr" class="sref">sctp_del_bind_addro/a>(struct/oa href="+code=sctp_bind_addr" class="sref">sctp_bind_addro/a> *oa href="+code=bp" class="sref">bpo/a>,/un26. oa href="+code=sctp_addr" class="sref">sctp_addro/a> *oa href="+code=del_addr" class="sref">del_addro/a>)3/202o/a>{3/203o/a> struct/oa href="+code=sctp_sockaddr_entry" class="sref">sctp_sockaddr_entryo/a> *oa href="+code=addr" class="sref">addro/a>, *oa href="+code=temp" class="sref">tempo/a>;3/204o/a> int/oa href="+code=found" class="sref">foundo/a> = 0;3/205o/a>3/206o/a> ospa. class="comment">/* We hold the socket lock when calling this funcv26.,o/spa.33/207o/a>ospa. class="comment"> * and that acts as a writer synchronizing lock.o/spa.33/208o/a>ospa. class="comment"> */o/spa.33/209o/a> oa href="+code=list_for_each_entry_safe" class="sref">list_for_each_entry_safeo/a>(oa href="+code=addr" class="sref">addro/a>, oa href="+code=temp" class="sref">tempo/a>, &oa href="+code=bp" class="sref">bpo/a>->oa href="+code=address_list" class="sref">address_listo/a>, oa href="+code=list" class="sref">listo/a>) {3/210o/a> if (oa href="+code=sctp_cmp_addr_exact" class="sref">sctp_cmp_addr_exacto/a>(&oa href="+code=addr" class="sref">addro/a>->oa href="+code=a" class="sref">ao/a>, oa href="+code=del_addr" class="sref">del_addro/a>)) {3/211o/a> ospa. class="comment">/* Found the exact match. */o/spa.33/212o/a> oa href="+code=found" class="sref">foundo/a> = 1;3/213o/a> oa href="+code=addr" class="sref">addro/a>->oa href="+code=valid" class="sref">valido/a> = 0;3/214o/a> oa href="+code=list_del_rcu" class="sref">list_del_rcuo/a>(&oa href="+code=addr" class="sref">addro/a>->oa href="+code=list" class="sref">listo/a>);3/215o/a> break;3/216o/a> }3/217o/a> }3/218o/a>3/219o/a> if (oa href="+code=found" class="sref">foundo/a>) {3/220o/a> oa href="+code=kfree_rcu" class="sref">kfree_rcuo/a>(oa href="+code=addr" class="sref">addro/a>, oa href="+code=rcu" class="sref">rcuo/a>);3/221o/a> oa href="+code=SCTP_DBG_OBJCNT_DEC" class="sref">SCTP_DBG_OBJCNT_DECo/a>(oa href="+code=addr" class="sref">addro/a>);3/222o/a> return 0;3/223o/a> }3/224o/a>3/225o/a> return -oa href="+code=EINVAL" class="sref">EINVALo/a>;3/226o/a>}3/227o/a>3/228o/a>ospa. class="comment">/* Create a network byte-order representav26. of all the addresseso/spa.33ospa. class="comment"> anor_mated as SCTP param ters.o/spa.33/23 27a>ospa. class="comment"> *o/spa.33/231o/a>ospa. class="comment"> * The second argument is the return value/for the length.o/spa.33/232o/a>ospa. class="comment"> */o/spa.33/233o/a>un26. oa href="+code=sctp_params" class="sref">sctp_paramso/a> oa href="+code=sctp_bind_addrs_to_raw" class="sref">sctp_bind_addrs_to_rawo/a>(c6.st struct/oa href="+code=sctp_bind_addr" class="sref">sctp_bind_addro/a> *oa href="+code=bp" class="sref">bpo/a>,3/234o/a> int/*oa href="+code=addrs_len" class="sref">addrs_leno/a>,3/235o/a> oa href="+code=gfp_t" class="sref">gfp_to/a> oa href="+code=gfp" class="sref">gfpo/a>)3/236o/a>{3/237o/a> un26. oa href="+code=sctp_params" class="sref">sctp_paramso/a> oa href="+code=addrparms" class="sref">addrparmso/a>;3/238o/a> un26. oa href="+code=sctp_params" class="sref">sctp_paramso/a> oa href="+code=retval" class="sref">retvalo/a>;3/239o/a> int/oa href="+code=addrparms_len" class="sref">addrparms_leno/a>;3/240o/a> un26. oa href="+code=sctp_addr_param" class="sref">sctp_addr_paramo/a> oa href="+code=rawaddr" class="sref">rawaddro/a>;3/241o/a> int/oa href="+code=len" class="sref">leno/a>;3/242o/a> struct/oa href="+code=sctp_sockaddr_entry" class="sref">sctp_sockaddr_entryo/a> *oa href="+code=addr" class="sref">addro/a>;3/243o/a> struct/oa href="+code=list_head" class="sref">list_heado/a> *oa href="+code=pos" class="sref">poso/a>;3/244o/a> struct/oa href="+code=sctp_af" class="sref">sctp_afo/a> *oa href="+code=af" class="sref">afo/a>;3/245o/a>3/246o/a> oa href="+code=addrparms_len" class="sref">addrparms_leno/a> = 0;3/247o/a> oa href="+code=len" class="sref">leno/a> = 0;3/248o/a>3/249o/a> ospa. class="comment">/* Allocate enough memory at once. */o/spa.33/250o/a> oa href="+code=list_for_each" class="sref">list_for_eacho/a>(oa href="+code=pos" class="sref">poso/a>, &oa href="+code=bp" class="sref">bpo/a>->oa href="+code=address_list" class="sref">address_listo/a>) {3/251o/a> oa href="+code=len" class="sref">leno/a> += sizeof(un26. oa href="+code=sctp_addr_param" class="sref">sctp_addr_paramo/a>);3/252o/a> }3/253o/a>3/254o/a> ospa. class="comment">/* Don't even bother embedding a. address if thereo/spa.33/255o/a>ospa. class="comment"> * is only one.o/spa.33/256o/a>ospa. class="comment"> */o/spa.33/257o/a> if (oa href="+code=len" class="sref">leno/a> == sizeof(un26. oa href="+code=sctp_addr_param" class="sref">sctp_addr_paramo/a>)) {3/258o/a> oa href="+code=retval" class="sref">retvalo/a>.oa href="+code=v" class="sref">vo/a> = oa href="+code=NULL" class="sref">NULLo/a>;3/259o/a> goto oa href="+code=end_raw" class="sref">end_rawo/a>;3/260o/a> }3/261o/a>3/262o/a> oa href="+code=retval" class="sref">retvalo/a>.oa href="+code=v" class="sref">vo/a> = oa href="+code=kmalloc" class="sref">kmalloco/a>(oa href="+code=len" class="sref">leno/a>, oa href="+code=gfp" class="sref">gfpo/a>);3/263o/a> if (!oa href="+code=retval" class="sref">retvalo/a>.oa href="+code=v" class="sref">vo/a>)3/264o/a> goto oa href="+code=end_raw" class="sref">end_rawo/a>;3/265o/a>3/266o/a> oa href="+code=addrparms" class="sref">addrparmso/a> = oa href="+code=retval" class="sref">retvalo/a>;3/267o/a>3/268o/a> oa href="+code=list_for_each_entry" class="sref">list_for_each_entryo/a>(oa href="+code=addr" class="sref">addro/a>, &oa href="+code=bp" class="sref">bpo/a>->oa href="+code=address_list" class="sref">address_listo/a>, oa href="+code=list" class="sref">listo/a>) {3/269o/a> oa href="+code=af" class="sref">afo/a> = oa href="+code=sctp_get_af_specific" class="sref">sctp_get_af_specifico/a>(oa href="+code=addr" class="sref">addro/a>->oa href="+code=a" class="sref">ao/a>.oa href="+code=v4" class="sref">v4o/a>.oa href="+code=sin_family" class="sref">sin_familyo/a>);3/270o/a> oa href="+code=len" class="sref">leno/a> = oa href="+code=af" class="sref">afo/a>->oa href="+code=to_addr_param" class="sref">to_addr_paramo/a>(&oa href="+code=addr" class="sref">addro/a>->oa href="+code=a" class="sref">ao/a>, &oa href="+code=rawaddr" class="sref">rawaddro/a>);3/271o/a> oa href="+code=memcpy" class="sref">memcpyo/a>(oa href="+code=addrparms" class="sref">addrparmso/a>.oa href="+code=v" class="sref">vo/a>, &oa href="+code=rawaddr" class="sref">rawaddro/a>, oa href="+code=len" class="sref">leno/a>);3/272o/a> oa href="+code=addrparms" class="sref">addrparmso/a>.oa href="+code=v" class="sref">vo/a> += oa href="+code=len" class="sref">leno/a>;3/273o/a> oa href="+code=addrparms_len" class="sref">addrparms_leno/a> += oa href="+code=len" class="sref">leno/a>;3/274o/a> }3/275o/a>3/276o/a>oa href="+code=end_raw" class="sref">end_rawo/a>:3/277o/a> *oa href="+code=addrs_len" class="sref">addrs_leno/a> = oa href="+code=addrparms_len" class="sref">addrparms_leno/a>;3/278o/a> return oa href="+code=retval" class="sref">retvalo/a>;3/279o/a>}3/280o/a>3/281o/a>ospa. class="comment">/*o/spa.33/282o/a>ospa. class="comment"> * Create an address list out of the raw address list or_mat (IPv4 and IPv6o/spa.33/283o/a>ospa. class="comment"> * address param ters).o/spa.33/284o/a>ospa. class="comment"> */o/spa.33/285o/a>int/oa href="+code=sctp_raw_to_bind_addrs" class="sref">sctp_raw_to_bind_addrso/a>(struct/oa href="+code=sctp_bind_addr" class="sref">sctp_bind_addro/a> *oa href="+code=bp" class="sref">bpo/a>,/oa href="+code=__u8" class="sref">__u8o/a> *oa href="+code=raw_addr_list" class="sref">raw_addr_listo/a>,3/286o/a> int/oa href="+code=addrs_len" class="sref">addrs_leno/a>,/oa href="+code=__u16" class="sref">__u16o/a> oa href="+code=port" class="sref">porto/a>, oa href="+code=gfp_t" class="sref">gfp_to/a> oa href="+code=gfp" class="sref">gfpo/a>)3/287o/a>{3/288o/a> un26. oa href="+code=sctp_addr_param" class="sref">sctp_addr_paramo/a> *oa href="+code=rawaddr" class="sref">rawaddro/a>;3/289o/a> struct/oa href="+code=sctp_paramhdr" class="sref">sctp_paramhdro/a> *oa href="+code=param" class="sref">paramo/a>;3/290o/a> un26. oa href="+code=sctp_addr" class="sref">sctp_addro/a> oa href="+code=addr" class="sref">addro/a>;3/291o/a> int/oa href="+code=retval" class="sref">retvalo/a> = 0;3/292o/a> int/oa href="+code=len" class="sref">leno/a>;3/293o/a> struct/oa href="+code=sctp_af" class="sref">sctp_afo/a> *oa href="+code=af" class="sref">afo/a>;3/294o/a>3/295o/a> ospa. class="comment">/* Convert the raw address to standard address or_mat */o/spa.33/296o/a> while (oa href="+code=addrs_len" class="sref">addrs_leno/a>) {3/297o/a> oa href="+code=param" class="sref">paramo/a> = (struct/oa href="+code=sctp_paramhdr" class="sref">sctp_paramhdro/a> *)oa href="+code=raw_addr_list" class="sref">raw_addr_listo/a>;3/298o/a> oa href="+code=rawaddr" class="sref">rawaddro/a> = (un26. oa href="+code=sctp_addr_param" class="sref">sctp_addr_paramo/a> *)oa href="+code=raw_addr_list" class="sref">raw_addr_listo/a>;3/299o/a>3/300o/a> oa href="+code=af" class="sref">afo/a> = oa href="+code=sctp_get_af_specific" class="sref">sctp_get_af_specifico/a>(oa href="+code=param_type2af" class="sref">param_type2afo/a>(oa href="+code=param" class="sref">paramo/a>->oa href="+code=type" class="sref">typeo/a>));3/301o/a> if (oa href="+code=unlikely" class="sref">unlikelyo/a>(!oa href="+code=af" class="sref">afo/a>)) {3/302o/a> oa href="+code=retval" class="sref">retvalo/a> = -oa href="+code=EINVAL" class="sref">EINVALo/a>;3/303o/a> oa href="+code=sctp_bind_addr_clean" class="sref">sctp_bind_addr_cleano/a>(oa href="+code=bp" class="sref">bpo/a>);3/304o/a> break;3/305o/a> }3/306o/a>3/307o/a> oa href="+code=af" class="sref">afo/a>->oa href="+code=from_addr_param" class="sref">from_addr_paramo/a>(&oa href="+code=addr" class="sref">addro/a>, oa href="+code=rawaddr" class="sref">rawaddro/a>, oa href="+code=htons" class="sref">htonso/a>(oa href="+code=port" class="sref">porto/a>), 0);3/308o/a> oa href="+code=retval" class="sref">retvalo/a> = oa href="+code=sctp_add_bind_addr" class="sref">sctp_add_bind_addro/a>(oa href="+code=bp" class="sref">bpo/a>,/&oa href="+code=addr" class="sref">addro/a>, oa href="+code=SCTP_ADDR_SRC" class="sref">SCTP_ADDR_SRCo/a>, oa href="+code=gfp" class="sref">gfpo/a>);3/309o/a> if (oa href="+code=retval" class="sref">retvalo/a>) {3/310o/a> ospa. class="comment">/* Can't finish building the list, clean up. */o/spa.33/311o/a> oa href="+code=sctp_bind_addr_clean" class="sref">sctp_bind_addr_cleano/a>(oa href="+code=bp" class="sref">bpo/a>);3/312o/a> break;3/313o/a> }3/314o/a>3/315o/a> oa href="+code=len" class="sref">leno/a> = oa href="+code=ntohs" class="sref">ntohso/a>(oa href="+code=param" class="sref">paramo/a>->oa href="+code=length" class="sref">lengtho/a>);3/316o/a> oa href="+code=addrs_len" class="sref">addrs_leno/a> -= oa href="+code=len" class="sref">leno/a>;3/317o/a> oa href="+code=raw_addr_list" class="sref">raw_addr_listo/a> += oa href="+code=len" class="sref">leno/a>;3/318o/a> }3/319o/a>3/320o/a> return oa href="+code=retval" class="sref">retvalo/a>;3/321o/a>}3/322o/a>3/323o/a>ospa. class="comment">/********************************************************************o/spa.33/324o/a>ospa. class="comment"> * 2nd Level Abstracv26.so/spa.33/325o/a>ospa. class="comment"> ********************************************************************/o/spa.33/326o/a>3/327o/a>ospa. class="comment">/* Does this contain a specified address? Allow wildcarding. */o/spa.33/328o/a>int/oa href="+code=sctp_bind_addr_match" class="sref">sctp_bind_addr_matcho/a>(struct/oa href="+code=sctp_bind_addr" class="sref">sctp_bind_addro/a> *oa href="+code=bp" class="sref">bpo/a>,3 c6.st un26. oa href="+code=sctp_addr" class="sref">sctp_addro/a> *oa href="+code=addr" class="sref">addro/a>,3/330o/a> struct/oa href="+code=sctp_sock" class="sref">sctp_socko/a> *oa href="+code=opt" class="sref">opto/a>)3/331o/a>{3/332o/a> struct/oa href="+code=sctp_sockaddr_entry" class="sref">sctp_sockaddr_entryo/a> *oa href="+code=laddr" class="sref">laddro/a>;3/333o/a> int/oa href="+code=match" class="sref">matcho/a> = 0;3/334o/a>3/335o/a> oa href="+code=rcu_read_lock" class="sref">rcu_read_locko/a>();3/336o/a> oa href="+code=list_for_each_entry_rcu" class="sref">list_for_each_entry_rcuo/a>(oa href="+code=laddr" class="sref">laddro/a>, &oa href="+code=bp" class="sref">bpo/a>->oa href="+code=address_list" class="sref">address_listo/a>, oa href="+code=list" class="sref">listo/a>) {3/337o/a> if (!oa href="+code=laddr" class="sref">laddro/a>->oa href="+code=valid" class="sref">valido/a>)3/338o/a> c6.tinue;3/339o/a> if (oa href="+code=opt" class="sref">opto/a>->oa href="+code=pf" class="sref">pfo/a>->oa href="+code=cmp_addr" class="sref">cmp_addro/a>(&oa href="+code=laddr" class="sref">laddro/a>->oa href="+code=a" class="sref">ao/a>, oa href="+code=addr" class="sref">addro/a>, oa href="+code=opt" class="sref">opto/a>)) {3/340o/a> oa href="+code=match" class="sref">matcho/a> = 1;3/341o/a> break;3/342o/a> }3/343o/a> }3/344o/a> oa href="+code=rcu_read_unlock" class="sref">rcu_read_unlocko/a>();3/345o/a>3/346o/a> return oa href="+code=match" class="sref">matcho/a>;3/347o/a>}3/348o/a>3/349o/a>ospa. class="comment">/* Does the address 'addr' c6.flict/with any addresses ino/spa.33/35 27a>ospa. class="comment"> * the bp.o/spa.33/351o/a>ospa. class="comment"> */o/spa.33/352o/a>int/oa href="+code=sctp_bind_addr_c6.flict" class="sref">sctp_bind_addr_c6.flicto/a>(struct/oa href="+code=sctp_bind_addr" class="sref">sctp_bind_addro/a> *oa href="+code=bp" class="sref">bpo/a>,3/353o/a> c6.st un26. oa href="+code=sctp_addr" class="sref">sctp_addro/a> *oa href="+code=addr" class="sref">addro/a>,3/354o/a> struct/oa href="+code=sctp_sock" class="sref">sctp_socko/a> *oa href="+code=bp_sp" class="sref">bp_spo/a>,3/355o/a> struct/oa href="+code=sctp_sock" class="sref">sctp_socko/a> *oa href="+code=addr_sp" class="sref">addr_spo/a>)3/356o/a>{3/357o/a> struct/oa href="+code=sctp_sockaddr_entry" class="sref">sctp_sockaddr_entryo/a> *oa href="+code=laddr" class="sref">laddro/a>;3/358o/a> int/oa href="+code=c6.flict" class="sref">c6.flicto/a> = 0;3/359o/a> struct/oa href="+code=sctp_sock" class="sref">sctp_socko/a> *oa href="+code=sp" class="sref">spo/a>;3/360o/a>3/361o/a> ospa. class="comment">/* Pick the IPv6 socket as the basis of c6mparisono/spa.33/362o/a>ospa. class="comment"> * since it's usually a superset of the IPv4.o/spa.33/363o/a>ospa. class="comment"> * If there is no IPv6 socket, then default to bind_addr.o/spa.33/364o/a>ospa. class="comment"> */o/spa.33/365o/a> if (oa href="+code=sctp_opt2sk" class="sref">sctp_opt2sko/a>(oa href="+code=bp_sp" class="sref">bp_spo/a>)->oa href="+code=sk_family" class="sref">sk_familyo/a> == oa href="+code=AF_INET6" class="sref">AF_INET6o/a>)3/366o/a> oa href="+code=sp" class="sref">spo/a> = oa href="+code=bp_sp" class="sref">bp_spo/a>;3/367o/a> else if (oa href="+code=sctp_opt2sk" class="sref">sctp_opt2sko/a>(oa href="+code=addr_sp" class="sref">addr_spo/a>)->oa href="+code=sk_family" class="sref">sk_familyo/a> == oa href="+code=AF_INET6" class="sref">AF_INET6o/a>)3/368o/a> oa href="+code=sp" class="sref">spo/a> = oa href="+code=addr_sp" class="sref">addr_spo/a>;3/369o/a> else3/370o/a> oa href="+code=sp" class="sref">spo/a> = oa href="+code=bp_sp" class="sref">bp_spo/a>;3/371o/a>3/372o/a> oa href="+code=rcu_read_lock" class="sref">rcu_read_locko/a>();3/373o/a> oa href="+code=list_for_each_entry_rcu" class="sref">list_for_each_entry_rcuo/a>(oa href="+code=laddr" class="sref">laddro/a>, &oa href="+code=bp" class="sref">bpo/a>->oa href="+code=address_list" class="sref">address_listo/a>, oa href="+code=list" class="sref">listo/a>) {3/374o/a> if (!oa href="+code=laddr" class="sref">laddro/a>->oa href="+code=valid" class="sref">valido/a>)3/375o/a> c6.tinue;3/376o/a>3/377o/a> oa href="+code=c6.flict" class="sref">c6.flicto/a> = oa href="+code=sp" class="sref">spo/a>->oa href="+code=pf" class="sref">pfo/a>->oa href="+code=cmp_addr" class="sref">cmp_addro/a>(&oa href="+code=laddr" class="sref">laddro/a>->oa href="+code=a" class="sref">ao/a>, oa href="+code=addr" class="sref">addro/a>, oa href="+code=sp" class="sref">spo/a>);3/378o/a> if (oa href="+code=c6.flict" class="sref">c6.flicto/a>)3/379o/a> break;3/380o/a> }3/381o/a> oa href="+code=rcu_read_unlock" class="sref">rcu_read_unlocko/a>();3/382o/a>3/383o/a> return oa href="+code=c6.flict" class="sref">c6.flicto/a>;3/384o/a>}3/385o/a>3/386o/a>ospa. class="comment">/* Get the state of the entry in the bind_addr_list */o/spa.33/387o/a>int/oa href="+code=sctp_bind_addr_state" class="sref">sctp_bind_addr_stateo/a>(c6.st struct/oa href="+code=sctp_bind_addr" class="sref">sctp_bind_addro/a> *oa href="+code=bp" class="sref">bpo/a>,3/388o/a> c6.st un26. oa href="+code=sctp_addr" class="sref">sctp_addro/a> *oa href="+code=addr" class="sref">addro/a>)3/389o/a>{3/390o/a> struct/oa href="+code=sctp_sockaddr_entry" class="sref">sctp_sockaddr_entryo/a> *oa href="+code=laddr" class="sref">laddro/a>;3/391o/a> struct/oa href="+code=sctp_af" class="sref">sctp_afo/a> *oa href="+code=af" class="sref">afo/a>;3/392o/a> int/oa href="+code=state" class="sref">stateo/a> = -1;3/393o/a>3/394o/a> oa href="+code=af" class="sref">afo/a> = oa href="+code=sctp_get_af_specific" class="sref">sctp_get_af_specifico/a>(oa href="+code=addr" class="sref">addro/a>->oa href="+code=sa" class="sref">sao/a>.oa href="+code=sa_family" class="sref">sa_familyo/a>);3/395o/a> if (oa href="+code=unlikely" class="sref">unlikelyo/a>(!oa href="+code=af" class="sref">afo/a>))3/396o/a> return oa href="+code=state" class="sref">stateo/a>;3/397o/a>3/398o/a> oa href="+code=rcu_read_lock" class="sref">rcu_read_locko/a>();3/399o/a> oa href="+code=list_for_each_entry_rcu" class="sref">list_for_each_entry_rcuo/a>(oa href="+code=laddr" class="sref">laddro/a>, &oa href="+code=bp" class="sref">bpo/a>->oa href="+code=address_list" class="sref">address_listo/a>, oa href="+code=list" class="sref">listo/a>) {3/400o/a> if (!oa href="+code=laddr" class="sref">laddro/a>->oa href="+code=valid" class="sref">valido/a>)3/401o/a> c6.tinue;3/402o/a> if (oa href="+code=af" class="sref">afo/a>->oa href="+code=cmp_addr" class="sref">cmp_addro/a>(&oa href="+code=laddr" class="sref">laddro/a>->oa href="+code=a" class="sref">ao/a>, oa href="+code=addr" class="sref">addro/a>)) {3/403o/a> oa href="+code=state" class="sref">stateo/a> = oa href="+code=laddr" class="sref">laddro/a>->oa href="+code=state" class="sref">stateo/a>;3/404o/a> break;3/405o/a> }3/406o/a> }3/407o/a> oa href="+code=rcu_read_unlock" class="sref">rcu_read_unlocko/a>();3/408o/a>3/409o/a> return oa href="+code=state" class="sref">stateo/a>;3/410o/a>}3/411o/a>3/412o/a>ospa. class="comment">/* Find the first address in the bind address list that is not present ino/spa.33/413o/a>ospa. class="comment"> * the addrs packed array.o/spa.33/414o/a>ospa. class="comment"> */o/spa.33/415o/a>un26. oa href="+code=sctp_addr" class="sref">sctp_addro/a> *oa href="+code=sctp_find_unmatch_addr" class="sref">sctp_find_unmatch_addro/a>(struct/oa href="+code=sctp_bind_addr" class="sref">sctp_bind_addro/a> *oa href="+code=bp" class="sref">bpo/a>,3/416o/a> c6.st un26. oa href="+code=sctp_addr" class="sref">sctp_addro/a> *oa href="+code=addrs" class="sref">addrso/a>,3/417o/a> int/////////////////////oa href="+code=addrcnt" class="sref">addrcnto/a>,3/418o/a> struct/oa href="+code=sctp_sock" class="sref">sctp_socko/a> *oa href="+code=opt" class="sref">opto/a>)3/419o/a>{3/420o/a> struct/oa href="+code=sctp_sockaddr_entry" class="sref">sctp_sockaddr_entryo/a> *oa href="+code=laddr" class="sref">laddro/a>;3/421o/a> un26. oa href="+code=sctp_addr" class="sref">sctp_addro/a> *oa href="+code=addr" class="sref">addro/a>;3/422o/a> void *oa href="+code=addr_buf" class="sref">addr_bufo/a>;3/423o/a> struct/oa href="+code=sctp_af" class="sref">sctp_afo/a> *oa href="+code=af" class="sref">afo/a>;3/424o/a> int/////////////////////////////oa href="+code=i" class="sref">io/a>;3/425o/a>3/426o/a> ospa. class="comment">/* This is only called sctp_send_asc6.f_del_ip() and we holdo/spa.33/427o/a>ospa. class="comment"> * the socket lock in that code patch, so that address listo/spa.33/428o/a>ospa. class="comment"> * can't change.o/spa.33ospa. class="comment"> */o/spa.33/430o/a> oa href="+code=list_for_each_entry" class="sref">list_for_each_entryo/a>(oa href="+code=laddr" class="sref">laddro/a>, &oa href="+code=bp" class="sref">bpo/a>->oa href="+code=address_list" class="sref">address_listo/a>, oa href="+code=list" class="sref">listo/a>) {3/431o/a> oa href="+code=addr_buf" class="sref">addr_bufo/a> = (un26. oa href="+code=sctp_addr" class="sref">sctp_addro/a> *)oa href="+code=addrs" class="sref">addrso/a>;3/432o/a> for (oa href="+code=i" class="sref">io/a> = 0;/oa href="+code=i" class="sref">io/a> </oa href="+code=addrcnt" class="sref">addrcnto/a>;/oa href="+code=i" class="sref">io/a>++) {3/433o/a> oa href="+code=addr" class="sref">addro/a> = oa href="+code=addr_buf" class="sref">addr_bufo/a>;3/434o/a> oa href="+code=af" class="sref">afo/a> = oa href="+code=sctp_get_af_specific" class="sref">sctp_get_af_specifico/a>(oa href="+code=addr" class="sref">addro/a>->oa href="+code=v4" class="sref">v4o/a>.oa href="+code=sin_family" class="sref">sin_familyo/a>);3/435o/a> if (!oa href="+code=af" class="sref">afo/a>)3/436o/a> break;3/437o/a>3/438o/a> if (oa href="+code=opt" class="sref">opto/a>->oa href="+code=pf" class="sref">pfo/a>->oa href="+code=cmp_addr" class="sref">cmp_addro/a>(&oa href="+code=laddr" class="sref">laddro/a>->oa href="+code=a" class="sref">ao/a>, oa href="+code=addr" class="sref">addro/a>, oa href="+code=opt" class="sref">opto/a>))3/439o/a> break;3/440o/a>3/441o/a> oa href="+code=addr_buf" class="sref">addr_bufo/a> += oa href="+code=af" class="sref">afo/a>->oa href="+code=sockaddr_len" class="sref">sockaddr_leno/a>;3/442o/a> }3/443o/a> if (oa href="+code=i" class="sref">io/a> == oa href="+code=addrcnt" class="sref">addrcnto/a>)3/444o/a> return &oa href="+code=laddr" class="sref">laddro/a>->oa href="+code=a" class="sref">ao/a>;3/445o/a> }3/446o/a>3/447o/a> return oa href="+code=NULL" class="sref">NULLo/a>;3/448o/a>}3/449o/a>3/45 27a>ospa. class="comment">/* Copy out addresses from the global local address list. */o/spa.33/451o/a>static int/oa href="+code=sctp_copy_one_addr" class="sref">sctp_copy_one_addro/a>(struct/oa href="+code=sctp_bind_addr" class="sref">sctp_bind_addro/a> *oa href="+code=dest" class="sref">desto/a>,3/452o/a> un26. oa href="+code=sctp_addr" class="sref">sctp_addro/a> *oa href="+code=addr" class="sref">addro/a>,3/453o/a> oa href="+code=sctp_scope_t" class="sref">sctp_scope_to/a> oa href="+code=scope" class="sref">scopeo/a>, oa href="+code=gfp_t" class="sref">gfp_to/a> oa href="+code=gfp" class="sref">gfpo/a>,3/454o/a> int/oa href="+code=flags" class="sref">flagso/a>)3/455o/a>{3/456o/a> int/oa href="+code=error" class="sref">erroro/a> = 0;3/457o/a>3/458o/a> if (oa href="+code=sctp_is_any" class="sref">sctp_is_anyo/a>(oa href="+code=NULL" class="sref">NULLo/a>, oa href="+code=addr" class="sref">addro/a>)) {3/459o/a> oa href="+code=error" class="sref">erroro/a> = oa href="+code=sctp_copy_local_addr_list" class="sref">sctp_copy_local_addr_listo/a>(oa href="+code=dest" class="sref">desto/a>, oa href="+code=scope" class="sref">scopeo/a>, oa href="+code=gfp" class="sref">gfpo/a>,/oa href="+code=flags" class="sref">flagso/a>);3/460o/a> } else if (oa href="+code=sctp_in_scope" class="sref">sctp_in_scopeo/a>(oa href="+code=addr" class="sref">addro/a>, oa href="+code=scope" class="sref">scopeo/a>)) {3/461o/a> ospa. class="comment">/* Now that the address is in scope, check to see ifo/spa.33/462o/a>ospa. class="comment"> * the address type is supported by local sock aso/spa.33/463o/a>ospa. class="comment"> * well as the remote peer.o/spa.33/464o/a>ospa. class="comment"> */o/spa.33/465o/a> if ((((oa href="+code=AF_INET" class="sref">AF_INETo/a> == oa href="+code=addr" class="sref">addro/a>->oa href="+code=sa" class="sref">sao/a>.oa href="+code=sa_family" class="sref">sa_familyo/a>) &&3/466o/a> (oa href="+code=flags" class="sref">flagso/a> & oa href="+code=SCTP_ADDR4_PEERSUPP" class="sref">SCTP_ADDR4_PEERSUPPo/a>))) ||3/467o/a> (((oa href="+code=AF_INET6" class="sref">AF_INET6o/a> == oa href="+code=addr" class="sref">addro/a>->oa href="+code=sa" class="sref">sao/a>.oa href="+code=sa_family" class="sref">sa_familyo/a>) &&3/468o/a> (oa href="+code=flags" class="sref">flagso/a> & oa href="+code=SCTP_ADDR6_ALLOWED" class="sref">SCTP_ADDR6_ALLOWEDo/a>) &&3/469o/a> (oa href="+code=flags" class="sref">flagso/a> & oa href="+code=SCTP_ADDR6_PEERSUPP" class="sref">SCTP_ADDR6_PEERSUPPo/a>))))3/470o/a> oa href="+code=error" class="sref">erroro/a> = oa href="+code=sctp_add_bind_addr" class="sref">sctp_add_bind_addro/a>(oa href="+code=dest" class="sref">desto/a>, oa href="+code=addr" class="sref">addro/a>, oa href="+code=SCTP_ADDR_SRC" class="sref">SCTP_ADDR_SRCo/a>,3/471o/a> oa href="+code=gfp" class="sref">gfpo/a>);3/472o/a> }3/473o/a>3/474o/a> return oa href="+code=error" class="sref">erroro/a>;3/475o/a>}3/476o/a>3/477o/a>ospa. class="comment">/* Is this a wildcard address? */o/spa.33/478o/a>int/oa href="+code=sctp_is_any" class="sref">sctp_is_anyo/a>(struct/oa href="+code=sock" class="sref">socko/a> *oa href="+code=sk" class="sref">sko/a>, c6.st un26. oa href="+code=sctp_addr" class="sref">sctp_addro/a> *oa href="+code=addr" class="sref">addro/a>)3/479o/a>{3/480o/a> unsigned short/oa href="+code=fam" class="sref">famo/a> = 0;3/481o/a> struct/oa href="+code=sctp_af" class="sref">sctp_afo/a> *oa href="+code=af" class="sref">afo/a>;3/482o/a>3/483o/a> ospa. class="comment">/* Try to get the right address family */o/spa.33/484o/a> if (oa href="+code=addr" class="sref">addro/a>->oa href="+code=sa" class="sref">sao/a>.oa href="+code=sa_family" class="sref">sa_familyo/a> != oa href="+code=AF_UNSPEC" class="sref">AF_UNSPECo/a>)3/485o/a> oa href="+code=fam" class="sref">famo/a> = oa href="+code=addr" class="sref">addro/a>->oa href="+code=sa" class="sref">sao/a>.oa href="+code=sa_family" class="sref">sa_familyo/a>;3/486o/a> else if (oa href="+code=sk" class="sref">sko/a>)3/487o/a> oa href="+code=fam" class="sref">famo/a> = oa href="+code=sk" class="sref">sko/a>->oa href="+code=sk_family" class="sref">sk_familyo/a>;3/488o/a>3/489o/a> oa href="+code=af" class="sref">afo/a> = oa href="+code=sctp_get_af_specific" class="sref">sctp_get_af_specifico/a>(oa href="+code=fam" class="sref">famo/a>);3/490o/a> if (!oa href="+code=af" class="sref">afo/a>)3/491o/a> return 0;3/492o/a>3/493o/a> return oa href="+code=af" class="sref">afo/a>->oa href="+code=is_any" class="sref">is_anyo/a>(oa href="+code=addr" class="sref">addro/a>);3/494o/a>}3/495o/a>3/496o/a>ospa. class="comment">/* Is 'addr' valid for 'scope'? */o/spa.33/497o/a>int/oa href="+code=sctp_in_scope" class="sref">sctp_in_scopeo/a>(c6.st un26. oa href="+code=sctp_addr" class="sref">sctp_addro/a> *oa href="+code=addr" class="sref">addro/a>, oa href="+code=sctp_scope_t" class="sref">sctp_scope_to/a> oa href="+code=scope" class="sref">scopeo/a>)3/498o/a>{3/499o/a> oa href="+code=sctp_scope_t" class="sref">sctp_scope_to/a> oa href="+code=addr_scope" class="sref">addr_scopeo/a> = oa href="+code=sctp_scope" class="sref">sctp_scopeo/a>(oa href="+code=addr" class="sref">addro/a>);3/500o/a>3/501o/a> ospa. class="comment">/* The unusable SCTP addresses will not be c6.sidered witho/spa.33/502o/a>ospa. class="comment"> * any defined scopes.o/spa.33/503o/a>ospa. class="comment"> */o/spa.33/504o/a> if (oa href="+code=SCTP_SCOPE_UNUSABLE" class="sref">SCTP_SCOPE_UNUSABLEo/a> == oa href="+code=addr_scope" class="sref">addr_scopeo/a>)3/505o/a> return 0;3/506o/a> ospa. class="comment">/*o/spa.33/507o/a>ospa. class="comment"> * For INIT and INIT-ACK address list, let L be the level ofo/spa.33/508o/a>ospa. class="comment"> * of requested destinav26. address, sender and receivero/spa.33/509o/a>ospa. class="comment"> * SHOULD include all of its addresses with level greatero/spa.33/51 27a>ospa. class="comment"> * tha. or equal to L.o/spa.33/511o/a>ospa. class="comment"> *o/spa.33/512o/a>ospa. class="comment"> * Address scoping can be selectively controlled via sysctlo/spa.33/513o/a>ospa. class="comment"> * opv26.o/spa.33/514o/a>ospa. class="comment"> */o/spa.33/515o/a> switch (oa href="+code=sctp_scope_policy" class="sref">sctp_scope_policyo/a>) {3/516o/a> case oa href="+code=SCTP_SCOPE_POLICY_DISABLE" class="sref">SCTP_SCOPE_POLICY_DISABLEo/a>:3/517o/a> return 1;3/518o/a> case oa href="+code=SCTP_SCOPE_POLICY_ENABLE" class="sref">SCTP_SCOPE_POLICY_ENABLEo/a>:3/519o/a> if (oa href="+code=addr_scope" class="sref">addr_scopeo/a> <= oa href="+code=scope" class="sref">scopeo/a>)3/520o/a> return 1;3/521o/a> break;3/522o/a> case oa href="+code=SCTP_SCOPE_POLICY_PRIVATE" class="sref">SCTP_SCOPE_POLICY_PRIVATEo/a>:3/523o/a> if (oa href="+code=addr_scope" class="sref">addr_scopeo/a> <= oa href="+code=scope" class="sref">scopeo/a> || oa href="+code=SCTP_SCOPE_PRIVATE" class="sref">SCTP_SCOPE_PRIVATEo/a> == oa href="+code=addr_scope" class="sref">addr_scopeo/a>)3/524o/a> return 1;3/525o/a> break;3/526o/a> case oa href="+code=SCTP_SCOPE_POLICY_LINK" class="sref">SCTP_SCOPE_POLICY_LINKo/a>:3/527o/a> if (oa href="+code=addr_scope" class="sref">addr_scopeo/a> <= oa href="+code=scope" class="sref">scopeo/a> || oa href="+code=SCTP_SCOPE_LINK" class="sref">SCTP_SCOPE_LINKo/a> == oa href="+code=addr_scope" class="sref">addr_scopeo/a>)3/528o/a> return 1;3 break;3/530o/a> default:3/531o/a> break;3/532o/a> }3/533o/a>3/534o/a> return 0;3/535o/a>}3/536o/a>3/537o/a>int/oa href="+code=sctp_is_ep_boundall" class="sref">sctp_is_ep_boundallo/a>(struct/oa href="+code=sock" class="sref">socko/a> *oa href="+code=sk" class="sref">sko/a>)3/538o/a>{3/539o/a> struct/oa href="+code=sctp_bind_addr" class="sref">sctp_bind_addro/a> *oa href="+code=bp" class="sref">bpo/a>;3/540o/a> struct/oa href="+code=sctp_sockaddr_entry" class="sref">sctp_sockaddr_entryo/a> *oa href="+code=addr" class="sref">addro/a>;3/541o/a>3/542o/a> oa href="+code=bp" class="sref">bpo/a> = &oa href="+code=sctp_sk" class="sref">sctp_sko/a>(oa href="+code=sk" class="sref">sko/a>)->oa href="+code=ep" class="sref">epo/a>->oa href="+code=base" class="sref">baseo/a>.oa href="+code=bind_addr" class="sref">bind_addro/a>;3/543o/a> if (oa href="+code=sctp_list_single_entry" class="sref">sctp_list_single_entryo/a>(&oa href="+code=bp" class="sref">bpo/a>->oa href="+code=address_list" class="sref">address_listo/a>)) {3/544o/a> oa href="+code=addr" class="sref">addro/a> = oa href="+code=list_entry" class="sref">list_entryo/a>(oa href="+code=bp" class="sref">bpo/a>->oa href="+code=address_list" class="sref">address_listo/a>.oa href="+code=next" class="sref">nexto/a>,3/545o/a> struct/oa href="+code=sctp_sockaddr_entry" class="sref">sctp_sockaddr_entryo/a>, oa href="+code=list" class="sref">listo/a>);3/546o/a> if (oa href="+code=sctp_is_any" class="sref">sctp_is_anyo/a>(oa href="+code=sk" class="sref">sko/a>, &oa href="+code=addr" class="sref">addro/a>->oa href="+code=a" class="sref">ao/a>))3/547o/a> return 1;3/548o/a> }3/549o/a> return 0;3/550o/a>}3/551o/a>3/552o/a>ospa. class="comment">/********************************************************************o/spa.33/553o/a>ospa. class="comment"> * 3rd Level Abstracv26.so/spa.33/554o/a>ospa. class="comment"> ********************************************************************/o/spa.33/555o/a>3/556o/a>ospa. class="comment">/* What is the scope of 'addr'? */o/spa.33/557o/a>oa href="+code=sctp_scope_t" class="sref">sctp_scope_to/a> oa href="+code=sctp_scope" class="sref">sctp_scopeo/a>(c6.st un26. oa href="+code=sctp_addr" class="sref">sctp_addro/a> *oa href="+code=addr" class="sref">addro/a>)3/558o/a>{3/559o/a> struct/oa href="+code=sctp_af" class="sref">sctp_afo/a> *oa href="+code=af" class="sref">afo/a>;3/560o/a>3/561o/a> oa href="+code=af" class="sref">afo/a> = oa href="+code=sctp_get_af_specific" class="sref">sctp_get_af_specifico/a>(oa href="+code=addr" class="sref">addro/a>->oa href="+code=sa" class="sref">sao/a>.oa href="+code=sa_family" class="sref">sa_familyo/a>);3/562o/a> if (!oa href="+code=af" class="sref">afo/a>)3/563o/a> return oa href="+code=SCTP_SCOPE_UNUSABLE" class="sref">SCTP_SCOPE_UNUSABLEo/a>;3/564o/a>3/565o/a> return oa href="+code=af" class="sref">afo/a>->oa href="+code=scope" class="sref">scopeo/a>((un26. oa href="+code=sctp_addr" class="sref">sctp_addro/a> *)oa href="+code=addr" class="sref">addro/a>);3/566o/a>}3/567o/a>
lxr.linux.no kindly hosted by Redpill Linpro ASo/a>, provider of Linux c6.sulting and operav26.s services since 1995.