char *fullcaps;
int caps; /* capabilities bit-field */
- int fd; /* >= 0, for local clients */
+ fde_t *F; /* >= 0, for local clients */
/* time challenge response is valid for */
time_t chal_time;
extern int comm_get_maxconnections(void);
extern fde_t *comm_locate_fd(int fd);
+extern fde_t *comm_add_fd(int fd);
#endif /* INCLUDED_commio_h */
add_to_client_hash(nick, source_p);
/* fd_desc is long enough */
- comm_note(client_p->localClient->fd, "Nick: %s", nick);
+ comm_note(client_p->localClient->F->fd, "Nick: %s", nick);
if(source_p->flags & FLAGS_SENTUSER)
{
}
/* fd_desc is long enough */
- comm_note(client_p->localClient->fd, "Nick: %s", nick);
+ comm_note(client_p->localClient->F->fd, "Nick: %s", nick);
return;
}
del_all_accepts(target_p);
- comm_note(target_p->localClient->fd, "Nick: %s", target_p->name);
+ comm_note(target_p->localClient->F->fd, "Nick: %s", target_p->name);
return 0;
}
else
{
send_signon(NULL, target_p, nick, user, host, CurrentTime, login);
- comm_note(target_p->localClient->fd, "Nick: %s", target_p->name);
+ comm_note(target_p->localClient->F->fd, "Nick: %s", target_p->name);
}
return 0;
client_p->localClient->lasttime = client_p->localClient->firsttime = CurrentTime;
- client_p->localClient->fd = -1;
+ client_p->localClient->F = NULL;
client_p->localClient->ctrlfd = -1;
client_p->preClient = (struct PreClient *) BlockHeapAlloc(pclient_heap);
client_p->localClient->listener = 0;
}
- if(client_p->localClient->fd >= 0)
- comm_close(client_p->localClient->fd);
+ if(client_p->localClient->F->fd >= 0)
+ comm_close(client_p->localClient->F->fd);
if(client_p->localClient->passwd)
{
else
ServerStats->is_ni++;
- if(-1 < client_p->localClient->fd)
+ if(client_p->localClient->F)
{
/* attempt to flush any pending dbufs. Evil, but .. -- adrian */
if(!IsIOError(client_p))
- send_queued_write(client_p->localClient->fd, client_p);
+ send_queued_write(client_p->localClient->F->fd, client_p);
- comm_close(client_p->localClient->fd);
- client_p->localClient->fd = -1;
+ comm_close(client_p->localClient->F->fd);
+ client_p->localClient->F = NULL;
}
if(-1 < client_p->localClient->ctrlfd)
* for reading even though it ends up being an EOF. -avalon
*/
char errmsg[255];
- int current_error = comm_get_sockerr(client_p->localClient->fd);
+ int current_error = comm_get_sockerr(client_p->localClient->F->fd);
SetIOError(client_p);
strlcpy(new_client->host, new_client->sockhost, sizeof(new_client->host));
- new_client->localClient->fd = fd;
+ new_client->localClient->F = comm_add_fd(fd);
new_client->localClient->listener = listener;
++listener->ref_count;
* I personally think it makes the code too hairy to make sane.
* -- adrian
*/
- length = read(client_p->localClient->fd, readBuf, READBUF_SIZE);
+ length = client_p->localClient->F->read_impl(client_p->localClient->F, readBuf, READBUF_SIZE);
if(length <= 0)
{
if((length == -1) && ignoreErrno(errno))
{
- comm_setselect(client_p->localClient->fd, FDLIST_IDLECLIENT,
+ comm_setselect(client_p->localClient->F->fd, FDLIST_IDLECLIENT,
COMM_SELECT_READ, read_packet, client_p, 0);
return;
}
/* If we get here, we need to register for another COMM_SELECT_READ */
if(PARSE_AS_SERVER(client_p))
{
- comm_setselect(client_p->localClient->fd, FDLIST_SERVER, COMM_SELECT_READ,
+ comm_setselect(client_p->localClient->F->fd, FDLIST_SERVER, COMM_SELECT_READ,
read_packet, client_p, 0);
}
else
{
- comm_setselect(client_p->localClient->fd, FDLIST_IDLECLIENT,
+ comm_setselect(client_p->localClient->F->fd, FDLIST_IDLECLIENT,
COMM_SELECT_READ, read_packet, client_p, 0);
}
}
struct Message *mptr;
s_assert(MyConnect(client_p));
- s_assert(client_p->localClient->fd >= 0);
+ s_assert(client_p->localClient->F->fd >= 0);
if(IsAnyDead(client_p))
return;
{
ServerStats->is_rej++;
SetReject(client_p);
- comm_setselect(client_p->localClient->fd, FDLIST_NONE, COMM_SELECT_WRITE | COMM_SELECT_READ, NULL, NULL, 0);
+ comm_setselect(client_p->localClient->F->fd, FDLIST_NONE, COMM_SELECT_WRITE | COMM_SELECT_READ, NULL, NULL, 0);
SetClosing(client_p);
dlinkMoveNode(&client_p->localClient->tnode, &unknown_list, &delay_exit);
return 1;
{
SetExUnknown(client_p);
SetReject(client_p);
- comm_setselect(client_p->localClient->fd, FDLIST_NONE, COMM_SELECT_WRITE | COMM_SELECT_READ, NULL, NULL, 0);
+ comm_setselect(client_p->localClient->F->fd, FDLIST_NONE, COMM_SELECT_WRITE | COMM_SELECT_READ, NULL, NULL, 0);
SetClosing(client_p);
dlinkMoveNode(&client_p->localClient->tnode, &unknown_list, &delay_exit);
return 1;
client->localClient->auth_request = NULL;
dlinkDelete(&auth->node, &auth_poll_list);
free_auth_request(auth);
- if(client->localClient->fd > highest_fd)
- highest_fd = client->localClient->fd;
+ if(client->localClient->F->fd > highest_fd)
+ highest_fd = client->localClient->F->fd;
/*
* When a client has auth'ed, we want to start reading what it sends
* -- adrian
*/
client->localClient->allow_read = MAX_FLOOD;
- comm_setflush(client->localClient->fd, 1000, flood_recalc, client);
+ comm_setflush(client->localClient->F->fd, 1000, flood_recalc, client);
dlinkAddTail(client, &client->node, &global_client_list);
- read_packet(client->localClient->fd, client);
+ read_packet(client->localClient->F->fd, client);
}
/*
* and machines with multiple IP addresses are common now
*/
memset(&localaddr, 0, locallen);
- getsockname(auth->client->localClient->fd,
+ getsockname(auth->client->localClient->F->fd,
(struct sockaddr *) &localaddr, &locallen);
mangle_mapped_sockaddr((struct sockaddr *)&localaddr);
}
if(getsockname
- (auth->client->localClient->fd, (struct sockaddr *) &us,
+ (auth->client->localClient->F->fd, (struct sockaddr *) &us,
(socklen_t *) & ulen)
- || getpeername(auth->client->localClient->fd,
+ || getpeername(auth->client->localClient->F->fd,
(struct sockaddr *) &them, (socklen_t *) & tlen))
{
ilog(L_IOERROR, "auth get{sock,peer}name error for %s:%m",
(me.info[0]) ? (me.info) : "IRCers United");
}
- if(!comm_set_buffers(client_p->localClient->fd, READBUF_SIZE))
+ if(!comm_set_buffers(client_p->localClient->F->fd, READBUF_SIZE))
report_error(SETBUF_ERROR_MSG,
get_server_name(client_p, SHOW_IP),
log_client_name(client_p, SHOW_IP), errno);
/* we won't overflow FD_DESC_SZ here, as it can hold
* client_p->name + 64
*/
- comm_note(client_p->localClient->fd, "slink data: %s", client_p->name);
+ comm_note(client_p->localClient->F->fd, "slink data: %s", client_p->name);
comm_note(client_p->localClient->ctrlfd, "slink ctrl: %s", client_p->name);
}
else
- comm_note(client_p->localClient->fd, "Server: %s", client_p->name);
+ comm_note(client_p->localClient->F->fd, "Server: %s", client_p->name);
/*
** Old sendto_serv_but_one() call removed because we now
{
- if((i == ctrl_fds[1]) || (i == data_fds[1]) || (i == server->localClient->fd))
+ if((i == ctrl_fds[1]) || (i == data_fds[1]) || (i == server->localClient->F->fd))
{
comm_set_nb(i);
}
ircsnprintf(fd_str[0], sizeof(fd_str[0]), "%d", ctrl_fds[1]);
ircsnprintf(fd_str[1], sizeof(fd_str[1]), "%d", data_fds[1]);
- ircsnprintf(fd_str[2], sizeof(fd_str[2]), "%d", server->localClient->fd);
+ ircsnprintf(fd_str[2], sizeof(fd_str[2]), "%d", server->localClient->F->fd);
kid_argv[0] = slink;
kid_argv[1] = fd_str[0];
kid_argv[2] = fd_str[1];
}
else
{
- comm_close(server->localClient->fd);
+ comm_close(server->localClient->F->fd);
/* close the childs end of the pipes */
close(ctrl_fds[1]);
s_assert(server->localClient);
server->localClient->ctrlfd = ctrl_fds[0];
- server->localClient->fd = data_fds[0];
+ server->localClient->F->fd = data_fds[0];
- if(!comm_set_nb(server->localClient->fd))
+ if(!comm_set_nb(server->localClient->F->fd))
{
report_error(NONB_ERROR_MSG,
get_server_name(server, SHOW_IP),
}
comm_open(server->localClient->ctrlfd, FD_SOCKET, NULL);
- comm_open(server->localClient->fd, FD_SOCKET, NULL);
+ comm_open(server->localClient->F->fd, FD_SOCKET, NULL);
read_ctrl_packet(server->localClient->ctrlfd, server);
- read_packet(server->localClient->fd, server);
+ read_packet(server->localClient->F->fd, server);
}
return 0;
strlcpy(client_p->name, server_p->name, sizeof(client_p->name));
strlcpy(client_p->host, server_p->host, sizeof(client_p->host));
strlcpy(client_p->sockhost, server_p->host, sizeof(client_p->sockhost));
- client_p->localClient->fd = fd;
+ client_p->localClient->F->fd = fd;
/*
* Set up the initial server evilness, ripped straight from
* -- adrian
*/
- if(!comm_set_buffers(client_p->localClient->fd, READBUF_SIZE))
+ if(!comm_set_buffers(client_p->localClient->F->fd, READBUF_SIZE))
{
report_error(SETBUF_ERROR_MSG,
get_server_name(client_p, SHOW_IP),
#endif
(server_p->aftype == AF_INET ? "IPv4" : "?"));
- comm_connect_tcp(client_p->localClient->fd, server_p->host,
+ comm_connect_tcp(client_p->localClient->F->fd, server_p->host,
server_p->port, NULL, 0, serv_connect_callback,
client_p, server_p->aftype,
ConfigFileEntry.connect_timeout);
(server_p->aftype == AF_INET ? "IPv4" : "?"), vhoststr);
- comm_connect_tcp(client_p->localClient->fd, server_p->host,
+ comm_connect_tcp(client_p->localClient->F->fd, server_p->host,
server_p->port, (struct sockaddr *) &myipnum,
GET_SS_LEN(myipnum), serv_connect_callback, client_p,
myipnum.ss_family, ConfigFileEntry.connect_timeout);
/* First, make sure its a real client! */
s_assert(client_p != NULL);
- s_assert(client_p->localClient->fd == fd);
+ s_assert(client_p->localClient->F->fd == fd);
if(client_p == NULL)
return;
del_from_client_hash(source_p->name, source_p);
strlcpy(source_p->name, source_p->preClient->spoofnick, NICKLEN + 1);
add_to_client_hash(source_p->name, source_p);
- comm_note(source_p->localClient->fd, "Nick: %s", source_p->name);
+ comm_note(source_p->localClient->F->fd, "Nick: %s", source_p->name);
}
if(!valid_hostname(source_p->host))
to->localClient->sendM += 1;
me.localClient->sendM += 1;
if(linebuf_len(&to->localClient->buf_sendq) > 0)
- send_queued_write(to->localClient->fd, to);
+ send_queued_write(to->localClient->F->fd, to);
return 0;
}
#ifdef USE_IODEBUG_HOOKS
hook_data_int hd;
#endif
- fde_t *F = comm_locate_fd(to->localClient->fd);
+ fde_t *F = comm_locate_fd(to->localClient->F->fd);
if (!F)
return;