netatalk  4.5.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
dsi_tcp.c File Reference
#include <arpa/inet.h>
#include <errno.h>
#include <net/if.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <atalk/logger.h>
#include <tcpd.h>
#include <atalk/dsi.h>
#include <atalk/compat.h>
#include <atalk/util.h>
#include <atalk/errchk.h>

Macros

#define min(a, b)   ((a) < (b) ? (a) : (b))
 
#define DSI_TCPMAXPEND   20
 
#define DSI_TCPTIMEOUT   120
 
#define SOCKLEN_T   unsigned int
 
#define IFF_SLAVE   0
 
#define SOL_TCP   IPPROTO_TCP
 
#define AI_NUMERICSERV   0
 

Functions

static void dsi_tcp_close (DSI *dsi)
 
static void timeout_handler (int sig)
 
static void dsi_init_buffer (DSI *dsi)
 
void dsi_free (DSI *dsi)
 
static pid_t dsi_tcp_open (DSI *dsi)
 
static void guess_interface (DSI *dsi, const char *hostname, const char *port)
 
static int dsi_tcp_listen (const char *address, const char *port, struct addrinfo *hints, DSI *dsi, bool *psocket_err_afnotsup)
 
int dsi_tcp_init (DSI *dsi, const char *hostname, const char *inaddress, const char *inport)
 Initialize DSI over TCP.
 

Variables

int allow_severity = log_info
 
int deny_severity = log_warning
 
static struct itimerval itimer
 

Macro Definition Documentation

◆ AI_NUMERICSERV

#define AI_NUMERICSERV   0

◆ DSI_TCPMAXPEND

#define DSI_TCPMAXPEND   20

max # of pending connections

◆ DSI_TCPTIMEOUT

#define DSI_TCPTIMEOUT   120

timeout in seconds for connections

◆ IFF_SLAVE

#define IFF_SLAVE   0

◆ min

#define min (   a,
 
)    ((a) < (b) ? (a) : (b))

◆ SOCKLEN_T

#define SOCKLEN_T   unsigned int

◆ SOL_TCP

#define SOL_TCP   IPPROTO_TCP

Function Documentation

◆ dsi_free()

void dsi_free ( DSI dsi)

Free any allocated resources of the master afpd DSI objects and close server socket

◆ dsi_init_buffer()

static void dsi_init_buffer ( DSI dsi)
static

Allocate DSI read buffer and read-ahead buffer

◆ dsi_tcp_close()

static void dsi_tcp_close ( DSI dsi)
static

◆ dsi_tcp_init()

int dsi_tcp_init ( DSI dsi,
const char *  hostname,
const char *  inaddress,
const char *  inport 
)

Initialize DSI over TCP.

Parameters
[in,out]dsiDSI handle
[in]hostnamepointer to hostname string
[in]inaddressOptional IPv4 or IPv6 address with an optional port, may be NULL
[in]inportpointer to port string

Creates listening AFP/DSI socket. If the parameter inaddress is NULL, then we listen on the wildcard address, i,e, on all interfaces. That should mean listening on the IPv6 address "::" on IPv4/IPv6 dual stack kernels, accepting both v4 and v6 requests.

If the parameter inaddress is not NULL, then we only listen on the given address. The parameter may contain a port number using the URL format for address and port:

IPv4, IPv4:port, IPv6, [IPv6], [IPv6]:port

Parameter inport must be a valid pointer to a port string and is used if the inaddress parameter doesn't contain a port.

Returns
0 on success, -1 on failure

◆ dsi_tcp_listen()

static int dsi_tcp_listen ( const char *  address,
const char *  port,
struct addrinfo *  hints,
DSI dsi,
bool *  psocket_err_afnotsup 
)
static

◆ dsi_tcp_open()

static pid_t dsi_tcp_open ( DSI dsi)
static

accept the socket and do a little sanity checking

◆ guess_interface()

static void guess_interface ( DSI dsi,
const char *  hostname,
const char *  port 
)
static

◆ timeout_handler()

static void timeout_handler ( int  sig)
static

alarm handler for tcp_open

Variable Documentation

◆ allow_severity

int allow_severity = log_info

◆ deny_severity

int deny_severity = log_warning

◆ itimer

struct itimerval itimer
static