needs, and inspired by 'common/system_aix.c' for the pcap usage.
*/
-#include "includes.h"
+#include "replace.h"
#include "system/network.h"
#include "system/filesys.h"
#include "system/wait.h"
-#include "../include/ctdb_private.h"
+
+#include "lib/util/debug.h"
+#include "lib/util/blocking.h"
+
+#include "protocol/protocol.h"
+
#include <net/ethernet.h>
#include <netinet/ip6.h>
#include <net/if_arp.h>
#include <pcap.h>
+#include "common/logging.h"
+#include "common/system.h"
#ifndef ETHERTYPE_IP6
#define ETHERTYPE_IP6 0x86dd
*/
int ctdb_sys_send_arp(const ctdb_sock_addr *addr, const char *iface)
{
- /* FIXME FreeBSD: We dont do gratuitous arp yet */
- return 0;
+ /* FIXME FreeBSD: We don't do gratuitous arp yet */
+ return -1;
}
struct ip6_hdr ip6;
struct tcphdr tcp;
} ip6pkt;
+ int saved_errno;
switch (src->ip.sin_family) {
case AF_INET:
ip4pkt.tcp.th_sum = tcp_checksum((uint16_t *)&ip4pkt.tcp, sizeof(ip4pkt.tcp), &ip4pkt.ip);
/* open a raw socket to send this segment from */
- s = socket(AF_INET, SOCK_RAW, htons(IPPROTO_RAW));
+ s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
if (s == -1) {
DEBUG(DEBUG_CRIT,(__location__ " failed to open raw socket (%s)\n",
strerror(errno)));
return -1;
}
- set_nonblocking(s);
- set_close_on_exec(s);
-
ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0,
(const struct sockaddr *)&dest->ip,
sizeof(dest->ip));
+ saved_errno = errno;
close(s);
if (ret != sizeof(ip4pkt)) {
- DEBUG(DEBUG_CRIT,(__location__ " failed sendto (%s)\n", strerror(errno)));
+ DEBUG(DEBUG_ERR,
+ ("Failed sendto (%s)\n", strerror(saved_errno)));
return -1;
}
break;
ip6pkt.tcp.th_win = htons(1234);
ip6pkt.tcp.th_sum = tcp_checksum6((uint16_t *)&ip6pkt.tcp, sizeof(ip6pkt.tcp), &ip6pkt.ip6);
- s = socket(PF_INET6, SOCK_RAW, IPPROTO_RAW);
+ s = socket(AF_INET6, SOCK_RAW, IPPROTO_RAW);
if (s == -1) {
DEBUG(DEBUG_CRIT, (__location__ " Failed to open sending socket\n"));
return -1;
}
- /* sendto() dont like if the port is set and the socket is
+ /* sendto() don't like if the port is set and the socket is
in raw mode.
*/
tmpdest = discard_const(dest);
ret = sendto(s, &ip6pkt, sizeof(ip6pkt), 0,
(const struct sockaddr *)&dest->ip6,
sizeof(dest->ip6));
+ saved_errno = errno;
tmpdest->ip6.sin6_port = tmpport;
close(s);
if (ret != sizeof(ip6pkt)) {
- DEBUG(DEBUG_CRIT,(__location__ " failed sendto (%s)\n", strerror(errno)));
+ DEBUG(DEBUG_ERR,
+ ("Failed sendto (%s)\n", strerror(saved_errno)));
return -1;
}
break;
called when the raw socket becomes readable
*/
int ctdb_sys_read_tcp_packet(int s, void *private_data,
- ctdb_sock_addr *src, ctdb_sock_addr *dst,
- uint32_t *ack_seq, uint32_t *seq)
+ ctdb_sock_addr *src, ctdb_sock_addr *dst,
+ uint32_t *ack_seq, uint32_t *seq,
+ int *rst, uint16_t *window)
{
int ret;
#define RCVPKTSIZE 100
return -1;
}
+ ZERO_STRUCTP(src);
+ ZERO_STRUCTP(dst);
+
/* Ethernet */
eth = (struct ether_header *)pkt;
dst->ip.sin_port = tcp->th_dport;
*ack_seq = tcp->th_ack;
*seq = tcp->th_seq;
+ if (window != NULL) {
+ *window = tcp->th_win;
+ }
+ if (rst != NULL) {
+ *rst = tcp->th_flags & TH_RST;
+ }
return 0;
} else if (ntohs(eth->ether_type) == ETHERTYPE_IP6) {
*ack_seq = tcp->th_ack;
*seq = tcp->th_seq;
+ if (window != NULL) {
+ *window = tcp->th_win;
+ }
+ if (rst != NULL) {
+ *rst = tcp->th_flags & TH_RST;
+ }
return 0;
}
/* FIXME FreeBSD: get_peer_pid not implemented */
return 1;
}
-
-char *ctdb_get_process_name(pid_t pid)
-{
- /* FIXME FreeBSD: get_process_name not implemented */
- return NULL;
-}
-
-bool ctdb_get_lock_info(pid_t req_pid, struct ctdb_lock_info *lock_info)
-{
- /* FIXME FreeBSD: get_lock_info not implemented */
- return false;
-}
-
-bool ctdb_get_blocker_pid(struct ctdb_lock_info *reqlock, pid_t *blocker_pid)
-{
- /* FIXME FreeBSD: get_blocker_pid not implemented */
- return false;
-}