}
if ((ConfGet("defrag.hash-size", &conf_val)) == 1)
{
- if (ByteExtractStringUint32(&configval, 10, strlen(conf_val),
+ if (StringParseUint32(&configval, 10, strlen(conf_val),
conf_val) > 0) {
defrag_config.hash_size = configval;
} else {
if ((ConfGet("defrag.trackers", &conf_val)) == 1)
{
- if (ByteExtractStringUint32(&configval, 10, strlen(conf_val),
+ if (StringParseUint32(&configval, 10, strlen(conf_val),
conf_val) > 0) {
defrag_config.prealloc = configval;
} else {
/* get the param */
tok = strtok_r(NULL, ASN_DELIM, &saveptr);
if ( tok == NULL ||
- ByteExtractStringUint32(&ov_len, 10, 0, tok) <= 0)
+ StringParseUint32(&ov_len, 10, 0, tok) <= 0)
{
SCLogError(SC_ERR_INVALID_VALUE, "Malformed value for "
"oversize_length: %s", tok);
/* get the param */
tok = strtok_r(NULL, ASN_DELIM, &saveptr);
if (tok == NULL ||
- ByteExtractStringUint32(&abs_off, 10, 0, tok) <= 0)
+ StringParseUint32(&abs_off, 10, 0, tok) <= 0)
{
SCLogError(SC_ERR_INVALID_VALUE, "Malformed value for "
"absolute_offset: %s", tok);
/* get the param */
tok = strtok_r(NULL, ASN_DELIM, &saveptr);
if (tok == NULL ||
- ByteExtractStringInt32(&rel_off, 10, 0, tok) <= 0)
+ StringParseInt32(&rel_off, 10, 0, tok) <= 0)
{
SCLogError(SC_ERR_INVALID_VALUE, "Malformed value for "
"relative_offset: %s", tok);
if (pcre_rc >= 3) {
if (pcre_get_substring((char *)str, ov, max, 2, &bytes_str) > 0) {
- if (ByteExtractStringUint32(bytes, 10, 0, bytes_str) <= 0) {
+ if (StringParseUint32(bytes, 10, 0, bytes_str) <= 0) {
SCLogError(SC_ERR_INVALID_RULE_ARGUMENT,
"Bad value for bytes: \"%s\"", bytes_str);
goto error;
if (pcre_rc >= 5) {
if (pcre_get_substring((char *)str, ov, max, 4, &offset_str)) {
- if (ByteExtractStringUint32(offset, 10, 0, offset_str) <= 0) {
+ if (StringParseUint32(offset, 10, 0, offset_str) <= 0) {
SCLogError(SC_ERR_INVALID_RULE_ARGUMENT,
"Bad value for offset: \"%s\"", offset_str);
goto error;
*/
/* Number of bytes */
- if (ByteExtractStringUint32(&nbytes, 10, strlen(args[0]), args[0]) <= 0) {
+ if (StringParseUint32(&nbytes, 10, strlen(args[0]), args[0]) <= 0) {
SCLogError(SC_ERR_INVALID_VALUE, "Malformed number of bytes: %s", optstr);
goto error;
}
if (*offset == NULL)
goto error;
} else {
- if (ByteExtractStringInt32(&data->offset, 0, strlen(args[1]), args[1]) <= 0) {
+ if (StringParseInt32(&data->offset, 0, strlen(args[1]), args[1]) <= 0) {
SCLogError(SC_ERR_INVALID_VALUE, "Malformed offset: %s", optstr);
goto error;
}
} else if (strcasecmp("align", args[i]) == 0) {
data->flags |= DETECT_BYTEJUMP_ALIGN;
} else if (strncasecmp("multiplier ", args[i], 11) == 0) {
- if (ByteExtractStringUint32(&data->multiplier, 10,
+ if (StringParseUint32(&data->multiplier, 10,
strlen(args[i]) - 11,
args[i] + 11) <= 0)
{
goto error;
}
} else if (strncasecmp("post_offset ", args[i], 12) == 0) {
- if (ByteExtractStringInt32(&data->post_offset, 10,
+ if (StringParseInt32(&data->post_offset, 10,
strlen(args[i]) - 12,
args[i] + 12) <= 0)
{
*/
/* Number of bytes */
- if (ByteExtractStringUint32(&nbytes, 10, 0, args[0]) <= 0) {
+ if (StringParseUint32(&nbytes, 10, 0, args[0]) <= 0) {
SCLogError(SC_ERR_INVALID_VALUE, "Malformed number of bytes: %s", str_ptr);
goto error;
}
if (*value == NULL)
goto error;
} else {
- if (ByteExtractStringUint64(&data->value, 0, 0, test_value) <= 0) {
+ if (StringParseUint64(&data->value, 0, 0, test_value) <= 0) {
SCLogError(SC_ERR_INVALID_VALUE, "Malformed value: %s", test_value);
goto error;
}
if (*offset == NULL)
goto error;
} else {
- if (ByteExtractStringInt32(&data->offset, 0, 0, data_offset) <= 0) {
+ if (StringParseInt32(&data->offset, 0, 0, data_offset) <= 0) {
SCLogError(SC_ERR_INVALID_VALUE, "Malformed offset: %s", data_offset);
goto error;
}
return -1;
}
- if (ByteExtractStringUint16(rep_value, 10, 0, key) != (int)strlen(key))
+ if (StringParseUint16(rep_value, 10, 0, key) < 0)
return -1;
value_set = true;
cd->depth = ((DetectByteExtractData *)bed_sm->ctx)->local_id;
cd->flags |= DETECT_CONTENT_DEPTH_BE;
} else {
- if (ByteExtractStringUint16(&cd->depth, 0, 0, str) != (int)strlen(str))
+ if (StringParseUint16(&cd->depth, 0, 0, str) < 0)
{
SCLogError(SC_ERR_INVALID_SIGNATURE,
"invalid value for depth: %s.", str);
goto error;
}
- if (ByteExtractStringUint32(&df->count, 10, strlen(args[count_pos]),
+ if (StringParseUint32(&df->count, 10, strlen(args[count_pos]),
args[count_pos]) <= 0) {
goto error;
}
- if (ByteExtractStringUint32(&df->seconds, 10, strlen(args[seconds_pos]),
+ if (StringParseUint32(&df->seconds, 10, strlen(args[seconds_pos]),
args[seconds_pos]) <= 0) {
goto error;
}
cd->distance = ((DetectByteExtractData *)bed_sm->ctx)->local_id;
cd->flags |= DETECT_CONTENT_DISTANCE_BE;
} else {
- if (ByteExtractStringInt32(&cd->distance, 0, 0, str) != (int)strlen(str)) {
+ if (StringParseInt32(&cd->distance, 0, 0, str) < 0) {
SCLogError(SC_ERR_INVALID_SIGNATURE,
"invalid value for distance: %s", str);
goto end;
*/
static int DetectDNP3FuncParseFunctionCode(const char *str, uint8_t *fc)
{
- if (ByteExtractStringUint8(fc, 10, strlen(str), str) >= 0) {
+ if (StringParseUint8(fc, 10, strlen(str), str) >= 0) {
return 1;
}
{
*flags = 0;
- if (ByteExtractStringUint16(flags, 0, strlen(str), str) > 0) {
+ if (StringParseUint16(flags, 0, strlen(str), str) > 0) {
return 1;
}
*sep = '\0';
varstr = sep + 1;
- if (ByteExtractStringUint8(group, 0, strlen(groupstr), groupstr) < 0) {
+ if (StringParseUint8(group, 0, strlen(groupstr), groupstr) < 0) {
return 0;
}
- if (ByteExtractStringUint8(var, 0, strlen(varstr), varstr) < 0) {
+ if (StringParseUint8(var, 0, strlen(varstr), varstr) < 0) {
return 0;
}
}
/** set the first dsize value */
- if (ByteExtractStringUint16(&dd->dsize,10,strlen(value1),value1) <= 0) {
+ if (StringParseUint16(&dd->dsize,10,strlen(value1),value1) <= 0) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid size value1:\"%s\"", value1);
goto error;
}
goto error;
}
- if (ByteExtractStringUint16(&dd->dsize2,10,strlen(value2),value2) <= 0) {
+ if (StringParseUint16(&dd->dsize2,10,strlen(value2),value2) <= 0) {
SCLogError(SC_ERR_INVALID_ARGUMENT,"Invalid size value2:\"%s\"",value2);
goto error;
}
}
}
if (max_uniq_toclient_groups_str != NULL) {
- if (ByteExtractStringUint16(&de_ctx->max_uniq_toclient_groups, 10,
+ if (StringParseUint16(&de_ctx->max_uniq_toclient_groups, 10,
strlen(max_uniq_toclient_groups_str),
(const char *)max_uniq_toclient_groups_str) <= 0)
{
SCLogConfig("toclient-groups %u", de_ctx->max_uniq_toclient_groups);
if (max_uniq_toserver_groups_str != NULL) {
- if (ByteExtractStringUint16(&de_ctx->max_uniq_toserver_groups, 10,
+ if (StringParseUint16(&de_ctx->max_uniq_toserver_groups, 10,
strlen(max_uniq_toserver_groups_str),
(const char *)max_uniq_toserver_groups_str) <= 0)
{
goto bad_mapping;
uint32_t tenant_id = 0;
- if (ByteExtractStringUint32(&tenant_id, 10, strlen(tenant_id_node->val),
- tenant_id_node->val) == -1)
+ if (StringParseUint32(&tenant_id, 10, strlen(tenant_id_node->val),
+ tenant_id_node->val) < 0)
{
SCLogError(SC_ERR_INVALID_ARGUMENT, "tenant-id "
"of %s is invalid", tenant_id_node->val);
goto bad_mapping;
uint32_t tenant_id = 0;
- if (ByteExtractStringUint32(&tenant_id, 10, strlen(tenant_id_node->val),
- tenant_id_node->val) == -1)
+ if (StringParseUint32(&tenant_id, 10, strlen(tenant_id_node->val),
+ tenant_id_node->val) < 0)
{
SCLogError(SC_ERR_INVALID_ARGUMENT, "tenant-id "
"of %s is invalid", tenant_id_node->val);
}
uint16_t vlan_id = 0;
- if (ByteExtractStringUint16(&vlan_id, 10, strlen(vlan_id_node->val),
- vlan_id_node->val) == -1)
+ if (StringParseUint16(&vlan_id, 10, strlen(vlan_id_node->val),
+ vlan_id_node->val) < 0)
{
SCLogError(SC_ERR_INVALID_ARGUMENT, "vlan-id "
"of %s is invalid", vlan_id_node->val);
}
uint32_t tenant_id = 0;
- if (ByteExtractStringUint32(&tenant_id, 10, strlen(id_node->val),
- id_node->val) == -1)
+ if (StringParseUint32(&tenant_id, 10, strlen(id_node->val),
+ id_node->val) < 0)
{
SCLogError(SC_ERR_INVALID_ARGUMENT, "tenant_id "
"of %s is invalid", id_node->val);
}
}
- if (ByteExtractStringUint16(&fragoff->frag_off, 10, 0, substr[1]) < 0) {
+ if (StringParseUint16(&fragoff->frag_off, 10, 0, substr[1]) < 0) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "specified frag offset %s is not "
"valid", substr[1]);
goto error;
}
}
- /** \todo can ByteExtractStringUint16 do this? */
uint16_t id = 0;
- if (ByteExtractStringUint16(&id, 10, 0, substr[1]) < 0) {
+ if (StringParseUint16(&id, 10, 0, substr[1]) < 0) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "specified icmp id %s is not "
"valid", substr[1]);
goto error;
}
uint16_t seq = 0;
- if (ByteExtractStringUint16(&seq, 10, 0, substr[1]) < 0) {
+ if (StringParseUint16(&seq, 10, 0, substr[1]) < 0) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "specified icmp seq %s is not "
"valid", substr[1]);
goto error;
goto error;
}
/* we have only a comparison ("<", ">") */
- if (ByteExtractStringUint8(&icd->code1, 10, 0, args[1]) < 0) {
+ if (StringParseUint8(&icd->code1, 10, 0, args[1]) < 0) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "specified icmp code %s is not "
"valid", args[1]);
goto error;
/* we have a range ("<>") */
if (args[2] != NULL) {
icd->mode = (uint8_t) DETECT_ICODE_RN;
- if (ByteExtractStringUint8(&icd->code1, 10, 0, args[1]) < 0) {
+ if (StringParseUint8(&icd->code1, 10, 0, args[1]) < 0) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "specified icmp code %s is not "
"valid", args[1]);
goto error;
}
- if (ByteExtractStringUint8(&icd->code2, 10, 0, args[2]) < 0) {
+ if (StringParseUint8(&icd->code2, 10, 0, args[2]) < 0) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "specified icmp code %s is not "
"valid", args[2]);
goto error;
}
} else { /* we have an equality */
icd->mode = DETECT_ICODE_EQ;
- if (ByteExtractStringUint8(&icd->code1, 10, 0, args[1]) < 0) {
+ if (StringParseUint8(&icd->code1, 10, 0, args[1]) < 0) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "specified icmp code %s is not "
"valid", args[1]);
goto error;
data->proto = (uint8_t)pent->p_proto;
}
else {
- if (ByteExtractStringUint8(&data->proto, 10, 0, args[1]) <= 0) {
+ if (StringParseUint8(&data->proto, 10, 0, args[1]) <= 0) {
SCLogError(SC_ERR_INVALID_VALUE, "Malformed protocol number: %s",
str_ptr);
goto error;
if (*offset == NULL)
goto error;
} else {
- if (ByteExtractStringUint16(&idad->dataat, 10,
+ if (StringParseUint16(&idad->dataat, 10,
strlen(args[0]), args[0]) < 0 ) {
SCLogError(SC_ERR_INVALID_VALUE, "isdataat out of range");
SCFree(idad);
goto error;
}
/* we have only a comparison ("<", ">") */
- if (ByteExtractStringUint8(&itd->type1, 10, 0, args[1]) < 0) {
+ if (StringParseUint8(&itd->type1, 10, 0, args[1]) < 0) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "specified icmp type %s is not "
"valid", args[1]);
goto error;
/* we have a range ("<>") */
if (args[2] != NULL) {
itd->mode = (uint8_t) DETECT_ITYPE_RN;
- if (ByteExtractStringUint8(&itd->type1, 10, 0, args[1]) < 0) {
+ if (StringParseUint8(&itd->type1, 10, 0, args[1]) < 0) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "specified icmp type %s is not "
"valid", args[1]);
goto error;
}
- if (ByteExtractStringUint8(&itd->type2, 10, 0, args[2]) < 0) {
+ if (StringParseUint8(&itd->type2, 10, 0, args[2]) < 0) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "specified icmp type %s is not "
"valid", args[2]);
goto error;
}
} else { /* we have an equality */
itd->mode = DETECT_ITYPE_EQ;
- if (ByteExtractStringUint8(&itd->type1, 10, 0, args[1]) < 0) {
+ if (StringParseUint8(&itd->type1, 10, 0, args[1]) < 0) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "specified icmp type %s is not "
"valid", args[1]);
goto error;
cd->offset = ((DetectByteExtractData *)bed_sm->ctx)->local_id;
cd->flags |= DETECT_CONTENT_OFFSET_BE;
} else {
- if (ByteExtractStringUint16(&cd->offset, 0, 0, str) != (int)strlen(str))
+ if (StringParseUint16(&cd->offset, 0, 0, str) < 0)
{
SCLogError(SC_ERR_INVALID_SIGNATURE, "invalid value for offset: %s.", str);
goto end;
if (args[i]) {
switch (i) {
case 0:
- if (ByteExtractStringUint32(&rd->program, 10, strlen(args[i]), args[i]) <= 0) {
+ if (StringParseUint32(&rd->program, 10, strlen(args[i]), args[i]) <= 0) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid size specified for the rpc program:\"%s\"", args[i]);
goto error;
}
break;
case 1:
if (args[i][0] != '*') {
- if (ByteExtractStringUint32(&rd->program_version, 10, strlen(args[i]), args[i]) <= 0) {
+ if (StringParseUint32(&rd->program_version, 10, strlen(args[i]), args[i]) <= 0) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid size specified for the rpc version:\"%s\"", args[i]);
goto error;
}
break;
case 2:
if (args[i][0] != '*') {
- if (ByteExtractStringUint32(&rd->procedure, 10, strlen(args[i]), args[i]) <= 0) {
+ if (StringParseUint32(&rd->procedure, 10, strlen(args[i]), args[i]) <= 0) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid size specified for the rpc procedure:\"%s\"", args[i]);
goto error;
}
}
/* count */
- if (ByteExtractStringUint32(&td.count, 10, strlen(str_ptr),
+ if (StringParseUint32(&td.count, 10, strlen(str_ptr),
str_ptr) <= 0) {
SCLogError(SC_ERR_INVALID_VALUE, "Invalid argument for count. Must be a value in the range of 0 to %"PRIu32" (%s)", UINT32_MAX, tagstr);
goto error;
sm->type = DETECT_ACK;
- if (-1 == ByteExtractStringUint32(&data->ack, 10, 0, optstr)) {
+ if (StringParseUint32(&data->ack, 10, 0, optstr) < 0) {
goto error;
}
sm->ctx = (SigMatchCtx*)data;
sm->type = DETECT_SEQ;
- if (-1 == ByteExtractStringUint32(&data->seq, 10, 0, optstr)) {
+ if (StringParseUint32(&data->seq, 10, 0, optstr) < 0) {
goto error;
}
sm->ctx = (SigMatchCtx*)data;
/* Get the window size if it's a valid value (in packets, we
* should alert if this doesn't happend from decode) */
- if (-1 == ByteExtractStringUint16(&wd->size, 10, 0, copy_str)) {
+ if (StringParseUint16(&wd->size, 10, 0, copy_str) < 0) {
goto error;
}
}
goto error;
}
- if (ByteExtractStringUint32(&de->count, 10, strlen(args[count_pos]),
+ if (StringParseUint32(&de->count, 10, strlen(args[count_pos]),
args[count_pos]) <= 0) {
goto error;
}
- if (ByteExtractStringUint32(&de->seconds, 10, strlen(args[second_pos]),
+ if (StringParseUint32(&de->seconds, 10, strlen(args[second_pos]),
args[second_pos]) <= 0) {
goto error;
}
int64_t tos = 0;
if (tosbytes_str[0] == 'x' || tosbytes_str[0] == 'X') {
- int r = ByteExtractStringInt64(&tos, 16, 0, &tosbytes_str[1]);
- if (r < 0) {
+ if (StringParseInt64(&tos, 16, 0, &tosbytes_str[1]) < 0) {
goto error;
}
} else {
- int r = ByteExtractStringInt64(&tos, 10, 0, &tosbytes_str[0]);
- if (r < 0) {
+ if (StringParseInt64(&tos, 10, 0, &tosbytes_str[0]) < 0) {
goto error;
}
}
}
/** set the first urilen value */
- if (ByteExtractStringUint16(&urilend->urilen1,10,strlen(arg2),arg2) <= 0){
+ if (StringParseUint16(&urilend->urilen1,10,strlen(arg2),arg2) <= 0){
SCLogError(SC_ERR_INVALID_ARGUMENT,"Invalid size :\"%s\"",arg2);
goto error;
}
goto error;
}
- if(ByteExtractStringUint16(&urilend->urilen2,10,strlen(arg4),arg4) <= 0)
+ if(StringParseUint16(&urilend->urilen2,10,strlen(arg4),arg4) <= 0)
{
SCLogError(SC_ERR_INVALID_ARGUMENT,"Invalid size :\"%s\"",arg4);
goto error;
cd->within = ((DetectByteExtractData *)bed_sm->ctx)->local_id;
cd->flags |= DETECT_CONTENT_WITHIN_BE;
} else {
- if (ByteExtractStringInt32(&cd->within, 0, 0, str) != (int)strlen(str)) {
+ if (StringParseInt32(&cd->within, 0, 0, str) < 0) {
SCLogError(SC_ERR_INVALID_SIGNATURE,
"invalid value for within: %s", str);
goto end;
exit(EXIT_FAILURE);
}
- if (ByteExtractStringUint32(&configval, 10, strlen(conf_val),
+ if (StringParseUint32(&configval, 10, strlen(conf_val),
conf_val) > 0) {
flow_config.hash_size = configval;
}
exit(EXIT_FAILURE);
}
- if (ByteExtractStringUint32(&configval, 10, strlen(conf_val),
+ if (StringParseUint32(&configval, 10, strlen(conf_val),
conf_val) > 0) {
flow_config.prealloc = configval;
}
"emergency-bypassed");
if (new != NULL &&
- ByteExtractStringUint32(&configval, 10, strlen(new), new) > 0) {
+ StringParseUint32(&configval, 10, strlen(new), new) > 0) {
flow_timeouts_normal[FLOW_PROTO_DEFAULT].new_timeout = configval;
}
if (established != NULL &&
- ByteExtractStringUint32(&configval, 10, strlen(established),
+ StringParseUint32(&configval, 10, strlen(established),
established) > 0) {
flow_timeouts_normal[FLOW_PROTO_DEFAULT].est_timeout = configval;
}
if (closed != NULL &&
- ByteExtractStringUint32(&configval, 10, strlen(closed),
+ StringParseUint32(&configval, 10, strlen(closed),
closed) > 0) {
flow_timeouts_normal[FLOW_PROTO_DEFAULT].closed_timeout = configval;
}
if (bypassed != NULL &&
- ByteExtractStringUint32(&configval, 10,
+ StringParseUint32(&configval, 10,
strlen(bypassed),
bypassed) > 0) {
flow_timeouts_normal[FLOW_PROTO_DEFAULT].bypassed_timeout = configval;
}
if (emergency_new != NULL &&
- ByteExtractStringUint32(&configval, 10, strlen(emergency_new),
+ StringParseUint32(&configval, 10, strlen(emergency_new),
emergency_new) > 0) {
flow_timeouts_emerg[FLOW_PROTO_DEFAULT].new_timeout = configval;
}
if (emergency_established != NULL &&
- ByteExtractStringUint32(&configval, 10,
+ StringParseUint32(&configval, 10,
strlen(emergency_established),
emergency_established) > 0) {
flow_timeouts_emerg[FLOW_PROTO_DEFAULT].est_timeout= configval;
}
if (emergency_closed != NULL &&
- ByteExtractStringUint32(&configval, 10,
+ StringParseUint32(&configval, 10,
strlen(emergency_closed),
emergency_closed) > 0) {
flow_timeouts_emerg[FLOW_PROTO_DEFAULT].closed_timeout = configval;
}
if (emergency_bypassed != NULL &&
- ByteExtractStringUint32(&configval, 10,
+ StringParseUint32(&configval, 10,
strlen(emergency_bypassed),
emergency_bypassed) > 0) {
"emergency-bypassed");
if (new != NULL &&
- ByteExtractStringUint32(&configval, 10, strlen(new), new) > 0) {
+ StringParseUint32(&configval, 10, strlen(new), new) > 0) {
flow_timeouts_normal[FLOW_PROTO_TCP].new_timeout = configval;
}
if (established != NULL &&
- ByteExtractStringUint32(&configval, 10, strlen(established),
+ StringParseUint32(&configval, 10, strlen(established),
established) > 0) {
flow_timeouts_normal[FLOW_PROTO_TCP].est_timeout = configval;
}
if (closed != NULL &&
- ByteExtractStringUint32(&configval, 10, strlen(closed),
+ StringParseUint32(&configval, 10, strlen(closed),
closed) > 0) {
flow_timeouts_normal[FLOW_PROTO_TCP].closed_timeout = configval;
}
if (bypassed != NULL &&
- ByteExtractStringUint32(&configval, 10,
+ StringParseUint32(&configval, 10,
strlen(bypassed),
bypassed) > 0) {
flow_timeouts_normal[FLOW_PROTO_TCP].bypassed_timeout = configval;
}
if (emergency_new != NULL &&
- ByteExtractStringUint32(&configval, 10, strlen(emergency_new),
+ StringParseUint32(&configval, 10, strlen(emergency_new),
emergency_new) > 0) {
flow_timeouts_emerg[FLOW_PROTO_TCP].new_timeout = configval;
}
if (emergency_established != NULL &&
- ByteExtractStringUint32(&configval, 10,
+ StringParseUint32(&configval, 10,
strlen(emergency_established),
emergency_established) > 0) {
flow_timeouts_emerg[FLOW_PROTO_TCP].est_timeout = configval;
}
if (emergency_closed != NULL &&
- ByteExtractStringUint32(&configval, 10,
+ StringParseUint32(&configval, 10,
strlen(emergency_closed),
emergency_closed) > 0) {
flow_timeouts_emerg[FLOW_PROTO_TCP].closed_timeout = configval;
}
if (emergency_bypassed != NULL &&
- ByteExtractStringUint32(&configval, 10,
+ StringParseUint32(&configval, 10,
strlen(emergency_bypassed),
emergency_bypassed) > 0) {
"emergency-bypassed");
if (new != NULL &&
- ByteExtractStringUint32(&configval, 10, strlen(new), new) > 0) {
+ StringParseUint32(&configval, 10, strlen(new), new) > 0) {
flow_timeouts_normal[FLOW_PROTO_UDP].new_timeout = configval;
}
if (established != NULL &&
- ByteExtractStringUint32(&configval, 10, strlen(established),
+ StringParseUint32(&configval, 10, strlen(established),
established) > 0) {
flow_timeouts_normal[FLOW_PROTO_UDP].est_timeout = configval;
}
if (bypassed != NULL &&
- ByteExtractStringUint32(&configval, 10,
+ StringParseUint32(&configval, 10,
strlen(bypassed),
bypassed) > 0) {
flow_timeouts_normal[FLOW_PROTO_UDP].bypassed_timeout = configval;
}
if (emergency_new != NULL &&
- ByteExtractStringUint32(&configval, 10, strlen(emergency_new),
+ StringParseUint32(&configval, 10, strlen(emergency_new),
emergency_new) > 0) {
flow_timeouts_emerg[FLOW_PROTO_UDP].new_timeout = configval;
}
if (emergency_established != NULL &&
- ByteExtractStringUint32(&configval, 10,
+ StringParseUint32(&configval, 10,
strlen(emergency_established),
emergency_established) > 0) {
flow_timeouts_emerg[FLOW_PROTO_UDP].est_timeout = configval;
}
if (emergency_bypassed != NULL &&
- ByteExtractStringUint32(&configval, 10,
+ StringParseUint32(&configval, 10,
strlen(emergency_bypassed),
emergency_bypassed) > 0) {
"emergency-bypassed");
if (new != NULL &&
- ByteExtractStringUint32(&configval, 10, strlen(new), new) > 0) {
+ StringParseUint32(&configval, 10, strlen(new), new) > 0) {
flow_timeouts_normal[FLOW_PROTO_ICMP].new_timeout = configval;
}
if (established != NULL &&
- ByteExtractStringUint32(&configval, 10, strlen(established),
+ StringParseUint32(&configval, 10, strlen(established),
established) > 0) {
flow_timeouts_normal[FLOW_PROTO_ICMP].est_timeout = configval;
}
if (bypassed != NULL &&
- ByteExtractStringUint32(&configval, 10,
+ StringParseUint32(&configval, 10,
strlen(bypassed),
bypassed) > 0) {
flow_timeouts_normal[FLOW_PROTO_ICMP].bypassed_timeout = configval;
}
if (emergency_new != NULL &&
- ByteExtractStringUint32(&configval, 10, strlen(emergency_new),
+ StringParseUint32(&configval, 10, strlen(emergency_new),
emergency_new) > 0) {
flow_timeouts_emerg[FLOW_PROTO_ICMP].new_timeout = configval;
}
if (emergency_established != NULL &&
- ByteExtractStringUint32(&configval, 10,
+ StringParseUint32(&configval, 10,
strlen(emergency_established),
emergency_established) > 0) {
flow_timeouts_emerg[FLOW_PROTO_ICMP].est_timeout = configval;
}
if (emergency_bypassed != NULL &&
- ByteExtractStringUint32(&configval, 10,
+ StringParseUint32(&configval, 10,
strlen(emergency_bypassed),
emergency_bypassed) > 0) {
}
if ((ConfGetValue("host.hash-size", &conf_val)) == 1)
{
- if (ByteExtractStringUint32(&configval, 10, strlen(conf_val),
+ if (StringParseUint32(&configval, 10, strlen(conf_val),
conf_val) > 0) {
host_config.hash_size = configval;
}
if ((ConfGetValue("host.prealloc", &conf_val)) == 1)
{
- if (ByteExtractStringUint32(&configval, 10, strlen(conf_val),
+ if (StringParseUint32(&configval, 10, strlen(conf_val),
conf_val) > 0) {
host_config.prealloc = configval;
} else {
}
if ((ConfGet("ippair.hash-size", &conf_val)) == 1)
{
- if (ByteExtractStringUint32(&configval, 10, strlen(conf_val),
+ if (StringParseUint32(&configval, 10, strlen(conf_val),
conf_val) > 0) {
ippair_config.hash_size = configval;
}
if ((ConfGet("ippair.prealloc", &conf_val)) == 1)
{
- if (ByteExtractStringUint32(&configval, 10, strlen(conf_val),
+ if (StringParseUint32(&configval, 10, strlen(conf_val),
conf_val) > 0) {
ippair_config.prealloc = configval;
} else {
1, buf, sizeof(buf)) < 0) {
return 0;
}
- if (ByteExtractStringUint64(secs, 10, 0, buf) < 0) {
+ if (StringParseUint64(secs, 10, 0, buf) < 0) {
return 0;
}
}
3, buf, sizeof(buf)) < 0) {
return 0;
}
- if (ByteExtractStringUint32(usecs, 10, 0, buf) < 0) {
+ if (StringParseUint32(usecs, 10, 0, buf) < 0) {
return 0;
}
}
const char *max_number_of_files_s = NULL;
max_number_of_files_s = ConfNodeLookupChildValue(conf, "max-files");
if (max_number_of_files_s != NULL) {
- if (ByteExtractStringUint32(&max_file_limit, 10, 0,
+ if (StringParseUint32(&max_file_limit, 10, 0,
max_number_of_files_s) == -1) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "Failed to initialize "
"pcap-log output, invalid number of files limit: %s",
const char *sensor_id_s = ConfNodeLookupChildValue(conf, "sensor-id");
if (sensor_id_s != NULL) {
- if (ByteExtractStringUint64((uint64_t *)&sensor_id, 10, 0, sensor_id_s) == -1) {
+ if (StringParseUint64((uint64_t *)&sensor_id, 10, 0, sensor_id_s) < 0) {
SCLogError(SC_ERR_INVALID_ARGUMENT,
"Failed to initialize JSON output, "
"invalid sensor-id: %s", sensor_id_s);
}
const char *cid_seed = ConfNodeLookupChildValue(conf, "community-id-seed");
if (cid_seed != NULL) {
- if (ByteExtractStringUint16(&json_ctx->cfg.community_id_seed,
- 10, 0, cid_seed) == -1)
+ if (StringParseUint16(&json_ctx->cfg.community_id_seed,
+ 10, 0, cid_seed) < 0)
{
SCLogError(SC_ERR_INVALID_ARGUMENT,
"Failed to initialize JSON output, "
IPFWQueueVars *nq = NULL;
/* Extract the queue number from the specified command line argument */
uint16_t port_num = 0;
- if ((ByteExtractStringUint16(&port_num, 10, strlen(queue), queue)) < 0)
+ if ((StringParseUint16(&port_num, 10, strlen(queue), queue)) < 0)
{
SCLogError(SC_ERR_INVALID_ARGUMENT, "specified queue number %s is not "
"valid", queue);
ConfNode *seg = ConfGetNode("stream.reassembly.segment-prealloc");
if (seg) {
uint32_t prealloc = 0;
- if (ByteExtractStringUint32(&prealloc, 10, strlen(seg->val), seg->val) == -1)
+ if (StringParseUint32(&prealloc, 10, strlen(seg->val), seg->val) < 0)
{
SCLogError(SC_ERR_INVALID_ARGUMENT, "segment-prealloc of "
"%s is invalid", seg->val);
const char *custom_umask;
if (ConfGet("umask", &custom_umask) == 1) {
uint16_t mask;
- if (ByteExtractStringUint16(&mask, 8, strlen(custom_umask),
+ if (StringParseUint16(&mask, 8, strlen(custom_umask),
custom_umask) > 0) {
umask((mode_t)mask);
}
*res = (uint32_t)i64;
if ((uint64_t)(*res) != i64) {
- SCLogError("Numeric value out of range (%" PRIu64 " > %" PRIuMAX ")",
- i64, (uintmax_t)UINT_MAX);
+ SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
+ "(%" PRIu64 " > %" PRIuMAX ")", i64, (uintmax_t)UINT_MAX);
return -1;
}
*res = (uint16_t)i64;
if ((uint64_t)(*res) != i64) {
- SCLogError("Numeric value out of range (%" PRIu64 " > %" PRIuMAX ")",
- i64, (uintmax_t)USHRT_MAX);
+ SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
+ "(%" PRIu64 " > %" PRIuMAX ")", i64, (uintmax_t)USHRT_MAX);
return -1;
}
*res = (uint8_t)i64;
if ((uint64_t)(*res) != i64) {
- SCLogError("Numeric value out of range (%" PRIu64 " > %" PRIuMAX ")",
- i64, (uintmax_t)UCHAR_MAX);
+ SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range "
+ "(%" PRIu64 " > %" PRIuMAX ")", i64, (uintmax_t)UCHAR_MAX);
return -1;
}
const char *filemode = ConfNodeLookupChildValue(conf, "filemode");
uint32_t mode = 0;
if (filemode != NULL &&
- ByteExtractStringUint32(&mode, 8, strlen(filemode),
+ StringParseUint32(&mode, 8, strlen(filemode),
filemode) > 0) {
log_ctx->filemode = mode;
}
val = ConfNodeLookupChildValue(conf, "limit");
if (val != NULL) {
- if (ByteExtractStringUint32(&profiling_rules_limit, 10,
+ if (StringParseUint32(&profiling_rules_limit, 10,
(uint16_t)strlen(val), val) <= 0) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid limit: %s", val);
exit(EXIT_FAILURE);
GET_VAR(cnf_prefix, "hash-size");
if ((ConfGet(varname, &conf_val)) == 1)
{
- if (ByteExtractStringUint32(&configval, 10, strlen(conf_val),
+ if (StringParseUint32(&configval, 10, strlen(conf_val),
conf_val) > 0) {
ctx->config.hash_size = configval;
}
GET_VAR(cnf_prefix, "prealloc");
if ((ConfGet(varname, &conf_val)) == 1)
{
- if (ByteExtractStringUint32(&configval, 10, strlen(conf_val),
+ if (StringParseUint32(&configval, 10, strlen(conf_val),
conf_val) > 0) {
ctx->config.prealloc = configval;
} else {
/* TODO: implement option "apply_to" */
- if (ByteExtractStringUint32(&parsed_timeout, 10, strlen(th_timeout), th_timeout) <= 0) {
+ if (StringParseUint32(&parsed_timeout, 10, strlen(th_timeout), th_timeout) <= 0) {
goto error;
}
goto error;
}
- if (ByteExtractStringUint32(&parsed_count, 10, strlen(th_count), th_count) <= 0) {
+ if (StringParseUint32(&parsed_count, 10, strlen(th_count), th_count) <= 0) {
goto error;
}
if (parsed_count == 0) {
goto error;
}
- if (ByteExtractStringUint32(&parsed_seconds, 10, strlen(th_seconds), th_seconds) <= 0) {
+ if (StringParseUint32(&parsed_seconds, 10, strlen(th_seconds), th_seconds) <= 0) {
goto error;
}
break;
}
- if (ByteExtractStringUint32(&id, 10, strlen(th_sid), th_sid) <= 0) {
+ if (StringParseUint32(&id, 10, strlen(th_sid), th_sid) <= 0) {
goto error;
}
- if (ByteExtractStringUint32(&gid, 10, strlen(th_gid), th_gid) <= 0) {
+ if (StringParseUint32(&gid, 10, strlen(th_gid), th_gid) <= 0) {
goto error;
}