void __connman_ipconfig_cleanup(void);
void __connman_ipconfig_newlink(int index, unsigned short type,
- unsigned int flags);
+ unsigned int flags, const char *address,
+ unsigned short mtu);
void __connman_ipconfig_dellink(int index);
void __connman_ipconfig_newaddr(int index, const char *label,
unsigned char prefixlen, const char *address);
DBusMessageIter *iter);
int __connman_ipconfig_set_ipv4(struct connman_ipconfig *ipconfig,
const char *key, DBusMessageIter *value);
+int __connman_ipconfig_append_ethernet(struct connman_ipconfig *ipconfig,
+ DBusMessageIter *iter);
int __connman_ipconfig_load(struct connman_ipconfig *ipconfig,
GKeyFile *keyfile, const char *identifier, const char *prefix);
enum connman_ipconfig_method method;
struct connman_ipaddress *address;
+
+ char *eth;
+ uint16_t mtu;
};
struct connman_ipdevice {
}
void __connman_ipconfig_newlink(int index, unsigned short type,
- unsigned int flags)
+ unsigned int flags, const char *address,
+ unsigned short mtu)
{
struct connman_ipdevice *ipdevice;
GList *list;
if (index != ipconfig->index)
continue;
+ g_free(ipconfig->eth);
+ ipconfig->eth = g_strdup(address);
+ ipconfig->mtu = mtu;
+
if (up == TRUE && ipconfig->ops->up)
ipconfig->ops->up(ipconfig);
if (lower_up == TRUE && ipconfig->ops->lower_up)
}
connman_ipaddress_free(ipconfig->address);
+ g_free(ipconfig->eth);
g_free(ipconfig);
}
}
return 0;
}
+int __connman_ipconfig_append_ethernet(struct connman_ipconfig *ipconfig,
+ DBusMessageIter *iter)
+{
+ const char *method = "auto";
+
+ connman_dbus_dict_append_basic(iter, "Method",
+ DBUS_TYPE_STRING, &method);
+
+ if (ipconfig->eth != NULL)
+ connman_dbus_dict_append_basic(iter, "Address",
+ DBUS_TYPE_STRING, &ipconfig->eth);
+
+ if (ipconfig->mtu > 0)
+ connman_dbus_dict_append_basic(iter, "MTU",
+ DBUS_TYPE_UINT16, &ipconfig->mtu);
+
+ return 0;
+}
+
int __connman_ipconfig_load(struct connman_ipconfig *ipconfig,
GKeyFile *keyfile, const char *identifier, const char *prefix)
{
}
static void extract_link(struct ifinfomsg *msg, int bytes,
- const char **ifname, unsigned char *operstate)
+ const char **address, const char **ifname,
+ unsigned int *mtu, unsigned char *operstate)
{
struct rtnl_link_stats stats;
struct rtattr *attr;
for (attr = IFLA_RTA(msg); RTA_OK(attr, bytes);
attr = RTA_NEXT(attr, bytes)) {
switch (attr->rta_type) {
+ case IFLA_ADDRESS:
+ if (address != NULL)
+ *address = RTA_DATA(attr);
+ break;
case IFLA_IFNAME:
if (ifname != NULL)
*ifname = RTA_DATA(attr);
break;
- case IFLA_OPERSTATE:
- if (operstate != NULL)
- *operstate = *((unsigned char *) RTA_DATA(attr));
- break;
- case IFLA_LINKMODE:
+ case IFLA_MTU:
+ if (mtu != NULL)
+ *mtu = *((unsigned int *) RTA_DATA(attr));
break;
case IFLA_STATS:
memcpy(&stats, RTA_DATA(attr),
connman_info("%s {TX} %d packets %d bytes", *ifname,
stats.tx_packets, stats.tx_bytes);
break;
+ case IFLA_OPERSTATE:
+ if (operstate != NULL)
+ *operstate = *((unsigned char *) RTA_DATA(attr));
+ break;
+ case IFLA_LINKMODE:
+ break;
}
}
}
static void process_newlink(unsigned short type, int index, unsigned flags,
unsigned change, struct ifinfomsg *msg, int bytes)
{
- unsigned char operstate = 0xff;
+ const char *address = NULL;
const char *ifname = NULL;
+ unsigned int mtu = 0;
+ unsigned char operstate = 0xff;
GSList *list;
+ extract_link(msg, bytes, &address, &ifname, &mtu, &operstate);
+
switch (type) {
case ARPHRD_ETHER:
case ARPHRD_LOOPBACK:
case ARPHRD_NONE:
- __connman_ipconfig_newlink(index, type, flags);
+ __connman_ipconfig_newlink(index, type, flags, address, mtu);
break;
}
- extract_link(msg, bytes, &ifname, &operstate);
+ if (address != NULL && strlen(address) > 0)
+ connman_info("%s {newlink} index %d address %s mtu %u",
+ ifname, index, address, mtu);
if (operstate != 0xff)
- connman_info("%s {newlink} index %d operstate %d <%s>",
+ connman_info("%s {newlink} index %d operstate %u <%s>",
ifname, index, operstate,
operstate2str(operstate));
static void process_dellink(unsigned short type, int index, unsigned flags,
unsigned change, struct ifinfomsg *msg, int bytes)
{
- unsigned char operstate = 0xff;
+ const char *address = NULL;
const char *ifname = NULL;
+ unsigned int mtu = 0;
+ unsigned char operstate = 0xff;
GSList *list;
- extract_link(msg, bytes, &ifname, &operstate);
+ extract_link(msg, bytes, &address, &ifname, &mtu, &operstate);
if (operstate != 0xff)
- connman_info("%s {dellink} index %d operstate %d <%s>",
+ connman_info("%s {dellink} index %d operstate %u <%s>",
ifname, index, operstate,
operstate2str(operstate));