Baptiste Assmann | 5d4e4f7 | 2015-04-13 23:08:16 +0200 | [diff] [blame] | 1 | /* |
| 2 | * UDP protocol related functions |
| 3 | * |
| 4 | * Copyright 2014 Baptiste Assmann <bedis9@gmail.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | */ |
| 12 | |
Willy Tarreau | 0f6ffd6 | 2020-06-03 19:33:00 +0200 | [diff] [blame] | 13 | #include <haproxy/fd-t.h> |
Willy Tarreau | 832ce65 | 2020-06-04 08:36:05 +0200 | [diff] [blame] | 14 | #include <haproxy/proto_udp-t.h> |
Baptiste Assmann | 5d4e4f7 | 2015-04-13 23:08:16 +0200 | [diff] [blame] | 15 | |
Willy Tarreau | 0f6ffd6 | 2020-06-03 19:33:00 +0200 | [diff] [blame] | 16 | #include <haproxy/fd.h> |
Baptiste Assmann | 5d4e4f7 | 2015-04-13 23:08:16 +0200 | [diff] [blame] | 17 | |
| 18 | /* datagram handler callback */ |
Willy Tarreau | 7a798e5 | 2016-04-14 11:13:20 +0200 | [diff] [blame] | 19 | void dgram_fd_handler(int fd) |
Baptiste Assmann | 5d4e4f7 | 2015-04-13 23:08:16 +0200 | [diff] [blame] | 20 | { |
| 21 | struct dgram_conn *dgram = fdtab[fd].owner; |
| 22 | |
| 23 | if (unlikely(!dgram)) |
Willy Tarreau | 7a798e5 | 2016-04-14 11:13:20 +0200 | [diff] [blame] | 24 | return; |
Baptiste Assmann | 5d4e4f7 | 2015-04-13 23:08:16 +0200 | [diff] [blame] | 25 | |
| 26 | if (fd_recv_ready(fd)) |
| 27 | dgram->data->recv(dgram); |
Willy Tarreau | d7f76a0 | 2019-12-10 18:12:04 +0100 | [diff] [blame] | 28 | if (fd_send_ready(fd)) |
Baptiste Assmann | 5d4e4f7 | 2015-04-13 23:08:16 +0200 | [diff] [blame] | 29 | dgram->data->send(dgram); |
| 30 | |
Willy Tarreau | 7a798e5 | 2016-04-14 11:13:20 +0200 | [diff] [blame] | 31 | return; |
Baptiste Assmann | 5d4e4f7 | 2015-04-13 23:08:16 +0200 | [diff] [blame] | 32 | } |