summaryrefslogtreecommitdiffstats
path: root/avahi-core/iface-linux.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-10-17 18:18:05 +0000
committerLennart Poettering <lennart@poettering.net>2005-10-17 18:18:05 +0000
commitab758d7bf41d1d7565e80fe5d2bded0d18160ccb (patch)
tree9c33c812d95a61f55016b15f7e4e9ecec3241547 /avahi-core/iface-linux.c
parent6c64943452eb880c6d02acb4d66ac0f99e2bab4e (diff)
slightly more comments
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@793 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-core/iface-linux.c')
-rw-r--r--avahi-core/iface-linux.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/avahi-core/iface-linux.c b/avahi-core/iface-linux.c
index 64bb0ae..bc87152 100644
--- a/avahi-core/iface-linux.c
+++ b/avahi-core/iface-linux.c
@@ -38,6 +38,8 @@ static int netlink_list_items(AvahiNetlink *nl, uint16_t type, unsigned *ret_seq
struct nlmsghdr *n;
struct rtgenmsg *gen;
uint8_t req[1024];
+
+ /* Issue a wild dump NETLINK request */
memset(&req, 0, sizeof(req));
n = (struct nlmsghdr*) req;
@@ -55,17 +57,23 @@ static int netlink_list_items(AvahiNetlink *nl, uint16_t type, unsigned *ret_seq
static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdata) {
AvahiInterfaceMonitor *m = userdata;
+
+ /* This routine is called for every RTNETLINK response packet */
assert(m);
assert(n);
assert(m->osdep.netlink == nl);
if (n->nlmsg_type == RTM_NEWLINK) {
+
+ /* A new interface appeared or an existing one has been modified */
+
struct ifinfomsg *ifinfomsg = NLMSG_DATA(n);
AvahiHwInterface *hw;
struct rtattr *a = NULL;
size_t l;
-
+
+ /* A (superfluous?) sanity check */
if (ifinfomsg->ifi_family != AF_UNSPEC)
return;
@@ -140,9 +148,13 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat
avahi_hw_interface_update_rrs(hw, 0);
} else if (n->nlmsg_type == RTM_DELLINK) {
+
+ /* An interface has been removed */
+
struct ifinfomsg *ifinfomsg = NLMSG_DATA(n);
AvahiHwInterface *hw;
+ /* A (superfluous?) sanity check */
if (ifinfomsg->ifi_family != AF_UNSPEC)
return;
@@ -155,6 +167,8 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat
} else if (n->nlmsg_type == RTM_NEWADDR || n->nlmsg_type == RTM_DELADDR) {
+ /* An address has been added, modified or removed */
+
struct ifaddrmsg *ifaddrmsg = NLMSG_DATA(n);
AvahiInterface *i;
struct rtattr *a = NULL;
@@ -304,13 +318,13 @@ int avahi_interface_monitor_init_osdep(AvahiInterfaceMonitor *m) {
if (!(m->osdep.netlink = avahi_netlink_new(m->server->poll_api, RTMGRP_LINK|RTMGRP_IPV4_IFADDR|RTMGRP_IPV6_IFADDR, netlink_callback, m)))
goto fail;
+ /* Set the initial state. */
+ m->osdep.list = LIST_IFACE;
+
/* Start the wild dump for the interfaces */
if (netlink_list_items(m->osdep.netlink, RTM_GETLINK, &m->osdep.query_link_seq) < 0)
goto fail;
- /* Set the initial state. */
- m->osdep.list = LIST_IFACE;
-
return 0;
fail: