blob: d063523ea2ad9b6b1c3156195db6672db56867a9 [file] [log] [blame]
/*
* Copyright 2012 Google Inc.
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but without any warranty; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#ifndef __NET_CONNECTION_H__
#define __NET_CONNECTION_H__
#include <stddef.h>
#include <stdint.h>
typedef struct NetConOps {
int (*bind)(struct NetConOps *me, uint16_t port);
int (*incoming)(struct NetConOps *me, size_t *size);
int (*send)(struct NetConOps *me, const void *data, size_t len);
int (*receive)(struct NetConOps *me, void *data, size_t *len,
size_t max_len);
int (*close)(struct NetConOps *me);
} NetConOps;
static inline int netcon_bind(NetConOps *con, uint16_t port)
{
return con->bind(con, port);
}
static inline int netcon_incoming(NetConOps *con, size_t *size)
{
return con->incoming(con, size);
}
static inline int netcon_send(NetConOps *con, const void *data, size_t len)
{
return con->send(con, data, len);
}
static inline int netcon_receive(NetConOps *con, void *data, size_t *len,
size_t max_len)
{
return con->receive(con, data, len, max_len);
}
static inline int netcon_close(NetConOps *con)
{
return con->close(con);
}
#endif /* __NET_CONNECTION_H__ */