Logo Search packages:      
Sourcecode: condor version File versions  Download package

Sock Class Reference

#include <sock.h>

Inheritance diagram for Sock:

Stream SafeSock

List of all members.


Detailed Description

The Sock class defines an interface for connection establishment. This interface is implemented with TCP in the ReliSock class and with UDP in the SafeSock class. ReliSock and SafeSock are the only Cedar classes which should be instantiated; however, pointers to the Stream base class are often used at points in the application where it is not important if the underlying medium is TCP or UDP (for example, in a daemon which handles the same commands over both TCP and UDP).

Definition at line 75 of file sock.h.


Public Types

enum  stream_code { internal, external, ascii }
enum  stream_type { file, incore, safe_sock, reli_sock }

Public Member Functions

virtual void allow_one_empty_message ()
int assign (SOCKET=INVALID_SOCKET)
int bind (bool outbound, char *s)
int bind (bool outbound, int port=0, bool loopback=false)
bool bind_to_loopback (bool outbound=false, int port=0)
int bytes_available_to_read ()
virtual StreamCloneStream ()=0
int close ()
int connect (char const *host, char *service, bool do_not_block=false)
virtual int connect (char const *host, int port=0, bool do_not_block=false)=0
bool deadline_expired ()
 returns true if the deadline timeout for this socket has expired
void decode ()
virtual char const * default_peer_description ()
 sinful address of peer, suitable for passing to dprintf() (never NULL)
void doNotEnforceMinimalCONNECT_TIMEOUT ()
void encode ()
virtual int end_of_message ()=0
struct sockaddr_in * endpoint ()
 peer's port and IP address in a struct sockaddr_in.
unsigned int endpoint_ip_int ()
 peer's IP address, integer version (e.g. 2154390801)
const char * endpoint_ip_str ()
 peer's IP address, string verison (e.g. "128.105.101.17")
int endpoint_port ()
 peer's port number
int get (char *, int)
int get (char *&)
int get (MyString &)
int get (double &)
int get (float &)
int get (unsigned short &)
int get (short &)
int get (uint64_t &)
int get (int64_t &)
int get (unsigned long &)
int get (long &)
int get (unsigned int &)
int get (int &)
int get (unsigned char &)
int get (char &)
int get_file_desc ()
 local file descriptor (fd) of this socket
unsigned int get_ip_int ()
 local ip address integer
CondorVersionInfo const * get_peer_version () const
int get_port ()
 local port number
virtual int get_ptr (void *&ptr, char d)=0
int get_secret (char *&s)
char * get_sinful ()
 sinful address of mypoint() in the form of "<a.b.c.d:pppp>"
char * get_sinful_peer ()
 sinful address of peer in form of "<a.b.c.d:pppp>"
int get_string_ptr (char const *&s)
const char * getDomain () const
 Get domain portion of fqu.
const char * getFullyQualifiedUser () const
const char * getOwner () const
 Get user portion of fqu.
virtual int handle_incoming_packet ()=0
 Virtual socket services.
void ignoreTimeoutMultiplier ()
bool is_connect_pending ()
 is a non-blocking connect outstanding?
bool is_connected ()
 is the socket connected?
int is_decode () const
int is_encode () const
int mypoint (struct sockaddr_in *sin)
virtual int peek (char &c)=0
char const * peer_description ()
void prepare_crypto_for_secret ()
bool prepare_crypto_for_secret_is_noop ()
int put (char const *, int)
int put (const MyString &)
int put (char const *)
int put (double)
int put (float)
int put (unsigned short)
int put (short)
int put (uint64_t)
int put (int64_t)
int put (unsigned long)
int put (long)
int put (unsigned int)
int put (int)
int put (unsigned char)
int put (char)
int put_secret (char const *)
bool readReady ()
stream_code representation () const
void restore_crypto_after_secret ()
virtual const char * sender_ip_str ()
 my IP address, string version (e.g. "128.105.101.17")
int set_async_handler (CedarHandler *handler)
void set_deadline (time_t t)
void set_deadline_timeout (int t)
int set_os_buffers (int desired_size, bool set_write_buf=false)
void set_peer_description (char const *str)
void set_peer_version (CondorVersionInfo const *version)
 Set the peer's version.
void set_representation (stream_code c)
void setFullyQualifiedUser (char const *fqu)
int setsockopt (int, int, const char *, int)
void setTriedAuthentication (bool toggle)
 Sock (const Sock &)
 Copy constructor -- this also dups the underlying socket.
int timeout (int sec)
int timeout_no_timeout_multiplier (int sec)
bool triedAuthentication () const
virtual stream_type type ()=0
Pointer Types.
Allow pointers instead of references to ease XDR compatibility

int code (struct utsname *x)
int code (struct rlimit *x)
int code (struct utimbuf *x)
int code (struct timeval *x)
int code (struct timezone *x)
int code (struct statfs *x)
int code (struct rusage *x)
int code (fcntl_cmd_t *x)
int code (condor_signal_t *x)
int code (condor_errno_t *x)
int code (open_flags_t *x)
int code (struct stat *x)
int code (StartdRec *x)
int code (PORTS *x)
int code (STARTUP_INFO *x)
int code (PROC_ID *x)
int code (double *x)
int code (float *x)
int code (unsigned short *x)
int code (short *x)
int code (unsigned long *x)
int code (long *x)
int code (unsigned int *x)
int code (int *x)
int code (unsigned char *x)
UNIX Types
int code (condor_mode_t &)
int code (struct utsname &)
int code (struct rlimit &)
int code (struct utimbuf &)
int code (struct timeval &)
int code (struct timezone &)
int code (struct statfs &)
int code (struct rusage &)
int code (fcntl_cmd_t &)
int code (condor_signal_t &)
int code (condor_errno_t &)
int code (struct stat &)
int code (open_flags_t &)
int code_array (gid_t *&array, int &len)
Condor Types
int code (StartdRec &)
int code (PORTS &)
int code (STARTUP_INFO &)
int code (PROC_ID &)
Basic Types
int code (char *&, int &)
int code (MyString &)
int code (char *&)
int code (double &)
int code (float &)
int code (unsigned short &)
int code (short &)
int code (uint64_t &)
int code (int64_t &)
int code (unsigned long &)
int code (long &)
int code (unsigned int &)
int code (int &)
int code (unsigned char &)
int code (char &)
int code (void *&)
int code_bytes (void *, int)
int code_bytes_bool (void *, int)
Byte Operations. Virtually defined by each stream
virtual int get_bytes (void *data, int maxn)=0
virtual int put_bytes (const void *data, int n)=0
Condor Compatibility Ops
bool get_encryption () const
virtual const char * isIncomingDataMD5ed ()=0
bool isOutgoing_MD5_on () const
int rcv_int (int &val, int end_of_record)
bool set_crypto_key (bool enable, KeyInfo *key, const char *keyId=0)
void set_crypto_mode (bool enable)
bool set_MD_mode (CONDOR_MD_MODE mode, KeyInfo *key=0, const char *keyid=0)
int snd_int (int val, int end_of_record)
bool unwrap (unsigned char *input, int input_len, unsigned char *&output, int &outputlen)
bool wrap (unsigned char *input, int input_len, unsigned char *&output, int &outputlen)

Static Public Member Functions

static int get_timeout_multiplier ()
static int set_timeout_multiplier (int secs)

Protected Types

enum  sock_state {
  sock_virgin, sock_assigned, sock_bound, sock_connect,
  sock_writemsg, sock_readmsg, sock_special, sock_connect_pending,
  sock_connect_pending_retry
}
enum  stream_coding { stream_decode, stream_encode, stream_unknown }

Protected Member Functions

virtual int authenticate (KeyInfo *&ki, const char *auth_methods, CondorError *errstack, int timeout)
virtual int authenticate (const char *auth_methods, CondorError *errstack, int timeout)
time_t connect_timeout_time ()
 get timeout time for pending connect operation;
int do_connect (char const *host, int port, bool non_blocking_flag=false)
virtual int encrypt (bool)
const KeyInfo & get_crypto_key () const
virtual time_t get_deadline ()
const KeyInfo & get_md_key () const
SOCKET get_socket (void)
int getportbyserv (char *)
virtual int hdr_encrypt ()
virtual bool init_MD (CONDOR_MD_MODE mode, KeyInfo *key, const char *keyId)=0
virtual bool is_encrypt ()
virtual bool is_hdr_encrypt ()
int move_descriptor_up ()
void resetCrypto ()
char * serialize () const
char * serialize (char *)
char * serializeCryptoInfo () const
char * serializeCryptoInfo (char *buf)
char * serializeMdInfo () const
char * serializeMdInfo (char *buf)
virtual bool set_encryption_id (const char *keyId)=0
int set_inheritable (int)
bool test_connection ()

Protected Attributes

stream_code _code
stream_coding _coding
char * _fqu
char * _fqu_domain_part
char * _fqu_user_part
char _sender_ip_buf [IP_STRING_BUF_SIZE]
SOCKET _sock
sock_state _state
int _timeout
bool _tried_authentication
struct sockaddr_in _who
int allow_empty_message_flag
Condor_Crypt_Base * crypto_
bool crypto_mode_
char * decrypt_buf
int decrypt_buf_len
bool encrypt_
bool ignore_connect_timeout
bool ignore_timeout_multiplier
bool m_crypto_state_before_secret
time_t m_deadline_time
char * m_peer_description_str
CondorVersionInfom_peer_version
KeyInfo * mdKey_
CONDOR_MD_MODE mdMode_

Static Protected Attributes

static int timeout_multiplier = 0

Private Member Functions

int _bind_helper (int fd, SOCKET_ADDR_CONST_BIND SOCKET_ADDR_TYPE addr, SOCKET_LENGTH_TYPE len, bool outbound, bool loopback)
int _condor_read (SOCKET fd, char *buf, int sz, int timeout)
int _condor_write (SOCKET fd, char *buf, int sz, int timeout)
int bindWithin (const int low, const int high, bool outbound)
void cancel_connect ()
int do_connect_finish ()
bool do_connect_tryit ()
void reportConnectionFailure (bool timed_out)
void setConnectFailureErrno (int error, char const *syscall)
void setConnectFailureReason (char const *reason)

Private Attributes

char _endpoint_ip_buf [IP_STRING_BUF_SIZE]
char _sinful_peer_buf [SINFUL_STRING_BUF_SIZE]
char _sinful_self_buf [SINFUL_STRING_BUF_SIZE]
struct Sock::connect_state_struct connect_state

Friends

class Daemon
class DaemonCore
class SecMan
class SecManStartCommand

Classes

struct  connect_state_struct

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index