Add mud_peer_is_up()
This commit is contained in:
23
mud.c
23
mud.c
@@ -824,6 +824,29 @@ int mud_can_push (struct mud *mud)
|
||||
return (mud->tx.start != mud->tx.end);
|
||||
}
|
||||
|
||||
int mud_peer_is_up (struct mud *mud, const char *name, const char *host, int port)
|
||||
{
|
||||
if (!name || !host || !port)
|
||||
return 0;
|
||||
|
||||
struct ipaddr local_addr;
|
||||
|
||||
if (mud_ipaddrinfo(&local_addr, name))
|
||||
return 0;
|
||||
|
||||
struct sockaddr_storage addr;
|
||||
|
||||
if (mud_addrinfo(&addr, host, port))
|
||||
return 0;
|
||||
|
||||
mud_unmapv4((struct sockaddr *)&addr);
|
||||
|
||||
struct path *path = mud_path(mud, &local_addr,
|
||||
(struct sockaddr *)&addr, 0);
|
||||
|
||||
return path->state.on && path->state.up;
|
||||
}
|
||||
|
||||
int mud_is_up (struct mud *mud)
|
||||
{
|
||||
struct path *path;
|
||||
|
||||
3
mud.h
3
mud.h
@@ -17,7 +17,8 @@ int mud_set_time_tolerance_sec (struct mud *, unsigned);
|
||||
|
||||
int mud_set_on (struct mud *, const char *, int);
|
||||
|
||||
int mud_peer (struct mud *, const char *, const char *, int);
|
||||
int mud_peer (struct mud *, const char *, const char *, int);
|
||||
int mud_peer_is_up (struct mud *, const char *, const char *, int);
|
||||
|
||||
int mud_can_pull (struct mud *);
|
||||
int mud_can_push (struct mud *);
|
||||
|
||||
Reference in New Issue
Block a user