nightmaremail

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

mxf-remote.h.sav (3225B)


      1 #ifndef MXF_REMOTE_H
      2 #define MXF_REMOTE_H
      3 
      4 #include "controls.h"
      5 // Needs control.o from qmail
      6 #ifndef USING_SKALIBS
      7 #error "You must use skalibs, s6-networking and s6-dns for Nightmare Remote."
      8 #else
      9 #include <limits.h>
     10 #include <skalibs/ip46.h>
     11 #include <skalibs/tai.h>
     12 #include <skalibs/types.h>
     13 #include <skalibs/iopause.h>
     14 #include <skalibs/stralloc.h>
     15 #include <skalibs/genalloc.h>
     16 #include <skalibs/socket.h>
     17 #include <s6-dns/s6dns.h>
     18 #include <s6-dns/skadns.h>
     19 
     20 
     21 #ifndef UCSPITLSC
     22 #define UCSPITLSC "/package/net/s6-networking/command/s6-ucspitlsc"
     23 #endif
     24 
     25 #ifndef TLSC
     26 #define TLSC "/package/net/s6-networking/command/s6-tlsc"
     27 #endif
     28 
     29 #ifndef TCPCLIENT
     30 #define TCPCLIENT "/package/net/s6-networking/command/s6-tcpclient"
     31 #endif
     32 
     33 // expected to be in PATH and to be ucspi client tools
     34 #ifndef QMTP_CLIENT
     35 #define QMTP_CLIENT "mxf-remote-qmtpc"
     36 #endif
     37 
     38 #ifndef SMTP_CLIENT
     39 #define SMTP_CLIENT "mxf-remote-smtpc"
     40 #endif
     41 
     42 #define DIE_RESOURCES	111
     43 #define DIE_BADPROTO	100
     44 //#define DIE_
     45 
     46 // Only use these on verified MXPS distances!
     47 // xmxps_prio will never be used, it is just an example
     48 //#define _xmxps_prio(distance)	(((distance - MXPS_MAGIC_NO) & 0xfff0) >> 4)
     49 #define _mxps_prio(distance)	((distance & 0x00f0) >> 4)
     50 #define _mxps_slice(distance)	(distance & 0x000f)
     51 #define _is_mxps(distance)		((distance + 1 > MXPS_MAGIC_NO) && (distance - 1 < MXPS_END))
     52 
     53 #define MXPS_MAGIC_NO	0x3200
     54 #define MXPS_END		0x32ff
     55 #define SRV_TCP			"tcp"
     56 #define SRV_RQMTP		"qmtp-relay"
     57 #define SRV_QMTP		"qmtp"
     58 #define SRV_RQMTPS		"qmtps-relay"
     59 #define SRV_QMTPS		"qmtps"
     60 #define SRV_SMTP		"smtp"
     61 #define SRV_RSMTP		"smtp-relay"
     62 #define SRV_SMTPS		"smtps" // officially deregistered by IANA; continued here
     63 #define SRV_RSMTPS		"smtps-relay"
     64 #define SLICE_SRV_SMTP	0x010 // all +32 from the kosher slices
     65 #define SLICE_SRV_QMTP	0x011
     66 #define SLICE_SRV_SMTPS	0x012
     67 #define SLICE_SRV_QMTPS	0x013
     68 #define SLICE_SMTP		0x00
     69 #define SLICE_QMTP		0x01
     70 #define SLICE_SMTPS		0x02 // we propose the use of 2 and 3 for -s versions of protocols.
     71 #define SLICE_QMTPS		0x03
     72 #define NOMXPS_SLICE	0x0
     73 
     74 // defaults, in case not a SRV record
     75 #define SMTP_PORT	25
     76 #define SMTPS_PORT	465	// Should be all but extinct; most SMTPS servers support STARTTLS
     77 #define QMTP_PORT	209
     78 #define QMTPS_PORT	6209 // Not extinct at all; QMTP has no STARTTLS support and will never grow it.
     79 
     80 #define FALSE	0
     81 #define TRUE	1
     82 
     83 typedef struct {
     84 	//unsigned int	slice:4; // plain mx = 0
     85 	char			srvservice[64];
     86 	char			tool[PATH_MAX];
     87 	unsigned int	starttls:1; // UCSPITLSC
     88 	unsigned int	tls:1; // TLSC
     89 } protocol_t;
     90 
     91 typedef struct {
     92 	uint16_t		port;
     93 	uint16_t		weight; // 0 for MX and A/AAAA; as published for SRV
     94 	char			name[256]; // may be a hostname or an IP; will not contain ports or priorities.
     95 	//unsigned int	isv6:1;
     96 } mxresult_t; // stores processed results; SRV hostnames and ports, MX hostnames and ports, IPs (A/AAAA legacy)
     97 
     98 typedef struct {
     99 	uint32_t	prio; // lower is to try sooner; we want a 32 bit value to apply slice-based offsets ((ffff-slice)<<16; try higher slice numbers sooner)
    100 	genalloc	mxresults; // should be of type mxresult_t
    101 } mxprio_t;
    102 
    103 extern protocol_t protocols[32]; // 16 slices, plus the 4 SRV pseudo slices plus unknown more
    104 
    105 #endif