summaryrefslogtreecommitdiff
path: root/src/options.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/options.cpp')
-rw-r--r--src/options.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/options.cpp b/src/options.cpp
index c9cbaae..fdbffde 100644
--- a/src/options.cpp
+++ b/src/options.cpp
@@ -23,6 +23,8 @@
#include <string.h>
#include <limits>
+#include "../include/xs.h"
+
#include "options.hpp"
#include "err.hpp"
@@ -47,6 +49,7 @@ xs::options_t::options_t () :
ipv4only (1),
keepalive (0),
protocol (0),
+ filter_id (XS_FILTER_PREFIX),
delay_on_close (true),
delay_on_disconnect (true),
filter (false),
@@ -248,6 +251,14 @@ int xs::options_t::setsockopt (int option_, const void *optval_,
return 0;
}
+ case XS_FILTER:
+ if (optvallen_ != sizeof (int)) {
+ errno = EINVAL;
+ return -1;
+ }
+ filter_id = *((int*) optval_);
+ return 0;
+
}
errno = EINVAL;
@@ -438,6 +449,15 @@ int xs::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
*optvallen_ = sizeof (int);
return 0;
+ case XS_FILTER:
+ if (*optvallen_ < sizeof (int)) {
+ errno = EINVAL;
+ return -1;
+ }
+ *((int*) optval_) = filter_id;
+ *optvallen_ = sizeof (int);
+ return 0;
+
}
errno = EINVAL;