Changes from upstream to improve compilation when INET or INET6

or none of them is defined.

MFC after: 3 days
This commit is contained in:
Michael Tuexen 2013-11-02 20:12:19 +00:00
parent 3d819cb610
commit b54ddf225f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=257555
6 changed files with 111 additions and 22 deletions

View File

@ -150,7 +150,12 @@ sctp_process_asconf_add_ip(struct sockaddr *src, struct sctp_asconf_paramhdr *ap
struct mbuf *m_reply = NULL;
struct sockaddr_storage sa_store;
struct sctp_paramhdr *ph;
uint16_t param_type, param_length, aparam_length;
uint16_t param_type, aparam_length;
#if defined(INET) || defined(INET6)
uint16_t param_length;
#endif
struct sockaddr *sa;
int zero_address = 0;
int bad_address = 0;
@ -169,8 +174,9 @@ sctp_process_asconf_add_ip(struct sockaddr *src, struct sctp_asconf_paramhdr *ap
aparam_length = ntohs(aph->ph.param_length);
ph = (struct sctp_paramhdr *)(aph + 1);
param_type = ntohs(ph->param_type);
#if defined(INET) || defined(INET6)
param_length = ntohs(ph->param_length);
#endif
sa = (struct sockaddr *)&sa_store;
switch (param_type) {
#ifdef INET
@ -298,7 +304,12 @@ sctp_process_asconf_delete_ip(struct sockaddr *src,
struct mbuf *m_reply = NULL;
struct sockaddr_storage sa_store;
struct sctp_paramhdr *ph;
uint16_t param_type, param_length, aparam_length;
uint16_t param_type, aparam_length;
#if defined(INET) || defined(INET6)
uint16_t param_length;
#endif
struct sockaddr *sa;
int zero_address = 0;
int result;
@ -317,8 +328,9 @@ sctp_process_asconf_delete_ip(struct sockaddr *src,
aparam_length = ntohs(aph->ph.param_length);
ph = (struct sctp_paramhdr *)(aph + 1);
param_type = ntohs(ph->param_type);
#if defined(INET) || defined(INET6)
param_length = ntohs(ph->param_length);
#endif
sa = (struct sockaddr *)&sa_store;
switch (param_type) {
#ifdef INET
@ -427,7 +439,12 @@ sctp_process_asconf_set_primary(struct sockaddr *src,
struct mbuf *m_reply = NULL;
struct sockaddr_storage sa_store;
struct sctp_paramhdr *ph;
uint16_t param_type, param_length, aparam_length;
uint16_t param_type, aparam_length;
#if defined(INET) || defined(INET6)
uint16_t param_length;
#endif
struct sockaddr *sa;
int zero_address = 0;
@ -445,8 +462,9 @@ sctp_process_asconf_set_primary(struct sockaddr *src,
aparam_length = ntohs(aph->ph.param_length);
ph = (struct sctp_paramhdr *)(aph + 1);
param_type = ntohs(ph->param_type);
#if defined(INET) || defined(INET6)
param_length = ntohs(ph->param_length);
#endif
sa = (struct sockaddr *)&sa_store;
switch (param_type) {
#ifdef INET
@ -860,10 +878,12 @@ sctp_asconf_addr_match(struct sctp_asconf_addr *aa, struct sockaddr *sa)
static uint32_t
sctp_addr_match(struct sctp_paramhdr *ph, struct sockaddr *sa)
{
#if defined(INET) || defined(INET6)
uint16_t param_type, param_length;
param_type = ntohs(ph->param_type);
param_length = ntohs(ph->param_length);
#endif
switch (sa->sa_family) {
#ifdef INET6
case AF_INET6:
@ -874,7 +894,7 @@ sctp_addr_match(struct sctp_paramhdr *ph, struct sockaddr *sa)
v6addr = (struct sctp_ipv6addr_param *)ph;
if ((param_type == SCTP_IPV6_ADDRESS) &&
param_length == sizeof(struct sctp_ipv6addr_param) &&
(param_length == sizeof(struct sctp_ipv6addr_param)) &&
(memcmp(&v6addr->addr, &sin6->sin6_addr,
sizeof(struct in6_addr)) == 0)) {
return (1);
@ -890,7 +910,7 @@ sctp_addr_match(struct sctp_paramhdr *ph, struct sockaddr *sa)
v4addr = (struct sctp_ipv4addr_param *)ph;
if ((param_type == SCTP_IPV4_ADDRESS) &&
param_length == sizeof(struct sctp_ipv4addr_param) &&
(param_length == sizeof(struct sctp_ipv4addr_param)) &&
(memcmp(&v4addr->addr, &sin->sin_addr,
sizeof(struct in_addr)) == 0)) {
return (1);

View File

@ -1937,10 +1937,13 @@ sctp_is_address_in_scope(struct sctp_ifa *ifa,
static struct mbuf *
sctp_add_addr_to_mbuf(struct mbuf *m, struct sctp_ifa *ifa, uint16_t * len)
{
#if defined(INET) || defined(INET6)
struct sctp_paramhdr *parmh;
struct mbuf *mret;
uint16_t plen;
#endif
switch (ifa->address.sa.sa_family) {
#ifdef INET
case AF_INET:
@ -1955,6 +1958,7 @@ sctp_add_addr_to_mbuf(struct mbuf *m, struct sctp_ifa *ifa, uint16_t * len)
default:
return (m);
}
#if defined(INET) || defined(INET6)
if (M_TRAILINGSPACE(m) >= plen) {
/* easy side we just drop it on the end */
parmh = (struct sctp_paramhdr *)(SCTP_BUF_AT(m, SCTP_BUF_LEN(m)));
@ -2015,6 +2019,7 @@ sctp_add_addr_to_mbuf(struct mbuf *m, struct sctp_ifa *ifa, uint16_t * len)
*len += plen;
}
return (mret);
#endif
}
@ -3855,8 +3860,11 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
struct sctphdr *sctphdr;
int packet_length;
int ret;
#if defined(INET) || defined(INET6)
uint32_t vrf_id;
#endif
#if defined(INET) || defined(INET6)
struct mbuf *o_pak;
sctp_route_t *ro = NULL;
@ -3875,12 +3883,13 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
sctp_m_freem(m);
return (EFAULT);
}
#if defined(INET) || defined(INET6)
if (stcb) {
vrf_id = stcb->asoc.vrf_id;
} else {
vrf_id = inp->def_vrf_id;
}
#endif
/* fill in the HMAC digest for any AUTH chunk in the packet */
if ((auth != NULL) && (stcb != NULL)) {
sctp_fill_hmac_digest_m(m, auth_offset, auth, stcb, auth_keyid);
@ -10798,8 +10807,12 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst,
struct sctphdr *shout;
struct sctp_chunkhdr *ch;
struct udphdr *udp;
int len, cause_len, padding_len, ret;
int len, cause_len, padding_len;
#if defined(INET) || defined(INET6)
int ret;
#endif
#ifdef INET
struct sockaddr_in *src_sin, *dst_sin;
struct ip *ip;

View File

@ -827,18 +827,30 @@ sctp_del_addr_from_vrf(uint32_t vrf_id, struct sockaddr *addr,
static int
sctp_does_stcb_own_this_addr(struct sctp_tcb *stcb, struct sockaddr *to)
{
int loopback_scope, ipv4_local_scope, local_scope, site_scope;
int ipv4_addr_legal, ipv6_addr_legal;
int loopback_scope;
#if defined(INET)
int ipv4_local_scope, ipv4_addr_legal;
#endif
#if defined(INET6)
int local_scope, site_scope, ipv6_addr_legal;
#endif
struct sctp_vrf *vrf;
struct sctp_ifn *sctp_ifn;
struct sctp_ifa *sctp_ifa;
loopback_scope = stcb->asoc.scope.loopback_scope;
#if defined(INET)
ipv4_local_scope = stcb->asoc.scope.ipv4_local_scope;
ipv4_addr_legal = stcb->asoc.scope.ipv4_addr_legal;
#endif
#if defined(INET6)
local_scope = stcb->asoc.scope.local_scope;
site_scope = stcb->asoc.scope.site_scope;
ipv4_addr_legal = stcb->asoc.scope.ipv4_addr_legal;
ipv6_addr_legal = stcb->asoc.scope.ipv6_addr_legal;
#endif
SCTP_IPI_ADDR_RLOCK();
vrf = sctp_find_vrf(stcb->asoc.vrf_id);
@ -1971,8 +1983,13 @@ sctp_findassociation_special_addr(struct mbuf *m, int offset,
struct sockaddr *dst)
{
struct sctp_paramhdr *phdr, parm_buf;
#if defined(INET) || defined(INET6)
struct sctp_tcb *stcb;
uint32_t ptype, plen;
uint16_t ptype;
#endif
uint16_t plen;
#ifdef INET
struct sockaddr_in sin4;
@ -1996,13 +2013,14 @@ sctp_findassociation_special_addr(struct mbuf *m, int offset,
sin6.sin6_port = sh->src_port;
#endif
stcb = NULL;
offset += sizeof(struct sctp_init_chunk);
phdr = sctp_get_next_param(m, offset, &parm_buf, sizeof(parm_buf));
while (phdr != NULL) {
/* now we must see if we want the parameter */
#if defined(INET) || defined(INET6)
ptype = ntohs(phdr->param_type);
#endif
plen = ntohs(phdr->param_length);
if (plen == 0) {
break;

View File

@ -1120,9 +1120,17 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp,
{
struct sctp_ifn *sctp_ifn;
struct sctp_ifa *sctp_ifa;
int loopback_scope, ipv4_local_scope, local_scope, site_scope;
size_t actual;
int ipv4_addr_legal, ipv6_addr_legal;
int loopback_scope;
#if defined(INET)
int ipv4_local_scope, ipv4_addr_legal;
#endif
#if defined(INET6)
int local_scope, site_scope, ipv6_addr_legal;
#endif
struct sctp_vrf *vrf;
actual = 0;
@ -1132,27 +1140,43 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp,
if (stcb) {
/* Turn on all the appropriate scope */
loopback_scope = stcb->asoc.scope.loopback_scope;
#if defined(INET)
ipv4_local_scope = stcb->asoc.scope.ipv4_local_scope;
ipv4_addr_legal = stcb->asoc.scope.ipv4_addr_legal;
#endif
#if defined(INET6)
local_scope = stcb->asoc.scope.local_scope;
site_scope = stcb->asoc.scope.site_scope;
ipv4_addr_legal = stcb->asoc.scope.ipv4_addr_legal;
ipv6_addr_legal = stcb->asoc.scope.ipv6_addr_legal;
#endif
} else {
/* Use generic values for endpoints. */
loopback_scope = 1;
#if defined(INET)
ipv4_local_scope = 1;
#endif
#if defined(INET6)
local_scope = 1;
site_scope = 1;
#endif
if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) {
#if defined(INET6)
ipv6_addr_legal = 1;
#endif
#if defined(INET)
if (SCTP_IPV6_V6ONLY(inp)) {
ipv4_addr_legal = 0;
} else {
ipv4_addr_legal = 1;
}
#endif
} else {
#if defined(INET6)
ipv6_addr_legal = 0;
#endif
#if defined(INET)
ipv4_addr_legal = 1;
#endif
}
}
vrf = sctp_find_vrf(vrf_id);

View File

@ -6612,8 +6612,16 @@ sctp_bindx_delete_address(struct sctp_inpcb *inp,
int
sctp_local_addr_count(struct sctp_tcb *stcb)
{
int loopback_scope, ipv4_local_scope, local_scope, site_scope;
int ipv4_addr_legal, ipv6_addr_legal;
int loopback_scope;
#if defined(INET)
int ipv4_local_scope, ipv4_addr_legal;
#endif
#if defined (INET6)
int local_scope, site_scope, ipv6_addr_legal;
#endif
struct sctp_vrf *vrf;
struct sctp_ifn *sctp_ifn;
struct sctp_ifa *sctp_ifa;
@ -6621,11 +6629,15 @@ sctp_local_addr_count(struct sctp_tcb *stcb)
/* Turn on all the appropriate scopes */
loopback_scope = stcb->asoc.scope.loopback_scope;
#if defined(INET)
ipv4_local_scope = stcb->asoc.scope.ipv4_local_scope;
ipv4_addr_legal = stcb->asoc.scope.ipv4_addr_legal;
#endif
#if defined(INET6)
local_scope = stcb->asoc.scope.local_scope;
site_scope = stcb->asoc.scope.site_scope;
ipv4_addr_legal = stcb->asoc.scope.ipv4_addr_legal;
ipv6_addr_legal = stcb->asoc.scope.ipv6_addr_legal;
#endif
SCTP_IPI_ADDR_RLOCK();
vrf = sctp_find_vrf(stcb->asoc.vrf_id);
if (vrf == NULL) {

View File

@ -839,16 +839,18 @@ sctp6_connect(struct socket *so, struct sockaddr *addr, struct thread *p)
uint32_t vrf_id;
int error = 0;
struct sctp_inpcb *inp;
struct in6pcb *inp6;
struct sctp_tcb *stcb;
#ifdef INET
struct in6pcb *inp6;
struct sockaddr_in6 *sin6;
struct sockaddr_storage ss;
#endif
#ifdef INET
inp6 = (struct in6pcb *)so->so_pcb;
#endif
inp = (struct sctp_inpcb *)so->so_pcb;
if (inp == NULL) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, ECONNRESET);