# netconnection.h

Go to the documentation of this file.

    00001 /***************************************************************************
    00002  $RCSfile: netconnection.h,v $
    00003                              -------------------
    00004     cvs         : $Id: netconnection.h,v 1.16 2005/01/25 23:26:03 aquamaniac Exp $
    00005     begin       : Mon Feb 09 2004
    00006     copyright   : (C) 2004 by Martin Preuss
    00007     email       : martin@libchipcard.de
    00008
    00009  ***************************************************************************
    00010  *                                                                         *
    00011  *   This library is free software; you can redistribute it and/or         *
    00012  *   modify it under the terms of the GNU Lesser General Public            *
    00013  *   License as published by the Free Software Foundation; either          *
    00014  *   version 2.1 of the License, or (at your option) any later version.    *
    00015  *                                                                         *
    00016  *   This library is distributed in the hope that it will be useful,       *
    00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
    00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
    00019  *   Lesser General Public License for more details.                       *
    00020  *                                                                         *
    00021  *   You should have received a copy of the GNU Lesser General Public      *
    00022  *   License along with this library; if not, write to the Free Software   *
    00023  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *
    00024  *   MA  02111-1307  USA                                                   *
    00025  *                                                                         *
    00026  ***************************************************************************/
    00027
    00028
    00029 #ifndef GWEN_NETCONNECTION_H
    00030 #define GWEN_NETCONNECTION_H
    00031
    00039
    00040
    00047 #define GWEN_NETCONNECTION_WAIT_READ  0x0001
    00048
    00049 #define GWEN_NETCONNECTION_WAIT_WRITE 0x0002
    00050
    00061 #define GWEN_NETCONNECTION_TIMEOUT_NONE    (0)
    00062
    00063 #define GWEN_NETCONNECTION_TIMEOUT_FOREVER (-1)
    00064
    00067 #define GWEN_NETCONNECTION_CBID_IO "GWEN_NETCONNECTION_CBID_IO"
    00068
    00069
    00074 #include <gwenhywfar/gwenhywfarapi.h>
    00075 #ifdef __cplusplus
    00076 extern "C" {
    00077 #endif
    00078 typedef struct GWEN_NETCONNECTION GWEN_NETCONNECTION;
    00079 #ifdef __cplusplus
    00080 }
    00081 #endif
    00082
    00083 #include <gwenhywfar/misc.h>
    00084 #include <gwenhywfar/inherit.h>
    00085 #include <gwenhywfar/nettransport.h>
    00086 #include <gwenhywfar/netmsg.h>
    00087 #include <gwenhywfar/ringbuffer.h>
    00088
    00089 #define GWEN_NETCONNECTION_CHECK_WANTREAD  0x0001
    00090 #define GWEN_NETCONNECTION_CHECK_WANTWRITE 0x0002
    00091
    00092 #ifdef __cplusplus
    00093 extern "C" {
    00094 #endif
    00095
    00096 typedef enum {
    00097   GWEN_NetConnectionWorkResult_NoChange=0,
    00098   GWEN_NetConnectionWorkResult_Change,
    00099   GWEN_NetConnectionWorkResult_Error,
    00100 } GWEN_NETCONNECTION_WORKRESULT;
    00101
    00102
    00103 GWEN_LIST_FUNCTION_LIB_DEFS(GWEN_NETCONNECTION, GWEN_NetConnection, GWENHYWFAR_API)
    00104 GWEN_INHERIT_FUNCTION_LIB_DEFS(GWEN_NETCONNECTION, GWENHYWFAR_API)
    00105 /* No trailing semicolon here because this is a macro call */
    00106
    00107
    00113 typedef GWEN_NETCONNECTION_WORKRESULT
    00114   (*GWEN_NETCONNECTION_WORKFN)(GWEN_NETCONNECTION *conn);
    00116 typedef void (*GWEN_NETCONNECTION_UPFN)(GWEN_NETCONNECTION *conn);
    00118 typedef void (*GWEN_NETCONNECTION_DOWNFN)(GWEN_NETCONNECTION *conn);
    00119
    00120 typedef GWEN_TYPE_UINT32
    00121   (*GWEN_NETCONNECTION_CHECKFN)(GWEN_NETCONNECTION *conn);
    00122
    00140 GWENHYWFAR_API
    00141 GWEN_NETCONNECTION *GWEN_NetConnection_new(GWEN_NETTRANSPORT *tr,
    00142                                            int take,
    00143                                            GWEN_TYPE_UINT32 libId);
    00144
    00145 GWENHYWFAR_API
    00146 void GWEN_NetConnection_free(GWEN_NETCONNECTION *conn);
    00147
    00148 GWENHYWFAR_API
    00149 void GWEN_NetConnection_Attach(GWEN_NETCONNECTION *conn);
    00150
    00166 GWENHYWFAR_API
    00167 int GWEN_NetConnection_Read(GWEN_NETCONNECTION *conn,
    00168                             char *buffer,
    00169                             GWEN_TYPE_UINT32 *bsize);
    00170
    00181 GWENHYWFAR_API
    00182 int GWEN_NetConnection_Read_Wait(GWEN_NETCONNECTION *conn,
    00183                                  char *buffer,
    00184                                  GWEN_TYPE_UINT32 *bsize,
    00185                                  int timeout);
    00186
    00187
    00196 GWENHYWFAR_API
    00197 int GWEN_NetConnection_Write(GWEN_NETCONNECTION *conn,
    00198                              const char *buffer,
    00199                              GWEN_TYPE_UINT32 *bsize);
    00200
    00214 GWENHYWFAR_API
    00215 int GWEN_NetConnection_Write_Wait(GWEN_NETCONNECTION *conn,
    00216                                   const char *buffer,
    00217                                   GWEN_TYPE_UINT32 *bsize,
    00218                                   int timeout);
    00219
    00228 GWENHYWFAR_API
    00229 int GWEN_NetConnection_Flush(GWEN_NETCONNECTION *conn,
    00230                              int timeout);
    00246 GWENHYWFAR_API
    00247 int GWEN_NetConnection_StartConnect(GWEN_NETCONNECTION *conn);
    00248
    00255 GWENHYWFAR_API
    00256 int GWEN_NetConnection_Connect_Wait(GWEN_NETCONNECTION *conn,
    00257                                     int timeout);
    00258
    00268 GWENHYWFAR_API
    00269 int GWEN_NetConnection_StartListen(GWEN_NETCONNECTION *conn);
    00270
    00277 GWENHYWFAR_API
    00278 GWEN_NETTRANSPORT*
    00279   GWEN_NetConnection_GetNextIncoming(GWEN_NETCONNECTION *conn);
    00280
    00289 GWENHYWFAR_API
    00290 GWEN_NETTRANSPORT*
    00291   GWEN_NetConnection_GetNextIncoming_Wait(GWEN_NETCONNECTION *conn,
    00292                                           int timeout);
    00293
    00301 GWENHYWFAR_API
    00302 int GWEN_NetConnection_StartDisconnect(GWEN_NETCONNECTION *conn);
    00303
    00312 GWENHYWFAR_API
    00313 int GWEN_NetConnection_Disconnect_Wait(GWEN_NETCONNECTION *conn,
    00314                                        int timeout);
    00331 GWENHYWFAR_API
    00332 GWEN_NETCONNECTION_WORKRESULT
    00333   GWEN_NetConnection_WorkIO(GWEN_NETCONNECTION *conn);
    00334
    00344 GWENHYWFAR_API
    00345 int GWEN_NetConnection_WaitForStatus(GWEN_NETCONNECTION *conn,
    00346                                      GWEN_NETTRANSPORT_STATUS expStatus,
    00347                                      int timeout);
    00348
    00356 GWENHYWFAR_API
    00357 GWEN_NETCONNECTION_WORKRESULT
    00358   GWEN_NetConnection_Walk(GWEN_NETCONNECTION_LIST *connList,
    00359                           int timeout);
    00360
    00379 GWENHYWFAR_API
    00380 GWEN_NETCONNECTION_WORKRESULT
    00381   GWEN_NetConnection_Work(GWEN_NETCONNECTION *conn);
    00382
    00395 GWENHYWFAR_API
    00396 void GWEN_NetConnection_Up(GWEN_NETCONNECTION *conn);
    00397
    00403 GWENHYWFAR_API
    00404 void GWEN_NetConnection_Down(GWEN_NETCONNECTION *conn);
    00405
    00413 GWENHYWFAR_API
    00414 void GWEN_NetConnection_SetWorkFn(GWEN_NETCONNECTION *conn,
    00415                                   GWEN_NETCONNECTION_WORKFN fn);
    00416
    00417 GWENHYWFAR_API
    00418 void GWEN_NetConnection_SetUpFn(GWEN_NETCONNECTION *conn,
    00419                                 GWEN_NETCONNECTION_UPFN fn);
    00420
    00421 GWENHYWFAR_API
    00422 void GWEN_NetConnection_SetDownFn(GWEN_NETCONNECTION *conn,
    00423                                   GWEN_NETCONNECTION_DOWNFN fn);
    00424 GWENHYWFAR_API
    00425 void GWEN_NetConnection_SetCheckFn(GWEN_NETCONNECTION *conn,
    00426                                    GWEN_NETCONNECTION_CHECKFN fn);
    00430 #if (defined(GWEN_EXTEND_NETCONNECTION) || defined(DOXYGEN))
    00431
    00444
    00451 GWENHYWFAR_API
    00452 GWEN_RINGBUFFER *GWEN_NetConnection_GetReadBuffer(GWEN_NETCONNECTION *conn);
    00453
    00460 GWENHYWFAR_API
    00461 GWEN_RINGBUFFER *GWEN_NetConnection_GetWriteBuffer(GWEN_NETCONNECTION *conn);
    00462
    00468 GWENHYWFAR_API
    00469 void GWEN_NetConnection_AddInMsg(GWEN_NETCONNECTION *conn,
    00470                                  GWEN_NETMSG *msg);
    00471
    00477 GWENHYWFAR_API
    00478 GWEN_NETMSG *GWEN_NetConnection_GetOutMsg(GWEN_NETCONNECTION *conn);
    00479
    00485 GWENHYWFAR_API
    00486 GWEN_NETMSG *GWEN_NetConnection_PeekOutMsg(const GWEN_NETCONNECTION *conn);
    00487
    00489 #endif /* GWEN_EXTENDING_NETCONNECTION */
    00490
    00491
    00501 GWENHYWFAR_API
    00502 GWEN_NETMSG *GWEN_NetConnection_GetInMsg(GWEN_NETCONNECTION *conn);
    00503
    00509 GWENHYWFAR_API
    00510 GWEN_NETMSG *GWEN_NetConnection_GetInMsg_Wait(GWEN_NETCONNECTION *conn,
    00511                                              int timeout);
    00512
    00518 GWENHYWFAR_API
    00519 GWEN_NETMSG *GWEN_NetConnection_PeekInMsg(const GWEN_NETCONNECTION *conn);
    00520
    00525 GWENHYWFAR_API
    00526 void GWEN_NetConnection_AddOutMsg(GWEN_NETCONNECTION *conn,
    00527                                   GWEN_NETMSG *msg);
    00528
    00541 GWENHYWFAR_API
    00542 GWEN_NETTRANSPORT*
    00543   GWEN_NetConnection_GetTransportLayer(const GWEN_NETCONNECTION *conn);
    00544
    00545
    00549 GWENHYWFAR_API
    00550 const GWEN_INETADDRESS*
    00551   GWEN_NetConnection_GetPeerAddr(const GWEN_NETCONNECTION *conn);
    00552
    00557 GWENHYWFAR_API
    00558 GWEN_TYPE_UINT32 GWEN_NetConnection_GetFlags(const GWEN_NETCONNECTION *conn);
    00559
    00560
    00565 GWENHYWFAR_API
    00566 GWEN_NETTRANSPORT_STATUS
    00567   GWEN_NetConnection_GetStatus(const GWEN_NETCONNECTION *conn);
    00568
    00569 GWENHYWFAR_API
    00570 void GWEN_NetConnection_SetStatus(GWEN_NETCONNECTION *conn,
    00571                                   GWEN_NETTRANSPORT_STATUS nst);
    00572
    00577 GWENHYWFAR_API
    00578 void GWEN_NetConnection_SetFlags(GWEN_NETCONNECTION *conn,
    00579                                  GWEN_TYPE_UINT32 fl);
    00580
    00587 GWENHYWFAR_API
    00588 GWEN_TYPE_UINT32
    00589   GWEN_NetConnection_GetLibraryMark(const GWEN_NETCONNECTION *conn);
    00590
    00596 GWENHYWFAR_API
    00597 GWEN_TYPE_UINT32
    00598   GWEN_NetConnection_GetUserMark(const GWEN_NETCONNECTION *conn);
    00599
    00605 GWENHYWFAR_API
    00606 void GWEN_NetConnection_SetUserMark(GWEN_NETCONNECTION *conn,
    00607                                     GWEN_TYPE_UINT32 m);
    00608
    00618 GWENHYWFAR_API
    00619 double GWEN_NetConnection_GetIdleTime(const GWEN_NETCONNECTION *conn);
    00620
    00621
    00626 GWENHYWFAR_API
    00627 void GWEN_NetConnection_SetDownAfterSend(GWEN_NETCONNECTION *conn, int i);
    00628
    00633 GWENHYWFAR_API
    00634 int GWEN_NetConnection_GetDownAfterSend(GWEN_NETCONNECTION *conn);
    00635
    00636 GWENHYWFAR_API
    00637 void GWEN_NetConnection_Reset(GWEN_NETCONNECTION *conn);
    00638
    00641 GWENHYWFAR_API
    00642 void GWEN_NetConnection_Dump(const GWEN_NETCONNECTION *conn);
    00643  /* defgroup */
    00645
    00646
    00647 #ifdef __cplusplus
    00648 }
    00649 #endif
    00650
    00651 #endif
    00652
    00653
    00654
    00655
    00656