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:
tuexen 2013-11-02 20:12:19 +00:00
parent ed9032c329
commit d30ae7faf7
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 mbuf *m_reply = NULL;
struct sockaddr_storage sa_store; struct sockaddr_storage sa_store;
struct sctp_paramhdr *ph; 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; struct sockaddr *sa;
int zero_address = 0; int zero_address = 0;
int bad_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); aparam_length = ntohs(aph->ph.param_length);
ph = (struct sctp_paramhdr *)(aph + 1); ph = (struct sctp_paramhdr *)(aph + 1);
param_type = ntohs(ph->param_type); param_type = ntohs(ph->param_type);
#if defined(INET) || defined(INET6)
param_length = ntohs(ph->param_length); param_length = ntohs(ph->param_length);
#endif
sa = (struct sockaddr *)&sa_store; sa = (struct sockaddr *)&sa_store;
switch (param_type) { switch (param_type) {
#ifdef INET #ifdef INET
@ -298,7 +304,12 @@ sctp_process_asconf_delete_ip(struct sockaddr *src,
struct mbuf *m_reply = NULL; struct mbuf *m_reply = NULL;
struct sockaddr_storage sa_store; struct sockaddr_storage sa_store;
struct sctp_paramhdr *ph; 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; struct sockaddr *sa;
int zero_address = 0; int zero_address = 0;
int result; int result;
@ -317,8 +328,9 @@ sctp_process_asconf_delete_ip(struct sockaddr *src,
aparam_length = ntohs(aph->ph.param_length); aparam_length = ntohs(aph->ph.param_length);
ph = (struct sctp_paramhdr *)(aph + 1); ph = (struct sctp_paramhdr *)(aph + 1);
param_type = ntohs(ph->param_type); param_type = ntohs(ph->param_type);
#if defined(INET) || defined(INET6)
param_length = ntohs(ph->param_length); param_length = ntohs(ph->param_length);
#endif
sa = (struct sockaddr *)&sa_store; sa = (struct sockaddr *)&sa_store;
switch (param_type) { switch (param_type) {
#ifdef INET #ifdef INET
@ -427,7 +439,12 @@ sctp_process_asconf_set_primary(struct sockaddr *src,
struct mbuf *m_reply = NULL; struct mbuf *m_reply = NULL;
struct sockaddr_storage sa_store; struct sockaddr_storage sa_store;
struct sctp_paramhdr *ph; 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; struct sockaddr *sa;
int zero_address = 0; int zero_address = 0;
@ -445,8 +462,9 @@ sctp_process_asconf_set_primary(struct sockaddr *src,
aparam_length = ntohs(aph->ph.param_length); aparam_length = ntohs(aph->ph.param_length);
ph = (struct sctp_paramhdr *)(aph + 1); ph = (struct sctp_paramhdr *)(aph + 1);
param_type = ntohs(ph->param_type); param_type = ntohs(ph->param_type);
#if defined(INET) || defined(INET6)
param_length = ntohs(ph->param_length); param_length = ntohs(ph->param_length);
#endif
sa = (struct sockaddr *)&sa_store; sa = (struct sockaddr *)&sa_store;
switch (param_type) { switch (param_type) {
#ifdef INET #ifdef INET
@ -860,10 +878,12 @@ sctp_asconf_addr_match(struct sctp_asconf_addr *aa, struct sockaddr *sa)
static uint32_t static uint32_t
sctp_addr_match(struct sctp_paramhdr *ph, struct sockaddr *sa) sctp_addr_match(struct sctp_paramhdr *ph, struct sockaddr *sa)
{ {
#if defined(INET) || defined(INET6)
uint16_t param_type, param_length; uint16_t param_type, param_length;
param_type = ntohs(ph->param_type); param_type = ntohs(ph->param_type);
param_length = ntohs(ph->param_length); param_length = ntohs(ph->param_length);
#endif
switch (sa->sa_family) { switch (sa->sa_family) {
#ifdef INET6 #ifdef INET6
case AF_INET6: case AF_INET6:
@ -874,7 +894,7 @@ sctp_addr_match(struct sctp_paramhdr *ph, struct sockaddr *sa)
v6addr = (struct sctp_ipv6addr_param *)ph; v6addr = (struct sctp_ipv6addr_param *)ph;
if ((param_type == SCTP_IPV6_ADDRESS) && 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, (memcmp(&v6addr->addr, &sin6->sin6_addr,
sizeof(struct in6_addr)) == 0)) { sizeof(struct in6_addr)) == 0)) {
return (1); return (1);
@ -890,7 +910,7 @@ sctp_addr_match(struct sctp_paramhdr *ph, struct sockaddr *sa)
v4addr = (struct sctp_ipv4addr_param *)ph; v4addr = (struct sctp_ipv4addr_param *)ph;
if ((param_type == SCTP_IPV4_ADDRESS) && 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, (memcmp(&v4addr->addr, &sin->sin_addr,
sizeof(struct in_addr)) == 0)) { sizeof(struct in_addr)) == 0)) {
return (1); return (1);

View File

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

View File

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

View File

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

View File

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

View File

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