Lines Matching refs:cli

131 ilbd_free_cli(ilbd_client_t *cli)  in ilbd_free_cli()  argument
133 (void) close(cli->cli_sd); in ilbd_free_cli()
134 if (cli->cli_cmd == ILBD_SHOW_NAT) in ilbd_free_cli()
136 if (cli->cli_cmd == ILBD_SHOW_PERSIST) in ilbd_free_cli()
138 if (cli->cli_saved_reply != NULL) in ilbd_free_cli()
139 free(cli->cli_saved_reply); in ilbd_free_cli()
140 if (cli->cli_peer_ucredp != NULL) in ilbd_free_cli()
141 ucred_free(cli->cli_peer_ucredp); in ilbd_free_cli()
142 free(cli->cli_pw_buf); in ilbd_free_cli()
143 free(cli); in ilbd_free_cli()
359 consume_common_struct(ilb_comm_t *ic, size_t ic_sz, ilbd_client_t *cli, in consume_common_struct() argument
374 cli->cli_ev = ILBD_EVENT_REQ; in consume_common_struct()
376 ps = &cli->cli_pw; in consume_common_struct()
397 cli->cli_peer_ucredp); in consume_common_struct()
403 rc = ilbd_destroy_sg(name, ps, cli->cli_peer_ucredp); in consume_common_struct()
410 ev_port, ps, cli->cli_peer_ucredp); in consume_common_struct()
417 ev_port, ps, cli->cli_peer_ucredp); in consume_common_struct()
424 cli->cli_peer_ucredp); in consume_common_struct()
431 cli->cli_peer_ucredp); in consume_common_struct()
465 ps, cli->cli_peer_ucredp); in consume_common_struct()
471 rc = ilbd_destroy_rule(name, ps, cli->cli_peer_ucredp); in consume_common_struct()
476 rc = ilbd_enable_rule(name, ps, cli->cli_peer_ucredp); in consume_common_struct()
481 rc = ilbd_disable_rule(name, ps, cli->cli_peer_ucredp); in consume_common_struct()
493 cli->cli_peer_ucredp); in consume_common_struct()
498 rc = ilbd_destroy_hc(name, ps, cli->cli_peer_ucredp); in consume_common_struct()
516 rc = ilbd_show_nat(cli, ic, reply_buf, &rbufsz); in consume_common_struct()
522 rc = ilbd_show_sticky(cli, ic, reply_buf, &rbufsz); in consume_common_struct()
550 if ((ret = send(cli->cli_sd, reply_buf, rbufsz, 0)) != rbufsz) { in consume_common_struct()
562 assert(cli->cli_saved_reply == NULL); in consume_common_struct()
563 if ((cli->cli_saved_reply = malloc(rbufsz)) == NULL) { in consume_common_struct()
573 bcopy(reply_buf, cli->cli_saved_reply, rbufsz); in consume_common_struct()
574 cli->cli_saved_size = rbufsz; in consume_common_struct()
595 ilbd_client_t *cli = NULL; in new_req() local
620 if ((cli = calloc(1, sizeof (ilbd_client_t))) == NULL) { in new_req()
624 res = getpeerucred(new_sd, &cli->cli_peer_ucredp); in new_req()
629 if ((uid = ucred_getruid(cli->cli_peer_ucredp)) == (uid_t)-1) { in new_req()
633 cli->cli_pw_bufsz = (size_t)sysconf(_SC_GETPW_R_SIZE_MAX); in new_req()
634 if ((cli->cli_pw_buf = malloc(cli->cli_pw_bufsz)) == NULL) { in new_req()
638 if (getpwuid_r(uid, &cli->cli_pw, cli->cli_pw_buf, in new_req()
639 cli->cli_pw_bufsz) == NULL) { in new_req()
643 cli->cli_ev = ILBD_EVENT_REQ; in new_req()
644 cli->cli_sd = new_sd; in new_req()
645 cli->cli_cmd = ILBD_BAD_CMD; in new_req()
646 cli->cli_saved_reply = NULL; in new_req()
647 cli->cli_saved_size = 0; in new_req()
649 cli) == -1) { in new_req()
652 if (cli != NULL) { in new_req()
653 if (cli->cli_peer_ucredp != NULL) in new_req()
654 ucred_free(cli->cli_peer_ucredp); in new_req()
655 free(cli->cli_pw_buf); in new_req()
656 free(cli); in new_req()
671 handle_req(int ev_port, ilbd_event_t event, ilbd_client_t *cli) in handle_req() argument
687 if (cli->cli_saved_reply != NULL) { in handle_req()
698 r = recv(cli->cli_sd, (void *)ic_u.buf, sizeof (ic_u.buf), 0); in handle_req()
711 cli->cli_cmd = ic_u.ic.ic_cmd; in handle_req()
713 rc = consume_common_struct(&ic_u.ic, r, cli, ev_port); in handle_req()
721 assert(cli->cli_saved_reply != NULL); in handle_req()
727 if (send(cli->cli_sd, cli->cli_saved_reply, in handle_req()
728 cli->cli_saved_size, 0) != cli->cli_saved_size) { in handle_req()
737 free(cli->cli_saved_reply); in handle_req()
738 cli->cli_saved_reply = NULL; in handle_req()
739 cli->cli_saved_size = 0; in handle_req()
743 cli->cli_ev = ILBD_EVENT_REQ; in handle_req()
744 if (port_associate(ev_port, PORT_SOURCE_FD, cli->cli_sd, in handle_req()
745 POLLRDNORM, cli) == -1) { in handle_req()
754 cli->cli_ev = ILBD_EVENT_REP_OK; in handle_req()
755 if (port_associate(ev_port, PORT_SOURCE_FD, cli->cli_sd, POLLWRNORM, in handle_req()
756 cli) == -1) { in handle_req()
764 ilbd_free_cli(cli); in handle_req()
809 ilbd_client_t *cli; in main_loop() local
848 cli = (ilbd_client_t *)p_ev.portev_user; in main_loop()
849 assert(ev_port_obj == cli->cli_sd); in main_loop()
858 ilbd_free_cli(cli); in main_loop()
862 handle_req(ev_port, event, cli); in main_loop()