You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.6 KiB
53 lines
1.6 KiB
#ifndef __UDP_NEWC_H__
|
|
#define __UDP_NEWC_H__
|
|
|
|
#ifdef __GNUC__
|
|
#define UNUSED __attribute__((unused))
|
|
#else
|
|
#define UNUSED
|
|
#endif
|
|
|
|
typedef struct udp udp_t;
|
|
struct udpops {
|
|
int (*bind) (udp_t *, const char *local_ip, int local_port);
|
|
int (*connect)(udp_t *, const char *remote_ip, int remote_port);
|
|
int (*send) (udp_t *, void *buf, int len);
|
|
int (*recv) (udp_t *, void *buf, int len);
|
|
int (*close) (udp_t *);
|
|
};
|
|
|
|
struct udp {
|
|
struct udpops *uops;
|
|
int sock;
|
|
};
|
|
|
|
udp_t *udp_open(void);
|
|
udp_t *udp_open_link(const char *l_ip, int l_port, const char *r_ip, int r_port);
|
|
udp_t *udp_open_comm(int to_port, int from_port);
|
|
udp_t *udp_open_mcast(const char *group, int port, const char *local_if);
|
|
udp_t *udp_open_mcast_write_only(const char *group, int port, const char *local);
|
|
udp_t *udp_open_mcast_read_only(const char *grp_addr, int port, const char *local);
|
|
int udp_open_pair(struct udp **reader, struct udp **writer);
|
|
int udp_mcast_set_loop(udp_t *u, int on);
|
|
int getip(const char *ethx, char *addr, int len);
|
|
|
|
static inline int UNUSED udp_bind(udp_t *u, const char *local_ip, int local_port) {
|
|
return u->uops->bind(u, local_ip, local_port);
|
|
}
|
|
static inline int UNUSED udp_connect(udp_t *u, const char *remote_ip, int remote_port) {
|
|
return u->uops->connect(u, remote_ip, remote_port);
|
|
}
|
|
static inline int UNUSED udp_send(udp_t *u, void *buf, int len) {
|
|
return u->uops->send(u, buf, len);
|
|
}
|
|
|
|
static inline int UNUSED udp_recv(udp_t *u, void *buf, int len) {
|
|
return u->uops->recv(u, buf, len);
|
|
}
|
|
|
|
static inline int UNUSED udp_close(udp_t *u) {
|
|
return u->uops->close(u);
|
|
}
|
|
|
|
#endif //__UDP_NEWC_H__
|
|
|
|
|