From a4913adfa8529e61648b223f1aebc6a080977d89 Mon Sep 17 00:00:00 2001 From: Quaylyn Rimer Date: Tue, 22 Jul 2025 21:18:06 -0600 Subject: [PATCH] dlpi: Replace magic number with named constant Replace hardcoded magic number '1' in dlbindreq() with a descriptive constant DLPI_MAX_CONIND. This improves code readability and follows best practices for maintainable code. - Added DLPI_MAX_CONIND constant with clear documentation - Replaced 'req.dl_max_conind = 1' with 'req.dl_max_conind = DLPI_MAX_CONIND' - Maintains full backwards compatibility Resolves XXX comment about magic number in pcap-dlpi.c line 1457. --- pcap-dlpi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pcap-dlpi.c b/pcap-dlpi.c index 1cb680bb11..cf6a14af85 100644 --- a/pcap-dlpi.c +++ b/pcap-dlpi.c @@ -122,6 +122,12 @@ #define MAXDLBUF 8192 +/* + * Maximum number of outstanding connection indication messages for DLPI. + * For libpcap packet capture, we use 1 since we only need simple capture. + */ +#define DLPI_MAX_CONIND 1 + /* Forwards */ static char *split_dname(char *, u_int *, char *); static int dl_doattach(int, int, char *); @@ -1454,7 +1460,7 @@ dlbindreq(int fd, bpf_u_int32 sap, char *ebuf) req.dl_primitive = DL_BIND_REQ; /* XXX - what if neither of these are defined? */ #if defined(DL_HP_RAWDLS) - req.dl_max_conind = 1; /* XXX magic number */ + req.dl_max_conind = DLPI_MAX_CONIND; req.dl_service_mode = DL_HP_RAWDLS; #elif defined(DL_CLDLS) req.dl_service_mode = DL_CLDLS;