Documentation

Generated on Thu Aug 31 00:02:33 2006

 

Connection.h File Reference

#include "generic.h"
#include "Utilities.h"
#include "Configuration.h"
#include "Log.h"

Include dependency graph for Connection.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


Classes

class  Connection

Defines

#define MEMBER(func, type)

Enumerations

enum  bits { B_SET, B_RESET, B_FLIP }
enum  sets {
  FACT_TYPE, FACT_SIZE, FACT_MODIFY, FACT_UNIQUE,
  FACT_U_MODE, FACT_U_UID, FACT_U_GID, FACT_U_LINK,
  FACT_PERM, DATA_ACCT, BINARY, COMPRESSED,
  PASSIVE, ANONYMOUS, DATA_OPEN, EPSV_ONLY,
  RETR_TRANS, PAM_DONE, FAILURE, TLS_ENABLED,
  TLS_INITED, TLS_PBSZ, TLS_PROT_D
}

Functions

int tls_db_store (void *, gnutls_datum, gnutls_datum)
gnutls_datum tls_db_fetch (void *, gnutls_datum)
int tls_db_delete (void *, gnutls_datum)

Variables

const int LAST_FACT = 8
const int TOTAL_U_BIT = 23
const int READ_SIZE = 16384
vector< pthread_t > cleanup_list
sem_t cleanup_list_lock
gnutls_certificate_credentials x509_cred

Define Documentation

#define MEMBER ( func,
type   ) 

Value:

private: type _##func; \
  public: type func(void){ \
            BABY_RDLOCK(this->lock); \
            type t = _##func; \
            BABY_UNLOCK(this->lock); \
            return t;} \
  public: void func(type var){ \
            BABY_WRLOCK(this->lock); \
            this->_##func = var; \
            BABY_UNLOCK(this->lock); \
          }

Definition at line 43 of file Connection.h.


Enumeration Type Documentation

enum bits

Enumerator:
B_SET 
B_RESET 
B_FLIP 

Definition at line 21 of file Connection.h.

00021 { B_SET, B_RESET, B_FLIP };

enum sets

Enumerator:
FACT_TYPE 
FACT_SIZE 
FACT_MODIFY 
FACT_UNIQUE 
FACT_U_MODE 
FACT_U_UID 
FACT_U_GID 
FACT_U_LINK 
FACT_PERM 
DATA_ACCT 
BINARY 
COMPRESSED 
PASSIVE 
ANONYMOUS 
DATA_OPEN 
EPSV_ONLY 
RETR_TRANS 
PAM_DONE 
FAILURE 
TLS_ENABLED 
TLS_INITED 
TLS_PBSZ 
TLS_PROT_D 

Definition at line 23 of file Connection.h.

00023           { // for mlsx
00024   FACT_TYPE, FACT_SIZE, FACT_MODIFY, FACT_UNIQUE, FACT_U_MODE, FACT_U_UID,
00025   FACT_U_GID, FACT_U_LINK, FACT_PERM,
00026   DATA_ACCT, BINARY, COMPRESSED, PASSIVE, ANONYMOUS, DATA_OPEN, EPSV_ONLY,
00027   RETR_TRANS, PAM_DONE, FAILURE
00028 #ifdef USE_TLS
00029     , TLS_ENABLED, TLS_INITED, TLS_PBSZ, TLS_PROT_D
00030 #endif // USE_TLS
00031 };


Function Documentation

int tls_db_delete ( void *  ,
gnutls_datum   
)

Definition at line 385 of file babyftpd.cpp.

References cache_db, and cache_lock.

Referenced by Connection::engage_tls().

00386 {
00387   int ret = -1;
00388   pthread_rwlock_rdlock(&cache_lock);
00389   for(vector<cache*>::iterator cache_it = cache_db.begin();
00390       cache_it != cache_db.end(); cache_it++)
00391     if(memcmp(key.data, (*cache_it)->key.data, (*cache_it)->key.size) == 0)
00392     {
00393       pthread_rwlock_unlock(&cache_lock);
00394       pthread_rwlock_wrlock(&cache_lock);
00395       gnutls_free((*cache_it)->key.data);
00396       gnutls_free((*cache_it)->data.data);
00397       delete(*cache_it);
00398       cache_db.erase(cache_it);
00399       ret = 0;
00400       break;
00401     }
00402   pthread_rwlock_unlock(&cache_lock);
00403 
00404   return(ret);
00405 }

gnutls_datum tls_db_fetch ( void *  ,
gnutls_datum   
)

Definition at line 366 of file babyftpd.cpp.

References cache_db, cache_lock, and cache::data.

Referenced by Connection::engage_tls().

00367 {
00368   gnutls_datum data = { NULL, 0 };
00369 
00370   pthread_rwlock_rdlock(&cache_lock);
00371   for(vector<cache*>::iterator cache_it = cache_db.begin();
00372       cache_it != cache_db.end(); cache_it++)
00373     if(memcmp(key.data, (*cache_it)->key.data, (*cache_it)->key.size) == 0)
00374     {
00375       data.size = (*cache_it)->data.size;
00376       data.data = static_cast<unsigned char*>(gnutls_malloc(data.size));
00377       memcpy(data.data, (*cache_it)->data.data, data.size);
00378       break;
00379     }
00380   pthread_rwlock_unlock(&cache_lock);
00381 
00382   return(data);
00383 }

int tls_db_store ( void *  ,
gnutls_datum  ,
gnutls_datum   
)

Definition at line 347 of file babyftpd.cpp.

References cache_db, cache_lock, cache::data, and cache::key.

Referenced by Connection::engage_tls().

00348 {
00349   struct cache *temp_cache = new cache;
00350 
00351   temp_cache->key.data = static_cast<unsigned char*>(gnutls_malloc(key.size));
00352   temp_cache->key.size = key.size;
00353   memcpy(temp_cache->key.data, key.data, key.size);
00354 
00355   temp_cache->data.data =
00356     static_cast<unsigned char*>(gnutls_malloc(data.size));
00357   temp_cache->data.size = data.size;
00358   memcpy(temp_cache->data.data, data.data, data.size);
00359 
00360   pthread_rwlock_wrlock(&cache_lock);
00361   cache_db.push_back(temp_cache);
00362   pthread_rwlock_unlock(&cache_lock);
00363   return(0);
00364 }


Variable Documentation

vector<pthread_t> cleanup_list

Definition at line 45 of file babyftpd.h.

Referenced by exit_baby(), lifebeat(), and Connection::~Connection().

Definition at line 41 of file babyftpd.h.

Referenced by exit_baby(), lifebeat(), main(), and Connection::~Connection().

const int LAST_FACT = 8

Definition at line 33 of file Connection.h.

Referenced by User::User().

const int READ_SIZE = 16384

Definition at line 109 of file Connection.h.

Referenced by Connection::Connection().

const int TOTAL_U_BIT = 23

Definition at line 37 of file Connection.h.

Referenced by Connection::settings().

gnutls_certificate_credentials x509_cred

Definition at line 50 of file babyftpd.h.

Referenced by Connection::engage_tls(), exit_baby(), lifebeat(), and main().