blob: 54823d157fdf11f39e0067f117f22fed54e782eb [file] [log] [blame]
Baptiste Assmann5d4e4f72015-04-13 23:08:16 +02001/*
Willy Tarreau7c18b542020-06-11 09:23:02 +02002 * Datagram processing functions
Baptiste Assmann5d4e4f72015-04-13 23:08:16 +02003 *
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 Tarreau0f6ffd62020-06-03 19:33:00 +020013#include <haproxy/fd.h>
Willy Tarreau7c18b542020-06-11 09:23:02 +020014#include <haproxy/dgram.h>
Baptiste Assmann5d4e4f72015-04-13 23:08:16 +020015
16/* datagram handler callback */
Willy Tarreau7a798e52016-04-14 11:13:20 +020017void dgram_fd_handler(int fd)
Baptiste Assmann5d4e4f72015-04-13 23:08:16 +020018{
19 struct dgram_conn *dgram = fdtab[fd].owner;
20
21 if (unlikely(!dgram))
Willy Tarreau7a798e52016-04-14 11:13:20 +020022 return;
Baptiste Assmann5d4e4f72015-04-13 23:08:16 +020023
24 if (fd_recv_ready(fd))
25 dgram->data->recv(dgram);
Willy Tarreaud7f76a02019-12-10 18:12:04 +010026 if (fd_send_ready(fd))
Baptiste Assmann5d4e4f72015-04-13 23:08:16 +020027 dgram->data->send(dgram);
28
Willy Tarreau7a798e52016-04-14 11:13:20 +020029 return;
Baptiste Assmann5d4e4f72015-04-13 23:08:16 +020030}