Lines Matching refs:vcp
62 static int smb_vc_disconnect(struct smb_vc *vcp);
125 struct smb_vc *vcp; in smb_sm_lookupint() local
131 vcp = NULL; in smb_sm_lookupint()
133 vcp = (struct smb_vc *)scp; in smb_sm_lookupint()
134 error = smb_vc_lock(vcp); in smb_sm_lookupint()
138 if ((vcp->obj.co_flags & SMBV_PRIVATE) || in smb_sm_lookupint()
139 !CONNADDREQ(vcp->vc_paddr, vcspec->sap) || in smb_sm_lookupint()
140 strcmp(vcp->vc_username, vcspec->username) != 0) in smb_sm_lookupint()
143 if (vcp->vc_uid != vcspec->owner) in smb_sm_lookupint()
148 if (vcp->vc_grp != vcspec->group) in smb_sm_lookupint()
154 vcp->vc_mode) in smb_sm_lookupint()
157 if (smb_vc_access(vcp, scred, vcspec->mode) != 0) in smb_sm_lookupint()
161 error = (int)smb_vc_lookupshare(vcp, shspec, scred, in smb_sm_lookupint()
171 smb_vc_unlock(vcp); in smb_sm_lookupint()
173 if (vcp) { in smb_sm_lookupint()
174 smb_vc_ref(vcp); in smb_sm_lookupint()
175 *vcpp = vcp; in smb_sm_lookupint()
184 struct smb_vc *vcp; in smb_sm_lookup() local
188 *vcpp = vcp = NULL; in smb_sm_lookup()
198 error = smb_sm_lookupint(vcspec, NULL, scred, &vcp); in smb_sm_lookup()
200 error = smb_vc_create(vcspec, scred, &vcp); in smb_sm_lookup()
203 error = smb_vc_connect(vcp, scred); in smb_sm_lookup()
209 error = smb_share_create(vcp, shspec, scred, &ssp); in smb_sm_lookup()
220 *vcpp = vcp; in smb_sm_lookup()
221 else if (vcp) { in smb_sm_lookup()
222 smb_vc_lock(vcp); in smb_sm_lookup()
223 smb_vc_put(vcp, scred); in smb_sm_lookup()
391 struct smb_vc *vcp; in smb_vc_create() local
408 vcp = smb_zmalloc(sizeof(*vcp), M_SMBCONN, M_WAITOK); in smb_vc_create()
409 smb_co_init(VCTOCP(vcp), SMBL_VC, "smb_vc ilock", "smb_vc"); in smb_vc_create()
410 vcp->obj.co_free = smb_vc_free; in smb_vc_create()
411 vcp->obj.co_gone = smb_vc_gone; in smb_vc_create()
412 vcp->vc_number = smb_vcnext++; in smb_vc_create()
413 vcp->vc_timo = SMB_DEFRQTIMO; in smb_vc_create()
414 vcp->vc_smbuid = SMB_UID_UNKNOWN; in smb_vc_create()
415 vcp->vc_mode = vcspec->rights & SMBM_MASK; in smb_vc_create()
416 vcp->obj.co_flags = vcspec->flags & (SMBV_PRIVATE | SMBV_SINGLESHARE); in smb_vc_create()
417 vcp->vc_tdesc = &smb_tran_nbtcp_desc; in smb_vc_create()
418 vcp->vc_seqno = 0; in smb_vc_create()
419 vcp->vc_mackey = NULL; in smb_vc_create()
420 vcp->vc_mackeylen = 0; in smb_vc_create()
426 vcp->vc_uid = uid; in smb_vc_create()
427 vcp->vc_grp = gid; in smb_vc_create()
429 smb_sl_init(&vcp->vc_stlock, "vcstlock"); in smb_vc_create()
432 vcp->vc_paddr = sodupsockaddr(vcspec->sap, M_WAITOK); in smb_vc_create()
433 if (vcp->vc_paddr == NULL) in smb_vc_create()
435 vcp->vc_laddr = sodupsockaddr(vcspec->lap, M_WAITOK); in smb_vc_create()
436 if (vcp->vc_laddr == NULL) in smb_vc_create()
438 vcp->vc_pass = smb_strdup(vcspec->pass); in smb_vc_create()
439 if (vcp->vc_pass == NULL) in smb_vc_create()
441 vcp->vc_domain = smb_strdup((domain && domain[0]) ? domain : in smb_vc_create()
443 if (vcp->vc_domain == NULL) in smb_vc_create()
445 vcp->vc_srvname = smb_strdup(vcspec->srvname); in smb_vc_create()
446 if (vcp->vc_srvname == NULL) in smb_vc_create()
448 vcp->vc_username = smb_strdup(vcspec->username); in smb_vc_create()
449 if (vcp->vc_username == NULL) in smb_vc_create()
451 error = (int)iconv_open("tolower", vcspec->localcs, &vcp->vc_tolower); in smb_vc_create()
454 error = (int)iconv_open("toupper", vcspec->localcs, &vcp->vc_toupper); in smb_vc_create()
459 &vcp->vc_cp_toserver); in smb_vc_create()
463 &vcp->vc_cp_tolocal); in smb_vc_create()
466 vcp->vc_toserver = vcp->vc_cp_toserver; in smb_vc_create()
467 vcp->vc_tolocal = vcp->vc_cp_tolocal; in smb_vc_create()
471 &vcp->vc_ucs_toserver); in smb_vc_create()
474 &vcp->vc_ucs_tolocal); in smb_vc_create()
477 if (vcp->vc_ucs_toserver) in smb_vc_create()
478 iconv_close(vcp->vc_ucs_toserver); in smb_vc_create()
479 vcp->vc_ucs_toserver = NULL; in smb_vc_create()
480 vcp->vc_ucs_tolocal = NULL; in smb_vc_create()
483 error = (int)smb_iod_create(vcp); in smb_vc_create()
486 *vcpp = vcp; in smb_vc_create()
487 smb_co_addchild(&smb_vclist, VCTOCP(vcp)); in smb_vc_create()
491 smb_vc_put(vcp, scred); in smb_vc_create()
498 struct smb_vc *vcp = CPTOVC(cp); in smb_vc_free() local
500 if (vcp->vc_iod) in smb_vc_free()
501 smb_iod_destroy(vcp->vc_iod); in smb_vc_free()
502 SMB_STRFREE(vcp->vc_username); in smb_vc_free()
503 SMB_STRFREE(vcp->vc_srvname); in smb_vc_free()
504 SMB_STRFREE(vcp->vc_pass); in smb_vc_free()
505 SMB_STRFREE(vcp->vc_domain); in smb_vc_free()
506 if (vcp->vc_mackey) in smb_vc_free()
507 free(vcp->vc_mackey, M_SMBTEMP); in smb_vc_free()
508 if (vcp->vc_paddr) in smb_vc_free()
509 free(vcp->vc_paddr, M_SONAME); in smb_vc_free()
510 if (vcp->vc_laddr) in smb_vc_free()
511 free(vcp->vc_laddr, M_SONAME); in smb_vc_free()
512 if (vcp->vc_tolower) in smb_vc_free()
513 iconv_close(vcp->vc_tolower); in smb_vc_free()
514 if (vcp->vc_toupper) in smb_vc_free()
515 iconv_close(vcp->vc_toupper); in smb_vc_free()
516 if (vcp->vc_tolocal) in smb_vc_free()
517 vcp->vc_tolocal = NULL; in smb_vc_free()
518 if (vcp->vc_toserver) in smb_vc_free()
519 vcp->vc_toserver = NULL; in smb_vc_free()
520 if (vcp->vc_cp_tolocal) in smb_vc_free()
521 iconv_close(vcp->vc_cp_tolocal); in smb_vc_free()
522 if (vcp->vc_cp_toserver) in smb_vc_free()
523 iconv_close(vcp->vc_cp_toserver); in smb_vc_free()
524 if (vcp->vc_ucs_tolocal) in smb_vc_free()
525 iconv_close(vcp->vc_ucs_tolocal); in smb_vc_free()
526 if (vcp->vc_ucs_toserver) in smb_vc_free()
527 iconv_close(vcp->vc_ucs_toserver); in smb_vc_free()
528 smb_co_done(VCTOCP(vcp)); in smb_vc_free()
529 smb_sl_destroy(&vcp->vc_stlock); in smb_vc_free()
530 free(vcp, M_SMBCONN); in smb_vc_free()
539 struct smb_vc *vcp = CPTOVC(cp); in smb_vc_gone() local
541 smb_vc_disconnect(vcp); in smb_vc_gone()
545 smb_vc_ref(struct smb_vc *vcp) in smb_vc_ref() argument
547 smb_co_ref(VCTOCP(vcp)); in smb_vc_ref()
551 smb_vc_rele(struct smb_vc *vcp, struct smb_cred *scred) in smb_vc_rele() argument
553 smb_co_rele(VCTOCP(vcp), scred); in smb_vc_rele()
557 smb_vc_get(struct smb_vc *vcp, struct smb_cred *scred) in smb_vc_get() argument
562 cp = VCTOCP(vcp); in smb_vc_get()
570 smb_vc_put(struct smb_vc *vcp, struct smb_cred *scred) in smb_vc_put() argument
572 smb_co_put(VCTOCP(vcp), scred); in smb_vc_put()
576 smb_vc_lock(struct smb_vc *vcp) in smb_vc_lock() argument
581 cp = VCTOCP(vcp); in smb_vc_lock()
589 smb_vc_unlock(struct smb_vc *vcp) in smb_vc_unlock() argument
594 cp = VCTOCP(vcp); in smb_vc_unlock()
601 smb_vc_access(struct smb_vc *vcp, struct smb_cred *scred, mode_t mode) in smb_vc_access() argument
605 if (smb_suser(cred) == 0 || cred->cr_uid == vcp->vc_uid) in smb_vc_access()
608 if (!groupmember(vcp->vc_grp, cred)) in smb_vc_access()
610 return (vcp->vc_mode & mode) == mode ? 0 : EACCES; in smb_vc_access()
646 smb_vc_lookupshare(struct smb_vc *vcp, struct smb_sharespec *dp, in smb_vc_lookupshare() argument
655 SMBCO_FOREACH(scp, VCTOCP(vcp)) { in smb_vc_lookupshare()
674 smb_vc_connect(struct smb_vc *vcp, struct smb_cred *scred) in smb_vc_connect() argument
677 return smb_iod_request(vcp->vc_iod, SMBIOD_EV_CONNECT | SMBIOD_EV_SYNC, NULL); in smb_vc_connect()
685 smb_vc_disconnect(struct smb_vc *vcp) in smb_vc_disconnect() argument
688 if (vcp->vc_iod != NULL) in smb_vc_disconnect()
689 smb_iod_request(vcp->vc_iod, SMBIOD_EV_DISCONNECT | in smb_vc_disconnect()
697 smb_vc_getpass(struct smb_vc *vcp) in smb_vc_getpass() argument
699 if (vcp->vc_pass) in smb_vc_getpass()
700 return vcp->vc_pass; in smb_vc_getpass()
705 smb_vc_getinfo(struct smb_vc *vcp, struct smb_vc_info *vip) in smb_vc_getinfo() argument
709 vip->usecount = vcp->obj.co_usecount; in smb_vc_getinfo()
710 vip->uid = vcp->vc_uid; in smb_vc_getinfo()
711 vip->gid = vcp->vc_grp; in smb_vc_getinfo()
712 vip->mode = vcp->vc_mode; in smb_vc_getinfo()
713 vip->flags = vcp->obj.co_flags; in smb_vc_getinfo()
714 vip->sopt = vcp->vc_sopt; in smb_vc_getinfo()
715 vip->iodstate = vcp->vc_iod->iod_state; in smb_vc_getinfo()
717 snprintf(vip->srvname, sizeof(vip->srvname), "%s", vcp->vc_srvname); in smb_vc_getinfo()
718 snprintf(vip->vcname, sizeof(vip->vcname), "%s", vcp->vc_username); in smb_vc_getinfo()
723 smb_vc_nextmid(struct smb_vc *vcp) in smb_vc_nextmid() argument
727 sx_xlock(&vcp->obj.co_interlock); in smb_vc_nextmid()
728 r = vcp->vc_mid++; in smb_vc_nextmid()
729 sx_unlock(&vcp->obj.co_interlock); in smb_vc_nextmid()
742 smb_share_create(struct smb_vc *vcp, struct smb_sharespec *shspec, in smb_share_create() argument
760 error = smb_vc_lookupshare(vcp, shspec, scred, &ssp); in smb_share_create()
782 smb_co_addchild(VCTOCP(vcp), SSTOCP(ssp)); in smb_share_create()
891 struct smb_vc *vcp; in smb_share_getpass() local
895 vcp = SSTOVC(ssp); in smb_share_getpass()
896 if (vcp->vc_pass) in smb_share_getpass()
897 return vcp->vc_pass; in smb_share_getpass()
924 struct smb_vc *vcp; in smb_sysctl_treedump() local
937 vcp = (struct smb_vc *)scp1; in smb_sysctl_treedump()
938 error = smb_vc_lock(vcp); in smb_sysctl_treedump()
941 smb_vc_getinfo(vcp, &vci); in smb_sysctl_treedump()
944 smb_vc_unlock(vcp); in smb_sysctl_treedump()
947 SMBCO_FOREACH(scp2, VCTOCP(vcp)) { in smb_sysctl_treedump()
960 smb_vc_unlock(vcp); in smb_sysctl_treedump()