Changeset 4777:5a250aafb5ba in roaraudio
- Timestamp:
- 03/10/11 16:11:03 (13 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r4774 r4777 9 9 * Added IPv6 support 10 10 * Updated Debian init script (See: DEB#613772) 11 * Added support for use of DECnet and ARP neighbour tables to locate servers 12 (enumdev only at the moment) (pr1) 11 13 12 14 v. 0.4beta3 - Wed Jan 26 2011 23:26 CET -
libroar/enumdev.c
r4775 r4777 41 41 struct roar_connection con; 42 42 struct roar_server_info * info; 43 int checked = 0; 43 44 44 45 if ( c->server == NULL ) … … 47 48 if ( flags & ROAR_ENUM_FLAG_NONBLOCK ) 48 49 return 0; 50 51 ROAR_DBG("_test_server(c=%p{.server='%s', ...}, flags=0x%.4X) = ?", c, c->server, flags); 49 52 50 53 if ( roar_connect(&con, (char*)c->server) == -1 ) … … 54 57 info = roar_server_info(&con); 55 58 if ( info != NULL ) { 59 checked = 1; 56 60 if ( info->location != NULL ) 57 61 c->location = roar_mm_strdup(info->location); … … 61 65 62 66 roar_server_info_free(info); 67 } 68 } 69 70 // make sure we get at least a NOOP from the server to detect protocol mismatch. 71 if ( !checked ) { 72 if ( roar_noop(&con) != 0 ) { 73 roar_disconnect(&con); 74 return -1; 63 75 } 64 76 } … … 162 174 } 163 175 176 static ssize_t _esl_neighbours(int flags, int dir, int socktype, char ** servers, size_t maxlen) { 177 ssize_t ret = 0; 178 char buf[1024]; 179 FILE * inp; 180 size_t i; 181 char * delm; 182 const struct { 183 const char * file; 184 const char * suffix; 185 const size_t skip; 186 } *f, files[] = { 187 #ifdef ROAR_PROC_NET_DECNET_NEIGH 188 {ROAR_PROC_NET_DECNET_NEIGH, "::", 1}, 189 #endif 190 #ifdef ROAR_PROC_NET_ARP 191 {ROAR_PROC_NET_ARP, NULL, 1}, 192 #endif 193 {NULL, NULL, 0} 194 }; 195 196 for (f = &(files[0]); f->file != NULL; f++) { 197 if ( (inp = fopen(f->file, "r")) == NULL ) 198 continue; 199 200 for (i = 0; i < f->skip; i++) { 201 if ( fgets(buf, sizeof(buf), inp) == NULL ) { 202 // bad error... 203 fclose(inp); 204 return ret; 205 } 206 } 207 208 while (ret < (ssize_t)maxlen && fgets(buf, sizeof(buf), inp) != NULL) { 209 // skip comments and empty lions 210 if ( buf[0] == '#' || buf[0] == '\0' ) 211 continue; 212 213 // ensure we have a tailing \0. 214 buf[sizeof(buf)-1] = 0; 215 216 delm = strstr(buf, " "); 217 if ( delm == NULL ) 218 delm = strstr(buf, "\t"); 219 220 // does it look like a correctly formated lion? 221 // we may remove this check or relax it later. 222 if ( delm == NULL ) 223 continue; 224 225 *delm = 0; 226 227 if ( f->suffix != NULL ) { 228 if ( (strlen(buf) + strlen(f->suffix) + 1) > sizeof(buf) ) 229 continue; 230 231 strcat(buf, f->suffix); 232 } 233 234 // work around a bug in Linux kernel which always reports node 0.2 to be up. 235 if ( !strcmp(buf, "0.2::") ) 236 continue; 237 238 _add(buf); 239 } 240 241 fclose(inp); 242 if ( ret == (ssize_t)maxlen ) 243 break; 244 } 245 246 return ret; 247 } 248 164 249 struct locmed { 165 250 int supflags; … … 169 254 static struct locmed _libroar_locmod[] = { 170 255 {ROAR_ENUM_FLAG_NONBLOCK|ROAR_ENUM_FLAG_HARDNONBLOCK, _esl_defaults}, 171 {ROAR_ENUM_FLAG_NONE, _esl_slp} 256 {ROAR_ENUM_FLAG_NONE, _esl_slp}, 257 {ROAR_ENUM_FLAG_NONBLOCK, _esl_neighbours} 172 258 }; 173 259
Note: See TracChangeset
for help on using the changeset viewer.