Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

libcomm.h

Go to the documentation of this file.
00001 
00007 /*
00008   Copyright (c) Andreas Hofmeier
00009   (www.an-h.de, www.an-h.de.vu, www.lgut.uni-bremen.de/an-h/)
00010   
00011   This program is free software; you can redistribute it and/or modify
00012   it under the terms of the GNU General Public License as published by
00013   the Free Software Foundation; either version 2 of the License, or
00014   (at your option) any later version.
00015 
00016   This program is distributed in the hope that it will be useful, but
00017   WITHOUT ANY WARRANTY; without even the implied warranty of
00018   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00019   General Public License for more details.
00020 
00021   You should have received a copy of the GNU General Public License
00022   along with this program; if not, write to the Free Software
00023   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00024 */
00025 
00026 
00027 
00028 //#include "md5.h"
00029 #include <stdio.h>
00030 #include <sys/types.h>
00031 #include <sys/socket.h>
00032 #include <netinet/in.h>
00033 #include <arpa/inet.h>
00034 
00035 #define true 1
00036 #define false 0
00037 
00038 #ifndef nothread
00039   #include <pthread.h>
00040 #endif
00041 
00042 // declaration
00043 
00044 // md5auth
00045 // the first authfile, which is fould will be used
00046 // first authfile. 
00047 #define authfile0 "./libcomm_md5auth.pwd"
00048 // second authfile
00049 #define authfile1 "/etc/libcomm_md5auth.pwd"
00050 // one char/byte which seperates the field in the authfile
00051 #define authfilefieldseperator ':'
00052 // maxinam lenght of a line in the authfile
00053 #define authfilemaxlinelenght 4096
00054 // how much random bytes are generated for the authentication
00055 #define authrandomstringsize (int) 16
00056 // Define the message-type for the auth blocks
00057 #define authmessagetype 65535
00058 
00059 // structure to stroe the authentication infromationen
00060 struct AUTHINFO {
00061   // network name
00062   char *netname;
00063   // login name
00064   char *name;
00065   // login passwd
00066   char *passwd;
00067   // Key for encryption (not used yet)
00068   char *keyencrypt;
00069   // Key for decryption (not used yet)
00070   char *keydecrypt;
00071 };
00072 
00073 int socket_md5auth(int fd, char *netname, char *name,
00074                    struct AUTHINFO **locallogin,
00075                    struct AUTHINFO **remotelogin);
00076 struct AUTHINFO *getauthinfo(char *netname, char *name);
00077 
00078 
00079 
00080 // socket_acceept
00081 #ifndef nothread
00082 struct LIBCOMMPTHREADP {
00083   void (*socket_accept_do)(int fd, int id, char *pip,
00084                             struct sockaddr_in their_addr);
00085 
00086   pthread_t        thrd_2;
00087   pthread_attr_t   thrd_2_attr;
00088   int              sockport;
00089   int              id;
00090 };
00091 void socket_accept_thread(struct LIBCOMMPTHREADP *libcommpthreadp);
00092 int socket_accept(int sockport, int id,
00093            void (*socket_accept_do)(int fd, int id, char *pip,
00094                             struct sockaddr_in their_addr));
00095 #endif
00096 
00097 
00098 // block_receive
00099 #ifndef nothread
00100 struct LIBCOMMPTHREADS {
00101   void (*block_call_do)(int fd, int id, unsigned int type,
00102                         char *buf, unsigned int size, int term);
00103   void (*block_call_term)(int fd, int id);
00104 
00105   pthread_t        thrd_1;
00106   pthread_attr_t   thrd_1_attr;
00107   int              fd;
00108   int              id;
00109   int              term;
00110 };
00111 void thread1(struct LIBCOMMPTHREADS *libcommpthreads);
00112 int block_call(int fd, int id, int term,
00113            void (*block_call_do)(int fd, int id, unsigned int type,
00114                                  char *buf, unsigned int size,
00115                                  int term), 
00116            void (*block_call_term)(int fd, int id));
00117 #endif
00118 char *block_receive_poll(int fd, unsigned int *type, char *buf,
00119                          unsigned int *size, unsigned int maxsize,
00120                          int term);
00121 char *block_receive(int fd, unsigned int *type, char *buf,
00122                     unsigned int *size, unsigned int maxsize,
00123                     int term);
00124 int block_receive_integer(int fd, unsigned int *recvi);
00125 int block_receive_nbytes(int fd, char *buf, int n);
00126 
00127 
00128 
00129 // block_send
00130 int block_send(int fd, unsigned int type, char *buf, unsigned int size);
00131 
00132 
00133 
00134 // block_random
00135 char *block_random(char *buf, int size);
00136 
00137 
00138 
00139 // socket_bind
00140 int socket_bind(int port, int cqueue);
00141 
00142 
00143 
00144 // socket_connect
00145 int socket_connect(char *host, int port);
00146 
00147 
00148 
00149 // line monitor
00150 struct LINEMONITOR_THREAD_DATA {
00151   char *server;
00152   int port;
00153   int soft_msec;
00154   int hard_msec;
00155   int wait_msec;
00156   void (*linemonitor_exception)(char *server, int port, int type);
00157   int sock;
00158 };
00159 
00160 
00161 void linemonitor_server_thread(struct LINEMONITOR_THREAD_DATA
00162                           *linemonitor_thread_data);
00163 int linemonitor_server(int port,
00164                 int soft_msec, int hard_msec, int wait_msec,
00165                 void (*linemonitor_exception)(char *server, int port,
00166                                               int type));
00167 void linemonitor_emergencystop(int sock);
00168 int linemonitor_thread(struct LINEMONITOR_THREAD_DATA
00169                        *linemonitor_thread_data);
00170 int linemonitor(char *server, int port,
00171                 int soft_msec, int hard_msec, int wait_msec,
00172                 void (*linemonitor_exception)(char *server, int port,
00173                                               int type));
00174 
00175 

Generated on Mon Apr 25 10:53:25 2005 for Hofmeier_FYP:libcomm by doxygen1.2.15