1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/mtransport/third_party/nICEr/src/net/local_addr.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,60 @@ 1.4 +/* 1.5 +Copyright (c) 2007, Adobe Systems, Incorporated 1.6 +Copyright (c) 2013, Mozilla 1.7 + 1.8 +All rights reserved. 1.9 + 1.10 +Redistribution and use in source and binary forms, with or without 1.11 +modification, are permitted provided that the following conditions are 1.12 +met: 1.13 + 1.14 +* Redistributions of source code must retain the above copyright 1.15 + notice, this list of conditions and the following disclaimer. 1.16 + 1.17 +* Redistributions in binary form must reproduce the above copyright 1.18 + notice, this list of conditions and the following disclaimer in the 1.19 + documentation and/or other materials provided with the distribution. 1.20 + 1.21 +* Neither the name of Adobe Systems, Network Resonance, Mozilla nor 1.22 + the names of its contributors may be used to endorse or promote 1.23 + products derived from this software without specific prior written 1.24 + permission. 1.25 + 1.26 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.27 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.28 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.29 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1.30 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.31 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.32 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1.33 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1.34 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.35 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1.36 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.37 +*/ 1.38 + 1.39 +#include <nr_api.h> 1.40 +#include <string.h> 1.41 +#include "local_addr.h" 1.42 + 1.43 +int nr_local_addr_copy(nr_local_addr *to, nr_local_addr *from) 1.44 + { 1.45 + nr_transport_addr_copy(&(to->addr), &(from->addr)); 1.46 + to->interface = from->interface; 1.47 + return(0); 1.48 + } 1.49 + 1.50 +int nr_local_addr_fmt_info_string(nr_local_addr *addr, char *buf, int len) 1.51 + { 1.52 + int addr_type = addr->interface.type; 1.53 + const char *vpn = (addr_type & NR_INTERFACE_TYPE_VPN) ? "VPN on " : ""; 1.54 + 1.55 + const char *type = (addr_type & NR_INTERFACE_TYPE_WIRED) ? "wired" : 1.56 + (addr_type & NR_INTERFACE_TYPE_WIFI) ? "wifi" : 1.57 + (addr_type & NR_INTERFACE_TYPE_MOBILE) ? "mobile" : 1.58 + "unknown"; 1.59 + 1.60 + snprintf(buf, len, "%s%s, estimated speed: %d kbps", 1.61 + vpn, type, addr->interface.estimated_speed); 1.62 + return (0); 1.63 + }