unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
blob 6fe7bfc0f4c241906dd77cefb7ee8a813f892de2 2419 bytes (raw)
name: gnu/packages/patches/netcat-openbsd-broadcast-support.patch 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
 
From: Aron Xu <aron@debian.org>
Date: Mon, 13 Feb 2012 19:06:52 +0800
Subject: broadcast support

---
 nc.1     |    4 +++-
 netcat.c |   22 ++++++++++++++++++++--
 2 files changed, 23 insertions(+), 3 deletions(-)

--- a/nc.1
+++ b/nc.1
@@ -33,7 +33,7 @@
 .Nd arbitrary TCP and UDP connections and listens
 .Sh SYNOPSIS
 .Nm nc
-.Op Fl 46CDdFhklNnrStUuvZz
+.Op Fl 46bCDdFhklNnrStUuvZz
 .Op Fl I Ar length
 .Op Fl i Ar interval
 .Op Fl M Ar ttl
@@ -93,6 +93,8 @@ The options are as follows:
 Use IPv4 addresses only.
 .It Fl 6
 Use IPv6 addresses only.
+.It Fl b
+Allow broadcast.
 .It Fl C
 Send CRLF as line-ending.  Each line feed (LF) character from the input
 data is translated into CR+LF before being written to the socket.  Line
--- a/netcat.c
+++ b/netcat.c
@@ -132,6 +132,7 @@
 #define UDP_SCAN_TIMEOUT 3			/* Seconds */
 
 /* Command Line Options */
+int	bflag;					/* Allow Broadcast */
 int	dflag;					/* detached, no stdin */
 int	Fflag;					/* fdpass sock to stdout */
 unsigned int iflag;				/* Interval Flag */
@@ -263,9 +264,9 @@ main(int argc, char *argv[])
 
 	while ((ch = getopt(argc, argv,
 # if defined(TLS)
-	    "46C:cDde:FH:hI:i:K:klM:m:NnO:o:P:p:q:R:rSs:T:tUuV:vW:w:X:x:Z:z"))
+	    "46bC:cDde:FH:hI:i:K:klM:m:NnO:o:P:p:q:R:rSs:T:tUuV:vW:w:X:x:Z:z"))
 # else
-	    "46CDdFhI:i:klM:m:NnO:P:p:q:rSs:T:tUuV:vW:w:X:x:Zz"))
+	    "46bCDdFhI:i:klM:m:NnO:P:p:q:rSs:T:tUuV:vW:w:X:x:Zz"))
 # endif
 	    != -1) {
 		switch (ch) {
@@ -275,6 +276,13 @@ main(int argc, char *argv[])
 		case '6':
 			family = AF_INET6;
 			break;
+		case 'b':
+# if defined(SO_BROADCAST)
+			bflag = 1;
+# else
+			errx(1, "no broadcast frame support available");
+# endif
+			break;
 		case 'U':
 			family = AF_UNIX;
 			break;
@@ -1852,6 +1860,15 @@ set_common_sockopts(int s, int af)
 {
 	int x = 1;
 
+# if defined(SO_BROADCAST)
+	if (bflag) {
+		/* allow datagram sockets to send packets to a broadcast address
+		 * (this option has no effect on stream-oriented sockets) */
+		if (setsockopt(s, SOL_SOCKET, SO_BROADCAST,
+			&x, sizeof(x)) == -1)
+			err(1, NULL);
+	}
+# endif
 # if defined(TCP_MD5SIG)
 	if (Sflag) {
 		if (setsockopt(s, IPPROTO_TCP, TCP_MD5SIG,
@@ -2127,6 +2144,7 @@ help(void)
 	fprintf(stderr, "\tCommand Summary:\n\
 	\t-4		Use IPv4\n\
 	\t-6		Use IPv6\n\
+	\t-b		Allow broadcast\n\
 	\t-C		Send CRLF as line-ending\n\
 	\t-D		Enable the debug socket option\n\
 	\t-d		Detach from stdin\n\

debug log:

solving 6fe7bfc0f4 ...
found 6fe7bfc0f4 in https://yhetil.org/guix-patches/3dfac477-b081-49f4-86b3-2c142bb39f6b@www.fastmail.com/

applying [1/1] https://yhetil.org/guix-patches/3dfac477-b081-49f4-86b3-2c142bb39f6b@www.fastmail.com/
diff --git a/gnu/packages/patches/netcat-openbsd-broadcast-support.patch b/gnu/packages/patches/netcat-openbsd-broadcast-support.patch
new file mode 100644
index 0000000000..6fe7bfc0f4

1:40: trailing whitespace.
 
1:47: trailing whitespace.
 
1:48: space before tab in indent.
 	while ((ch = getopt(argc, argv,
1:56: space before tab in indent.
 	    != -1) {
1:57: space before tab in indent.
 		switch (ch) {
Checking patch gnu/packages/patches/netcat-openbsd-broadcast-support.patch...
Applied patch gnu/packages/patches/netcat-openbsd-broadcast-support.patch cleanly.
warning: squelched 16 whitespace errors
warning: 21 lines add whitespace errors.

index at:
100644 6fe7bfc0f4c241906dd77cefb7ee8a813f892de2	gnu/packages/patches/netcat-openbsd-broadcast-support.patch

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).