First cut at patches to make appletalk compile again

after the dissapearance of the USRREQ() entrypoint.
This commit is contained in:
Julian Elischer 1997-05-13 21:01:45 +00:00
parent 36abea5dc5
commit f3b44df01d
5 changed files with 392 additions and 236 deletions

View File

@ -43,7 +43,8 @@ static int at_ifinit( struct ifnet *ifp, struct at_ifaddr *aa,
(a)->sat_addr.s_node == (b)->sat_addr.s_node )
int
at_control( int cmd, caddr_t data, struct ifnet *ifp, struct proc *p )
at_control(struct socket *so, int cmd, caddr_t data,
struct ifnet *ifp, struct proc *p )
{
struct ifreq *ifr = (struct ifreq *)data;
struct sockaddr_at *sat;

View File

@ -14,15 +14,12 @@ extern void aarptfree __P((struct aarptab *));
#endif
extern void aarp_clean __P((void));
extern int at_control __P(( int cmd,
extern int at_control __P(( struct socket *so,
int cmd,
caddr_t data,
struct ifnet *ifp,
struct proc *p ));
extern u_short at_cksum __P(( struct mbuf *m, int skip));
extern int ddp_usrreq __P(( struct socket *so, int req,
struct mbuf *m,
struct mbuf *addr,
struct mbuf *rights));
extern void ddp_init __P((void ));
extern struct ifaddr *at_ifawithnet __P((struct sockaddr_at *,
struct ifaddrhead *));

View File

@ -55,8 +55,8 @@ struct protosw atalksw[] = {
* they be included in the kernel.
*/
0, ddp_output, 0, 0,
/* socket-protocol interface. */
ddp_usrreq,
/* socket-protocol interface. deprecated */
NULL,
/* utility routines. */
ddp_init, 0, 0, 0,
},

View File

@ -36,152 +36,187 @@ struct ddpcb *ddpcb = NULL;
u_long ddp_sendspace = DDP_MAXSZ; /* Max ddp size + 1 (ddp_type) */
u_long ddp_recvspace = 10 * ( 587 + sizeof( struct sockaddr_at ));
/*ARGSUSED*/
int
ddp_usrreq( struct socket *so, int req, struct mbuf *m,
struct mbuf *addr, struct mbuf *rights)
static int
ddp_attach(struct socket *so, int proto, struct proc *p)
{
struct proc *p = curproc; /* XXX */
struct ddpcb *ddp;
int error = 0;
struct ddpcb *ddp;
int error = 0;
int s;
ddp = sotoddpcb( so );
if ( req == PRU_CONTROL ) {
return( at_control( (int) m, (caddr_t) addr,
(struct ifnet *) rights, (struct proc *)p ));
}
if ( rights && rights->m_len ) {
error = EINVAL;
goto release;
}
if ( ddp == NULL && req != PRU_ATTACH ) {
error = EINVAL;
goto release;
}
switch ( req ) {
case PRU_ATTACH :
ddp = sotoddpcb( so );
if ( ddp != NULL ) {
error = EINVAL;
break;
return( EINVAL);
}
if (( error = at_pcballoc( so )) != 0 ) {
break;
}
error = soreserve( so, ddp_sendspace, ddp_recvspace );
break;
case PRU_DETACH :
s = splnet();
error = at_pcballoc( so );
splx(s);
if (error) {
return (error);
}
return (soreserve( so, ddp_sendspace, ddp_recvspace ));
}
static int
ddp_detach(struct socket *so)
{
struct ddpcb *ddp;
int error = 0;
int s;
ddp = sotoddpcb( so );
if ( ddp == NULL ) {
return( EINVAL);
}
s = splnet();
at_pcbdetach( so, ddp );
break;
splx(s);
return(0);
}
case PRU_BIND :
error = at_pcbsetaddr( ddp, addr, p );
break;
static int
ddp_bind(struct socket *so, struct mbuf *nam, struct proc *p)
{
struct ddpcb *ddp;
int error = 0;
int s;
ddp = sotoddpcb( so );
if ( ddp == NULL ) {
return( EINVAL);
}
s = splnet();
error = at_pcbsetaddr( ddp, nam, p );
splx(s);
return (error);
}
case PRU_SOCKADDR :
at_sockaddr( ddp, addr );
break;
case PRU_CONNECT:
if ( ddp->ddp_fsat.sat_port != ATADDR_ANYPORT ) {
error = EISCONN;
break;
static int
ddp_connect(struct socket *so, struct mbuf *nam, struct proc *p)
{
struct ddpcb *ddp;
int error = 0;
int s;
ddp = sotoddpcb( so );
if ( ddp == NULL ) {
return( EINVAL);
}
error = at_pcbconnect( ddp, addr, p );
if ( ddp->ddp_fsat.sat_port != ATADDR_ANYPORT ) {
return(EISCONN);
}
s = splnet();
error = at_pcbconnect( ddp, nam, p );
splx(s);
if ( error == 0 )
soisconnected( so );
break;
return(error);
}
case PRU_DISCONNECT:
if ( ddp->ddp_fsat.sat_addr.s_node == ATADDR_ANYNODE ) {
error = ENOTCONN;
break;
static int
ddp_disconnect(struct socket *so)
{
struct ddpcb *ddp;
int error = 0;
int s;
ddp = sotoddpcb( so );
if ( ddp == NULL ) {
return( EINVAL);
}
if ( ddp->ddp_fsat.sat_addr.s_node == ATADDR_ANYNODE ) {
return(ENOTCONN);
}
s = splnet();
at_pcbdisconnect( ddp );
ddp->ddp_fsat.sat_addr.s_node = ATADDR_ANYNODE;
splx(s);
soisdisconnected( so );
break;
return(0);
}
case PRU_SHUTDOWN:
static int
ddp_shutdown(struct socket *so)
{
struct ddpcb *ddp;
int error = 0;
int s;
ddp = sotoddpcb( so );
if ( ddp == NULL ) {
return( EINVAL);
}
socantsendmore( so );
break;
return(0);
}
case PRU_SEND: {
int s = 0;
static int
ddp_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *addr,
struct mbuf *control, struct proc *p)
{
struct ddpcb *ddp;
int error = 0;
int s;
ddp = sotoddpcb( so );
if ( ddp == NULL ) {
return(EINVAL);
}
if ( control && control->m_len ) {
return(EINVAL);
}
if ( addr ) {
if ( ddp->ddp_fsat.sat_port != ATADDR_ANYPORT ) {
error = EISCONN;
break;
}
if ( ddp->ddp_fsat.sat_port != ATADDR_ANYPORT ) {
return(EISCONN);
}
s = splnet();
error = at_pcbconnect( ddp, addr, p );
if ( error ) {
s = splnet();
error = at_pcbconnect( ddp, addr, p );
splx( s );
break;
}
if ( error ) {
return(error);
}
} else {
if ( ddp->ddp_fsat.sat_port == ATADDR_ANYPORT ) {
error = ENOTCONN;
break;
}
if ( ddp->ddp_fsat.sat_port == ATADDR_ANYPORT ) {
return(ENOTCONN);
}
}
s = splnet();
error = ddp_output( m, so );
m = NULL;
if ( addr ) {
at_pcbdisconnect( ddp );
splx( s );
}
}
break;
case PRU_ABORT:
soisdisconnected( so );
at_pcbdetach( so, ddp );
break;
case PRU_LISTEN:
case PRU_CONNECT2:
case PRU_ACCEPT:
case PRU_SENDOOB:
case PRU_FASTTIMO:
case PRU_SLOWTIMO:
case PRU_PROTORCV:
case PRU_PROTOSEND:
error = EOPNOTSUPP;
break;
case PRU_RCVD:
case PRU_RCVOOB:
/*
* Don't mfree. Good architecture...
*/
return( EOPNOTSUPP );
case PRU_SENSE:
/*
* 1. Don't return block size.
* 2. Don't mfree.
*/
return( 0 );
default:
error = EOPNOTSUPP;
}
release:
if ( m != NULL ) {
m_freem( m );
}
return( error );
splx(s);
return(error);
}
static int
ddp_abort(struct socket *so)
{
struct ddpcb *ddp;
int s;
ddp = sotoddpcb( so );
if ( ddp == NULL ) {
return(EINVAL);
}
soisdisconnected( so );
s = splnet();
at_pcbdetach( so, ddp );
splx(s);
return(0);
}
static void
at_sockaddr( struct ddpcb *ddp, struct mbuf *addr)
{
@ -505,6 +540,27 @@ ddp_search( struct sockaddr_at *from, struct sockaddr_at *to,
}
return( ddp );
}
static int
at_setpeeraddr(struct socket *so, struct mbuf *nam)
{
return(EOPNOTSUPP);
}
static int
at_setsockaddr(struct socket *so, struct mbuf *nam)
{
struct ddpcb *ddp;
int error = 0;
int s;
ddp = sotoddpcb( so );
if ( ddp == NULL ) {
return( EINVAL);
}
at_sockaddr( ddp, nam );
return(0);
}
void
ddp_init(void )
@ -524,3 +580,26 @@ ddp_clean(void )
}
}
#endif
struct pr_usrreqs ddp_usrreqs = {
ddp_abort,
pru_accept_notsupp,
ddp_attach,
ddp_bind,
ddp_connect,
pru_connect2_notsupp,
at_control,
ddp_detach,
ddp_disconnect,
pru_listen_notsupp,
at_setpeeraddr,
pru_rcvd_notsupp,
pru_rcvoob_notsupp,
ddp_send,
pru_sense_null,
ddp_shutdown,
at_setsockaddr,
sosend,
soreceive,
soselect
};

View File

@ -36,152 +36,187 @@ struct ddpcb *ddpcb = NULL;
u_long ddp_sendspace = DDP_MAXSZ; /* Max ddp size + 1 (ddp_type) */
u_long ddp_recvspace = 10 * ( 587 + sizeof( struct sockaddr_at ));
/*ARGSUSED*/
int
ddp_usrreq( struct socket *so, int req, struct mbuf *m,
struct mbuf *addr, struct mbuf *rights)
static int
ddp_attach(struct socket *so, int proto, struct proc *p)
{
struct proc *p = curproc; /* XXX */
struct ddpcb *ddp;
int error = 0;
struct ddpcb *ddp;
int error = 0;
int s;
ddp = sotoddpcb( so );
if ( req == PRU_CONTROL ) {
return( at_control( (int) m, (caddr_t) addr,
(struct ifnet *) rights, (struct proc *)p ));
}
if ( rights && rights->m_len ) {
error = EINVAL;
goto release;
}
if ( ddp == NULL && req != PRU_ATTACH ) {
error = EINVAL;
goto release;
}
switch ( req ) {
case PRU_ATTACH :
ddp = sotoddpcb( so );
if ( ddp != NULL ) {
error = EINVAL;
break;
return( EINVAL);
}
if (( error = at_pcballoc( so )) != 0 ) {
break;
}
error = soreserve( so, ddp_sendspace, ddp_recvspace );
break;
case PRU_DETACH :
s = splnet();
error = at_pcballoc( so );
splx(s);
if (error) {
return (error);
}
return (soreserve( so, ddp_sendspace, ddp_recvspace ));
}
static int
ddp_detach(struct socket *so)
{
struct ddpcb *ddp;
int error = 0;
int s;
ddp = sotoddpcb( so );
if ( ddp == NULL ) {
return( EINVAL);
}
s = splnet();
at_pcbdetach( so, ddp );
break;
splx(s);
return(0);
}
case PRU_BIND :
error = at_pcbsetaddr( ddp, addr, p );
break;
static int
ddp_bind(struct socket *so, struct mbuf *nam, struct proc *p)
{
struct ddpcb *ddp;
int error = 0;
int s;
ddp = sotoddpcb( so );
if ( ddp == NULL ) {
return( EINVAL);
}
s = splnet();
error = at_pcbsetaddr( ddp, nam, p );
splx(s);
return (error);
}
case PRU_SOCKADDR :
at_sockaddr( ddp, addr );
break;
case PRU_CONNECT:
if ( ddp->ddp_fsat.sat_port != ATADDR_ANYPORT ) {
error = EISCONN;
break;
static int
ddp_connect(struct socket *so, struct mbuf *nam, struct proc *p)
{
struct ddpcb *ddp;
int error = 0;
int s;
ddp = sotoddpcb( so );
if ( ddp == NULL ) {
return( EINVAL);
}
error = at_pcbconnect( ddp, addr, p );
if ( ddp->ddp_fsat.sat_port != ATADDR_ANYPORT ) {
return(EISCONN);
}
s = splnet();
error = at_pcbconnect( ddp, nam, p );
splx(s);
if ( error == 0 )
soisconnected( so );
break;
return(error);
}
case PRU_DISCONNECT:
if ( ddp->ddp_fsat.sat_addr.s_node == ATADDR_ANYNODE ) {
error = ENOTCONN;
break;
static int
ddp_disconnect(struct socket *so)
{
struct ddpcb *ddp;
int error = 0;
int s;
ddp = sotoddpcb( so );
if ( ddp == NULL ) {
return( EINVAL);
}
if ( ddp->ddp_fsat.sat_addr.s_node == ATADDR_ANYNODE ) {
return(ENOTCONN);
}
s = splnet();
at_pcbdisconnect( ddp );
ddp->ddp_fsat.sat_addr.s_node = ATADDR_ANYNODE;
splx(s);
soisdisconnected( so );
break;
return(0);
}
case PRU_SHUTDOWN:
static int
ddp_shutdown(struct socket *so)
{
struct ddpcb *ddp;
int error = 0;
int s;
ddp = sotoddpcb( so );
if ( ddp == NULL ) {
return( EINVAL);
}
socantsendmore( so );
break;
return(0);
}
case PRU_SEND: {
int s = 0;
static int
ddp_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *addr,
struct mbuf *control, struct proc *p)
{
struct ddpcb *ddp;
int error = 0;
int s;
ddp = sotoddpcb( so );
if ( ddp == NULL ) {
return(EINVAL);
}
if ( control && control->m_len ) {
return(EINVAL);
}
if ( addr ) {
if ( ddp->ddp_fsat.sat_port != ATADDR_ANYPORT ) {
error = EISCONN;
break;
}
if ( ddp->ddp_fsat.sat_port != ATADDR_ANYPORT ) {
return(EISCONN);
}
s = splnet();
error = at_pcbconnect( ddp, addr, p );
if ( error ) {
s = splnet();
error = at_pcbconnect( ddp, addr, p );
splx( s );
break;
}
if ( error ) {
return(error);
}
} else {
if ( ddp->ddp_fsat.sat_port == ATADDR_ANYPORT ) {
error = ENOTCONN;
break;
}
if ( ddp->ddp_fsat.sat_port == ATADDR_ANYPORT ) {
return(ENOTCONN);
}
}
s = splnet();
error = ddp_output( m, so );
m = NULL;
if ( addr ) {
at_pcbdisconnect( ddp );
splx( s );
}
}
break;
case PRU_ABORT:
soisdisconnected( so );
at_pcbdetach( so, ddp );
break;
case PRU_LISTEN:
case PRU_CONNECT2:
case PRU_ACCEPT:
case PRU_SENDOOB:
case PRU_FASTTIMO:
case PRU_SLOWTIMO:
case PRU_PROTORCV:
case PRU_PROTOSEND:
error = EOPNOTSUPP;
break;
case PRU_RCVD:
case PRU_RCVOOB:
/*
* Don't mfree. Good architecture...
*/
return( EOPNOTSUPP );
case PRU_SENSE:
/*
* 1. Don't return block size.
* 2. Don't mfree.
*/
return( 0 );
default:
error = EOPNOTSUPP;
}
release:
if ( m != NULL ) {
m_freem( m );
}
return( error );
splx(s);
return(error);
}
static int
ddp_abort(struct socket *so)
{
struct ddpcb *ddp;
int s;
ddp = sotoddpcb( so );
if ( ddp == NULL ) {
return(EINVAL);
}
soisdisconnected( so );
s = splnet();
at_pcbdetach( so, ddp );
splx(s);
return(0);
}
static void
at_sockaddr( struct ddpcb *ddp, struct mbuf *addr)
{
@ -505,6 +540,27 @@ ddp_search( struct sockaddr_at *from, struct sockaddr_at *to,
}
return( ddp );
}
static int
at_setpeeraddr(struct socket *so, struct mbuf *nam)
{
return(EOPNOTSUPP);
}
static int
at_setsockaddr(struct socket *so, struct mbuf *nam)
{
struct ddpcb *ddp;
int error = 0;
int s;
ddp = sotoddpcb( so );
if ( ddp == NULL ) {
return( EINVAL);
}
at_sockaddr( ddp, nam );
return(0);
}
void
ddp_init(void )
@ -524,3 +580,26 @@ ddp_clean(void )
}
}
#endif
struct pr_usrreqs ddp_usrreqs = {
ddp_abort,
pru_accept_notsupp,
ddp_attach,
ddp_bind,
ddp_connect,
pru_connect2_notsupp,
at_control,
ddp_detach,
ddp_disconnect,
pru_listen_notsupp,
at_setpeeraddr,
pru_rcvd_notsupp,
pru_rcvoob_notsupp,
ddp_send,
pru_sense_null,
ddp_shutdown,
at_setsockaddr,
sosend,
soreceive,
soselect
};