Check if IP_TOS is defined before using.

This commit is contained in:
Darren Tucker 2019-11-01 13:42:12 +11:00
parent 764d51e044
commit d500b59a82
1 changed files with 4 additions and 0 deletions

View File

@ -1181,11 +1181,13 @@ set_common_sockopts(int s)
&x, sizeof(x)) == -1) &x, sizeof(x)) == -1)
err(1, "setsockopt"); err(1, "setsockopt");
} }
#ifdef IP_TOS
if (Tflag != -1) { if (Tflag != -1) {
if (setsockopt(s, IPPROTO_IP, IP_TOS, if (setsockopt(s, IPPROTO_IP, IP_TOS,
&Tflag, sizeof(Tflag)) == -1) &Tflag, sizeof(Tflag)) == -1)
err(1, "set IP ToS"); err(1, "set IP ToS");
} }
#endif
if (Iflag) { if (Iflag) {
if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, if (setsockopt(s, SOL_SOCKET, SO_RCVBUF,
&Iflag, sizeof(Iflag)) == -1) &Iflag, sizeof(Iflag)) == -1)
@ -1201,6 +1203,7 @@ set_common_sockopts(int s)
int int
map_tos(char *s, int *val) map_tos(char *s, int *val)
{ {
#ifdef IP_TOS
/* DiffServ Codepoints and other TOS mappings */ /* DiffServ Codepoints and other TOS mappings */
const struct toskeywords { const struct toskeywords {
const char *keyword; const char *keyword;
@ -1242,6 +1245,7 @@ map_tos(char *s, int *val)
return (1); return (1);
} }
} }
#endif
return (0); return (0);
} }