| Создание |
| О компании | Программ | Устройств | Linux |
| Контакты | Обучение |
| Инвестиционные проекты |
LsoL |
Обслуживание | ||||||
| Продукция | Советы | |||||||
Contents:
Overview
Возможности:
Заголовочный файл (хидер) UsageThis is DNS server. It may work throught UDP and TCP protocol. Usualy for UDP using name resolving, but for long size requests, (e.g. AXFR -- download full zone) using TCP. For setup server call SetUDPServer, SetTCPServer. The callback function will call when somebody when somebody required anything from server. The host program may just return zero by this callback, and in this case the server will work with this request (make reply if the host defined, or make recurcive request if recurcion enable). The host program may return the error code, and in this case request will be declined. The host program may make reply withhelp SRVAddReplyRecord , SRVAddARecord, SRVAddAAAARecord, SRVAddPTRRecordm SRVAddMXRecord, SRVAddNSRecord,SRVAddSOARecord,SRVAddSOARecord functions, and then call SRVSendReply, to send it Functiostype of stream ServerStream; 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 flie. 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 understan 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 int SetUDPServer(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 sucess. Subzero if fail 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 sucess. Subzero if fail int SRVAddReplyRecord(ServerStream * stream, void * bufer, int type, int part); Parameters: The stream -- pointer to stream that was transfer to callback function. The bufer -- bufer to send The type -- type of reply The part -- part of reply PART_REQUEST PART_REPLY PART_ADV Return value: Number of bytes in the reply. Zero if error 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 addres 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 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 addres 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 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 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 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 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 original or primary source of data for this zone. rname -- A 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 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 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 ulong GetRemoteIP(ServerStream * stream); Parameters: The stream -- pointer to stream that was transfer to callback function. Return value: IP address of remote. 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 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, int LoadConfig(char * filename="ftp.cfg"); Parameters: The filename -- name of configuration file. Return value: Zero if sucess. Subzero if fail void SetConfigParam(char * param, int val); Parameters: The param -- name of param val -- value. 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: int GetConfigParamInt(char * param); Parameters: The param -- name of param char *SetConfigParamStr(char * param); Parameters: The param -- name of param |