This way the size is the same on all archs and 32bit should be good enough.
OK rob@
-.\" $OpenBSD: ber.3,v 1.16 2018/06/29 20:28:11 jmc Exp $
+.\" $OpenBSD: ber.3,v 1.17 2018/07/31 11:01:29 claudio Exp $
.\"
.\" Copyright (c) 2007, 2012 Reyk Floeter <reyk@openbsd.org>
.\"
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: June 29 2018 $
+.Dd $Mdocdate: July 31 2018 $
.Dt BER 3
.Os
.Sh NAME
.Sh SYNOPSIS
.Fd #include <ber.h>
.Ft "struct ber_element *"
-.Fn "ber_get_element" "unsigned long encoding"
+.Fn "ber_get_element" "unsigned int encoding"
.Ft "void"
-.Fn "ber_set_header" "struct ber_element *elm" "int class" "unsigned long type"
+.Fn "ber_set_header" "struct ber_element *elm" "int class" "unsigned int type"
.Ft "void"
.Fn "ber_link_elements" "struct ber_element *prev" "struct ber_element *elm"
.Ft "struct ber_element *"
.Ft "size_t"
.Fn "ber_calc_len" "struct ber_element *root"
.Ft "void"
-.Fn "ber_set_application" "struct ber *ber" "unsigned long (*cb)(struct ber_element *)"
+.Fn "ber_set_application" "struct ber *ber" "unsigned int (*cb)(struct ber_element *)"
.Ft "void"
.Fn "ber_set_writecallback" "struct ber_element *elm" "void (*cb)(void *arg, size_t offs)" "void *arg"
.Ft "void"
-/* $OpenBSD: ber.c,v 1.43 2018/07/13 08:50:38 rob Exp $ */
+/* $OpenBSD: ber.c,v 1.44 2018/07/31 11:01:29 claudio Exp $ */
/*
* Copyright (c) 2007, 2012 Reyk Floeter <reyk@openbsd.org>
static void ber_dump_header(struct ber *ber, struct ber_element *root);
static void ber_putc(struct ber *ber, u_char c);
static void ber_write(struct ber *ber, void *buf, size_t len);
-static ssize_t get_id(struct ber *b, unsigned long *tag, int *class,
+static ssize_t get_id(struct ber *b, unsigned int *tag, int *class,
int *cstruct);
static ssize_t get_len(struct ber *b, ssize_t *len);
static ssize_t ber_read_element(struct ber *ber, struct ber_element *elm);
#endif
struct ber_element *
-ber_get_element(unsigned long encoding)
+ber_get_element(unsigned int encoding)
{
struct ber_element *elm;
}
void
-ber_set_header(struct ber_element *elm, int class, unsigned long type)
+ber_set_header(struct ber_element *elm, int class, unsigned int type)
{
elm->be_class = class & BER_CLASS_MASK;
if (type == BER_TYPE_DEFAULT)
va_list ap;
int d, class;
size_t len;
- unsigned long type;
+ unsigned int type;
long long i;
char *s;
void *p;
break;
case 't':
class = va_arg(ap, int);
- type = va_arg(ap, unsigned long);
+ type = va_arg(ap, unsigned int);
ber_set_header(ber, class, type);
break;
case 'x':
#define _MAX_SEQ 128
va_list ap;
int *d, level = -1;
- unsigned long *t;
+ unsigned int *t;
long long *i, l;
void **ptr;
size_t *len, ret = 0, n = strlen(fmt);
break;
case 't':
d = va_arg(ap, int *);
- t = va_arg(ap, unsigned long *);
+ t = va_arg(ap, unsigned int *);
*d = ber->be_class;
*t = ber->be_type;
ret++;
size_t
ber_calc_len(struct ber_element *root)
{
- unsigned long t;
+ unsigned int t;
size_t s;
size_t size = 2; /* minimum 1 byte head and 1 byte size */
static void
ber_dump_header(struct ber *ber, struct ber_element *root)
{
- u_char id = 0, t, buf[8];
- unsigned long type;
+ u_char id = 0, t, buf[5];
+ unsigned int type;
size_t size;
/* class universal, type encoding depending on type value */
* extract a BER encoded tag. There are two types, a short and long form.
*/
static ssize_t
-get_id(struct ber *b, unsigned long *tag, int *class, int *cstruct)
+get_id(struct ber *b, unsigned int *tag, int *class, int *cstruct)
{
u_char u;
size_t i = 0;
- unsigned long t = 0;
+ unsigned int t = 0;
if (ber_getc(b, &u) == -1)
return -1;
return -1;
t = (t << 7) | (u & ~BER_TAG_MORE);
i++;
- if (i > sizeof(unsigned long)) {
+ if (i > sizeof(unsigned int)) {
errno = ERANGE;
return -1;
}
{
long long val = 0;
struct ber_element *next;
- unsigned long type;
+ unsigned int type;
int i, class, cstruct;
ssize_t len, r, totlen = 0;
u_char c;
}
void
-ber_set_application(struct ber *b, unsigned long (*cb)(struct ber_element *))
+ber_set_application(struct ber *b, unsigned int (*cb)(struct ber_element *))
{
b->br_application = cb;
}
-/* $OpenBSD: ber.h,v 1.11 2018/06/29 19:28:02 rob Exp $ */
+/* $OpenBSD: ber.h,v 1.12 2018/07/31 11:01:29 claudio Exp $ */
/*
* Copyright (c) 2007, 2012 Reyk Floeter <reyk@openbsd.org>
struct ber_element {
struct ber_element *be_next;
- unsigned long be_type;
- unsigned long be_encoding;
+ unsigned int be_type;
+ unsigned int be_encoding;
size_t be_len;
off_t be_offs;
int be_free;
u_char *br_rptr;
u_char *br_rend;
- unsigned long (*br_application)(struct ber_element *);
+ unsigned int (*br_application)(struct ber_element *);
};
/* well-known ber_element types */
-#define BER_TYPE_DEFAULT ((unsigned long)-1)
+#define BER_TYPE_DEFAULT ((unsigned int)-1)
#define BER_TYPE_EOC 0
#define BER_TYPE_BOOLEAN 1
#define BER_TYPE_INTEGER 2
};
__BEGIN_DECLS
-struct ber_element *ber_get_element(unsigned long);
+struct ber_element *ber_get_element(unsigned int);
void ber_set_header(struct ber_element *, int,
- unsigned long);
+ unsigned int);
void ber_link_elements(struct ber_element *,
struct ber_element *);
struct ber_element *ber_unlink_elements(struct ber_element *);
void ber_free_elements(struct ber_element *);
size_t ber_calc_len(struct ber_element *);
void ber_set_application(struct ber *,
- unsigned long (*)(struct ber_element *));
+ unsigned int (*)(struct ber_element *));
void ber_set_writecallback(struct ber_element *,
void (*)(void *, size_t), void *);
void ber_free(struct ber *);
-/* $OpenBSD: smi.c,v 1.21 2018/07/23 19:51:39 rob Exp $ */
+/* $OpenBSD: smi.c,v 1.22 2018/07/31 11:01:29 claudio Exp $ */
/*
* Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org>
return (NULL);
}
-unsigned long
+unsigned int
smi_application(struct ber_element *elm)
{
if (elm->be_class != BER_CLASS_APPLICATION)
-/* $OpenBSD: snmpd.h,v 1.78 2018/04/15 11:57:29 mpf Exp $ */
+/* $OpenBSD: snmpd.h,v 1.79 2018/07/31 11:01:29 claudio Exp $ */
/*
* Copyright (c) 2007, 2008, 2012 Reyk Floeter <reyk@openbsd.org>
int smi_insert(struct oid *);
int smi_oid_cmp(struct oid *, struct oid *);
int smi_key_cmp(struct oid *, struct oid *);
-unsigned long smi_application(struct ber_element *);
+unsigned int smi_application(struct ber_element *);
void smi_debug_elements(struct ber_element *);
char *smi_print_element(struct ber_element *);
-/* $OpenBSD: snmpe.c,v 1.53 2018/07/24 01:31:20 rob Exp $ */
+/* $OpenBSD: snmpe.c,v 1.54 2018/07/31 11:01:29 claudio Exp $ */
/*
* Copyright (c) 2007, 2008, 2012 Reyk Floeter <reyk@openbsd.org>
struct ber_element *a;
long long ver, req;
long long errval, erridx;
- unsigned long type;
+ unsigned int type;
u_int class;
char *comn;
char *flagstr, *ctxname;