summaryrefslogtreecommitdiff
path: root/ctdb/utils
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronniesahlberg@gmail.com>2008-05-14 15:33:01 +1000
committerRonnie Sahlberg <ronniesahlberg@gmail.com>2008-05-14 15:33:01 +1000
commit9aba594429306e09e191f3bf844df467a8b2c978 (patch)
tree719618754354de0b7e40fff6e1d2543743255e36 /ctdb/utils
parent7178dfb6569ec213d4a14f6b81cc2684df97c2e4 (diff)
downloadsamba-9aba594429306e09e191f3bf844df467a8b2c978.tar.gz
move the function to open a sending socket into the main executable since this function will dissapear soon...
(This used to be ctdb commit 7f4c7cf6355a88b1a02d3a4d1fa25427106953f9)
Diffstat (limited to 'ctdb/utils')
-rw-r--r--ctdb/utils/ipmux/ipmux.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/ctdb/utils/ipmux/ipmux.c b/ctdb/utils/ipmux/ipmux.c
index 20affd8e554..539490e674d 100644
--- a/ctdb/utils/ipmux/ipmux.c
+++ b/ctdb/utils/ipmux/ipmux.c
@@ -38,6 +38,35 @@ struct ipmux_node {
};
struct ipmux_node *ipmux_nodes;
+/*
+ This function is used to open a raw socket to send tickles from
+ */
+int ctdb_sys_open_sending_socket(void)
+{
+ int s, ret;
+ uint32_t one = 1;
+
+ s = socket(AF_INET, SOCK_RAW, htons(IPPROTO_RAW));
+ if (s == -1) {
+ DEBUG(DEBUG_CRIT,(__location__ " failed to open raw socket (%s)\n",
+ strerror(errno)));
+ return -1;
+ }
+
+ ret = setsockopt(s, SOL_IP, IP_HDRINCL, &one, sizeof(one));
+ if (ret != 0) {
+ DEBUG(DEBUG_CRIT,(__location__ " failed to setup IP headers (%s)\n",
+ strerror(errno)));
+ close(s);
+ return -1;
+ }
+
+ set_nonblocking(s);
+ set_close_on_exec(s);
+
+ return s;
+}
+
/*
main program