return totemip_equal(addr, &localhost);
}
+const char *totemip_sa_print(const struct sockaddr *sa)
+{
+ static char buf[INET6_ADDRSTRLEN];
+
+ buf[0] = 0;
+
+ switch (sa->sa_family) {
+ case AF_INET:
+ inet_ntop(sa->sa_family, &((struct sockaddr_in *)(sa))->sin_addr, buf,
+ INET6_ADDRSTRLEN);
+ break;
+ case AF_INET6:
+ inet_ntop(sa->sa_family, &((struct sockaddr_in6 *)(sa))->sin6_addr, buf,
+ INET6_ADDRSTRLEN);
+ break;
+ default:
+ return (NULL);
+ }
+
+ return (buf);
+}
+
const char *totemip_print(const struct totem_ip_address *addr)
{
static char buf[INET6_ADDRSTRLEN];
void (*totemknet_deliver_fn) (
void *context,
const void *msg,
- unsigned int msg_len);
+ unsigned int msg_len,
+ const struct sockaddr_storage *system_from);
void (*totemknet_iface_change_fn) (
void *context,
instance->totemknet_deliver_fn (
instance->context,
instance->iov_buffer,
- msg_len);
+ msg_len,
+ &system_from);
return (0);
}
void (*deliver_fn) (
void *context,
const void *msg,
- unsigned int msg_len),
+ unsigned int msg_len,
+ const struct sockaddr_storage *system_from),
void (*iface_change_fn) (
void *context,
void (*deliver_fn) (
void *context,
const void *msg,
- unsigned int msg_len),
+ unsigned int msg_len,
+ const struct sockaddr_storage *system_from),
void (*iface_change_fn) (
void *context,
void *context,
void (*deliver_fn) (
- void *context,
- const void *msg,
- unsigned int msg_len),
+ void *context,
+ const void *msg,
+ unsigned int msg_len,
+ const struct sockaddr_storage *system_from),
void (*iface_change_fn) (
void *context,
void (*deliver_fn) (
void *context,
const void *msg,
- unsigned int msg_len),
+ unsigned int msg_len,
+ const struct sockaddr_storage *system_from),
void (*iface_change_fn) (
void *context,
void (*deliver_fn) (
void *context,
const void *msg,
- unsigned int msg_len),
+ unsigned int msg_len,
+ const struct sockaddr_storage *system_from),
void (*iface_change_fn) (
void *context,
void main_deliver_fn (
void *context,
const void *msg,
- unsigned int msg_len);
+ unsigned int msg_len,
+ const struct sockaddr_storage *system_from);
void main_iface_change_fn (
void *context,
static int check_message_header_validity(
void *context,
const void *msg,
- unsigned int msg_len)
+ unsigned int msg_len,
+ const struct sockaddr_storage *system_from)
{
struct totemsrp_instance *instance = context;
const struct totem_message_header *message_header = msg;
if (msg_len < sizeof (struct totem_message_header)) {
log_printf (instance->totemsrp_log_level_security,
- "Received message is too short... Ignoring %u.",
- (unsigned int)msg_len);
+ "Message received from %s is too short... Ignoring %u.",
+ totemip_sa_print((struct sockaddr *)system_from), (unsigned int)msg_len);
return (-1);
}
}
log_printf(instance->totemsrp_log_level_security,
- "Received message with bad magic number (probably sent by %s).. Ignoring",
+ "Message received from %s has bad magic number (probably sent by %s).. Ignoring",
+ totemip_sa_print((struct sockaddr *)system_from),
guessed_str);
return (-1);
if (message_header->version != TOTEM_MH_VERSION) {
log_printf(instance->totemsrp_log_level_security,
- "Received message with unsupported version %u... Ignoring",
- message_header->version);
+ "Message received from %s has unsupported version %u... Ignoring",
+ totemip_sa_print((struct sockaddr *)system_from),
+ message_header->version);
return (-1);
}
void main_deliver_fn (
void *context,
const void *msg,
- unsigned int msg_len)
+ unsigned int msg_len,
+ const struct sockaddr_storage *system_from)
{
struct totemsrp_instance *instance = context;
const struct totem_message_header *message_header = msg;
- if (check_message_header_validity(context, msg, msg_len) == -1) {
+ if (check_message_header_validity(context, msg, msg_len, system_from) == -1) {
return ;
}
break;
default:
log_printf (instance->totemsrp_log_level_security,
- "Type of received message is wrong... ignoring %d.\n",
+ "Message received from %s has wrong type... ignoring %d.\n",
+ totemip_sa_print((struct sockaddr *)system_from),
(int)message_header->type);
instance->stats.rx_msg_dropped++;
void (*totemudp_deliver_fn) (
void *context,
const void *msg,
- unsigned int msg_len);
+ unsigned int msg_len,
+ const struct sockaddr_storage *system_from);
void (*totemudp_iface_change_fn) (
void *context,
instance->totemudp_deliver_fn (
instance->context,
iovec->iov_base,
- iovec->iov_len);
+ iovec->iov_len,
+ &system_from);
iovec->iov_len = UDP_RECEIVE_FRAME_SIZE_MAX;
return (0);
void (*deliver_fn) (
void *context,
const void *msg,
- unsigned int msg_len),
+ unsigned int msg_len,
+ const struct sockaddr_storage *system_from),
void (*iface_change_fn) (
void *context,
void (*deliver_fn) (
void *context,
const void *msg,
- unsigned int msg_len),
+ unsigned int msg_len,
+ const struct sockaddr_storage *system_from),
void (*iface_change_fn) (
void *context,
void (*totemudpu_deliver_fn) (
void *context,
const void *msg,
- unsigned int msg_len);
+ unsigned int msg_len,
+ const struct sockaddr_storage *system_from);
void (*totemudpu_iface_change_fn) (
void *context,
instance->totemudpu_deliver_fn (
instance->context,
iovec->iov_base,
- iovec->iov_len);
+ iovec->iov_len,
+ &system_from);
iovec->iov_len = UDP_RECEIVE_FRAME_SIZE_MAX;
return (0);
void (*deliver_fn) (
void *context,
const void *msg,
- unsigned int msg_len),
+ unsigned int msg_len,
+ const struct sockaddr_storage *system_from),
void (*iface_change_fn) (
void *context,
void (*deliver_fn) (
void *context,
const void *msg,
- unsigned int msg_len),
+ unsigned int msg_len,
+ const struct sockaddr_storage *system_from),
void (*iface_change_fn) (
void *context,
int totemip_localhost(int family, struct totem_ip_address *localhost);
extern int totemip_localhost_check(const struct totem_ip_address *addr);
extern const char *totemip_print(const struct totem_ip_address *addr);
+extern const char *totemip_sa_print(const struct sockaddr *sa);
extern int totemip_sockaddr_to_totemip_convert(const struct sockaddr_storage *saddr,
struct totem_ip_address *ip_addr);
extern int totemip_totemip_to_sockaddr_convert(struct totem_ip_address *ip_addr,