Deleted Added
sdiff udiff text old ( 46112 ) new ( 83366 )
full compact
1/*
2 * Copyright (c) 1994, 1995 Scott Bartram
3 * Copyright (c) 1994 Arne H Juul
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 7 unchanged lines hidden (view full) ---

16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 * $FreeBSD: head/sys/i386/ibcs2/ibcs2_socksys.c 83366 2001-09-12 08:38:13Z julian $
26 */
27
28#include <sys/param.h>
29#include <sys/systm.h>
30#include <sys/sysproto.h>
31#include <sys/kernel.h>
32#include <sys/sysctl.h>
33

--- 7 unchanged lines hidden (view full) ---

41};
42
43struct setipdomainname_args {
44 char *ipdomainname;
45 int len;
46};
47
48/* Local prototypes */
49static int ibcs2_getipdomainname __P((struct thread *,
50 struct getipdomainname_args *));
51static int ibcs2_setipdomainname __P((struct thread *,
52 struct setipdomainname_args *));
53
54/*
55 * iBCS2 socksys calls.
56 */
57
58int
59ibcs2_socksys(td, uap)
60 register struct thread *td;
61 register struct ibcs2_socksys_args *uap;
62{
63 int error;
64 int realargs[7]; /* 1 for command, 6 for recvfrom */
65 void *passargs;
66
67 /*
68 * SOCKET should only be legal on /dev/socksys.

--- 5 unchanged lines hidden (view full) ---

74 return error;
75 DPRINTF(("ibcs2_socksys: %08x %08x %08x %08x %08x %08x %08x\n",
76 realargs[0], realargs[1], realargs[2], realargs[3],
77 realargs[4], realargs[5], realargs[6]));
78
79 passargs = (void *)(realargs + 1);
80 switch (realargs[0]) {
81 case SOCKSYS_ACCEPT:
82 return accept(td, passargs);
83 case SOCKSYS_BIND:
84 return bind(td, passargs);
85 case SOCKSYS_CONNECT:
86 return connect(td, passargs);
87 case SOCKSYS_GETPEERNAME:
88 return getpeername(td, passargs);
89 case SOCKSYS_GETSOCKNAME:
90 return getsockname(td, passargs);
91 case SOCKSYS_GETSOCKOPT:
92 return getsockopt(td, passargs);
93 case SOCKSYS_LISTEN:
94 return listen(td, passargs);
95 case SOCKSYS_RECV:
96 realargs[5] = realargs[6] = 0;
97 /* FALLTHROUGH */
98 case SOCKSYS_RECVFROM:
99 return recvfrom(td, passargs);
100 case SOCKSYS_SEND:
101 realargs[5] = realargs[6] = 0;
102 /* FALLTHROUGH */
103 case SOCKSYS_SENDTO:
104 return sendto(td, passargs);
105 case SOCKSYS_SETSOCKOPT:
106 return setsockopt(td, passargs);
107 case SOCKSYS_SHUTDOWN:
108 return shutdown(td, passargs);
109 case SOCKSYS_SOCKET:
110 return socket(td, passargs);
111 case SOCKSYS_SELECT:
112 return select(td, passargs);
113 case SOCKSYS_GETIPDOMAIN:
114 return ibcs2_getipdomainname(td, passargs);
115 case SOCKSYS_SETIPDOMAIN:
116 return ibcs2_setipdomainname(td, passargs);
117 case SOCKSYS_ADJTIME:
118 return adjtime(td, passargs);
119 case SOCKSYS_SETREUID:
120 return setreuid(td, passargs);
121 case SOCKSYS_SETREGID:
122 return setregid(td, passargs);
123 case SOCKSYS_GETTIME:
124 return gettimeofday(td, passargs);
125 case SOCKSYS_SETTIME:
126 return settimeofday(td, passargs);
127 case SOCKSYS_GETITIMER:
128 return getitimer(td, passargs);
129 case SOCKSYS_SETITIMER:
130 return setitimer(td, passargs);
131
132 default:
133 printf("socksys unknown %08x %08x %08x %08x %08x %08x %08x\n",
134 realargs[0], realargs[1], realargs[2], realargs[3],
135 realargs[4], realargs[5], realargs[6]);
136 return EINVAL;
137 }
138 /* NOTREACHED */
139}
140
141/* ARGSUSED */
142static int
143ibcs2_getipdomainname(td, uap)
144 struct thread *td;
145 struct getipdomainname_args *uap;
146{
147 char hname[MAXHOSTNAMELEN], *dptr;
148 int len;
149
150 /* Get the domain name */
151 snprintf(hname, sizeof(hname), "%s", hostname);
152 dptr = index(hname, '.');

--- 6 unchanged lines hidden (view full) ---

159 len = strlen(dptr) + 1;
160 if ((u_int)uap->len > len + 1)
161 uap->len = len + 1;
162 return (copyout((caddr_t)dptr, (caddr_t)uap->ipdomainname, uap->len));
163}
164
165/* ARGSUSED */
166static int
167ibcs2_setipdomainname(td, uap)
168 struct thread *td;
169 struct setipdomainname_args *uap;
170{
171 char hname[MAXHOSTNAMELEN], *ptr;
172 int error, sctl[2], hlen;
173
174 if ((error = suser_td(td)))
175 return (error);
176
177 /* W/out a hostname a domain-name is nonsense */
178 if ( strlen(hostname) == 0 )
179 return EINVAL;
180
181 /* Get the host's unqualified name (strip off the domain) */
182 snprintf(hname, sizeof(hname), "%s", hostname);

--- 14 unchanged lines hidden (view full) ---

197 error = copyin((caddr_t)uap->ipdomainname, ptr, uap->len);
198 if (error)
199 return (error);
200
201 /* 'sethostname' with the new information */
202 sctl[0] = CTL_KERN;
203 sctl[1] = KERN_HOSTNAME;
204 hlen = strlen(hname) + 1;
205 return (kernel_sysctl(td, sctl, 2, 0, 0, hname, hlen, 0));
206}