diff --git a/docs/globals.html b/docs/globals.html
index 4c4361f..0246026 100644
--- a/docs/globals.html
+++ b/docs/globals.html
@@ -97,6 +97,7 @@
- DEBUG : udp-redirect.c
- EOK : udp-redirect.c
+- ERRNO_IGNORE_CHECK : udp-redirect.c
- ERRNO_IGNORE_SET : udp-redirect.c
- MAX_ERRNO : udp-redirect.c
- NETWORK_BUFFER_SIZE : udp-redirect.c
diff --git a/docs/navtreeindex0.js b/docs/navtreeindex0.js
index 9eb24ea..6c50bcf 100644
--- a/docs/navtreeindex0.js
+++ b/docs/navtreeindex0.js
@@ -41,19 +41,20 @@ var NAVTREEINDEX0 =
"structsettings.html#acdfde83a90fe7d0c4f621bf8b5d1dfae":[1,0,0,2],
"structsettings.html#ad19d72d81de785bc796800503cda86a6":[1,0,0,1],
"udp-redirect_8c.html":[2,0,0],
-"udp-redirect_8c.html#a0ddf1224851353fc92bfbff6f499fa97":[2,0,0,7],
-"udp-redirect_8c.html#a1abe4a502b5a81ac9d4fc4ca3548b997":[2,0,0,6],
-"udp-redirect_8c.html#a1abe4a502b5a81ac9d4fc4ca3548b997a2458bd2178cc99bc6737bc528be5f61c":[2,0,0,6,0],
-"udp-redirect_8c.html#a1abe4a502b5a81ac9d4fc4ca3548b997a3849ab144f4ec0bc1433ce1ccfa389f4":[2,0,0,6,3],
-"udp-redirect_8c.html#a1abe4a502b5a81ac9d4fc4ca3548b997abef70e723b637a07777210af3cefc066":[2,0,0,6,2],
-"udp-redirect_8c.html#a1abe4a502b5a81ac9d4fc4ca3548b997ad190887353b0664ff091b83d6387aa9b":[2,0,0,6,1],
-"udp-redirect_8c.html#a4979fa449090ea6181c2f0a91fe512e7":[2,0,0,5],
-"udp-redirect_8c.html#a683d9394d63aedb7ea0eca78e619156e":[2,0,0,3],
-"udp-redirect_8c.html#a795c40580eb8389eeb92c007ba8910a6":[2,0,0,8],
-"udp-redirect_8c.html#a94965649155359a4c4eb047af782bf22":[2,0,0,11],
-"udp-redirect_8c.html#a9998f145d5911cecdac6aa347ad08559":[2,0,0,4],
+"udp-redirect_8c.html#a0ddf1224851353fc92bfbff6f499fa97":[2,0,0,8],
+"udp-redirect_8c.html#a1abe4a502b5a81ac9d4fc4ca3548b997":[2,0,0,7],
+"udp-redirect_8c.html#a1abe4a502b5a81ac9d4fc4ca3548b997a2458bd2178cc99bc6737bc528be5f61c":[2,0,0,7,0],
+"udp-redirect_8c.html#a1abe4a502b5a81ac9d4fc4ca3548b997a3849ab144f4ec0bc1433ce1ccfa389f4":[2,0,0,7,3],
+"udp-redirect_8c.html#a1abe4a502b5a81ac9d4fc4ca3548b997abef70e723b637a07777210af3cefc066":[2,0,0,7,2],
+"udp-redirect_8c.html#a1abe4a502b5a81ac9d4fc4ca3548b997ad190887353b0664ff091b83d6387aa9b":[2,0,0,7,1],
+"udp-redirect_8c.html#a4979fa449090ea6181c2f0a91fe512e7":[2,0,0,6],
+"udp-redirect_8c.html#a683d9394d63aedb7ea0eca78e619156e":[2,0,0,4],
+"udp-redirect_8c.html#a795c40580eb8389eeb92c007ba8910a6":[2,0,0,9],
+"udp-redirect_8c.html#a94965649155359a4c4eb047af782bf22":[2,0,0,12],
+"udp-redirect_8c.html#a9998f145d5911cecdac6aa347ad08559":[2,0,0,5],
"udp-redirect_8c.html#ac1f6fbe3701c17626b9d9222002790a3":[2,0,0,1],
-"udp-redirect_8c.html#aca406131bb636c31134d300e0caae9b6":[2,0,0,9],
+"udp-redirect_8c.html#ac55492e92f1e5fde0a623ffdf45671e9":[2,0,0,3],
+"udp-redirect_8c.html#aca406131bb636c31134d300e0caae9b6":[2,0,0,10],
"udp-redirect_8c.html#acf2e4414e0bf0d331a111e70f9317434":[2,0,0,2],
-"udp-redirect_8c.html#ae9a2954f00e12c29eff4ffd4e47f6d32":[2,0,0,10]
+"udp-redirect_8c.html#ae9a2954f00e12c29eff4ffd4e47f6d32":[2,0,0,11]
};
diff --git a/docs/search/all_3.js b/docs/search/all_3.js
index bd43e23..21c4a6a 100644
--- a/docs/search/all_3.js
+++ b/docs/search/all_3.js
@@ -2,5 +2,6 @@ var searchData=
[
['eignore_0',['eignore',['../structsettings.html#a73ba0b9364d8e2f535fd5a0e9f0850ba',1,'settings']]],
['eok_1',['EOK',['../udp-redirect_8c.html#acf2e4414e0bf0d331a111e70f9317434',1,'udp-redirect.c']]],
- ['errno_5fignore_5fset_2',['ERRNO_IGNORE_SET',['../udp-redirect_8c.html#a683d9394d63aedb7ea0eca78e619156e',1,'udp-redirect.c']]]
+ ['errno_5fignore_5fcheck_2',['ERRNO_IGNORE_CHECK',['../udp-redirect_8c.html#ac55492e92f1e5fde0a623ffdf45671e9',1,'udp-redirect.c']]],
+ ['errno_5fignore_5fset_3',['ERRNO_IGNORE_SET',['../udp-redirect_8c.html#a683d9394d63aedb7ea0eca78e619156e',1,'udp-redirect.c']]]
];
diff --git a/docs/search/defines_1.js b/docs/search/defines_1.js
index 1f7be21..d7bf55c 100644
--- a/docs/search/defines_1.js
+++ b/docs/search/defines_1.js
@@ -1,5 +1,6 @@
var searchData=
[
['eok_0',['EOK',['../udp-redirect_8c.html#acf2e4414e0bf0d331a111e70f9317434',1,'udp-redirect.c']]],
- ['errno_5fignore_5fset_1',['ERRNO_IGNORE_SET',['../udp-redirect_8c.html#a683d9394d63aedb7ea0eca78e619156e',1,'udp-redirect.c']]]
+ ['errno_5fignore_5fcheck_1',['ERRNO_IGNORE_CHECK',['../udp-redirect_8c.html#ac55492e92f1e5fde0a623ffdf45671e9',1,'udp-redirect.c']]],
+ ['errno_5fignore_5fset_2',['ERRNO_IGNORE_SET',['../udp-redirect_8c.html#a683d9394d63aedb7ea0eca78e619156e',1,'udp-redirect.c']]]
];
diff --git a/docs/udp-redirect_8c.html b/docs/udp-redirect_8c.html
index 90636ca..bad351e 100644
--- a/docs/udp-redirect_8c.html
+++ b/docs/udp-redirect_8c.html
@@ -165,8 +165,10 @@
|
#define | MAX_ERRNO 256 |
|
-#define | ERRNO_IGNORE_SET(X, Y) if ((Y) >= 0 && (Y) < MAX_ERRNO) (X)[(Y)] = 1; |
+#define | ERRNO_IGNORE_SET(X, Y) if ((Y) >= 0 && (Y) < MAX_ERRNO) (X)[(Y)] = 1 |
|
+#define | ERRNO_IGNORE_CHECK(X, Y) ((Y) >= 0 && (Y) < MAX_ERRNO && (X)[(Y)] == 1) |
+ |
|
@@ -260,6 +262,35 @@
+◆ ERRNO_IGNORE_CHECK
+
+
+
+
+
+ #define ERRNO_IGNORE_CHECK |
+ ( |
+ |
+ X, |
+
+
+ |
+ |
+ |
+ Y |
+
+
+ |
+ ) |
+ | ((Y) >= 0 && (Y) < MAX_ERRNO && (X)[(Y)] == 1) |
+
+
+
+
Check if errno is in declared set
+
@@ -283,7 +314,7 @@ MAX_ERRNO) (X)[(Y)] = 1;
+ | if ((Y) >= 0 && (Y) < MAX_ERRNO) (X)[(Y)] = 1 |
diff --git a/docs/udp-redirect_8c.js b/docs/udp-redirect_8c.js
index be5403b..86207ac 100644
--- a/docs/udp-redirect_8c.js
+++ b/docs/udp-redirect_8c.js
@@ -3,6 +3,7 @@ var udp_redirect_8c =
[ "settings", "structsettings.html", "structsettings" ],
[ "DEBUG", "udp-redirect_8c.html#ac1f6fbe3701c17626b9d9222002790a3", null ],
[ "EOK", "udp-redirect_8c.html#acf2e4414e0bf0d331a111e70f9317434", null ],
+ [ "ERRNO_IGNORE_CHECK", "udp-redirect_8c.html#ac55492e92f1e5fde0a623ffdf45671e9", null ],
[ "ERRNO_IGNORE_SET", "udp-redirect_8c.html#a683d9394d63aedb7ea0eca78e619156e", null ],
[ "MAX_ERRNO", "udp-redirect_8c.html#a9998f145d5911cecdac6aa347ad08559", null ],
[ "NETWORK_BUFFER_SIZE", "udp-redirect_8c.html#a4979fa449090ea6181c2f0a91fe512e7", null ],
diff --git a/udp-redirect.c b/udp-redirect.c
index 88f4be7..6fa7cbb 100644
--- a/udp-redirect.c
+++ b/udp-redirect.c
@@ -62,7 +62,12 @@
/**
* Set the errno ignore boolean for a specific errno
*/
-#define ERRNO_IGNORE_SET(X, Y) if ((Y) >= 0 && (Y) < MAX_ERRNO) (X)[(Y)] = 1;
+#define ERRNO_IGNORE_SET(X, Y) if ((Y) >= 0 && (Y) < MAX_ERRNO) (X)[(Y)] = 1
+
+/**
+ * Check if errno is in declared set
+ */
+#define ERRNO_IGNORE_CHECK(X, Y) ((Y) >= 0 && (Y) < MAX_ERRNO && (X)[(Y)] == 1)
/**
* @brief The available debug levels.
@@ -585,6 +590,7 @@ int main(int argc, char *argv[]) {
memset(errno_ignore, 0, MAX_ERRNO * sizeof(unsigned char));
ERRNO_IGNORE_SET(errno_ignore, EINTR); /* Always ignore EINTR */
+
if (s.eignore == 1) { /* List of harmless recvfrom / sendto errors. Possibly incorrect. */
ERRNO_IGNORE_SET(errno_ignore, EAGAIN);
ERRNO_IGNORE_SET(errno_ignore, EHOSTUNREACH);
@@ -626,7 +632,7 @@ int main(int argc, char *argv[]) {
if (ufds[0].revents & POLLIN || ufds[0].revents & POLLPRI) {
if ((recvfrom_retval = recvfrom(lsock, network_buffer, sizeof(network_buffer), 0,
(struct sockaddr *)&endpoint, (socklen_t *)&endpoint_len)) == -1) {
- if (errno < 0 || errno > MAX_ERRNO || errno_ignore[errno] == 0) {
+ if (!ERRNO_IGNORE_CHECK(errno_ignore, errno)) {
perror("recvfrom");
DEBUG(DEBUG_LEVEL_INFO, "Listen cannot receive (%d)", errno);
@@ -660,7 +666,7 @@ int main(int argc, char *argv[]) {
if ((sendto_retval = sendto(ssock, network_buffer, recvfrom_retval, 0,
(struct sockaddr *)&caddr, sizeof(caddr))) == -1) {
- if (errno < 0 || errno > MAX_ERRNO || errno_ignore[errno] == 0) {
+ if (!ERRNO_IGNORE_CHECK(errno_ignore, errno)) {
perror("sendto");
DEBUG(DEBUG_LEVEL_ERROR, "Cannot send packet to send port (%d)", errno);
@@ -686,7 +692,7 @@ int main(int argc, char *argv[]) {
if (ufds[1].revents & POLLIN || ufds[1].revents & POLLPRI) {
if ((recvfrom_retval = recvfrom(ssock, network_buffer, sizeof(network_buffer), 0,
(struct sockaddr *)&endpoint, (socklen_t *)&endpoint_len)) == -1) {
- if (errno < 0 || errno > MAX_ERRNO || errno_ignore[errno] == 0) {
+ if (!ERRNO_IGNORE_CHECK(errno_ignore, errno)) {
perror("recvfrom");
DEBUG(DEBUG_LEVEL_INFO, "Send cannot receive packet (%d)", errno);
@@ -709,7 +715,7 @@ int main(int argc, char *argv[]) {
if ((sendto_retval = sendto(lsock, network_buffer, recvfrom_retval, 0,
(struct sockaddr *)&previous_endpoint, sizeof(previous_endpoint))) == -1) {
- if (errno < 0 || errno > MAX_ERRNO || errno_ignore[errno] == 0) {
+ if (!ERRNO_IGNORE_CHECK(errno_ignore, errno)) {
perror("sendto");
DEBUG(DEBUG_LEVEL_INFO, "Cannot send packet to listen port (%d)", errno);