]> The Tcpdump Group git mirrors - libpcap/blobdiff - pcap-linux.c
More pcap_setdirection() cleanups.
[libpcap] / pcap-linux.c
index 928c08c586c13040123d7d6d2f0d42acd13a9859..004bc91b092abecf1052e139a9b6303d2a2fc0ae 100644 (file)
@@ -2916,7 +2916,19 @@ pcap_setfilter_linux(pcap_t *handle, struct bpf_program *filter)
 static int
 pcap_setdirection_linux(pcap_t *handle, pcap_direction_t d)
 {
-       handle->direction = d;
+       switch (d) {
+
+       case PCAP_D_IN:
+       case PCAP_D_OUT:
+       case PCAP_D_INOUT:
+               handle->direction = d;
+               break;
+
+       default:
+               snprintf(handle->errbuf, sizeof(handle->errbuf),
+                   "Invalid direction");
+               return -1;
+       }
        return 0;
 }