1*2139Sjp161948 /* crypto/bio/bio_dgram.c */
2*2139Sjp161948 /*
3*2139Sjp161948 * DTLS implementation written by Nagendra Modadugu
4*2139Sjp161948 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
5*2139Sjp161948 */
6*2139Sjp161948 /* ====================================================================
7*2139Sjp161948 * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved.
8*2139Sjp161948 *
9*2139Sjp161948 * Redistribution and use in source and binary forms, with or without
10*2139Sjp161948 * modification, are permitted provided that the following conditions
11*2139Sjp161948 * are met:
12*2139Sjp161948 *
13*2139Sjp161948 * 1. Redistributions of source code must retain the above copyright
14*2139Sjp161948 * notice, this list of conditions and the following disclaimer.
15*2139Sjp161948 *
16*2139Sjp161948 * 2. Redistributions in binary form must reproduce the above copyright
17*2139Sjp161948 * notice, this list of conditions and the following disclaimer in
18*2139Sjp161948 * the documentation and/or other materials provided with the
19*2139Sjp161948 * distribution.
20*2139Sjp161948 *
21*2139Sjp161948 * 3. All advertising materials mentioning features or use of this
22*2139Sjp161948 * software must display the following acknowledgment:
23*2139Sjp161948 * "This product includes software developed by the OpenSSL Project
24*2139Sjp161948 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
25*2139Sjp161948 *
26*2139Sjp161948 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27*2139Sjp161948 * endorse or promote products derived from this software without
28*2139Sjp161948 * prior written permission. For written permission, please contact
29*2139Sjp161948 * openssl-core@OpenSSL.org.
30*2139Sjp161948 *
31*2139Sjp161948 * 5. Products derived from this software may not be called "OpenSSL"
32*2139Sjp161948 * nor may "OpenSSL" appear in their names without prior written
33*2139Sjp161948 * permission of the OpenSSL Project.
34*2139Sjp161948 *
35*2139Sjp161948 * 6. Redistributions of any form whatsoever must retain the following
36*2139Sjp161948 * acknowledgment:
37*2139Sjp161948 * "This product includes software developed by the OpenSSL Project
38*2139Sjp161948 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
39*2139Sjp161948 *
40*2139Sjp161948 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41*2139Sjp161948 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42*2139Sjp161948 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43*2139Sjp161948 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44*2139Sjp161948 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45*2139Sjp161948 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46*2139Sjp161948 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47*2139Sjp161948 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48*2139Sjp161948 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49*2139Sjp161948 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50*2139Sjp161948 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51*2139Sjp161948 * OF THE POSSIBILITY OF SUCH DAMAGE.
52*2139Sjp161948 * ====================================================================
53*2139Sjp161948 *
54*2139Sjp161948 * This product includes cryptographic software written by Eric Young
55*2139Sjp161948 * (eay@cryptsoft.com). This product includes software written by Tim
56*2139Sjp161948 * Hudson (tjh@cryptsoft.com).
57*2139Sjp161948 *
58*2139Sjp161948 */
59*2139Sjp161948
60*2139Sjp161948 #ifndef OPENSSL_NO_DGRAM
61*2139Sjp161948
62*2139Sjp161948 #include <stdio.h>
63*2139Sjp161948 #include <errno.h>
64*2139Sjp161948 #define USE_SOCKETS
65*2139Sjp161948 #include "cryptlib.h"
66*2139Sjp161948
67*2139Sjp161948 #include <openssl/bio.h>
68*2139Sjp161948
69*2139Sjp161948 #define IP_MTU 14 /* linux is lame */
70*2139Sjp161948
71*2139Sjp161948 #ifdef WATT32
72*2139Sjp161948 #define sock_write SockWrite /* Watt-32 uses same names */
73*2139Sjp161948 #define sock_read SockRead
74*2139Sjp161948 #define sock_puts SockPuts
75*2139Sjp161948 #endif
76*2139Sjp161948
77*2139Sjp161948 static int dgram_write(BIO *h, const char *buf, int num);
78*2139Sjp161948 static int dgram_read(BIO *h, char *buf, int size);
79*2139Sjp161948 static int dgram_puts(BIO *h, const char *str);
80*2139Sjp161948 static long dgram_ctrl(BIO *h, int cmd, long arg1, void *arg2);
81*2139Sjp161948 static int dgram_new(BIO *h);
82*2139Sjp161948 static int dgram_free(BIO *data);
83*2139Sjp161948 static int dgram_clear(BIO *bio);
84*2139Sjp161948
85*2139Sjp161948 int BIO_dgram_should_retry(int s);
86*2139Sjp161948
87*2139Sjp161948 static BIO_METHOD methods_dgramp=
88*2139Sjp161948 {
89*2139Sjp161948 BIO_TYPE_DGRAM,
90*2139Sjp161948 "datagram socket",
91*2139Sjp161948 dgram_write,
92*2139Sjp161948 dgram_read,
93*2139Sjp161948 dgram_puts,
94*2139Sjp161948 NULL, /* dgram_gets, */
95*2139Sjp161948 dgram_ctrl,
96*2139Sjp161948 dgram_new,
97*2139Sjp161948 dgram_free,
98*2139Sjp161948 NULL,
99*2139Sjp161948 };
100*2139Sjp161948
101*2139Sjp161948 typedef struct bio_dgram_data_st
102*2139Sjp161948 {
103*2139Sjp161948 struct sockaddr peer;
104*2139Sjp161948 unsigned int connected;
105*2139Sjp161948 unsigned int _errno;
106*2139Sjp161948 unsigned int mtu;
107*2139Sjp161948 } bio_dgram_data;
108*2139Sjp161948
BIO_s_datagram(void)109*2139Sjp161948 BIO_METHOD *BIO_s_datagram(void)
110*2139Sjp161948 {
111*2139Sjp161948 return(&methods_dgramp);
112*2139Sjp161948 }
113*2139Sjp161948
BIO_new_dgram(int fd,int close_flag)114*2139Sjp161948 BIO *BIO_new_dgram(int fd, int close_flag)
115*2139Sjp161948 {
116*2139Sjp161948 BIO *ret;
117*2139Sjp161948
118*2139Sjp161948 ret=BIO_new(BIO_s_datagram());
119*2139Sjp161948 if (ret == NULL) return(NULL);
120*2139Sjp161948 BIO_set_fd(ret,fd,close_flag);
121*2139Sjp161948 return(ret);
122*2139Sjp161948 }
123*2139Sjp161948
dgram_new(BIO * bi)124*2139Sjp161948 static int dgram_new(BIO *bi)
125*2139Sjp161948 {
126*2139Sjp161948 bio_dgram_data *data = NULL;
127*2139Sjp161948
128*2139Sjp161948 bi->init=0;
129*2139Sjp161948 bi->num=0;
130*2139Sjp161948 data = OPENSSL_malloc(sizeof(bio_dgram_data));
131*2139Sjp161948 if (data == NULL)
132*2139Sjp161948 return 0;
133*2139Sjp161948 memset(data, 0x00, sizeof(bio_dgram_data));
134*2139Sjp161948 bi->ptr = data;
135*2139Sjp161948
136*2139Sjp161948 bi->flags=0;
137*2139Sjp161948 return(1);
138*2139Sjp161948 }
139*2139Sjp161948
dgram_free(BIO * a)140*2139Sjp161948 static int dgram_free(BIO *a)
141*2139Sjp161948 {
142*2139Sjp161948 bio_dgram_data *data;
143*2139Sjp161948
144*2139Sjp161948 if (a == NULL) return(0);
145*2139Sjp161948 if ( ! dgram_clear(a))
146*2139Sjp161948 return 0;
147*2139Sjp161948
148*2139Sjp161948 data = (bio_dgram_data *)a->ptr;
149*2139Sjp161948 if(data != NULL) OPENSSL_free(data);
150*2139Sjp161948
151*2139Sjp161948 return(1);
152*2139Sjp161948 }
153*2139Sjp161948
dgram_clear(BIO * a)154*2139Sjp161948 static int dgram_clear(BIO *a)
155*2139Sjp161948 {
156*2139Sjp161948 if (a == NULL) return(0);
157*2139Sjp161948 if (a->shutdown)
158*2139Sjp161948 {
159*2139Sjp161948 if (a->init)
160*2139Sjp161948 {
161*2139Sjp161948 SHUTDOWN2(a->num);
162*2139Sjp161948 }
163*2139Sjp161948 a->init=0;
164*2139Sjp161948 a->flags=0;
165*2139Sjp161948 }
166*2139Sjp161948 return(1);
167*2139Sjp161948 }
168*2139Sjp161948
dgram_read(BIO * b,char * out,int outl)169*2139Sjp161948 static int dgram_read(BIO *b, char *out, int outl)
170*2139Sjp161948 {
171*2139Sjp161948 int ret=0;
172*2139Sjp161948 bio_dgram_data *data = (bio_dgram_data *)b->ptr;
173*2139Sjp161948
174*2139Sjp161948 struct sockaddr peer;
175*2139Sjp161948 int peerlen = sizeof(peer);
176*2139Sjp161948
177*2139Sjp161948 if (out != NULL)
178*2139Sjp161948 {
179*2139Sjp161948 clear_socket_error();
180*2139Sjp161948 memset(&peer, 0x00, peerlen);
181*2139Sjp161948 /* Last arg in recvfrom is signed on some platforms and
182*2139Sjp161948 * unsigned on others. It is of type socklen_t on some
183*2139Sjp161948 * but this is not universal. Cast to (void *) to avoid
184*2139Sjp161948 * compiler warnings.
185*2139Sjp161948 */
186*2139Sjp161948 ret=recvfrom(b->num,out,outl,0,&peer,(void *)&peerlen);
187*2139Sjp161948
188*2139Sjp161948 if ( ! data->connected && ret > 0)
189*2139Sjp161948 BIO_ctrl(b, BIO_CTRL_DGRAM_CONNECT, 0, &peer);
190*2139Sjp161948
191*2139Sjp161948 BIO_clear_retry_flags(b);
192*2139Sjp161948 if (ret <= 0)
193*2139Sjp161948 {
194*2139Sjp161948 if (BIO_dgram_should_retry(ret))
195*2139Sjp161948 {
196*2139Sjp161948 BIO_set_retry_read(b);
197*2139Sjp161948 data->_errno = get_last_socket_error();
198*2139Sjp161948 }
199*2139Sjp161948 }
200*2139Sjp161948 }
201*2139Sjp161948 return(ret);
202*2139Sjp161948 }
203*2139Sjp161948
dgram_write(BIO * b,const char * in,int inl)204*2139Sjp161948 static int dgram_write(BIO *b, const char *in, int inl)
205*2139Sjp161948 {
206*2139Sjp161948 int ret;
207*2139Sjp161948 bio_dgram_data *data = (bio_dgram_data *)b->ptr;
208*2139Sjp161948 clear_socket_error();
209*2139Sjp161948
210*2139Sjp161948 if ( data->connected )
211*2139Sjp161948 ret=send(b->num,in,inl,0);
212*2139Sjp161948 else
213*2139Sjp161948 ret=sendto(b->num, in, inl, 0, &data->peer, sizeof(data->peer));
214*2139Sjp161948
215*2139Sjp161948 BIO_clear_retry_flags(b);
216*2139Sjp161948 if (ret <= 0)
217*2139Sjp161948 {
218*2139Sjp161948 if (BIO_sock_should_retry(ret))
219*2139Sjp161948 {
220*2139Sjp161948 BIO_set_retry_write(b);
221*2139Sjp161948 data->_errno = get_last_socket_error();
222*2139Sjp161948
223*2139Sjp161948 #if 0 /* higher layers are responsible for querying MTU, if necessary */
224*2139Sjp161948 if ( data->_errno == EMSGSIZE)
225*2139Sjp161948 /* retrieve the new MTU */
226*2139Sjp161948 BIO_ctrl(b, BIO_CTRL_DGRAM_QUERY_MTU, 0, NULL);
227*2139Sjp161948 #endif
228*2139Sjp161948 }
229*2139Sjp161948 }
230*2139Sjp161948 return(ret);
231*2139Sjp161948 }
232*2139Sjp161948
dgram_ctrl(BIO * b,int cmd,long num,void * ptr)233*2139Sjp161948 static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
234*2139Sjp161948 {
235*2139Sjp161948 long ret=1;
236*2139Sjp161948 int *ip;
237*2139Sjp161948 struct sockaddr *to = NULL;
238*2139Sjp161948 bio_dgram_data *data = NULL;
239*2139Sjp161948 long sockopt_val = 0;
240*2139Sjp161948 unsigned int sockopt_len = 0;
241*2139Sjp161948
242*2139Sjp161948 data = (bio_dgram_data *)b->ptr;
243*2139Sjp161948
244*2139Sjp161948 switch (cmd)
245*2139Sjp161948 {
246*2139Sjp161948 case BIO_CTRL_RESET:
247*2139Sjp161948 num=0;
248*2139Sjp161948 case BIO_C_FILE_SEEK:
249*2139Sjp161948 ret=0;
250*2139Sjp161948 break;
251*2139Sjp161948 case BIO_C_FILE_TELL:
252*2139Sjp161948 case BIO_CTRL_INFO:
253*2139Sjp161948 ret=0;
254*2139Sjp161948 break;
255*2139Sjp161948 case BIO_C_SET_FD:
256*2139Sjp161948 dgram_clear(b);
257*2139Sjp161948 b->num= *((int *)ptr);
258*2139Sjp161948 b->shutdown=(int)num;
259*2139Sjp161948 b->init=1;
260*2139Sjp161948 break;
261*2139Sjp161948 case BIO_C_GET_FD:
262*2139Sjp161948 if (b->init)
263*2139Sjp161948 {
264*2139Sjp161948 ip=(int *)ptr;
265*2139Sjp161948 if (ip != NULL) *ip=b->num;
266*2139Sjp161948 ret=b->num;
267*2139Sjp161948 }
268*2139Sjp161948 else
269*2139Sjp161948 ret= -1;
270*2139Sjp161948 break;
271*2139Sjp161948 case BIO_CTRL_GET_CLOSE:
272*2139Sjp161948 ret=b->shutdown;
273*2139Sjp161948 break;
274*2139Sjp161948 case BIO_CTRL_SET_CLOSE:
275*2139Sjp161948 b->shutdown=(int)num;
276*2139Sjp161948 break;
277*2139Sjp161948 case BIO_CTRL_PENDING:
278*2139Sjp161948 case BIO_CTRL_WPENDING:
279*2139Sjp161948 ret=0;
280*2139Sjp161948 break;
281*2139Sjp161948 case BIO_CTRL_DUP:
282*2139Sjp161948 case BIO_CTRL_FLUSH:
283*2139Sjp161948 ret=1;
284*2139Sjp161948 break;
285*2139Sjp161948 case BIO_CTRL_DGRAM_CONNECT:
286*2139Sjp161948 to = (struct sockaddr *)ptr;
287*2139Sjp161948 #if 0
288*2139Sjp161948 if (connect(b->num, to, sizeof(struct sockaddr)) < 0)
289*2139Sjp161948 { perror("connect"); ret = 0; }
290*2139Sjp161948 else
291*2139Sjp161948 {
292*2139Sjp161948 #endif
293*2139Sjp161948 memcpy(&(data->peer),to, sizeof(struct sockaddr));
294*2139Sjp161948 #if 0
295*2139Sjp161948 }
296*2139Sjp161948 #endif
297*2139Sjp161948 break;
298*2139Sjp161948 /* (Linux)kernel sets DF bit on outgoing IP packets */
299*2139Sjp161948 #ifdef IP_MTU_DISCOVER
300*2139Sjp161948 case BIO_CTRL_DGRAM_MTU_DISCOVER:
301*2139Sjp161948 sockopt_val = IP_PMTUDISC_DO;
302*2139Sjp161948 if ((ret = setsockopt(b->num, IPPROTO_IP, IP_MTU_DISCOVER,
303*2139Sjp161948 &sockopt_val, sizeof(sockopt_val))) < 0)
304*2139Sjp161948 perror("setsockopt");
305*2139Sjp161948 break;
306*2139Sjp161948 #endif
307*2139Sjp161948 case BIO_CTRL_DGRAM_QUERY_MTU:
308*2139Sjp161948 sockopt_len = sizeof(sockopt_val);
309*2139Sjp161948 if ((ret = getsockopt(b->num, IPPROTO_IP, IP_MTU, (void *)&sockopt_val,
310*2139Sjp161948 &sockopt_len)) < 0 || sockopt_val < 0)
311*2139Sjp161948 { ret = 0; }
312*2139Sjp161948 else
313*2139Sjp161948 {
314*2139Sjp161948 data->mtu = sockopt_val;
315*2139Sjp161948 ret = data->mtu;
316*2139Sjp161948 }
317*2139Sjp161948 break;
318*2139Sjp161948 case BIO_CTRL_DGRAM_GET_MTU:
319*2139Sjp161948 return data->mtu;
320*2139Sjp161948 break;
321*2139Sjp161948 case BIO_CTRL_DGRAM_SET_MTU:
322*2139Sjp161948 data->mtu = num;
323*2139Sjp161948 ret = num;
324*2139Sjp161948 break;
325*2139Sjp161948 case BIO_CTRL_DGRAM_SET_CONNECTED:
326*2139Sjp161948 to = (struct sockaddr *)ptr;
327*2139Sjp161948
328*2139Sjp161948 if ( to != NULL)
329*2139Sjp161948 {
330*2139Sjp161948 data->connected = 1;
331*2139Sjp161948 memcpy(&(data->peer),to, sizeof(struct sockaddr));
332*2139Sjp161948 }
333*2139Sjp161948 else
334*2139Sjp161948 {
335*2139Sjp161948 data->connected = 0;
336*2139Sjp161948 memset(&(data->peer), 0x00, sizeof(struct sockaddr));
337*2139Sjp161948 }
338*2139Sjp161948 break;
339*2139Sjp161948 case BIO_CTRL_DGRAM_SET_PEER:
340*2139Sjp161948 to = (struct sockaddr *) ptr;
341*2139Sjp161948
342*2139Sjp161948 memcpy(&(data->peer), to, sizeof(struct sockaddr));
343*2139Sjp161948 break;
344*2139Sjp161948 case BIO_CTRL_DGRAM_SET_RECV_TIMEOUT:
345*2139Sjp161948 if ( setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, ptr,
346*2139Sjp161948 sizeof(struct timeval)) < 0)
347*2139Sjp161948 { perror("setsockopt"); ret = -1; }
348*2139Sjp161948 break;
349*2139Sjp161948 case BIO_CTRL_DGRAM_GET_RECV_TIMEOUT:
350*2139Sjp161948 if ( getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
351*2139Sjp161948 ptr, (void *)&ret) < 0)
352*2139Sjp161948 { perror("getsockopt"); ret = -1; }
353*2139Sjp161948 break;
354*2139Sjp161948 case BIO_CTRL_DGRAM_SET_SEND_TIMEOUT:
355*2139Sjp161948 if ( setsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, ptr,
356*2139Sjp161948 sizeof(struct timeval)) < 0)
357*2139Sjp161948 { perror("setsockopt"); ret = -1; }
358*2139Sjp161948 break;
359*2139Sjp161948 case BIO_CTRL_DGRAM_GET_SEND_TIMEOUT:
360*2139Sjp161948 if ( getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO,
361*2139Sjp161948 ptr, (void *)&ret) < 0)
362*2139Sjp161948 { perror("getsockopt"); ret = -1; }
363*2139Sjp161948 break;
364*2139Sjp161948 case BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP:
365*2139Sjp161948 /* fall-through */
366*2139Sjp161948 case BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP:
367*2139Sjp161948 if ( data->_errno == EAGAIN)
368*2139Sjp161948 {
369*2139Sjp161948 ret = 1;
370*2139Sjp161948 data->_errno = 0;
371*2139Sjp161948 }
372*2139Sjp161948 else
373*2139Sjp161948 ret = 0;
374*2139Sjp161948 break;
375*2139Sjp161948 #ifdef EMSGSIZE
376*2139Sjp161948 case BIO_CTRL_DGRAM_MTU_EXCEEDED:
377*2139Sjp161948 if ( data->_errno == EMSGSIZE)
378*2139Sjp161948 {
379*2139Sjp161948 ret = 1;
380*2139Sjp161948 data->_errno = 0;
381*2139Sjp161948 }
382*2139Sjp161948 else
383*2139Sjp161948 ret = 0;
384*2139Sjp161948 break;
385*2139Sjp161948 #endif
386*2139Sjp161948 default:
387*2139Sjp161948 ret=0;
388*2139Sjp161948 break;
389*2139Sjp161948 }
390*2139Sjp161948 return(ret);
391*2139Sjp161948 }
392*2139Sjp161948
dgram_puts(BIO * bp,const char * str)393*2139Sjp161948 static int dgram_puts(BIO *bp, const char *str)
394*2139Sjp161948 {
395*2139Sjp161948 int n,ret;
396*2139Sjp161948
397*2139Sjp161948 n=strlen(str);
398*2139Sjp161948 ret=dgram_write(bp,str,n);
399*2139Sjp161948 return(ret);
400*2139Sjp161948 }
401*2139Sjp161948
BIO_dgram_should_retry(int i)402*2139Sjp161948 int BIO_dgram_should_retry(int i)
403*2139Sjp161948 {
404*2139Sjp161948 int err;
405*2139Sjp161948
406*2139Sjp161948 if ((i == 0) || (i == -1))
407*2139Sjp161948 {
408*2139Sjp161948 err=get_last_socket_error();
409*2139Sjp161948
410*2139Sjp161948 #if defined(OPENSSL_SYS_WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */
411*2139Sjp161948 if ((i == -1) && (err == 0))
412*2139Sjp161948 return(1);
413*2139Sjp161948 #endif
414*2139Sjp161948
415*2139Sjp161948 return(BIO_dgram_non_fatal_error(err));
416*2139Sjp161948 }
417*2139Sjp161948 return(0);
418*2139Sjp161948 }
419*2139Sjp161948
BIO_dgram_non_fatal_error(int err)420*2139Sjp161948 int BIO_dgram_non_fatal_error(int err)
421*2139Sjp161948 {
422*2139Sjp161948 switch (err)
423*2139Sjp161948 {
424*2139Sjp161948 #if defined(OPENSSL_SYS_WINDOWS)
425*2139Sjp161948 # if defined(WSAEWOULDBLOCK)
426*2139Sjp161948 case WSAEWOULDBLOCK:
427*2139Sjp161948 # endif
428*2139Sjp161948
429*2139Sjp161948 # if 0 /* This appears to always be an error */
430*2139Sjp161948 # if defined(WSAENOTCONN)
431*2139Sjp161948 case WSAENOTCONN:
432*2139Sjp161948 # endif
433*2139Sjp161948 # endif
434*2139Sjp161948 #endif
435*2139Sjp161948
436*2139Sjp161948 #ifdef EWOULDBLOCK
437*2139Sjp161948 # ifdef WSAEWOULDBLOCK
438*2139Sjp161948 # if WSAEWOULDBLOCK != EWOULDBLOCK
439*2139Sjp161948 case EWOULDBLOCK:
440*2139Sjp161948 # endif
441*2139Sjp161948 # else
442*2139Sjp161948 case EWOULDBLOCK:
443*2139Sjp161948 # endif
444*2139Sjp161948 #endif
445*2139Sjp161948
446*2139Sjp161948 #if defined(ENOTCONN)
447*2139Sjp161948 case ENOTCONN:
448*2139Sjp161948 #endif
449*2139Sjp161948
450*2139Sjp161948 #ifdef EINTR
451*2139Sjp161948 case EINTR:
452*2139Sjp161948 #endif
453*2139Sjp161948
454*2139Sjp161948 #ifdef EAGAIN
455*2139Sjp161948 #if EWOULDBLOCK != EAGAIN
456*2139Sjp161948 case EAGAIN:
457*2139Sjp161948 # endif
458*2139Sjp161948 #endif
459*2139Sjp161948
460*2139Sjp161948 #ifdef EPROTO
461*2139Sjp161948 case EPROTO:
462*2139Sjp161948 #endif
463*2139Sjp161948
464*2139Sjp161948 #ifdef EINPROGRESS
465*2139Sjp161948 case EINPROGRESS:
466*2139Sjp161948 #endif
467*2139Sjp161948
468*2139Sjp161948 #ifdef EALREADY
469*2139Sjp161948 case EALREADY:
470*2139Sjp161948 #endif
471*2139Sjp161948
472*2139Sjp161948 /* DF bit set, and packet larger than MTU */
473*2139Sjp161948 #ifdef EMSGSIZE
474*2139Sjp161948 case EMSGSIZE:
475*2139Sjp161948 #endif
476*2139Sjp161948
477*2139Sjp161948 return(1);
478*2139Sjp161948 /* break; */
479*2139Sjp161948 default:
480*2139Sjp161948 break;
481*2139Sjp161948 }
482*2139Sjp161948 return(0);
483*2139Sjp161948 }
484*2139Sjp161948 #endif
485