aboutsummaryrefslogtreecommitdiffstats
path: root/libnetutils
diff options
context:
space:
mode:
authorNiranjan Pendharkar <npendhar@codeaurora.org>2011-11-16 12:50:36 -0800
committerGiulio Cervera <giulio.cervera@gmail.com>2012-09-23 17:15:37 +0200
commit7c9bc378e45b8dcac8bb3ba60748adbdbb4d15a9 (patch)
treea7a358f5b98884ffec800d43e18185fb18977dd8 /libnetutils
parentd39f52491364217e40aca4fb06ed9f7903af60f0 (diff)
downloadsystem_core-7c9bc378e45b8dcac8bb3ba60748adbdbb4d15a9.zip
system_core-7c9bc378e45b8dcac8bb3ba60748adbdbb4d15a9.tar.gz
system_core-7c9bc378e45b8dcac8bb3ba60748adbdbb4d15a9.tar.bz2
core: Add API to retrieve mtu size
Adding an API to libnetutils to retrieve mtu size of an interface Made few utility functions from ifc_utils public Change-Id: Iddec2dcd9f241b146d7f362e2df0724cf740d1f2 (cherry picked from commit 108cded7d96cc347f36b5b78c404c5ebccce13d7)
Diffstat (limited to 'libnetutils')
-rw-r--r--libnetutils/ifc_utils.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/libnetutils/ifc_utils.c b/libnetutils/ifc_utils.c
index a3579a4..1832b92 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;
+}