2005-01-07 01:45:51 +00:00
|
|
|
/*-
|
1998-09-15 08:23:17 +00:00
|
|
|
*
|
|
|
|
* ===================================
|
|
|
|
* HARP | Host ATM Research Platform
|
|
|
|
* ===================================
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This Host ATM Research Platform ("HARP") file (the "Software") is
|
|
|
|
* made available by Network Computing Services, Inc. ("NetworkCS")
|
|
|
|
* "AS IS". NetworkCS does not provide maintenance, improvements or
|
|
|
|
* support of any kind.
|
|
|
|
*
|
|
|
|
* NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
|
|
|
|
* INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
|
|
* AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
|
|
|
|
* SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
|
|
|
|
* In no event shall NetworkCS be responsible for any damages, including
|
|
|
|
* but not limited to consequential damages, arising from or relating to
|
|
|
|
* any use of the Software or related support.
|
|
|
|
*
|
|
|
|
* Copyright 1994-1998 Network Computing Services, Inc.
|
|
|
|
*
|
|
|
|
* Copies of this Software may be made, however, the above copyright
|
|
|
|
* notice must be reproduced on all copies.
|
|
|
|
*
|
1999-08-28 01:08:13 +00:00
|
|
|
* @(#) $FreeBSD$
|
1998-09-15 08:23:17 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Core ATM Services
|
|
|
|
* -----------------
|
|
|
|
*
|
|
|
|
* ATM system variables
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NETATM_ATM_VAR_H
|
|
|
|
#define _NETATM_ATM_VAR_H
|
|
|
|
|
|
|
|
|
2000-10-12 07:42:34 +00:00
|
|
|
#ifdef _KERNEL
|
2002-04-24 18:06:18 +00:00
|
|
|
|
|
|
|
#include <vm/uma.h>
|
|
|
|
|
2002-05-07 20:36:35 +00:00
|
|
|
typedef void (*atm_init_fn)(void);
|
|
|
|
|
1998-09-15 08:23:17 +00:00
|
|
|
/*
|
|
|
|
* Global variable declarations
|
|
|
|
*/
|
|
|
|
extern struct pr_usrreqs atm_aal5_usrreqs;
|
|
|
|
|
|
|
|
/* atm_proto.c */
|
|
|
|
extern struct domain atmdomain;
|
|
|
|
|
|
|
|
/* atm_subr.c */
|
|
|
|
extern struct atm_pif *atm_interface_head;
|
|
|
|
extern struct atm_ncm *atm_netconv_head;
|
|
|
|
extern Atm_endpoint *atm_endpoints[];
|
|
|
|
extern struct stackq_entry *atm_stackq_head;
|
|
|
|
extern struct stackq_entry *atm_stackq_tail;
|
|
|
|
extern struct atm_sock_stat atm_sock_stat;
|
|
|
|
extern int atm_init;
|
|
|
|
extern int atm_version;
|
|
|
|
extern int atm_debug;
|
|
|
|
extern struct timeval atm_debugtime;
|
|
|
|
extern int atm_dev_print;
|
|
|
|
extern int atm_print_data;
|
2002-04-24 18:06:18 +00:00
|
|
|
extern uma_zone_t atm_attributes_zone;
|
1998-09-15 08:23:17 +00:00
|
|
|
|
|
|
|
extern struct pr_usrreqs atm_dgram_usrreqs;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Global function declarations
|
|
|
|
*/
|
|
|
|
/* atm_aal5.c */
|
2002-03-20 02:39:27 +00:00
|
|
|
int atm_aal5_ctloutput(struct socket *, struct sockopt *);
|
|
|
|
void atm_aal5_init(void);
|
1998-09-15 08:23:17 +00:00
|
|
|
|
|
|
|
/* atm_cm.c */
|
2002-03-20 02:39:27 +00:00
|
|
|
int atm_cm_connect(Atm_endpoint *, void *, Atm_attributes *,
|
|
|
|
Atm_connection **);
|
In the current world order, solisten() implements the state transition of
a socket from a regular socket to a listening socket able to accept new
connections. As part of this state transition, solisten() calls into the
protocol to update protocol-layer state. There were several bugs in this
implementation that could result in a race wherein a TCP SYN received
in the interval between the protocol state transition and the shortly
following socket layer transition would result in a panic in the TCP code,
as the socket would be in the TCPS_LISTEN state, but the socket would not
have the SO_ACCEPTCONN flag set.
This change does the following:
- Pushes the socket state transition from the socket layer solisten() to
to socket "library" routines called from the protocol. This permits
the socket routines to be called while holding the protocol mutexes,
preventing a race exposing the incomplete socket state transition to TCP
after the TCP state transition has completed. The check for a socket
layer state transition is performed by solisten_proto_check(), and the
actual transition is performed by solisten_proto().
- Holds the socket lock for the duration of the socket state test and set,
and over the protocol layer state transition, which is now possible as
the socket lock is acquired by the protocol layer, rather than vice
versa. This prevents additional state related races in the socket
layer.
This permits the dual transition of socket layer and protocol layer state
to occur while holding locks for both layers, making the two changes
atomic with respect to one another. Similar changes are likely require
elsewhere in the socket/protocol code.
Reported by: Peter Holm <peter@holm.cc>
Review and fixes from: emax, Antoine Brodin <antoine.brodin@laposte.net>
Philosophical head nod: gnn
2005-02-21 21:58:17 +00:00
|
|
|
int atm_cm_listen(struct socket *, Atm_endpoint *, void *,
|
2005-10-30 19:44:40 +00:00
|
|
|
Atm_attributes *, Atm_connection **, int);
|
2002-03-20 02:39:27 +00:00
|
|
|
int atm_cm_addllc(Atm_endpoint *, void *, struct attr_llc *,
|
|
|
|
Atm_connection *, Atm_connection **);
|
|
|
|
int atm_cm_addparty(Atm_connection *, int, struct t_atm_sap *);
|
|
|
|
int atm_cm_dropparty(Atm_connection *, int, struct t_atm_cause *);
|
|
|
|
int atm_cm_release(Atm_connection *, struct t_atm_cause *);
|
|
|
|
int atm_cm_abort(Atm_connvc *, struct t_atm_cause *);
|
|
|
|
int atm_cm_incoming(struct vccb *, Atm_attributes *);
|
|
|
|
void atm_cm_connected(Atm_connvc *);
|
|
|
|
void atm_cm_cleared(Atm_connvc *);
|
|
|
|
Atm_connection *atm_cm_match(Atm_attributes *, Atm_connection *);
|
|
|
|
int atm_cm_cpcs_ctl(int, Atm_connection *, void *);
|
|
|
|
int atm_cm_cpcs_data(Atm_connection *, KBuffer *);
|
|
|
|
int atm_cm_saal_ctl(int, Atm_connection *, void *);
|
|
|
|
int atm_cm_saal_data(Atm_connection *, KBuffer *);
|
|
|
|
int atm_cm_sscop_ctl(int, Atm_connection *, void *, void *);
|
|
|
|
int atm_cm_sscop_data(Atm_connection *, KBuffer *);
|
|
|
|
int atm_endpoint_register(Atm_endpoint *);
|
|
|
|
int atm_endpoint_deregister(Atm_endpoint *);
|
1998-09-15 08:23:17 +00:00
|
|
|
|
|
|
|
/* atm_device.c */
|
2002-03-20 02:39:27 +00:00
|
|
|
int atm_dev_inst(struct stack_defn **, Atm_connvc *);
|
2002-11-08 18:27:30 +00:00
|
|
|
void atm_dev_lower(int, void *, intptr_t, intptr_t);
|
2002-03-20 02:39:27 +00:00
|
|
|
void * atm_dev_alloc(u_int, u_int, u_int);
|
|
|
|
void atm_dev_free(volatile void *);
|
|
|
|
KBuffer * atm_dev_compress(KBuffer *);
|
|
|
|
Cmn_vcc * atm_dev_vcc_find(Cmn_unit *, u_int, u_int, u_int);
|
2003-07-24 09:13:03 +00:00
|
|
|
void atm_dev_pdu_print(const Cmn_unit *, const Cmn_vcc *,
|
|
|
|
const KBuffer *, const char *);
|
1998-09-15 08:23:17 +00:00
|
|
|
|
|
|
|
/* atm_if.c */
|
2003-10-31 18:32:15 +00:00
|
|
|
int atm_physif_register(Cmn_unit *, const char *,
|
2002-03-20 02:39:27 +00:00
|
|
|
struct stack_defn *);
|
|
|
|
int atm_physif_deregister(Cmn_unit *);
|
2002-06-14 16:59:38 +00:00
|
|
|
void atm_physif_freenifs(struct atm_pif *, uma_zone_t);
|
2002-03-20 02:39:27 +00:00
|
|
|
int atm_netconv_register(struct atm_ncm *);
|
|
|
|
int atm_netconv_deregister(struct atm_ncm *);
|
|
|
|
int atm_nif_attach(struct atm_nif *);
|
|
|
|
void atm_nif_detach(struct atm_nif *);
|
|
|
|
int atm_nif_setaddr(struct atm_nif *, struct ifaddr *);
|
|
|
|
int atm_ifoutput(struct ifnet *, KBuffer *,
|
|
|
|
struct sockaddr *, struct rtentry *);
|
1998-09-15 08:23:17 +00:00
|
|
|
struct atm_pif *
|
2002-03-20 02:39:27 +00:00
|
|
|
atm_pifname(char *);
|
1998-09-15 08:23:17 +00:00
|
|
|
struct atm_nif *
|
2002-03-20 02:39:27 +00:00
|
|
|
atm_nifname(char *);
|
1998-09-15 08:23:17 +00:00
|
|
|
|
|
|
|
/* atm_proto.c */
|
2002-03-20 02:39:27 +00:00
|
|
|
int atm_proto_notsupp1(struct socket *);
|
|
|
|
int atm_proto_notsupp2(struct socket *, struct sockaddr *,
|
|
|
|
struct thread *);
|
|
|
|
int atm_proto_notsupp3(struct socket *, struct sockaddr **);
|
|
|
|
int atm_proto_notsupp4(struct socket *, int, KBuffer *,
|
|
|
|
struct sockaddr *, KBuffer *, struct thread *);
|
2006-04-01 15:15:05 +00:00
|
|
|
void atm_proto_notsupp5(struct socket *);
|
1998-09-15 08:23:17 +00:00
|
|
|
|
|
|
|
/* atm_signal.c */
|
2002-03-20 02:39:27 +00:00
|
|
|
int atm_sigmgr_register(struct sigmgr *);
|
|
|
|
int atm_sigmgr_deregister(struct sigmgr *);
|
|
|
|
int atm_sigmgr_attach(struct atm_pif *, u_char);
|
|
|
|
int atm_sigmgr_detach(struct atm_pif *);
|
|
|
|
int atm_stack_register(struct stack_defn *);
|
|
|
|
int atm_stack_deregister(struct stack_defn *);
|
|
|
|
int atm_create_stack(Atm_connvc *, struct stack_list *,
|
2002-11-08 18:27:30 +00:00
|
|
|
void (*)(int, void *, intptr_t, intptr_t) );
|
1998-09-15 08:23:17 +00:00
|
|
|
|
|
|
|
/* atm_socket.c */
|
2002-05-07 20:13:55 +00:00
|
|
|
void atm_sock_init(void);
|
2002-03-20 02:39:27 +00:00
|
|
|
int atm_sock_attach(struct socket *, u_long, u_long);
|
Chance protocol switch method pru_detach() so that it returns void
rather than an error. Detaches do not "fail", they other occur or
the protocol flags SS_PROTOREF to take ownership of the socket.
soclose() no longer looks at so_pcb to see if it's NULL, relying
entirely on the protocol to decide whether it's time to free the
socket or not using SS_PROTOREF. so_pcb is now entirely owned and
managed by the protocol code. Likewise, no longer test so_pcb in
other socket functions, such as soreceive(), which have no business
digging into protocol internals.
Protocol detach routines no longer try to free the socket on detach,
this is performed in the socket code if the protocol permits it.
In rts_detach(), no longer test for rp != NULL in detach, and
likewise in other protocols that don't permit a NULL so_pcb, reduce
the incidence of testing for it during detach.
netinet and netinet6 are not fully updated to this change, which
will be in an upcoming commit. In their current state they may leak
memory or panic.
MFC after: 3 months
2006-04-01 15:42:02 +00:00
|
|
|
void atm_sock_detach(struct socket *);
|
2002-03-20 02:39:27 +00:00
|
|
|
int atm_sock_bind(struct socket *, struct sockaddr *);
|
2005-10-30 19:44:40 +00:00
|
|
|
int atm_sock_listen(struct socket *, Atm_endpoint *, int);
|
2002-03-20 02:39:27 +00:00
|
|
|
int atm_sock_connect(struct socket *, struct sockaddr *,
|
|
|
|
Atm_endpoint *);
|
|
|
|
int atm_sock_disconnect(struct socket *);
|
|
|
|
int atm_sock_sockaddr(struct socket *, struct sockaddr **);
|
|
|
|
int atm_sock_peeraddr(struct socket *, struct sockaddr **);
|
|
|
|
int atm_sock_setopt(struct socket *, struct sockopt *,
|
|
|
|
Atm_pcb *);
|
|
|
|
int atm_sock_getopt(struct socket *, struct sockopt *,
|
|
|
|
Atm_pcb *);
|
|
|
|
void atm_sock_connected(void *);
|
|
|
|
void atm_sock_cleared(void *, struct t_atm_cause *);
|
1998-09-15 08:23:17 +00:00
|
|
|
|
|
|
|
/* atm_subr.c */
|
2002-03-20 02:39:27 +00:00
|
|
|
void atm_initialize(void);
|
|
|
|
void atm_timeout(struct atm_time *, int,
|
|
|
|
void (*)(struct atm_time *) );
|
|
|
|
int atm_untimeout(struct atm_time *);
|
2002-11-08 18:27:30 +00:00
|
|
|
int atm_stack_enq(int, void (*)(int, void *, intptr_t, intptr_t),
|
|
|
|
void *, Atm_connvc *, intptr_t, intptr_t);
|
2002-03-20 02:39:27 +00:00
|
|
|
void atm_stack_drain(void);
|
2003-07-24 09:13:03 +00:00
|
|
|
void atm_pdu_print(const KBuffer *, const char *);
|
2003-07-24 10:33:01 +00:00
|
|
|
|
|
|
|
#ifdef SYSCTL_DECL
|
|
|
|
SYSCTL_DECL(_net_harp);
|
|
|
|
SYSCTL_DECL(_net_harp_atm);
|
|
|
|
#endif
|
|
|
|
|
2000-10-12 07:42:34 +00:00
|
|
|
#endif /* _KERNEL */
|
1998-09-15 08:23:17 +00:00
|
|
|
#endif /* _NETATM_ATM_VAR_H */
|