5.1.1 主要的结构体--SMTPD_STATE

来源:互联网 发布:阿菲金软件配置 编辑:程序博客网 时间:2024/06/06 05:34

SMTPD_STATE是smtpd模块的核心结构体,该结构体很大(120多行),所以我们仅列一下主要的属性:

 

         VSTREAM*client;                      /* SMTPclient handle */

         网络或标准输入流。

        

         VSTRING*buffer;                       /* SMTPclient buffer */

         内容缓存。

 

         VSTRING*addr_buf;                           /*internalized address buffer */

地址缓存,缓存处理过程中的收件人和发件人地址,该缓存地址最终会被写入收件人或发件人字段:

state->sender= mystrdup(STR(state->addr_buf));

 

char   *service;                        /*for event rate control */

anvil模块使用的服务名。

 

struct timevalarrival_time;    /* start of MAIL FROMtransaction */

MAIL命令处理函数mail_cmd中记录的MAIL命令处理时间:

GETTIMEOFDAY(&state->arrival_time);

宏GETTIMEOFDAY即函数gettimeofday。

 

         char   *name;                          /*verified client hostname */

客户端主机名。

客户端主机名通过HELO/EHLO命令得到。

如果无法得到,则置为unknow:

state->name= mystrdup(CLIENT_NAME_UNKNOWN);

state->reverse_name= mystrdup(CLIENT_NAME_UNKNOWN);

如果是非网络客户,则置为localhost:

/*

    * If it's not Internet, assume the client is local, and avoid using the

    * naming service because that can hang when the machine is disconnected.

     */

state->name= mystrdup("localhost");

state->reverse_name= mystrdup("localhost");

 

         char   *addr;                            /*client host address string */

   char   *port;                    /* port for logging */

char   *namaddr;                    /*name[address]:port */

客户端地址和端口相关信息,客户端ip通过getpeername函数取得。

 

         int     conn_count;                         /* connections from this client */

int     conn_rate;                            /*connection rate for this client */

客户端连接数和连接频率统计。

 

int     error_count;               /* reset after DOT */

错误统计。

 

int     notify_mask;               /* what to report to postmaster */

notify_class参数信息掩码。该参数记录将发给postmaster邮件管理员的错误信息。

 

char   *helo_name;                         /*client HELO/EHLO argument */

helo/ehlo命令参数值。

 

char   *queue_id;                    /*from cleanup server/queue file */

队列id:

state->queue_id= mystrdup(state->dest->id);

 

VSTREAM*cleanup;                           /*cleanup server/queue file handle */

和cleanup模块通信的流:

         state->cleanup= state->dest->stream;

 

         MAIL_STREAM*dest;                        /* anotherserver/file handle */

         和cleanup模块通信的MAIL_STREAM流:

state->dest= mail_stream_service(MAIL_CLASS_PUBLIC,

                                                 var_cleanup_service);

        

         int     rcpt_count;                           /* number of accepted recipients */

         收信地址数。

 

         ARGV   *history;                     /*protocol transcript */

         命令历史记录。在smtpd_chat_query和smtpd_chat_replay函数中通过smtp_chat_append函数记录,也即每当从客户端读取到信息或向客户端发送信息后,都要做历史记录:

argv_add(state->history,line, (char *) 0);

        

         char   *sender;                        /*sender address */

         发件人地址。

 

         char   *encoding;                    /*owned by mail_cmd() */

         在mail_cmd命令解析函数中记录MAIL命令的BODY扩展参数的值。

 

         char   *verp_delims;              /* owned by mail_cmd() */

         如果mail_cmd命令有XVERP扩展参数,该值置为1。

 

         char   *recipient;                    /*recipient address */

         收件人地址。

 

         char   *etrn_name;                         /*client ETRN argument */

         ETRN命令参数值。当服务器由于网络原因累积大量无法发送的邮件时,由flush模块记录各网域累积邮件列表,ETRN命令可以快速清空队列中的邮件。

 

         char   *protocol;                     /*SMTP or ESMTP */

protocol:协议名,SMTP或ESMTP。

        

         char   *where;                         /* protocol stage */

         在smtp协议解析个阶段记录当前的解析阶段。

 

         off_t   msg_size;                     /*MAIL FROM message size */

         MAIL命令传入的SIZE参数的值。

 

         off_t   act_size;                       /*END-OF-DATA message size */

         data命令传入的一行邮件信息的大小。

 

         int     junk_cmds;                           /*counter */

         NOOP、VRFY、ETRN、RSET命令数统计。

 

         int     rcpt_overshoot;                  /* counter */

         smtpd_recipient_overshoot_limit参数值。

 

         char   *rewrite_context;                /* address rewriting context */

         trivial-rewrite模块使用,值为local或remote。

 

         int     sender_rcptmap_checked;        /* sender validated against maps */

         saved_flags相关字段,为smtpd acl所使用。

 

         VSTRING*expand_buf;            /* scratch spacefor $name expansion */

         为进行5.6.8节指令是否符合流水线规则的判断而开辟的空间。

 

         char   *dsn_envid;                           /*temporary MAIL FROM state */

   int     dsn_ret;                       /* temporary MAIL FROMstate */

   VSTRING *dsn_buf;                   /*scratch space for xtext expansion */

VSTRING*dsn_orcpt_buf;                /* scratchspace for ORCPT parsing */

记录dsn扩展参数相关信息。dsn扩展参数有RET,ENVID,NOTIFY,ORCPT四个,见1.5.1。
0 0