aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/netutils/ifc.h5
-rw-r--r--libnetutils/ifc_utils.c19
2 files changed, 23 insertions, 1 deletions
diff --git a/include/netutils/ifc.h b/include/netutils/ifc.h
index 67a4a456..834f73fa 100644
--- a/include/netutils/ifc.h
+++ b/include/netutils/ifc.h
@@ -1,5 +1,6 @@
/*
* Copyright 2008, The Android Open Source Project
+ * Copyright (C) 2011, Code Aurora Forum. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -61,10 +62,12 @@ extern int ifc_remove_route(const char *ifname, const char *dst,
int prefix_length, const char *gw);
extern int ifc_get_info(const char *name, in_addr_t *addr, int *prefixLength,
unsigned *flags);
-
extern int ifc_configure(const char *ifname, in_addr_t address,
uint32_t prefixLength, in_addr_t gateway,
in_addr_t dns1, in_addr_t dns2);
+extern int ifc_get_mtu(const char *name, int *mtuSz);
+extern in_addr_t prefixLengthToIpv4Netmask(int prefix_length);
+extern int ipv4NetmaskToPrefixLength(in_addr_t mask);
__END_DECLS
diff --git a/libnetutils/ifc_utils.c b/libnetutils/ifc_utils.c
index a3579a4c..1832b926 100644
--- a/libnetutils/ifc_utils.c
+++ b/libnetutils/ifc_utils.c
@@ -1,5 +1,6 @@
/*
* Copyright 2008, The Android Open Source Project
+ * Copyright (C) 2011, Code Aurora Forum. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -981,3 +982,21 @@ int ifc_remove_route(const char *ifname, const char*dst, int prefix_length, cons
{
return ifc_act_on_route(SIOCDELRT, ifname, dst, prefix_length, gw);
}
+
+int ifc_get_mtu(const char *name, int *mtuSz)
+{
+ struct ifreq ifr;
+ ifc_init_ifr(name, &ifr);
+
+ if (mtuSz != NULL) {
+ if(ioctl(ifc_ctl_sock, SIOCGIFMTU, &ifr) < 0) {
+ *mtuSz = 0;
+ return -2;
+ } else {
+ *mtuSz = ifr.ifr_mtu;
+ return 0;
+ }
+ }
+
+ return -1;
+}