Add a variable offset to vpn_packet_t, drop sptps_packet_t.

The offset value indicates where the actual payload starts, so we can
process both legacy and SPTPS UDP packets without having to do casting
tricks and/or moving memory around.
This commit is contained in:
Guus Sliepen 2014-12-24 22:23:24 +01:00
parent 107d9c7da5
commit 6b92ac505d
14 changed files with 234 additions and 212 deletions

View file

@ -244,7 +244,7 @@ static bool read_packet(vpn_packet_t *packet) {
}
case 2: {
if((inlen = read(data_fd, packet->data, MTU)) <= 0) {
if((inlen = read(data_fd, DATA(packet), MTU)) <= 0) {
logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading from %s %s: %s", device_info,
device, strerror(errno));
event_exit();
@ -275,7 +275,7 @@ static bool write_packet(vpn_packet_t *packet) {
logger(DEBUG_TRAFFIC, LOG_DEBUG, "Writing packet of %d bytes to %s",
packet->len, device_info);
if(write(write_fd, packet->data, packet->len) < 0) {
if(write(write_fd, DATA(packet), packet->len) < 0) {
if(errno != EINTR && errno != EAGAIN) {
logger(DEBUG_ALWAYS, LOG_ERR, "Can't write to %s %s: %s", device_info, device, strerror(errno));
event_exit();