diff options
author | Guy Harris <guy@alum.mit.edu> | 2019-11-09 19:44:33 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2019-11-09 19:44:33 -0800 |
commit | ddbd32822b39dd2a5fb452cc1a7e9f5dd351b507 (patch) | |
tree | 0e83feecedc32ff0912ff571f197cc1e25fe62de /pcap-linux.c | |
parent | c24390ab35367e76970006e8a5cf327efabd7f1c (diff) |
Do the check for a valid direction value in pcap_setdirection().
That way, we don't have to do the check in the individual setdirection
op routines.
Diffstat (limited to 'pcap-linux.c')
-rw-r--r-- | pcap-linux.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/pcap-linux.c b/pcap-linux.c index e0da92f3..83cf9777 100644 --- a/pcap-linux.c +++ b/pcap-linux.c @@ -2610,19 +2610,11 @@ pcap_setfilter_linux(pcap_t *handle, struct bpf_program *filter) static int pcap_setdirection_linux(pcap_t *handle, pcap_direction_t 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; - } + /* + * It's guaranteed, at this point, that d is a valid + * direction value. + */ + handle->direction = d; return 0; } |