blob: c4434d78eaa6aa627890f59918d72a41a674aff2 [file] [log] [blame]
Baptiste Assmann5d4e4f72015-04-13 23:08:16 +02001/*
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
13#include <types/global.h>
14#include <types/fd.h>
15#include <types/proto_udp.h>
16
17#include <proto/fd.h>
18
19/* datagram handler callback */
Willy Tarreau7a798e52016-04-14 11:13:20 +020020void dgram_fd_handler(int fd)
Baptiste Assmann5d4e4f72015-04-13 23:08:16 +020021{
22 struct dgram_conn *dgram = fdtab[fd].owner;
23
24 if (unlikely(!dgram))
Willy Tarreau7a798e52016-04-14 11:13:20 +020025 return;
Baptiste Assmann5d4e4f72015-04-13 23:08:16 +020026
27 if (fd_recv_ready(fd))
28 dgram->data->recv(dgram);
29 else if (fd_send_ready(fd))
30 dgram->data->send(dgram);
31
Willy Tarreau7a798e52016-04-14 11:13:20 +020032 return;
Baptiste Assmann5d4e4f72015-04-13 23:08:16 +020033}