The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/netncp/ncp_conn.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1999 Boris Popov
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  *
   26  * $FreeBSD: releng/9.2/sys/netncp/ncp_conn.h 206361 2010-04-07 16:50:38Z joel $
   27  */
   28 #ifndef _NETNCP_NCP_CONN_H_
   29 #define _NETNCP_NCP_CONN_H_
   30 
   31 #ifndef _NETINET_IN_H_
   32 #include <netinet/in.h>
   33 #endif
   34 
   35 #ifndef _NETIPX_IPX_H_
   36 #include <netipx/ipx.h>
   37 #endif
   38 
   39 #ifndef _SYS_SOCKET_H_
   40 #include <sys/socket.h>
   41 #endif
   42 
   43 /* type of transport we use */
   44 /*#define       NCP_ON_IPX      0
   45 #define NCP_ON_TCP      1*/
   46 
   47 /* flags field in conn structure */
   48 #define NCPFL_SOCONN            0x0001  /* socket layer is up */
   49 #define NCPFL_ATTACHED          0x0002  /* ncp layer is up */
   50 #define NCPFL_LOGGED            0x0004  /* logged in to server */
   51 #define NCPFL_INVALID           0x0008  /* last request was not completed */
   52 #define NCPFL_INTR              0x0010  /* interrupted call */
   53 #define NCPFL_RESTORING         0x0020  /* trying to reconnect */
   54 #define NCPFL_PERMANENT         0x0040  /* no way to kill conn, when this set */
   55 #define NCPFL_PRIMARY           0x0080  /* have meaning only for owner */
   56 #define NCPFL_WASATTACHED       0x0100  /* there was at least one successfull connect */
   57 #define NCPFL_WASLOGGED         0x0200  /* there was at least one successfull login */
   58 #define NCPFL_SIGNACTIVE        0x1000  /* packet signing active */
   59 #define NCPFL_SIGNWANTED        0x2000  /* signing should start */
   60 
   61 /* access mode for connection */
   62 #define NCPM_READ               0400    /* able to fetch conn params */
   63 #define NCPM_WRITE              0200    /* modify/close */
   64 #define NCPM_EXECUTE            0100    /* run requests */
   65 
   66 #define NCP_DEFAULT_OWNER       ((uid_t)-1)
   67 #define NCP_DEFAULT_GROUP       ((uid_t)-1)
   68 
   69 
   70 /* args used to create connection */
   71 #define ncp_conn_loginfo        ncp_conn_args
   72 struct ncp_conn_args {
   73         int             opt;
   74 #define NCP_OPT_WDOG            1       /* need watch dog socket */
   75 #define NCP_OPT_MSG             2       /* need message socket */
   76 #define NCP_OPT_SIGN            4       /* signatures wanted */
   77 #define NCP_OPT_BIND            8       /* force bindery login */
   78 #define NCP_OPT_PERMANENT       0x10    /* only for refernce, completly ignored */
   79 #define NCP_OPT_NOUPCASEPASS    0x20    /* leave password as is */
   80         int             sig_level;      /* wanted signature level */
   81         char            server[NCP_BINDERY_NAME_LEN+1];
   82         char            *user;
   83         char            *password;
   84         u_int32_t       objtype;
   85         union {
   86                 struct sockaddr addr;
   87                 struct sockaddr_ipx ipxaddr;
   88                 struct sockaddr_in inaddr;
   89         } addr;
   90         int             timeout;        /* ncp rq timeout */
   91         int             retry_count;    /* counts to give an error */
   92         uid_t           owner;          /* proposed owner of connection */
   93         gid_t           group;          /* proposed group of connection */
   94         mode_t          access_mode;    /* R/W - can do rq's, X - can see the conn */
   95 };
   96 
   97 #define ipxaddr         addr.ipxaddr
   98 #define inaddr          addr.inaddr
   99 #define saddr           addr.addr
  100 
  101 /* user side structure to issue ncp calls */
  102 struct ncp_buf {
  103         int     rqsize;                 /* request size without ncp header */
  104         int     rpsize;                 /* reply size minus ncp header */
  105         int     cc;                     /* completion code */
  106         int     cs;                     /* connection state */
  107         char    packet[NCP_MAX_PACKET_SIZE];/* Here we prepare requests and receive replies */
  108 };
  109 
  110 /*
  111  * Connection status, returned via sysctl(vfs.nwfs.connstat)
  112  */
  113 struct ncp_conn_stat {
  114         struct ncp_conn_args li;
  115         int             connRef;
  116         int             ref_cnt;
  117         int             connid;
  118         int             buffer_size;
  119         int             flags;
  120         int             sign_active;
  121         uid_t           owner;
  122         gid_t           group;
  123         char            user[NCP_MAXUSERNAMELEN+1];
  124 };
  125 
  126 #ifdef _KERNEL
  127 
  128 #ifndef LK_SHARED
  129 #include <sys/lock.h>
  130 #include <sys/lockmgr.h>
  131 #endif
  132 
  133 struct socket;
  134 struct u_cred;
  135 
  136 SLIST_HEAD(ncp_conn_head,ncp_conn);
  137 
  138 struct ncp_rq;
  139 struct ncp_conn;
  140 
  141 /*
  142  * External and internal processes can reference connection only by handle.
  143  * This gives us a freedom in maintance of underlying connections.
  144  */
  145 struct ncp_handle {
  146         SLIST_ENTRY(ncp_handle) nh_next;
  147         int             nh_id;          /* handle id */
  148         struct ncp_conn*nh_conn;        /* which conn we are refernce */
  149         struct thread * nh_td;          /* who owns the handle  */
  150         int             nh_ref;         /* one process can asquire many handles, but we return the one */
  151 };
  152 
  153 /* 
  154  * Describes any connection to server 
  155  */
  156 struct ncp_conn {
  157         SLIST_ENTRY(ncp_conn) nc_next;
  158         struct ncp_conn_args li;
  159         struct ucred    *nc_owner;
  160         gid_t           nc_group;
  161         int             flags;
  162         int             nc_id;
  163         struct socket   *ncp_so;
  164         struct socket   *wdg_so;
  165         struct socket   *msg_so;
  166         struct socket   *bc_so;
  167         int             ref_cnt;                /* how many handles leased */
  168         SLIST_HEAD(ncp_ref_hd,ncp_ref) ref_list;/* list of handles */
  169         struct lock     nc_lock;                /* excl locks */
  170         int             nc_lwant;               /* number of wanted locks */
  171         struct thread   *td;                    /* pid currently operates */
  172         struct ucred    *ucred;                 /* usr currently operates */
  173         /* Fields used to process ncp requests */
  174         int             connid;                 /* assigned by server */
  175         u_int8_t        seq;
  176         int             buffer_size;            /* Negotiated bufsize */
  177         /* Fields used to make packet signatures */
  178         u_int32_t       sign_root[2];
  179         u_int32_t       sign_state[4];          /* md4 state */
  180 #ifdef NCPBURST
  181         /* Fields used for packet bursting */
  182         u_long          bc_pktseq;              /* raw packet sequence */
  183         u_short         bc_seq;                 /* burst sequence */
  184         u_long          bc_locid;               /* local connection id */
  185         u_long          bc_remid;               /* remote connection id */
  186         u_long          bc_pktsize;             /* negotiated burst packet size */
  187 #endif
  188 };
  189 
  190 int  ncp_conn_init(void);
  191 int  ncp_conn_destroy(void);
  192 int  ncp_conn_alloc(struct ncp_conn_args *cap,
  193         struct thread *td, struct ucred *cred, struct ncp_conn **connid);
  194 int  ncp_conn_free(struct ncp_conn *conn);
  195 int  ncp_conn_access(struct ncp_conn *conn,struct ucred *cred,mode_t mode);
  196 int  ncp_conn_lock(struct ncp_conn *conn,struct thread *td, struct ucred *cred,int mode);
  197 void ncp_conn_unlock(struct ncp_conn *conn,struct thread *td);
  198 int  ncp_conn_assert_locked(struct ncp_conn *conn,const char *checker,struct thread *td);
  199 void ncp_conn_invalidate(struct ncp_conn *ncp);
  200 int  ncp_conn_invalid(struct ncp_conn *ncp);
  201 /*int  ncp_conn_ref(struct ncp_conn *conn, pid_t pid);
  202 int  ncp_conn_rm_ref(struct ncp_conn *conn, pid_t pid, int force);
  203 void ncp_conn_list_rm_ref(pid_t pid);*/
  204 int  ncp_conn_getbyref(int connRef,struct thread *td, struct ucred *cred, int mode,
  205         struct ncp_conn **connpp);
  206 int  ncp_conn_getbyli(struct ncp_conn_loginfo *li,struct thread *td, struct ucred *cred, 
  207         int mode, struct ncp_conn **connpp);
  208 int  ncp_conn_setprimary(struct ncp_conn *conn, int on);
  209 int  ncp_conn_locklist(int flags, struct thread *td);
  210 void ncp_conn_unlocklist(struct thread *td);
  211 int  ncp_conn_gethandle(struct ncp_conn *conn, struct thread *td, struct ncp_handle **handle);
  212 int  ncp_conn_puthandle(struct ncp_handle *handle, struct thread *td, int force);
  213 int  ncp_conn_findhandle(int connHandle, struct thread *td, struct ncp_handle **handle);
  214 int  ncp_conn_getattached(struct ncp_conn_args *li,struct thread *td, struct ucred *cred,int mode, struct ncp_conn **connpp);
  215 int  ncp_conn_putprochandles(struct thread *td);
  216 int  ncp_conn_getinfo(struct ncp_conn *ncp, struct ncp_conn_stat *ncs);
  217 
  218 int  ncp_conn_reconnect(struct ncp_conn *ncp);
  219 int  ncp_conn_login(struct ncp_conn *conn, struct thread *td, struct ucred *cred);
  220 
  221 extern struct ncp_conn_head conn_list;
  222 extern int ncp_burst_enabled;
  223 
  224 #ifdef MALLOC_DECLARE
  225 MALLOC_DECLARE(M_NCPDATA);
  226 #endif
  227 
  228 #endif /* _KERNEL */
  229 #endif /* _NCP_CONN_H_ */

Cache object: 532eb7507afe046f889e287379e3a661


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.