Loading include/netutils/ifc.h +4 −1 Original line number Diff line number Diff line /* * 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. Loading Loading @@ -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 Loading libnetutils/ifc_utils.c +19 −0 Original line number Diff line number Diff line /* * 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. Loading Loading @@ -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; } Loading
include/netutils/ifc.h +4 −1 Original line number Diff line number Diff line /* * 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. Loading Loading @@ -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 Loading
libnetutils/ifc_utils.c +19 −0 Original line number Diff line number Diff line /* * 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. Loading Loading @@ -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; }