Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 22d8f165 authored by Giulio Cervera's avatar Giulio Cervera Committed by Gerrit Code Review
Browse files

Merge "core: Add API to retrieve mtu size" into jellybean

parents 38eee0ff 7c9bc378
Loading
Loading
Loading
Loading
+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. 
@@ -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

+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. 
@@ -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;
}