summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Straz <nstraz@redhat.com>2013-09-17 09:35:52 -0400
committerNathan Straz <nstraz@redhat.com>2013-09-17 09:35:52 -0400
commit87dcf2368a2ea72589791dcff2146a700db7d122 (patch)
tree0ce6096b685a7080f49450fa275e0062675a4604
parent28574cb4d104df98b92a9e6ca632729ed6c5fa9a (diff)
downloadqarsh-87dcf2368a2ea72589791dcff2146a700db7d122.zip
qarsh-87dcf2368a2ea72589791dcff2146a700db7d122.tar.gz
qarsh-87dcf2368a2ea72589791dcff2146a700db7d122.tar.xz
Remove unused utility functions
-rw-r--r--sockutil.c101
-rw-r--r--sockutil.h3
2 files changed, 0 insertions, 104 deletions
diff --git a/sockutil.c b/sockutil.c
index 9ff9210..73ab304 100644
--- a/sockutil.c
+++ b/sockutil.c
@@ -36,67 +36,6 @@ static int packet_seq = 1;
/* Some generic socket related functions to make things easier */
int
-getsockport(int sd)
-{
- struct sockaddr_storage addr;
- socklen_t addrlen;
-
- addrlen = sizeof addr;
- if (getsockname(sd, (struct sockaddr *)&addr, &addrlen) == 0) {
- if (addr.ss_family == AF_INET) {
- struct sockaddr_in *ipv4p = (struct sockaddr_in *)&addr;
- return ntohs(ipv4p->sin_port);
- } else {
- struct sockaddr_in6 *ipv6p = (struct sockaddr_in6 *)&addr;
- return ntohs(ipv6p->sin6_port);
- }
- } else {
- return -1;
- }
-}
-
-int
-bind_any(int minport, unsigned short ss_family)
-{
- static int lastminport = 0;
- static int nextport = 0;
- int sd;
- struct sockaddr_storage addr;
-
- if (minport == lastminport) {
- minport = nextport;
- } else {
- lastminport = minport;
- }
-
- sd = socket(ss_family, SOCK_STREAM, 0);
- if (sd == -1) return -1;
-
- if (ss_family == AF_INET) {
- struct sockaddr_in *ipv4p = (struct sockaddr_in *)&addr;
- ipv4p->sin_family = AF_INET;
- ipv4p->sin_addr.s_addr = htonl(INADDR_ANY);
- do {
- ipv4p->sin_port = htons(minport++);
- } while (bind(sd, (struct sockaddr *)&addr, sizeof addr) != 0);
- } else {
- struct sockaddr_in6 *ipv6p = (struct sockaddr_in6 *)&addr;
- ipv6p->sin6_family = AF_INET6;
- ipv6p->sin6_addr = in6addr_any;
- do {
- ipv6p->sin6_port = htons(minport++);
- } while (bind(sd, (struct sockaddr *)&addr, sizeof addr) != 0);
- }
- nextport = minport;
-
- if (listen(sd, 0) == -1) {
- syslog(LOG_WARNING, "listen error %d, %s", errno,
- strerror(errno));
- }
- return sd;
-}
-
-int
connect_to_host(char *hostname, int port, unsigned short *ss_family)
{
struct addrinfo *ail;
@@ -158,46 +97,6 @@ connect_to_host(char *hostname, int port, unsigned short *ss_family)
return -1;
}
-int
-connect_to_peer(struct sockaddr_storage *peer, int port)
-{
- int sd;
- int fdflags;
- struct sockaddr_in ipv4;
- struct sockaddr_in6 ipv6;
- struct sockaddr_storage *peeraddr;
-
- if (peer->ss_family == AF_INET) {
- ipv4.sin_family = AF_INET;
- ipv4.sin_port=htons(port);
- ipv4.sin_addr = ((struct sockaddr_in *)peer)->sin_addr;
- peeraddr = (struct sockaddr_storage *)&ipv4;
- } else {
- ipv6.sin6_family = AF_INET6;
- ipv6.sin6_port=htons(port);
- ipv6.sin6_addr = ((struct sockaddr_in6 *)peer)->sin6_addr;
- peeraddr = (struct sockaddr_storage *)&ipv6;
- }
-
- sd = socket(peer->ss_family, SOCK_STREAM, 0);
- if (sd == -1) return -1;
-
- /* Set close-on-exec for these sds */
- if ((fdflags = fcntl(sd, F_GETFD, 0)) < 0) {
- return -1;
- }
-
- fdflags |= FD_CLOEXEC;
- if (fcntl(sd, F_SETFD, fdflags) < 0) {
- return -1;
- }
-
- if (connect(sd, (struct sockaddr *)peeraddr, sizeof *peeraddr) == -1) {
- return -1;
- }
- return sd;
-}
-
/*
* All incoming and outgoing packets go through this function.
* Caller should make sure the fd is ready to read.
diff --git a/sockutil.h b/sockutil.h
index 3678b1f..d0f630b 100644
--- a/sockutil.h
+++ b/sockutil.h
@@ -19,9 +19,6 @@
*/
#include <netinet/in.h>
-int getsockport(int sd);
-int bind_any(int minport, unsigned short ss_family);
int connect_to_host(char *hostname, int port, unsigned short *ss_family);
-int connect_to_peer(struct sockaddr_storage *peer, int port);
struct qa_packet * recv_packet(int fd);
int send_packet(int fd, struct qa_packet *qp);