type of stream
typedef void * ServerStream;
DNSReqCallback
type for callback function that will call for each request, after request recived, before server do anything other.
typedef int (*
DNSReqCallback)(ServerStream *
stream, char *
reqname, int
action, ...);
Parameters:
The
stream may be used by host program for next request.
The
reqname it is name of requested file.
The
action defined there:
ACTION_REQ_A ACTION_REQ_PTR ACTION_REQ_CNAME ACTION_REQ_MX ACTION_REQ_NS ACTION_REQ_AAAA ACTION_REQ_ANY ACTION_REQ_SOA ACTION_REQ_TXT ACTION_REQ_AXFR ACTION_REQ_UNKNOW
ACTION_REQ_TCP
Return value:
If this callback return zero, the server will still work the request.
If this callback return subzero the server understand that host program
If this callback return value above zero, the server return it to client as error code and return error page.
ALL_ACTIONS
SetUDPServer
The host program must only call SetServer function, that create server thread
int
SetUDPServer(DNSReqCallback
callback=NULL, int
mask=ALL_ACTIONS);
Parameters:
The
callback -- callback function that will call for each request, after request received, before server do anything other
by default NULL -- int this case the server will just work with request.
The
port -- TCP/IP port. If used default value zero, the server use value from config, by default 21.
mask -- the mask for action for that the server call callback
Return value:
Zero if sucess.
Subzero if fail
SetTCPServer
The host program must only call SetServer function, that create server thread
int
SetTCPServer(DNSReqCallback
callback=NULL, int
mask=ALL_ACTIONS);
Parameters:
The
callback -- callback function that will call for each request, after request recived, before server do anything other
by default NULL -- int this case the server will just work with request.
The
port -- TCP/IP port. If used default value zero, the server use value from config, by default 21.
mask -- the mask for action for that the server call callback
Return value:
Zero if success.
Subzero if fail
PART_REQUEST PART_REPLY PART_ADV
SRVAddReplyRecord
The host program may send data to the client CONTROL connection with next functions:
int
SRVAddReplyRecord(ServerStream *
stream, void *
bufer, int
type, int
part);
Parameters:
The
stream -- pointer to stream that was transfer to callback function.
The
buffer -- buffer to send
The
type -- type of reply
The
part -- part of reply
Return value:
Number of bytes in the reply.
Zero if error
SRVAddARecord
The host program may send data to the client CONTROL connection with next functions:
int
SRVAddARecord(ServerStream *
stream, ulong
IP, char *
host=0, int
part=0);
Parameters:
The
stream -- pointer to stream that was transfer to callback function.
IP -- is IP address for reply
host -- is the source host, the default NULL pointer mean that IP for required host
The
part -- part of reply
Return value:
Number of bytes in the reply.
Zero if error
SRVAddAAAARecord
int
SRVAddAAAARecord(ServerStream *
stream, uchar*
IPv6, char *
host=0, int
part=0);
Parameters:
The
stream -- pointer to stream that was transfer to callback function.
IPv6 -- is IPv6 address for reply
host -- is the source host, the default NULL pointer mean that IP for required host
The
part -- part of reply
Return value:
Number of bytes in the reply.
Zero if error
SRVAddMXRecord
The host program may send data to the client CONTROL connection with next functions:
int
SRVAddMXRecord(ServerStream *
stream, char *
mhost, int
priority, char *
host=0, int
part=0);
Parameters:
The
stream -- pointer to stream that was transfer to callback function.
mhost -- is mail host for reply
priority -- is mail host priority
host -- is the source host, the default NULL pointer mean that for required host
The
part -- part of reply
Return value:
Number of bytes in the reply.
Zero if error
SRVAddNSRecord
The host program may send data to the client CONTROL connection with next functions:
int
SRVAddNSRecord(ServerStream *
stream, char *
ns, char *
host=0, int
part=0);
Parameters:
The
stream -- pointer to stream that was transfer to callback function.
ns -- is names server for reply
host -- is the source host, the default NULL pointer mean that for required host
The
part -- part of reply
Return value:
Number of bytes in the reply.
Zero if error
SRVAddCNAMERecord
The host program may send data to the client CONTROL connection with next functions:
int
SRVAddCNAMERecord(ServerStream *
stream, char *
cname, char *
host=0, int
part=0);
Parameters:
The
stream -- pointer to stream that was transfer to callback function.
cname -- is alternate name for reply
host -- is the source host, the default NULL pointer mean that for required host
The
part -- part of reply
Return value:
Number of bytes in the reply.
Zero if error
SRVAddTEXTERecord
int
SRVAddTEXTERecord(ServerStream *
stream, char *
text, char *
host=0, int
part=0);
Parameters:
The
stream -- pointer to stream that was transfer to callback function.
text -- is text for reply
host -- is the source host, the default NULL pointer mean that for required host
The
part -- part of reply
Return value:
Number of bytes in the reply.
Zero if error
The host program may send data to the client CONTROL connection with next functions:
int SRVAddSOARecord(ServerStream *stream,char *mname,
char *rname,char *serial,char *refres, char *retry,
char *expire,char *minimum,
char *host=0);
Parameters:
The
stream -- pointer to stream that was transfer to callback function.
ns -- is names server for reply
mname -- The
of the name server that was the
original or primary source of data for this zone.
rname -- A which specifies the mailbox of the
person responsible for this zone.
serial -- The unsigned 32 bit version number of the original copy
of the zone. Zone transfers preserve this value. This
value wraps and should be compared using sequence space
arithmetic.
refresh -- A 32 bit time interval before the zone should be
refreshed .
retry -- A 32 bit time interval that should elapse before a
failed refresh should be retried.
expire -- A 32 bit time value that specifies the upper limit on
the time interval that can elapse before the zone is no
longer authoritative.
minimum -- The unsigned 32 bit minimum TTL field that should be
exported with any RR from this zone.
Return value:
Number of bytes in the reply.
Zero if error
SRVAddPTRRecord
The host program may send data to the client CONTROL connection with next functions:
int SRVAddPTRRecord(ServerStream * stream, char * ptr, char * host=0, int part=0);
Parameters:
The stream -- pointer to stream that was transfer to callback function.
ns -- is names server for reply
host -- is the source host, the default NULL pointer mean that IP for required host
The part -- part of reply
Return value:
Number of bytes in the reply.
Zero if error
SRVSendReply
The host program may send data to the client DATA conection with next functions:
int SRVSendReply(ServerStream * stream);
Parameters:
The stream -- pointer to stream that was transfer to callback function.
Return value:
Number of bytes that has been send.
Zero if error
GetRemoteIP
Advanced info about connection you may get with next functions.
ulong GetRemoteIP(ServerStream * stream);
Parameters:
The stream -- pointer to stream that was transfer to callback function.
Return value:
IP address of remote.
GetRemoteAddr
int GetRemoteAddr(void * addr, int buflen);
Parameters:
The stream -- pointer to stream that was transfer to callback function.
Return value:
address of remote in sockaddr struct
GetSocket
int GetSocket(ServerStream * stream);
Parameters:
The stream -- pointer to stream that was transfer to callback function.
Return value:
socket
The host program may load all params for module from separate file,
LoadConfig
or my set required params directly, or use default values.
int LoadConfig(char * filename="ftp.cfg");
Parameters:
The filename -- name of configuration file.
Return value:
Zero if success.
Subzero if fail
SetConfigParam
You may set all params directly:
void SetConfigParam(char * param, int val);
Parameters:
The param -- name of param
val -- value.
SetConfigParam
void SetConfigParam(char * param, char * val);
Parameters:
The param -- name of param
val -- value.
To get current values of configuration params you may use next functions:
GetConfigParamInt
For integer params:
int GetConfigParamInt(char * param);
Parameters:
The param -- name of param
SetConfigParamStr
For string params:
char *SetConfigParamStr(char * param);
Parameters:
The param -- name of param