2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

socket-util: Change ss_format_address() to take a dynamic string.

It's occasionally convenient to format into a fixed-size buffer, but
as the use cases, and the text to be formatted, get more sophisticated,
it becomes easier to deal with "struct ds *" than a buffer pointer and
length pair.  An upcoming commit will make ss_format_address() do more
work, and I think that this is the point at which it becomes easier to
take a dynamic string.  This commit makes the parameter type change
without yet changing what is formatted.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: Numan Siddique <nusiddiq@redhat.com>
Acked-by: Numan Siddique <nusiddiq@redhat.com>
This commit is contained in:
Ben Pfaff
2017-07-14 14:33:45 -07:00
parent b7636967a8
commit fd245f1da9
4 changed files with 45 additions and 52 deletions

View File

@@ -28,6 +28,8 @@
#include <netinet/in_systm.h>
#include <netinet/ip.h>
struct ds;
int set_nonblocking(int fd);
void xset_nonblocking(int fd);
void setsockopt_tcp_nodelay(int fd);
@@ -71,9 +73,7 @@ char *describe_fd(int fd);
/* Functions for working with sockaddr_storage that might contain an IPv4 or
* IPv6 address. */
uint16_t ss_get_port(const struct sockaddr_storage *);
#define SS_NTOP_BUFSIZE (1 + INET6_ADDRSTRLEN + 1)
char *ss_format_address(const struct sockaddr_storage *,
char *buf, size_t bufsize);
void ss_format_address(const struct sockaddr_storage *, struct ds *);
size_t ss_length(const struct sockaddr_storage *);
const char *sock_strerror(int error);