* Copyright (c) 1988 University of Utah.
* Copyright (c) 1990 The Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* from: Utah $Hdr: hpux_net.c 1.33 89/08/23$
* @(#)hpux_net.c 7.7 (Berkeley) 2/13/91
* Network related HP-UX compatibility routines
#include "sys/socketvar.h"
#define MINBSDIPCCODE 0x3EE
* HPUX netioctl() to BSD syscall map.
* Indexed by callno - MINBSDIPCCODE
extern int socket(), listen(), bind(), oaccept(), connect(), orecv();
extern int osend(), shutdown(), ogetsockname(), sendto();
extern int orecvfrom(), ogetpeername();
int hpuxgetsockopt(), hpuxsetsockopt();
} hpuxtobsdipc
[NUMBSDIPC
] = {
socket
, 3, /* 3ee */ listen
, 2, /* 3ef */
bind
, 3, /* 3f0 */ oaccept
, 3, /* 3f1 */
connect
, 3, /* 3f2 */ orecv
, 4, /* 3f3 */
osend
, 4, /* 3f4 */ shutdown
, 2, /* 3f5 */
ogetsockname
, 3, /* 3f6 */ hpuxsetsockopt
, 5, /* 3f7 */
sendto
, 6, /* 3f8 */ orecvfrom
, 6, /* 3f9 */
ogetpeername
, 3, /* 3fa */ NULL
, 0, /* 3fb */
NULL
, 0, /* 3fc */ NULL
, 0, /* 3fd */
NULL
, 0, /* 3fe */ NULL
, 0, /* 3ff */
NULL
, 0, /* 400 */ NULL
, 0, /* 401 */
NULL
, 0, /* 402 */ NULL
, 0, /* 403 */
NULL
, 0, /* 404 */ NULL
, 0, /* 405 */
NULL
, 0, /* 406 */ NULL
, 0, /* 407 */
NULL
, 0, /* 408 */ NULL
, 0, /* 409 */
NULL
, 0, /* 40a */ hpuxgetsockopt
, 5, /* 40b */
NULL
, 0, /* 40c */ NULL
, 0, /* 40d */
* Single system call entry to BSD style IPC.
* Gleened from disassembled libbsdipc.a syscall entries.
hpuxnetioctl(p
, uap
, retval
)
code
= uap
->call
- MINBSDIPCCODE
;
if (code
< 0 || code
>= NUMBSDIPC
|| hpuxtobsdipc
[code
].rout
== NULL
)
if ((i
= hpuxtobsdipc
[code
].nargs
* sizeof (int)) &&
(error
= copyin((caddr_t
)args
, (caddr_t
)uap
, (u_int
)i
))) {
if (KTRPOINT(p
, KTR_SYSCALL
))
ktrsyscall(p
->p_tracep
, code
+ MINBSDIPCCODE
,
hpuxtobsdipc
[code
].nargs
);
if (KTRPOINT(p
, KTR_SYSCALL
))
ktrsyscall(p
->p_tracep
, code
+ MINBSDIPCCODE
,
hpuxtobsdipc
[code
].nargs
);
return ((*hpuxtobsdipc
[code
].rout
)(p
, uap
, retval
));
hpuxsetsockopt(p
, uap
, retval
)
if (error
= getsock(p
->p_fd
, uap
->s
, &fp
))
m
= m_get(M_WAIT
, MT_SOOPTS
);
if (error
= copyin(uap
->val
, mtod(m
, caddr_t
),
if (uap
->name
== SO_LINGER
) {
mtod(m
, struct linger
*)->l_onoff
= 1;
mtod(m
, struct linger
*)->l_linger
= tmp
;
m
->m_len
= sizeof(struct linger
);
} else if (uap
->name
== ~SO_LINGER
) {
m
= m_get(M_WAIT
, MT_SOOPTS
);
mtod(m
, struct linger
*)->l_onoff
= 0;
m
->m_len
= sizeof(struct linger
);
return (sosetopt((struct socket
*)fp
->f_data
, uap
->level
,
hpuxgetsockopt(p
, uap
, retval
)
if (error
= getsock(p
->p_fd
, uap
->s
, &fp
))
if (error
= copyin((caddr_t
)uap
->avalsize
, (caddr_t
)&valsize
,
if (error
= sogetopt((struct socket
*)fp
->f_data
, uap
->level
,
if (uap
->val
&& valsize
&& m
!= NULL
) {
if (uap
->name
== SO_LINGER
) {
if (mtod(m
, struct linger
*)->l_onoff
)
*mtod(m
, int *) = mtod(m
, struct linger
*)->l_linger
;
error
= copyout(mtod(m
, caddr_t
), uap
->val
, (u_int
)valsize
);
error
= copyout((caddr_t
)&valsize
,
(caddr_t
)uap
->avalsize
, sizeof (valsize
));