From patchwork Mon Nov 11 01:59:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "mrbff (Code Review)" X-Patchwork-Id: 3933 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:41ba:b0:5d9:9f4c:3bc7 with SMTP id a26csp2278176mad; Sun, 10 Nov 2024 18:00:25 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUGSRApja7kGxDCjAzLk2/V2dzEzsvw4z3IPAHvv/CmGhxkISqjO7J4l2Cp9kFRIQPnuFq+1qJ4jFk=@openvpn.net X-Google-Smtp-Source: AGHT+IGLNtlgAmSETE1Hzx1N02xEZ9C1CkjFRceRL8G+rLPXs9fJJ50PRIvVXKkZ/MYTVbOQO3Bc X-Received: by 2002:a05:6602:6d86:b0:83a:b235:2d74 with SMTP id ca18e2360f4ac-83e032e0387mr1000320339f.7.1731290424821; Sun, 10 Nov 2024 18:00:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731290424; cv=none; d=google.com; s=arc-20240605; b=SLd+GCm5RcRmegJ5yBp3q92N0PwoeR7+OkhCkebD7KFlvYHZK7+ldVU4YxUXbiD6rw hC4auKtmz1FR5vA94VaNkKi+pB4Hfmfj1G7jBEDdUaap/akY6knRGpvwsEBS/DgV7ONb 2IZMauRokxMWxkbX4J7dJVitWMF5BAPUWhrlVAKlTB1Zs86QDf4W/m6XzFZpiIajqqE5 wWmD3HsDWoJ5qPUgUk6Y1/hLqB/ANELyg8rVcUO1K419Sr3dR1QIJ0yU2v7yws1TprbM TYm8m8au0InmLweUi1XNjtSiG/YcmTkOcWKdIx0lOeFXq9ijm3koU8yE8TOhx9azTlqg mFLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:cc:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:user-agent :mime-version:message-id:references:auto-submitted:to:date:from :dkim-signature:dkim-signature:dkim-signature; bh=RAKE4wUCC34Hzd4AKbb1dl9VKWtTHwgv4EOpzy0OgZU=; fh=lm0MLPW7DntlrDqRECIiC9JlE1uPxhepE0URYHIf+eE=; b=JlXbIEcC8lvC9MU1fH6i16X7G1AcNpkUQ9GJAynGPUSueAi2yAIsuCKBadM4qzWAH8 WLKRattcDO7fD2mUEnLVvib+3JH47luIPfwkKCrqvPsu1D0h7H2rSdueNnJcOERhfoST N1p1l5g3Q5qyAhLljfnIYqqOxym8wRv8a7Q6DbdIDlCHLQf6C8zhoik78IrNDT6YUXGA 7Niq1TdxR3WZEND+v9VqufZ+UdzXE5/mgXWz3R3/er8ulss+u3GGDGxiWW3ImKkxGEwD Iz12EoKNVZx3ZpwoeeEKcA+LkLtN/gEzNDB8w17SlKP9BcjjtIFXjXzwPU+RLeJMYZuj QpMQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="F/k9sKml"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=e4SoBDuY; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=a0jHVAJt; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvpn.net; dara=fail header.i=@openvpn.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id ca18e2360f4ac-83e13246474si14502939f.26.2024.11.10.18.00.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Nov 2024 18:00:24 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="F/k9sKml"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=e4SoBDuY; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=a0jHVAJt; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvpn.net; dara=fail header.i=@openvpn.net Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1tAJix-0003a2-7B; Mon, 11 Nov 2024 02:00:14 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1tAJiv-0003Zs-G5 for openvpn-devel@lists.sourceforge.net; Mon, 11 Nov 2024 02:00:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Content-Transfer-Encoding:MIME-Version :Message-ID:Reply-To:References:Subject:List-Unsubscribe:List-Id:Cc:To:Date: From:Sender:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help: List-Subscribe:List-Post:List-Owner:List-Archive; bh=d4UfBl7haQHmu54SDuZv7BGProwcsp8AgEBReqZ74zk=; b=F/k9sKmlFdTJQHsLnp4jjocoVw 6PXquW/TZ5SO2lKuDEBaPEn1/wU2jR/HE72iR3DqVEbmIhvyNpX+7FmtTD4wskPO6WDoWhMWxknzx fBKvphGdaE03rfEh5XgC7PrKccodx9/83LQIbOY9I/flSgZty5bNckz3RPqdC10J+cUc=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Reply-To: References:Subject:List-Unsubscribe:List-Id:Cc:To:Date:From:Sender:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help:List-Subscribe:List-Post: List-Owner:List-Archive; bh=d4UfBl7haQHmu54SDuZv7BGProwcsp8AgEBReqZ74zk=; b=e 4SoBDuYT9dbSw9iapN96iFynNsy+EcP+XlQO33Z2GQm5FAmRv3q0tGo7IayFgJsEMP6j9vYHvsFPw gW6EjcO1KnDeTc3BwlShoFIBBbHUMf0iXHkoRTPYz3NLH2ovOmtoSYLRzLL4qZ+gGaP+BMM2wohGV VVbCNGHhZrg1QTpc=; Received: from mail-wr1-f45.google.com ([209.85.221.45]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1tAJis-0001aN-Mh for openvpn-devel@lists.sourceforge.net; Mon, 11 Nov 2024 02:00:12 +0000 Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-37ed7eb07a4so2590446f8f.2 for ; Sun, 10 Nov 2024 18:00:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvpn.net; s=google; t=1731290399; x=1731895199; darn=lists.sourceforge.net; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from:from:to:cc :subject:date:message-id:reply-to; bh=d4UfBl7haQHmu54SDuZv7BGProwcsp8AgEBReqZ74zk=; b=a0jHVAJtIIPIy+t3BkTjy1aeXqCPtoeP6iUy/ApTQVds3okTshzQZwT7YdJhUXWRoj DxinycL7jeTkir+MC3/FZSt4gchnfLHHqO3B5TR7W9UTSMwwuXcj2RAjGtGVi5zmO6kq QUCNW2s4c4A02Eb/H6dbhPfGRTEMOjg/8hKANrauqzQWsSxPVf6K8SzcyarioMnNxfyd IkiYrUVOfCGLyCgGKmpXfz4rtMfyLs5Zk+CrWvtgMI98T7wtrK3uU34ebrPo2bynl5fv MfFRrrCIFWiynqR7zkUKbAoLux5oQOy5QJ33kBOGUmVqSU2C6XoYjWwY4m1dXRKoJqMd dx1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731290399; x=1731895199; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=d4UfBl7haQHmu54SDuZv7BGProwcsp8AgEBReqZ74zk=; b=b770PGFU4mAIaVhhbCRiF44iGHZWH+0+wAtgaM1sHL3JyPao+9OQdq0K8qjq0Zrzw9 tvXkA++tzx6WgTQgW+C6OrFuLH7rOU0M8RGbdflfSp/TwtTWNY0TsBk08mtY+S/9A7Nm 3rBY5V8echI5eLTqrBhiKvxQxEsFd/Zd4IHPuoFULusYh5ZvCkxQGR0Irf+12itN+xGm WuGlioAv/eG8SVgTa0Qanw0md+C/gXhP1miNqWrcQg8W2XfR5NrOAhcybB4c7O4rJw2j B4sevf0wFgyfxfErEJEKNxkCeOTXU4KAvyQU7m+S8DGaUIqq2L0by3efJxIa4iob1DTR 6fyA== X-Gm-Message-State: AOJu0YyKhyP78tIaUzZqm54SONnGOebO6UtTjWx1T4IY2J1WFcZankfk eg/Gc5tcrSn1pPEt94+3cNGoit5jSUEUlCOPGMuUnRWoHNCF4uVHftNsvtIanIIoeopALE9XoZC P X-Received: by 2002:a05:6000:188b:b0:37d:9476:45f6 with SMTP id ffacd0b85a97d-381f1726233mr8615716f8f.7.1731290398735; Sun, 10 Nov 2024 17:59:58 -0800 (PST) Received: from gerrit.openvpn.in (ec2-18-159-0-78.eu-central-1.compute.amazonaws.com. [18.159.0.78]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432bc500b20sm57600625e9.1.2024.11.10.17.59.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 17:59:57 -0800 (PST) From: "plaisthos (Code Review)" X-Google-Original-From: "plaisthos (Code Review)" X-Gerrit-PatchSet: 1 Date: Mon, 11 Nov 2024 01:59:56 +0000 To: flichtenheld Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange X-Gerrit-Change-Id: If470af2eb456b2b10f9f2806933e026842188c42 X-Gerrit-Change-Number: 802 X-Gerrit-Project: openvpn X-Gerrit-ChangeURL: X-Gerrit-Commit: 2d19778a1ab494a9ac89bd0bccca1967b78937a9 References: Message-ID: MIME-Version: 1.0 User-Agent: Gerrit/3.8.2 X-Spam-Score: -0.9 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-2.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Attention is currently required from: flichtenheld. Hello flichtenheld, I'd like you to do a code review. Please visit Content analysis details: (-0.9 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.221.45 listed in list.dnswl.org] -0.7 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.221.45 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 WEIRD_PORT URI: Uses non-standard port number for HTTP 0.0 HTML_MESSAGE BODY: HTML included in message -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 T_KAM_HTML_FONT_INVALID Test for Invalidly Named or Formatted Colors in HTML X-Headers-End: 1tAJis-0001aN-Mh Subject: [Openvpn-devel] [M] Change in openvpn[master]: Change internal id of packet id to uint64 X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: arne-openvpn@rfc2549.org, openvpn-devel@lists.sourceforge.net, frank@lichtenheld.com Cc: openvpn-devel Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1815389588410494571?= X-GMAIL-MSGID: =?utf-8?q?1815389588410494571?= X-getmail-filter-classifier: gerrit message type newchange Attention is currently required from: flichtenheld. Hello flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/802?usp=email to review the following change. Change subject: Change internal id of packet id to uint64 ...................................................................... Change internal id of packet id to uint64 This allows to get rid of multiple casts and also prepares for the larger packet id used by epoch data format. Change-Id: If470af2eb456b2b10f9f2806933e026842188c42 Signed-off-by: Arne Schwabe --- M src/openvpn/packet_id.c M src/openvpn/packet_id.h M tests/unit_tests/openvpn/test_packet_id.c 3 files changed, 55 insertions(+), 59 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/02/802/1 diff --git a/src/openvpn/packet_id.c b/src/openvpn/packet_id.c index fb962e4..117c95f 100644 --- a/src/openvpn/packet_id.c +++ b/src/openvpn/packet_id.c @@ -36,6 +36,8 @@ #include "syshead.h" +#include + #include "packet_id.h" #include "misc.h" #include "integer.h" @@ -56,7 +58,7 @@ const struct packet_id_rec *p, const struct packet_id_net *pin, const char *message, - int value); + packet_id_print_type value); #endif /* ENABLE_DEBUG */ @@ -65,7 +67,7 @@ const struct packet_id_rec *p, const struct packet_id_net *pin, const char *message, - int value) + uint64_t value) { #ifdef ENABLE_DEBUG if (unlikely(check_debug_level(msglevel))) @@ -115,22 +117,21 @@ const time_t local_now = now; if (p->seq_list) { - packet_id_type diff; + int64_t diff; /* - * If time value increases, start a new - * sequence number sequence. + * If time value increases, start a new sequence number sequence. */ if (!CIRC_LIST_SIZE(p->seq_list) || pin->time > p->time - || (pin->id >= (packet_id_type)p->seq_backtrack - && pin->id - (packet_id_type)p->seq_backtrack > p->id)) + || (pin->id >= p->seq_backtrack + && pin->id - p->seq_backtrack > p->id)) { p->time = pin->time; p->id = 0; - if (pin->id > (packet_id_type)p->seq_backtrack) + if (pin->id > p->seq_backtrack) { - p->id = pin->id - (packet_id_type)p->seq_backtrack; + p->id = pin->id - p->seq_backtrack; } CIRC_LIST_RESET(p->seq_list); } @@ -146,7 +147,7 @@ } diff = p->id - pin->id; - if (diff < (packet_id_type) CIRC_LIST_SIZE(p->seq_list) + if (diff < CIRC_LIST_SIZE(p->seq_list) && local_now > SEQ_EXPIRED) { CIRC_LIST_ITEM(p->seq_list, diff) = local_now; @@ -170,9 +171,8 @@ const time_t local_now = now; if (p->time_backtrack) { - int i; bool expire = false; - for (i = 0; i < CIRC_LIST_SIZE(p->seq_list); ++i) + for (int i = 0; i < CIRC_LIST_SIZE(p->seq_list); ++i) { const time_t t = CIRC_LIST_ITEM(p->seq_list, i); if (t == SEQ_EXPIRED) @@ -200,7 +200,7 @@ packet_id_test(struct packet_id_rec *p, const struct packet_id_net *pin) { - packet_id_type diff; + uint64_t diff; packet_id_debug(D_PID_DEBUG, p, pin, "PID_TEST", 0); @@ -231,9 +231,9 @@ diff = p->id - pin->id; /* keep track of maximum backtrack seen for debugging purposes */ - if ((int)diff > p->max_backtrack_stat) + if (diff > p->max_backtrack_stat) { - p->max_backtrack_stat = (int)diff; + p->max_backtrack_stat = diff; packet_id_debug(D_PID_DEBUG_LOW, p, pin, "PID_ERR replay-window backtrack occurred", p->max_backtrack_stat); } @@ -557,7 +557,7 @@ const struct packet_id_rec *p, const struct packet_id_net *pin, const char *message, - int value) + packet_id_print_type value) { struct gc_arena gc = gc_new(); struct buffer out = alloc_buf_gc(256, &gc); @@ -569,7 +569,7 @@ CLEAR(tv); gettimeofday(&tv, NULL); - buf_printf(&out, "%s [%d]", message, value); + buf_printf(&out, "%s [" packet_id_format "]", message, value); buf_printf(&out, " [%s-%d] [", p->name, p->unit); for (i = 0; sl != NULL && i < sl->x_size; ++i) { @@ -604,17 +604,17 @@ } buf_printf(&out, "%c", c); } - buf_printf(&out, "] %" PRIi64 ":" packet_id_format, (int64_t)p->time, (packet_id_print_type)p->id); + buf_printf(&out, "] %" PRIi64 ":" packet_id_format, (int64_t)p->time, p->id); if (pin) { - buf_printf(&out, " %" PRIi64 ":" packet_id_format, (int64_t)pin->time, (packet_id_print_type)pin->id); + buf_printf(&out, " %" PRIi64 ":" packet_id_format, (int64_t)pin->time, pin->id); } buf_printf(&out, " t=%" PRIi64 "[%d]", (int64_t)prev_now, (int)(prev_now - tv.tv_sec)); - buf_printf(&out, " r=[%d,%d,%d,%d,%d]", + buf_printf(&out, " r=[%d,%" PRIu64 ",%d,%" PRIu64 ",%d]", (int)(p->last_reap - tv.tv_sec), p->seq_backtrack, p->time_backtrack, diff --git a/src/openvpn/packet_id.h b/src/openvpn/packet_id.h index 3778d19..d8a3e1a 100644 --- a/src/openvpn/packet_id.h +++ b/src/openvpn/packet_id.h @@ -35,11 +35,13 @@ #include "error.h" #include "otime.h" -#if 1 /* - * These are the types that members of - * a struct packet_id_net are converted - * to for network transmission. + * These are the types that members of a struct packet_id_net are converted + * to for network transmission and for saving to a persistent file. + * + * Note: data epoch data uses a 64 bit packet ID + * compromised of 16 bit epoch and 48 bit per-epoch packet counter. + * These are ephemeral and are never saved to a file. */ typedef uint32_t packet_id_type; #define PACKET_ID_MAX UINT32_MAX @@ -64,31 +66,12 @@ /* convert a net_time_t in network order to a time_t in host order */ #define ntohtime(x) ((time_t)ntohl(x)) -#else /* if 1 */ - -/* - * DEBUGGING ONLY. - * Make packet_id_type and net_time_t small - * to test wraparound logic and corner cases. - */ - -typedef uint8_t packet_id_type; -typedef uint16_t net_time_t; - -#define PACKET_ID_WRAP_TRIGGER 0x80 - -#define htonpid(x) (x) -#define ntohpid(x) (x) -#define htontime(x) htons((net_time_t)x) -#define ntohtime(x) ((time_t)ntohs(x)) - -#endif /* if 1 */ /* * Printf formats for special types */ -#define packet_id_format "%u" -typedef unsigned int packet_id_print_type; +#define packet_id_format "%" PRIu64 +typedef uint64_t packet_id_print_type; /* * Maximum allowed backtrack in @@ -128,10 +111,10 @@ { time_t last_reap; /* last call of packet_id_reap */ time_t time; /* highest time stamp received */ - packet_id_type id; /* highest sequence number received */ - int seq_backtrack; /* set from --replay-window */ + uint64_t id; /* highest sequence number received */ + uint64_t seq_backtrack; /* set from --replay-window */ int time_backtrack; /* set from --replay-window */ - int max_backtrack_stat; /* maximum backtrack seen so far */ + uint64_t max_backtrack_stat; /* maximum backtrack seen so far */ bool initialized; /* true if packet_id_init was called */ struct seq_list *seq_list; /* packet-id "memory" */ const char *name; @@ -164,7 +147,7 @@ */ struct packet_id_send { - packet_id_type id; + uint64_t id; time_t time; }; @@ -174,8 +157,12 @@ * sequence number. A long packet-id * includes a timestamp as well. * + * An epoch packet-id is a 16 bit epoch + * counter plus a 48 per-epoch packet-id + * * Long packet-ids are used as IVs for - * CFB/OFB ciphers. + * CFB/OFB ciphers and for control channel + * messages. * * This data structure is always sent * over the net in network byte order, @@ -191,9 +178,16 @@ * 64 bit platforms use a * 64 bit time_t. */ + +/** + * Data structure for describing the packet id that is received/send to the + * network. This struct does not match the on wire format. + */ struct packet_id_net { - packet_id_type id; + /* converted to packet_id_type on non-epoch data ids, does not contain + * the epoch but is a flat id */ + uint64_t id; time_t time; /* converted to net_time_t before transmission */ }; diff --git a/tests/unit_tests/openvpn/test_packet_id.c b/tests/unit_tests/openvpn/test_packet_id.c index a3567bc..d918985 100644 --- a/tests/unit_tests/openvpn/test_packet_id.c +++ b/tests/unit_tests/openvpn/test_packet_id.c @@ -90,8 +90,8 @@ now = 5010; assert_true(packet_id_write(&data->pis, &data->test_buf, true, false)); - assert(data->pis.id == 1); - assert(data->pis.time == now); + assert_int_equal(data->pis.id, 1); + assert_int_equal(data->pis.time, now); assert_true(data->test_buf_data.buf_id == htonl(1)); assert_true(data->test_buf_data.buf_time == htonl((uint32_t)now)); } @@ -117,8 +117,8 @@ data->test_buf.offset = sizeof(data->test_buf_data); now = 5010; assert_true(packet_id_write(&data->pis, &data->test_buf, true, true)); - assert(data->pis.id == 1); - assert(data->pis.time == now); + assert_int_equal(data->pis.id, 1); + assert_int_equal(data->pis.time, now); assert_true(data->test_buf_data.buf_id == htonl(1)); assert_true(data->test_buf_data.buf_time == htonl((uint32_t)now)); } @@ -128,7 +128,8 @@ { struct test_packet_id_write_data *data = *state; - data->pis.id = ~0; + /* maximum 32-bit packet id */ + data->pis.id = (packet_id_type)(~0); assert_false(packet_id_write(&data->pis, &data->test_buf, false, false)); } @@ -137,7 +138,8 @@ { struct test_packet_id_write_data *data = *state; - data->pis.id = ~0; + /* maximum 32-bit packet id */ + data->pis.id = (packet_id_type)(~0); data->pis.time = 5006; /* Write fails if time did not change */ @@ -148,8 +150,8 @@ now = 5010; assert_true(packet_id_write(&data->pis, &data->test_buf, true, false)); - assert(data->pis.id == 1); - assert(data->pis.time == now); + assert_int_equal(data->pis.id, 1); + assert_int_equal(data->pis.time, now); assert_true(data->test_buf_data.buf_id == htonl(1)); assert_true(data->test_buf_data.buf_time == htonl((uint32_t)now)); }