#ifndef _NETINET_IP_ICMP_H_
#define _NETINET_IP_ICMP_H_
-#include <sys/types.h> /* u_int32_t, u_char */
+#include <sys/types.h> /* uint32_t */
#include <netinet/in.h> /* in_addr */
#include <netinet/in_systm.h> /* n_short */
#include <netinet/ip.h> /* idi_ip */
* Internal of an ICMP Router Advertisement
*/
struct icmp_ra_addr {
- u_int32_t ira_addr;
- u_int32_t ira_preference;
+ uint32_t ira_addr;
+ uint32_t ira_preference;
};
/*
* Structure of an icmp header.
*/
struct icmp {
- u_char icmp_type; /* type of message, see below */
- u_char icmp_code; /* type sub code */
- u_short icmp_cksum; /* ones complement cksum of struct */
+ unsigned char icmp_type; /* type of message, see below */
+ unsigned char icmp_code; /* type sub code */
+ unsigned short icmp_cksum; /* ones complement cksum of struct */
union {
- u_char ih_pptr; /* ICMP_PARAMPROB */
+ unsigned char ih_pptr; /* ICMP_PARAMPROB */
struct in_addr ih_gwaddr; /* ICMP_REDIRECT */
struct ih_idseq {
n_short icd_id;
} ih_pmtu;
struct ih_rtradv {
- u_char irt_num_addrs;
- u_char irt_wpa;
- u_int16_t irt_lifetime;
+ unsigned char irt_num_addrs;
+ unsigned char irt_wpa;
+ uint16_t irt_lifetime;
} ih_rtradv;
} icmp_hun;
#define icmp_pptr icmp_hun.ih_pptr
/* options and then 64 bits of data */
} id_ip;
struct icmp_ra_addr id_radv;
- u_int32_t id_mask;
+ uint32_t id_mask;
char id_data[1];
} icmp_dun;
#define icmp_otime icmp_dun.id_ts.its_otime
__BEGIN_DECLS
uint32_t arc4random(void);
void arc4random_stir(void);
-void arc4random_addrandom(u_char *dat, int datlen);
+void arc4random_addrandom(unsigned char *dat, int datlen);
void arc4random_buf(void *_buf, size_t n);
uint32_t arc4random_uniform(uint32_t upper_bound);
/* Maybe be preserved in fork children, if _rs_allocate() decides. */
static struct _rsx {
chacha_ctx rs_chacha; /* chacha context for random keystream */
- u_char rs_buf[RSBUFSZ]; /* keystream blocks */
+ unsigned char rs_buf[RSBUFSZ]; /* keystream blocks */
} *rsx;
static inline int _rs_allocate(struct _rs **, struct _rsx **);
#include "arc4random.h"
static inline void
-_rs_init(u_char *buf, size_t n)
+_rs_init(unsigned char *buf, size_t n)
{
if (n < KEYSZ + IVSZ)
return;
}
static inline void
-_rs_rekey(u_char *dat, size_t datlen)
+_rs_rekey(unsigned char *dat, size_t datlen)
{
#ifndef KEYSTREAM_ONLY
memset(rsx->rs_buf, 0, sizeof(rsx->rs_buf));
static void
_rs_stir(void)
{
- u_char rnd[KEYSZ + IVSZ];
+ unsigned char rnd[KEYSZ + IVSZ];
if (getentropy(rnd, sizeof rnd) == -1)
_getentropy_fail();
static inline void
_rs_random_buf(void *_buf, size_t n)
{
- u_char *buf = (u_char *)_buf;
- u_char *keystream;
+ unsigned char *buf = (unsigned char *)_buf;
+ unsigned char *keystream;
size_t m;
_rs_stir_if_needed(n);
static inline void
_rs_random_u32(uint32_t *val)
{
- u_char *keystream;
+ unsigned char *keystream;
_rs_stir_if_needed(sizeof(*val));
if (rs->rs_have < sizeof(*val))
}
void
-arc4random_addrandom(u_char *dat, int datlen)
+arc4random_addrandom(unsigned char *dat, int datlen)
{
_ARC4_LOCK();
_rs_stir_if_needed(datlen);
u32 j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15;
u8 *ctarget = NULL;
u8 tmp[64];
- u_int i;
+ unsigned int i;
if (!bytes) return;
* Derived from lib/libc/gen/arc4random.c from FreeBSD.
*/
static size_t
-getentropy_sysctl(u_char *buf, size_t size)
+getentropy_sysctl(unsigned char *buf, size_t size)
{
int mib[2];
size_t len, done;
HASHFileChunk(const char *filename, char *buf, off_t off, off_t len)
{
struct stat sb;
- u_char buffer[BUFSIZ];
+ unsigned char buffer[BUFSIZ];
HASH_CTX ctx;
int fd, save_errno;
ssize_t nr;
}
char *
-HASHData(const u_char *data, size_t len, char *buf)
+HASHData(const unsigned char *data, size_t len, char *buf)
{
HASH_CTX ctx;
# define SPRINTF(x) ((size_t)sprintf x)
#endif
-static int inet_net_pton_ipv4(const char *src, u_char *dst, size_t size);
+static int inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size);
/*
* static int
* Paul Vixie (ISC), June 1996
*/
static int
-inet_net_pton_ipv4(const char *src, u_char *dst, size_t size)
+inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size)
{
static const char
xdigits[] = "0123456789abcdef",
digits[] = "0123456789";
int n, ch, tmp, dirty, bits;
- const u_char *odst = dst;
+ const unsigned char *odst = dst;
ch = *src++;
if (ch == '0' && (src[0] == 'x' || src[0] == 'X')
isascii(ch) && isdigit(ch));
if (size-- <= 0)
goto emsgsize;
- *dst++ = (u_char) tmp;
+ *dst++ = (unsigned char) tmp;
if (ch == '\0' || ch == '/')
break;
if (ch != '.')
#include <stdlib.h>
#include <string.h>
-static void setup(u_char *, u_char *, size_t, size_t,
+static void setup(unsigned char *, unsigned char *, size_t, size_t,
int (*)(const void *, const void *));
-static void insertionsort(u_char *, size_t, size_t,
+static void insertionsort(unsigned char *, size_t, size_t,
int (*)(const void *, const void *));
#define ISIZE sizeof(int)
-#define PSIZE sizeof(u_char *)
+#define PSIZE sizeof(unsigned char *)
#define ICOPY_LIST(src, dst, last) \
do \
*(int*)dst = *(int*)src, src += ISIZE, dst += ISIZE; \
* boundaries.
*/
/* Assumption: PSIZE is a power of 2. */
-#define EVAL(p) (u_char **) \
- ((u_char *)0 + \
- (((u_char *)p + PSIZE - 1 - (u_char *) 0) & ~(PSIZE - 1)))
+#define EVAL(p) (unsigned char **) \
+ ((unsigned char *)0 + \
+ (((unsigned char *)p + PSIZE - 1 - \
+ (unsigned char *)0) & ~(PSIZE - 1)))
/*
* Arguments are as for qsort.
size_t i;
int sense;
int big, iflag;
- u_char *f1, *f2, *t, *b, *tp2, *q, *l1, *l2;
- u_char *list2, *list1, *p2, *p, *last, **p1;
+ unsigned char *f1, *f2, *t, *b, *tp2, *q, *l1, *l2;
+ unsigned char *list2, *list1, *p2, *p, *last, **p1;
if (size < PSIZE / 2) { /* Pointers must fit into 2 * size. */
errno = EINVAL;
* is defined. Otherwise simple pairwise merging is used.)
*/
static void
-setup(u_char *list1, u_char *list2, size_t n, size_t size,
+setup(unsigned char *list1, unsigned char *list2, size_t n, size_t size,
int (*cmp)(const void *, const void *))
{
int i, length, size2, tmp, sense;
- u_char *f1, *f2, *s, *l2, *last, *p2;
+ unsigned char *f1, *f2, *s, *l2, *last, *p2;
size2 = size*2;
if (n <= 5) {
insertionsort(list1, n, size, cmp);
- *EVAL(list2) = (u_char*) list2 + n*size;
+ *EVAL(list2) = (unsigned char*) list2 + n*size;
return;
}
/*
* last 4 elements.
*/
static void
-insertionsort(u_char *a, size_t n, size_t size,
+insertionsort(unsigned char *a, size_t n, size_t size,
int (*cmp)(const void *, const void *))
{
- u_char *ai, *s, *t, *u, tmp;
+ unsigned char *ai, *s, *t, *u, tmp;
int i;
for (ai = a+size; --n >= 1; ai += size)
struct nlist *p, *symtab;
caddr_t strtab, a_out_mmap;
off_t stroff, symoff;
- u_long symsize;
+ unsigned long symsize;
int nent;
struct exec * exec;
struct stat st;
#include <errno.h>
typedef struct {
- const u_char **sa;
+ const unsigned char **sa;
int sn, si;
} stack;
-static inline void simplesort(const u_char **, int, int, const u_char *, u_int);
-static void r_sort_a(const u_char **, int, int, const u_char *, u_int);
-static void r_sort_b(const u_char **,
- const u_char **, int, int, const u_char *, u_int);
+static inline void simplesort(const unsigned char **, int, int, const unsigned char *, unsigned int);
+static void r_sort_a(const unsigned char **, int, int, const unsigned char *, unsigned int);
+static void r_sort_b(const unsigned char **,
+ const unsigned char **, int, int, const unsigned char *, unsigned int);
#define THRESHOLD 20 /* Divert to simplesort(). */
#define SIZE 512 /* Default stack size. */
}
int
-radixsort(const u_char **a, int n, const u_char *tab, u_int endch)
+radixsort(const unsigned char **a, int n, const unsigned char *tab,
+ unsigned int endch)
{
- const u_char *tr;
- u_int c;
- u_char tr0[256];
+ const unsigned char *tr;
+ unsigned int c;
+ unsigned char tr0[256];
SETUP;
r_sort_a(a, n, 0, tr, endch);
}
int
-sradixsort(const u_char **a, int n, const u_char *tab, u_int endch)
+sradixsort(const unsigned char **a, int n, const unsigned char *tab,
+ unsigned int endch)
{
- const u_char *tr, **ta;
- u_int c;
- u_char tr0[256];
+ const unsigned char *tr, **ta;
+ unsigned int c;
+ unsigned char tr0[256];
if (a == NULL) {
errno = EFAULT;
/* Unstable, in-place sort. */
static void
-r_sort_a(const u_char **a, int n, int i, const u_char *tr, u_int endch)
+r_sort_a(const unsigned char **a, int n, int i, const unsigned char *tr,
+ unsigned int endch)
{
- static u_int count[256], nc, bmin;
- u_int c;
- const u_char **ak, *r;
+ static unsigned int count[256], nc, bmin;
+ unsigned int c;
+ const unsigned char **ak, *r;
stack s[SIZE], *sp, *sp0, *sp1, temp;
- u_int *cp, bigc;
- const u_char **an, *t, **aj, **top[256];
+ unsigned int *cp, bigc;
+ const unsigned char **an, *t, **aj, **top[256];
/* Set up stack. */
sp = s;
* character at position i, move on to the next
* character.
*/
- if (nc == 1 && count[bmin] == (u_int)n) {
+ if (nc == 1 && count[bmin] == (unsigned int)n) {
push(a, n, i+1);
nc = count[bmin] = 0;
continue;
/* Stable sort, requiring additional memory. */
static void
-r_sort_b(const u_char **a, const u_char **ta, int n, int i, const u_char *tr,
- u_int endch)
+r_sort_b(const unsigned char **a, const unsigned char **ta, int n, int i,
+ const unsigned char *tr, unsigned int endch)
{
- static u_int count[256], nc, bmin;
- u_int c;
- const u_char **ak, **ai;
+ static unsigned int count[256], nc, bmin;
+ unsigned int c;
+ const unsigned char **ak, **ai;
stack s[512], *sp, *sp0, *sp1, temp;
- const u_char **top[256];
- u_int *cp, bigc;
+ const unsigned char **top[256];
+ unsigned int *cp, bigc;
sp = s;
push(a, n, i);
/* insertion sort */
static inline void
-simplesort(const u_char **a, int n, int b, const u_char *tr, u_int endch)
+simplesort(const unsigned char **a, int n, int b, const unsigned char *tr,
+ unsigned int endch)
{
- u_char ch;
- const u_char **ak, **ai, *s, *t;
+ unsigned char ch;
+ const unsigned char **ak, **ai, *s, *t;
for (ak = a+1; --n >= 1; ak++)
for (ai = ak; ai > a; ai--) {
#define S_HTTP 0x080 /* %HEXHEX escape */
-#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
-#define ishex(c) ((((u_char)(c)) >= '0' && ((u_char)(c)) <= '9') || (((u_char)(c)) >= 'a' && ((u_char)(c)) <= 'f'))
+#define isoctal(c) \
+ (((unsigned char)(c)) >= '0' && ((unsigned char)(c)) <= '7')
+#define ishex(c) \
+ ((((unsigned char)(c)) >= '0' && ((unsigned char)(c)) <= '9') || \
+ (((unsigned char)(c)) >= 'a' && ((unsigned char)(c)) <= 'f'))
/*
* unvis - decode characters previously encoded by vis
#include <stdio.h>
#include <vis.h>
-#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
+#define isoctal(c) \
+ (((unsigned char)(c)) >= '0' && ((unsigned char)(c)) <= '7')
#define isvisible(c) \
- (((u_int)(c) <= UCHAR_MAX && isascii((u_char)(c)) && \
+ (((unsigned int)(c) <= UCHAR_MAX && \
+ isascii((unsigned char)(c)) && \
(((c) != '*' && (c) != '?' && (c) != '[' && (c) != '#') || \
- (flag & VIS_GLOB) == 0) && isgraph((u_char)(c))) || \
+ (flag & VIS_GLOB) == 0) && \
+ isgraph((unsigned char)(c))) || \
((flag & VIS_SP) == 0 && (c) == ' ') || \
((flag & VIS_TAB) == 0 && (c) == '\t') || \
((flag & VIS_NL) == 0 && (c) == '\n') || \
((flag & VIS_SAFE) && ((c) == '\b' || \
(c) == '\007' || (c) == '\r' || \
- isgraph((u_char)(c)))))
+ isgraph((unsigned char)(c)))))
/*
* vis - visually encode characters
}
if (((c & 0177) == ' ') || isgraph(c) || (flag & VIS_OCTAL)) {
*dst++ = '\\';
- *dst++ = ((u_char)c >> 6 & 07) + '0';
- *dst++ = ((u_char)c >> 3 & 07) + '0';
- *dst++ = ((u_char)c & 07) + '0';
+ *dst++ = ((unsigned char)c >> 6 & 07) + '0';
+ *dst++ = ((unsigned char)c >> 3 & 07) + '0';
+ *dst++ = ((unsigned char)c & 07) + '0';
goto done;
}
if ((flag & VIS_NOSLASH) == 0)