diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2018-03-27 15:13:34 -0400 | 
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2018-03-27 15:13:34 -0400 | 
| commit | d7c0a89a3a5697783a6dd89333ab660074790890 (patch) | |
| tree | eefa73e502f919b524b8a345437260d4acc23083 /lib | |
| parent | 28ac5a038101c66e4275a9b1ef6fb37b4f74fb6a (diff) | |
*: use C99 standard fixed-width integer types
The following types are nonstandard:
- u_char
- u_short
- u_int
- u_long
- u_int8_t
- u_int16_t
- u_int32_t
Replace them with the C99 standard types:
- uint8_t
- unsigned short
- unsigned int
- unsigned long
- uint8_t
- uint16_t
- uint32_t
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/agentx.c | 6 | ||||
| -rw-r--r-- | lib/bfd.c | 15 | ||||
| -rw-r--r-- | lib/bfd.h | 24 | ||||
| -rw-r--r-- | lib/buffer.c | 6 | ||||
| -rw-r--r-- | lib/buffer.h | 2 | ||||
| -rw-r--r-- | lib/checksum.c | 20 | ||||
| -rw-r--r-- | lib/checksum.h | 4 | ||||
| -rw-r--r-- | lib/command_graph.c | 4 | ||||
| -rw-r--r-- | lib/filter.c | 4 | ||||
| -rw-r--r-- | lib/if.h | 24 | ||||
| -rw-r--r-- | lib/imsg-buffer.c | 2 | ||||
| -rw-r--r-- | lib/imsg.c | 14 | ||||
| -rw-r--r-- | lib/imsg.h | 29 | ||||
| -rw-r--r-- | lib/ipaddr.h | 4 | ||||
| -rw-r--r-- | lib/jhash.c | 50 | ||||
| -rw-r--r-- | lib/jhash.h | 17 | ||||
| -rw-r--r-- | lib/keychain.c | 12 | ||||
| -rw-r--r-- | lib/keychain.h | 6 | ||||
| -rw-r--r-- | lib/log.c | 27 | ||||
| -rw-r--r-- | lib/log_int.h | 2 | ||||
| -rw-r--r-- | lib/md5.h | 2 | ||||
| -rw-r--r-- | lib/mpls.h | 7 | ||||
| -rw-r--r-- | lib/network.c | 10 | ||||
| -rw-r--r-- | lib/network.h | 4 | ||||
| -rw-r--r-- | lib/nexthop.c | 2 | ||||
| -rw-r--r-- | lib/nexthop.h | 4 | ||||
| -rw-r--r-- | lib/ns.h | 2 | ||||
| -rw-r--r-- | lib/pid_output.c | 3 | ||||
| -rw-r--r-- | lib/plist.c | 14 | ||||
| -rw-r--r-- | lib/plist.h | 12 | ||||
| -rw-r--r-- | lib/prefix.c | 54 | ||||
| -rw-r--r-- | lib/prefix.h | 66 | ||||
| -rw-r--r-- | lib/sigevent.c | 6 | ||||
| -rw-r--r-- | lib/smux.c | 194 | ||||
| -rw-r--r-- | lib/smux.h | 6 | ||||
| -rw-r--r-- | lib/snmp.c | 8 | ||||
| -rw-r--r-- | lib/sockopt.c | 10 | ||||
| -rw-r--r-- | lib/sockopt.h | 2 | ||||
| -rw-r--r-- | lib/sockunion.c | 14 | ||||
| -rw-r--r-- | lib/sockunion.h | 4 | ||||
| -rw-r--r-- | lib/stream.c | 192 | ||||
| -rw-r--r-- | lib/stream.h | 44 | ||||
| -rw-r--r-- | lib/table.c | 18 | ||||
| -rw-r--r-- | lib/thread.c | 2 | ||||
| -rw-r--r-- | lib/vlan.h | 2 | ||||
| -rw-r--r-- | lib/vrf.c | 17 | ||||
| -rw-r--r-- | lib/vrf.h | 2 | ||||
| -rw-r--r-- | lib/vty.c | 10 | ||||
| -rw-r--r-- | lib/vxlan.h | 2 | ||||
| -rw-r--r-- | lib/workqueue.h | 2 | ||||
| -rw-r--r-- | lib/zclient.c | 92 | ||||
| -rw-r--r-- | lib/zclient.h | 94 | ||||
| -rw-r--r-- | lib/zebra.h | 10 | 
53 files changed, 600 insertions, 583 deletions
diff --git a/lib/agentx.c b/lib/agentx.c index f8845f1461..302bbf0a42 100644 --- a/lib/agentx.c +++ b/lib/agentx.c @@ -230,7 +230,7 @@ int smux_trap(struct variable *vp, size_t vp_len, const oid *ename,  	      size_t enamelen, const oid *name, size_t namelen,  	      const oid *iname, size_t inamelen,  	      const struct trap_object *trapobj, size_t trapobjlen, -	      u_char sptrap) +	      uint8_t sptrap)  {  	oid objid_snmptrap[] = {1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0};  	size_t objid_snmptrap_len = sizeof objid_snmptrap / sizeof(oid); @@ -248,7 +248,7 @@ int smux_trap(struct variable *vp, size_t vp_len, const oid *ename,  	notification_oid_len = enamelen + 1;  	snmp_varlist_add_variable(¬ification_vars, objid_snmptrap,  				  objid_snmptrap_len, ASN_OBJECT_ID, -				  (u_char *)notification_oid, +				  (uint8_t *)notification_oid,  				  notification_oid_len * sizeof(oid));  	/* Provided bindings */ @@ -256,7 +256,7 @@ int smux_trap(struct variable *vp, size_t vp_len, const oid *ename,  		unsigned int j;  		oid oid[MAX_OID_LEN];  		size_t oid_len, onamelen; -		u_char *val; +		uint8_t *val;  		size_t val_len;  		WriteMethod *wm = NULL;  		struct variable cvp; @@ -84,8 +84,8 @@ void bfd_info_free(struct bfd_info **bfd_info)   * bfd_validate_param - Validate the BFD paramter information.   */  int bfd_validate_param(struct vty *vty, const char *dm_str, const char *rx_str, -		       const char *tx_str, u_int8_t *dm_val, u_int32_t *rx_val, -		       u_int32_t *tx_val) +		       const char *tx_str, uint8_t *dm_val, uint32_t *rx_val, +		       uint32_t *tx_val)  {  	*dm_val = strtoul(dm_str, NULL, 10);  	*rx_val = strtoul(rx_str, NULL, 10); @@ -96,9 +96,8 @@ int bfd_validate_param(struct vty *vty, const char *dm_str, const char *rx_str,  /*   * bfd_set_param - Set the configured BFD paramter values   */ -void bfd_set_param(struct bfd_info **bfd_info, u_int32_t min_rx, -		   u_int32_t min_tx, u_int8_t detect_mult, int defaults, -		   int *command) +void bfd_set_param(struct bfd_info **bfd_info, uint32_t min_rx, uint32_t min_tx, +		   uint8_t detect_mult, int defaults, int *command)  {  	if (!*bfd_info) {  		*bfd_info = bfd_info_create(); @@ -343,7 +342,7 @@ static void bfd_last_update(time_t last_update, char *buf, size_t len)   * bfd_show_param - Show the BFD parameter information.   */  void bfd_show_param(struct vty *vty, struct bfd_info *bfd_info, int bfd_tag, -		    int extra_space, u_char use_json, json_object *json_obj) +		    int extra_space, uint8_t use_json, json_object *json_obj)  {  	json_object *json_bfd = NULL; @@ -379,7 +378,7 @@ void bfd_show_param(struct vty *vty, struct bfd_info *bfd_info, int bfd_tag,   * bfd_show_status - Show the BFD status information.   */  static void bfd_show_status(struct vty *vty, struct bfd_info *bfd_info, -			    int bfd_tag, int extra_space, u_char use_json, +			    int bfd_tag, int extra_space, uint8_t use_json,  			    json_object *json_bfd)  {  	char time_buf[32]; @@ -403,7 +402,7 @@ static void bfd_show_status(struct vty *vty, struct bfd_info *bfd_info,   * bfd_show_info - Show the BFD information.   */  void bfd_show_info(struct vty *vty, struct bfd_info *bfd_info, int multihop, -		   int extra_space, u_char use_json, json_object *json_obj) +		   int extra_space, uint8_t use_json, json_object *json_obj)  {  	json_object *json_bfd = NULL; @@ -37,7 +37,7 @@  #define BFD_GBL_FLAG_IN_SHUTDOWN (1 << 0) /* The daemon in shutdown */  struct bfd_gbl { -	u_int16_t flags; +	uint16_t flags;  };  #define BFD_FLAG_PARAM_CFG (1 << 0) /* parameters have been configured */ @@ -55,12 +55,12 @@ enum bfd_sess_type {  };  struct bfd_info { -	u_int16_t flags; -	u_int8_t detect_mult; -	u_int32_t desired_min_tx; -	u_int32_t required_min_rx; +	uint16_t flags; +	uint8_t detect_mult; +	uint32_t desired_min_tx; +	uint32_t required_min_rx;  	time_t last_update; -	u_int8_t status; +	uint8_t status;  	enum bfd_sess_type type;  }; @@ -70,11 +70,11 @@ extern void bfd_info_free(struct bfd_info **bfd_info);  extern int bfd_validate_param(struct vty *vty, const char *dm_str,  			      const char *rx_str, const char *tx_str, -			      u_int8_t *dm_val, u_int32_t *rx_val, -			      u_int32_t *tx_val); +			      uint8_t *dm_val, uint32_t *rx_val, +			      uint32_t *tx_val); -extern void bfd_set_param(struct bfd_info **bfd_info, u_int32_t min_rx, -			  u_int32_t min_tx, u_int8_t detect_mult, int defaults, +extern void bfd_set_param(struct bfd_info **bfd_info, uint32_t min_rx, +			  uint32_t min_tx, uint8_t detect_mult, int defaults,  			  int *command);  extern void bfd_peer_sendmsg(struct zclient *zclient, struct bfd_info *bfd_info,  			     int family, void *dst_ip, void *src_ip, @@ -90,11 +90,11 @@ extern struct interface *bfd_get_peer_info(struct stream *s, struct prefix *dp,  const char *bfd_get_status_str(int status);  extern void bfd_show_param(struct vty *vty, struct bfd_info *bfd_info, -			   int bfd_tag, int extra_space, u_char use_json, +			   int bfd_tag, int extra_space, uint8_t use_json,  			   json_object *json_obj);  extern void bfd_show_info(struct vty *vty, struct bfd_info *bfd_info, -			  int multihop, int extra_space, u_char use_json, +			  int multihop, int extra_space, uint8_t use_json,  			  json_object *json_obj);  extern void bfd_client_sendmsg(struct zclient *zclient, int command); diff --git a/lib/buffer.c b/lib/buffer.c index 191fbf875a..03202f1253 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -174,7 +174,7 @@ void buffer_put(struct buffer *b, const void *p, size_t size)  }  /* Insert character into the buffer. */ -void buffer_putc(struct buffer *b, u_char c) +void buffer_putc(struct buffer *b, uint8_t c)  {  	buffer_put(b, &c, 1);  } @@ -336,7 +336,7 @@ buffer_status_t buffer_flush_window(struct buffer *b, int fd, int width,  					"%s: growing iov array to %d; "  					"width %d, height %d, size %lu",  					__func__, iov_alloc, width, height, -					(u_long)b->size); +					(unsigned long)b->size);  				iov = XREALLOC(MTYPE_TMP, iov,  					       iov_alloc * sizeof(*iov));  			} else { @@ -456,7 +456,7 @@ in one shot. */  			zlog_err(  				"%s: corruption detected: buffer queue empty, "  				"but written is %lu", -				__func__, (u_long)written); +				__func__, (unsigned long)written);  			break;  		}  		if (written < d->cp - d->sp) { diff --git a/lib/buffer.h b/lib/buffer.h index 130c677da8..0c945a2acf 100644 --- a/lib/buffer.h +++ b/lib/buffer.h @@ -37,7 +37,7 @@ extern void buffer_free(struct buffer *);  /* Add the given data to the end of the buffer. */  extern void buffer_put(struct buffer *, const void *, size_t);  /* Add a single character to the end of the buffer. */ -extern void buffer_putc(struct buffer *, u_char); +extern void buffer_putc(struct buffer *, uint8_t);  /* Add a NUL-terminated string to the end of the buffer. */  extern void buffer_putstr(struct buffer *, const char *);  /* Add given data, inline-expanding \n to \r\n */ diff --git a/lib/checksum.c b/lib/checksum.c index 8eef73e243..18e3850474 100644 --- a/lib/checksum.c +++ b/lib/checksum.c @@ -12,10 +12,10 @@  int /* return checksum in low-order 16 bits */  	in_cksum(void *parg, int nbytes)  { -	u_short *ptr = parg; +	unsigned short *ptr = parg;  	register long sum; /* assumes long == 32 bits */ -	u_short oddbyte; -	register u_short answer; /* assumes u_short == 16 bits */ +	unsigned short oddbyte; +	register unsigned short answer; /* assumes unsigned short == 16 bits */  	/*  	 * Our algorithm is simple, using a 32-bit accumulator (sum), @@ -32,7 +32,7 @@ int /* return checksum in low-order 16 bits */  	/* mop up an odd byte, if necessary */  	if (nbytes == 1) {  		oddbyte = 0; /* make sure top half is zero */ -		*((u_char *)&oddbyte) = *(u_char *)ptr; /* one byte only */ +		*((uint8_t *)&oddbyte) = *(uint8_t *)ptr; /* one byte only */  		sum += oddbyte;  	} @@ -53,13 +53,13 @@ int /* return checksum in low-order 16 bits */     index required in the specification ISO 8473, Annex C.1 */  /* calling with offset == FLETCHER_CHECKSUM_VALIDATE will validate the checksum     without modifying the buffer; a valid checksum returns 0 */ -u_int16_t fletcher_checksum(u_char *buffer, const size_t len, -			    const uint16_t offset) +uint16_t fletcher_checksum(uint8_t *buffer, const size_t len, +			   const uint16_t offset)  { -	u_int8_t *p; +	uint8_t *p;  	int x, y, c0, c1; -	u_int16_t checksum = 0; -	u_int16_t *csum; +	uint16_t checksum = 0; +	uint16_t *csum;  	size_t partial_len, i, left = len;  	if (offset != FLETCHER_CHECKSUM_VALIDATE) @@ -67,7 +67,7 @@ u_int16_t fletcher_checksum(u_char *buffer, const size_t len,  	{  		assert(offset  		       < (len - 1)); /* account for two bytes of checksum */ -		csum = (u_int16_t *)(buffer + offset); +		csum = (uint16_t *)(buffer + offset);  		*(csum) = 0;  	} diff --git a/lib/checksum.h b/lib/checksum.h index aecaaf6bcc..c2764e35fb 100644 --- a/lib/checksum.h +++ b/lib/checksum.h @@ -1,4 +1,4 @@  extern int in_cksum(void *, int);  #define FLETCHER_CHECKSUM_VALIDATE 0xffff -extern u_int16_t fletcher_checksum(u_char *, const size_t len, -				   const uint16_t offset); +extern uint16_t fletcher_checksum(uint8_t *, const size_t len, +				  const uint16_t offset); diff --git a/lib/command_graph.c b/lib/command_graph.c index f00b126536..3e8261cb3e 100644 --- a/lib/command_graph.c +++ b/lib/command_graph.c @@ -32,7 +32,7 @@ DEFINE_MTYPE_STATIC(LIB, CMD_TEXT, "Command Token Help")  DEFINE_MTYPE(LIB, CMD_ARG, "Command Argument")  DEFINE_MTYPE_STATIC(LIB, CMD_VAR, "Command Argument Name") -struct cmd_token *cmd_token_new(enum cmd_token_type type, u_char attr, +struct cmd_token *cmd_token_new(enum cmd_token_type type, uint8_t attr,  				const char *text, const char *desc)  {  	struct cmd_token *token = @@ -198,7 +198,7 @@ static bool cmd_nodes_equal(struct graph_node *ga, struct graph_node *gb)  }  static void cmd_fork_bump_attr(struct graph_node *gn, struct graph_node *join, -			       u_char attr) +			       uint8_t attr)  {  	size_t i;  	struct cmd_token *tok = gn->data; diff --git a/lib/filter.c b/lib/filter.c index ac73482216..5f391aa767 100644 --- a/lib/filter.c +++ b/lib/filter.c @@ -161,8 +161,8 @@ static int filter_match_cisco(struct filter *mfilter, struct prefix *p)  {  	struct filter_cisco *filter;  	struct in_addr mask; -	u_int32_t check_addr; -	u_int32_t check_mask; +	uint32_t check_addr; +	uint32_t check_mask;  	filter = &mfilter->u.cfilter;  	check_addr = p->u.prefix4.s_addr & ~filter->addr_mask.s_addr; @@ -176,20 +176,20 @@ struct if_stats {  /* Link Parameters for Traffic Engineering */  struct if_link_params { -	u_int32_t lp_status; /* Status of Link Parameters: */ -	u_int32_t te_metric; /* Traffic Engineering metric */ +	uint32_t lp_status; /* Status of Link Parameters: */ +	uint32_t te_metric; /* Traffic Engineering metric */  	float default_bw;  	float max_bw;			/* Maximum Bandwidth */  	float max_rsv_bw;		/* Maximum Reservable Bandwidth */  	float unrsv_bw[MAX_CLASS_TYPE]; /* Unreserved Bandwidth per Class Type  					   (8) */ -	u_int32_t admin_grp;		/* Administrative group */ -	u_int32_t rmt_as;		/* Remote AS number */ +	uint32_t admin_grp;		/* Administrative group */ +	uint32_t rmt_as;		/* Remote AS number */  	struct in_addr rmt_ip;		/* Remote IP address */ -	u_int32_t av_delay;		/* Link Average Delay */ -	u_int32_t min_delay;		/* Link Min Delay */ -	u_int32_t max_delay;		/* Link Max Delay */ -	u_int32_t delay_var;		/* Link Delay Variation */ +	uint32_t av_delay;		/* Link Average Delay */ +	uint32_t min_delay;		/* Link Min Delay */ +	uint32_t max_delay;		/* Link Max Delay */ +	uint32_t delay_var;		/* Link Delay Variation */  	float pkt_loss;			/* Link Packet Loss */  	float res_bw;			/* Residual Bandwidth */  	float ava_bw;			/* Available Bandwidth */ @@ -224,7 +224,7 @@ struct interface {  #define IFINDEX_INTERNAL	0  	/* Zebra internal interface status */ -	u_char status; +	uint8_t status;  #define ZEBRA_INTERFACE_ACTIVE     (1 << 0)  #define ZEBRA_INTERFACE_SUB        (1 << 1)  #define ZEBRA_INTERFACE_LINKDETECTION (1 << 2) @@ -247,7 +247,7 @@ struct interface {  	/* Link-layer information and hardware address */  	enum zebra_link_type ll_type; -	u_char hw_addr[INTERFACE_HWADDR_MAX]; +	uint8_t hw_addr[INTERFACE_HWADDR_MAX];  	int hw_addr_len;  	/* interface bandwidth, kbits */ @@ -347,7 +347,7 @@ struct connected {  	struct interface *ifp;  	/* Flags for configuration. */ -	u_char conf; +	uint8_t conf;  #define ZEBRA_IFC_REAL         (1 << 0)  #define ZEBRA_IFC_CONFIGURED   (1 << 1)  #define ZEBRA_IFC_QUEUED       (1 << 2) @@ -367,7 +367,7 @@ struct connected {  	 */  	/* Flags for connected address. */ -	u_char flags; +	uint8_t flags;  #define ZEBRA_IFA_SECONDARY    (1 << 0)  #define ZEBRA_IFA_PEER         (1 << 1)  #define ZEBRA_IFA_UNNUMBERED   (1 << 2) diff --git a/lib/imsg-buffer.c b/lib/imsg-buffer.c index ba1e26820b..b83f1f76f2 100644 --- a/lib/imsg-buffer.c +++ b/lib/imsg-buffer.c @@ -59,7 +59,7 @@ struct ibuf *ibuf_dynamic(size_t len, size_t max)  int ibuf_realloc(struct ibuf *buf, size_t len)  { -	u_char *b; +	uint8_t *b;  	/* on static buffers max is eq size and so the following fails */  	if (buf->wpos + len > buf->max) { diff --git a/lib/imsg.c b/lib/imsg.c index 1c2f480aab..0ea1dd6302 100644 --- a/lib/imsg.c +++ b/lib/imsg.c @@ -193,8 +193,8 @@ ssize_t imsg_get(struct imsgbuf *ibuf, struct imsg *imsg)  	return (datalen + IMSG_HEADER_SIZE);  } -int imsg_compose(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid, -		 pid_t pid, int fd, const void *data, u_int16_t datalen) +int imsg_compose(struct imsgbuf *ibuf, uint32_t type, uint32_t peerid, +		 pid_t pid, int fd, const void *data, uint16_t datalen)  {  	struct ibuf *wbuf; @@ -211,7 +211,7 @@ int imsg_compose(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,  	return (1);  } -int imsg_composev(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid, +int imsg_composev(struct imsgbuf *ibuf, uint32_t type, uint32_t peerid,  		  pid_t pid, int fd, const struct iovec *iov, int iovcnt)  {  	struct ibuf *wbuf; @@ -235,8 +235,8 @@ int imsg_composev(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,  }  /* ARGSUSED */ -struct ibuf *imsg_create(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid, -			 pid_t pid, u_int16_t datalen) +struct ibuf *imsg_create(struct imsgbuf *ibuf, uint32_t type, uint32_t peerid, +			 pid_t pid, uint16_t datalen)  {  	struct ibuf *wbuf;  	struct imsg_hdr hdr; @@ -261,7 +261,7 @@ struct ibuf *imsg_create(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,  	return (wbuf);  } -int imsg_add(struct ibuf *msg, const void *data, u_int16_t datalen) +int imsg_add(struct ibuf *msg, const void *data, uint16_t datalen)  {  	if (datalen)  		if (ibuf_add(msg, data, datalen) == -1) { @@ -281,7 +281,7 @@ void imsg_close(struct imsgbuf *ibuf, struct ibuf *msg)  	if (msg->fd != -1)  		hdr->flags |= IMSGF_HASFD; -	hdr->len = (u_int16_t)msg->wpos; +	hdr->len = (uint16_t)msg->wpos;  	ibuf_close(&ibuf->w, msg);  } diff --git a/lib/imsg.h b/lib/imsg.h index ddaf71344e..eed7074e4a 100644 --- a/lib/imsg.h +++ b/lib/imsg.h @@ -27,7 +27,7 @@  struct ibuf {  	TAILQ_ENTRY(ibuf) entry; -	u_char *buf; +	uint8_t *buf;  	size_t size;  	size_t max;  	size_t wpos; @@ -37,13 +37,13 @@ struct ibuf {  struct msgbuf {  	TAILQ_HEAD(, ibuf) bufs; -	u_int32_t queued; +	uint32_t queued;  	int fd;  };  struct ibuf_read { -	u_char buf[IBUF_READ_SIZE]; -	u_char *rptr; +	uint8_t buf[IBUF_READ_SIZE]; +	uint8_t *rptr;  	size_t wpos;  }; @@ -63,11 +63,11 @@ struct imsgbuf {  #define IMSGF_HASFD	1  struct imsg_hdr { -	u_int32_t type; -	u_int16_t len; -	u_int16_t flags; -	u_int32_t peerid; -	u_int32_t pid; +	uint32_t type; +	uint16_t len; +	uint16_t flags; +	uint32_t peerid; +	uint32_t pid;  };  struct imsg { @@ -97,13 +97,12 @@ void msgbuf_drain(struct msgbuf *, size_t);  void imsg_init(struct imsgbuf *, int);  ssize_t imsg_read(struct imsgbuf *);  ssize_t imsg_get(struct imsgbuf *, struct imsg *); -int imsg_compose(struct imsgbuf *, u_int32_t, u_int32_t, pid_t, int, -		 const void *, u_int16_t); -int imsg_composev(struct imsgbuf *, u_int32_t, u_int32_t, pid_t, int, +int imsg_compose(struct imsgbuf *, uint32_t, uint32_t, pid_t, int, const void *, +		 uint16_t); +int imsg_composev(struct imsgbuf *, uint32_t, uint32_t, pid_t, int,  		  const struct iovec *, int); -struct ibuf *imsg_create(struct imsgbuf *, u_int32_t, u_int32_t, pid_t, -			 u_int16_t); -int imsg_add(struct ibuf *, const void *, u_int16_t); +struct ibuf *imsg_create(struct imsgbuf *, uint32_t, uint32_t, pid_t, uint16_t); +int imsg_add(struct ibuf *, const void *, uint16_t);  void imsg_close(struct imsgbuf *, struct ibuf *);  void imsg_free(struct imsg *);  int imsg_flush(struct imsgbuf *); diff --git a/lib/ipaddr.h b/lib/ipaddr.h index 44bde45add..33591cb4e7 100644 --- a/lib/ipaddr.h +++ b/lib/ipaddr.h @@ -37,7 +37,7 @@ enum ipaddr_type_t {  struct ipaddr {  	enum ipaddr_type_t ipa_type;  	union { -		u_char addr; +		uint8_t addr;  		struct in_addr _v4_addr;  		struct in6_addr _v6_addr;  	} ip; @@ -95,7 +95,7 @@ static inline char *ipaddr2str(struct ipaddr *ip, char *buf, int size)  static inline void ipv4_to_ipv4_mapped_ipv6(struct in6_addr *in6,  					    struct in_addr in)  { -	u_int32_t addr_type = htonl(0xFFFF); +	uint32_t addr_type = htonl(0xFFFF);  	memset(in6, 0, sizeof(struct in6_addr));  	memcpy((char *)in6 + 8, &addr_type, sizeof(addr_type)); diff --git a/lib/jhash.c b/lib/jhash.c index b943997b1b..cb6946f37e 100644 --- a/lib/jhash.c +++ b/lib/jhash.c @@ -59,22 +59,22 @@   * of bytes.  No alignment or length assumptions are made about   * the input key.   */ -u_int32_t jhash(const void *key, u_int32_t length, u_int32_t initval) +uint32_t jhash(const void *key, uint32_t length, uint32_t initval)  { -	u_int32_t a, b, c, len; -	const u_int8_t *k = key; +	uint32_t a, b, c, len; +	const uint8_t *k = key;  	len = length;  	a = b = JHASH_GOLDEN_RATIO;  	c = initval;  	while (len >= 12) { -		a += (k[0] + ((u_int32_t)k[1] << 8) + ((u_int32_t)k[2] << 16) -		      + ((u_int32_t)k[3] << 24)); -		b += (k[4] + ((u_int32_t)k[5] << 8) + ((u_int32_t)k[6] << 16) -		      + ((u_int32_t)k[7] << 24)); -		c += (k[8] + ((u_int32_t)k[9] << 8) + ((u_int32_t)k[10] << 16) -		      + ((u_int32_t)k[11] << 24)); +		a += (k[0] + ((uint32_t)k[1] << 8) + ((uint32_t)k[2] << 16) +		      + ((uint32_t)k[3] << 24)); +		b += (k[4] + ((uint32_t)k[5] << 8) + ((uint32_t)k[6] << 16) +		      + ((uint32_t)k[7] << 24)); +		c += (k[8] + ((uint32_t)k[9] << 8) + ((uint32_t)k[10] << 16) +		      + ((uint32_t)k[11] << 24));  		__jhash_mix(a, b, c); @@ -85,34 +85,34 @@ u_int32_t jhash(const void *key, u_int32_t length, u_int32_t initval)  	c += length;  	switch (len) {  	case 11: -		c += ((u_int32_t)k[10] << 24); +		c += ((uint32_t)k[10] << 24);  	/* fallthru */  	case 10: -		c += ((u_int32_t)k[9] << 16); +		c += ((uint32_t)k[9] << 16);  	/* fallthru */  	case 9: -		c += ((u_int32_t)k[8] << 8); +		c += ((uint32_t)k[8] << 8);  	/* fallthru */  	case 8: -		b += ((u_int32_t)k[7] << 24); +		b += ((uint32_t)k[7] << 24);  	/* fallthru */  	case 7: -		b += ((u_int32_t)k[6] << 16); +		b += ((uint32_t)k[6] << 16);  	/* fallthru */  	case 6: -		b += ((u_int32_t)k[5] << 8); +		b += ((uint32_t)k[5] << 8);  	/* fallthru */  	case 5:  		b += k[4];  	/* fallthru */  	case 4: -		a += ((u_int32_t)k[3] << 24); +		a += ((uint32_t)k[3] << 24);  	/* fallthru */  	case 3: -		a += ((u_int32_t)k[2] << 16); +		a += ((uint32_t)k[2] << 16);  	/* fallthru */  	case 2: -		a += ((u_int32_t)k[1] << 8); +		a += ((uint32_t)k[1] << 8);  	/* fallthru */  	case 1:  		a += k[0]; @@ -123,12 +123,12 @@ u_int32_t jhash(const void *key, u_int32_t length, u_int32_t initval)  	return c;  } -/* A special optimized version that handles 1 or more of u_int32_ts. - * The length parameter here is the number of u_int32_ts in the key. +/* A special optimized version that handles 1 or more of uint32_ts. + * The length parameter here is the number of uint32_ts in the key.   */ -u_int32_t jhash2(const u_int32_t *k, u_int32_t length, u_int32_t initval) +uint32_t jhash2(const uint32_t *k, uint32_t length, uint32_t initval)  { -	u_int32_t a, b, c, len; +	uint32_t a, b, c, len;  	a = b = JHASH_GOLDEN_RATIO;  	c = initval; @@ -165,7 +165,7 @@ u_int32_t jhash2(const u_int32_t *k, u_int32_t length, u_int32_t initval)   * NOTE: In partilar the "c += length; __jhash_mix(a,b,c);" normally   *       done at the end is not done here.   */ -u_int32_t jhash_3words(u_int32_t a, u_int32_t b, u_int32_t c, u_int32_t initval) +uint32_t jhash_3words(uint32_t a, uint32_t b, uint32_t c, uint32_t initval)  {  	a += JHASH_GOLDEN_RATIO;  	b += JHASH_GOLDEN_RATIO; @@ -176,12 +176,12 @@ u_int32_t jhash_3words(u_int32_t a, u_int32_t b, u_int32_t c, u_int32_t initval)  	return c;  } -u_int32_t jhash_2words(u_int32_t a, u_int32_t b, u_int32_t initval) +uint32_t jhash_2words(uint32_t a, uint32_t b, uint32_t initval)  {  	return jhash_3words(a, b, 0, initval);  } -u_int32_t jhash_1word(u_int32_t a, u_int32_t initval) +uint32_t jhash_1word(uint32_t a, uint32_t initval)  {  	return jhash_3words(a, 0, 0, initval);  } diff --git a/lib/jhash.h b/lib/jhash.h index 74ce6a3233..f8ab4209a8 100644 --- a/lib/jhash.h +++ b/lib/jhash.h @@ -24,13 +24,12 @@   * of bytes.  No alignment or length assumptions are made about   * the input key.   */ -extern u_int32_t jhash(const void *key, u_int32_t length, u_int32_t initval); +extern uint32_t jhash(const void *key, uint32_t length, uint32_t initval); -/* A special optimized version that handles 1 or more of u_int32_ts. - * The length parameter here is the number of u_int32_ts in the key. +/* A special optimized version that handles 1 or more of uint32_ts. + * The length parameter here is the number of uint32_ts in the key.   */ -extern u_int32_t jhash2(const u_int32_t *k, u_int32_t length, -			u_int32_t initval); +extern uint32_t jhash2(const uint32_t *k, uint32_t length, uint32_t initval);  /* A special ultra-optimized versions that knows they are hashing exactly   * 3, 2 or 1 word(s). @@ -38,9 +37,9 @@ extern u_int32_t jhash2(const u_int32_t *k, u_int32_t length,   * NOTE: In partilar the "c += length; __jhash_mix(a,b,c);" normally   *       done at the end is not done here.   */ -extern u_int32_t jhash_3words(u_int32_t a, u_int32_t b, u_int32_t c, -			      u_int32_t initval); -extern u_int32_t jhash_2words(u_int32_t a, u_int32_t b, u_int32_t initval); -extern u_int32_t jhash_1word(u_int32_t a, u_int32_t initval); +extern uint32_t jhash_3words(uint32_t a, uint32_t b, uint32_t c, +			     uint32_t initval); +extern uint32_t jhash_2words(uint32_t a, uint32_t b, uint32_t initval); +extern uint32_t jhash_1word(uint32_t a, uint32_t initval);  #endif /* _QUAGGA_JHASH_H */ diff --git a/lib/keychain.c b/lib/keychain.c index 39807cc7ce..c3e1a6d3c4 100644 --- a/lib/keychain.c +++ b/lib/keychain.c @@ -124,7 +124,7 @@ static void keychain_delete(struct keychain *keychain)  	keychain_free(keychain);  } -static struct key *key_lookup(const struct keychain *keychain, u_int32_t index) +static struct key *key_lookup(const struct keychain *keychain, uint32_t index)  {  	struct listnode *node;  	struct key *key; @@ -137,7 +137,7 @@ static struct key *key_lookup(const struct keychain *keychain, u_int32_t index)  }  struct key *key_lookup_for_accept(const struct keychain *keychain, -				  u_int32_t index) +				  uint32_t index)  {  	struct listnode *node;  	struct key *key; @@ -197,7 +197,7 @@ struct key *key_lookup_for_send(const struct keychain *keychain)  	return NULL;  } -static struct key *key_get(const struct keychain *keychain, u_int32_t index) +static struct key *key_get(const struct keychain *keychain, uint32_t index)  {  	struct key *key; @@ -270,7 +270,7 @@ DEFUN_NOSH (key,  	int idx_number = 1;  	VTY_DECLVAR_CONTEXT(keychain, keychain);  	struct key *key; -	u_int32_t index; +	uint32_t index;  	index = strtoul(argv[idx_number]->arg, NULL, 10);  	key = key_get(keychain, index); @@ -289,7 +289,7 @@ DEFUN (no_key,  	int idx_number = 2;  	VTY_DECLVAR_CONTEXT(keychain, keychain);  	struct key *key; -	u_int32_t index; +	uint32_t index;  	index = strtoul(argv[idx_number]->arg, NULL, 10);  	key = key_lookup(keychain, index); @@ -469,7 +469,7 @@ static int key_lifetime_duration_set(struct vty *vty, struct key_range *krange,  				     const char *duration_str)  {  	time_t time_start; -	u_int32_t duration; +	uint32_t duration;  	time_start = key_str2time(stime_str, sday_str, smonth_str, syear_str);  	if (time_start < 0) { diff --git a/lib/keychain.h b/lib/keychain.h index ab016f35c4..49da9ba459 100644 --- a/lib/keychain.h +++ b/lib/keychain.h @@ -36,11 +36,11 @@ struct key_range {  	time_t start;  	time_t end; -	u_char duration; +	uint8_t duration;  };  struct key { -	u_int32_t index; +	uint32_t index;  	char *string; @@ -53,7 +53,7 @@ DECLARE_QOBJ_TYPE(key)  extern void keychain_init(void);  extern struct keychain *keychain_lookup(const char *); -extern struct key *key_lookup_for_accept(const struct keychain *, u_int32_t); +extern struct key *key_lookup_for_accept(const struct keychain *, uint32_t);  extern struct key *key_match_for_accept(const struct keychain *, const char *);  extern struct key *key_lookup_for_send(const struct keychain *); @@ -296,7 +296,7 @@ static char *str_append(char *dst, int len, const char *src)  	return dst;  } -static char *num_append(char *s, int len, u_long x) +static char *num_append(char *s, int len, unsigned long x)  {  	char buf[30];  	char *t; @@ -312,7 +312,7 @@ static char *num_append(char *s, int len, u_long x)  }  #if defined(SA_SIGINFO) || defined(HAVE_STACK_TRACE) -static char *hex_append(char *s, int len, u_long x) +static char *hex_append(char *s, int len, unsigned long x)  {  	char buf[30];  	char *t; @@ -321,7 +321,7 @@ static char *hex_append(char *s, int len, u_long x)  		return str_append(s, len, "0");  	*(t = &buf[sizeof(buf) - 1]) = '\0';  	while (x && (t > buf)) { -		u_int cc = (x % 16); +		unsigned int cc = (x % 16);  		*--t = ((cc < 10) ? ('0' + cc) : ('a' + cc - 10));  		x /= 16;  	} @@ -446,10 +446,10 @@ void zlog_signal(int signo, const char *action  	s = num_append(LOC, now);  #ifdef SA_SIGINFO  	s = str_append(LOC, " (si_addr 0x"); -	s = hex_append(LOC, (u_long)(siginfo->si_addr)); +	s = hex_append(LOC, (unsigned long)(siginfo->si_addr));  	if (program_counter) {  		s = str_append(LOC, ", PC 0x"); -		s = hex_append(LOC, (u_long)program_counter); +		s = hex_append(LOC, (unsigned long)program_counter);  	}  	s = str_append(LOC, "); ");  #else  /* SA_SIGINFO */ @@ -596,7 +596,8 @@ void zlog_backtrace_sigsafe(int priority, void *program_counter)  					s = str_append(LOC, "[bt ");  					s = num_append(LOC, i);  					s = str_append(LOC, "] 0x"); -					s = hex_append(LOC, (u_long)(array[i])); +					s = hex_append( +						LOC, (unsigned long)(array[i]));  				}  				*s = '\0';  				if (priority @@ -720,11 +721,11 @@ void memory_oom(size_t size, const char *name)  }  /* Open log stream */ -void openzlog(const char *progname, const char *protoname, u_short instance, -	      int syslog_flags, int syslog_facility) +void openzlog(const char *progname, const char *protoname, +	      unsigned short instance, int syslog_flags, int syslog_facility)  {  	struct zlog *zl; -	u_int i; +	unsigned int i;  	zl = XCALLOC(MTYPE_ZLOG, sizeof(struct zlog)); @@ -969,9 +970,9 @@ static const struct zebra_desc_table command_types[] = {  static const struct zebra_desc_table unknown = {0, "unknown", '?'}; -static const struct zebra_desc_table *zroute_lookup(u_int zroute) +static const struct zebra_desc_table *zroute_lookup(unsigned int zroute)  { -	u_int i; +	unsigned int i;  	if (zroute >= array_size(route_types)) {  		zlog_err("unknown zebra route type: %u", zroute); @@ -992,12 +993,12 @@ static const struct zebra_desc_table *zroute_lookup(u_int zroute)  	return &unknown;  } -const char *zebra_route_string(u_int zroute) +const char *zebra_route_string(unsigned int zroute)  {  	return zroute_lookup(zroute)->string;  } -char zebra_route_char(u_int zroute) +char zebra_route_char(unsigned int zroute)  {  	return zroute_lookup(zroute)->chr;  } diff --git a/lib/log_int.h b/lib/log_int.h index 56823fb971..a7f8be9ae7 100644 --- a/lib/log_int.h +++ b/lib/log_int.h @@ -27,7 +27,7 @@  struct zlog {  	const char *ident; /* daemon name (first arg to openlog) */  	const char *protoname; -	u_short instance; +	unsigned short instance;  	int maxlvl[ZLOG_NUM_DESTS]; /* maximum priority to send to associated  				       logging destination */  	int default_lvl;	    /* maxlvl to use if none is specified */ @@ -64,7 +64,7 @@ typedef struct {  } md5_ctxt;  extern void md5_init(md5_ctxt *); -extern void md5_loop(md5_ctxt *, const void *, u_int); +extern void md5_loop(md5_ctxt *, const void *, unsigned int);  extern void md5_pad(md5_ctxt *);  extern void md5_result(uint8_t *, md5_ctxt *); diff --git a/lib/mpls.h b/lib/mpls.h index 1a1819c2c0..4e5c70cf8c 100644 --- a/lib/mpls.h +++ b/lib/mpls.h @@ -124,8 +124,8 @@ enum lsp_types_t {  /* Encode a label stack entry from fields; convert to network byte-order as   * the Netlink interface expects MPLS labels to be in this format.   */ -static inline mpls_lse_t mpls_lse_encode(mpls_label_t label, u_int32_t ttl, -					 u_int32_t exp, u_int32_t bos) +static inline mpls_lse_t mpls_lse_encode(mpls_label_t label, uint32_t ttl, +					 uint32_t exp, uint32_t bos)  {  	mpls_lse_t lse;  	lse = htonl((label << MPLS_LS_LABEL_SHIFT) | (exp << MPLS_LS_EXP_SHIFT) @@ -139,8 +139,7 @@ static inline mpls_lse_t mpls_lse_encode(mpls_label_t label, u_int32_t ttl,   * Netlink interface.   */  static inline void mpls_lse_decode(mpls_lse_t lse, mpls_label_t *label, -				   u_int32_t *ttl, u_int32_t *exp, -				   u_int32_t *bos) +				   uint32_t *ttl, uint32_t *exp, uint32_t *bos)  {  	mpls_lse_t local_lse; diff --git a/lib/network.c b/lib/network.c index 3f72b7141e..6d3350ad49 100644 --- a/lib/network.c +++ b/lib/network.c @@ -24,7 +24,7 @@  #include "network.h"  /* Read nbytes from fd and store into ptr. */ -int readn(int fd, u_char *ptr, int nbytes) +int readn(int fd, uint8_t *ptr, int nbytes)  {  	int nleft;  	int nread; @@ -47,7 +47,7 @@ int readn(int fd, u_char *ptr, int nbytes)  }  /* Write nbytes from ptr to fd. */ -int writen(int fd, const u_char *ptr, int nbytes) +int writen(int fd, const uint8_t *ptr, int nbytes)  {  	int nleft;  	int nwritten; @@ -105,12 +105,12 @@ int set_cloexec(int fd)  float htonf(float host)  { -	u_int32_t lu1, lu2; +	uint32_t lu1, lu2;  	float convert; -	memcpy(&lu1, &host, sizeof(u_int32_t)); +	memcpy(&lu1, &host, sizeof(uint32_t));  	lu2 = htonl(lu1); -	memcpy(&convert, &lu2, sizeof(u_int32_t)); +	memcpy(&convert, &lu2, sizeof(uint32_t));  	return convert;  } diff --git a/lib/network.h b/lib/network.h index 4faf992bc5..4703dc9b63 100644 --- a/lib/network.h +++ b/lib/network.h @@ -25,8 +25,8 @@  /* Both readn and writen are deprecated and will be removed.  They are not     suitable for use with non-blocking file descriptors.   */ -extern int readn(int, u_char *, int); -extern int writen(int, const u_char *, int); +extern int readn(int, uint8_t *, int); +extern int writen(int, const uint8_t *, int);  /* Set the file descriptor to use non-blocking I/O.  Returns 0 for success,     -1 on error. */ diff --git a/lib/nexthop.c b/lib/nexthop.c index fb7ccc169e..b1e9582b20 100644 --- a/lib/nexthop.c +++ b/lib/nexthop.c @@ -216,7 +216,7 @@ bool nexthop_same(const struct nexthop *nh1, const struct nexthop *nh2)  /* Update nexthop with label information. */  void nexthop_add_labels(struct nexthop *nexthop, enum lsp_types_t type, -			u_int8_t num_labels, mpls_label_t *label) +			uint8_t num_labels, mpls_label_t *label)  {  	struct mpls_label_stack *nh_label;  	int i; diff --git a/lib/nexthop.h b/lib/nexthop.h index 568243d3a9..036fc5b888 100644 --- a/lib/nexthop.h +++ b/lib/nexthop.h @@ -71,7 +71,7 @@ struct nexthop {  	enum nexthop_types_t type; -	u_char flags; +	uint8_t flags;  #define NEXTHOP_FLAG_ACTIVE     (1 << 0) /* This nexthop is alive. */  #define NEXTHOP_FLAG_FIB        (1 << 1) /* FIB nexthop. */  #define NEXTHOP_FLAG_RECURSIVE  (1 << 2) /* Recursive nexthop. */ @@ -114,7 +114,7 @@ struct nexthop *nexthop_new(void);  void nexthop_free(struct nexthop *nexthop);  void nexthops_free(struct nexthop *nexthop); -void nexthop_add_labels(struct nexthop *, enum lsp_types_t, u_int8_t, +void nexthop_add_labels(struct nexthop *, enum lsp_types_t, uint8_t,  			mpls_label_t *);  void nexthop_del_labels(struct nexthop *); @@ -26,7 +26,7 @@  #include "linklist.h"  #include "vty.h" -typedef u_int32_t ns_id_t; +typedef uint32_t ns_id_t;  /* the default NS ID */  #define NS_UNKNOWN UINT32_MAX diff --git a/lib/pid_output.c b/lib/pid_output.c index 9a7307bc4f..023a166f27 100644 --- a/lib/pid_output.c +++ b/lib/pid_output.c @@ -71,7 +71,8 @@ pid_t pid_output(const char *path)  		else if (ftruncate(fd, pidsize) < 0)  			zlog_err(  				"Could not truncate pid_file %s to %u bytes: %s", -				path, (u_int)pidsize, safe_strerror(errno)); +				path, (unsigned int)pidsize, +				safe_strerror(errno));  	}  	return pid;  } diff --git a/lib/plist.c b/lib/plist.c index 9dd5e561a7..01b55f9f1d 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -1812,8 +1812,8 @@ static int config_write_prefix_afi(afi_t afi, struct vty *vty)  }  struct stream *prefix_bgp_orf_entry(struct stream *s, struct prefix_list *plist, -				    u_char init_flag, u_char permit_flag, -				    u_char deny_flag) +				    uint8_t init_flag, uint8_t permit_flag, +				    uint8_t deny_flag)  {  	struct prefix_list_entry *pentry; @@ -1821,15 +1821,15 @@ struct stream *prefix_bgp_orf_entry(struct stream *s, struct prefix_list *plist,  		return s;  	for (pentry = plist->head; pentry; pentry = pentry->next) { -		u_char flag = init_flag; +		uint8_t flag = init_flag;  		struct prefix *p = &pentry->prefix;  		flag |= (pentry->type == PREFIX_PERMIT ? permit_flag  						       : deny_flag);  		stream_putc(s, flag); -		stream_putl(s, (u_int32_t)pentry->seq); -		stream_putc(s, (u_char)pentry->ge); -		stream_putc(s, (u_char)pentry->le); +		stream_putl(s, (uint32_t)pentry->seq); +		stream_putc(s, (uint8_t)pentry->ge); +		stream_putc(s, (uint8_t)pentry->le);  		stream_put_prefix(s, p);  	} @@ -1893,7 +1893,7 @@ void prefix_bgp_orf_remove_all(afi_t afi, char *name)  /* return prefix count */  int prefix_bgp_show_prefix_list(struct vty *vty, afi_t afi, char *name, -				u_char use_json) +				uint8_t use_json)  {  	struct prefix_list *plist;  	struct prefix_list_entry *pentry; diff --git a/lib/plist.h b/lib/plist.h index 9662f0311b..67e345a485 100644 --- a/lib/plist.h +++ b/lib/plist.h @@ -35,9 +35,9 @@ enum prefix_list_type {  struct prefix_list;  struct orf_prefix { -	u_int32_t seq; -	u_char ge; -	u_char le; +	uint32_t seq; +	uint8_t ge; +	uint8_t le;  	struct prefix p;  }; @@ -67,10 +67,10 @@ prefix_list_apply_which_prefix(struct prefix_list *plist, struct prefix **which,  extern struct prefix_list *prefix_bgp_orf_lookup(afi_t, const char *);  extern struct stream *prefix_bgp_orf_entry(struct stream *, -					   struct prefix_list *, u_char, u_char, -					   u_char); +					   struct prefix_list *, uint8_t, +					   uint8_t, uint8_t);  extern int prefix_bgp_orf_set(char *, afi_t, struct orf_prefix *, int, int);  extern void prefix_bgp_orf_remove_all(afi_t, char *); -extern int prefix_bgp_show_prefix_list(struct vty *, afi_t, char *, u_char); +extern int prefix_bgp_show_prefix_list(struct vty *, afi_t, char *, uint8_t);  #endif /* _QUAGGA_PLIST_H */ diff --git a/lib/prefix.c b/lib/prefix.c index 1344039498..003ce992b4 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -31,8 +31,8 @@  DEFINE_MTYPE_STATIC(LIB, PREFIX, "Prefix")  /* Maskbit. */ -static const u_char maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0, -				 0xf8, 0xfc, 0xfe, 0xff}; +static const uint8_t maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0, +				  0xf8, 0xfc, 0xfe, 0xff};  static const struct in6_addr maskbytes6[] = {  	/* /0   */ {{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -441,7 +441,7 @@ int is_zero_mac(struct ethaddr *mac)  	return 1;  } -unsigned int prefix_bit(const u_char *prefix, const u_char prefixlen) +unsigned int prefix_bit(const uint8_t *prefix, const uint8_t prefixlen)  {  	unsigned int offset = prefixlen / 8;  	unsigned int shift = 7 - (prefixlen % 8); @@ -449,9 +449,9 @@ unsigned int prefix_bit(const u_char *prefix, const u_char prefixlen)  	return (prefix[offset] >> shift) & 1;  } -unsigned int prefix6_bit(const struct in6_addr *prefix, const u_char prefixlen) +unsigned int prefix6_bit(const struct in6_addr *prefix, const uint8_t prefixlen)  { -	return prefix_bit((const u_char *)&prefix->s6_addr, prefixlen); +	return prefix_bit((const uint8_t *)&prefix->s6_addr, prefixlen);  }  int str2family(const char *string) @@ -533,15 +533,15 @@ int prefix_match(const struct prefix *n, const struct prefix *p)  {  	int offset;  	int shift; -	const u_char *np, *pp; +	const uint8_t *np, *pp;  	/* If n's prefix is longer than p's one return 0. */  	if (n->prefixlen > p->prefixlen)  		return 0;  	/* Set both prefix's head pointer. */ -	np = (const u_char *)&n->u.prefix; -	pp = (const u_char *)&p->u.prefix; +	np = (const uint8_t *)&n->u.prefix; +	pp = (const uint8_t *)&p->u.prefix;  	offset = n->prefixlen / PNBBY;  	shift = n->prefixlen % PNBBY; @@ -562,11 +562,11 @@ int prefix_match_network_statement(const struct prefix *n,  {  	int offset;  	int shift; -	const u_char *np, *pp; +	const uint8_t *np, *pp;  	/* Set both prefix's head pointer. */ -	np = (const u_char *)&n->u.prefix; -	pp = (const u_char *)&p->u.prefix; +	np = (const uint8_t *)&n->u.prefix; +	pp = (const uint8_t *)&p->u.prefix;  	offset = n->prefixlen / PNBBY;  	shift = n->prefixlen % PNBBY; @@ -659,8 +659,8 @@ int prefix_cmp(const struct prefix *p1, const struct prefix *p2)  	int shift;  	/* Set both prefix's head pointer. */ -	const u_char *pp1 = (const u_char *)&p1->u.prefix; -	const u_char *pp2 = (const u_char *)&p2->u.prefix; +	const uint8_t *pp1 = (const uint8_t *)&p1->u.prefix; +	const uint8_t *pp2 = (const uint8_t *)&p2->u.prefix;  	if (p1->family != p2->family || p1->prefixlen != p2->prefixlen)  		return 1; @@ -689,11 +689,11 @@ int prefix_common_bits(const struct prefix *p1, const struct prefix *p2)  {  	int pos, bit;  	int length = 0; -	u_char xor ; +	uint8_t xor ;  	/* Set both prefix's head pointer. */ -	const u_char *pp1 = (const u_char *)&p1->u.prefix; -	const u_char *pp2 = (const u_char *)&p2->u.prefix; +	const uint8_t *pp1 = (const uint8_t *)&p1->u.prefix; +	const uint8_t *pp2 = (const uint8_t *)&p2->u.prefix;  	if (p1->family == AF_INET)  		length = IPV4_MAX_BYTELEN; @@ -787,7 +787,7 @@ int str2prefix_ipv4(const char *str, struct prefix_ipv4 *p)  		XFREE(MTYPE_TMP, cp);  		/* Get prefix length. */ -		plen = (u_char)atoi(++pnt); +		plen = (uint8_t)atoi(++pnt);  		if (plen > IPV4_MAX_PREFIXLEN)  			return 0; @@ -821,7 +821,7 @@ int str2prefix_eth(const char *str, struct prefix_eth *p)  	if (pnt) {  		/* Get prefix length. */ -		plen = (u_char)atoi(++pnt); +		plen = (uint8_t)atoi(++pnt);  		if (plen > 48) {  			ret = 0;  			goto done; @@ -883,7 +883,7 @@ void masklen2ip(const int masklen, struct in_addr *netmask)  /* Convert IP address's netmask into integer. We assume netmask is     sequential one. Argument netmask should be network byte order. */ -u_char ip_masklen(struct in_addr netmask) +uint8_t ip_masklen(struct in_addr netmask)  {  	uint32_t tmp = ~ntohl(netmask.s_addr);  	if (tmp) @@ -953,7 +953,7 @@ int str2prefix_ipv6(const char *str, struct prefix_ipv6 *p)  		XFREE(MTYPE_TMP, cp);  		if (ret == 0)  			return 0; -		plen = (u_char)atoi(++pnt); +		plen = (uint8_t)atoi(++pnt);  		if (plen > IPV6_MAX_BITLEN)  			return 0;  		p->prefixlen = plen; @@ -964,7 +964,7 @@ int str2prefix_ipv6(const char *str, struct prefix_ipv6 *p)  }  /* Convert struct in6_addr netmask into integer. - * FIXME return u_char as ip_maskleni() does. */ + * FIXME return uint8_t as ip_maskleni() does. */  int ip6_masklen(struct in6_addr netmask)  {  	int len = 0; @@ -996,14 +996,14 @@ void masklen2ip6(const int masklen, struct in6_addr *netmask)  void apply_mask_ipv6(struct prefix_ipv6 *p)  { -	u_char *pnt; +	uint8_t *pnt;  	int index;  	int offset;  	index = p->prefixlen / 8;  	if (index < 16) { -		pnt = (u_char *)&p->prefix; +		pnt = (uint8_t *)&p->prefix;  		offset = p->prefixlen % 8;  		pnt[index] &= maskbit[offset]; @@ -1135,7 +1135,7 @@ int str2prefix(const char *str, struct prefix *p)  static const char *prefixevpn2str(const struct prefix *p, char *str, int size)  { -	u_char family; +	uint8_t family;  	char buf[PREFIX2STR_BUFFER];  	char buf2[ETHER_ADDR_STRLEN]; @@ -1244,7 +1244,7 @@ int all_digit(const char *str)  void apply_classful_mask_ipv4(struct prefix_ipv4 *p)  { -	u_int32_t destination; +	uint32_t destination;  	destination = ntohl(p->prefix.s_addr); @@ -1292,8 +1292,8 @@ int netmask_str2prefix_str(const char *net_str, const char *mask_str,  {  	struct in_addr network;  	struct in_addr mask; -	u_char prefixlen; -	u_int32_t destination; +	uint8_t prefixlen; +	uint32_t destination;  	int ret;  	ret = inet_aton(net_str, &network); diff --git a/lib/prefix.h b/lib/prefix.h index 1724225817..133264f999 100644 --- a/lib/prefix.h +++ b/lib/prefix.h @@ -45,7 +45,7 @@   * own to simplify internal handling   */  struct ethaddr { -	u_char octet[ETH_ALEN]; +	uint8_t octet[ETH_ALEN];  } __attribute__((packed)); @@ -58,15 +58,15 @@ struct ethaddr {  /* EVPN address (RFC 7432) */  struct evpn_addr { -	u_char route_type; -	u_char ip_prefix_length; +	uint8_t route_type; +	uint8_t ip_prefix_length;  	struct ethaddr mac;  	uint32_t eth_tag;  	struct ipaddr ip;  #if 0    union    { -    u_char addr; +    uint8_t addr;      struct in_addr v4_addr;      struct in6_addr v6_addr;    } ip; @@ -108,10 +108,10 @@ struct evpn_addr {  /* FRR generic prefix structure. */  struct prefix { -	u_char family; -	u_char prefixlen; +	uint8_t family; +	uint8_t prefixlen;  	union { -		u_char prefix; +		uint8_t prefix;  		struct in_addr prefix4;  		struct in6_addr prefix6;  		struct { @@ -119,7 +119,7 @@ struct prefix {  			struct in_addr adv_router;  		} lp;  		struct ethaddr prefix_eth; /* AF_ETHERNET */ -		u_char val[16]; +		uint8_t val[16];  		uintptr_t ptr;  		struct evpn_addr prefix_evpn; /* AF_EVPN */  	} u __attribute__((aligned(8))); @@ -127,56 +127,56 @@ struct prefix {  /* IPv4 prefix structure. */  struct prefix_ipv4 { -	u_char family; -	u_char prefixlen; +	uint8_t family; +	uint8_t prefixlen;  	struct in_addr prefix __attribute__((aligned(8)));  };  /* IPv6 prefix structure. */  struct prefix_ipv6 { -	u_char family; -	u_char prefixlen; +	uint8_t family; +	uint8_t prefixlen;  	struct in6_addr prefix __attribute__((aligned(8)));  };  struct prefix_ls { -	u_char family; -	u_char prefixlen; +	uint8_t family; +	uint8_t prefixlen;  	struct in_addr id __attribute__((aligned(8)));  	struct in_addr adv_router;  };  /* Prefix for routing distinguisher. */  struct prefix_rd { -	u_char family; -	u_char prefixlen; -	u_char val[8] __attribute__((aligned(8))); +	uint8_t family; +	uint8_t prefixlen; +	uint8_t val[8] __attribute__((aligned(8)));  };  /* Prefix for ethernet. */  struct prefix_eth { -	u_char family; -	u_char prefixlen; +	uint8_t family; +	uint8_t prefixlen;  	struct ethaddr eth_addr __attribute__((aligned(8))); /* AF_ETHERNET */  };  /* EVPN prefix structure. */  struct prefix_evpn { -	u_char family; -	u_char prefixlen; +	uint8_t family; +	uint8_t prefixlen;  	struct evpn_addr prefix __attribute__((aligned(8)));  };  /* Prefix for a generic pointer */  struct prefix_ptr { -	u_char family; -	u_char prefixlen; +	uint8_t family; +	uint8_t prefixlen;  	uintptr_t prefix __attribute__((aligned(8)));  };  struct prefix_sg { -	u_char family; -	u_char prefixlen; +	uint8_t family; +	uint8_t prefixlen;  	struct in_addr src __attribute__((aligned(8)));  	struct in_addr grp;  }; @@ -235,11 +235,11 @@ static inline void ipv4_addr_copy(struct in_addr *dst,  }  #define IPV4_ADDR_COPY(D,S)  ipv4_addr_copy((D), (S)) -#define IPV4_NET0(a)    ((((u_int32_t) (a)) & 0xff000000) == 0x00000000) -#define IPV4_NET127(a)  ((((u_int32_t) (a)) & 0xff000000) == 0x7f000000) -#define IPV4_LINKLOCAL(a) ((((u_int32_t) (a)) & 0xffff0000) == 0xa9fe0000) -#define IPV4_CLASS_DE(a)  ((((u_int32_t) (a)) & 0xe0000000) == 0xe0000000) -#define IPV4_MC_LINKLOCAL(a)  ((((u_int32_t) (a)) & 0xffffff00) == 0xe0000000) +#define IPV4_NET0(a) ((((uint32_t)(a)) & 0xff000000) == 0x00000000) +#define IPV4_NET127(a) ((((uint32_t)(a)) & 0xff000000) == 0x7f000000) +#define IPV4_LINKLOCAL(a) ((((uint32_t)(a)) & 0xffff0000) == 0xa9fe0000) +#define IPV4_CLASS_DE(a) ((((uint32_t)(a)) & 0xe0000000) == 0xe0000000) +#define IPV4_MC_LINKLOCAL(a) ((((uint32_t)(a)) & 0xffffff00) == 0xe0000000)  /* Max bit/byte length of IPv6 address. */  #define IPV6_MAX_BYTELEN    16 @@ -275,9 +275,9 @@ extern const char *safi2str(safi_t safi);  extern const char *afi2str(afi_t afi);  /* Check bit of the prefix. */ -extern unsigned int prefix_bit(const u_char *prefix, const u_char prefixlen); +extern unsigned int prefix_bit(const uint8_t *prefix, const uint8_t prefixlen);  extern unsigned int prefix6_bit(const struct in6_addr *prefix, -				const u_char prefixlen); +				const uint8_t prefixlen);  extern struct prefix *prefix_new(void);  extern void prefix_free(struct prefix *); @@ -318,7 +318,7 @@ extern void apply_mask_ipv4(struct prefix_ipv4 *);  extern int prefix_ipv4_any(const struct prefix_ipv4 *);  extern void apply_classful_mask_ipv4(struct prefix_ipv4 *); -extern u_char ip_masklen(struct in_addr); +extern uint8_t ip_masklen(struct in_addr);  extern void masklen2ip(const int, struct in_addr *);  /* returns the network portion of the host address */  extern in_addr_t ipv4_network_addr(in_addr_t hostaddr, int masklen); diff --git a/lib/sigevent.c b/lib/sigevent.c index d55f368dfb..d299760fab 100644 --- a/lib/sigevent.c +++ b/lib/sigevent.c @@ -284,7 +284,7 @@ static void trap_default_signals(void)  	};  	static const struct {  		const int *sigs; -		u_int nsigs; +		unsigned int nsigs;  		void (*handler)(int signo  #ifdef SA_SIGINFO  				, @@ -296,10 +296,10 @@ static void trap_default_signals(void)  		{exit_signals, array_size(exit_signals), exit_handler},  		{ignore_signals, array_size(ignore_signals), NULL},  	}; -	u_int i; +	unsigned int i;  	for (i = 0; i < array_size(sigmap); i++) { -		u_int j; +		unsigned int j;  		for (j = 0; j < sigmap[i].nsigs; j++) {  			struct sigaction oact; diff --git a/lib/smux.c b/lib/smux.c index 9a0063df21..51abfccba3 100644 --- a/lib/smux.c +++ b/lib/smux.c @@ -56,7 +56,7 @@  struct subtree {  	/* Tree's oid. */  	oid name[MAX_OID_LEN]; -	u_char name_len; +	uint8_t name_len;  	/* List of the variables. */  	struct variable *variables; @@ -189,11 +189,11 @@ static int smux_socket(void)  }  static void smux_getresp_send(oid objid[], size_t objid_len, long reqid, -			      long errstat, long errindex, u_char val_type, +			      long errstat, long errindex, uint8_t val_type,  			      void *arg, size_t arg_len)  { -	u_char buf[BUFSIZ]; -	u_char *ptr, *h1, *h1e, *h2, *h2e; +	uint8_t buf[BUFSIZ]; +	uint8_t *ptr, *h1, *h1e, *h2, *h2e;  	size_t len, length;  	ptr = buf; @@ -207,30 +207,33 @@ static void smux_getresp_send(oid objid[], size_t objid_len, long reqid,  	h1 = ptr;  	/* Place holder h1 for complete sequence */ -	ptr = asn_build_sequence(ptr, &len, (u_char)SMUX_GETRSP, 0); +	ptr = asn_build_sequence(ptr, &len, (uint8_t)SMUX_GETRSP, 0);  	h1e = ptr; -	ptr = asn_build_int(ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE -						| ASN_INTEGER), -			    &reqid, sizeof(reqid)); +	ptr = asn_build_int( +		ptr, &len, +		(uint8_t)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER), &reqid, +		sizeof(reqid));  	if (debug_smux)  		zlog_debug("SMUX GETRSP errstat: %ld", errstat); -	ptr = asn_build_int(ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE -						| ASN_INTEGER), -			    &errstat, sizeof(errstat)); +	ptr = asn_build_int( +		ptr, &len, +		(uint8_t)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER), +		&errstat, sizeof(errstat));  	if (debug_smux)  		zlog_debug("SMUX GETRSP errindex: %ld", errindex); -	ptr = asn_build_int(ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE -						| ASN_INTEGER), -			    &errindex, sizeof(errindex)); +	ptr = asn_build_int( +		ptr, &len, +		(uint8_t)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER), +		&errindex, sizeof(errindex));  	h2 = ptr;  	/* Place holder h2 for one variable */  	ptr = asn_build_sequence(ptr, &len, -				 (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR), 0); +				 (uint8_t)(ASN_SEQUENCE | ASN_CONSTRUCTOR), 0);  	h2e = ptr;  	ptr = snmp_build_var_op(ptr, objid, &objid_len, val_type, arg_len, arg, @@ -238,10 +241,11 @@ static void smux_getresp_send(oid objid[], size_t objid_len, long reqid,  	/* Now variable size is known, fill in size */  	asn_build_sequence(h2, &length, -			   (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR), ptr - h2e); +			   (uint8_t)(ASN_SEQUENCE | ASN_CONSTRUCTOR), +			   ptr - h2e);  	/* Fill in size of whole sequence */ -	asn_build_sequence(h1, &length, (u_char)SMUX_GETRSP, ptr - h1e); +	asn_build_sequence(h1, &length, (uint8_t)SMUX_GETRSP, ptr - h1e);  	if (debug_smux)  		zlog_debug("SMUX getresp send: %td", (ptr - buf)); @@ -249,14 +253,14 @@ static void smux_getresp_send(oid objid[], size_t objid_len, long reqid,  	send(smux_sock, buf, (ptr - buf), 0);  } -static u_char *smux_var(u_char *ptr, size_t len, oid objid[], size_t *objid_len, -			size_t *var_val_len, u_char *var_val_type, -			void **var_value) +static uint8_t *smux_var(uint8_t *ptr, size_t len, oid objid[], +			 size_t *objid_len, size_t *var_val_len, +			 uint8_t *var_val_type, void **var_value)  { -	u_char type; -	u_char val_type; +	uint8_t type; +	uint8_t val_type;  	size_t val_len; -	u_char *val; +	uint8_t *val;  	if (debug_smux)  		zlog_debug("SMUX var parse: len %zd", len); @@ -347,7 +351,7 @@ static u_char *smux_var(u_char *ptr, size_t len, oid objid[], size_t *objid_len,     ucd-snmp smux and as such suppose, that the peer receives in the message     only one variable. Fortunately, IBM seems to do the same in AIX. */ -static int smux_set(oid *reqid, size_t *reqid_len, u_char val_type, void *val, +static int smux_set(oid *reqid, size_t *reqid_len, uint8_t val_type, void *val,  		    size_t val_len, int action)  {  	int j; @@ -357,7 +361,7 @@ static int smux_set(oid *reqid, size_t *reqid_len, u_char val_type, void *val,  	oid *suffix;  	size_t suffix_len;  	int result; -	u_char *statP = NULL; +	uint8_t *statP = NULL;  	WriteMethod *write_method = NULL;  	struct listnode *node, *nnode; @@ -414,7 +418,7 @@ static int smux_set(oid *reqid, size_t *reqid_len, u_char val_type, void *val,  	return SNMP_ERR_NOSUCHNAME;  } -static int smux_get(oid *reqid, size_t *reqid_len, int exact, u_char *val_type, +static int smux_get(oid *reqid, size_t *reqid_len, int exact, uint8_t *val_type,  		    void **val, size_t *val_len)  {  	int j; @@ -481,7 +485,7 @@ static int smux_get(oid *reqid, size_t *reqid_len, int exact, u_char *val_type,  }  static int smux_getnext(oid *reqid, size_t *reqid_len, int exact, -			u_char *val_type, void **val, size_t *val_len) +			uint8_t *val_type, void **val, size_t *val_len)  {  	int j;  	oid save[MAX_OID_LEN]; @@ -572,9 +576,9 @@ static int smux_getnext(oid *reqid, size_t *reqid_len, int exact,  }  /* GET message header. */ -static u_char *smux_parse_get_header(u_char *ptr, size_t *len, long *reqid) +static uint8_t *smux_parse_get_header(uint8_t *ptr, size_t *len, long *reqid)  { -	u_char type; +	uint8_t type;  	long errstat;  	long errindex; @@ -600,12 +604,12 @@ static u_char *smux_parse_get_header(u_char *ptr, size_t *len, long *reqid)  	return ptr;  } -static void smux_parse_set(u_char *ptr, size_t len, int action) +static void smux_parse_set(uint8_t *ptr, size_t len, int action)  {  	long reqid;  	oid oid[MAX_OID_LEN];  	size_t oid_len; -	u_char val_type; +	uint8_t val_type;  	void *val;  	size_t val_len;  	int ret; @@ -633,12 +637,12 @@ static void smux_parse_set(u_char *ptr, size_t len, int action)  				  0);  } -static void smux_parse_get(u_char *ptr, size_t len, int exact) +static void smux_parse_get(uint8_t *ptr, size_t len, int exact)  {  	long reqid;  	oid oid[MAX_OID_LEN];  	size_t oid_len; -	u_char val_type; +	uint8_t val_type;  	void *val;  	size_t val_len;  	int ret; @@ -669,7 +673,7 @@ static void smux_parse_get(u_char *ptr, size_t len, int exact)  }  /* Parse SMUX_CLOSE message. */ -static void smux_parse_close(u_char *ptr, int len) +static void smux_parse_close(uint8_t *ptr, int len)  {  	long reason = 0; @@ -681,9 +685,9 @@ static void smux_parse_close(u_char *ptr, int len)  }  /* SMUX_RRSP message. */ -static void smux_parse_rrsp(u_char *ptr, size_t len) +static void smux_parse_rrsp(uint8_t *ptr, size_t len)  { -	u_char val; +	uint8_t val;  	long errstat;  	ptr = asn_parse_int(ptr, &len, &val, &errstat, sizeof(errstat)); @@ -693,17 +697,17 @@ static void smux_parse_rrsp(u_char *ptr, size_t len)  }  /* Parse SMUX message. */ -static int smux_parse(u_char *ptr, size_t len) +static int smux_parse(uint8_t *ptr, size_t len)  {  	/* This buffer we'll use for SOUT message. We could allocate it with  	   malloc and save only static pointer/lenght, but IMHO static  	   buffer is a faster solusion. */ -	static u_char sout_save_buff[SMUXMAXPKTSIZE]; +	static uint8_t sout_save_buff[SMUXMAXPKTSIZE];  	static int sout_save_len = 0;  	int len_income = len; /* see note below: YYY */ -	u_char type; -	u_char rollback; +	uint8_t type; +	uint8_t rollback;  	rollback = ptr[2]; /* important only for SMUX_SOUT */ @@ -813,7 +817,7 @@ static int smux_read(struct thread *t)  {  	int sock;  	int len; -	u_char buf[SMUXMAXPKTSIZE]; +	uint8_t buf[SMUXMAXPKTSIZE];  	int ret;  	/* Clear thread. */ @@ -864,8 +868,8 @@ static int smux_read(struct thread *t)  static int smux_open(int sock)  { -	u_char buf[BUFSIZ]; -	u_char *ptr; +	uint8_t buf[BUFSIZ]; +	uint8_t *ptr;  	size_t len;  	long version;  	const char progname[] = FRR_SMUX_NAME "-" FRR_VERSION; @@ -880,32 +884,36 @@ static int smux_open(int sock)  	len = BUFSIZ;  	/* SMUX Header.  As placeholder. */ -	ptr = asn_build_header(ptr, &len, (u_char)SMUX_OPEN, 0); +	ptr = asn_build_header(ptr, &len, (uint8_t)SMUX_OPEN, 0);  	/* SMUX Open. */  	version = 0; -	ptr = asn_build_int(ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE -						| ASN_INTEGER), -			    &version, sizeof(version)); +	ptr = asn_build_int( +		ptr, &len, +		(uint8_t)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER), +		&version, sizeof(version));  	/* SMUX connection oid. */ -	ptr = asn_build_objid(ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE -						  | ASN_OBJECT_ID), -			      smux_oid, smux_oid_len); +	ptr = asn_build_objid( +		ptr, &len, +		(uint8_t)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID), +		smux_oid, smux_oid_len);  	/* SMUX connection description. */ -	ptr = asn_build_string(ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE -						   | ASN_OCTET_STR), -			       (const u_char *)progname, strlen(progname)); +	ptr = asn_build_string( +		ptr, &len, +		(uint8_t)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR), +		(const uint8_t *)progname, strlen(progname));  	/* SMUX connection password. */ -	ptr = asn_build_string(ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE -						   | ASN_OCTET_STR), -			       (u_char *)smux_passwd, strlen(smux_passwd)); +	ptr = asn_build_string( +		ptr, &len, +		(uint8_t)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR), +		(uint8_t *)smux_passwd, strlen(smux_passwd));  	/* Fill in real SMUX header.  We exclude ASN header size (2). */  	len = BUFSIZ; -	asn_build_header(buf, &len, (u_char)SMUX_OPEN, (ptr - buf) - 2); +	asn_build_header(buf, &len, (uint8_t)SMUX_OPEN, (ptr - buf) - 2);  	return send(sock, buf, (ptr - buf), 0);  } @@ -919,15 +927,15 @@ int smux_trap(struct variable *vp, size_t vp_len, const oid *ename,  	      size_t enamelen, const oid *name, size_t namelen,  	      const oid *iname, size_t inamelen,  	      const struct trap_object *trapobj, size_t trapobjlen, -	      u_char sptrap) +	      uint8_t sptrap)  {  	unsigned int i; -	u_char buf[BUFSIZ]; -	u_char *ptr; +	uint8_t buf[BUFSIZ]; +	uint8_t *ptr;  	size_t len, length;  	struct in_addr addr;  	unsigned long val; -	u_char *h1, *h1e; +	uint8_t *h1, *h1e;  	ptr = buf;  	len = BUFSIZ; @@ -938,42 +946,46 @@ int smux_trap(struct variable *vp, size_t vp_len, const oid *ename,  		return 0;  	/* SMUX header. */ -	ptr = asn_build_header(ptr, &len, (u_char)SMUX_TRAP, 0); +	ptr = asn_build_header(ptr, &len, (uint8_t)SMUX_TRAP, 0);  	/* Sub agent enterprise oid. */ -	ptr = asn_build_objid(ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE -						  | ASN_OBJECT_ID), -			      smux_oid, smux_oid_len); +	ptr = asn_build_objid( +		ptr, &len, +		(uint8_t)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID), +		smux_oid, smux_oid_len);  	/* IP address. */  	addr.s_addr = 0; -	ptr = asn_build_string(ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE -						   | ASN_IPADDRESS), -			       (u_char *)&addr, sizeof(addr)); +	ptr = asn_build_string( +		ptr, &len, +		(uint8_t)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_IPADDRESS), +		(uint8_t *)&addr, sizeof(addr));  	/* Generic trap integer. */  	val = SNMP_TRAP_ENTERPRISESPECIFIC; -	ptr = asn_build_int(ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE -						| ASN_INTEGER), -			    (long *)&val, sizeof(val)); +	ptr = asn_build_int( +		ptr, &len, +		(uint8_t)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER), +		(long *)&val, sizeof(val));  	/* Specific trap integer. */  	val = sptrap; -	ptr = asn_build_int(ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE -						| ASN_INTEGER), -			    (long *)&val, sizeof(val)); +	ptr = asn_build_int( +		ptr, &len, +		(uint8_t)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER), +		(long *)&val, sizeof(val));  	/* Timeticks timestamp. */  	val = 0;  	ptr = asn_build_unsigned_int(  		ptr, &len, -		(u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_TIMETICKS), &val, +		(uint8_t)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_TIMETICKS), &val,  		sizeof(val));  	/* Variables. */  	h1 = ptr;  	ptr = asn_build_sequence(ptr, &len, -				 (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR), 0); +				 (uint8_t)(ASN_SEQUENCE | ASN_CONSTRUCTOR), 0);  	/* Iteration for each objects. */ @@ -984,7 +996,7 @@ int smux_trap(struct variable *vp, size_t vp_len, const oid *ename,  		size_t oid_len;  		void *val;  		size_t val_len; -		u_char val_type; +		uint8_t val_type;  		/* Make OID. */  		if (trapobj[i].namelen > 0) { @@ -1013,7 +1025,7 @@ int smux_trap(struct variable *vp, size_t vp_len, const oid *ename,  			}  			smux_oid_dump("Trap", oid, oid_len);  			zlog_info("BUFSIZ: %d // oid_len: %lu", BUFSIZ, -				  (u_long)oid_len); +				  (unsigned long)oid_len);  		}  		ret = smux_get(oid, &oid_len, 1, &val_type, &val, &val_len); @@ -1028,19 +1040,20 @@ int smux_trap(struct variable *vp, size_t vp_len, const oid *ename,  	/* Now variable size is known, fill in size */  	asn_build_sequence(h1, &length, -			   (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR), ptr - h1e); +			   (uint8_t)(ASN_SEQUENCE | ASN_CONSTRUCTOR), +			   ptr - h1e);  	/* Fill in size of whole sequence */  	len = BUFSIZ; -	asn_build_header(buf, &len, (u_char)SMUX_TRAP, (ptr - buf) - 2); +	asn_build_header(buf, &len, (uint8_t)SMUX_TRAP, (ptr - buf) - 2);  	return send(smux_sock, buf, (ptr - buf), 0);  }  static int smux_register(int sock)  { -	u_char buf[BUFSIZ]; -	u_char *ptr; +	uint8_t buf[BUFSIZ]; +	uint8_t *ptr;  	int ret;  	size_t len;  	long priority; @@ -1055,26 +1068,26 @@ static int smux_register(int sock)  		len = BUFSIZ;  		/* SMUX RReq Header. */ -		ptr = asn_build_header(ptr, &len, (u_char)SMUX_RREQ, 0); +		ptr = asn_build_header(ptr, &len, (uint8_t)SMUX_RREQ, 0);  		/* Register MIB tree. */ -		ptr = asn_build_objid( -			ptr, &len, -			(u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID), -			subtree->name, subtree->name_len); +		ptr = asn_build_objid(ptr, &len, +				      (uint8_t)(ASN_UNIVERSAL | ASN_PRIMITIVE +						| ASN_OBJECT_ID), +				      subtree->name, subtree->name_len);  		/* Priority. */  		priority = -1;  		ptr = asn_build_int(  			ptr, &len, -			(u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER), +			(uint8_t)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),  			&priority, sizeof(priority));  		/* Operation. */  		operation = 2; /* Register R/W */  		ptr = asn_build_int(  			ptr, &len, -			(u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER), +			(uint8_t)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),  			&operation, sizeof(operation));  		if (debug_smux) { @@ -1085,7 +1098,8 @@ static int smux_register(int sock)  		}  		len = BUFSIZ; -		asn_build_header(buf, &len, (u_char)SMUX_RREQ, (ptr - buf) - 2); +		asn_build_header(buf, &len, (uint8_t)SMUX_RREQ, +				 (ptr - buf) - 2);  		ret = send(sock, buf, (ptr - buf), 0);  		if (ret < 0)  			return ret; diff --git a/lib/smux.h b/lib/smux.h index 987414c0d1..9adfacb3e4 100644 --- a/lib/smux.h +++ b/lib/smux.h @@ -59,11 +59,11 @@ struct trap_object {  #define SNMP_INTEGER(V)                                                        \  	(*var_len = sizeof(snmp_int_val), snmp_int_val = V,                    \ -	 (u_char *)&snmp_int_val) +	 (uint8_t *)&snmp_int_val)  #define SNMP_IPADDRESS(V)                                                      \  	(*var_len = sizeof(struct in_addr), snmp_in_addr_val = V,              \ -	 (u_char *)&snmp_in_addr_val) +	 (uint8_t *)&snmp_in_addr_val)  extern void smux_init(struct thread_master *tm);  extern void smux_register_mib(const char *, struct variable *, size_t, int, @@ -96,7 +96,7 @@ extern int smux_header_table(struct variable *, oid *, size_t *, int, size_t *,  */  extern int smux_trap(struct variable *, size_t, const oid *, size_t,  		     const oid *, size_t, const oid *, size_t, -		     const struct trap_object *, size_t, u_char); +		     const struct trap_object *, size_t, uint8_t);  extern int oid_compare(const oid *, int, const oid *, int);  extern void oid2in_addr(oid[], int, struct in_addr *); diff --git a/lib/snmp.c b/lib/snmp.c index fefd7ba37d..f11d9dc8cf 100644 --- a/lib/snmp.c +++ b/lib/snmp.c @@ -53,12 +53,12 @@ void *oid_copy(void *dest, const void *src, size_t size)  void oid2in_addr(oid oid[], int len, struct in_addr *addr)  {  	int i; -	u_char *pnt; +	uint8_t *pnt;  	if (len == 0)  		return; -	pnt = (u_char *)addr; +	pnt = (uint8_t *)addr;  	for (i = 0; i < len; i++)  		*pnt++ = oid[i]; @@ -67,12 +67,12 @@ void oid2in_addr(oid oid[], int len, struct in_addr *addr)  void oid_copy_addr(oid oid[], struct in_addr *addr, int len)  {  	int i; -	u_char *pnt; +	uint8_t *pnt;  	if (len == 0)  		return; -	pnt = (u_char *)addr; +	pnt = (uint8_t *)addr;  	for (i = 0; i < len; i++)  		oid[i] = *pnt++; diff --git a/lib/sockopt.c b/lib/sockopt.c index d100991a33..1d8d9990df 100644 --- a/lib/sockopt.c +++ b/lib/sockopt.c @@ -56,7 +56,7 @@ void setsockopt_so_sendbuf(const int sock, int size)  int getsockopt_so_sendbuf(const int sock)  { -	u_int32_t optval; +	uint32_t optval;  	socklen_t optlen = sizeof(optval);  	int ret = getsockopt(sock, SOL_SOCKET, SO_SNDBUF, (char *)&optval,  			     &optlen); @@ -382,7 +382,7 @@ int setsockopt_ipv4_multicast_if(int sock, struct in_addr if_addr,  #endif  } -int setsockopt_ipv4_multicast_loop(int sock, u_char val) +int setsockopt_ipv4_multicast_loop(int sock, uint8_t val)  {  	int ret; @@ -584,9 +584,9 @@ int sockopt_tcp_signature(int sock, union sockunion *su, const char *password)  #define TCP_MD5_AUTH_ADD 1  #define TCP_MD5_AUTH_DEL 2  	struct tcp_rfc2385_cmd { -		u_int8_t command;  /* Command - Add/Delete */ -		u_int32_t address; /* IPV4 address associated */ -		u_int8_t keylen;   /* MD5 Key len (do NOT assume 0 terminated +		uint8_t command;  /* Command - Add/Delete */ +		uint32_t address; /* IPV4 address associated */ +		uint8_t keylen;   /* MD5 Key len (do NOT assume 0 terminated  				      ascii) */  		void *key;	 /* MD5 Key */  	} cmd; diff --git a/lib/sockopt.h b/lib/sockopt.h index 7be36222da..f54f60ffd7 100644 --- a/lib/sockopt.h +++ b/lib/sockopt.h @@ -81,7 +81,7 @@ extern int setsockopt_ipv4_multicast(int sock, int optname,  				     struct in_addr if_addr,  				     unsigned int mcast_addr,  				     ifindex_t ifindex); -extern int setsockopt_ipv4_multicast_loop(int sock, u_char val); +extern int setsockopt_ipv4_multicast_loop(int sock, uint8_t val);  extern int setsockopt_ipv4_tos(int sock, int tos); diff --git a/lib/sockunion.c b/lib/sockunion.c index ab8d8be3e5..28a7f647cb 100644 --- a/lib/sockunion.c +++ b/lib/sockunion.c @@ -486,18 +486,18 @@ size_t sockunion_get_addrlen(const union sockunion *su)  	return family2addrsize(sockunion_family(su));  } -const u_char *sockunion_get_addr(const union sockunion *su) +const uint8_t *sockunion_get_addr(const union sockunion *su)  {  	switch (sockunion_family(su)) {  	case AF_INET: -		return (const u_char *)&su->sin.sin_addr.s_addr; +		return (const uint8_t *)&su->sin.sin_addr.s_addr;  	case AF_INET6: -		return (const u_char *)&su->sin6.sin6_addr; +		return (const uint8_t *)&su->sin6.sin6_addr;  	}  	return NULL;  } -void sockunion_set(union sockunion *su, int family, const u_char *addr, +void sockunion_set(union sockunion *su, int family, const uint8_t *addr,  		   size_t bytes)  {  	if (family2addrsize(family) != bytes) @@ -622,10 +622,10 @@ static int in6addr_cmp(const struct in6_addr *addr1,  		       const struct in6_addr *addr2)  {  	unsigned int i; -	const u_char *p1, *p2; +	const uint8_t *p1, *p2; -	p1 = (const u_char *)addr1; -	p2 = (const u_char *)addr2; +	p1 = (const uint8_t *)addr1; +	p2 = (const uint8_t *)addr2;  	for (i = 0; i < sizeof(struct in6_addr); i++) {  		if (p1[i] > p2[i]) diff --git a/lib/sockunion.h b/lib/sockunion.h index 67a7a46272..b585aee5b4 100644 --- a/lib/sockunion.h +++ b/lib/sockunion.h @@ -73,8 +73,8 @@ extern unsigned int sockunion_hash(const union sockunion *);  extern size_t family2addrsize(int family);  extern size_t sockunion_get_addrlen(const union sockunion *); -extern const u_char *sockunion_get_addr(const union sockunion *); -extern void sockunion_set(union sockunion *, int family, const u_char *addr, +extern const uint8_t *sockunion_get_addr(const union sockunion *); +extern void sockunion_set(union sockunion *, int family, const uint8_t *addr,  			  size_t bytes);  extern union sockunion *sockunion_str2su(const char *str); diff --git a/lib/stream.c b/lib/stream.c index 3c08d4454b..927a3d3d55 100644 --- a/lib/stream.c +++ b/lib/stream.c @@ -171,7 +171,7 @@ struct stream *stream_dupcat(struct stream *s1, struct stream *s2,  size_t stream_resize(struct stream *s, size_t newsize)  { -	u_char *newdata; +	uint8_t *newdata;  	STREAM_VERIFY_SANE(s);  	newdata = XREALLOC(MTYPE_STREAM_DATA, s->data, newsize); @@ -299,11 +299,11 @@ void stream_get(void *dst, struct stream *s, size_t size)  }  /* Get next character from the stream. */ -inline bool stream_getc2(struct stream *s, u_char *byte) +inline bool stream_getc2(struct stream *s, uint8_t *byte)  {  	STREAM_VERIFY_SANE(s); -	if (STREAM_READABLE(s) < sizeof(u_char)) { +	if (STREAM_READABLE(s) < sizeof(uint8_t)) {  		STREAM_BOUND_WARN2(s, "get char");  		return false;  	} @@ -312,13 +312,13 @@ inline bool stream_getc2(struct stream *s, u_char *byte)  	return true;  } -u_char stream_getc(struct stream *s) +uint8_t stream_getc(struct stream *s)  { -	u_char c; +	uint8_t c;  	STREAM_VERIFY_SANE(s); -	if (STREAM_READABLE(s) < sizeof(u_char)) { +	if (STREAM_READABLE(s) < sizeof(uint8_t)) {  		STREAM_BOUND_WARN(s, "get char");  		return 0;  	} @@ -328,13 +328,13 @@ u_char stream_getc(struct stream *s)  }  /* Get next character from the stream. */ -u_char stream_getc_from(struct stream *s, size_t from) +uint8_t stream_getc_from(struct stream *s, size_t from)  { -	u_char c; +	uint8_t c;  	STREAM_VERIFY_SANE(s); -	if (!GETP_VALID(s, from + sizeof(u_char))) { +	if (!GETP_VALID(s, from + sizeof(uint8_t))) {  		STREAM_BOUND_WARN(s, "get char");  		return 0;  	} @@ -360,13 +360,13 @@ inline bool stream_getw2(struct stream *s, uint16_t *word)  }  /* Get next word from the stream. */ -u_int16_t stream_getw(struct stream *s) +uint16_t stream_getw(struct stream *s)  { -	u_int16_t w; +	uint16_t w;  	STREAM_VERIFY_SANE(s); -	if (STREAM_READABLE(s) < sizeof(u_int16_t)) { +	if (STREAM_READABLE(s) < sizeof(uint16_t)) {  		STREAM_BOUND_WARN(s, "get ");  		return 0;  	} @@ -378,13 +378,13 @@ u_int16_t stream_getw(struct stream *s)  }  /* Get next word from the stream. */ -u_int16_t stream_getw_from(struct stream *s, size_t from) +uint16_t stream_getw_from(struct stream *s, size_t from)  { -	u_int16_t w; +	uint16_t w;  	STREAM_VERIFY_SANE(s); -	if (!GETP_VALID(s, from + sizeof(u_int16_t))) { +	if (!GETP_VALID(s, from + sizeof(uint16_t))) {  		STREAM_BOUND_WARN(s, "get ");  		return 0;  	} @@ -396,9 +396,9 @@ u_int16_t stream_getw_from(struct stream *s, size_t from)  }  /* Get next 3-byte from the stream. */ -u_int32_t stream_get3_from(struct stream *s, size_t from) +uint32_t stream_get3_from(struct stream *s, size_t from)  { -	u_int32_t l; +	uint32_t l;  	STREAM_VERIFY_SANE(s); @@ -414,9 +414,9 @@ u_int32_t stream_get3_from(struct stream *s, size_t from)  	return l;  } -u_int32_t stream_get3(struct stream *s) +uint32_t stream_get3(struct stream *s)  { -	u_int32_t l; +	uint32_t l;  	STREAM_VERIFY_SANE(s); @@ -433,13 +433,13 @@ u_int32_t stream_get3(struct stream *s)  }  /* Get next long word from the stream. */ -u_int32_t stream_getl_from(struct stream *s, size_t from) +uint32_t stream_getl_from(struct stream *s, size_t from)  { -	u_int32_t l; +	uint32_t l;  	STREAM_VERIFY_SANE(s); -	if (!GETP_VALID(s, from + sizeof(u_int32_t))) { +	if (!GETP_VALID(s, from + sizeof(uint32_t))) {  		STREAM_BOUND_WARN(s, "get long");  		return 0;  	} @@ -482,13 +482,13 @@ inline bool stream_getl2(struct stream *s, uint32_t *l)  	return true;  } -u_int32_t stream_getl(struct stream *s) +uint32_t stream_getl(struct stream *s)  { -	u_int32_t l; +	uint32_t l;  	STREAM_VERIFY_SANE(s); -	if (STREAM_READABLE(s) < sizeof(u_int32_t)) { +	if (STREAM_READABLE(s) < sizeof(uint32_t)) {  		STREAM_BOUND_WARN(s, "get long");  		return 0;  	} @@ -549,19 +549,19 @@ uint64_t stream_getq(struct stream *s)  }  /* Get next long word from the stream. */ -u_int32_t stream_get_ipv4(struct stream *s) +uint32_t stream_get_ipv4(struct stream *s)  { -	u_int32_t l; +	uint32_t l;  	STREAM_VERIFY_SANE(s); -	if (STREAM_READABLE(s) < sizeof(u_int32_t)) { +	if (STREAM_READABLE(s) < sizeof(uint32_t)) {  		STREAM_BOUND_WARN(s, "get ipv4");  		return 0;  	} -	memcpy(&l, s->data + s->getp, sizeof(u_int32_t)); -	s->getp += sizeof(u_int32_t); +	memcpy(&l, s->data + s->getp, sizeof(uint32_t)); +	s->getp += sizeof(uint32_t);  	return l;  } @@ -615,37 +615,37 @@ void stream_put(struct stream *s, const void *src, size_t size)  }  /* Put character to the stream. */ -int stream_putc(struct stream *s, u_char c) +int stream_putc(struct stream *s, uint8_t c)  {  	STREAM_VERIFY_SANE(s); -	if (STREAM_WRITEABLE(s) < sizeof(u_char)) { +	if (STREAM_WRITEABLE(s) < sizeof(uint8_t)) {  		STREAM_BOUND_WARN(s, "put");  		return 0;  	}  	s->data[s->endp++] = c; -	return sizeof(u_char); +	return sizeof(uint8_t);  }  /* Put word to the stream. */ -int stream_putw(struct stream *s, u_int16_t w) +int stream_putw(struct stream *s, uint16_t w)  {  	STREAM_VERIFY_SANE(s); -	if (STREAM_WRITEABLE(s) < sizeof(u_int16_t)) { +	if (STREAM_WRITEABLE(s) < sizeof(uint16_t)) {  		STREAM_BOUND_WARN(s, "put");  		return 0;  	} -	s->data[s->endp++] = (u_char)(w >> 8); -	s->data[s->endp++] = (u_char)w; +	s->data[s->endp++] = (uint8_t)(w >> 8); +	s->data[s->endp++] = (uint8_t)w;  	return 2;  }  /* Put long word to the stream. */ -int stream_put3(struct stream *s, u_int32_t l) +int stream_put3(struct stream *s, uint32_t l)  {  	STREAM_VERIFY_SANE(s); @@ -654,27 +654,27 @@ int stream_put3(struct stream *s, u_int32_t l)  		return 0;  	} -	s->data[s->endp++] = (u_char)(l >> 16); -	s->data[s->endp++] = (u_char)(l >> 8); -	s->data[s->endp++] = (u_char)l; +	s->data[s->endp++] = (uint8_t)(l >> 16); +	s->data[s->endp++] = (uint8_t)(l >> 8); +	s->data[s->endp++] = (uint8_t)l;  	return 3;  }  /* Put long word to the stream. */ -int stream_putl(struct stream *s, u_int32_t l) +int stream_putl(struct stream *s, uint32_t l)  {  	STREAM_VERIFY_SANE(s); -	if (STREAM_WRITEABLE(s) < sizeof(u_int32_t)) { +	if (STREAM_WRITEABLE(s) < sizeof(uint32_t)) {  		STREAM_BOUND_WARN(s, "put");  		return 0;  	} -	s->data[s->endp++] = (u_char)(l >> 24); -	s->data[s->endp++] = (u_char)(l >> 16); -	s->data[s->endp++] = (u_char)(l >> 8); -	s->data[s->endp++] = (u_char)l; +	s->data[s->endp++] = (uint8_t)(l >> 24); +	s->data[s->endp++] = (uint8_t)(l >> 16); +	s->data[s->endp++] = (uint8_t)(l >> 8); +	s->data[s->endp++] = (uint8_t)l;  	return 4;  } @@ -689,14 +689,14 @@ int stream_putq(struct stream *s, uint64_t q)  		return 0;  	} -	s->data[s->endp++] = (u_char)(q >> 56); -	s->data[s->endp++] = (u_char)(q >> 48); -	s->data[s->endp++] = (u_char)(q >> 40); -	s->data[s->endp++] = (u_char)(q >> 32); -	s->data[s->endp++] = (u_char)(q >> 24); -	s->data[s->endp++] = (u_char)(q >> 16); -	s->data[s->endp++] = (u_char)(q >> 8); -	s->data[s->endp++] = (u_char)q; +	s->data[s->endp++] = (uint8_t)(q >> 56); +	s->data[s->endp++] = (uint8_t)(q >> 48); +	s->data[s->endp++] = (uint8_t)(q >> 40); +	s->data[s->endp++] = (uint8_t)(q >> 32); +	s->data[s->endp++] = (uint8_t)(q >> 24); +	s->data[s->endp++] = (uint8_t)(q >> 16); +	s->data[s->endp++] = (uint8_t)(q >> 8); +	s->data[s->endp++] = (uint8_t)q;  	return 8;  } @@ -721,11 +721,11 @@ int stream_putd(struct stream *s, double d)  	return stream_putq(s, u.o);  } -int stream_putc_at(struct stream *s, size_t putp, u_char c) +int stream_putc_at(struct stream *s, size_t putp, uint8_t c)  {  	STREAM_VERIFY_SANE(s); -	if (!PUT_AT_VALID(s, putp + sizeof(u_char))) { +	if (!PUT_AT_VALID(s, putp + sizeof(uint8_t))) {  		STREAM_BOUND_WARN(s, "put");  		return 0;  	} @@ -735,22 +735,22 @@ int stream_putc_at(struct stream *s, size_t putp, u_char c)  	return 1;  } -int stream_putw_at(struct stream *s, size_t putp, u_int16_t w) +int stream_putw_at(struct stream *s, size_t putp, uint16_t w)  {  	STREAM_VERIFY_SANE(s); -	if (!PUT_AT_VALID(s, putp + sizeof(u_int16_t))) { +	if (!PUT_AT_VALID(s, putp + sizeof(uint16_t))) {  		STREAM_BOUND_WARN(s, "put");  		return 0;  	} -	s->data[putp] = (u_char)(w >> 8); -	s->data[putp + 1] = (u_char)w; +	s->data[putp] = (uint8_t)(w >> 8); +	s->data[putp + 1] = (uint8_t)w;  	return 2;  } -int stream_put3_at(struct stream *s, size_t putp, u_int32_t l) +int stream_put3_at(struct stream *s, size_t putp, uint32_t l)  {  	STREAM_VERIFY_SANE(s); @@ -758,25 +758,25 @@ int stream_put3_at(struct stream *s, size_t putp, u_int32_t l)  		STREAM_BOUND_WARN(s, "put");  		return 0;  	} -	s->data[putp] = (u_char)(l >> 16); -	s->data[putp + 1] = (u_char)(l >> 8); -	s->data[putp + 2] = (u_char)l; +	s->data[putp] = (uint8_t)(l >> 16); +	s->data[putp + 1] = (uint8_t)(l >> 8); +	s->data[putp + 2] = (uint8_t)l;  	return 3;  } -int stream_putl_at(struct stream *s, size_t putp, u_int32_t l) +int stream_putl_at(struct stream *s, size_t putp, uint32_t l)  {  	STREAM_VERIFY_SANE(s); -	if (!PUT_AT_VALID(s, putp + sizeof(u_int32_t))) { +	if (!PUT_AT_VALID(s, putp + sizeof(uint32_t))) {  		STREAM_BOUND_WARN(s, "put");  		return 0;  	} -	s->data[putp] = (u_char)(l >> 24); -	s->data[putp + 1] = (u_char)(l >> 16); -	s->data[putp + 2] = (u_char)(l >> 8); -	s->data[putp + 3] = (u_char)l; +	s->data[putp] = (uint8_t)(l >> 24); +	s->data[putp + 1] = (uint8_t)(l >> 16); +	s->data[putp + 2] = (uint8_t)(l >> 8); +	s->data[putp + 3] = (uint8_t)l;  	return 4;  } @@ -789,31 +789,31 @@ int stream_putq_at(struct stream *s, size_t putp, uint64_t q)  		STREAM_BOUND_WARN(s, "put");  		return 0;  	} -	s->data[putp] = (u_char)(q >> 56); -	s->data[putp + 1] = (u_char)(q >> 48); -	s->data[putp + 2] = (u_char)(q >> 40); -	s->data[putp + 3] = (u_char)(q >> 32); -	s->data[putp + 4] = (u_char)(q >> 24); -	s->data[putp + 5] = (u_char)(q >> 16); -	s->data[putp + 6] = (u_char)(q >> 8); -	s->data[putp + 7] = (u_char)q; +	s->data[putp] = (uint8_t)(q >> 56); +	s->data[putp + 1] = (uint8_t)(q >> 48); +	s->data[putp + 2] = (uint8_t)(q >> 40); +	s->data[putp + 3] = (uint8_t)(q >> 32); +	s->data[putp + 4] = (uint8_t)(q >> 24); +	s->data[putp + 5] = (uint8_t)(q >> 16); +	s->data[putp + 6] = (uint8_t)(q >> 8); +	s->data[putp + 7] = (uint8_t)q;  	return 8;  }  /* Put long word to the stream. */ -int stream_put_ipv4(struct stream *s, u_int32_t l) +int stream_put_ipv4(struct stream *s, uint32_t l)  {  	STREAM_VERIFY_SANE(s); -	if (STREAM_WRITEABLE(s) < sizeof(u_int32_t)) { +	if (STREAM_WRITEABLE(s) < sizeof(uint32_t)) {  		STREAM_BOUND_WARN(s, "put");  		return 0;  	} -	memcpy(s->data + s->endp, &l, sizeof(u_int32_t)); -	s->endp += sizeof(u_int32_t); +	memcpy(s->data + s->endp, &l, sizeof(uint32_t)); +	s->endp += sizeof(uint32_t); -	return sizeof(u_int32_t); +	return sizeof(uint32_t);  }  /* Put long word to the stream. */ @@ -821,15 +821,15 @@ int stream_put_in_addr(struct stream *s, struct in_addr *addr)  {  	STREAM_VERIFY_SANE(s); -	if (STREAM_WRITEABLE(s) < sizeof(u_int32_t)) { +	if (STREAM_WRITEABLE(s) < sizeof(uint32_t)) {  		STREAM_BOUND_WARN(s, "put");  		return 0;  	} -	memcpy(s->data + s->endp, addr, sizeof(u_int32_t)); -	s->endp += sizeof(u_int32_t); +	memcpy(s->data + s->endp, addr, sizeof(uint32_t)); +	s->endp += sizeof(uint32_t); -	return sizeof(u_int32_t); +	return sizeof(uint32_t);  }  /* Put in_addr at location in the stream. */ @@ -862,7 +862,7 @@ int stream_put_in6_addr_at(struct stream *s, size_t putp, struct in6_addr *addr)  /* Put prefix by nlri type format. */  int stream_put_prefix_addpath(struct stream *s, struct prefix *p, -			      int addpath_encode, u_int32_t addpath_tx_id) +			      int addpath_encode, uint32_t addpath_tx_id)  {  	size_t psize;  	size_t psize_with_addpath; @@ -876,16 +876,16 @@ int stream_put_prefix_addpath(struct stream *s, struct prefix *p,  	else  		psize_with_addpath = psize; -	if (STREAM_WRITEABLE(s) < (psize_with_addpath + sizeof(u_char))) { +	if (STREAM_WRITEABLE(s) < (psize_with_addpath + sizeof(uint8_t))) {  		STREAM_BOUND_WARN(s, "put");  		return 0;  	}  	if (addpath_encode) { -		s->data[s->endp++] = (u_char)(addpath_tx_id >> 24); -		s->data[s->endp++] = (u_char)(addpath_tx_id >> 16); -		s->data[s->endp++] = (u_char)(addpath_tx_id >> 8); -		s->data[s->endp++] = (u_char)addpath_tx_id; +		s->data[s->endp++] = (uint8_t)(addpath_tx_id >> 24); +		s->data[s->endp++] = (uint8_t)(addpath_tx_id >> 16); +		s->data[s->endp++] = (uint8_t)(addpath_tx_id >> 8); +		s->data[s->endp++] = (uint8_t)addpath_tx_id;  	}  	s->data[s->endp++] = p->prefixlen; @@ -905,7 +905,7 @@ int stream_put_labeled_prefix(struct stream *s, struct prefix *p,  			      mpls_label_t *label)  {  	size_t psize; -	u_char *label_pnt = (u_char *)label; +	uint8_t *label_pnt = (uint8_t *)label;  	STREAM_VERIFY_SANE(s); @@ -1060,7 +1060,7 @@ size_t stream_write(struct stream *s, const void *ptr, size_t size)   * Use stream_get_pnt_to if you must, but decoding streams properly   * is preferred   */ -u_char *stream_pnt(struct stream *s) +uint8_t *stream_pnt(struct stream *s)  {  	STREAM_VERIFY_SANE(s);  	return s->data + s->getp; diff --git a/lib/stream.h b/lib/stream.h index e738040d34..8011fc0963 100644 --- a/lib/stream.h +++ b/lib/stream.h @@ -148,7 +148,7 @@ extern size_t stream_resize(struct stream *, size_t);  extern size_t stream_get_getp(struct stream *);  extern size_t stream_get_endp(struct stream *);  extern size_t stream_get_size(struct stream *); -extern u_char *stream_get_data(struct stream *); +extern uint8_t *stream_get_data(struct stream *);  /**   * Create a new stream structure; copy offset bytes from s1 to the new @@ -165,43 +165,43 @@ extern void stream_forward_endp(struct stream *, size_t);  /* steam_put: NULL source zeroes out size_t bytes of stream */  extern void stream_put(struct stream *, const void *, size_t); -extern int stream_putc(struct stream *, u_char); -extern int stream_putc_at(struct stream *, size_t, u_char); -extern int stream_putw(struct stream *, u_int16_t); -extern int stream_putw_at(struct stream *, size_t, u_int16_t); -extern int stream_put3(struct stream *, u_int32_t); -extern int stream_put3_at(struct stream *, size_t, u_int32_t); -extern int stream_putl(struct stream *, u_int32_t); -extern int stream_putl_at(struct stream *, size_t, u_int32_t); +extern int stream_putc(struct stream *, uint8_t); +extern int stream_putc_at(struct stream *, size_t, uint8_t); +extern int stream_putw(struct stream *, uint16_t); +extern int stream_putw_at(struct stream *, size_t, uint16_t); +extern int stream_put3(struct stream *, uint32_t); +extern int stream_put3_at(struct stream *, size_t, uint32_t); +extern int stream_putl(struct stream *, uint32_t); +extern int stream_putl_at(struct stream *, size_t, uint32_t);  extern int stream_putq(struct stream *, uint64_t);  extern int stream_putq_at(struct stream *, size_t, uint64_t); -extern int stream_put_ipv4(struct stream *, u_int32_t); +extern int stream_put_ipv4(struct stream *, uint32_t);  extern int stream_put_in_addr(struct stream *, struct in_addr *);  extern int stream_put_in_addr_at(struct stream *, size_t, struct in_addr *);  extern int stream_put_in6_addr_at(struct stream *, size_t, struct in6_addr *);  extern int stream_put_prefix_addpath(struct stream *, struct prefix *,  				     int addpath_encode, -				     u_int32_t addpath_tx_id); +				     uint32_t addpath_tx_id);  extern int stream_put_prefix(struct stream *, struct prefix *);  extern int stream_put_labeled_prefix(struct stream *, struct prefix *,  				     mpls_label_t *);  extern void stream_get(void *, struct stream *, size_t);  extern bool stream_get2(void *data, struct stream *s, size_t size);  extern void stream_get_from(void *, struct stream *, size_t, size_t); -extern u_char stream_getc(struct stream *); -extern bool stream_getc2(struct stream *s, u_char *byte); -extern u_char stream_getc_from(struct stream *, size_t); -extern u_int16_t stream_getw(struct stream *); +extern uint8_t stream_getc(struct stream *); +extern bool stream_getc2(struct stream *s, uint8_t *byte); +extern uint8_t stream_getc_from(struct stream *, size_t); +extern uint16_t stream_getw(struct stream *);  extern bool stream_getw2(struct stream *s, uint16_t *word); -extern u_int16_t stream_getw_from(struct stream *, size_t); -extern u_int32_t stream_get3(struct stream *); -extern u_int32_t stream_get3_from(struct stream *, size_t); -extern u_int32_t stream_getl(struct stream *); +extern uint16_t stream_getw_from(struct stream *, size_t); +extern uint32_t stream_get3(struct stream *); +extern uint32_t stream_get3_from(struct stream *, size_t); +extern uint32_t stream_getl(struct stream *);  extern bool stream_getl2(struct stream *s, uint32_t *l); -extern u_int32_t stream_getl_from(struct stream *, size_t); +extern uint32_t stream_getl_from(struct stream *, size_t);  extern uint64_t stream_getq(struct stream *);  extern uint64_t stream_getq_from(struct stream *, size_t); -extern u_int32_t stream_get_ipv4(struct stream *); +extern uint32_t stream_get_ipv4(struct stream *);  /* IEEE-754 floats */  extern float stream_getf(struct stream *); @@ -238,7 +238,7 @@ extern int stream_flush(struct stream *, int);  extern int stream_empty(struct stream *); /* is the stream empty? */  /* deprecated */ -extern u_char *stream_pnt(struct stream *); +extern uint8_t *stream_pnt(struct stream *);  /* Stream fifo. */  extern struct stream_fifo *stream_fifo_new(void); diff --git a/lib/table.c b/lib/table.c index 76062cd10c..bf63609bc3 100644 --- a/lib/table.c +++ b/lib/table.c @@ -142,20 +142,20 @@ static void route_table_free(struct route_table *rt)  }  /* Utility mask array. */ -static const u_char maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0, -				 0xf8, 0xfc, 0xfe, 0xff}; +static const uint8_t maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0, +				  0xf8, 0xfc, 0xfe, 0xff};  /* Common prefix route genaration. */  static void route_common(const struct prefix *n, const struct prefix *p,  			 struct prefix *new)  {  	int i; -	u_char diff; -	u_char mask; +	uint8_t diff; +	uint8_t mask; -	const u_char *np = (const u_char *)&n->u.prefix; -	const u_char *pp = (const u_char *)&p->u.prefix; -	u_char *newp = (u_char *)&new->u.prefix; +	const uint8_t *np = (const uint8_t *)&n->u.prefix; +	const uint8_t *pp = (const uint8_t *)&p->u.prefix; +	uint8_t *newp = (uint8_t *)&new->u.prefix;  	for (i = 0; i < p->prefixlen / 8; i++) {  		if (np[i] == pp[i]) @@ -277,8 +277,8 @@ struct route_node *route_node_get(struct route_table *const table,  	struct route_node *node;  	struct route_node *match;  	struct route_node *inserted; -	u_char prefixlen = p->prefixlen; -	const u_char *prefix = &p->u.prefix; +	uint8_t prefixlen = p->prefixlen; +	const uint8_t *prefix = &p->u.prefix;  	apply_mask((struct prefix *)p);  	node = hash_get(table->hash, (void *)p, NULL); diff --git a/lib/thread.c b/lib/thread.c index d26be1541f..f3129e39e8 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -621,7 +621,7 @@ struct timeval thread_timer_remain(struct thread *thread)  }  /* Get new thread.  */ -static struct thread *thread_get(struct thread_master *m, u_char type, +static struct thread *thread_get(struct thread_master *m, uint8_t type,  				 int (*func)(struct thread *), void *arg,  				 debugargdef)  { diff --git a/lib/vlan.h b/lib/vlan.h index 5e735aac1f..6d15e62dfc 100644 --- a/lib/vlan.h +++ b/lib/vlan.h @@ -23,7 +23,7 @@  #define __VLAN_H__  /* VLAN Identifier */ -typedef u_int16_t vlanid_t; +typedef uint16_t vlanid_t;  #define VLANID_MAX 4095  #endif /* __VLAN_H__ */ @@ -343,10 +343,11 @@ void *vrf_info_lookup(vrf_id_t vrf_id)  #define VRF_BITMAP_BIT_OFFSET(_id) ((_id) % VRF_BITMAP_NUM_OF_BITS_IN_GROUP)  #define VRF_BITMAP_INDEX_IN_GROUP(_bit_offset) ((_bit_offset) / CHAR_BIT) -#define VRF_BITMAP_FLAG(_bit_offset) (((u_char)1) << ((_bit_offset) % CHAR_BIT)) +#define VRF_BITMAP_FLAG(_bit_offset)                                           \ +	(((uint8_t)1) << ((_bit_offset) % CHAR_BIT))  struct vrf_bitmap { -	u_char *groups[VRF_BITMAP_NUM_OF_GROUPS]; +	uint8_t *groups[VRF_BITMAP_NUM_OF_GROUPS];  };  vrf_bitmap_t vrf_bitmap_init(void) @@ -373,8 +374,8 @@ void vrf_bitmap_free(vrf_bitmap_t bmap)  void vrf_bitmap_set(vrf_bitmap_t bmap, vrf_id_t vrf_id)  {  	struct vrf_bitmap *bm = (struct vrf_bitmap *)bmap; -	u_char group = VRF_BITMAP_GROUP(vrf_id); -	u_char offset = VRF_BITMAP_BIT_OFFSET(vrf_id); +	uint8_t group = VRF_BITMAP_GROUP(vrf_id); +	uint8_t offset = VRF_BITMAP_BIT_OFFSET(vrf_id);  	if (bmap == VRF_BITMAP_NULL || vrf_id == VRF_UNKNOWN)  		return; @@ -390,8 +391,8 @@ void vrf_bitmap_set(vrf_bitmap_t bmap, vrf_id_t vrf_id)  void vrf_bitmap_unset(vrf_bitmap_t bmap, vrf_id_t vrf_id)  {  	struct vrf_bitmap *bm = (struct vrf_bitmap *)bmap; -	u_char group = VRF_BITMAP_GROUP(vrf_id); -	u_char offset = VRF_BITMAP_BIT_OFFSET(vrf_id); +	uint8_t group = VRF_BITMAP_GROUP(vrf_id); +	uint8_t offset = VRF_BITMAP_BIT_OFFSET(vrf_id);  	if (bmap == VRF_BITMAP_NULL || vrf_id == VRF_UNKNOWN  	    || bm->groups[group] == NULL) @@ -404,8 +405,8 @@ void vrf_bitmap_unset(vrf_bitmap_t bmap, vrf_id_t vrf_id)  int vrf_bitmap_check(vrf_bitmap_t bmap, vrf_id_t vrf_id)  {  	struct vrf_bitmap *bm = (struct vrf_bitmap *)bmap; -	u_char group = VRF_BITMAP_GROUP(vrf_id); -	u_char offset = VRF_BITMAP_BIT_OFFSET(vrf_id); +	uint8_t group = VRF_BITMAP_GROUP(vrf_id); +	uint8_t offset = VRF_BITMAP_BIT_OFFSET(vrf_id);  	if (bmap == VRF_BITMAP_NULL || vrf_id == VRF_UNKNOWN  	    || bm->groups[group] == NULL) @@ -73,7 +73,7 @@ struct vrf {  	char name[VRF_NAMSIZ + 1];  	/* Zebra internal VRF status */ -	u_char status; +	uint8_t status;  #define VRF_ACTIVE     (1 << 0) /* VRF is up in kernel */  #define VRF_CONFIGURED (1 << 1) /* VRF has some FRR configuration */ @@ -160,9 +160,9 @@ int vty_out(struct vty *vty, const char *format, ...)  		/* Pointer p must point out buffer. */  		if (vty->type != VTY_TERM) -			buffer_put(vty->obuf, (u_char *)p, len); +			buffer_put(vty->obuf, (uint8_t *)p, len);  		else -			buffer_put_crlf(vty->obuf, (u_char *)p, len); +			buffer_put_crlf(vty->obuf, (uint8_t *)p, len);  		/* If p is not different with buf, it is allocated buffer.  */  		if (p != buf) @@ -1243,12 +1243,12 @@ static int vty_telnet_option(struct vty *vty, unsigned char *buf, int nbytes)  					"RFC 1073 violation detected: telnet NAWS option "  					"should send %d characters, but we received %lu",  					TELNET_NAWS_SB_LEN, -					(u_long)vty->sb_len); +					(unsigned long)vty->sb_len);  			else if (sizeof(vty->sb_buf) < TELNET_NAWS_SB_LEN)  				zlog_err(  					"Bug detected: sizeof(vty->sb_buf) %lu < %d, "  					"too small to handle the telnet NAWS option", -					(u_long)sizeof(vty->sb_buf), +					(unsigned long)sizeof(vty->sb_buf),  					TELNET_NAWS_SB_LEN);  			else {  				vty->width = ((vty->sb_buf[1] << 8) @@ -2057,7 +2057,7 @@ static int vtysh_read(struct thread *thread)  	struct vty *vty;  	unsigned char buf[VTY_READ_BUFSIZ];  	unsigned char *p; -	u_char header[4] = {0, 0, 0, 0}; +	uint8_t header[4] = {0, 0, 0, 0};  	sock = THREAD_FD(thread);  	vty = THREAD_ARG(thread); diff --git a/lib/vxlan.h b/lib/vxlan.h index 75c7b97347..ba3dbb05c8 100644 --- a/lib/vxlan.h +++ b/lib/vxlan.h @@ -23,7 +23,7 @@  #define __VXLAN_H__  /* VxLAN Network Identifier - 24-bit (RFC 7348) */ -typedef u_int32_t vni_t; +typedef uint32_t vni_t;  #define VNI_MAX 16777215 /* (2^24 - 1) */  #endif /* __VXLAN_H__ */ diff --git a/lib/workqueue.h b/lib/workqueue.h index c9785de09a..fe1700f8de 100644 --- a/lib/workqueue.h +++ b/lib/workqueue.h @@ -106,7 +106,7 @@ struct work_queue {  	} cycles; /* cycle counts */  	/* private state */ -	u_int16_t flags; /* user set flag */ +	uint16_t flags; /* user set flag */  };  /* User API */ diff --git a/lib/zclient.c b/lib/zclient.c index 2cac71ac45..4659bce1b1 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -88,10 +88,11 @@ void zclient_free(struct zclient *zclient)  	XFREE(MTYPE_ZCLIENT, zclient);  } -u_short *redist_check_instance(struct redist_proto *red, u_short instance) +unsigned short *redist_check_instance(struct redist_proto *red, +				      unsigned short instance)  {  	struct listnode *node; -	u_short *id; +	unsigned short *id;  	if (!red->instances)  		return NULL; @@ -103,23 +104,23 @@ u_short *redist_check_instance(struct redist_proto *red, u_short instance)  	return NULL;  } -void redist_add_instance(struct redist_proto *red, u_short instance) +void redist_add_instance(struct redist_proto *red, unsigned short instance)  { -	u_short *in; +	unsigned short *in;  	red->enabled = 1;  	if (!red->instances)  		red->instances = list_new(); -	in = XMALLOC(MTYPE_REDIST_INST, sizeof(u_short)); +	in = XMALLOC(MTYPE_REDIST_INST, sizeof(unsigned short));  	*in = instance;  	listnode_add(red->instances, in);  } -void redist_del_instance(struct redist_proto *red, u_short instance) +void redist_del_instance(struct redist_proto *red, unsigned short instance)  { -	u_short *id; +	unsigned short *id;  	id = redist_check_instance(red, instance);  	if (!id) @@ -294,9 +295,9 @@ void zclient_create_header(struct stream *s, uint16_t command, vrf_id_t vrf_id)  	stream_putw(s, command);  } -int zclient_read_header(struct stream *s, int sock, u_int16_t *size, -			u_char *marker, u_char *version, vrf_id_t *vrf_id, -			u_int16_t *cmd) +int zclient_read_header(struct stream *s, int sock, uint16_t *size, +			uint8_t *marker, uint8_t *version, vrf_id_t *vrf_id, +			uint16_t *cmd)  {  	if (stream_read(s, sock, ZEBRA_HEADER_SIZE) != ZEBRA_HEADER_SIZE)  		return -1; @@ -423,7 +424,7 @@ void zclient_send_reg_requests(struct zclient *zclient, vrf_id_t vrf_id)  					continue;  				struct listnode *node; -				u_short *id; +				unsigned short *id;  				for (ALL_LIST_ELEMENTS_RO(  					     zclient->mi_redist[afi][i] @@ -488,7 +489,7 @@ void zclient_send_dereg_requests(struct zclient *zclient, vrf_id_t vrf_id)  					continue;  				struct listnode *node; -				u_short *id; +				unsigned short *id;  				for (ALL_LIST_ELEMENTS_RO(  					     zclient->mi_redist[afi][i] @@ -594,8 +595,8 @@ int zclient_start(struct zclient *zclient)  /* Initialize zebra client.  Argument redist_default is unwanted     redistribute route type. */ -void zclient_init(struct zclient *zclient, int redist_default, u_short instance, -		  struct zebra_privs_t *privs) +void zclient_init(struct zclient *zclient, int redist_default, +		  unsigned short instance, struct zebra_privs_t *privs)  {  	int afi, i; @@ -730,7 +731,7 @@ int zclient_send_rnh(struct zclient *zclient, int command, struct prefix *p,   *   * XXX: No attention paid to alignment.   */ -int zapi_ipv4_route(u_char cmd, struct zclient *zclient, struct prefix_ipv4 *p, +int zapi_ipv4_route(uint8_t cmd, struct zclient *zclient, struct prefix_ipv4 *p,  		    struct zapi_ipv4 *api)  {  	int i; @@ -765,7 +766,7 @@ int zapi_ipv4_route(u_char cmd, struct zclient *zclient, struct prefix_ipv4 *p,  	/* Put prefix information. */  	psize = PSIZE(p->prefixlen);  	stream_putc(s, p->prefixlen); -	stream_write(s, (u_char *)&p->prefix, psize); +	stream_write(s, (uint8_t *)&p->prefix, psize);  	/* Nexthop, ifindex, distance and metric information. */  	if (CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) { @@ -800,7 +801,7 @@ int zapi_ipv4_route(u_char cmd, struct zclient *zclient, struct prefix_ipv4 *p,  	return zclient_send_message(zclient);  } -int zapi_ipv4_route_ipv6_nexthop(u_char cmd, struct zclient *zclient, +int zapi_ipv4_route_ipv6_nexthop(uint8_t cmd, struct zclient *zclient,  				 struct prefix_ipv4 *p, struct zapi_ipv6 *api)  {  	int i; @@ -835,7 +836,7 @@ int zapi_ipv4_route_ipv6_nexthop(u_char cmd, struct zclient *zclient,  	/* Put prefix information. */  	psize = PSIZE(p->prefixlen);  	stream_putc(s, p->prefixlen); -	stream_write(s, (u_char *)&p->prefix, psize); +	stream_write(s, (uint8_t *)&p->prefix, psize);  	/* Nexthop, ifindex, distance and metric information. */  	if (CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) { @@ -843,7 +844,7 @@ int zapi_ipv4_route_ipv6_nexthop(u_char cmd, struct zclient *zclient,  		for (i = 0; i < api->nexthop_num; i++) {  			stream_putc(s, NEXTHOP_TYPE_IPV6); -			stream_write(s, (u_char *)api->nexthop[i], 16); +			stream_write(s, (uint8_t *)api->nexthop[i], 16);  			/* For labeled-unicast, each nexthop is followed by  			 * label. */  			if (CHECK_FLAG(api->message, ZAPI_MESSAGE_LABEL)) @@ -870,7 +871,7 @@ int zapi_ipv4_route_ipv6_nexthop(u_char cmd, struct zclient *zclient,  	return zclient_send_message(zclient);  } -int zapi_ipv6_route(u_char cmd, struct zclient *zclient, struct prefix_ipv6 *p, +int zapi_ipv6_route(uint8_t cmd, struct zclient *zclient, struct prefix_ipv6 *p,  		    struct prefix_ipv6 *src_p, struct zapi_ipv6 *api)  {  	int i; @@ -909,12 +910,12 @@ int zapi_ipv6_route(u_char cmd, struct zclient *zclient, struct prefix_ipv6 *p,  	/* Put prefix information. */  	psize = PSIZE(p->prefixlen);  	stream_putc(s, p->prefixlen); -	stream_write(s, (u_char *)&p->prefix, psize); +	stream_write(s, (uint8_t *)&p->prefix, psize);  	if (CHECK_FLAG(api->message, ZAPI_MESSAGE_SRCPFX)) {  		psize = PSIZE(src_p->prefixlen);  		stream_putc(s, src_p->prefixlen); -		stream_write(s, (u_char *)&src_p->prefix, psize); +		stream_write(s, (uint8_t *)&src_p->prefix, psize);  	}  	/* Nexthop, ifindex, distance and metric information. */ @@ -923,7 +924,7 @@ int zapi_ipv6_route(u_char cmd, struct zclient *zclient, struct prefix_ipv6 *p,  		for (i = 0; i < api->nexthop_num; i++) {  			stream_putc(s, NEXTHOP_TYPE_IPV6); -			stream_write(s, (u_char *)api->nexthop[i], 16); +			stream_write(s, (uint8_t *)api->nexthop[i], 16);  			/* For labeled-unicast, each nexthop is followed by  			 * label. */  			if (CHECK_FLAG(api->message, ZAPI_MESSAGE_LABEL)) @@ -950,7 +951,7 @@ int zapi_ipv6_route(u_char cmd, struct zclient *zclient, struct prefix_ipv6 *p,  	return zclient_send_message(zclient);  } -int zclient_route_send(u_char cmd, struct zclient *zclient, +int zclient_route_send(uint8_t cmd, struct zclient *zclient,  		       struct zapi_route *api)  {  	if (zapi_route_encode(cmd, zclient->obuf, api) < 0) @@ -958,7 +959,7 @@ int zclient_route_send(u_char cmd, struct zclient *zclient,  	return zclient_send_message(zclient);  } -int zapi_route_encode(u_char cmd, struct stream *s, struct zapi_route *api) +int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api)  {  	struct zapi_nexthop *api_nh;  	int i; @@ -979,12 +980,12 @@ int zapi_route_encode(u_char cmd, struct stream *s, struct zapi_route *api)  	stream_putc(s, api->prefix.family);  	psize = PSIZE(api->prefix.prefixlen);  	stream_putc(s, api->prefix.prefixlen); -	stream_write(s, (u_char *)&api->prefix.u.prefix, psize); +	stream_write(s, (uint8_t *)&api->prefix.u.prefix, psize);  	if (CHECK_FLAG(api->message, ZAPI_MESSAGE_SRCPFX)) {  		psize = PSIZE(api->src_prefix.prefixlen);  		stream_putc(s, api->src_prefix.prefixlen); -		stream_write(s, (u_char *)&api->src_prefix.prefix, psize); +		stream_write(s, (uint8_t *)&api->src_prefix.prefix, psize);  	}  	/* Nexthops.  */ @@ -1023,11 +1024,11 @@ int zapi_route_encode(u_char cmd, struct stream *s, struct zapi_route *api)  				stream_putl(s, api_nh->ifindex);  				break;  			case NEXTHOP_TYPE_IPV6: -				stream_write(s, (u_char *)&api_nh->gate.ipv6, +				stream_write(s, (uint8_t *)&api_nh->gate.ipv6,  					     16);  				break;  			case NEXTHOP_TYPE_IPV6_IFINDEX: -				stream_write(s, (u_char *)&api_nh->gate.ipv6, +				stream_write(s, (uint8_t *)&api_nh->gate.ipv6,  					     16);  				stream_putl(s, api_nh->ifindex);  				break; @@ -1364,7 +1365,7 @@ stream_failure:   * sending client   */  int zebra_redistribute_send(int command, struct zclient *zclient, afi_t afi, -			    int type, u_short instance, vrf_id_t vrf_id) +			    int type, unsigned short instance, vrf_id_t vrf_id)  {  	struct stream *s; @@ -1385,7 +1386,7 @@ int zebra_redistribute_send(int command, struct zclient *zclient, afi_t afi,  static void zclient_stream_get_prefix(struct stream *s, struct prefix *p)  {  	size_t plen = prefix_blen(p); -	u_char c; +	uint8_t c;  	p->prefixlen = 0;  	if (plen == 0) @@ -1597,7 +1598,7 @@ struct interface *zebra_interface_link_params_read(struct stream *s)  void zebra_interface_if_set_value(struct stream *s, struct interface *ifp)  { -	u_char link_params_status = 0; +	uint8_t link_params_status = 0;  	/* Read interface's index. */  	if_set_index(ifp, stream_getl(s)); @@ -1700,7 +1701,7 @@ size_t zebra_interface_link_params_write(struct stream *s,  static int memconstant(const void *s, int c, size_t n)  { -	const u_char *p = s; +	const uint8_t *p = s;  	while (n-- > 0)  		if (*p++ != c) @@ -1717,7 +1718,7 @@ struct connected *zebra_interface_address_read(int type, struct stream *s,  	struct connected *ifc;  	struct prefix p, d, *dp;  	int plen; -	u_char ifc_flags; +	uint8_t ifc_flags;  	memset(&p, 0, sizeof(p));  	memset(&d, 0, sizeof(d)); @@ -1882,14 +1883,14 @@ struct interface *zebra_interface_vrf_update_read(struct stream *s,  /* filter unwanted messages until the expected one arrives */  static int zclient_read_sync_response(struct zclient *zclient, -				      u_int16_t expected_cmd) +				      uint16_t expected_cmd)  {  	struct stream *s; -	u_int16_t size = -1; -	u_char marker; -	u_char version; +	uint16_t size = -1; +	uint8_t marker; +	uint8_t version;  	vrf_id_t vrf_id; -	u_int16_t cmd; +	uint16_t cmd;  	fd_set readfds;  	int ret; @@ -1932,7 +1933,7 @@ int lm_label_manager_connect(struct zclient *zclient)  {  	int ret;  	struct stream *s; -	u_char result; +	uint8_t result;  	if (zclient_debug)  		zlog_debug("Connecting to Label Manager"); @@ -1999,12 +2000,12 @@ int lm_label_manager_connect(struct zclient *zclient)   * @param end To write last assigned chunk label to   * @result 0 on success, -1 otherwise   */ -int lm_get_label_chunk(struct zclient *zclient, u_char keep, +int lm_get_label_chunk(struct zclient *zclient, uint8_t keep,  		       uint32_t chunk_size, uint32_t *start, uint32_t *end)  {  	int ret;  	struct stream *s; -	u_char response_keep; +	uint8_t response_keep;  	if (zclient_debug)  		zlog_debug("Getting Label Chunk"); @@ -2144,7 +2145,7 @@ int zebra_send_pw(struct zclient *zclient, int command, struct zapi_pw *pw)  		stream_put_in_addr(s, &pw->nexthop.ipv4);  		break;  	case AF_INET6: -		stream_write(s, (u_char *)&pw->nexthop.ipv6, 16); +		stream_write(s, (uint8_t *)&pw->nexthop.ipv6, 16);  		break;  	default:  		zlog_err("%s: unknown af", __func__); @@ -2247,7 +2248,8 @@ static int zclient_read(struct thread *thread)  		struct stream *ns;  		zlog_warn(  			"%s: message size %u exceeds buffer size %lu, expanding...", -			__func__, length, (u_long)STREAM_SIZE(zclient->ibuf)); +			__func__, length, +			(unsigned long)STREAM_SIZE(zclient->ibuf));  		ns = stream_new(length);  		stream_copy(ns, zclient->ibuf);  		stream_free(zclient->ibuf); @@ -2452,7 +2454,7 @@ static int zclient_read(struct thread *thread)  }  void zclient_redistribute(int command, struct zclient *zclient, afi_t afi, -			  int type, u_short instance, vrf_id_t vrf_id) +			  int type, unsigned short instance, vrf_id_t vrf_id)  {  	if (instance) { diff --git a/lib/zclient.h b/lib/zclient.h index 8033488444..b51c518463 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -135,7 +135,7 @@ typedef enum {  } zebra_message_types_t;  struct redist_proto { -	u_char enabled; +	uint8_t enabled;  	struct list *instances;  }; @@ -173,8 +173,8 @@ struct zclient {  	struct thread *t_write;  	/* Redistribute information. */ -	u_char redist_default; /* clients protocol */ -	u_short instance; +	uint8_t redist_default; /* clients protocol */ +	unsigned short instance;  	struct redist_proto mi_redist[AFI_MAX][ZEBRA_ROUTE_MAX];  	vrf_bitmap_t redist[AFI_MAX][ZEBRA_ROUTE_MAX]; @@ -270,12 +270,12 @@ struct zapi_nexthop {   * to encode/decode.   */  struct zapi_route { -	u_char type; -	u_short instance; +	uint8_t type; +	unsigned short instance; -	u_int32_t flags; +	uint32_t flags; -	u_char message; +	uint8_t message;  	/*  	 * This is an enum but we are going to treat it as a uint8_t @@ -286,16 +286,16 @@ struct zapi_route {  	struct prefix prefix;  	struct prefix_ipv6 src_prefix; -	u_int16_t nexthop_num; +	uint16_t nexthop_num;  	struct zapi_nexthop nexthops[MULTIPATH_NUM]; -	u_char distance; +	uint8_t distance; -	u_int32_t metric; +	uint32_t metric;  	route_tag_t tag; -	u_int32_t mtu; +	uint32_t mtu;  	vrf_id_t vrf_id; @@ -306,31 +306,31 @@ struct zapi_route {  /* Zebra IPv4 route message API. */  struct zapi_ipv4 { -	u_char type; -	u_short instance; +	uint8_t type; +	unsigned short instance; -	u_int32_t flags; +	uint32_t flags; -	u_char message; +	uint8_t message;  	safi_t safi; -	u_char nexthop_num; +	uint8_t nexthop_num;  	struct in_addr **nexthop; -	u_char ifindex_num; +	uint8_t ifindex_num;  	ifindex_t *ifindex; -	u_char label_num; +	uint8_t label_num;  	unsigned int *label; -	u_char distance; +	uint8_t distance; -	u_int32_t metric; +	uint32_t metric;  	route_tag_t tag; -	u_int32_t mtu; +	uint32_t mtu;  	vrf_id_t vrf_id;  }; @@ -394,7 +394,7 @@ extern struct zclient *zclient_new_notify(struct thread_master *m,  	zclient_new_notify((A), &zclient_options_default);                     \  	CPP_WARN("Please transition to using zclient_new_notify"); -extern void zclient_init(struct zclient *, int, u_short, +extern void zclient_init(struct zclient *, int, unsigned short,  			 struct zebra_privs_t *privs);  extern int zclient_start(struct zclient *);  extern void zclient_stop(struct zclient *); @@ -403,9 +403,10 @@ extern void zclient_free(struct zclient *);  extern int zclient_socket_connect(struct zclient *); -extern u_short *redist_check_instance(struct redist_proto *, u_short); -extern void redist_add_instance(struct redist_proto *, u_short); -extern void redist_del_instance(struct redist_proto *, u_short); +extern unsigned short *redist_check_instance(struct redist_proto *, +					     unsigned short); +extern void redist_add_instance(struct redist_proto *, unsigned short); +extern void redist_del_instance(struct redist_proto *, unsigned short);  /*   * Send to zebra that the specified vrf is using label to resolve @@ -434,11 +435,12 @@ extern void zclient_send_interface_radv_req(struct zclient *zclient,  /* Send redistribute command to zebra daemon. Do not update zclient state. */  extern int zebra_redistribute_send(int command, struct zclient *, afi_t, -				   int type, u_short instance, vrf_id_t vrf_id); +				   int type, unsigned short instance, +				   vrf_id_t vrf_id);  /* If state has changed, update state and call zebra_redistribute_send. */  extern void zclient_redistribute(int command, struct zclient *, afi_t, int type, -				 u_short instance, vrf_id_t vrf_id); +				 unsigned short instance, vrf_id_t vrf_id);  /* If state has changed, update state and send the command to zebra. */  extern void zclient_redistribute_default(int command, struct zclient *, @@ -483,9 +485,9 @@ extern void zclient_create_header(struct stream *, uint16_t, vrf_id_t);   *    - a marker mismatch was detected   *    - header size field specified more data than could be read   */ -extern int zclient_read_header(struct stream *s, int sock, u_int16_t *size, -			       u_char *marker, u_char *version, -			       vrf_id_t *vrf_id, u_int16_t *cmd); +extern int zclient_read_header(struct stream *s, int sock, uint16_t *size, +			       uint8_t *marker, uint8_t *version, +			       vrf_id_t *vrf_id, uint16_t *cmd);  /*   * Parse header from ZAPI message stream into struct zmsghdr.   * This function assumes the stream getp points at the first byte of the header. @@ -524,14 +526,14 @@ CPP_NOTICE("zapi_ipv4_route, zapi_ipv6_route, zapi_ipv4_route_ipv6_nexthop as we  #endif  /* clang-format on */ -extern int zapi_ipv4_route(u_char, struct zclient *, struct prefix_ipv4 *, +extern int zapi_ipv4_route(uint8_t, struct zclient *, struct prefix_ipv4 *,  			   struct zapi_ipv4 *) __attribute__((deprecated));  extern struct interface *zebra_interface_link_params_read(struct stream *);  extern size_t zebra_interface_link_params_write(struct stream *,  						struct interface *);  extern int lm_label_manager_connect(struct zclient *zclient); -extern int lm_get_label_chunk(struct zclient *zclient, u_char keep, +extern int lm_get_label_chunk(struct zclient *zclient, uint8_t keep,  			      uint32_t chunk_size, uint32_t *start,  			      uint32_t *end);  extern int lm_release_label_chunk(struct zclient *zclient, uint32_t start, @@ -545,47 +547,47 @@ extern void zebra_read_pw_status_update(int command, struct zclient *zclient,  /* IPv6 prefix add and delete function prototype. */  struct zapi_ipv6 { -	u_char type; -	u_short instance; +	uint8_t type; +	unsigned short instance; -	u_int32_t flags; +	uint32_t flags; -	u_char message; +	uint8_t message;  	safi_t safi; -	u_char nexthop_num; +	uint8_t nexthop_num;  	struct in6_addr **nexthop; -	u_char ifindex_num; +	uint8_t ifindex_num;  	ifindex_t *ifindex; -	u_char label_num; +	uint8_t label_num;  	unsigned int *label; -	u_char distance; +	uint8_t distance; -	u_int32_t metric; +	uint32_t metric;  	route_tag_t tag; -	u_int32_t mtu; +	uint32_t mtu;  	vrf_id_t vrf_id;  }; -extern int zapi_ipv6_route(u_char cmd, struct zclient *zclient, +extern int zapi_ipv6_route(uint8_t cmd, struct zclient *zclient,  			   struct prefix_ipv6 *p, struct prefix_ipv6 *src_p,  			   struct zapi_ipv6 *api) __attribute__((deprecated)); -extern int zapi_ipv4_route_ipv6_nexthop(u_char, struct zclient *, +extern int zapi_ipv4_route_ipv6_nexthop(uint8_t, struct zclient *,  					struct prefix_ipv4 *,  					struct zapi_ipv6 *)  	__attribute__((deprecated)); -extern int zclient_route_send(u_char, struct zclient *, struct zapi_route *); +extern int zclient_route_send(uint8_t, struct zclient *, struct zapi_route *);  extern int zclient_send_rnh(struct zclient *zclient, int command,  			    struct prefix *p, bool exact_match,  			    vrf_id_t vrf_id); -extern int zapi_route_encode(u_char, struct stream *, struct zapi_route *); +extern int zapi_route_encode(uint8_t, struct stream *, struct zapi_route *);  extern int zapi_route_decode(struct stream *, struct zapi_route *);  bool zapi_route_notify_decode(struct stream *s, struct prefix *p,  			      uint32_t *tableid, diff --git a/lib/zebra.h b/lib/zebra.h index 923f6f77c6..ec530397be 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -27,9 +27,9 @@  #ifdef SUNOS_5  #define _XPG4_2 -typedef unsigned int u_int32_t; -typedef unsigned short u_int16_t; -typedef unsigned char u_int8_t; +typedef unsigned int uint32_t; +typedef unsigned short uint16_t; +typedef unsigned char uint8_t;  #endif /* SUNOS_5 */  #include <unistd.h> @@ -494,8 +494,8 @@ typedef enum {  	((atomic_store_explicit(PV, 0, memory_order_seq_cst)))  /* Zebra types. Used in Zserv message header. */ -typedef u_int16_t zebra_size_t; -typedef u_int16_t zebra_command_t; +typedef uint16_t zebra_size_t; +typedef uint16_t zebra_command_t;  /* VRF ID type. */  typedef uint32_t vrf_id_t;  | 
