White cleanups.
This commit is contained in:
parent
65ef323137
commit
fa5867cbd6
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=327214
@ -422,8 +422,8 @@ int sysctl_chg_loglevel(SYSCTL_HANDLER_ARGS)
|
||||
error = sysctl_handle_int(oidp, &level, 0, req);
|
||||
if (error) return (error);
|
||||
|
||||
level = (level > SN_LOG_DEBUG_MAX)?(SN_LOG_DEBUG_MAX):(level);
|
||||
level = (level < SN_LOG_LOW)?(SN_LOG_LOW):(level);
|
||||
level = (level > SN_LOG_DEBUG_MAX) ? (SN_LOG_DEBUG_MAX) : (level);
|
||||
level = (level < SN_LOG_LOW) ? (SN_LOG_LOW) : (level);
|
||||
sysctl_log_level = level;
|
||||
return (0);
|
||||
}
|
||||
@ -443,12 +443,11 @@ int sysctl_chg_timer(SYSCTL_HANDLER_ARGS)
|
||||
error = sysctl_handle_int(oidp, &timer, 0, req);
|
||||
if (error) return (error);
|
||||
|
||||
timer = (timer > SN_MAX_TIMER)?(SN_MAX_TIMER):(timer);
|
||||
timer = (timer > SN_MAX_TIMER) ? (SN_MAX_TIMER) : (timer);
|
||||
|
||||
if (((u_int *)arg1) != &sysctl_holddown_timer)
|
||||
{
|
||||
timer = (timer < SN_MIN_TIMER)?(SN_MIN_TIMER):(timer);
|
||||
}
|
||||
if (((u_int *)arg1) != &sysctl_holddown_timer) {
|
||||
timer = (timer < SN_MIN_TIMER) ? (SN_MIN_TIMER) : (timer);
|
||||
}
|
||||
|
||||
*(u_int *)arg1 = timer;
|
||||
|
||||
@ -472,11 +471,11 @@ int sysctl_chg_hashtable_size(SYSCTL_HANDLER_ARGS)
|
||||
error = sysctl_handle_int(oidp, &size, 0, req);
|
||||
if (error) return (error);
|
||||
|
||||
size = (size < SN_MIN_HASH_SIZE)?(SN_MIN_HASH_SIZE):((size > SN_MAX_HASH_SIZE)?(SN_MAX_HASH_SIZE):(size));
|
||||
size = (size < SN_MIN_HASH_SIZE) ? (SN_MIN_HASH_SIZE) : ((size > SN_MAX_HASH_SIZE) ? (SN_MAX_HASH_SIZE) : (size));
|
||||
|
||||
size |= 0x00000001; /* make odd */
|
||||
|
||||
for(;(((size % 3) == 0) || ((size % 5) == 0) || ((size % 7) == 0) || ((size % 11) == 0)); size+=2);
|
||||
for (;(((size % 3) == 0) || ((size % 5) == 0) || ((size % 7) == 0) || ((size % 11) == 0)); size+=2);
|
||||
sysctl_hashtable_size = size;
|
||||
|
||||
return (0);
|
||||
@ -717,7 +716,7 @@ SctpAlias(struct libalias *la, struct ip *pip, int direction)
|
||||
|
||||
if ((direction != SN_TO_LOCAL) && (direction != SN_TO_GLOBAL)) {
|
||||
SctpAliasLog("ERROR: Invalid direction\n");
|
||||
return(PKT_ALIAS_ERROR);
|
||||
return (PKT_ALIAS_ERROR);
|
||||
}
|
||||
|
||||
sctp_CheckTimers(la); /* Check timers */
|
||||
@ -735,24 +734,24 @@ SctpAlias(struct libalias *la, struct ip *pip, int direction)
|
||||
}
|
||||
SN_LOG(SN_LOG_EVENT,
|
||||
logsctperror("SN_PARSE_ERROR", msg.sctp_hdr->v_tag, rtnval, direction));
|
||||
return(PKT_ALIAS_ERROR);
|
||||
return (PKT_ALIAS_ERROR);
|
||||
case SN_PARSE_ERROR_PARTIALLOOKUP:
|
||||
if (sysctl_error_on_ootb > SN_LOCALandPARTIAL_ERROR_ON_OOTB) {
|
||||
SN_LOG(SN_LOG_EVENT,
|
||||
logsctperror("SN_PARSE_ERROR", msg.sctp_hdr->v_tag, rtnval, direction));
|
||||
return(PKT_ALIAS_ERROR);
|
||||
return (PKT_ALIAS_ERROR);
|
||||
}
|
||||
case SN_PARSE_ERROR_LOOKUP:
|
||||
if (sysctl_error_on_ootb == SN_ERROR_ON_OOTB ||
|
||||
(sysctl_error_on_ootb == SN_LOCALandPARTIAL_ERROR_ON_OOTB && direction == SN_TO_LOCAL) ||
|
||||
(sysctl_error_on_ootb == SN_LOCAL_ERROR_ON_OOTB && direction == SN_TO_GLOBAL)) {
|
||||
TxAbortErrorM(la, &msg, assoc, SN_REFLECT_ERROR, direction); /*NB assoc=NULL */
|
||||
return(PKT_ALIAS_RESPOND);
|
||||
return (PKT_ALIAS_RESPOND);
|
||||
}
|
||||
default:
|
||||
SN_LOG(SN_LOG_EVENT,
|
||||
logsctperror("SN_PARSE_ERROR", msg.sctp_hdr->v_tag, rtnval, direction));
|
||||
return(PKT_ALIAS_ERROR);
|
||||
return (PKT_ALIAS_ERROR);
|
||||
}
|
||||
|
||||
SN_LOG(SN_LOG_DETAIL,
|
||||
@ -770,9 +769,9 @@ SctpAlias(struct libalias *la, struct ip *pip, int direction)
|
||||
);
|
||||
SN_LOG(SN_LOG_DEBUG, logTimerQ(la));
|
||||
|
||||
switch(rtnval){
|
||||
switch (rtnval) {
|
||||
case SN_NAT_PKT:
|
||||
switch(direction) {
|
||||
switch (direction) {
|
||||
case SN_TO_LOCAL:
|
||||
DifferentialChecksum(&(msg.ip_hdr->ip_sum),
|
||||
&(assoc->l_addr), &(msg.ip_hdr->ip_dst), 2);
|
||||
@ -814,18 +813,18 @@ SctpAlias(struct libalias *la, struct ip *pip, int direction)
|
||||
freeGlobalAddressList(assoc);
|
||||
sn_free(assoc);
|
||||
}
|
||||
switch(rtnval) {
|
||||
switch (rtnval) {
|
||||
case SN_NAT_PKT:
|
||||
return(PKT_ALIAS_OK);
|
||||
return (PKT_ALIAS_OK);
|
||||
case SN_SEND_ABORT:
|
||||
return(PKT_ALIAS_OK);
|
||||
return (PKT_ALIAS_OK);
|
||||
case SN_REPLY_ABORT:
|
||||
case SN_REPLY_ERROR:
|
||||
case SN_REFLECT_ERROR:
|
||||
return(PKT_ALIAS_RESPOND);
|
||||
return (PKT_ALIAS_RESPOND);
|
||||
case SN_DROP_PKT:
|
||||
default:
|
||||
return(PKT_ALIAS_ERROR);
|
||||
return (PKT_ALIAS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@ -924,7 +923,7 @@ TxAbortErrorM(struct libalias *la, struct sctp_nat_msg *sm, struct sctp_nat_asso
|
||||
ip->ip_hl = 5; /* 5*32 bit words */
|
||||
ip->ip_tos = 0;
|
||||
ip->ip_len = htons(ip_size);
|
||||
ip->ip_id = sm->ip_hdr->ip_id;
|
||||
ip->ip_id = sm->ip_hdr->ip_id;
|
||||
ip->ip_off = 0;
|
||||
ip->ip_ttl = 255;
|
||||
ip->ip_p = IPPROTO_SCTP;
|
||||
@ -937,7 +936,7 @@ TxAbortErrorM(struct libalias *la, struct sctp_nat_msg *sm, struct sctp_nat_asso
|
||||
chunk_hdr->chunk_type = (sndrply & SN_TX_ABORT) ? SCTP_ABORT_ASSOCIATION : SCTP_OPERATION_ERROR;
|
||||
chunk_hdr->chunk_flags = SCTP_MIDDLEBOX_FLAG;
|
||||
if (include_error_cause) {
|
||||
error_cause->code = htons((sndrply & SN_REFLECT_ERROR) ? SCTP_MISSING_NAT : SCTP_NAT_TABLE_COLLISION);
|
||||
error_cause->code = htons((sndrply & SN_REFLECT_ERROR) ? SCTP_MISSING_NAT : SCTP_NAT_TABLE_COLLISION);
|
||||
error_cause->length = htons(sizeof(struct sctp_error_cause));
|
||||
chunk_hdr->chunk_length = htons(sizeof(*chunk_hdr) + sizeof(struct sctp_error_cause));
|
||||
} else {
|
||||
@ -945,16 +944,16 @@ TxAbortErrorM(struct libalias *la, struct sctp_nat_msg *sm, struct sctp_nat_asso
|
||||
}
|
||||
|
||||
/* set specific values */
|
||||
switch(sndrply) {
|
||||
switch (sndrply) {
|
||||
case SN_REFLECT_ERROR:
|
||||
chunk_hdr->chunk_flags |= SCTP_HAD_NO_TCB; /* set Tbit */
|
||||
sctp_hdr->v_tag = sm->sctp_hdr->v_tag;
|
||||
sctp_hdr->v_tag = sm->sctp_hdr->v_tag;
|
||||
break;
|
||||
case SN_REPLY_ERROR:
|
||||
sctp_hdr->v_tag = (direction == SN_TO_LOCAL) ? assoc->g_vtag : assoc->l_vtag ;
|
||||
sctp_hdr->v_tag = (direction == SN_TO_LOCAL) ? assoc->g_vtag : assoc->l_vtag ;
|
||||
break;
|
||||
case SN_SEND_ABORT:
|
||||
sctp_hdr->v_tag = sm->sctp_hdr->v_tag;
|
||||
sctp_hdr->v_tag = sm->sctp_hdr->v_tag;
|
||||
break;
|
||||
case SN_REPLY_ABORT:
|
||||
sctp_hdr->v_tag = sm->sctpchnk.Init->initiate_tag;
|
||||
@ -1049,7 +1048,7 @@ sctp_PktParser(struct libalias *la, int direction, struct ip *pip,
|
||||
/* Check SCTP header length and move to first chunk */
|
||||
if (bytes_left < sizeof(struct sctphdr)) {
|
||||
sm->sctp_hdr = NULL;
|
||||
return(SN_PARSE_ERROR_IPSHL); /* packet not long enough*/
|
||||
return (SN_PARSE_ERROR_IPSHL); /* packet not long enough*/
|
||||
}
|
||||
|
||||
sm->sctp_hdr = sctp_hdr = (struct sctphdr *) ip_next(pip);
|
||||
@ -1057,18 +1056,18 @@ sctp_PktParser(struct libalias *la, int direction, struct ip *pip,
|
||||
|
||||
/* Check for valid ports (zero valued ports would find partially initialised associations */
|
||||
if (sctp_hdr->src_port == 0 || sctp_hdr->dest_port == 0)
|
||||
return(SN_PARSE_ERROR_PORT);
|
||||
return (SN_PARSE_ERROR_PORT);
|
||||
|
||||
/* Check length of first chunk */
|
||||
if (bytes_left < SN_MIN_CHUNK_SIZE) /* malformed chunk - could cause endless loop*/
|
||||
return(SN_PARSE_ERROR_CHHL); /* packet not long enough for this chunk */
|
||||
return (SN_PARSE_ERROR_CHHL); /* packet not long enough for this chunk */
|
||||
|
||||
/* First chunk */
|
||||
chunk_hdr = SN_SCTP_FIRSTCHUNK(sctp_hdr);
|
||||
|
||||
chunk_length = SCTP_SIZE32(ntohs(chunk_hdr->chunk_length));
|
||||
if ((chunk_length < SN_MIN_CHUNK_SIZE) || (chunk_length > bytes_left)) /* malformed chunk - could cause endless loop*/
|
||||
return(SN_PARSE_ERROR_CHHL);
|
||||
return (SN_PARSE_ERROR_CHHL);
|
||||
|
||||
if ((chunk_hdr->chunk_flags & SCTP_HAD_NO_TCB) &&
|
||||
((chunk_hdr->chunk_type == SCTP_ABORT_ASSOCIATION) ||
|
||||
@ -1091,43 +1090,43 @@ sctp_PktParser(struct libalias *la, int direction, struct ip *pip,
|
||||
sm->msg = SN_SCTP_OTHER;/* Initialise to largest value*/
|
||||
sm->chunk_length = 0; /* only care about length for key chunks */
|
||||
while (IS_SCTP_CONTROL(chunk_hdr)) {
|
||||
switch(chunk_hdr->chunk_type) {
|
||||
switch (chunk_hdr->chunk_type) {
|
||||
case SCTP_INITIATION:
|
||||
if (chunk_length < sizeof(struct sctp_init_chunk)) /* malformed chunk*/
|
||||
return(SN_PARSE_ERROR_CHHL);
|
||||
return (SN_PARSE_ERROR_CHHL);
|
||||
sm->msg = SN_SCTP_INIT;
|
||||
sm->sctpchnk.Init = (struct sctp_init *) ((char *) chunk_hdr + sizeof(struct sctp_chunkhdr));
|
||||
sm->chunk_length = chunk_length;
|
||||
/* if no existing association, create a new one */
|
||||
if (*passoc == NULL) {
|
||||
if (sctp_hdr->v_tag == 0){ //Init requires vtag=0
|
||||
if (sctp_hdr->v_tag == 0) { //Init requires vtag=0
|
||||
*passoc = (struct sctp_nat_assoc *) sn_malloc(sizeof(struct sctp_nat_assoc));
|
||||
if (*passoc == NULL) {/* out of resources */
|
||||
return(SN_PARSE_ERROR_AS_MALLOC);
|
||||
return (SN_PARSE_ERROR_AS_MALLOC);
|
||||
}
|
||||
/* Initialise association - malloc initialises memory to zeros */
|
||||
(*passoc)->state = SN_ID;
|
||||
LIST_INIT(&((*passoc)->Gaddr)); /* always initialise to avoid memory problems */
|
||||
(*passoc)->TableRegister = SN_NULL_TBL;
|
||||
return(SN_PARSE_OK);
|
||||
return (SN_PARSE_OK);
|
||||
}
|
||||
return(SN_PARSE_ERROR_VTAG);
|
||||
return (SN_PARSE_ERROR_VTAG);
|
||||
}
|
||||
return(SN_PARSE_ERROR_LOOKUP);
|
||||
return (SN_PARSE_ERROR_LOOKUP);
|
||||
case SCTP_INITIATION_ACK:
|
||||
if (chunk_length < sizeof(struct sctp_init_ack_chunk)) /* malformed chunk*/
|
||||
return(SN_PARSE_ERROR_CHHL);
|
||||
return (SN_PARSE_ERROR_CHHL);
|
||||
sm->msg = SN_SCTP_INITACK;
|
||||
sm->sctpchnk.InitAck = (struct sctp_init_ack *) ((char *) chunk_hdr + sizeof(struct sctp_chunkhdr));
|
||||
sm->chunk_length = chunk_length;
|
||||
return ((*passoc == NULL)?(SN_PARSE_ERROR_LOOKUP):(SN_PARSE_OK));
|
||||
return ((*passoc == NULL) ? (SN_PARSE_ERROR_LOOKUP) : (SN_PARSE_OK));
|
||||
case SCTP_ABORT_ASSOCIATION: /* access only minimum sized chunk */
|
||||
sm->msg = SN_SCTP_ABORT;
|
||||
sm->chunk_length = chunk_length;
|
||||
return ((*passoc == NULL)?(SN_PARSE_ERROR_LOOKUP_ABORT):(SN_PARSE_OK));
|
||||
return ((*passoc == NULL) ? (SN_PARSE_ERROR_LOOKUP_ABORT) : (SN_PARSE_OK));
|
||||
case SCTP_SHUTDOWN_ACK:
|
||||
if (chunk_length < sizeof(struct sctp_shutdown_ack_chunk)) /* malformed chunk*/
|
||||
return(SN_PARSE_ERROR_CHHL);
|
||||
return (SN_PARSE_ERROR_CHHL);
|
||||
if (sm->msg > SN_SCTP_SHUTACK) {
|
||||
sm->msg = SN_SCTP_SHUTACK;
|
||||
sm->chunk_length = chunk_length;
|
||||
@ -1138,11 +1137,11 @@ sctp_PktParser(struct libalias *la, int direction, struct ip *pip,
|
||||
sm->msg = SN_SCTP_SHUTCOMP;
|
||||
sm->chunk_length = chunk_length;
|
||||
}
|
||||
return ((*passoc == NULL)?(SN_PARSE_ERROR_LOOKUP):(SN_PARSE_OK));
|
||||
return ((*passoc == NULL) ? (SN_PARSE_ERROR_LOOKUP) : (SN_PARSE_OK));
|
||||
case SCTP_ASCONF:
|
||||
if (sm->msg > SN_SCTP_ASCONF) {
|
||||
if (chunk_length < (sizeof(struct sctp_asconf_chunk) + sizeof(struct sctp_ipv4addr_param))) /* malformed chunk*/
|
||||
return(SN_PARSE_ERROR_CHHL);
|
||||
return (SN_PARSE_ERROR_CHHL);
|
||||
//leave parameter searching to later, if required
|
||||
param_hdr = (struct sctp_paramhdr *) ((char *) chunk_hdr + sizeof(struct sctp_asconf_chunk)); /*compulsory IP parameter*/
|
||||
if (ntohs(param_hdr->param_type) == SCTP_IPV4_ADDRESS) {
|
||||
@ -1156,7 +1155,7 @@ sctp_PktParser(struct libalias *la, int direction, struct ip *pip,
|
||||
sm->chunk_length = chunk_length - sizeof(struct sctp_asconf_chunk) - sizeof(struct sctp_ipv4addr_param); /* rest of chunk */
|
||||
} else {
|
||||
if (chunk_length < (sizeof(struct sctp_asconf_chunk) + sizeof(struct sctp_ipv6addr_param))) /* malformed chunk*/
|
||||
return(SN_PARSE_ERROR_CHHL);
|
||||
return (SN_PARSE_ERROR_CHHL);
|
||||
param_hdr = (struct sctp_paramhdr *)
|
||||
((char *) param_hdr + sizeof(struct sctp_ipv6addr_param)); /*asconf's compulsory address parameter */
|
||||
sm->chunk_length = chunk_length - sizeof(struct sctp_asconf_chunk) - sizeof(struct sctp_ipv6addr_param); /* rest of chunk */
|
||||
@ -1167,20 +1166,20 @@ sctp_PktParser(struct libalias *la, int direction, struct ip *pip,
|
||||
if (*passoc == NULL) { /* AddIP with no association */
|
||||
*passoc = (struct sctp_nat_assoc *) sn_malloc(sizeof(struct sctp_nat_assoc));
|
||||
if (*passoc == NULL) {/* out of resources */
|
||||
return(SN_PARSE_ERROR_AS_MALLOC);
|
||||
return (SN_PARSE_ERROR_AS_MALLOC);
|
||||
}
|
||||
/* Initialise association - malloc initialises memory to zeros */
|
||||
(*passoc)->state = SN_ID;
|
||||
LIST_INIT(&((*passoc)->Gaddr)); /* always initialise to avoid memory problems */
|
||||
(*passoc)->TableRegister = SN_NULL_TBL;
|
||||
return(SN_PARSE_OK);
|
||||
return (SN_PARSE_OK);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SCTP_ASCONF_ACK:
|
||||
if (sm->msg > SN_SCTP_ASCONFACK) {
|
||||
if (chunk_length < sizeof(struct sctp_asconf_ack_chunk)) /* malformed chunk*/
|
||||
return(SN_PARSE_ERROR_CHHL);
|
||||
return (SN_PARSE_ERROR_CHHL);
|
||||
//leave parameter searching to later, if required
|
||||
param_hdr = (struct sctp_paramhdr *) ((char *) chunk_hdr
|
||||
+ sizeof(struct sctp_asconf_ack_chunk));
|
||||
@ -1195,33 +1194,33 @@ sctp_PktParser(struct libalias *la, int direction, struct ip *pip,
|
||||
|
||||
/* if no association is found exit - we need to find an Init or AddIP within sysctl_initialising_chunk_proc_limit */
|
||||
if ((*passoc == NULL) && (chunk_count >= sysctl_initialising_chunk_proc_limit))
|
||||
return(SN_PARSE_ERROR_LOOKUP);
|
||||
return (SN_PARSE_ERROR_LOOKUP);
|
||||
|
||||
/* finished with this chunk, on to the next chunk*/
|
||||
bytes_left-= chunk_length;
|
||||
|
||||
/* Is this the end of the packet ? */
|
||||
if (bytes_left == 0)
|
||||
return (*passoc == NULL)?(SN_PARSE_ERROR_LOOKUP):(SN_PARSE_OK);
|
||||
return (*passoc == NULL) ? (SN_PARSE_ERROR_LOOKUP) : (SN_PARSE_OK);
|
||||
|
||||
/* Are there enough bytes in packet to at least retrieve length of next chunk ? */
|
||||
if (bytes_left < SN_MIN_CHUNK_SIZE)
|
||||
return(SN_PARSE_ERROR_CHHL);
|
||||
return (SN_PARSE_ERROR_CHHL);
|
||||
|
||||
chunk_hdr = SN_SCTP_NEXTCHUNK(chunk_hdr);
|
||||
|
||||
/* Is the chunk long enough to not cause endless look and are there enough bytes in packet to read the chunk ? */
|
||||
chunk_length = SCTP_SIZE32(ntohs(chunk_hdr->chunk_length));
|
||||
if ((chunk_length < SN_MIN_CHUNK_SIZE) || (chunk_length > bytes_left))
|
||||
return(SN_PARSE_ERROR_CHHL);
|
||||
if(++chunk_count > sysctl_chunk_proc_limit)
|
||||
return(SN_PARSE_OK); /* limit for processing chunks, take what we get */
|
||||
return (SN_PARSE_ERROR_CHHL);
|
||||
if (++chunk_count > sysctl_chunk_proc_limit)
|
||||
return (SN_PARSE_OK); /* limit for processing chunks, take what we get */
|
||||
}
|
||||
|
||||
if (*passoc == NULL)
|
||||
return (partial_match)?(SN_PARSE_ERROR_PARTIALLOOKUP):(SN_PARSE_ERROR_LOOKUP);
|
||||
return (partial_match) ? (SN_PARSE_ERROR_PARTIALLOOKUP) : (SN_PARSE_ERROR_LOOKUP);
|
||||
else
|
||||
return(SN_PARSE_OK);
|
||||
return (SN_PARSE_OK);
|
||||
}
|
||||
|
||||
/** @ingroup packet_parser
|
||||
@ -1266,7 +1265,7 @@ GetAsconfVtags(struct libalias *la, struct sctp_nat_msg *sm, uint32_t *l_vtag, u
|
||||
while((bytes_left >= param_size) && (bytes_left >= SN_VTAG_PARAM_SIZE)) {
|
||||
if (ntohs(param->param_type) == SCTP_VTAG_PARAM) {
|
||||
vtag_param = (struct sctp_vtag_param *) param;
|
||||
switch(direction) {
|
||||
switch (direction) {
|
||||
/* The Internet draft is a little ambigious as to order of these vtags.
|
||||
We think it is this way around. If we are wrong, the order will need
|
||||
to be changed. */
|
||||
@ -1279,11 +1278,11 @@ GetAsconfVtags(struct libalias *la, struct sctp_nat_msg *sm, uint32_t *l_vtag, u
|
||||
*l_vtag = vtag_param->local_vtag;
|
||||
break;
|
||||
}
|
||||
return(1); /* found */
|
||||
return (1); /* found */
|
||||
}
|
||||
|
||||
bytes_left -= param_size;
|
||||
if (bytes_left < SN_MIN_PARAM_SIZE) return(0);
|
||||
if (bytes_left < SN_MIN_PARAM_SIZE) return (0);
|
||||
|
||||
param = SN_SCTP_NEXTPARAM(param);
|
||||
param_size = SCTP_SIZE32(ntohs(param->param_length));
|
||||
@ -1291,10 +1290,10 @@ GetAsconfVtags(struct libalias *la, struct sctp_nat_msg *sm, uint32_t *l_vtag, u
|
||||
SN_LOG(SN_LOG_EVENT,
|
||||
logsctperror("Parameter parse limit exceeded (GetAsconfVtags)",
|
||||
sm->sctp_hdr->v_tag, sysctl_param_proc_limit, direction));
|
||||
return(0); /* not found limit exceeded*/
|
||||
return (0); /* not found limit exceeded*/
|
||||
}
|
||||
}
|
||||
return(0); /* not found */
|
||||
return (0); /* not found */
|
||||
}
|
||||
|
||||
/** @ingroup packet_parser
|
||||
@ -1319,7 +1318,7 @@ AddGlobalIPAddresses(struct sctp_nat_msg *sm, struct sctp_nat_assoc *assoc, int
|
||||
int param_size;
|
||||
int param_count, addr_param_count = 0;
|
||||
|
||||
switch(direction) {
|
||||
switch (direction) {
|
||||
case SN_TO_GLOBAL: /* does not contain global addresses */
|
||||
g_addr = sm->ip_hdr->ip_dst;
|
||||
bytes_left = 0; /* force exit */
|
||||
@ -1327,7 +1326,7 @@ AddGlobalIPAddresses(struct sctp_nat_msg *sm, struct sctp_nat_assoc *assoc, int
|
||||
case SN_TO_LOCAL:
|
||||
g_addr = sm->ip_hdr->ip_src;
|
||||
param_count = 1;
|
||||
switch(sm->msg) {
|
||||
switch (sm->msg) {
|
||||
case SN_SCTP_INIT:
|
||||
bytes_left = sm->chunk_length - sizeof(struct sctp_init_chunk);
|
||||
param = (struct sctp_paramhdr *)((char *)sm->sctpchnk.Init + sizeof(struct sctp_init));
|
||||
@ -1372,7 +1371,7 @@ AddGlobalIPAddresses(struct sctp_nat_msg *sm, struct sctp_nat_assoc *assoc, int
|
||||
sm->sctp_hdr->v_tag, sysctl_track_global_addresses, direction));
|
||||
return;
|
||||
}
|
||||
switch(ntohs(param->param_type)) {
|
||||
switch (ntohs(param->param_type)) {
|
||||
case SCTP_ADD_IP_ADDRESS:
|
||||
/* skip to address parameter - leave param_size so bytes left will be calculated properly*/
|
||||
param = (struct sctp_paramhdr *) &((struct sctp_asconf_addrv4_param *) param)->addrp;
|
||||
@ -1449,12 +1448,12 @@ static int Add_Global_Address_to_List(struct sctp_nat_assoc *assoc, struct sct
|
||||
} else {
|
||||
LIST_FOREACH(iter_G_Addr, &(assoc->Gaddr), list_Gaddr) {
|
||||
if (G_addr->g_addr.s_addr == iter_G_Addr->g_addr.s_addr)
|
||||
return(0); /* already exists, so don't add */
|
||||
return (0); /* already exists, so don't add */
|
||||
}
|
||||
LIST_INSERT_AFTER(first_G_Addr, G_addr, list_Gaddr); /* add address to end of list*/
|
||||
}
|
||||
assoc->num_Gaddr++;
|
||||
return(1); /* success */
|
||||
return (1); /* success */
|
||||
}
|
||||
|
||||
/** @ingroup packet_parser
|
||||
@ -1481,7 +1480,7 @@ RmGlobalIPAddresses(struct sctp_nat_msg *sm, struct sctp_nat_assoc *assoc, int d
|
||||
int param_size;
|
||||
int param_count;
|
||||
|
||||
if(direction == SN_TO_GLOBAL)
|
||||
if (direction == SN_TO_GLOBAL)
|
||||
g_addr = sm->ip_hdr->ip_dst;
|
||||
else
|
||||
g_addr = sm->ip_hdr->ip_src;
|
||||
@ -1504,7 +1503,7 @@ RmGlobalIPAddresses(struct sctp_nat_msg *sm, struct sctp_nat_assoc *assoc, int d
|
||||
asconf_ipv4_param = (struct sctp_asconf_addrv4_param *) param;
|
||||
if (asconf_ipv4_param->addrp.addr == INADDR_ANY) { /* remove all bar pkt address */
|
||||
LIST_FOREACH_SAFE(G_Addr, &(assoc->Gaddr), list_Gaddr, G_Addr_tmp) {
|
||||
if(G_Addr->g_addr.s_addr != sm->ip_hdr->ip_src.s_addr) {
|
||||
if (G_Addr->g_addr.s_addr != sm->ip_hdr->ip_src.s_addr) {
|
||||
if (assoc->num_Gaddr > 1) { /* only delete if more than one */
|
||||
LIST_REMOVE(G_Addr, list_Gaddr);
|
||||
sn_free(G_Addr);
|
||||
@ -1519,7 +1518,7 @@ RmGlobalIPAddresses(struct sctp_nat_msg *sm, struct sctp_nat_assoc *assoc, int d
|
||||
return; /*shouldn't be any other addresses if the zero address is given*/
|
||||
} else {
|
||||
LIST_FOREACH_SAFE(G_Addr, &(assoc->Gaddr), list_Gaddr, G_Addr_tmp) {
|
||||
if(G_Addr->g_addr.s_addr == asconf_ipv4_param->addrp.addr) {
|
||||
if (G_Addr->g_addr.s_addr == asconf_ipv4_param->addrp.addr) {
|
||||
if (assoc->num_Gaddr > 1) { /* only delete if more than one */
|
||||
LIST_REMOVE(G_Addr, list_Gaddr);
|
||||
sn_free(G_Addr);
|
||||
@ -1588,33 +1587,33 @@ IsASCONFack(struct libalias *la, struct sctp_nat_msg *sm, int direction)
|
||||
param = sm->sctpchnk.Asconf;
|
||||
param_size = SCTP_SIZE32(ntohs(param->param_length));
|
||||
if (param_size == 8)
|
||||
return(1); /*success - default acknowledgement of everything */
|
||||
return (1); /*success - default acknowledgement of everything */
|
||||
|
||||
bytes_left = sm->chunk_length;
|
||||
if (bytes_left < param_size)
|
||||
return(0); /* not found */
|
||||
return (0); /* not found */
|
||||
/* step through Asconf parameters */
|
||||
while(bytes_left >= SN_ASCONFACK_PARAM_SIZE) {
|
||||
if (ntohs(param->param_type) == SCTP_SUCCESS_REPORT)
|
||||
return(1); /* success - but can't match correlation IDs - should only be one */
|
||||
return (1); /* success - but can't match correlation IDs - should only be one */
|
||||
/* check others just in case */
|
||||
bytes_left -= param_size;
|
||||
if (bytes_left >= SN_MIN_PARAM_SIZE) {
|
||||
param = SN_SCTP_NEXTPARAM(param);
|
||||
} else {
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
param_size = SCTP_SIZE32(ntohs(param->param_length));
|
||||
if (bytes_left < param_size) return(0);
|
||||
if (bytes_left < param_size) return (0);
|
||||
|
||||
if (++param_count > sysctl_param_proc_limit) {
|
||||
SN_LOG(SN_LOG_EVENT,
|
||||
logsctperror("Parameter parse limit exceeded (IsASCONFack)",
|
||||
sm->sctp_hdr->v_tag, sysctl_param_proc_limit, direction));
|
||||
return(0); /* not found limit exceeded*/
|
||||
return (0); /* not found limit exceeded*/
|
||||
}
|
||||
}
|
||||
return(0); /* not success */
|
||||
return (0); /* not success */
|
||||
}
|
||||
|
||||
/** @ingroup packet_parser
|
||||
@ -1643,31 +1642,31 @@ IsADDorDEL(struct libalias *la, struct sctp_nat_msg *sm, int direction)
|
||||
|
||||
bytes_left = sm->chunk_length;
|
||||
if (bytes_left < param_size)
|
||||
return(0); /* not found */
|
||||
return (0); /* not found */
|
||||
/* step through Asconf parameters */
|
||||
while(bytes_left >= SN_ASCONFACK_PARAM_SIZE) {
|
||||
if (ntohs(param->param_type) == SCTP_ADD_IP_ADDRESS)
|
||||
return(SCTP_ADD_IP_ADDRESS);
|
||||
return (SCTP_ADD_IP_ADDRESS);
|
||||
else if (ntohs(param->param_type) == SCTP_DEL_IP_ADDRESS)
|
||||
return(SCTP_DEL_IP_ADDRESS);
|
||||
return (SCTP_DEL_IP_ADDRESS);
|
||||
/* check others just in case */
|
||||
bytes_left -= param_size;
|
||||
if (bytes_left >= SN_MIN_PARAM_SIZE) {
|
||||
param = SN_SCTP_NEXTPARAM(param);
|
||||
} else {
|
||||
return(0); /*Neither found */
|
||||
return (0); /*Neither found */
|
||||
}
|
||||
param_size = SCTP_SIZE32(ntohs(param->param_length));
|
||||
if (bytes_left < param_size) return(0);
|
||||
if (bytes_left < param_size) return (0);
|
||||
|
||||
if (++param_count > sysctl_param_proc_limit) {
|
||||
SN_LOG(SN_LOG_EVENT,
|
||||
logsctperror("Parameter parse limit exceeded IsADDorDEL)",
|
||||
sm->sctp_hdr->v_tag, sysctl_param_proc_limit, direction));
|
||||
return(0); /* not found limit exceeded*/
|
||||
return (0); /* not found limit exceeded*/
|
||||
}
|
||||
}
|
||||
return(0); /*Neither found */
|
||||
return (0); /*Neither found */
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -1707,17 +1706,17 @@ ProcessSctpMsg(struct libalias *la, int direction, struct sctp_nat_msg *sm, stru
|
||||
if (rtnval != SN_NAT_PKT) {
|
||||
assoc->state = SN_RM;/* Mark for removal*/
|
||||
}
|
||||
return(rtnval);
|
||||
return (rtnval);
|
||||
case SN_INi: /* Initialising - Init */
|
||||
return(INi_process(la, direction, assoc, sm));
|
||||
return (INi_process(la, direction, assoc, sm));
|
||||
case SN_INa: /* Initialising - AddIP */
|
||||
return(INa_process(la, direction, assoc, sm));
|
||||
return (INa_process(la, direction, assoc, sm));
|
||||
case SN_UP: /* Association UP */
|
||||
return(UP_process(la, direction, assoc, sm));
|
||||
return (UP_process(la, direction, assoc, sm));
|
||||
case SN_CL: /* Association Closing */
|
||||
return(CL_process(la, direction, assoc, sm));
|
||||
return (CL_process(la, direction, assoc, sm));
|
||||
}
|
||||
return(SN_PROCESSING_ERROR);
|
||||
return (SN_PROCESSING_ERROR);
|
||||
}
|
||||
|
||||
/** @ingroup state_machine
|
||||
@ -1757,10 +1756,10 @@ ID_process(struct libalias *la, int direction, struct sctp_nat_assoc *assoc, str
|
||||
if (sm->msg == SN_SCTP_INIT)
|
||||
assoc->g_vtag = sm->sctpchnk.Init->initiate_tag;
|
||||
if (AddSctpAssocGlobal(la, assoc)) /* DB clash *///**** need to add dst address
|
||||
return((sm->msg == SN_SCTP_INIT) ? SN_REPLY_ABORT : SN_REPLY_ERROR);
|
||||
return ((sm->msg == SN_SCTP_INIT) ? SN_REPLY_ABORT : SN_REPLY_ERROR);
|
||||
if (sm->msg == SN_SCTP_ASCONF) {
|
||||
if (AddSctpAssocLocal(la, assoc, sm->ip_hdr->ip_dst)) /* DB clash */
|
||||
return(SN_REPLY_ERROR);
|
||||
return (SN_REPLY_ERROR);
|
||||
assoc->TableRegister |= SN_WAIT_TOLOCAL; /* wait for tolocal ack */
|
||||
}
|
||||
break;
|
||||
@ -1772,10 +1771,10 @@ ID_process(struct libalias *la, int direction, struct sctp_nat_assoc *assoc, str
|
||||
if (sm->msg == SN_SCTP_INIT)
|
||||
assoc->l_vtag = sm->sctpchnk.Init->initiate_tag;
|
||||
if (AddSctpAssocLocal(la, assoc, sm->ip_hdr->ip_src)) /* DB clash */
|
||||
return((sm->msg == SN_SCTP_INIT) ? SN_REPLY_ABORT : SN_REPLY_ERROR);
|
||||
return ((sm->msg == SN_SCTP_INIT) ? SN_REPLY_ABORT : SN_REPLY_ERROR);
|
||||
if (sm->msg == SN_SCTP_ASCONF) {
|
||||
if (AddSctpAssocGlobal(la, assoc)) /* DB clash */ //**** need to add src address
|
||||
return(SN_REPLY_ERROR);
|
||||
return (SN_REPLY_ERROR);
|
||||
assoc->TableRegister |= SN_WAIT_TOGLOBAL; /* wait for toglobal ack */
|
||||
}
|
||||
break;
|
||||
@ -1806,19 +1805,19 @@ ID_process(struct libalias *la, int direction, struct sctp_nat_assoc *assoc, str
|
||||
static int
|
||||
INi_process(struct libalias *la, int direction, struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm)
|
||||
{
|
||||
switch(sm->msg) {
|
||||
switch (sm->msg) {
|
||||
case SN_SCTP_INIT: /* a packet containing a retransmitted INIT chunk */
|
||||
sctp_ResetTimeOut(la, assoc, SN_I_T(la));
|
||||
return(SN_NAT_PKT);
|
||||
return (SN_NAT_PKT);
|
||||
case SN_SCTP_INITACK: /* a packet containing an INIT-ACK chunk */
|
||||
switch(direction){
|
||||
switch (direction) {
|
||||
case SN_TO_LOCAL:
|
||||
if (assoc->num_Gaddr) /*If tracking global addresses for this association */
|
||||
AddGlobalIPAddresses(sm, assoc, direction);
|
||||
assoc->l_vtag = sm->sctpchnk.Init->initiate_tag;
|
||||
if (AddSctpAssocLocal(la, assoc, sm->ip_hdr->ip_src)) { /* DB clash */
|
||||
assoc->state = SN_RM;/* Mark for removal*/
|
||||
return(SN_SEND_ABORT);
|
||||
return (SN_SEND_ABORT);
|
||||
}
|
||||
break;
|
||||
case SN_TO_GLOBAL:
|
||||
@ -1826,20 +1825,20 @@ INi_process(struct libalias *la, int direction, struct sctp_nat_assoc *assoc, st
|
||||
assoc->g_vtag = sm->sctpchnk.Init->initiate_tag;
|
||||
if (AddSctpAssocGlobal(la, assoc)) { /* DB clash */
|
||||
assoc->state = SN_RM;/* Mark for removal*/
|
||||
return(SN_SEND_ABORT);
|
||||
return (SN_SEND_ABORT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
assoc->state = SN_UP;/* association established for NAT */
|
||||
sctp_ResetTimeOut(la,assoc, SN_U_T(la));
|
||||
return(SN_NAT_PKT);
|
||||
return (SN_NAT_PKT);
|
||||
case SN_SCTP_ABORT: /* a packet containing an ABORT chunk */
|
||||
assoc->state = SN_RM;/* Mark for removal*/
|
||||
return(SN_NAT_PKT);
|
||||
return (SN_NAT_PKT);
|
||||
default:
|
||||
return(SN_DROP_PKT);
|
||||
return (SN_DROP_PKT);
|
||||
}
|
||||
return(SN_DROP_PKT);/* shouldn't get here very bad: log, drop and hope for the best */
|
||||
return (SN_DROP_PKT);/* shouldn't get here very bad: log, drop and hope for the best */
|
||||
}
|
||||
|
||||
/** @ingroup state_machine
|
||||
@ -1858,36 +1857,36 @@ INi_process(struct libalias *la, int direction, struct sctp_nat_assoc *assoc, st
|
||||
static int
|
||||
INa_process(struct libalias *la, int direction,struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm)
|
||||
{
|
||||
switch(sm->msg) {
|
||||
switch (sm->msg) {
|
||||
case SN_SCTP_ASCONF: /* a packet containing an ASCONF chunk*/
|
||||
sctp_ResetTimeOut(la,assoc, SN_I_T(la));
|
||||
return(SN_NAT_PKT);
|
||||
return (SN_NAT_PKT);
|
||||
case SN_SCTP_ASCONFACK: /* a packet containing an ASCONF chunk with a ADDIP-ACK */
|
||||
switch(direction){
|
||||
switch (direction) {
|
||||
case SN_TO_LOCAL:
|
||||
if (!(assoc->TableRegister & SN_WAIT_TOLOCAL)) /* wrong direction */
|
||||
return(SN_DROP_PKT);
|
||||
return (SN_DROP_PKT);
|
||||
break;
|
||||
case SN_TO_GLOBAL:
|
||||
if (!(assoc->TableRegister & SN_WAIT_TOGLOBAL)) /* wrong direction */
|
||||
return(SN_DROP_PKT);
|
||||
return (SN_DROP_PKT);
|
||||
}
|
||||
if (IsASCONFack(la,sm,direction)) {
|
||||
assoc->TableRegister &= SN_BOTH_TBL; /* remove wait flags */
|
||||
assoc->state = SN_UP; /* association established for NAT */
|
||||
sctp_ResetTimeOut(la,assoc, SN_U_T(la));
|
||||
return(SN_NAT_PKT);
|
||||
return (SN_NAT_PKT);
|
||||
} else {
|
||||
assoc->state = SN_RM;/* Mark for removal*/
|
||||
return(SN_NAT_PKT);
|
||||
return (SN_NAT_PKT);
|
||||
}
|
||||
case SN_SCTP_ABORT: /* a packet containing an ABORT chunk */
|
||||
assoc->state = SN_RM;/* Mark for removal*/
|
||||
return(SN_NAT_PKT);
|
||||
return (SN_NAT_PKT);
|
||||
default:
|
||||
return(SN_DROP_PKT);
|
||||
return (SN_DROP_PKT);
|
||||
}
|
||||
return(SN_DROP_PKT);/* shouldn't get here very bad: log, drop and hope for the best */
|
||||
return (SN_DROP_PKT);/* shouldn't get here very bad: log, drop and hope for the best */
|
||||
}
|
||||
|
||||
/** @ingroup state_machine
|
||||
@ -1906,17 +1905,17 @@ INa_process(struct libalias *la, int direction,struct sctp_nat_assoc *assoc, str
|
||||
static int
|
||||
UP_process(struct libalias *la, int direction, struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm)
|
||||
{
|
||||
switch(sm->msg) {
|
||||
switch (sm->msg) {
|
||||
case SN_SCTP_SHUTACK: /* a packet containing a SHUTDOWN-ACK chunk */
|
||||
assoc->state = SN_CL;
|
||||
sctp_ResetTimeOut(la,assoc, SN_C_T(la));
|
||||
return(SN_NAT_PKT);
|
||||
return (SN_NAT_PKT);
|
||||
case SN_SCTP_ABORT: /* a packet containing an ABORT chunk */
|
||||
assoc->state = SN_RM;/* Mark for removal*/
|
||||
return(SN_NAT_PKT);
|
||||
return (SN_NAT_PKT);
|
||||
case SN_SCTP_ASCONF: /* a packet containing an ASCONF chunk*/
|
||||
if ((direction == SN_TO_LOCAL) && assoc->num_Gaddr) /*If tracking global addresses for this association & from global side */
|
||||
switch(IsADDorDEL(la,sm,direction)) {
|
||||
switch (IsADDorDEL(la,sm,direction)) {
|
||||
case SCTP_ADD_IP_ADDRESS:
|
||||
AddGlobalIPAddresses(sm, assoc, direction);
|
||||
break;
|
||||
@ -1926,9 +1925,9 @@ UP_process(struct libalias *la, int direction, struct sctp_nat_assoc *assoc, str
|
||||
} /* fall through to default */
|
||||
default:
|
||||
sctp_ResetTimeOut(la,assoc, SN_U_T(la));
|
||||
return(SN_NAT_PKT); /* forward packet */
|
||||
return (SN_NAT_PKT); /* forward packet */
|
||||
}
|
||||
return(SN_DROP_PKT);/* shouldn't get here very bad: log, drop and hope for the best */
|
||||
return (SN_DROP_PKT);/* shouldn't get here very bad: log, drop and hope for the best */
|
||||
}
|
||||
|
||||
/** @ingroup state_machine
|
||||
@ -1949,25 +1948,25 @@ UP_process(struct libalias *la, int direction, struct sctp_nat_assoc *assoc, str
|
||||
static int
|
||||
CL_process(struct libalias *la, int direction,struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm)
|
||||
{
|
||||
switch(sm->msg) {
|
||||
switch (sm->msg) {
|
||||
case SN_SCTP_SHUTCOMP: /* a packet containing a SHUTDOWN-COMPLETE chunk */
|
||||
assoc->state = SN_CL; /* Stay in Close state until timeout */
|
||||
if (sysctl_holddown_timer > 0)
|
||||
sctp_ResetTimeOut(la, assoc, SN_X_T(la));/* allow to stay open for Tbit packets*/
|
||||
else
|
||||
assoc->state = SN_RM;/* Mark for removal*/
|
||||
return(SN_NAT_PKT);
|
||||
return (SN_NAT_PKT);
|
||||
case SN_SCTP_SHUTACK: /* a packet containing a SHUTDOWN-ACK chunk */
|
||||
assoc->state = SN_CL; /* Stay in Close state until timeout */
|
||||
sctp_ResetTimeOut(la, assoc, SN_C_T(la));
|
||||
return(SN_NAT_PKT);
|
||||
return (SN_NAT_PKT);
|
||||
case SN_SCTP_ABORT: /* a packet containing an ABORT chunk */
|
||||
assoc->state = SN_RM;/* Mark for removal*/
|
||||
return(SN_NAT_PKT);
|
||||
return (SN_NAT_PKT);
|
||||
default:
|
||||
return(SN_DROP_PKT);
|
||||
return (SN_DROP_PKT);
|
||||
}
|
||||
return(SN_DROP_PKT);/* shouldn't get here very bad: log, drop and hope for the best */
|
||||
return (SN_DROP_PKT);/* shouldn't get here very bad: log, drop and hope for the best */
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -2008,16 +2007,16 @@ FindSctpLocal(struct libalias *la, struct in_addr l_addr, struct in_addr g_addr,
|
||||
&& (assoc->l_addr.s_addr == l_addr.s_addr)) {
|
||||
if (assoc->num_Gaddr) {
|
||||
LIST_FOREACH(G_Addr, &(assoc->Gaddr), list_Gaddr) {
|
||||
if(G_Addr->g_addr.s_addr == g_addr.s_addr)
|
||||
return(assoc);
|
||||
if (G_Addr->g_addr.s_addr == g_addr.s_addr)
|
||||
return (assoc);
|
||||
}
|
||||
} else {
|
||||
return(assoc);
|
||||
return (assoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return(NULL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/** @ingroup Hash
|
||||
@ -2046,17 +2045,17 @@ FindSctpGlobalClash(struct libalias *la, struct sctp_nat_assoc *Cassoc)
|
||||
if (assoc->num_Gaddr) {
|
||||
LIST_FOREACH(G_AddrC, &(Cassoc->Gaddr), list_Gaddr) {
|
||||
LIST_FOREACH(G_Addr, &(assoc->Gaddr), list_Gaddr) {
|
||||
if(G_Addr->g_addr.s_addr == G_AddrC->g_addr.s_addr)
|
||||
return(assoc);
|
||||
if (G_Addr->g_addr.s_addr == G_AddrC->g_addr.s_addr)
|
||||
return (assoc);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return(assoc);
|
||||
return (assoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return(NULL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/** @ingroup Hash
|
||||
@ -2093,16 +2092,16 @@ FindSctpGlobal(struct libalias *la, struct in_addr g_addr, uint32_t g_vtag, uint
|
||||
*partial_match = 1;
|
||||
if (assoc->num_Gaddr) {
|
||||
LIST_FOREACH(G_Addr, &(assoc->Gaddr), list_Gaddr) {
|
||||
if(G_Addr->g_addr.s_addr == g_addr.s_addr)
|
||||
return(assoc);
|
||||
if (G_Addr->g_addr.s_addr == g_addr.s_addr)
|
||||
return (assoc);
|
||||
}
|
||||
} else {
|
||||
return(assoc);
|
||||
return (assoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return(NULL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/** @ingroup Hash
|
||||
@ -2174,16 +2173,16 @@ FindSctpGlobalT(struct libalias *la, struct in_addr g_addr, uint32_t g_vtag, uin
|
||||
if ((assoc->l_vtag == g_vtag) && (assoc->l_port == l_port) && (assoc->g_port == g_port)) {
|
||||
if (assoc->num_Gaddr) {
|
||||
LIST_FOREACH(G_Addr, &(assoc->Gaddr), list_Gaddr) {
|
||||
if(G_Addr->g_addr.s_addr == g_addr.s_addr)
|
||||
return(assoc);
|
||||
if (G_Addr->g_addr.s_addr == g_addr.s_addr)
|
||||
return (assoc);
|
||||
}
|
||||
} else {
|
||||
return(assoc);
|
||||
return (assoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return(NULL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/** @ingroup Hash
|
||||
@ -2225,7 +2224,7 @@ AddSctpAssocLocal(struct libalias *la, struct sctp_nat_assoc *assoc, struct in_a
|
||||
freeGlobalAddressList(found);
|
||||
sn_free(found);
|
||||
} else
|
||||
return(SN_ADD_CLASH);
|
||||
return (SN_ADD_CLASH);
|
||||
}
|
||||
|
||||
LIST_INSERT_HEAD(&la->sctpTableLocal[SN_TABLE_HASH(assoc->l_vtag, assoc->l_port, la->sctpNatTableSize)],
|
||||
@ -2241,7 +2240,7 @@ AddSctpAssocLocal(struct libalias *la, struct sctp_nat_assoc *assoc, struct in_a
|
||||
SN_LOG(SN_LOG_INFO, logsctpassoc(assoc, "^"));
|
||||
}
|
||||
|
||||
return(SN_ADD_OK);
|
||||
return (SN_ADD_OK);
|
||||
}
|
||||
|
||||
/** @ingroup Hash
|
||||
@ -2274,7 +2273,7 @@ AddSctpAssocGlobal(struct libalias *la, struct sctp_nat_assoc *assoc)
|
||||
freeGlobalAddressList(found);
|
||||
sn_free(found);
|
||||
} else
|
||||
return(SN_ADD_CLASH);
|
||||
return (SN_ADD_CLASH);
|
||||
}
|
||||
|
||||
LIST_INSERT_HEAD(&la->sctpTableGlobal[SN_TABLE_HASH(assoc->g_vtag, assoc->g_port, la->sctpNatTableSize)],
|
||||
@ -2290,7 +2289,7 @@ AddSctpAssocGlobal(struct libalias *la, struct sctp_nat_assoc *assoc)
|
||||
SN_LOG(SN_LOG_INFO, logsctpassoc(assoc, "^"));
|
||||
}
|
||||
|
||||
return(SN_ADD_OK);
|
||||
return (SN_ADD_OK);
|
||||
}
|
||||
|
||||
/** @ingroup Hash
|
||||
@ -2466,7 +2465,7 @@ sctp_CheckTimers(struct libalias *la)
|
||||
//SLIST_REMOVE_HEAD(&la->sctpNatTimer.TimerQ[la->sctpNatTimer.cur_loc], timer_Q);
|
||||
LIST_REMOVE(assoc, timer_Q);
|
||||
if (la->timeStamp >= assoc->exp) { /* state expired */
|
||||
SN_LOG(((assoc->state == SN_CL)?(SN_LOG_DEBUG):(SN_LOG_INFO)),
|
||||
SN_LOG(((assoc->state == SN_CL) ? (SN_LOG_DEBUG) : (SN_LOG_INFO)),
|
||||
logsctperror("Timer Expired", assoc->g_vtag, assoc->state, SN_TO_NODIR));
|
||||
RmSctpAssoc(la, assoc);
|
||||
freeGlobalAddressList(assoc);
|
||||
@ -2504,7 +2503,7 @@ static void
|
||||
logsctperror(char* errormsg, uint32_t vtag, int error, int direction)
|
||||
{
|
||||
char dir;
|
||||
switch(direction) {
|
||||
switch (direction) {
|
||||
case SN_TO_LOCAL:
|
||||
dir = 'L';
|
||||
break;
|
||||
@ -2528,7 +2527,7 @@ static void
|
||||
logsctpparse(int direction, struct sctp_nat_msg *sm)
|
||||
{
|
||||
char *ploc, *pstate;
|
||||
switch(direction) {
|
||||
switch (direction) {
|
||||
case SN_TO_LOCAL:
|
||||
ploc = "TO_LOCAL -";
|
||||
break;
|
||||
@ -2538,7 +2537,7 @@ logsctpparse(int direction, struct sctp_nat_msg *sm)
|
||||
default:
|
||||
ploc = "";
|
||||
}
|
||||
switch(sm->msg) {
|
||||
switch (sm->msg) {
|
||||
case SN_SCTP_INIT:
|
||||
pstate = "Init";
|
||||
break;
|
||||
@ -2582,7 +2581,7 @@ static void logsctpassoc(struct sctp_nat_assoc *assoc, char* s)
|
||||
char *sp;
|
||||
char addrbuf[INET_ADDRSTRLEN];
|
||||
|
||||
switch(assoc->state) {
|
||||
switch (assoc->state) {
|
||||
case SN_ID:
|
||||
sp = "ID ";
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user