summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2013-05-16 13:39:46 +0200
committerGravatar Christian Hesse <mail@eworm.de>2013-05-16 13:39:46 +0200
commit83b0a6ce4f4f627aec620d62f0542bc6c543d0c4 (patch)
treee9f6ffe0444da6de625d18a46d8d54cc2aa3b99f
parent6214212e06a03d94891561fd4e9af83b6ecafcff (diff)
downloadnetlink-notify-83b0a6ce4f4f627aec620d62f0542bc6c543d0c4.tar.gz
netlink-notify-83b0a6ce4f4f627aec620d62f0542bc6c543d0c4.tar.zst
changes for IPv6
-rw-r--r--netlink-notify-address.svg599
-rw-r--r--netlink-notify.c53
2 files changed, 629 insertions, 23 deletions
diff --git a/netlink-notify-address.svg b/netlink-notify-address.svg
new file mode 100644
index 0000000..658fc0d
--- /dev/null
+++ b/netlink-notify-address.svg
@@ -0,0 +1,599 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ width="48"
+ height="48"
+ id="svg10439"
+ inkscape:version="0.48.4 r9939"
+ sodipodi:docname="netlink-notify-connected.svg">
+ <metadata
+ id="metadata3362">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1680"
+ inkscape:window-height="1000"
+ id="namedview3360"
+ showgrid="false"
+ inkscape:zoom="1.7460215"
+ inkscape:cx="24"
+ inkscape:cy="24"
+ inkscape:window-x="0"
+ inkscape:window-y="31"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="svg10439" />
+ <defs
+ id="defs10441">
+ <linearGradient
+ x1="41.829601"
+ y1="48.540501"
+ x2="6.1704001"
+ y2="-0.54009998"
+ id="SVGID_1_"
+ gradientUnits="userSpaceOnUse">
+ <stop
+ id="stop8539"
+ style="stop-color:#9b9b9b;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop8541"
+ style="stop-color:#ececec;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ x1="24"
+ y1="35.9175"
+ x2="24"
+ y2="12.083"
+ id="path3499_1_"
+ gradientUnits="userSpaceOnUse">
+ <stop
+ id="stop8556"
+ style="stop-color:#1f1f1f;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop8558"
+ style="stop-color:#000000;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ x1="22.382799"
+ y1="33.566898"
+ x2="22.382799"
+ y2="30.768101"
+ id="rect3503_2_"
+ gradientUnits="userSpaceOnUse">
+ <stop
+ id="stop8564"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0.4725" />
+ <stop
+ id="stop8566"
+ style="stop-color:#737373;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ x1="28.7358"
+ y1="33.672401"
+ x2="28.7358"
+ y2="30.660601"
+ id="rect3505_1_"
+ gradientUnits="userSpaceOnUse">
+ <stop
+ id="stop8570"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0.4725" />
+ <stop
+ id="stop8572"
+ style="stop-color:#737373;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ x1="25.5581"
+ y1="33.672401"
+ x2="25.5581"
+ y2="30.660601"
+ id="rect3507_1_"
+ gradientUnits="userSpaceOnUse">
+ <stop
+ id="stop8576"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0.4725" />
+ <stop
+ id="stop8578"
+ style="stop-color:#737373;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ x1="19.205099"
+ y1="33.566898"
+ x2="19.205099"
+ y2="30.768101"
+ id="rect3509_1_"
+ gradientUnits="userSpaceOnUse">
+ <stop
+ id="stop8582"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0.4725" />
+ <stop
+ id="stop8584"
+ style="stop-color:#737373;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ x1="16.029301"
+ y1="33.566898"
+ x2="16.029301"
+ y2="30.768101"
+ id="rect3503_3_"
+ gradientUnits="userSpaceOnUse">
+ <stop
+ id="stop8588"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0.4725" />
+ <stop
+ id="stop8590"
+ style="stop-color:#737373;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ x1="31.913601"
+ y1="33.672401"
+ x2="31.913601"
+ y2="30.660601"
+ id="rect3512_1_"
+ gradientUnits="userSpaceOnUse">
+ <stop
+ id="stop8594"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0.4725" />
+ <stop
+ id="stop8596"
+ style="stop-color:#737373;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ y2="18.787563"
+ x2="25.000017"
+ y1="40.000107"
+ x1="24.925514"
+ gradientTransform="matrix(1.2446306,0,0,1.1767765,-7.0741541,-3.982654)"
+ gradientUnits="userSpaceOnUse"
+ id="linearGradient2295"
+ xlink:href="#linearGradient2781"
+ inkscape:collect="always" />
+ <linearGradient
+ y2="12.403291"
+ x2="23.069359"
+ y1="6.7993021"
+ x1="23.069359"
+ gradientTransform="matrix(1.2446306,0,0,1.2707947,-7.0741541,-5.3017616)"
+ gradientUnits="userSpaceOnUse"
+ id="linearGradient2292"
+ xlink:href="#linearGradient3674"
+ inkscape:collect="always" />
+ <linearGradient
+ y2="13.408723"
+ x2="9.5"
+ y1="16.26436"
+ x1="9.5"
+ gradientTransform="matrix(1.2605424,0,0,1.2058553,-7.4733927,-4.9459439)"
+ gradientUnits="userSpaceOnUse"
+ id="linearGradient2289"
+ xlink:href="#linearGradient3690"
+ inkscape:collect="always" />
+ <radialGradient
+ r="2.171875"
+ fy="-12.203125"
+ fx="51.4375"
+ cy="-12.203125"
+ cx="51.4375"
+ gradientTransform="matrix(-1.9576392,-9.2540676e-8,-1.2888861e-7,1.4565793,110.01781,62.73803)"
+ gradientUnits="userSpaceOnUse"
+ id="radialGradient2286"
+ xlink:href="#linearGradient51765"
+ inkscape:collect="always" />
+ <radialGradient
+ r="2.171875"
+ fy="-12.203125"
+ fx="51.4375"
+ cy="-12.203125"
+ cx="51.4375"
+ gradientTransform="matrix(1.9576392,-8.146468e-7,6.6614241e-7,1.4565793,-59.017557,62.738067)"
+ gradientUnits="userSpaceOnUse"
+ id="radialGradient2284"
+ xlink:href="#linearGradient51765"
+ inkscape:collect="always" />
+ <linearGradient
+ y2="-5.5633383"
+ x2="32.084972"
+ y1="-14.402173"
+ x1="32.084972"
+ gradientTransform="matrix(0.9788196,0,0,0.7154223,-8.5008021,52.112719)"
+ gradientUnits="userSpaceOnUse"
+ id="linearGradient2282"
+ xlink:href="#linearGradient47870"
+ inkscape:collect="always" />
+ <linearGradient
+ id="linearGradient3690">
+ <stop
+ style="stop-color:white;stop-opacity:1;"
+ offset="0"
+ id="stop3692" />
+ <stop
+ style="stop-color:white;stop-opacity:0.46875"
+ offset="1"
+ id="stop3694" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3674">
+ <stop
+ style="stop-color:#555753;stop-opacity:1"
+ offset="0"
+ id="stop3676" />
+ <stop
+ style="stop-color:#888a85;stop-opacity:1"
+ offset="1"
+ id="stop3678" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient2781">
+ <stop
+ style="stop-color:#d3d7cf;stop-opacity:1"
+ offset="0"
+ id="stop2783" />
+ <stop
+ style="stop-color:#eeeeec;stop-opacity:1"
+ offset="1"
+ id="stop2785" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient51765">
+ <stop
+ style="stop-color:#000000;stop-opacity:1"
+ offset="0"
+ id="stop51767" />
+ <stop
+ style="stop-color:#000000;stop-opacity:0"
+ offset="1"
+ id="stop51769" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient47870">
+ <stop
+ style="stop-color:#000000;stop-opacity:0"
+ offset="0"
+ id="stop47872" />
+ <stop
+ style="stop-color:#000000;stop-opacity:1"
+ offset="0.5"
+ id="stop47878" />
+ <stop
+ style="stop-color:#000000;stop-opacity:0"
+ offset="1"
+ id="stop47874" />
+ </linearGradient>
+ <radialGradient
+ r="8.341651"
+ fy="9.3411446"
+ fx="38.658855"
+ cy="9.3411446"
+ cx="38.658855"
+ gradientUnits="userSpaceOnUse"
+ id="radialGradient4835"
+ xlink:href="#linearGradient2378"
+ inkscape:collect="always" />
+ <linearGradient
+ id="linearGradient2378">
+ <stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop2380" />
+ <stop
+ id="stop4146"
+ offset="0.25"
+ style="stop-color:#fefede;stop-opacity:0.91836733;" />
+ <stop
+ id="stop2386"
+ offset="0.5"
+ style="stop-color:#f5f328;stop-opacity:1;" />
+ <stop
+ style="stop-color:#f5f32d;stop-opacity:0.12234043;"
+ offset="1"
+ id="stop2382" />
+ </linearGradient>
+ </defs>
+ <g
+ id="layer1">
+ <g
+ id="Layer_2"
+ style="opacity:0.3">
+ <g
+ id="g8529">
+ <g
+ id="g8531">
+ <path
+ d="M 45,0 H 3 C 1.345,0 0,1.345 0,3 v 42 c 0,1.655 1.345,3 3,3 h 42 c 1.652,0 2.997,-1.345 2.997,-3 V 3 C 47.998,1.345 46.653,0 45,0 z m 1,45 c 0,0.553 -0.447,1 -1,1 H 3 C 2.448,46 2,45.553 2,45 V 3 C 2,2.448 2.448,2 3,2 h 42 c 0.553,0 1,0.448 1,1 v 42 z"
+ id="path8533" />
+ </g>
+ </g>
+ </g>
+ <g
+ id="Layer_4">
+ <g
+ id="g8536">
+ <linearGradient
+ x1="41.829601"
+ y1="48.540501"
+ x2="6.1704001"
+ y2="-0.54009998"
+ id="linearGradient10375"
+ gradientUnits="userSpaceOnUse">
+ <stop
+ id="stop10377"
+ style="stop-color:#9b9b9b;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop10379"
+ style="stop-color:#ececec;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <path
+ d="m 46,45 c 0,0.553 -0.447,1 -1,1 H 3 C 2.448,46 2,45.553 2,45 V 3 C 2,2.448 2.448,2 3,2 h 42 c 0.553,0 1,0.448 1,1 v 42 z"
+ id="path8543"
+ style="fill:url(#SVGID_1_)" />
+ </g>
+ </g>
+ <g
+ id="Layer_5">
+ <g
+ id="g8546"
+ style="opacity:0.4">
+ <g
+ id="g8548">
+ <path
+ d="M 45,2 H 3 C 2.448,2 2,2.448 2,3 v 42 c 0,0.553 0.448,1 1,1 h 42 c 0.553,0 1,-0.447 1,-1 V 3 C 46,2.448 45.552,2 45,2 z m 0,43.001 H 3 L 3.001,2.999 H 45 v 42.002 z"
+ id="path8550"
+ style="fill:#ffffff" />
+ </g>
+ </g>
+ </g>
+ <g
+ id="Layer_3">
+ <path
+ d="m 21.028,13.083 v 1.986 H 15.07 v 3.973 H 11.096 V 36.918 H 38.904 V 19.042 h -3.971 v -3.973 h -5.961 v -1.986 h -7.944 z"
+ id="path3499_3_"
+ style="opacity:0.4;fill:#ffffff" />
+ </g>
+ <g
+ id="Layer_1">
+ <linearGradient
+ x1="24"
+ y1="35.9175"
+ x2="24"
+ y2="12.083"
+ id="linearGradient10389"
+ gradientUnits="userSpaceOnUse">
+ <stop
+ id="stop10391"
+ style="stop-color:#1f1f1f;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop10393"
+ style="stop-color:#000000;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <path
+ d="m 20.028,12.083 v 1.986 H 14.07 v 3.973 H 10.096 V 35.918 H 37.904 V 18.042 h -3.971 v -3.973 h -5.961 v -1.986 h -7.944 z"
+ id="path3499_2_"
+ style="fill:url(#path3499_1_)" />
+ <g
+ id="g8561">
+ <linearGradient
+ x1="22.382799"
+ y1="33.566898"
+ x2="22.382799"
+ y2="30.768101"
+ id="linearGradient10397"
+ gradientUnits="userSpaceOnUse">
+ <stop
+ id="stop10399"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0.4725" />
+ <stop
+ id="stop10401"
+ style="stop-color:#737373;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <rect
+ width="1.541"
+ height="2.799"
+ x="21.612"
+ y="30.768"
+ id="rect3503_4_"
+ style="fill:url(#rect3503_2_)" />
+ <linearGradient
+ x1="28.7358"
+ y1="33.672401"
+ x2="28.7358"
+ y2="30.660601"
+ id="linearGradient10404"
+ gradientUnits="userSpaceOnUse">
+ <stop
+ id="stop10406"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0.4725" />
+ <stop
+ id="stop10408"
+ style="stop-color:#737373;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <rect
+ width="1.6569999"
+ height="3.0120001"
+ x="27.908001"
+ y="30.660999"
+ id="rect3505_2_"
+ style="fill:url(#rect3505_1_)" />
+ <linearGradient
+ x1="25.5581"
+ y1="33.672401"
+ x2="25.5581"
+ y2="30.660601"
+ id="linearGradient10411"
+ gradientUnits="userSpaceOnUse">
+ <stop
+ id="stop10413"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0.4725" />
+ <stop
+ id="stop10415"
+ style="stop-color:#737373;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <rect
+ width="1.655"
+ height="3.0120001"
+ x="24.731001"
+ y="30.660999"
+ id="rect3507_2_"
+ style="fill:url(#rect3507_1_)" />
+ <linearGradient
+ x1="19.205099"
+ y1="33.566898"
+ x2="19.205099"
+ y2="30.768101"
+ id="linearGradient10418"
+ gradientUnits="userSpaceOnUse">
+ <stop
+ id="stop10420"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0.4725" />
+ <stop
+ id="stop10422"
+ style="stop-color:#737373;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <rect
+ width="1.54"
+ height="2.799"
+ x="18.436001"
+ y="30.768"
+ id="rect3509_2_"
+ style="fill:url(#rect3509_1_)" />
+ <linearGradient
+ x1="16.029301"
+ y1="33.566898"
+ x2="16.029301"
+ y2="30.768101"
+ id="linearGradient10425"
+ gradientUnits="userSpaceOnUse">
+ <stop
+ id="stop10427"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0.4725" />
+ <stop
+ id="stop10429"
+ style="stop-color:#737373;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <rect
+ width="1.541"
+ height="2.799"
+ x="15.259"
+ y="30.768"
+ id="rect3503_1_"
+ style="fill:url(#rect3503_3_)" />
+ <linearGradient
+ x1="31.913601"
+ y1="33.672401"
+ x2="31.913601"
+ y2="30.660601"
+ id="linearGradient10432"
+ gradientUnits="userSpaceOnUse">
+ <stop
+ id="stop10434"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0.4725" />
+ <stop
+ id="stop10436"
+ style="stop-color:#737373;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <rect
+ width="1.654"
+ height="3.0120001"
+ x="31.086"
+ y="30.660999"
+ id="rect3512_2_"
+ style="fill:url(#rect3512_1_)" />
+ </g>
+ </g>
+ </g>
+ <g
+ inkscape:label="Layer 1"
+ id="layer1-0"
+ transform="translate(-3.2561048,0.84932513)">
+ <g
+ transform="translate(-11.172678,-40.076333)"
+ id="g2721"
+ inkscape:label="Base"
+ style="display:inline" />
+ <g
+ transform="translate(-45.445588,7.0028596)"
+ id="g4831">
+ <path
+ transform="matrix(1.14985,0,0,1.14985,37.40235,-4.152422)"
+ d="m 47.000506,9.3411446 c 0,4.6069664 -3.734684,8.3416514 -8.341651,8.3416514 -4.606966,0 -8.341651,-3.734685 -8.341651,-8.3416514 0,-4.6069667 3.734685,-8.341651 8.341651,-8.341651 4.606967,0 8.341651,3.7346843 8.341651,8.341651 z"
+ sodipodi:ry="8.341651"
+ sodipodi:rx="8.341651"
+ sodipodi:cy="9.3411446"
+ sodipodi:cx="38.658855"
+ id="path4827"
+ style="fill:url(#radialGradient4835);fill-opacity:1;fill-rule:evenodd;stroke:none;display:inline"
+ sodipodi:type="arc" />
+ <path
+ transform="matrix(0.674116,0.299577,-0.299577,0.674116,60.46181,-11.83579)"
+ d="m 44.520054,15.50279 c -0.507171,0.878446 -4.594703,-0.160823 -5.521351,0.251748 -0.926648,0.41257 -2.889414,4.145604 -3.88159,3.934711 -0.992177,-0.210894 -1.266891,-4.419519 -1.945618,-5.173323 -0.678728,-0.753803 -4.835582,-1.466933 -4.94161,-2.475719 -0.106028,-1.008786 3.811722,-2.5705906 4.318893,-3.4490369 0.507171,-0.8784463 -0.09914,-5.0522193 0.827507,-5.4647895 0.926648,-0.4125703 3.622664,2.8308064 4.614841,3.0417001 0.992176,0.2108936 4.77431,-1.6555099 5.453037,-0.9017066 0.678728,0.7538034 -1.572792,4.3201254 -1.466764,5.3289109 0.106027,1.008786 3.049826,4.029058 2.542655,4.907505 z"
+ inkscape:randomized="0"
+ inkscape:rounded="0.18352206"
+ inkscape:flatsided="false"
+ sodipodi:arg2="1.1519173"
+ sodipodi:arg1="0.52359878"
+ sodipodi:r2="5.0676599"
+ sodipodi:r1="8.755579"
+ sodipodi:cy="11.125"
+ sodipodi:cx="36.9375"
+ sodipodi:sides="5"
+ id="path4829"
+ style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.5;marker:none;visibility:visible;display:inline;overflow:visible"
+ sodipodi:type="star" />
+ </g>
+ </g>
+</svg>
diff --git a/netlink-notify.c b/netlink-notify.c
index ad8c60e..d5dd647 100644
--- a/netlink-notify.c
+++ b/netlink-notify.c
@@ -30,16 +30,14 @@
#ifndef DEBUG
#define DEBUG 0
#endif
-#ifndef IPV6
-#define IPV6 0
-#endif
+#define ICON_NETWORK_ADDRESS "netlink-notify-address"
#define ICON_NETWORK_CONNECTED "netlink-notify-connected"
#define ICON_NETWORK_DISCONNECTED "netlink-notify-disconnected"
#define TEXT_TOPIC "Netlink Notification"
#define TEXT_NEWLINK "Interface <b>%s</b> is <b>%s</b>."
-#define TEXT_NEWADDR "Interface <b>%s</b> is <b>%s</b>,\nnew address <b>%s</b>/%d."
+#define TEXT_NEWADDR "Interface <b>%s</b> has new %s address\n<b>%s</b>/%d."
#define TEXT_DELLINK "An interface has gone away."
#define TEXT_NONE "(NONE)"
@@ -61,13 +59,13 @@ char * newstr_link(char *text, char *interface, unsigned int flags) {
}
/*** newstr_addr ***/
-char * newstr_addr(char *text, char *interface, unsigned int flags, unsigned char family, void *ipaddr, unsigned char prefix) {
+char * newstr_addr(char *text, char *interface, unsigned char family, void *ipaddr, unsigned char prefix) {
char *notifystr;
char buf[64];
inet_ntop(family, ipaddr, buf, sizeof(buf));
notifystr = malloc(strlen(text) + strlen(interface) + strlen(buf));
- sprintf(notifystr, text, interface, (flags & CHECK_CONNECTED) ? "up" : "down", buf, prefix);
+ sprintf(notifystr, text, interface, family == AF_INET6 ? "IPv6" : "IP", buf, prefix);
return notifystr;
}
@@ -162,6 +160,7 @@ static int msg_handler (struct sockaddr_nl *nl, struct nlmsghdr *msg) {
struct rtattr *rth;
int rtl;
char name[IFNAMSIZ];
+ NotifyNotification * address = NULL;
ifa = (struct ifaddrmsg *) NLMSG_DATA (msg);
ifi = (struct ifinfomsg *) NLMSG_DATA (msg);
@@ -182,12 +181,10 @@ static int msg_handler (struct sockaddr_nl *nl, struct nlmsghdr *msg) {
rtl = IFA_PAYLOAD (msg);
while (rtl && RTA_OK (rth, rtl)) {
- if (rth->rta_type == IFA_LOCAL /* IPv4 */
-#if IPV6
- || rth->rta_type == IFA_ADDRESS /* IPv6 */
-#endif
- )
- notifystr = newstr_addr(TEXT_NEWADDR, name, ifi->ifi_flags,
+ if ((rth->rta_type == IFA_LOCAL /* IPv4 */
+ || rth->rta_type == IFA_ADDRESS /* IPv6 */)
+ && ifa->ifa_scope == RT_SCOPE_UNIVERSE /* no IPv6 scope link */)
+ notifystr = newstr_addr(TEXT_NEWADDR, name,
ifa->ifa_family, RTA_DATA (rth), ifa->ifa_prefixlen);
rth = RTA_NEXT (rth, rtl);
}
@@ -197,6 +194,11 @@ static int msg_handler (struct sockaddr_nl *nl, struct nlmsghdr *msg) {
#if DEBUG
puts (notifystr);
#endif
+ address = notify_notification_new(TEXT_TOPIC, notifystr, ICON_NETWORK_ADDRESS);
+ notify_notification_set_category(address, PROGNAME);
+ notify_notification_set_urgency(address, NOTIFY_URGENCY_NORMAL);
+ notify_notification_set_timeout(address, NOTIFICATION_TIMEOUT);
+
break;
case RTM_DELADDR:
return 0;
@@ -222,18 +224,20 @@ static int msg_handler (struct sockaddr_nl *nl, struct nlmsghdr *msg) {
return 0;
}
- if (notification[ifi->ifi_index] == NULL) {
- notification[ifi->ifi_index] = notify_notification_new(TEXT_TOPIC, notifystr,
- (ifi->ifi_flags & CHECK_CONNECTED ? ICON_NETWORK_CONNECTED : ICON_NETWORK_DISCONNECTED));
- notify_notification_set_category(notification[ifi->ifi_index], PROGNAME);
- notify_notification_set_urgency(notification[ifi->ifi_index], NOTIFY_URGENCY_NORMAL);
- } else
- notify_notification_update(notification[ifi->ifi_index], TEXT_TOPIC, notifystr,
- (ifi->ifi_flags & CHECK_CONNECTED ? ICON_NETWORK_CONNECTED : ICON_NETWORK_DISCONNECTED));
-
- notify_notification_set_timeout(notification[ifi->ifi_index], NOTIFICATION_TIMEOUT);
+ if (address == NULL) {
+ if (notification[ifi->ifi_index] == NULL) {
+ notification[ifi->ifi_index] = notify_notification_new(TEXT_TOPIC, notifystr,
+ (ifi->ifi_flags & CHECK_CONNECTED ? ICON_NETWORK_CONNECTED : ICON_NETWORK_DISCONNECTED));
+ notify_notification_set_category(notification[ifi->ifi_index], PROGNAME);
+ notify_notification_set_urgency(notification[ifi->ifi_index], NOTIFY_URGENCY_NORMAL);
+ } else
+ notify_notification_update(notification[ifi->ifi_index], TEXT_TOPIC, notifystr,
+ (ifi->ifi_flags & CHECK_CONNECTED ? ICON_NETWORK_CONNECTED : ICON_NETWORK_DISCONNECTED));
+
+ notify_notification_set_timeout(notification[ifi->ifi_index], NOTIFICATION_TIMEOUT);
+ }
- while (!notify_notification_show (notification[ifi->ifi_index], &error)) {
+ while (!notify_notification_show (address ? address : notification[ifi->ifi_index], &error)) {
if (errcount > 1) {
fprintf(stderr, "%s: Looks like we can not reconnect to notification daemon... Exiting.\n", program);
exit(EXIT_FAILURE);
@@ -254,6 +258,9 @@ static int msg_handler (struct sockaddr_nl *nl, struct nlmsghdr *msg) {
}
}
}
+
+ if (address)
+ g_object_unref(G_OBJECT(address));
errcount = 0;
free(notifystr);