authd/provider: add c_addr/l_addr fields

Some providers consume these directly, so it's better to have a "cached"
version that's already generated.
This commit is contained in:
Elizabeth Myers 2016-03-23 18:56:29 -05:00
parent 6e4bcf20ff
commit 9c7498d559
2 changed files with 18 additions and 0 deletions

View file

@ -205,9 +205,25 @@ static void start_auth(const char *cid, const char *l_ip, const char *l_port, co
rb_strlcpy(auth->l_ip, l_ip, sizeof(auth->l_ip));
auth->l_port = (uint16_t)atoi(l_port); /* should be safe */
(void) rb_inet_pton_sock(l_ip, (struct sockaddr *)&auth->l_addr, sizeof(auth->l_addr));
rb_strlcpy(auth->c_ip, c_ip, sizeof(auth->c_ip));
auth->c_port = (uint16_t)atoi(c_port);
(void) rb_inet_pton_sock(c_ip, (struct sockaddr *)&auth->c_addr, sizeof(auth->c_addr));
#ifdef RB_IPV6
if(GET_SS_FAMILY(&auth->l_addr) == AF_INET6)
((struct sockaddr_in6 *)&l_addr)->sin6_port = htons(auth->l_port);
else
#endif
((struct sockaddr_in *)&l_addr)->sin_port = htons(auth->l_port);
#ifdef RB_IPV6
if(GET_SS_FAMILY(&auth->c_addr) == AF_INET6)
((struct sockaddr_in6 *)&c_addr)->sin6_port = htons(auth->c_port);
else
#endif
((struct sockaddr_in *)&c_addr)->sin_port = htons(auth->c_port);
rb_dictionary_add(auth_clients, RB_UINT_TO_POINTER(auth->cid), auth);

View file

@ -40,9 +40,11 @@ struct auth_client
char l_ip[HOSTIPLEN + 1]; /* Listener IP address */
uint16_t l_port; /* Listener port */
struct rb_sockaddr_storage l_addr; /* Listener address/port */
char c_ip[HOSTIPLEN + 1]; /* Client IP address */
uint16_t c_port; /* Client port */
struct rb_sockaddr_storage c_addr; /* Client address/port */
char hostname[HOSTLEN + 1]; /* Used for DNS lookup */
char username[USERLEN + 1]; /* Used for ident lookup */