~ubuntu-branches/ubuntu/saucy/libhdhomerun/saucy

« back to all changes in this revision

Viewing changes to hdhomerun_sock_posix.c

  • Committer: Package Import Robot
  • Author(s): Francois Marier
  • Date: 2013-05-19 18:04:56 UTC
  • mfrom: (1.1.16) (0.1.14 sid)
  • Revision ID: package-import@ubuntu.com-20130519180456-y73jtd4wr5lmo6v5
Tags: 20130328-1
* New upstream release
* Add CPPFLAGS to the upstream Makefile
* Bump Standards-Version up to 3.9.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
105
105
                struct ifreq *ifr = (struct ifreq *)ptr;
106
106
                ptr += _SIZEOF_ADDR_IFREQ(*ifr);
107
107
 
 
108
                /* Flags. */
 
109
                if (ioctl(sock, SIOCGIFFLAGS, ifr) != 0) {
 
110
                        continue;
 
111
                }
 
112
 
 
113
                if ((ifr->ifr_flags & IFF_UP) == 0) {
 
114
                        continue;
 
115
                }
 
116
                if ((ifr->ifr_flags & IFF_RUNNING) == 0) {
 
117
                        continue;
 
118
                }
 
119
 
 
120
                /* Local IP address. */
108
121
                if (ioctl(sock, SIOCGIFADDR, ifr) != 0) {
109
122
                        continue;
110
123
                }
115
128
                        continue;
116
129
                }
117
130
 
 
131
                /* Subnet mask. */
118
132
                if (ioctl(sock, SIOCGIFNETMASK, ifr) != 0) {
119
133
                        continue;
120
134
                }
122
136
                struct sockaddr_in *subnet_mask_in = (struct sockaddr_in *)&(ifr->ifr_addr);
123
137
                uint32_t subnet_mask = ntohl(subnet_mask_in->sin_addr.s_addr);
124
138
 
125
 
                struct hdhomerun_local_ip_info_t *ip_info = &ip_info_list[count++];
126
 
                ip_info->ip_addr = ip_addr;
127
 
                ip_info->subnet_mask = subnet_mask;
128
 
 
129
 
                if (count >= max_count) {
130
 
                        break;
 
139
                /* Report. */
 
140
                if (count < max_count) {
 
141
                        struct hdhomerun_local_ip_info_t *ip_info = &ip_info_list[count];
 
142
                        ip_info->ip_addr = ip_addr;
 
143
                        ip_info->subnet_mask = subnet_mask;
131
144
                }
 
145
 
 
146
                count++;
132
147
        }
133
148
 
134
149
        free(ifc.ifc_buf);