u_char *pktd;
struct iovec iv;
struct can_frame* cf;
+ int len;
pktd = (u_char *)handle->buffer + CAN_CONTROL_SIZE;
iv.iov_base = pktd;
do
{
- pkth.caplen = recvmsg(handle->fd, &msg, 0);
+ len = recvmsg(handle->fd, &msg, 0);
if (handle->break_loop)
{
handle->break_loop = 0;
return -2;
}
- } while ((pkth.caplen == -1) && (errno == EINTR));
+ } while ((len == -1) && (errno == EINTR));
- if (pkth.caplen == -1)
+ if (len == -1)
{
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't receive packet %d:%s",
errno, strerror(errno));
return -1;
}
+ pkth.caplen = (bpf_u_int32)len;
/* adjust capture len according to frame len */
cf = (struct can_frame*)(void *)pktd;
const char *dev = handle->opt.device;
DBusError error = DBUS_ERROR_INIT;
- int i;
+ u_int i;
if (strcmp(dev, "dbus-system") == 0) {
if (!(handlep->conn = dbus_bus_get(DBUS_BUS_SYSTEM, &error))) {
#endif
continue;
- len = packet_len > iov.iov_len ? iov.iov_len : packet_len;
+ len = (u_int)packet_len > iov.iov_len ? iov.iov_len : packet_len;
if (len < (unsigned int) handlep->vlan_offset)
break;
*status = PCAP_ERROR;
return -1;
}
- if (frame_size > mtu + 18)
- frame_size = mtu + 18;
+ if (frame_size > (unsigned int)mtu + 18)
+ frame_size = (unsigned int)mtu + 18;
}
}
* Trim the snapshot length to be no longer than the
* specified snapshot length.
*/
- if (pcaphdr.caplen > handle->snapshot)
+ if (pcaphdr.caplen > (bpf_u_int32)handle->snapshot)
pcaphdr.caplen = handle->snapshot;
/* pass the packet to the user */
static void
iface_set_all_ts_types(pcap_t *handle)
{
- int i;
+ u_int i;
handle->tstamp_type_count = NUM_SOF_TIMESTAMPING_TYPES;
handle->tstamp_type_list = malloc(NUM_SOF_TIMESTAMPING_TYPES * sizeof(u_int));
struct ifreq ifr;
struct ethtool_ts_info info;
int num_ts_types;
- int i, j;
+ u_int i, j;
/*
* This doesn't apply to the "any" device; you can't say "turn on
if (mtu == -1)
return PCAP_ERROR;
handle->bufsize = MAX_LINKHEADER_SIZE + mtu;
- if (handle->bufsize < handle->snapshot)
- handle->bufsize = handle->snapshot;
+ if (handle->bufsize < (u_int)handle->snapshot)
+ handle->bufsize = (u_int)handle->snapshot;
} else {
/*
* This is a 2.2[.x] or later kernel.
* We can safely pass "recvfrom()" a byte count
* based on the snapshot length.
*/
- handle->bufsize = handle->snapshot;
+ handle->bufsize = (u_int)handle->snapshot;
}
/*
}
buf = (unsigned char *)handle->buffer;
- while (len >= NLMSG_SPACE(0)) {
+ while ((u_int)len >= NLMSG_SPACE(0)) {
const struct nlmsghdr *nlh = (const struct nlmsghdr *) buf;
u_int32_t msg_len;
nftype_t type = OTHER;
- if (nlh->nlmsg_len < sizeof(struct nlmsghdr) || len < nlh->nlmsg_len) {
+ if (nlh->nlmsg_len < sizeof(struct nlmsghdr) || (u_int)len < nlh->nlmsg_len) {
pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Message truncated: (got: %d) (nlmsg_len: %u)", len, nlh->nlmsg_len);
return -1;
}
}
msg_len = NLMSG_ALIGN(nlh->nlmsg_len);
- if (msg_len > len)
- msg_len = len;
+ if (msg_len > (u_int)len)
+ msg_len = (u_int)len;
len -= msg_len;
buf += msg_len;
if (snl.nl_pid != 0 || seq_id != nlh->nlmsg_seq) /* if not from kernel or wrong sequence skip */
continue;
- while (len >= NLMSG_SPACE(0) && NLMSG_OK(nlh, len)) {
+ while ((u_int)len >= NLMSG_SPACE(0) && NLMSG_OK(nlh, len)) {
if (nlh->nlmsg_type == NLMSG_ERROR || (nlh->nlmsg_type == NLMSG_DONE && nlh->nlmsg_flags & NLM_F_MULTI)) {
if (nlh->nlmsg_len < NLMSG_ALIGN(sizeof(struct nlmsgerr))) {
errno = EBADMSG;
* a partial information.
* At least until linux 2.6.17 there is no way to set usbmon intenal buffer
* length and default value is 130. */
- while ((string[0] != 0) && (string[1] != 0) && (pkth.caplen < handle->snapshot))
+ while ((string[0] != 0) && (string[1] != 0) && (pkth.caplen < (bpf_u_int32)handle->snapshot))
{
rawdata[0] = ascii_to_int(string[0]) * 16 + ascii_to_int(string[1]);
rawdata++;
got:
uhdr->data_len = data_len;
- if (pkth.caplen > handle->snapshot)
- pkth.caplen = handle->snapshot;
+ if (pkth.caplen > (bpf_u_int32)handle->snapshot)
+ pkth.caplen = (bpf_u_int32)handle->snapshot;
if (handle->fcode.bf_insns == NULL ||
bpf_filter(handle->fcode.bf_insns, handle->buffer,
struct mon_bin_get info;
int ret;
struct pcap_pkthdr pkth;
- int clen = handle->snapshot - sizeof(pcap_usb_header);
+ u_int clen = handle->snapshot - sizeof(pcap_usb_header);
/* the usb header is going to be part of 'packet' data*/
info.hdr = (pcap_usb_header*) handle->buffer;