[insert project logo here (125x200px max)]

Navigator

Mailinglists

Please report any errors or ommissions you find to our `Help' mailinglist, or post a message in the Forums.

Copyright and Licensing Information

Snap is (c) Jonathan T. Moore, 1999-2002 and licensed under the GNU General Public License (GPL).

All other parts of Splash are (c) Willem de Bruijn, 2002-2003 and licensed under the BSD Open Source License.

All sourcecode is made publicly available.

Acknowledgement

Splash and the Splash website are hosted by SourceForge.net

SourceForge.net Logo

osi-open source certified logo

Splash - Documentation

SNMP Plus a Lightweight API for SNAP Handling

Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

snap-1.1-wjdb/lib/sockets.c

Go to the documentation of this file.
00001 /* sockets.c */
00002 
00003 #include <sys/socket.h>
00004 #include <stdio.h>
00005 
00006 #include "config.h"
00007 #include "sockets.h"
00008 #include "intl.h"
00009 
00010 int skfd = -1;              /* generic raw socket desc. */
00011 #if HAVE_AFIPX
00012 int ipx_sock = -1;          /* IPX socket           */
00013 #endif
00014 #if HAVE_AFAX25
00015 int ax25_sock = -1;         /* AX.25 socket         */
00016 #endif
00017 #if HAVE_AFROSE
00018 int rose_sock = -1;         /* Rose socket          */
00019 #endif
00020 #if HAVE_AFINET
00021 int inet_sock = -1;         /* INET socket          */
00022 #endif
00023 #if HAVE_AFINET6
00024 int inet6_sock = -1;            /* INET6 socket         */
00025 #endif
00026 #if HAVE_AFATALK
00027 int ddp_sock = -1;          /* Appletalk DDP socket     */
00028 #endif
00029 #if HAVE_AFECONET
00030 int ec_sock = -1;           /* Econet socket        */
00031 #endif
00032 
00033 int sockets_open(void)
00034 {
00035 #if HAVE_AFINET
00036   inet_sock = socket(AF_INET, SOCK_DGRAM, 0);
00037 #endif
00038 
00039 #if HAVE_AFINET6
00040   inet6_sock = socket(AF_INET6, SOCK_DGRAM, 0);
00041 #endif
00042 
00043 #if HAVE_AFIPX 
00044   ipx_sock = socket(AF_IPX, SOCK_DGRAM, 0);
00045 #endif
00046 
00047 #if HAVE_AFAX25 
00048   ax25_sock = socket(AF_AX25, SOCK_DGRAM, 0);
00049 #endif
00050 
00051 #if HAVE_ROSE
00052   rose_sock = socket(AF_ROSE, SOCK_DGRAM, 0);
00053 #endif
00054 
00055 #if HAVE_AFATALK
00056   ddp_sock = socket(AF_APPLETALK, SOCK_DGRAM, 0);
00057 #endif
00058 
00059 #if HAVE_AFECONET
00060   ec_sock = socket(AF_ECONET, SOCK_DGRAM, 0);
00061 #endif
00062   
00063   /*
00064    *    Now pick any (existing) useful socket family for generic queries
00065    */
00066 
00067 #if HAVE_AFINET
00068   if (inet_sock != -1) return inet_sock;
00069 #endif
00070 
00071 #if HAVE_AFINET6
00072   if (inet6_sock != -1) return inet6_sock;
00073 #endif
00074 
00075 #if HAVE_AFIPX 
00076   if (ipx_sock != -1) return ipx_sock;
00077 #endif
00078 
00079 #if HAVE_AFAX25 
00080   if (ax25_sock != -1) return ax25_sock;
00081 #endif
00082 
00083 #if HAVE_AFROSE 
00084   if (rose_sock != -1) return rose_sock;
00085 #endif
00086 
00087 #if HAVE_AFATALK
00088   if (ddp_sock != -1) return ddp_sock;
00089 #endif
00090 
00091 #if HAVE_AFECONET
00092   if (ec_sock != -1) return ec_sock;
00093 #endif
00094 
00095   /* We have no address families.  */
00096   fprintf(stderr, _("No usable address families found.\n"));
00097   return -1;
00098 }