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/chips/nw.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  * Mach Operating System
    3  * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
    4  * All Rights Reserved.
    5  * 
    6  * Permission to use, copy, modify and distribute this software and its
    7  * documentation is hereby granted, provided that both the copyright
    8  * notice and this permission notice appear in all copies of the
    9  * software, derivative works or modified versions, and any portions
   10  * thereof, and that both notices appear in supporting documentation.
   11  * 
   12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
   14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   15  * 
   16  * Carnegie Mellon requests users of this software to return to
   17  * 
   18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   19  *  School of Computer Science
   20  *  Carnegie Mellon University
   21  *  Pittsburgh PA 15213-3890
   22  * 
   23  * any improvements or extensions that they make and grant Carnegie Mellon
   24  * the rights to redistribute these changes.
   25  */
   26 /*
   27  * HISTORY
   28  * $Log:        nw.h,v $
   29  * Revision 2.2  93/08/10  15:18:39  mrt
   30  *      Initial check-in.
   31  *      [93/06/09  15:54:51  jcb]
   32  * 
   33  *
   34  */
   35 
   36 #ifndef _NW_H_
   37 #define _NW_H_ 1
   38 
   39 #if defined(KMODE) || defined(KERNEL)
   40 #include <sys/types.h> 
   41 #include <mach/port.h> 
   42 #else
   43 #include "stub0.h"
   44 #endif
   45 
   46 /*** NETWORK APPLICATION PROGRAMMING INTERFACE ***/
   47 
   48 /*** TYPES ***/
   49 
   50 typedef enum {
   51   NW_SUCCESS,
   52   NW_FAILURE,
   53   NW_BAD_ADDRESS,
   54   NW_OVERRUN,
   55   NW_NO_CARRIER,
   56   NW_NOT_SERVER,
   57   NW_NO_EP,
   58   NW_BAD_EP,
   59   NW_INVALID_ARGUMENT,
   60   NW_NO_RESOURCES,
   61   NW_PROT_VIOLATION,
   62   NW_BAD_BUFFER,
   63   NW_BAD_LENGTH,
   64   NW_NO_REMOTE_EP,
   65   NW_TIME_OUT,
   66   NW_INCONSISTENCY,
   67   NW_ABORTED,
   68   NW_SYNCH,
   69   NW_QUEUED
   70 } nw_result, *nw_result_t;
   71 
   72 typedef enum {
   73   NW_INITIALIZE,
   74   NW_HOST_ADDRESS_REGISTER,
   75   NW_HOST_ADDRESS_UNREGISTER
   76 } nw_update_type;
   77 
   78 typedef enum {
   79   NW_STATUS,
   80   NW_HOST_ADDRESS_LOOKUP
   81 } nw_lookup_type;
   82 
   83 typedef u_int ip_address;
   84 
   85 typedef u_int nw_address_1;
   86 typedef u_int nw_address_2;
   87 
   88 typedef struct {
   89   char name[20];          /*Host name -- first 19 characters, zero-terminated*/
   90   ip_address ip_addr;
   91   nw_address_1 nw_addr_1; /*4 most significant bits specify the device*/
   92   nw_address_2 nw_addr_2;
   93 } nw_address_s, *nw_address_t;
   94 
   95 typedef enum {
   96   NW_NULL,
   97   NW_IP,                 /*Virtual network for IP addresses*/
   98   NW_TCA100_1,           /*Fore Systems ATM network, first unit*/
   99   NW_TCA100_2            /*Fore Systems ATM network, second unit*/
  100 } nw_device, *nw_device_t;
  101 
  102 #define NW_DEVICE(addr) (addr >> 28)
  103 
  104 typedef u_int nw_ep, *nw_ep_t;
  105 
  106 typedef enum {
  107   NW_RAW,                      /*Raw service provided by network*/
  108   NW_DATAGRAM,                 /*Connectionless service*/
  109   NW_SEQ_PACKET,               /*Connection-oriented service*/
  110   NW_LINE                      /*Multiplexing line (system use only)*/
  111 } nw_protocol;
  112 
  113 typedef enum {
  114   NW_NO_ACCEPT,                /*Connection requests not accepted (client)*/
  115   NW_APPL_ACCEPT,              /*Connection requests received as message by
  116                                  application (msg_seqno 0), for examination
  117                                  and approval (nw_connection_accept function)*/
  118   NW_AUTO_ACCEPT,              /*Connection requests automatically accepted
  119                                  if endpoint is connection-oriented and
  120                                  not already connected*/
  121   NW_LINE_ACCEPT               /*Connection requests automatically accepted
  122                                  on a new endpoint (system use only)*/
  123 } nw_acceptance;
  124 
  125 typedef struct {
  126   nw_address_1 rem_addr_1;
  127   nw_address_2 rem_addr_2;
  128   nw_ep remote_ep:16;
  129   nw_ep local_ep:16;
  130 } nw_peer_s, *nw_peer_t;
  131 
  132 typedef struct nw_buffer {
  133   u_int buf_used:1;               /*Read-only for applications (always 1)*/
  134   u_int buf_length:31;            /*Read-only for applications*/
  135   struct nw_buffer *buf_next;     /*Used only to gather on sends*/
  136   u_int msg_seqno:10;             /*Sequential number of message,
  137                                     automatically set by network interface*/
  138   u_int block_offset:22;          /*Offset to the beginning of data (in bytes),
  139                                     from the start of the buffer*/
  140   u_int block_deallocate:1;       /*Used only to deallocate on sends*/
  141   u_int block_length:31;          /*Length of data (in bytes)
  142                                     beginning at offset*/
  143   nw_peer_s peer;                 /*Set on receives. Also required
  144                                     in first block on datagram sends.
  145                                     Ignored on sequenced packet sends.*/
  146 } nw_buffer_s, *nw_buffer_t;
  147 
  148 
  149 /* msg_seqno is normally between 1 and 1023, and increases modulo 1024
  150    (skipping 0) between consecutive messages. In sequenced packets, msg_seqno
  151    increases strictly by one. msg_seqno is assigned automatically.
  152    The network interface writes in the buffer the msg_seqno used,
  153    but only after the  buffer has been transmitted and, in case of 
  154    sequenced packet, acknowledged. The application can use this update
  155    to determine if a buffer can be reused, after a sending a message without
  156    the deallocate option.
  157    msg_seqno 0 is used when the corresponding send specifies the NW_URGENT 
  158    option. Such messages bypass any other messages possibly enqueued.
  159    msg_seqno 0 is also used for open connection requests, in the case
  160    of sequenced packet endpoints with the NW_APPL_ACCEPT option.
  161    The type of msg_seqno 0 message is differentiated by the first word in the
  162    message, which has type nw_options */
  163 
  164 #define NW_BUFFER_ERROR ((nw_buffer_t) -1)      /*Used for error indication
  165                                                   other than buffer overrun
  166                                                   (for which NULL is used)*/
  167 
  168 typedef enum {
  169   NW_INEXISTENT,
  170   NW_UNCONNECTED,
  171   NW_SIMPLEX_ORIGINATING,
  172   NW_SIMPLEX_ORIGINATED,
  173   NW_DUPLEX_ORIGINATING,
  174   NW_DUPLEX_ORIGINATING_2,
  175   NW_DUPLEX_ORIGINATED,
  176   NW_ORIGINATOR_CLOSING,
  177   NW_ORIGINATOR_RCLOSING,
  178   NW_ACCEPTING,
  179   NW_SIMPLEX_ACCEPTED,
  180   NW_DUPLEX_ACCEPTING,
  181   NW_DUPLEX_ACCEPTED,
  182   NW_ACCEPTOR_CLOSING,
  183   NW_ACCEPTOR_RCLOSING
  184 } nw_state, *nw_state_t;
  185 
  186 
  187 typedef enum nw_options {
  188   NW_NORMAL,
  189   NW_URGENT,
  190   NW_SYNCHRONIZATION                              /*System use only*/
  191 } nw_options;
  192 
  193 
  194 /*** FUNCTIONS ***/
  195 
  196 extern nw_result nw_update(mach_port_t master_port, nw_update_type up_type,
  197                            int *up_info);
  198 
  199 /*****************************************************************************
  200      Allows privileged applications to update network tables. The 
  201      application must present the device master port. up_type selects the
  202      type of update, and up_info is cast accordingly to the correct type.
  203 
  204      For NW_HOST_ADDRESS_REGISTER and NW_HOST_ADDRESS_UNREGISTER,
  205      up_info has type nw_address_t. For NW_HOST_ADDRESS_UNREGISTER,
  206      however, only the network address field is used.
  207 
  208      up_info is not used for NW_INITIALIZE. This option is used to 
  209      initialize network interface tables, but does not initialize
  210      devices. Initialization of hardware and network tables occurs
  211      automatically at probe/boot time, so this option is normally
  212      unnecessary.
  213 
  214      Returns NW_SUCCESS if operation completed successfully.
  215              NW_FAILURE if master port not presented.
  216              NW_NO_RESOURCES if network tables full (NW_HOST_ADDRESS_REGISTER).
  217              NW_BAD_ADDRESS if host not found (NW_HOST_ADDRESS_UNREGISTER).
  218              NW_INVALID_ARGUMENT if up_type is invalid or up_info is
  219                                  a bad pointer.
  220  *****************************************************************************/
  221 
  222 
  223 extern nw_result nw_lookup(nw_lookup_type lt, int *look_info);
  224 
  225 /*****************************************************************************
  226      Allows applications to lookup network tables. The type of 
  227      lookup is selected by lt, and look_info is cast to the correct type
  228      accordingly.
  229 
  230      For lt equal to NW_HOST_ADDRESS_LOOKUP, look_info has type
  231      nw_address_t. In this option, the host is looked up first using the
  232      IP address  as a key (if non-zero), then by name (if non-empty), 
  233      and finally by network address (if non-zero). The function
  234      returns NW_SUCCESS on the first match it finds, and sets the non-key
  235      fields of look_info to the values found. No consistency check is
  236      made if more than one key is supplied. The function returns
  237      NW_BAD_ADDRESS if the host was not found, and NW_INVALID_ARGUMENT
  238      if lt is invalid or look_info is a bad pointer.
  239 
  240      For lt equal to NW_STATUS, look_info has type nw_device_t on input
  241      and nw_result_t on output. The function returns NW_INVALID_ARGUMENT
  242      if the device chosen is invalid or look_info is a bad pointer;
  243      otherwise, the function returns NW_SUCCESS. look_info is
  244      set to: NW_FAILURE if the device is not present, NW_NOT_SERVER
  245      if the device is not serviced by this interface, or a
  246      device-dependent value otherwise (NW_SUCCESS if there is no device error).
  247 
  248  *****************************************************************************/
  249 
  250 
  251 extern nw_result nw_endpoint_allocate(nw_ep_t epp, nw_protocol protocol,
  252                                       nw_acceptance accept, u_int buffer_size);
  253 
  254 /*****************************************************************************
  255      Allocates a communication endpoint. On input, epp should point to the
  256      the endpoint number desired, or to 0 if any number is adequate.
  257      On output, epp points to the actual number allocated for the endpoint.
  258      protocol specifies the transport discipline applied to data transmitted
  259      or received through the endpoint. accept selects how open connection
  260      requests received for the endpoint should be handled (connection-oriented
  261      protocol), or whether the endpoint can receive messages (connectionless
  262      protocol). buffer_size specifies the length in bytes of the buffer area
  263      for data sent or received through the endpoint. 
  264 
  265      Returns NW_SUCCESS if endpoint successfully allocated.
  266              NW_INVALID_ARGUMENT if epp is a bad pointer or the
  267                                  protocol or accept arguments are invalid.
  268              NW_NO_EP if the endpoint name space is exhausted.
  269              NW_BAD_EP if there already is an endpoint with the
  270                        number selected, or the number selected is
  271                        out of bounds.
  272              NW_NO_RESOURCES if not enough memory for buffer.
  273  *****************************************************************************/
  274             
  275 
  276 extern nw_result nw_endpoint_deallocate(nw_ep ep);
  277 
  278 /*****************************************************************************
  279       Deallocates the given endpoint.
  280 
  281       Returns NW_SUCCESS if successfully deallocated endpoint.
  282               NW_BAD_EP if endpoint does not exist.
  283               NW_PROT_VIOLATION if access to endpoint not authorized.
  284  *****************************************************************************/
  285 
  286 
  287 extern nw_buffer_t nw_buffer_allocate(nw_ep ep, u_int size);
  288 
  289 /*****************************************************************************
  290       Allocates a buffer of the given size (in bytes) from the buffer area
  291       of the given endpoint.
  292 
  293       Returns NW_BUFFER_ERROR if endpoint does not exist or access to endpoint
  294                               is not authorized.
  295               NULL if no buffer with given size could be allocated.
  296               Pointer to allocated buffer, otherwise.
  297  *****************************************************************************/
  298 
  299 
  300 extern nw_result nw_buffer_deallocate(nw_ep ep, nw_buffer_t buffer);
  301 
  302 /*****************************************************************************
  303       Deallocates the given buffer.
  304 
  305       Returns NW_SUCCESS if successfully deallocated buffer.
  306               NW_BAD_EP if endpoint does not exist.
  307               NW_PROT_VIOLATION if access to endpoint not authorized.
  308               NW_BAD_BUFFER if buffer does not belong to endpoint's
  309                             buffer area or is malformed.
  310  *****************************************************************************/
  311 
  312 
  313 extern nw_result nw_connection_open(nw_ep local_ep, nw_address_1 rem_addr_1,
  314                                     nw_address_2 rem_addr_2, nw_ep remote_ep);
  315 
  316 /*****************************************************************************
  317       Opens a connection.
  318 
  319       Returns NW_SUCCESS if connection successfully opened.
  320               NW_BAD_EP if local endpoint does not exist, uses connectionless
  321                         protocol or is already connected.
  322               NW_PROT_VIOLATION if access to local or remote endpoint
  323                                 not authorized.
  324               NW_BAD_ADDRESS if address of remote host is invalid.
  325               NW_NO_REMOTE_EP if connection name space exhausted at
  326                               remote host.
  327               NW_TIME_OUT if attempt to open connection timed out repeatedly.
  328               NW_FAILURE if remote endpoint does not exist, uses connectionless
  329                          protocol or is already connected, or if remote
  330                          application did not accept open request.
  331  *****************************************************************************/
  332 
  333 
  334 extern nw_result nw_connection_accept(nw_ep ep, nw_buffer_t msg,
  335                                       nw_ep_t new_epp);
  336 
  337 /*****************************************************************************
  338       Accepts open request (at the remote host). On input, new_epp equal to
  339       NULL indicates that the application does not accept the request.
  340       new_epp pointing to the value 0 indicates that the application wants
  341       to accept the connection on a new endpoint, created dynamically,
  342       with the same attributes as the original endpoint; new_epp pointing
  343       to the value ep indicates that the application wants to simply
  344       accept the open request. On output, new_epp points to the endpoint
  345       actually connected, if any. msg points to the open request, which is
  346       automatically deallocated. 
  347 
  348       Returns NW_SUCCESS if connection correctly accepted or refused.
  349               NW_BAD_EP if endpoint does not exist or has no outstanding
  350                          open request.
  351               NW_PROT_VIOLATION if access to endpoint not authorized.
  352               NW_BAD_BUFFER if msg does not belong to the endpoint's
  353                             buffer area, or is malformed.
  354               NW_INVALID_ARGUMENT if new_epp is a bad pointer or points to
  355                                   invalid value.
  356               NW_NO_EP if endpoint name space exhausted.
  357               NW_NO_RESOURCES if no buffer available for new endpoint.
  358               NW_TIME_OUT if attempt to accept at different endpoint
  359                            repeatedly timed out.
  360  *****************************************************************************/
  361 
  362 
  363 extern nw_result nw_connection_close(nw_ep ep);
  364 
  365 /*****************************************************************************
  366       Closes the endpoint's connection.
  367 
  368       Returns NW_SUCCESS if successfully closed connection.
  369               NW_BAD_EP if endpoint does not exist or is not connected.
  370               NW_PROT_VIOLATION if access to endpoint not authorized.
  371  *****************************************************************************/
  372 
  373 
  374 extern nw_result nw_multicast_add(nw_ep local_ep, nw_address_1 rem_addr_1,
  375                                   nw_address_2 rem_addr_2, nw_ep remote_ep);
  376 
  377 /*****************************************************************************
  378       Open multicast group or add one more member to multicast group.
  379 
  380       Returns NW_SUCCESS if successfully opened multicast group
  381                          or added member.
  382               NW_BAD_EP if local endpoint does not exist, uses connectionless
  383                         protocol or is already connected point-to-point.
  384               NW_PROT_VIOLATION if access to local or remote endpoint
  385                                 not authorized.
  386               NW_BAD_ADDRESS if address of remote host is invalid.
  387               NW_NO_REMOTE_EP if connection name space exhausted at
  388                               remote host.
  389               NW_TIME_OUT if attempt to open or add to multicast
  390                           timed out repeatedly.
  391               NW_FAILURE if remote endpoint does not exist, uses connectionless
  392                          protocol or is already connected, or if remote
  393                          application did not accept open or add request.
  394  *****************************************************************************/
  395 
  396 
  397 extern nw_result nw_multicast_drop(nw_ep local_ep, nw_address_1 rem_addr_1,
  398                                    nw_address_2 rem_addr_2, nw_ep remote_ep);
  399 
  400 /*****************************************************************************
  401       Drop member from multicast group, or close group if last member.
  402 
  403       Returns NW_SUCCESS if successfully dropped member or closed group.
  404               NW_BAD_EP if local endpoint does not exist or is not connected in
  405                         multicast to the given remote endpoint.
  406               NW_PROT_VIOLATION if access to local endpoint not authorized.
  407  *****************************************************************************/
  408 
  409 
  410 extern nw_result nw_endpoint_status(nw_ep ep, nw_state_t state,
  411                                     nw_peer_t peer);
  412 
  413 /*****************************************************************************
  414       Returns the state of the given endpoint and peer to which it is 
  415       connected, if any. In case of multicast group, the first peer is
  416       returned.
  417 
  418       Returns NW_SUCCESS if status correctly returned.
  419               NW_BAD_EP if endpoint does not exist.
  420               NW_PROT_VIOLATION if access to endpoint not authorized.
  421               NW_INVALID_ARGUMENT if state or peer is a bad pointer.
  422  *****************************************************************************/
  423 
  424 
  425 extern nw_result nw_send(nw_ep ep, nw_buffer_t msg, nw_options options);
  426 
  427 /*****************************************************************************
  428       Sends message through endpoint with the given options.
  429       
  430       Returns NW_SUCCESS if message successfully queued for sending
  431                          (connectionless protocol) or sent and acknowledged
  432                          (connection-oriented protocol).
  433               NW_BAD_EP if endpoint does not exist or uses connection-oriented
  434                         protocol but is unconnected.
  435               NW_PROT_VIOLATION if access to endpoint not authorized.
  436               NW_BAD_BUFFER if msg (or one of the buffers linked by buf_next)
  437                             is not a buffer in the endpoint's buffer area, or
  438                             is malformed (e.g., block_length extends beyond
  439                             end of buffer).
  440               NW_NO_RESOURCES if unable to queue message due to resource
  441                               exhaustion.
  442               NW_BAD_LENGTH if the total message length is too long for the
  443                             network and protocol used.
  444               NW_BAD_ADDRESS if address of remote host is invalid
  445                              (connectionless protocol).
  446               NW_FAILURE if repeated errors in message transmission
  447                          (connection-oriented).
  448               NW_TIME_OUT if repeated time-outs in message transmission
  449                           (connection-oriented).
  450               NW_OVERRUN if no buffer available in receiver's buffer area.
  451                          (connection-oriented).
  452  *****************************************************************************/
  453 
  454 
  455 extern nw_buffer_t nw_receive(nw_ep ep, int time_out);
  456 
  457 /*****************************************************************************
  458       Receive message destined to endpoint. Return if request  not
  459       satisfied within time_out msec. time_out 0 means non-blocking receive,
  460       while -1 means block indefinitely.
  461 
  462       Returns NW_BUFFER_ERROR if endpoint does not exist or access
  463                               to endpoint is not authorized.
  464               NULL if no message available for reception within the
  465                    specified time-out period.
  466               Pointer to message, otherwise.
  467  *****************************************************************************/
  468 
  469 
  470 extern nw_buffer_t nw_rpc(nw_ep ep, nw_buffer_t send_msg, nw_options options,
  471                           int time_out);
  472 
  473 /*****************************************************************************
  474       Send message through given endpoint with given options and then
  475       receive message through the same endpoint. Receive waiting time
  476       is limited to time_out msec.
  477 
  478       Returns NW_BUFFER_ERROR if endpoint does not exist, access to
  479                               endpoint is not authorized, or there was
  480                               some transmission error.
  481               NULL if no message available for reception within the
  482                    specified time-out period.
  483               Pointer to message received, otherwise.
  484  *****************************************************************************/
  485 
  486 
  487 extern nw_buffer_t nw_select(u_int nep, nw_ep_t epp, int time_out);
  488 
  489 /*****************************************************************************
  490       Receive message from one of the nep endpoints in the array epp.
  491       Waiting time is limited to time_out msec.
  492 
  493       Returns NW_BUFFER_ERROR if epp does not point to a valid array of nep
  494                               endpoint numbers, one of the endpoints does
  495                               not exist or has restricted access or the request
  496                               could not be correctly queued because of resource
  497                               exhaustion.
  498               NULL if no message arrived within the specified time-out period.
  499               Pointer to message received, otherwise.
  500  *****************************************************************************/
  501 
  502 
  503 #endif /* _NW_H_ */

Cache object: e59cee4c1a080d4bf7b362b1fa812aad


[ 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.