| OLD | NEW |
| 1 /* getifaddrs -- get names and addresses of all network interfaces | 1 /* getifaddrs -- get names and addresses of all network interfaces |
| 2 Copyright (C) 2003-2007, 2008 Free Software Foundation, Inc. | 2 Copyright (C) 2003-2007, 2008 Free Software Foundation, Inc. |
| 3 This file is part of the GNU C Library. | 3 This file is part of the GNU C Library. |
| 4 | 4 |
| 5 The GNU C Library is free software; you can redistribute it and/or | 5 The GNU C Library is free software; you can redistribute it and/or |
| 6 modify it under the terms of the GNU Lesser General Public | 6 modify it under the terms of the GNU Lesser General Public |
| 7 License as published by the Free Software Foundation; either | 7 License as published by the Free Software Foundation; either |
| 8 version 2.1 of the License, or (at your option) any later version. | 8 version 2.1 of the License, or (at your option) any later version. |
| 9 | 9 |
| 10 The GNU C Library is distributed in the hope that it will be useful, | 10 The GNU C Library is distributed in the hope that it will be useful, |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 136 |
| 137 | 137 |
| 138 int | 138 int |
| 139 __netlink_request (struct netlink_handle *h, int type) | 139 __netlink_request (struct netlink_handle *h, int type) |
| 140 { | 140 { |
| 141 struct netlink_res *nlm_next; | 141 struct netlink_res *nlm_next; |
| 142 struct sockaddr_nl nladdr; | 142 struct sockaddr_nl nladdr; |
| 143 struct nlmsghdr *nlmh; | 143 struct nlmsghdr *nlmh; |
| 144 ssize_t read_len; | 144 ssize_t read_len; |
| 145 bool done = false; | 145 bool done = false; |
| 146 | |
| 147 #ifdef PAGE_SIZE | 146 #ifdef PAGE_SIZE |
| 148 /* Help the compiler optimize out the malloc call if PAGE_SIZE | 147 /* Help the compiler optimize out the malloc call if PAGE_SIZE |
| 149 is constant and smaller or equal to PTHREAD_STACK_MIN/4. */ | 148 is constant and smaller or equal to PTHREAD_STACK_MIN/4. */ |
| 150 const size_t buf_size = PAGE_SIZE; | 149 const size_t buf_size = PAGE_SIZE; |
| 151 #else | 150 #else |
| 152 const size_t buf_size = __getpagesize (); | 151 const size_t buf_size = __getpagesize (); |
| 153 #endif | 152 #endif |
| 154 bool use_malloc = false; | 153 bool use_malloc = false; |
| 155 char *buf; | 154 char *buf; |
| 156 | 155 |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 ifas[i - 1].ifa.ifa_next = &ifas[newlink].ifa; | 811 ifas[i - 1].ifa.ifa_next = &ifas[newlink].ifa; |
| 813 } | 812 } |
| 814 | 813 |
| 815 if (i == 0 && newlink > 0) | 814 if (i == 0 && newlink > 0) |
| 816 /* No valid link, but we allocated memory. We have to | 815 /* No valid link, but we allocated memory. We have to |
| 817 populate the first entry. */ | 816 populate the first entry. */ |
| 818 memmove (ifas, &ifas[newlink], sizeof (struct ifaddrs_storage)); | 817 memmove (ifas, &ifas[newlink], sizeof (struct ifaddrs_storage)); |
| 819 } | 818 } |
| 820 | 819 |
| 821 *ifap = &ifas[0].ifa; | 820 *ifap = &ifas[0].ifa; |
| 822 | |
| 823 exit_free: | 821 exit_free: |
| 824 __netlink_free_handle (&nh); | 822 __netlink_free_handle (&nh); |
| 825 __netlink_close (&nh); | 823 __netlink_close (&nh); |
| 826 | 824 |
| 827 return result; | 825 return result; |
| 828 } | 826 } |
| 829 libc_hidden_def (getifaddrs) | 827 libc_hidden_def (getifaddrs) |
| 830 | 828 |
| 831 | 829 |
| 832 #if __ASSUME_NETLINK_SUPPORT != 0 | 830 #if __ASSUME_NETLINK_SUPPORT != 0 |
| 833 void | 831 void |
| 834 freeifaddrs (struct ifaddrs *ifa) | 832 freeifaddrs (struct ifaddrs *ifa) |
| 835 { | 833 { |
| 836 free (ifa); | 834 free (ifa); |
| 837 } | 835 } |
| 838 libc_hidden_def (freeifaddrs) | 836 libc_hidden_def (freeifaddrs) |
| 839 #endif | 837 #endif |
| OLD | NEW |