* Returns NULL on any error.
*/
u_char *
-asn_parse_int(data, datalength, type, intp, intsize)
- u_char *data; /* IN - pointer to start of object */
- int *datalength; /* IN/OUT - number of valid bytes left in buffer */
- u_char *type; /* OUT - asn type of object */
- long *intp; /* IN/OUT - pointer to start of output buffer */
- int intsize; /* IN - size of output buffer */
-{
+asn_parse_int(
+ u_char * data, /* IN - pointer to start of object */
+ int *datalength, /* IN/OUT - number of valid bytes left in buffer */
+ u_char * type, /* OUT - asn type of object */
+ long *intp, /* IN/OUT - pointer to start of output buffer */
+ int intsize)
+{ /* IN - size of output buffer */
/*
* ASN.1 integer ::= 0x02 asnlength byte {byte}*
*/
* Returns NULL on any error.
*/
u_char *
-asn_parse_unsigned_int(data, datalength, type, intp, intsize)
- u_char *data; /* IN - pointer to start of object */
- int *datalength; /* IN/OUT - number of valid bytes left in buffer */
- u_char *type; /* OUT - asn type of object */
- u_long *intp; /* IN/OUT - pointer to start of output buffer */
- int intsize; /* IN - size of output buffer */
-{
+asn_parse_unsigned_int(
+ u_char * data, /* IN - pointer to start of object */
+ int *datalength, /* IN/OUT - number of valid bytes left in buffer */
+ u_char * type, /* OUT - asn type of object */
+ u_long * intp, /* IN/OUT - pointer to start of output buffer */
+ int intsize)
+{ /* IN - size of output buffer */
/*
* ASN.1 integer ::= 0x02 asnlength byte {byte}*
*/
* Returns NULL on any error.
*/
u_char *
-asn_build_int(data, datalength, type, intp, intsize)
- u_char *data; /* IN - pointer to start of output buffer */
- int *datalength; /* IN/OUT - number of valid bytes left in buffer */
- u_char type; /* IN - asn type of object */
- long *intp; /* IN - pointer to start of long integer */
- int intsize; /* IN - size of *intp */
-{
+asn_build_int(
+ u_char * data, /* IN - pointer to start of output buffer */
+ int *datalength, /* IN/OUT - number of valid bytes left in buffer */
+ u_char type, /* IN - asn type of object */
+ long *intp, /* IN - pointer to start of long integer */
+ int intsize)
+{ /* IN - size of *intp */
/*
* ASN.1 integer ::= 0x02 asnlength byte {byte}*
*/
* Returns NULL on any error.
*/
u_char *
-asn_build_unsigned_int(data, datalength, type, intp, intsize)
- u_char *data; /* IN - pointer to start of output buffer */
- int *datalength; /* IN/OUT - number of valid bytes left in buffer */
- u_char type; /* IN - asn type of object */
- u_long *intp; /* IN - pointer to start of long integer */
- int intsize; /* IN - size of *intp */
-{
+asn_build_unsigned_int(
+ u_char * data, /* IN - pointer to start of output buffer */
+ int *datalength, /* IN/OUT - number of valid bytes left in buffer */
+ u_char type, /* IN - asn type of object */
+ u_long * intp, /* IN - pointer to start of long integer */
+ int intsize)
+{ /* IN - size of *intp */
/*
* ASN.1 integer ::= 0x02 asnlength byte {byte}*
*/
* Returns NULL on any error.
*/
u_char *
-asn_parse_string(data, datalength, type, string, strlength)
- u_char *data; /* IN - pointer to start of object */
- int *datalength; /* IN/OUT - number of valid bytes left in buffer */
- u_char *type; /* OUT - asn type of object */
- u_char *string; /* IN/OUT - pointer to start of output buffer */
- int *strlength; /* IN/OUT - size of output buffer */
-{
+asn_parse_string(
+ u_char * data, /* IN - pointer to start of object */
+ int *datalength, /* IN/OUT - number of valid bytes left in buffer */
+ u_char * type, /* OUT - asn type of object */
+ u_char * string, /* IN/OUT - pointer to start of output buffer */
+ int *strlength)
+{ /* IN/OUT - size of output buffer */
/*
* ASN.1 octet string ::= primstring | cmpdstring
* primstring ::= 0x04 asnlength byte {byte}*
ERROR("I don't support such long strings");
return NULL;
}
- bcopy((char *) bufp, (char *) string, (int) asn_length);
+ xmemcpy(string, bufp, (int) asn_length);
*strlength = (int) asn_length;
*datalength -= (int) asn_length + (bufp - data);
return bufp + asn_length;
* Returns NULL on any error.
*/
u_char *
-asn_build_string(data, datalength, type, string, strlength)
- u_char *data; /* IN - pointer to start of object */
- int *datalength; /* IN/OUT - number of valid bytes left in buffer */
- u_char type; /* IN - ASN type of string */
- u_char *string; /* IN - pointer to start of input buffer */
- int strlength; /* IN - size of input buffer */
-{
+asn_build_string(
+ u_char * data, /* IN - pointer to start of object */
+ int *datalength, /* IN/OUT - number of valid bytes left in buffer */
+ u_char type, /* IN - ASN type of string */
+ u_char * string, /* IN - pointer to start of input buffer */
+ int strlength)
+{ /* IN - size of input buffer */
/*
* ASN.1 octet string ::= primstring | cmpdstring
* primstring ::= 0x04 asnlength byte {byte}*
return NULL;
if (*datalength < strlength)
return NULL;
- bcopy((char *) string, (char *) data, strlength);
+ xmemcpy(data, string, strlength);
*datalength -= strlength;
return data + strlength;
}
* Returns NULL on any error.
*/
u_char *
-asn_parse_header(data, datalength, type)
- u_char *data; /* IN - pointer to start of object */
- int *datalength; /* IN/OUT - number of valid bytes left in buffer */
- u_char *type; /* OUT - ASN type of object */
-{
+asn_parse_header(
+ u_char * data, /* IN - pointer to start of object */
+ int *datalength, /* IN/OUT - number of valid bytes left in buffer */
+ u_char * type)
+{ /* OUT - ASN type of object */
u_char *bufp = data;
int header_len;
u_long asn_length;
* Returns NULL on any error.
*/
u_char *
-asn_build_header(data, datalength, type, length)
- u_char *data; /* IN - pointer to start of object */
- int *datalength; /* IN/OUT - number of valid bytes left in buffer */
- u_char type; /* IN - ASN type of object */
- int length; /* IN - length of object */
-{
+asn_build_header(
+ u_char * data, /* IN - pointer to start of object */
+ int *datalength, /* IN/OUT - number of valid bytes left in buffer */
+ u_char type, /* IN - ASN type of object */
+ int length)
+{ /* IN - length of object */
if (*datalength < 1)
return NULL;
*data++ = type;
* Returns NULL on any error.
*/
u_char *
-asn_build_sequence(data, datalength, type, length)
- u_char *data; /* IN - pointer to start of object */
- int *datalength; /* IN/OUT - number of valid bytes left in buffer */
- u_char type; /* IN - ASN type of object */
- int length; /* IN - length of object */
-{
+asn_build_sequence(
+ u_char * data, /* IN - pointer to start of object */
+ int *datalength, /* IN/OUT - number of valid bytes left in buffer */
+ u_char type, /* IN - ASN type of object */
+ int length)
+{ /* IN - length of object */
assert(*datalength >= 0);
*datalength -= 4;
if (*datalength < 0) {
* Returns NULL on any error.
*/
u_char *
-asn_parse_length(data, length)
- u_char *data; /* IN - pointer to start of length field */
- u_long *length; /* OUT - value of length field */
-{
+asn_parse_length(
+ u_char * data, /* IN - pointer to start of length field */
+ u_long * length)
+{ /* OUT - value of length field */
u_char lengthbyte = *data;
*length = 0;
ERROR("we can't support data lengths that long");
return NULL;
}
- bcopy((char *) data + 1, (char *) length, (int) lengthbyte);
+ xmemcpy(length, data + 1, (int) lengthbyte);
/* XXX: is this useable on a 64bit platform ? */
*length = ntohl(*length);
*length >>= (8 * ((sizeof(*length)) - lengthbyte));
}
u_char *
-asn_build_length(data, datalength, length)
- u_char *data; /* IN - pointer to start of object */
- int *datalength; /* IN/OUT - number of valid bytes left in buffer */
- int length; /* IN - length of object */
-{
+asn_build_length(
+ u_char * data, /* IN - pointer to start of object */
+ int *datalength, /* IN/OUT - number of valid bytes left in buffer */
+ int length)
+{ /* IN - length of object */
u_char *start_data = data;
/* no indefinite lengths sent */
* Returns NULL on any error.
*/
u_char *
-asn_parse_objid(data, datalength, type, objid, objidlength)
- u_char *data; /* IN - pointer to start of object */
- int *datalength; /* IN/OUT - number of valid bytes left in buffer */
- u_char *type; /* OUT - ASN type of object */
- oid *objid; /* IN/OUT - pointer to start of output buffer */
- int *objidlength; /* IN/OUT - number of sub-id's in objid */
-{
+asn_parse_objid(
+ u_char * data, /* IN - pointer to start of object */
+ int *datalength, /* IN/OUT - number of valid bytes left in buffer */
+ u_char * type, /* OUT - ASN type of object */
+ oid * objid, /* IN/OUT - pointer to start of output buffer */
+ int *objidlength)
+{ /* IN/OUT - number of sub-id's in objid */
/*
* ASN.1 objid ::= 0x06 asnlength subidentifier {subidentifier}*
* subidentifier ::= {leadingbyte}* lastbyte
* Returns NULL on any error.
*/
u_char *
-asn_build_objid(data, datalength, type, objid, objidlength)
- u_char *data; /* IN - pointer to start of object */
- int *datalength; /* IN/OUT - number of valid bytes left in buffer */
- u_char type; /* IN - ASN type of object */
- oid *objid; /* IN - pointer to start of input buffer */
- int objidlength; /* IN - number of sub-id's in objid */
-{
+asn_build_objid(
+ u_char * data, /* IN - pointer to start of object */
+ int *datalength, /* IN/OUT - number of valid bytes left in buffer */
+ u_char type, /* IN - ASN type of object */
+ oid * objid, /* IN - pointer to start of input buffer */
+ int objidlength)
+{ /* IN - number of sub-id's in objid */
/*
* ASN.1 objid ::= 0x06 asnlength subidentifier {subidentifier}*
* subidentifier ::= {leadingbyte}* lastbyte
return NULL;
if (*datalength < asnlength)
return NULL;
- bcopy((char *) buf, (char *) data, asnlength);
+ xmemcpy(data, buf, asnlength);
*datalength -= asnlength;
return data + asnlength;
}
* Returns NULL on any error.
*/
u_char *
-asn_parse_null(data, datalength, type)
- u_char *data; /* IN - pointer to start of object */
- int *datalength; /* IN/OUT - number of valid bytes left in buffer */
- u_char *type; /* OUT - ASN type of object */
-{
+asn_parse_null(
+ u_char * data, /* IN - pointer to start of object */
+ int *datalength, /* IN/OUT - number of valid bytes left in buffer */
+ u_char * type)
+{ /* OUT - ASN type of object */
/*
* ASN.1 null ::= 0x05 0x00
*/
* Returns NULL on any error.
*/
u_char *
-asn_build_null(data, datalength, type)
- u_char *data; /* IN - pointer to start of object */
- int *datalength; /* IN/OUT - number of valid bytes left in buffer */
- u_char type; /* IN - ASN type of object */
-{
+asn_build_null(
+ u_char * data, /* IN - pointer to start of object */
+ int *datalength, /* IN/OUT - number of valid bytes left in buffer */
+ u_char type)
+{ /* IN - ASN type of object */
/*
* ASN.1 null ::= 0x05 0x00
*/
* Returns NULL on any error.
*/
u_char *
-asn_parse_bitstring(data, datalength, type, string, strlength)
- u_char *data; /* IN - pointer to start of object */
- int *datalength; /* IN/OUT - number of valid bytes left in buffer */
- u_char *type; /* OUT - asn type of object */
- u_char *string; /* IN/OUT - pointer to start of output buffer */
- int *strlength; /* IN/OUT - size of output buffer */
-{
+asn_parse_bitstring(
+ u_char * data, /* IN - pointer to start of object */
+ int *datalength, /* IN/OUT - number of valid bytes left in buffer */
+ u_char * type, /* OUT - asn type of object */
+ u_char * string, /* IN/OUT - pointer to start of output buffer */
+ int *strlength)
+{ /* IN/OUT - size of output buffer */
/*
* bitstring ::= 0x03 asnlength unused {byte}*
*/
ERROR("Invalid bitstring");
return NULL;
}
- bcopy((char *) bufp, (char *) string, (int) asn_length);
+ xmemcpy(string, bufp, (int) asn_length);
*strlength = (int) asn_length;
*datalength -= (int) asn_length + (bufp - data);
return bufp + asn_length;
* Returns NULL on any error.
*/
u_char *
-asn_build_bitstring(data, datalength, type, string, strlength)
- u_char *data; /* IN - pointer to start of object */
- int *datalength; /* IN/OUT - number of valid bytes left in buffer */
- u_char type; /* IN - ASN type of string */
- u_char *string; /* IN - pointer to start of input buffer */
- int strlength; /* IN - size of input buffer */
-{
+asn_build_bitstring(
+ u_char * data, /* IN - pointer to start of object */
+ int *datalength, /* IN/OUT - number of valid bytes left in buffer */
+ u_char type, /* IN - ASN type of string */
+ u_char * string, /* IN - pointer to start of input buffer */
+ int strlength)
+{ /* IN - size of input buffer */
/*
* ASN.1 bit string ::= 0x03 asnlength unused {byte}*
*/
return NULL;
if (*datalength < strlength)
return NULL;
- bcopy((char *) string, (char *) data, strlength);
+ xmemcpy(data, string, strlength);
*datalength -= strlength;
return data + strlength;
}
* Returns NULL on any error.
*/
u_char *
-asn_parse_unsigned_int64(data, datalength, type, cp, countersize)
- u_char *data; /* IN - pointer to start of object */
- int *datalength; /* IN/OUT - number of valid bytes left in buffer */
- u_char *type; /* OUT - asn type of object */
- struct counter64 *cp; /* IN/OUT -pointer to counter struct */
- int countersize; /* IN - size of output buffer */
-{
+asn_parse_unsigned_int64(
+ u_char * data, /* IN - pointer to start of object */
+ int *datalength, /* IN/OUT - number of valid bytes left in buffer */
+ u_char * type, /* OUT - asn type of object */
+ struct counter64 * cp, /* IN/OUT -pointer to counter struct */
+ int countersize)
+{ /* IN - size of output buffer */
/*
* ASN.1 integer ::= 0x02 asnlength byte {byte}*
*/
* Returns NULL on any error.
*/
u_char *
-asn_build_unsigned_int64(data, datalength, type, cp, countersize)
- u_char *data; /* IN - pointer to start of output buffer */
- int *datalength; /* IN/OUT - number of valid bytes left in buffer */
- u_char type; /* IN - asn type of object */
- struct counter64 *cp; /* IN - pointer to counter struct */
- int countersize; /* IN - size of *intp */
-{
+asn_build_unsigned_int64(
+ u_char * data, /* IN - pointer to start of output buffer */
+ int *datalength, /* IN/OUT - number of valid bytes left in buffer */
+ u_char type, /* IN - asn type of object */
+ struct counter64 * cp, /* IN - pointer to counter struct */
+ int countersize)
+{ /* IN - size of *intp */
/*
* ASN.1 integer ::= 0x02 asnlength byte {byte}*
*/
#include "mib.h"
#include "util.h"
+#include "snprintf.h"
/* fwd: */
static void sprint_by_type();
static struct tree *get_symbol();
static char *
-uptimeString(timeticks, buf)
- u_long timeticks;
- char *buf;
+uptimeString(unsigned long timeticks, char *buf)
{
int seconds, minutes, hours, days;
}
static void
-sprint_hexstring(buf, cp, len)
- char *buf;
- u_char *cp;
- int len;
+sprint_hexstring(char *buf, unsigned char *cp, int len)
{
for (; len >= 16; len -= 16) {
}
static void
-sprint_asciistring(buf, cp, len)
- char *buf;
- u_char *cp;
- int len;
+sprint_asciistring(char *buf, unsigned char *cp, int len)
{
int x;
#ifdef UNUSED
int
-read_rawobjid(input, output, out_len)
- char *input;
- oid *output;
- int *out_len;
+read_rawobjid(char *input, oid * output, int *out_len)
{
char buf[12], *cp;
oid *op = output;
*
*/
static void
-sprint_octet_string(buf, var, enums)
- char *buf;
- struct variable_list *var;
- struct enum_list *enums;
+sprint_octet_string(char *buf, struct variable_list *var, struct enum_list *enums)
{
int hex, x;
u_char *cp;
}
static void
-sprint_opaque(buf, var, enums)
- char *buf;
- struct variable_list *var;
- struct enum_list *enums;
+sprint_opaque(char *buf, struct variable_list *var, struct enum_list *enums)
{
if (var->type != OPAQUE) {
}
static void
-sprint_object_identifier(buf, var, enums)
- char *buf;
- struct variable_list *var;
- struct enum_list *enums;
+sprint_object_identifier(char *buf, struct variable_list *var, struct enum_list *enums)
{
if (var->type != ASN_OBJECT_ID) {
sprintf(buf, "Wrong Type (should be OBJECT IDENTIFIER): ");
}
static void
-sprint_timeticks(buf, var, enums)
- char *buf;
- struct variable_list *var;
- struct enum_list *enums;
+sprint_timeticks(char *buf, struct variable_list *var, struct enum_list *enums)
{
char timebuf[32];
}
static void
-sprint_integer(buf, var, enums)
- char *buf;
- struct variable_list *var;
- struct enum_list *enums;
+sprint_integer(char *buf, struct variable_list *var, struct enum_list *enums)
{
char *enum_string = NULL;
}
static void
-sprint_uinteger(buf, var, enums)
- char *buf;
- struct variable_list *var;
- struct enum_list *enums;
+sprint_uinteger(char *buf, struct variable_list *var, struct enum_list *enums)
{
char *enum_string = NULL;
}
static void
-sprint_gauge(buf, var, enums)
- char *buf;
- struct variable_list *var;
- struct enum_list *enums;
+sprint_gauge(char *buf, struct variable_list *var, struct enum_list *enums)
{
if (var->type != GAUGE) {
sprintf(buf, "Wrong Type (should be Gauge): ");
}
static void
-sprint_counter(buf, var, enums)
- char *buf;
- struct variable_list *var;
- struct enum_list *enums;
+sprint_counter(char *buf, struct variable_list *var, struct enum_list *enums)
{
if (var->type != COUNTER) {
sprintf(buf, "Wrong Type (should be Counter): ");
}
static void
-sprint_networkaddress(buf, var, enums)
- char *buf;
- struct variable_list *var;
- struct enum_list *enums;
+sprint_networkaddress(char *buf, struct variable_list *var, struct enum_list *enums)
{
int x, len;
u_char *cp;
}
static void
-sprint_ipaddress(buf, var, enums)
- char *buf;
- struct variable_list *var;
- struct enum_list *enums;
+sprint_ipaddress(char *buf, struct variable_list *var, struct enum_list *enums)
{
u_char *ip;
#if 0
static void
-sprint_unsigned_short(buf, var, enums)
- char *buf;
- struct variable_list *var;
- struct enum_list *enums;
+sprint_unsigned_short(char *buf, struct variable_list *var, struct enum_list *enums)
{
if (var->type != ASN_INTEGER) {
sprintf(buf, "Wrong Type (should be INTEGER): ");
#endif
static void
-sprint_null(buf, var, enums)
- char *buf;
- struct variable_list *var;
- struct enum_list *enums;
+sprint_null(char *buf, struct variable_list *var, struct enum_list *enums)
{
if (var->type != ASN_NULL) {
sprintf(buf, "Wrong Type (should be NULL): ");
}
static void
-sprint_bitstring(buf, var, enums)
- char *buf;
- struct variable_list *var;
- struct enum_list *enums;
+sprint_bitstring(char *buf, struct variable_list *var, struct enum_list *enums)
{
int len, bit;
u_char *cp;
}
static void
-sprint_nsapaddress(buf, var, enums)
- char *buf;
- struct variable_list *var;
- struct enum_list *enums;
+sprint_nsapaddress(char *buf, struct variable_list *var, struct enum_list *enums)
{
if (var->type != NSAP) {
sprintf(buf, "Wrong Type (should be NsapAddress): ");
}
static void
-sprint_counter64(buf, var, enums)
- char *buf;
- struct variable_list *var;
- struct enum_list *enums;
+sprint_counter64(char *buf, struct variable_list *var, struct enum_list *enums)
{
if (var->type != COUNTER64) {
sprintf(buf, "Wrong Type (should be Counter64): ");
sprintf(buf, "Counter64: ");
buf += strlen(buf);
- sprint_hexstring(buf, &var->val.counter64->high,
+ sprint_hexstring(buf, (unsigned char *) &var->val.counter64->high,
sizeof(var->val.counter64->high));
buf += strlen(buf);
- sprint_hexstring(buf, &var->val.counter64->low,
+ sprint_hexstring(buf, (unsigned char *) &var->val.counter64->low,
sizeof(var->val.counter64->low));
}
static void
-sprint_unknowntype(buf, var, enums)
- char *buf;
- struct variable_list *var;
- struct enum_list *enums;
+sprint_unknowntype(char *buf, struct variable_list *var, struct enum_list *enums)
{
/* sprintf(buf, "Variable has bad type"); */
sprint_by_type(buf, var, NULL);
}
static void
-sprint_badtype(buf, var, enums)
- char *buf;
- struct variable_list *var;
- struct enum_list *enums;
+sprint_badtype(char *buf, struct variable_list *var, struct enum_list *enums)
{
sprintf(buf, "Variable has bad type");
}
static void
-sprint_by_type(buf, var, enums)
- char *buf;
- struct variable_list *var;
- struct enum_list *enums;
+sprint_by_type(char *buf, struct variable_list *var, struct enum_list *enums)
{
switch (var->type) {
case ASN_INTEGER:
}
void
-print_objid(objid, objidlen)
- oid *objid;
- int objidlen; /* number of subidentifiers */
+print_objid(oid * objid, int objidlen)
{
char buf[256];
void
-print_variable(objid, objidlen, variable)
- oid *objid;
- int objidlen;
- struct variable_list *variable;
+print_variable(oid * objid, int objidlen, struct variable_list *variable)
{
char buf[2048];
}
static void
-sprint_variable(buf, objid, objidlen, variable)
- char *buf;
- oid *objid;
- int objidlen;
- struct variable_list *variable;
+sprint_variable(char *buf, oid * objid, int objidlen, struct variable_list *variable)
{
char tempbuf[2048];
struct tree *subtree = Mib;
}
void
-sprint_value(buf, objid, objidlen, variable)
- char *buf;
- oid *objid;
- int objidlen;
- struct variable_list *variable;
+sprint_value(char *buf, oid * objid, int objidlen, struct variable_list *variable)
{
char tempbuf[2048];
struct tree *subtree = Mib;
}
void
-print_value(objid, objidlen, variable)
- oid *objid;
- int objidlen;
- struct variable_list *variable;
+print_value(oid * objid, int objidlen, struct variable_list *variable)
{
char tempbuf[2048];
}
static struct tree *
-get_symbol(objid, objidlen, subtree, buf)
- oid *objid;
- int objidlen;
- struct tree *subtree;
- char *buf;
+get_symbol(oid * objid, int objidlen, struct tree *subtree, char *buf)
{
struct tree *return_tree = NULL;
static int
-lc_cmp(s1, s2)
- char *s1, *s2;
+lc_cmp(char *s1, char *s2)
{
char c1, c2;
* Clone of get_symbol that doesn't take a buffer argument
*/
static struct tree *
-get_tree(objid, objidlen, subtree)
- oid *objid;
- int objidlen;
- struct tree *subtree;
+get_tree(oid * objid, int objidlen, struct tree *subtree)
{
struct tree *return_tree = NULL;
#if 0
static char *
-get_description(objid, objidlen)
- oid *objid;
- int objidlen; /* number of subidentifiers */
+get_description(oid * objid, int objidlen)
{
struct tree *subtree = Mib;
#if 0
static void
-print_description(objid, objidlen)
- oid *objid;
- int objidlen; /* number of subidentifiers */
+print_description(oid * objid, int objidlen)
{
char *desc = get_description(objid, objidlen);
static struct tree *
-find_node(name, subtree)
- char *name;
- struct tree *subtree;
+find_node(char *name, struct tree *subtree)
{
struct tree *tp, *ret;
#if 0
static int
-get_node(name, objid, objidlen)
- char *name;
- oid *objid;
- int *objidlen;
+get_node(char *name, oid * objid, int *objidlen)
{
struct tree *tp;
oid newname[64], *op;
if (newname + 64 - op > *objidlen)
return 0;
*objidlen = newname + 64 - op;
- bcopy(op, objid, (newname + 64 - op) * sizeof(oid));
+ xmemcpy(objid, op, (newname + 64 - op) * sizeof(oid));
return 1;
} else {
return 0;
static int tossObjectIdentifier();
static void
-hash_init()
+hash_init(void)
{
struct tok *tp;
char *cp;
struct node *nbuckets[NHASHSIZE];
void
-init_node_hash(nodes)
- struct node *nodes;
+init_node_hash(struct node *nodes)
{
struct node *np, *nextp;
char *cp;
}
static char *
-Malloc(num)
- unsigned num;
+Malloc(unsigned int num)
{
/* this is to fix (what seems to be) a problem with the IBM RT C
* library malloc */
}
static void
-print_error(string, token, type)
- char *string;
- char *token;
- int type;
+print_error(char *string, char *token, int type)
{
if (type == ENDOFFILE)
fprintf(stderr, "%s(EOF): On or around line %d\n", string, Line);
}
#ifdef TEST
-print_subtree(tree, count)
- struct tree *tree;
- int count;
+print_subtree(struct tree *tree, int count)
{
struct tree *tp;
int i;
int translation_table[256];
void
-build_translation_table()
+build_translation_table(void)
{
int count;
}
static struct tree *
-build_tree(nodes)
- struct node *nodes;
+build_tree(struct node *nodes)
{
struct node *np;
struct tree *tp, *lasttp;
* tree and out of the nodes list.
*/
static void
-do_subtree(root, nodes)
- struct tree *root;
- struct node **nodes;
+do_subtree(struct tree *root, struct node **nodes)
{
struct tree *tp;
struct tree *peer = NULL;
* Returns NULL on error.
*/
static int
-getoid(fp, oid, length)
- FILE *fp;
- struct subid *oid; /* an array of subids */
- int length; /* the length of the array */
+getoid(FILE * fp, struct subid *oid, int length)
{
int count;
int type;
}
static void
-free_node(np)
- struct node *np;
+free_node(struct node *np)
{
struct enum_list *ep, *tep;
* Returns 0 on error.
*/
static struct node *
-parse_objectid(fp, name)
- FILE *fp;
- char *name;
+parse_objectid(FILE * fp, char *name)
{
int type;
char token[MAXTOKEN];
}
static int
-get_tc(descriptor, ep)
- char *descriptor;
- struct enum_list **ep;
+get_tc(char *descriptor, struct enum_list **ep)
{
int i;
* Returns NULL on error.
*/
static int
-parse_asntype(fp, name, ntype, ntoken)
- FILE *fp;
- char *name;
- int *ntype;
- char *ntoken;
+parse_asntype(FILE * fp, char *name, int *ntype, char *ntoken)
{
int type, i;
char token[MAXTOKEN];
* Returns 0 on error.
*/
static struct node *
-parse_objecttype(fp, name)
- FILE *fp;
- char *name;
+parse_objecttype(FILE * fp, char *name)
{
int type;
char token[MAXTOKEN];
* Returns 0 on error.
*/
static struct node *
-parse_objectgroup(fp, name)
- FILE *fp;
- char *name;
+parse_objectgroup(FILE * fp, char *name)
{
int type;
char token[MAXTOKEN];
* Returns 0 on error.
*/
static struct node *
-parse_notificationDefinition(fp, name)
- FILE *fp;
- char *name;
+parse_notificationDefinition(FILE * fp, char *name)
{
int type;
char token[MAXTOKEN];
* Returns 0 on error.
*/
static struct node *
-parse_compliance(fp, name)
- FILE *fp;
- char *name;
+parse_compliance(FILE * fp, char *name)
{
int type;
char token[MAXTOKEN];
* Returns 0 on error.
*/
static struct node *
-parse_moduleIdentity(fp, name)
- FILE *fp;
- char *name;
+parse_moduleIdentity(FILE * fp, char *name)
{
int type;
char token[MAXTOKEN];
}
int
-parse_mib_header(fp, name)
- FILE *fp;
- char *name;
+parse_mib_header(FILE * fp, char *name)
{
int type = DEFINITIONS;
char token[MAXTOKEN];
* Returns NULL on error.
*/
static struct node *
-parse(fp)
- FILE *fp;
+parse(FILE * fp)
{
char token[MAXTOKEN];
char name[MAXTOKEN];
* and the text is placed in the string pointed to by token.
*/
static int
-get_token(fp, token)
- FILE *fp;
- char *token;
+get_token(FILE * fp, char *token)
{
static char last = ' ';
int ch;
#ifdef TEST
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
FILE *fp;
struct node *nodes;
#endif /* TEST */
static int
-parseQuoteString(fp, token)
- FILE *fp;
- char *token;
+parseQuoteString(FILE * fp, char *token)
{
int ch;
* it is well formed, and NULL if not.
*/
static int
-tossObjectIdentifier(fp)
- FILE *fp;
+tossObjectIdentifier(FILE * fp)
{
int ch;
};
-void sync_with_agent();
-int parse_app_community_string();
-void snmp_synch_setup();
-int snmp_synch_response();
-void md5Digest(u_char * msg, int length, u_char * key, u_char * digest);
+static void sync_with_agent(struct snmp_session *session);
#if NO_PRINTFS
static char *
-api_errstring(snmp_errnumber)
- int snmp_errnumber;
+api_errstring(int snmp_errnumber)
{
if (snmp_errnumber <= SNMPERR_BAD_SESSION && snmp_errnumber >= SNMPERR_GENERR) {
return api_errors[snmp_errnumber + 4];
* Gets initial request ID for all transactions.
*/
static void
-init_snmp()
+init_snmp(void)
{
struct timeval tv;
* Dump snmp packet to stdout:
*/
static void
-snmp_print_packet(packet, length, addr, code)
- char *packet;
- int length;
- ipaddr addr;
- int code;
+snmp_print_packet(char *packet, int length, ipaddr addr, int code)
{
if (length < 0) {
return;
#define TRACE_RECV (1)
#define TRACE_TIMEOUT (2)
static void
-snmp_print_trace(slp, rp, code)
- struct session_list *slp;
- struct request_list *rp;
- int code;
+snmp_print_trace(struct session_list *slp, struct request_list *rp, int code)
{
int reqid = 0, retries = 1;
if (rp) {
* and snmp_errno is set to the appropriate error code.
*/
struct snmp_session *
-snmp_open(session)
- struct snmp_session *session;
+snmp_open(struct snmp_session *session)
{
struct session_list *slp;
struct snmp_internal_session *isp;
memset(isp, '\0', sizeof(struct snmp_internal_session));
slp->internal->sd = -1; /* mark it not set */
slp->session = xcalloc(1, sizeof(struct snmp_session));
- bcopy((char *) session, (char *) slp->session, sizeof(struct snmp_session));
+ xmemcpy(slp->session, session, sizeof(struct snmp_session));
session = slp->session;
/* now link it in. */
slp->next = Sessions;
} else {
session->community_len = strlen(DEFAULT_COMMUNITY);
cp = xcalloc(1, (unsigned) session->community_len);
- bcopy((char *) DEFAULT_COMMUNITY, (char *) cp, session->community_len);
+ xmemcpy(cp, DEFAULT_COMMUNITY, session->community_len);
}
/* Set up connections */
if (session->peername != SNMP_DEFAULT_PEERNAME) {
if ((addr = inet_addr(session->peername)) != -1) {
- bcopy((char *) &addr, (char *) &isp->addr.sin_addr, sizeof(isp->addr.sin_addr));
+ xmemcpy(&isp->addr.sin_addr, &addr, sizeof(isp->addr.sin_addr));
} else {
hp = gethostbyname(session->peername);
if (hp == NULL) {
}
return 0;
} else {
- bcopy((char *) hp->h_addr, (char *) &isp->addr.sin_addr, hp->h_length);
+ xmemcpy(&isp->addr.sin_addr, hp->h_addr, hp->h_length);
}
}
isp->addr.sin_family = AF_INET;
return session;
}
-void
-sync_with_agent(session)
- struct snmp_session *session;
+static void
+sync_with_agent(struct snmp_session *session)
{
struct snmp_pdu *pdu, *response = 0;
int status;
* then free it and it's pdu.
*/
static void
-free_one_request(isp, orp)
- struct snmp_internal_session *isp;
- struct request_list *orp;
+free_one_request(struct snmp_internal_session *isp, struct request_list *orp)
{
struct request_list *rp;
if (!orp)
* Free each element in the input request list.
*/
static void
-free_request_list(rp)
- struct request_list *rp;
+free_request_list(struct request_list *rp)
{
struct request_list *orp;
* the session. Returns 0 on error, 1 otherwise.
*/
int
-snmp_close(session)
- struct snmp_session *session;
+snmp_close(struct snmp_session *session)
{
struct session_list *slp = NULL, *oslp = NULL;
* occur, -1 is returned. If all goes well, 0 is returned.
*/
int
-snmp_build(session, pdu, packet, out_length, is_agent)
- struct snmp_session *session;
- struct snmp_pdu *pdu;
- u_char *packet;
- int *out_length;
- int is_agent;
+snmp_build(
+ struct snmp_session *session,
+ struct snmp_pdu *pdu,
+ u_char * packet,
+ int *out_length,
+ int is_agent)
{
u_char buf[PACKET_LENGTH];
u_char *cp;
cp = asn_build_header(buf, &length, (u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR), totallength);
if (cp == NULL)
return -1;
- bcopy((char *) packet, (char *) cp, totallength);
+ xmemcpy(cp, packet, totallength);
totallength += cp - buf;
length = *out_length;
}
if (length < totallength)
return -1;
- bcopy((char *) buf, (char *) cp, totallength);
+ xmemcpy(cp, buf, totallength);
totallength += cp - packet;
length = PACKET_LENGTH;
return -1;
if (length < totallength)
return -1;
- bcopy((char *) packet, (char *) cp, totallength);
+ xmemcpy(cp, packet, totallength);
totallength += cp - buf;
length = *out_length;
return -1;
if ((*out_length - (cp - packet)) < totallength)
return -1;
- bcopy((char *) buf, (char *) cp, totallength);
+ xmemcpy(cp, buf, totallength);
totallength += cp - packet;
*out_length = totallength;
* are encountered, -1 is returned. Otherwise, a 0 is returned.
*/
static int
-snmp_parse(session, pdu, data, length)
- struct snmp_session *session;
- struct snmp_pdu *pdu;
- u_char *data;
- int length;
+snmp_parse(
+ struct snmp_session *session,
+ struct snmp_pdu *pdu,
+ u_char * data,
+ int length)
{
u_char msg_type;
u_char type;
if (data == NULL)
return -1;
pdu->enterprise = xcalloc(1, pdu->enterprise_length * sizeof(oid));
- bcopy((char *) objid, (char *) pdu->enterprise, pdu->enterprise_length * sizeof(oid));
+ xmemcpy(pdu->enterprise, objid, pdu->enterprise_length * sizeof(oid));
four = 4;
data = asn_parse_string(data, &length, &type, (u_char *) & pdu->agent_addr.sin_addr.s_addr, &four);
if (data == NULL)
return -1;
op = xcalloc(1, (unsigned) vp->name_length * sizeof(oid));
- bcopy((char *) objid, (char *) op, vp->name_length * sizeof(oid));
+ xmemcpy(op, objid, vp->name_length * sizeof(oid));
vp->name = op;
len = PACKET_LENGTH;
asn_parse_objid(var_val, &len, &vp->type, objid, &vp->val_len);
vp->val_len *= sizeof(oid);
vp->val.objid = xcalloc(1, (unsigned) vp->val_len);
- bcopy((char *) objid, (char *) vp->val.objid, vp->val_len);
+ xmemcpy(vp->val.objid, objid, vp->val_len);
break;
case SNMP_NOSUCHOBJECT:
case SNMP_NOSUCHINSTANCE:
* The pdu is freed by snmp_send() unless a failure occured.
*/
int
-snmp_send(session, pdu)
- struct snmp_session *session;
- struct snmp_pdu *pdu;
+snmp_send(struct snmp_session *session, struct snmp_pdu *pdu)
{
struct session_list *slp;
struct snmp_internal_session *isp = NULL;
pdu->reqid = 1; /* give a bogus non-error reqid for traps */
if (pdu->enterprise_length == SNMP_DEFAULT_ENTERPRISE_LENGTH) {
pdu->enterprise = xcalloc(1, sizeof(DEFAULT_ENTERPRISE));
- bcopy((char *) DEFAULT_ENTERPRISE, (char *) pdu->enterprise, sizeof(DEFAULT_ENTERPRISE));
+ xmemcpy(pdu->enterprise, DEFAULT_ENTERPRISE, sizeof(DEFAULT_ENTERPRISE));
pdu->enterprise_length = sizeof(DEFAULT_ENTERPRISE) / sizeof(oid);
}
if (pdu->time == SNMP_DEFAULT_TIME)
}
if (pdu->address.sin_addr.s_addr == SNMP_DEFAULT_ADDRESS) {
if (isp->addr.sin_addr.s_addr != SNMP_DEFAULT_ADDRESS) {
- bcopy((char *) &isp->addr, (char *) &pdu->address, sizeof(pdu->address));
+ xmemcpy(&pdu->address, &isp->addr, sizeof(pdu->address));
} else {
#if NO_PRINTFS
fprintf(stderr, "No remote IP address specified\n");
* routine returns successfully, the pdu and it's request are deleted.
*/
void
-snmp_read(fdset)
- fd_set *fdset;
+snmp_read(fd_set * fdset)
{
struct session_list *slp;
struct snmp_session *sp;
* number of sessions open)
*/
int
-snmp_select_info(numfds, fdset, timeout, block)
- int *numfds;
- fd_set *fdset;
- struct timeval *timeout;
- int *block; /* should the select block until input arrives (i.e. no input) */
-{
+snmp_select_info(
+ int *numfds,
+ fd_set * fdset,
+ struct timeval *timeout,
+ int *block)
+{ /* should the select block until input arrives (i.e. no input) */
struct session_list *slp;
struct snmp_internal_session *isp;
struct request_list *rp;
* the session is used to alert the user of the timeout.
*/
void
-snmp_timeout()
+snmp_timeout(void)
{
struct session_list *slp;
struct snmp_session *sp;