}
#endif
-/*
- uint16 checksum for n bytes
- */
-static uint32_t uint16_checksum(uint16_t *data, size_t n)
-{
- uint32_t sum=0;
- while (n>=2) {
- sum += (uint32_t)ntohs(*data);
- data++;
- n -= 2;
- }
- if (n == 1) {
- sum += (uint32_t)ntohs(*(uint8_t *)data);
- }
- return sum;
-}
-
/*
simple TCP checksum - assumes data is multiple of 2 bytes long
*/
return 0;
}
-
-/*
- see if we currently have an interface with the given IP
-
- we try to bind to it, and if that fails then we don't have that IP
- on an interface
- */
-bool ctdb_sys_have_ip(ctdb_sock_addr *addr)
-{
- int s;
- int ret;
-
- addr->ip.sin_port = 0;
- s = socket(addr->sa.sa_family, SOCK_STREAM, IPPROTO_TCP);
- if (s == -1) {
- return false;
- }
- ret = bind(s, (struct sockaddr *)addr, sizeof(ctdb_sock_addr));
- close(s);
- return ret == 0;
-}
-
-
-
-
/* This function is used to open a raw socket to capture from
*/
int ctdb_sys_open_capture_socket(const char *iface, void **private_data)