mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-18 10:35:55 +00:00
Use an existing function to get the source address.
MFC after: 3 days
This commit is contained in:
parent
5355e5b582
commit
b82bd838f6
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=236515
@ -856,70 +856,20 @@ sctp_handle_asconf(struct mbuf *m, unsigned int offset,
|
|||||||
* this could happen if the source address was just newly
|
* this could happen if the source address was just newly
|
||||||
* added
|
* added
|
||||||
*/
|
*/
|
||||||
struct ip *iph;
|
struct sockaddr_storage addr;
|
||||||
struct sctphdr *sh;
|
struct sockaddr *src = (struct sockaddr *)&addr;
|
||||||
struct sockaddr_storage from_store;
|
|
||||||
struct sockaddr *from = (struct sockaddr *)&from_store;
|
|
||||||
|
|
||||||
SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf: looking up net for IP source address\n");
|
SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf: looking up net for IP source address\n");
|
||||||
/* pullup already done, IP options already stripped */
|
sctp_asconf_get_source_ip(m, src);
|
||||||
iph = mtod(m, struct ip *);
|
SCTPDBG(SCTP_DEBUG_ASCONF1, "Looking for IP source: ");
|
||||||
switch (iph->ip_v) {
|
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1, src);
|
||||||
#ifdef INET
|
/* look up the from address */
|
||||||
case IPVERSION:
|
stcb->asoc.last_control_chunk_from = sctp_findnet(stcb, src);
|
||||||
{
|
|
||||||
struct sockaddr_in *from4;
|
|
||||||
|
|
||||||
sh = (struct sctphdr *)((caddr_t)iph + sizeof(*iph));
|
|
||||||
from4 = (struct sockaddr_in *)&from_store;
|
|
||||||
bzero(from4, sizeof(*from4));
|
|
||||||
from4->sin_family = AF_INET;
|
|
||||||
from4->sin_len = sizeof(struct sockaddr_in);
|
|
||||||
from4->sin_addr.s_addr = iph->ip_src.s_addr;
|
|
||||||
from4->sin_port = sh->src_port;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef INET6
|
|
||||||
case IPV6_VERSION >> 4:
|
|
||||||
{
|
|
||||||
struct ip6_hdr *ip6;
|
|
||||||
struct sockaddr_in6 *from6;
|
|
||||||
|
|
||||||
ip6 = mtod(m, struct ip6_hdr *);
|
|
||||||
sh = (struct sctphdr *)((caddr_t)ip6 + sizeof(*ip6));
|
|
||||||
from6 = (struct sockaddr_in6 *)&from_store;
|
|
||||||
bzero(from6, sizeof(*from6));
|
|
||||||
from6->sin6_family = AF_INET6;
|
|
||||||
from6->sin6_len = sizeof(struct sockaddr_in6);
|
|
||||||
from6->sin6_addr = ip6->ip6_src;
|
|
||||||
from6->sin6_port = sh->src_port;
|
|
||||||
/*
|
|
||||||
* Get the scopes in properly to the sin6
|
|
||||||
* addr's
|
|
||||||
*/
|
|
||||||
/* we probably don't need these operations */
|
|
||||||
(void)sa6_recoverscope(from6);
|
|
||||||
sa6_embedscope(from6,
|
|
||||||
MODULE_GLOBAL(ip6_use_defzone));
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
/* unknown address type */
|
|
||||||
from = NULL;
|
|
||||||
}
|
|
||||||
if (from != NULL) {
|
|
||||||
SCTPDBG(SCTP_DEBUG_ASCONF1, "Looking for IP source: ");
|
|
||||||
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1, from);
|
|
||||||
/* look up the from address */
|
|
||||||
stcb->asoc.last_control_chunk_from = sctp_findnet(stcb, from);
|
|
||||||
#ifdef SCTP_DEBUG
|
#ifdef SCTP_DEBUG
|
||||||
if (stcb->asoc.last_control_chunk_from == NULL)
|
if (stcb->asoc.last_control_chunk_from == NULL) {
|
||||||
SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf: IP source address not found?!\n");
|
SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf: IP source address not found?!\n");
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user