Main Page | Class List | Directories | File List | Class Members | File Members

s_apps.h File Reference

#include <sys/types.h>
#include <openssl/opensslconf.h>

Go to the source code of this file.

Defines

#define PORT   4433
#define PORT_STR   "4433"
#define PROTOCOL   "tcp"

Functions

int do_server (int port, int type, int *ret, int(*cb)(char *hostname, int s, unsigned char *context), unsigned char *context)
int init_client (int *sock, char *server, int port, int type)
int should_retry (int i)
int extract_port (char *str, short *port_ptr)
int extract_host_port (char *str, char **host_ptr, unsigned char *ip, short *p)
long MS_CALLBACK bio_dump_callback (BIO *bio, int cmd, const char *argp, int argi, long argl, long ret)


Define Documentation

#define PORT   4433
 

Definition at line 147 of file s_apps.h.

Referenced by MAIN(), and sv_usage().

#define PORT_STR   "4433"
 

Definition at line 148 of file s_apps.h.

Referenced by sc_usage().

#define PROTOCOL   "tcp"
 

Definition at line 149 of file s_apps.h.


Function Documentation

long MS_CALLBACK bio_dump_callback BIO bio,
int  cmd,
const char *  argp,
int  argi,
long  argl,
long  ret
 

Definition at line 260 of file s_cb.c.

References BIO_CB_READ, BIO_CB_RETURN, BIO_CB_WRITE, BIO_dump(), BIO_get_callback_arg, BIO_printf(), and out.

Referenced by sv_body(), and www_body().

00262         {
00263         BIO *out;
00264 
00265         out=(BIO *)BIO_get_callback_arg(bio);
00266         if (out == NULL) return(ret);
00267 
00268         if (cmd == (BIO_CB_READ|BIO_CB_RETURN))
00269                 {
00270                 BIO_printf(out,"read from %p [%p] (%d bytes => %ld (0x%lX))\n",
00271                         (void *)bio,argp,argi,ret,ret);
00272                 BIO_dump(out,argp,(int)ret);
00273                 return(ret);
00274                 }
00275         else if (cmd == (BIO_CB_WRITE|BIO_CB_RETURN))
00276                 {
00277                 BIO_printf(out,"write to %p [%p] (%d bytes => %ld (0x%lX))\n",
00278                         (void *)bio,argp,argi,ret,ret);
00279                 BIO_dump(out,argp,(int)ret);
00280                 }
00281         return(ret);
00282         }

int do_server int  port,
int  type,
int *  ret,
int(*)(char *hostname, int s, unsigned char *context)  cb,
unsigned char *  context
 

Definition at line 284 of file s_socket.c.

References accept_socket, do_accept(), init_server(), and OPENSSL_free.

Referenced by doit(), and MAIN().

00285         {
00286         int sock;
00287         char *name = NULL;
00288         int accept_socket;
00289         int i;
00290 
00291         if (!init_server(&accept_socket,port,type)) return(0);
00292 
00293         if (ret != NULL)
00294                 {
00295                 *ret=accept_socket;
00296                 /* return(1);*/
00297                 }
00298         for (;;)
00299                 {
00300                 if (type==SOCK_STREAM)
00301                         {
00302                         if (do_accept(accept_socket,&sock,&name) == 0)
00303                                 {
00304                                 SHUTDOWN(accept_socket);
00305                                 return(0);
00306                                 }
00307                         }
00308                 else
00309                         sock = accept_socket;
00310                 i=(*cb)(name,sock, context);
00311                 if (name != NULL) OPENSSL_free(name);
00312                 if (type==SOCK_STREAM)
00313                         SHUTDOWN2(sock);
00314                 if (i < 0)
00315                         {
00316                         SHUTDOWN2(accept_socket);
00317                         return(i);
00318                         }
00319                 }
00320         }

int extract_host_port char *  str,
char **  host_ptr,
unsigned char *  ip,
short *  p
 

Definition at line 472 of file s_socket.c.

References bio_err, BIO_printf(), extract_port(), host_ip(), and p.

00474         {
00475         char *h,*p;
00476 
00477         h=str;
00478         p=strchr(str,':');
00479         if (p == NULL)
00480                 {
00481                 BIO_printf(bio_err,"no port defined\n");
00482                 return(0);
00483                 }
00484         *(p++)='\0';
00485 
00486         if ((ip != NULL) && !host_ip(str,ip))
00487                 goto err;
00488         if (host_ptr != NULL) *host_ptr=h;
00489 
00490         if (!extract_port(p,port_ptr))
00491                 goto err;
00492         return(1);
00493 err:
00494         return(0);
00495         }

int extract_port char *  str,
short *  port_ptr
 

Definition at line 543 of file s_socket.c.

References bio_err, and BIO_printf().

Referenced by extract_host_port(), and MAIN().

00544         {
00545         int i;
00546         struct servent *s;
00547 
00548         i=atoi(str);
00549         if (i != 0)
00550                 *port_ptr=(unsigned short)i;
00551         else
00552                 {
00553                 s=getservbyname(str,"tcp");
00554                 if (s == NULL)
00555                         {
00556                         BIO_printf(bio_err,"getservbyname failure for %s\n",str);
00557                         return(0);
00558                         }
00559                 *port_ptr=ntohs((unsigned short)s->s_port);
00560                 }
00561         return(1);
00562         }

int init_client int *  sock,
char *  server,
int  port,
int  type
 

Definition at line 231 of file s_socket.c.

References host_ip(), init_client_ip(), and p.

00232         {
00233         unsigned char ip[4];
00234         short p=0;
00235 
00236         if (!host_ip(host,&(ip[0])))
00237                 {
00238                 return(0);
00239                 }
00240         if (p != 0) port=p;
00241         return(init_client_ip(sock,ip,port,type));
00242         }

int should_retry int  i  ) 
 


© sourcejam.com 2005-2008