Changeset 500:d4fc98a3b79c in freeDiameter
- Timestamp:
- Aug 17, 2010, 4:35:19 PM (14 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
contrib/OpenWRT/packages/freeDiameter/Makefile
r498 r500 11 11 12 12 PKG_NAME:=freeDiameter 13 PKG_REV:= 49713 PKG_REV:=500 14 14 PKG_VERSION:=r$(PKG_REV) 15 15 PKG_RELEASE:=1 -
extensions/app_radgw/rgw_clients.c
r442 r500 66 66 67 67 /* The FQDN, realm, and optional aliases */ 68 int is_local; /* true if the RADIUS client runs on the same host -- we use Diameter Identity in that case */ 68 69 char *fqdn; 69 70 size_t fqdn_len; … … 95 96 char buf[255]; 96 97 int ret; 97 98 /* Search FQDN for the client */ 99 ret = getnameinfo( *ip_port, sizeof(struct sockaddr_storage), &buf[0], sizeof(buf), NULL, 0, 0 ); 100 if (ret) { 101 TRACE_DEBUG(INFO, "Unable to resolve peer name: %s", gai_strerror(ret)); 102 return EINVAL; 98 int loc = 0; 99 100 /* Check if the IP address is local */ 101 if ( ( ((*ip_port)->sa_family == AF_INET ) && ( IN_IS_ADDR_LOOPBACK( &((struct sockaddr_in *)(*ip_port))->sin_addr ) ) ) 102 ||( ((*ip_port)->sa_family == AF_INET6) && ( IN6_IS_ADDR_LOOPBACK( &((struct sockaddr_in6 *)(*ip_port))->sin6_addr) ) )) { 103 /* The client is local */ 104 loc = 1; 105 } else { 106 107 /* Search FQDN for the client */ 108 ret = getnameinfo( *ip_port, sizeof(struct sockaddr_storage), &buf[0], sizeof(buf), NULL, 0, 0 ); 109 if (ret) { 110 TRACE_DEBUG(INFO, "Unable to resolve peer name: %s", gai_strerror(ret)); 111 return EINVAL; 112 } 103 113 } 104 114 … … 108 118 fd_list_init(&tmp->chain, NULL); 109 119 110 /* Copy the fqdn */ 111 CHECK_MALLOC( tmp->fqdn = strdup(buf) ); 112 tmp->fqdn_len = strlen(tmp->fqdn); 113 /* Find an appropriate realm */ 114 tmp->realm = strchr(tmp->fqdn, '.'); 115 if (tmp->realm) 116 tmp->realm += 1; 117 if ((!tmp->realm) || (*tmp->realm == '\0')) /* in case the fqdn was "localhost." for example, if it is possible... */ 118 tmp->realm = fd_g_config->cnf_diamrlm; 120 if (loc) { 121 tmp->is_local = 1; 122 } else { 123 /* Copy the fqdn */ 124 CHECK_MALLOC( tmp->fqdn = strdup(buf) ); 125 tmp->fqdn_len = strlen(tmp->fqdn); 126 /* Find an appropriate realm */ 127 tmp->realm = strchr(tmp->fqdn, '.'); 128 if (tmp->realm) 129 tmp->realm += 1; 130 if ((!tmp->realm) || (*tmp->realm == '\0')) /* in case the fqdn was "localhost." for example, if it is possible... */ 131 tmp->realm = fd_g_config->cnf_diamrlm; 132 } 119 133 120 134 /* move the sa info reference */ … … 155 169 156 170 157 /* Macro to avoid duplic ting the code in the next function */171 /* Macro to avoid duplicating the code in the next function */ 158 172 #define client_search_family( _family_ ) \ 159 173 case AF_INET##_family_: { \ … … 370 384 } 371 385 372 /* Now check the nas_id */373 if (nas_id ) {386 /* Now check the nas_id, but only for non-local hosts */ 387 if (nas_id && (! cli->is_local) ) { 374 388 char * str; 375 389 int found, ret; … … 464 478 CHECK_PARAMS(cli && fqdn); 465 479 466 *fqdn = cli->fqdn; 467 if (realm) 468 *realm= cli->realm; 480 if (cli->is_local) { 481 *fqdn = fd_g_config->cnf_diamid; 482 if (realm) 483 *realm= fd_g_config->cnf_diamrlm; 484 } else { 485 *fqdn = cli->fqdn; 486 if (realm) 487 *realm= cli->realm; 488 } 489 469 490 return 0; 470 491 } … … 472 493 char * rgw_clients_id(struct rgw_client *cli) 473 494 { 474 return cli-> fqdn;495 return cli->is_local ? "(local)" : cli->fqdn; 475 496 } 476 497
Note: See TracChangeset
for help on using the changeset viewer.