int sdp_mangle_ip (struct sip_msg *msg, char *oldip, char *newip) { int i, oldContentLength, newContentLength, diff, oldlen,len,off,ret,needToDealocate; unsigned int mask, address, locatedIp; struct lump *l; regmatch_t pmatch; regex_t *re; char *s, *pos,*begin,*key; char buffer[16]; /* 123.456.789.123\0 */ #ifdef DEBUG fprintf (stdout,"---START--------MANGLE IP-----------------\n"); #endif key = IP_REGEX; /* * Checking if msg has a payload */ if (msg == NULL) { LOG(L_ERR,"ERROR: sdp_mangle_ip: Received NULL for msg\n"); return -1; } if ((msg->content_length==0) && ((parse_headers(msg,HDR_CONTENTLENGTH,0)==-1) || (msg->content_length==0) )){ LOG(L_ERR,"ERROR: sdp_mangle_port: bad or missing " "Content-Length \n"); return -2; } oldContentLength = get_content_length(msg); if (oldContentLength <= 0) { LOG(L_ERR,"ERROR: sdp_mangle_ip: Received <= for Content-Length\n"); return -2; } /* checking oldip */ if (oldip == NULL) { LOG(L_ERR,"ERROR: sdp_mangle_ip: Received NULL for oldip\n"); return -3; } /* checking newip */ if (newip == NULL) { LOG(L_ERR,"ERROR: sdp_mangle_ip: Received NULL for newip\n"); return -4; } i = parse_ip_netmask (oldip, &pos, &mask); if (i == -1) { /* invalid value for the netmask specified in oldip */ LOG(L_ERR,"ERROR: sdp_mangle_ip: invalid value for the netmask specified in oldip\n"); return -5; } else { i = parse_ip_address (pos, &address); if (pos != NULL) free (pos); if (i == 0) { LOG(L_ERR,"ERROR: sdp_mangle_ip: invalid value for the ip specified in oldip\n"); return -6; /* parse error in ip */ } } /* now we have in address/netmask binary values */ begin = get_body(msg);//msg->buf + msg->first_line.len; // inlocuiesc cu begin = getbody */ ret = -1; len = strlen (newip); /* try to use precompiled expressions */ needToDealocate = 0; if (ipExpression != NULL) { re = ipExpression; #ifdef DEBUG fprintf(stdout,"Using PRECOMPILED expression for ip ...\n"); #endif } else /* we are not using precompiled expressions */ { re = pkg_malloc(sizeof(regex_t)); if (re == NULL) { LOG(L_ERR,"ERROR: sdp_mangle_ip: Unable to allocate re\n"); return -7; } needToDealocate = 1; if ((regcomp (re, key, REG_EXTENDED)) != 0) { LOG(L_ERR,"ERROR: sdp_mangle_ip: Unable to compile %s \n",key); return -8; } #ifdef DEBUG fprintf(stdout,"Using ALLOCATED expression for ip ...\n"); #endif } diff = 0; while ((begin < msg->buf + msg->len) && (regexec (re, begin, 1, &pmatch, 0) == 0)) { off = begin - msg->buf; if (pmatch.rm_so == -1) { LOG (L_ERR,"ERROR: sdp_mangler_ip: offset unknown\n"); return -9; } #ifdef STRICT_CHECK pmatch.rm_eo --; /* return with one space,\n,\r */ #endif /* for BSD and Solaris we avoid memrchr pos = (char *) memrchr (begin + pmatch.rm_so, ' ',pmatch.rm_eo - pmatch.rm_so); */ pos = begin+pmatch.rm_eo; do pos--; while (*pos != ' '); /* we should find ' ' because we matched c=IN IP4 ip */ pos++; /* jumping over space */ oldlen = (pmatch.rm_eo - pmatch.rm_so) - (pos - (begin + pmatch.rm_so)); /* ip length */ if (oldlen > 15) { LOG(L_WARN,"WARNING: sdp_mangle_ip: Silent fail because oldlen > 15\n"); #ifdef STRICT_CHECK return -10; #else goto continue2; /* silent fail return -10; invalid ip format ,probably like 1000.3.12341.2 */ #endif } buffer[0] = '\0'; strncat ((char *) buffer, pos, oldlen); buffer[oldlen] = '\0'; i = parse_ip_address (buffer, &locatedIp); if (i == 0) { LOG(L_WARN,"WARNING: sdp_mangle_ip: Silent fail on parsing matched address \n"); #ifdef STRICT_CHECK return -11; #else goto continue2; #endif } if (same_net (locatedIp, address, mask) == 0) { LOG(L_WARN,"WARNING: sdp_mangle_ip: Silent fail because matched address is not in network\n"); #ifdef DEBUG fprintf(stdout,"Extracted ip is %s and not mangling \n",buffer); #endif goto continue2; /* not in the same net, skiping */ } #ifdef DEBUG fprintf(stdout,"Extracted ip is %s and mangling to %s\n",buffer,newip); #endif /* replacing ip */ /* deleting old ip */ if ((l = del_lump (msg,pmatch.rm_so + off + (pos - (begin + pmatch.rm_so)),oldlen, 0)) == 0) { LOG (L_ERR,"ERROR: sdp_mangle_ip: del_lump failed\n"); return -12; } s = pkg_malloc (len); if (s == 0) { LOG (L_ERR,"ERROR: sdp_mangle_ip: mem. allocation failure\n"); return -13; } memcpy (s, newip, len); if (insert_new_lump_after (l, s, len, 0) == 0) { LOG (L_ERR, "ERROR: sdp_mangle_ip: could not insert new lump\n"); pkg_free (s); return -14; } diff = diff + len /*new length */ - oldlen; /* new cycle */ ret++; continue2: begin = begin + pmatch.rm_eo; } /* while */ if (needToDealocate) { regfree (re); /* if I am going to use precompiled expressions to be removed */ pkg_free(re); #ifdef DEBUG fprintf(stdout,"Dealocating expression for ip ...\n"); #endif } if (diff != 0) { newContentLength = oldContentLength + diff; patch_content_length (msg, newContentLength); } #ifdef DEBUG fprintf (stdout,"---END--------MANGLE IP-----------------\n"); #endif return ret+2; }
/* this functione tryes to interpret what we have read from the config file and makes the changes to the global variables if possible */ void change_config (struct name_value *config_values) { int result, ret; unsigned int conv; struct name_value *config_list, *csv_list, *this_name_value; struct fcp_address_list *this_address_list, *tmp; config_list = config_values; fcp_log (LOG_DEBUG, "CONFIGURE: begin of changing configuration"); while (config_list->name != NULL) { /* what parameter was read */ result = compare_to_def (config_list->name); if (result) { /* if it was a correct spelled parameter switch to point where we scan the value and make the changes */ switch (result) { case argument_PORT: conv = atol (config_list->value); if ((conv > 65535) || (conv < 1)) { sprintf (debug_msg_helper, "CONFIGURE: error port %i out of range", conv); fcp_log (LOG_ERR, debug_msg_helper); conv = FCP_DEFAULT_PORT; sprintf (debug_msg_helper, "CONFIGURE: using standard port %i instead", conv); fcp_log (LOG_ERR, debug_msg_helper); } else { sprintf (debug_msg_helper, "CONFIGURE: using port %i", conv); fcp_log (LOG_DEBUG, debug_msg_helper); } if (conv != fcp_port) { /* the listening port have changed so we stop our network (all connections are getting lost) and restart it with the new port */ stop_network(); fcp_port = conv; init_network(); fcp_log (LOG_DEBUG, "CONFIGURE: network restartet with new port"); } break; case argument_DEBUGLEVEL: conv = atoi (config_list->value); if ((conv > 7) || (conv < 0)) { sprintf (debug_msg_helper, "CONFIGURE: error debuglevel %i out of range", conv); fcp_log (LOG_ERR, debug_msg_helper); } else { if (fcp_loglevel_override) conv = fcp_loglevel; /* was specified on command line */ sprintf (debug_msg_helper, "CONFIGURE: using debuglevel %i", conv); fcp_log (LOG_INFO, debug_msg_helper); if (conv != fcp_loglevel) /* change our loglevel to the new value */ fcp_loglevel = conv; } break; case argument_ACL: sprintf (debug_msg_helper, "CONFIGURE: access restricted to %s.", config_list->value); fcp_log (LOG_DEBUG, debug_msg_helper); /* Seperate the string by the commas */ csv_list = (struct name_value *) scan_csv (config_list->value); if (csv_list) { /* First of all free the existing acl_list. */ this_address_list = fcp_acl_list.next; while (this_address_list) { tmp = this_address_list->next; free (this_address_list); this_address_list = tmp; } /* Convert the strings into IPs and netmasks and put them into the acl_list. */ this_name_value = csv_list; fcp_acl_list.next = malloc (sizeof (struct fcp_address_list)); this_address_list = fcp_acl_list.next; this_address_list->next = NULL; ret = parse_ip_netmask (this_name_value->name, &this_address_list->netmask); if (ret == 1) { if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in ACL isn't valid"); this_address_list->address = 0; } } else if (ret == 0) { this_address_list->netmask = 0xFFFFFFFF; if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in ACL isn't valid"); this_address_list->address = 0; } } else { fcp_log (LOG_ERR, "CONFIGURE: netmask in ACL isn't valid"); this_address_list->netmask = 0xFFFFFFFF; this_address_list->address = 0; } this_name_value = this_name_value->next; /* The first element is now in the list, now do the same for the rest. */ while (this_name_value) { this_address_list->next = malloc (sizeof (struct fcp_address_list)); this_address_list = this_address_list->next; this_address_list->next = NULL; ret = parse_ip_netmask (this_name_value->name, &this_address_list->netmask); if (ret == 1) { if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in ACL isn't valid"); this_address_list->address = 0; } } else if (ret == 0) { this_address_list->netmask = 0xFFFFFFFF; if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in ACL isn't valid"); this_address_list->address = 0; } } else { fcp_log (LOG_ERR, "CONFIGURE: netmask in ACL isn't valid"); this_address_list->netmask = 0xFFFFFFFF; this_address_list->address = 0; } this_name_value = this_name_value->next; } /* Everything is in the acl_list now freeing the name_value_list where the strings were in. */ while (csv_list) { this_name_value = csv_list->next; free (csv_list->name); free (csv_list); csv_list = this_name_value; } } else { fcp_log (LOG_ERR, "CONFIGURE: ACL couldn't be converted"); /* Free the existing acl_list if exists. */ if (fcp_acl_list.next) { this_address_list = fcp_acl_list.next; while (this_address_list) { tmp = this_address_list->next; free (this_address_list); this_address_list = tmp; } fcp_acl_list.next = NULL; } } break; case argument_INTFIN: if (strlen (config_list->value) > 0) { sprintf (debug_msg_helper, "CONFIGURE: in interface %s found.", config_list->value); fcp_log (LOG_DEBUG, debug_msg_helper); /* Freeing the old interface if specified, alloc and copy the new value. More then one interface is NOT supported yet. */ if (fcp_in_interface.name) free (fcp_in_interface.name); fcp_in_interface.name = malloc (sizeof (config_list->value)); strcpy (fcp_in_interface.name, config_list->value); } break; case argument_INTFOUT: if (strlen (config_list->value) > 0) { sprintf (debug_msg_helper, "CONFIGURE: out interface %s found.", config_list->value); fcp_log (LOG_DEBUG, debug_msg_helper); /* Freeing the old interface if specified, alloc and copy the new value. More then one interface is NOT supported yet. */ if (fcp_out_interface.name) free (fcp_out_interface.name); fcp_out_interface.name = malloc (sizeof (config_list->value)); strcpy (fcp_out_interface.name, config_list->value); } break; case argument_INTFDMZ: if (strlen (config_list->value) > 0) { sprintf (debug_msg_helper, "CONFIGURE: dmz interface %s found.", config_list->value); fcp_log (LOG_DEBUG, debug_msg_helper); /* Freeing the old interface if specified, alloc and copy the new value. More then one interface is NOT supported yet. */ if (fcp_dmz_interface.name) free (fcp_dmz_interface.name); fcp_dmz_interface.name = malloc (sizeof (config_list->value)); strcpy (fcp_dmz_interface.name, config_list->value); } break; case argument_TIMEOUT: conv = atoi (config_list->value); if ((conv > FCP_MAX_TIMEOUT) || (conv < 0)) { sprintf (debug_msg_helper, "CONFIGURE: the timeout value %i is grater then the" " maximum %i or less 0", conv, FCP_MAX_TIMEOUT); fcp_log (LOG_ERR, debug_msg_helper); conv = FCP_DEFAULT_TIMEOUT; sprintf (debug_msg_helper, "CONFIGURE: using standard timeout %i instead", conv); fcp_log (LOG_ERR, debug_msg_helper); } else { sprintf (debug_msg_helper, "CONFIGURE: using %i as standard timeout value", conv); fcp_log (LOG_DEBUG, debug_msg_helper); } if (conv != fcp_timeout) /* is there anything else to do ??? should we calculate the timeout of the existing states new? but how? we don't know how much time is elapsed by every state. so i assume that the new timeout is only valid for new states. :( */ fcp_timeout = conv; break; case argument_MAXPRIORITY: conv = atoi (config_list->value); if ((conv > FCP_MAX_PRIORITY_CLASSES) || (conv < 0)) { sprintf (debug_msg_helper, "CONFIGURE: %i priority classes are grater then the" " maximum %i or less 0", conv, FCP_MAX_PRIORITY_CLASSES); fcp_log (LOG_ERR, debug_msg_helper); conv = FCP_DEFAULT_PRIORITY_CLASSES; sprintf (debug_msg_helper, "CONFIGURE: using %i priority classes instead.", conv); fcp_log (LOG_ERR, debug_msg_helper); } else { sprintf (debug_msg_helper, "CONFIGURE: using %i priority classes.", conv); fcp_log (LOG_DEBUG, debug_msg_helper); } if (conv != fcp_priorityclasses) /* *FIXME* here we definetly have to do some more things but at this ... */ fcp_priorityclasses = conv; break; case argument_MAXLOG: conv = atoi (config_list->value); if ((conv > FCP_MAX_LOG_CLASSES) || (conv < 0)) { sprintf (debug_msg_helper, "CONFIGURE: %i log classes are grater then the" " maximum %i or less 0", conv, FCP_MAX_LOG_CLASSES); fcp_log (LOG_ERR, debug_msg_helper); conv = FCP_DEFAULT_LOG_CLASSES; sprintf (debug_msg_helper, "CONFIGURE: using %i log classes instead.", conv); fcp_log (LOG_ERR, debug_msg_helper); } else { sprintf (debug_msg_helper, "CONFIGURE: using %i logging classes.", conv); fcp_log (LOG_DEBUG, debug_msg_helper); } if (fcp_logclasses != conv) /* *FIXME* here we definetly have to do some more things but at this time ... */ fcp_logclasses = conv; break; case argument_INTERNALIPS: sprintf (debug_msg_helper, "CONFIGURE: internal IPs are %s.", config_list->value); fcp_log (LOG_DEBUG, debug_msg_helper); /* Seperate the string by the commas */ csv_list = (struct name_value *) scan_csv (config_list->value); if (csv_list) { /* First of all free the existing internal_ips. */ this_address_list = fcp_internal_ips.next; while (this_address_list) { tmp = this_address_list->next; free (this_address_list); this_address_list = tmp; } /* Convert the strings into IPs and netmasks and put them into the internal_ips. */ this_name_value = csv_list; fcp_internal_ips.next = malloc (sizeof (struct fcp_address_list)); this_address_list = fcp_internal_ips.next; this_address_list->next = NULL; ret = parse_ip_netmask (this_name_value->name, &this_address_list->netmask); if (ret == 1) { if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in INTERNALIPS isn't valid"); this_address_list->address = 0; } } else if (ret == 0) { this_address_list->netmask = 0xFFFFFFFF; if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in INTERNALIPS isn't valid"); this_address_list->address = 0; } } else { fcp_log (LOG_ERR, "CONFIGURE: netmask in INTERNALIPS isn't" " valid"); this_address_list->netmask = 0xFFFFFFFF; this_address_list->address = 0; } this_name_value = this_name_value->next; /* The first element is now in the list, now do the same for the rest. */ while (this_name_value) { this_address_list->next = malloc (sizeof (struct fcp_address_list)); this_address_list = this_address_list->next; this_address_list->next = NULL; ret = parse_ip_netmask (this_name_value->name, &this_address_list->netmask); if (ret == 1) { if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in INTERNALIPS isn't" " valid"); this_address_list->address = 0; } } else if (ret == 0) { this_address_list->netmask = 0xFFFFFFFF; if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in INTERNALIPS isn't" " valid"); this_address_list->address = 0; } } else { fcp_log (LOG_ERR, "CONFIGURE: netmask in INTERNALIPS isn't" " valid"); this_address_list->netmask = 0xFFFFFFFF; this_address_list->address = 0; } this_name_value = this_name_value->next; } /* Everything is in the internal_ips now freeing the name_value_list where the strings were in. */ while (csv_list) { this_name_value = csv_list->next; free (csv_list->name); free (csv_list); csv_list = this_name_value; } } else { fcp_log (LOG_ERR, "CONFIGURE: INTERNALIPS couldn't be converted"); /* Free the existing internal_ips if exists. */ if (fcp_internal_ips.next) { this_address_list = fcp_internal_ips.next; while (this_address_list) { tmp = this_address_list->next; free (this_address_list); this_address_list = tmp; } fcp_internal_ips.next = NULL; } } break; case argument_MASQUIPS: sprintf (debug_msg_helper, "CONFIGURE: this IPS %s will be masqueraded.", config_list->value); fcp_log (LOG_DEBUG, debug_msg_helper); /* Seperate the string by the commas */ csv_list = (struct name_value *) scan_csv (config_list->value); if (csv_list) { /* First of all free the existing masqu_ips. */ this_address_list = fcp_masq_ips.next; while (this_address_list) { tmp = this_address_list->next; free (this_address_list); this_address_list = tmp; } /* Convert the strings into IPs and netmasks and put them into the masqu_ips. */ this_name_value = csv_list; fcp_masq_ips.next = malloc (sizeof (struct fcp_address_list)); this_address_list = fcp_masq_ips.next; this_address_list->next = NULL; ret = parse_ip_netmask (this_name_value->name, &this_address_list->netmask); if (ret == 1) { if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in MASQUIPS isn't valid"); this_address_list->address = 0; } } else if (ret == 0) { this_address_list->netmask = 0xFFFFFFFF; if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in MASQUIPS isn't valid"); this_address_list->address = 0; } } else { fcp_log (LOG_ERR, "CONFIGURE: netmask in MASQUIPS isn't valid"); this_address_list->netmask = 0xFFFFFFFF; this_address_list->address = 0; } this_name_value = this_name_value->next; /* The first element is now in the list, now do the same for the rest. */ while (this_name_value) { this_address_list->next = malloc (sizeof (struct fcp_address_list)); this_address_list = this_address_list->next; this_address_list->next = NULL; ret = parse_ip_netmask (this_name_value->name, &this_address_list->netmask); if (ret == 1) { if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in MASQUIPS isn't" " valid"); this_address_list->address = 0; } } else if (ret == 0) { this_address_list->netmask = 0xFFFFFFFF; if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in MASQUIPS isn't" " valid"); this_address_list->address = 0; } } else { fcp_log (LOG_ERR, "CONFIGURE: netmask in MASQUIPS isn't" " valid"); this_address_list->netmask = 0xFFFFFFFF; this_address_list->address = 0; } this_name_value = this_name_value->next; } /* Everything is in the masqu_ips now freeing the name_value_list where the strings were in. */ while (csv_list) { this_name_value = csv_list->next; free (csv_list->name); free (csv_list); csv_list = this_name_value; } } else { fcp_log (LOG_ERR, "CONFIGURE: MASQIPS couldn't be converted"); /* Free the existing masq_ips if exists. */ if (fcp_masq_ips.next) { this_address_list = fcp_masq_ips.next; while (this_address_list) { tmp = this_address_list->next; free (this_address_list); this_address_list = tmp; } fcp_masq_ips.next = NULL; } } break; case argument_IPIN: if (parse_ip_address (config_list->value, &conv)) { sprintf (debug_msg_helper, "CONFIGURE: IP of internal interface is %s", config_list->value); fcp_log (LOG_DEBUG, debug_msg_helper); fcp_internal_IP = conv; } else { sprintf (debug_msg_helper, "CONFIGURE: couldn't convert IP (%s) of internal" " interface", config_list->value); fcp_log (LOG_ERR, debug_msg_helper); } break; case argument_IPOUT: if (parse_ip_address (config_list->value, &conv)) { sprintf (debug_msg_helper, "CONFIGURE: IP of outer (external) interface is %s", config_list->value); fcp_log (LOG_DEBUG, debug_msg_helper); fcp_outer_IP = conv; } else { sprintf (debug_msg_helper, "CONFIGURE: couldn't convert IP (%s) of outer" " (external) interface", config_list->value); fcp_log (LOG_ERR, debug_msg_helper); } break; case argument_IPDMZ: if (parse_ip_address (config_list->value, &conv)) { sprintf (debug_msg_helper, "CONFIGURE: IP of DMZ interface is %s", config_list->value); fcp_log (LOG_DEBUG, debug_msg_helper); fcp_demilitary_IP = conv; } else { sprintf (debug_msg_helper, "CONFIGURE: couldn't convert IP (%s) of DMZ" " interface", config_list->value); fcp_log (LOG_ERR, debug_msg_helper); } break; case argument_DMZIPS: sprintf (debug_msg_helper, "CONFIGURE: this IPS %s are in the DMZ.", config_list->value); fcp_log (LOG_DEBUG, debug_msg_helper); /* Seperate the string by the commas */ csv_list = (struct name_value *) scan_csv (config_list->value); if (csv_list) { /* First of all free the existing dmz_ips. */ this_address_list = fcp_dmz_ips.next; while (this_address_list) { tmp = this_address_list->next; free (this_address_list); this_address_list = tmp; } /* Convert the strings into IPs and netmasks and put them into the dmz_ips. */ this_name_value = csv_list; fcp_dmz_ips.next = malloc (sizeof (struct fcp_address_list)); this_address_list = fcp_dmz_ips.next; this_address_list->next = NULL; ret = parse_ip_netmask (this_name_value->name, &this_address_list->netmask); if (ret == 1) { if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in DMZIPS isn't valid"); this_address_list->address = 0; } } else if (ret == 0) { this_address_list->netmask = 0xFFFFFFFF; if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in DMZIPS isn't valid"); this_address_list->address = 0; } } else { fcp_log (LOG_ERR, "CONFIGURE: netmask in DMZIPS isn't valid"); this_address_list->netmask = 0xFFFFFFFF; this_address_list->address = 0; } this_name_value = this_name_value->next; /* The first element is now in the list, now do the same for the rest. */ while (this_name_value) { this_address_list->next = malloc (sizeof (struct fcp_address_list)); this_address_list = this_address_list->next; this_address_list->next = NULL; ret = parse_ip_netmask (this_name_value->name, &this_address_list->netmask); if (ret == 1) { if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in DMZIPS isn't valid"); this_address_list->address = 0; } } else if (ret == 0) { this_address_list->netmask = 0xFFFFFFFF; if (!parse_ip_address (this_name_value->name, &this_address_list->address)) { fcp_log (LOG_ERR, "CONFIGURE: IP in DMZIPS isn't valid"); this_address_list->address = 0; } } else { fcp_log (LOG_ERR, "CONFIGURE: netmask in DMZIPS isn't valid"); this_address_list->netmask = 0xFFFFFFFF; this_address_list->address = 0; } this_name_value = this_name_value->next; } /* Everything is in the dmz_ips now freeing the name_value_list where the strings were in. */ while (csv_list) { this_name_value = csv_list->next; free (csv_list->name); free (csv_list); csv_list = this_name_value; } } else { fcp_log (LOG_ERR, "CONFIGURE: DMZIPS couldn't be converted"); /* Free the existing dmz_ips if exists. */ if (fcp_dmz_ips.next) { this_address_list = fcp_dmz_ips.next; while (this_address_list) { tmp = this_address_list->next; free (this_address_list); this_address_list = tmp; } fcp_dmz_ips.next = NULL; } } break; case argument_LOG_S: fcp_log_per_sec = atoi (config_list->value); sprintf (debug_msg_helper, "CONFIGURE: log class 1 will log %i packets/second", fcp_log_per_sec); fcp_log (LOG_DEBUG, debug_msg_helper); break; case argument_LOG_M: fcp_log_per_min = atoi (config_list->value); sprintf (debug_msg_helper, "CONFIGURE: log class 2 will log %i packets/minute", fcp_log_per_min); fcp_log (LOG_DEBUG, debug_msg_helper); break; case argument_LOG_H: fcp_log_per_hou = atoi (config_list->value); sprintf (debug_msg_helper, "CONFIGURE: log class 3 will log %i packets/hour", fcp_log_per_hou); fcp_log (LOG_DEBUG, debug_msg_helper); break; case argument_LOG_D: fcp_log_per_day = atoi (config_list->value); sprintf (debug_msg_helper, "CONFIGURE: log class 4 will log %i packets/day", fcp_log_per_day); fcp_log (LOG_DEBUG, debug_msg_helper); break; default: sprintf (debug_msg_helper, "CONFIGURE: don't know what to do with parameter %s", config_list->name); fcp_log (LOG_ERR, debug_msg_helper); break; } } /* if result */ else { sprintf (debug_msg_helper, "CONFIGURE: unknown parameter %s found in config file\n", config_list->name); fcp_log (LOG_CRIT, debug_msg_helper); } /* if result */ config_list = config_list->next; } /* while */ fcp_log (LOG_DEBUG, "CONFIGURE: end of changing configuration\n"); }