| // dhcp_protect.c | |||||
| // DHCP Protect | |||||
| // | |||||
| // Copyright 2019 Pascal Gloor | // Copyright 2019 Pascal Gloor | ||||
| // | // | ||||
| // Licensed under the Apache License, Version 2.0 (the "License"); | // Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| static char buf[65536]; | static char buf[65536]; | ||||
| int rv; | int rv; | ||||
| if ((rv = recv(fd, buf, sizeof(buf), 0)) >= 0) { | |||||
| nfq_handle_packet(h, buf, rv); /* send packet to callback */ | |||||
| rv = recv(fd, buf, sizeof(buf), 0); | |||||
| switch(rv) { | |||||
| case -1: | |||||
| fprintf(stderr, "recv() error: %s\n", strerror(errno)); | |||||
| return; | |||||
| case 0: | |||||
| fprintf(stderr,"socket is closed!?\n"); | |||||
| return; | |||||
| default: | |||||
| // send packet to callback | |||||
| nfq_handle_packet(h, buf, rv); | |||||
| break; | |||||
| } | } | ||||
| } | } | ||||
| } | } |