version 1.4.4.3, 2012/03/27 22:31:37
|
version 1.4.4.4, 2012/03/27 23:06:37
|
Line 60 io_vars2buffer(u_char *buf, int buflen, array_t *vars)
|
Line 60 io_vars2buffer(u_char *buf, int buflen, array_t *vars)
|
int Limit = 0; |
int Limit = 0; |
register int i; |
register int i; |
ait_val_t *v, *val; |
ait_val_t *v, *val; |
u_char *data; | u_char *dat; |
|
|
assert(buf); |
assert(buf); |
assert(vars); |
assert(vars); |
Line 78 io_vars2buffer(u_char *buf, int buflen, array_t *vars)
|
Line 78 io_vars2buffer(u_char *buf, int buflen, array_t *vars)
|
memset(buf, 0, buflen); |
memset(buf, 0, buflen); |
|
|
v = (ait_val_t*) buf; |
v = (ait_val_t*) buf; |
data = buf + Limit; | dat = buf + Limit; |
} |
} |
|
|
/* marshaling */ |
/* marshaling */ |
Line 103 io_vars2buffer(u_char *buf, int buflen, array_t *vars)
|
Line 103 io_vars2buffer(u_char *buf, int buflen, array_t *vars)
|
case u64: |
case u64: |
v[i].val.net = htobe64(val->val.net); |
v[i].val.net = htobe64(val->val.net); |
break; |
break; |
|
case data: |
|
if (AIT_LEN(val) > buflen - Limit) { |
|
io_SetErr(EMSGSIZE, "Error:: too short buffer buflen=%d " |
|
"needed min %d ...\n", buflen, Limit + AIT_LEN(val)); |
|
return -1; |
|
} else |
|
Limit += AIT_LEN(val); |
|
|
|
memcpy(dat, val->val_data, AIT_LEN(val)); |
|
/* Debug:: data offset in packet, not matter for anything! */ |
|
v[i].val.net = dat - buf; |
|
dat += AIT_LEN(val); |
|
break; |
case buffer: |
case buffer: |
case string: |
case string: |
if (AIT_LEN(val) > buflen - Limit) { |
if (AIT_LEN(val) > buflen - Limit) { |
Line 112 io_vars2buffer(u_char *buf, int buflen, array_t *vars)
|
Line 125 io_vars2buffer(u_char *buf, int buflen, array_t *vars)
|
} else |
} else |
Limit += AIT_LEN(val); |
Limit += AIT_LEN(val); |
|
|
memcpy(data, val->val.buffer, AIT_LEN(val)); | memcpy(dat, val->val.buffer, AIT_LEN(val)); |
/* Debug:: data offset in packet, not matter for anything! */ |
/* Debug:: data offset in packet, not matter for anything! */ |
v[i].val.net = data - buf; | v[i].val.net = dat - buf; |
data += AIT_LEN(val); | dat += AIT_LEN(val); |
break; |
break; |
default: |
default: |
io_SetErr(EINVAL, "Error:: unsupported variable type=%d at element #%d ...\n", |
io_SetErr(EINVAL, "Error:: unsupported variable type=%d at element #%d ...\n", |
Line 144 io_buffer2vars(u_char *buf, int buflen, int vnum, int
|
Line 157 io_buffer2vars(u_char *buf, int buflen, int vnum, int
|
int Limit = 0; |
int Limit = 0; |
register int i; |
register int i; |
ait_val_t *v, *val; |
ait_val_t *v, *val; |
u_char *data; | u_char *dat; |
|
|
assert(buf); |
assert(buf); |
if (!buf || !buflen || !vnum) |
if (!buf || !buflen || !vnum) |
Line 160 io_buffer2vars(u_char *buf, int buflen, int vnum, int
|
Line 173 io_buffer2vars(u_char *buf, int buflen, int vnum, int
|
return NULL; |
return NULL; |
|
|
v = (ait_val_t*) buf; |
v = (ait_val_t*) buf; |
data = buf + Limit; | dat = buf + Limit; |
} |
} |
|
|
/* de-marshaling */ |
/* de-marshaling */ |
Line 204 io_buffer2vars(u_char *buf, int buflen, int vnum, int
|
Line 217 io_buffer2vars(u_char *buf, int buflen, int vnum, int
|
val->val.net = be64toh(v[i].val.net); |
val->val.net = be64toh(v[i].val.net); |
#endif |
#endif |
break; |
break; |
|
case data: |
|
/* WARNING:: remap data type to buffer */ |
|
val->val_type = buffer; |
case buffer: |
case buffer: |
case string: |
case string: |
if (AIT_LEN(val) > buflen - Limit) { |
if (AIT_LEN(val) > buflen - Limit) { |
Line 224 io_buffer2vars(u_char *buf, int buflen, int vnum, int
|
Line 240 io_buffer2vars(u_char *buf, int buflen, int vnum, int
|
io_arrayDestroy(&vars); |
io_arrayDestroy(&vars); |
return NULL; |
return NULL; |
} else |
} else |
memcpy(val->val.buffer, data, AIT_LEN(val)); | memcpy(val->val.buffer, dat, AIT_LEN(val)); |
} else |
} else |
val->val.buffer = data; | val->val.buffer = dat; |
data += AIT_LEN(val); | dat += AIT_LEN(val); |
break; |
break; |
default: |
default: |
io_SetErr(EINVAL, "Error:: unsupported variable type=%d at element #%d ...\n", |
io_SetErr(EINVAL, "Error:: unsupported variable type=%d at element #%d ...\n", |
Line 258 io_vars2map(u_char *buf, int buflen, array_t *vars)
|
Line 274 io_vars2map(u_char *buf, int buflen, array_t *vars)
|
int Limit = 0; |
int Limit = 0; |
register int i; |
register int i; |
ait_val_t *v, *val; |
ait_val_t *v, *val; |
u_char *data; | u_char *dat; |
|
|
assert(buf); |
assert(buf); |
assert(vars); |
assert(vars); |
Line 276 io_vars2map(u_char *buf, int buflen, array_t *vars)
|
Line 292 io_vars2map(u_char *buf, int buflen, array_t *vars)
|
memset(buf, 0, buflen); |
memset(buf, 0, buflen); |
|
|
v = (ait_val_t*) buf; |
v = (ait_val_t*) buf; |
data = buf + Limit; | dat = buf + Limit; |
} |
} |
|
|
/* marshaling */ |
/* marshaling */ |
Line 301 io_vars2map(u_char *buf, int buflen, array_t *vars)
|
Line 317 io_vars2map(u_char *buf, int buflen, array_t *vars)
|
case u64: |
case u64: |
v[i].val.net = val->val.net; |
v[i].val.net = val->val.net; |
break; |
break; |
|
case data: |
|
if (AIT_LEN(val) > buflen - Limit) { |
|
io_SetErr(EMSGSIZE, "Error:: too short buffer buflen=%d " |
|
"needed min %d ...\n", buflen, Limit + AIT_LEN(val)); |
|
return -1; |
|
} else |
|
Limit += AIT_LEN(val); |
|
|
|
memcpy(dat, val->val_data, AIT_LEN(val)); |
|
/* Debug:: data offset in packet, not matter for anything! */ |
|
v[i].val.net = dat - buf; |
|
dat += AIT_LEN(val); |
|
break; |
case buffer: |
case buffer: |
case string: |
case string: |
if (AIT_LEN(val) > buflen - Limit) { |
if (AIT_LEN(val) > buflen - Limit) { |
Line 310 io_vars2map(u_char *buf, int buflen, array_t *vars)
|
Line 339 io_vars2map(u_char *buf, int buflen, array_t *vars)
|
} else |
} else |
Limit += AIT_LEN(val); |
Limit += AIT_LEN(val); |
|
|
memcpy(data, val->val.buffer, AIT_LEN(val)); | memcpy(dat, val->val.buffer, AIT_LEN(val)); |
/* Debug:: data offset in packet, not matter for anything! */ |
/* Debug:: data offset in packet, not matter for anything! */ |
v[i].val.net = data - buf; | v[i].val.net = dat - buf; |
data += AIT_LEN(val); | dat += AIT_LEN(val); |
break; |
break; |
default: |
default: |
io_SetErr(EINVAL, "Error:: unsupported variable type=%d at element #%d ...\n", |
io_SetErr(EINVAL, "Error:: unsupported variable type=%d at element #%d ...\n", |
Line 342 io_map2vars(u_char *buf, int buflen, int vnum, int zcp
|
Line 371 io_map2vars(u_char *buf, int buflen, int vnum, int zcp
|
int Limit = 0; |
int Limit = 0; |
register int i; |
register int i; |
ait_val_t *v, *val; |
ait_val_t *v, *val; |
u_char *data; | u_char *dat; |
|
|
assert(buf); |
assert(buf); |
if (!buf || !buflen || !vnum) |
if (!buf || !buflen || !vnum) |
Line 358 io_map2vars(u_char *buf, int buflen, int vnum, int zcp
|
Line 387 io_map2vars(u_char *buf, int buflen, int vnum, int zcp
|
return NULL; |
return NULL; |
|
|
v = (ait_val_t*) buf; |
v = (ait_val_t*) buf; |
data = buf + Limit; | dat = buf + Limit; |
} |
} |
|
|
/* de-marshaling */ |
/* de-marshaling */ |
Line 393 io_map2vars(u_char *buf, int buflen, int vnum, int zcp
|
Line 422 io_map2vars(u_char *buf, int buflen, int vnum, int zcp
|
case u64: |
case u64: |
val->val.net = v[i].val.net; |
val->val.net = v[i].val.net; |
break; |
break; |
|
case data: |
|
/* WARNING:: remap data type to buffer */ |
|
val->val_type = buffer; |
case buffer: |
case buffer: |
case string: |
case string: |
if (AIT_LEN(val) > buflen - Limit) { |
if (AIT_LEN(val) > buflen - Limit) { |
Line 413 io_map2vars(u_char *buf, int buflen, int vnum, int zcp
|
Line 445 io_map2vars(u_char *buf, int buflen, int vnum, int zcp
|
io_arrayDestroy(&vars); |
io_arrayDestroy(&vars); |
return NULL; |
return NULL; |
} else |
} else |
memcpy(val->val.buffer, data, AIT_LEN(val)); | memcpy(val->val.buffer, dat, AIT_LEN(val)); |
} else |
} else |
val->val.buffer = data; | val->val.buffer = dat; |
data += AIT_LEN(val); | dat += AIT_LEN(val); |
break; |
break; |
default: |
default: |
io_SetErr(EINVAL, "Error:: unsupported variable type=%d at element #%d ...\n", |
io_SetErr(EINVAL, "Error:: unsupported variable type=%d at element #%d ...\n", |