parser: Add parser for Min-Expires
authorAlex Hermann <alex@speakup.nl>
Tue, 5 Jul 2016 09:45:41 +0000 (11:45 +0200)
committerAlex Hermann <alex@speakup.nl>
Thu, 28 Jul 2016 12:02:33 +0000 (14:02 +0200)
parser/case_min.h
parser/hf.c
parser/hf.h
parser/msg_parser.c
parser/msg_parser.h
sip_msg_clone.c

index 56231c3..e09f4ac 100644 (file)
 #define CASE_MIN_H
 
 
-#define min_se_CASE                  \
-        if (LOWER_BYTE(*p) == 's') {                       \
-                p++;                                       \
-                if (LOWER_BYTE(*p) == 'e') {               \
-                        hdr->type = HDR_MIN_SE_T;          \
-                        p++;                               \
-                        goto dc_end;                       \
-                }                                          \
-        }
-
-
-#define min_CASE       \
-     p += 4;           \
-     val = READ(p);    \
-     min_se_CASE;      \
-     goto other;       \
+#define RES_CASE                            \
+       switch(LOWER_DWORD(val)) {              \
+               case _res1_:    /* "res:" */        \
+                       hdr->type = HDR_MIN_EXPIRES_T;  \
+                       hdr->name.len = 11;             \
+                       return (p + 4);                 \
+               case _res2_:    /* "res " */        \
+                       hdr->type = HDR_MIN_EXPIRES_T;  \
+                       p+=4;                           \
+                       goto dc_end;                    \
+       }
+
+#define MIN2_CASE                           \
+       if (LOWER_BYTE(*p) == 's') {            \
+               p++;                                \
+               if (LOWER_BYTE(*p) == 'e') {        \
+                       hdr->type = HDR_MIN_SE_T;       \
+                       p++;                            \
+                       goto dc_end;                    \
+               }                                   \
+       } else if (LOWER_DWORD(val) == _expi_) { \
+               p += 4;                             \
+               val = READ(p);                      \
+               RES_CASE;                           \
+       }
+
+#define min_CASE                            \
+       p += 4;                                 \
+       val = READ(p);                          \
+       MIN2_CASE;                              \
+       goto other;
 
 
 #endif /* CASE_MIN_H */
index 3f2f879..2ff94d0 100644 (file)
@@ -98,6 +98,10 @@ void clean_hdr_field(struct hdr_field* const hf)
                        free_expires((exp_body_t**)h_parsed);
                        break;
 
+               case HDR_MIN_EXPIRES_T:
+                       free_expires((exp_body_t**)h_parsed);
+                       break;
+
                case HDR_FROM_T:
                        free_to(hf->parsed);
                        break;
index 03b1ec7..0dc25c9 100644 (file)
@@ -65,6 +65,7 @@ enum _hdr_types_t {
        HDR_CONTENTLENGTH_T                            /*!< Content-Length header field */,
        HDR_AUTHORIZATION_T                            /*!< Authorization header field */,
        HDR_EXPIRES_T                                  /*!< Expires header field */,
+       HDR_MIN_EXPIRES_T                              /*!< Min-Expires header */,
        HDR_PROXYAUTH_T                                /*!< Proxy-Authorization hdr field */,
        HDR_SUPPORTED_T                                /*!< Supported  header field */,
        HDR_REQUIRE_T                                  /*!< Require header */,
@@ -137,6 +138,7 @@ typedef unsigned long long hdr_flags_t;
 #define HDR_CONTENTLENGTH_F                    HDR_F_DEF(CONTENTLENGTH)
 #define HDR_AUTHORIZATION_F                    HDR_F_DEF(AUTHORIZATION)
 #define HDR_EXPIRES_F                          HDR_F_DEF(EXPIRES)
+#define HDR_MIN_EXPIRES_F                      HDR_F_DEF(MIN_EXPIRES)
 #define HDR_PROXYAUTH_F                                HDR_F_DEF(PROXYAUTH)
 #define HDR_SUPPORTED_F                                HDR_F_DEF(SUPPORTED)
 #define HDR_REQUIRE_F                          HDR_F_DEF(REQUIRE)
@@ -217,6 +219,7 @@ static inline int hdr_allocs_parse(struct hdr_field* hdr)
                case HDR_DIVERSION_T:
                case HDR_EVENT_T:
                case HDR_EXPIRES_T:
+               case HDR_MIN_EXPIRES_T:
                case HDR_FROM_T:
                case HDR_IDENTITY_INFO_T:
                case HDR_IDENTITY_T:
index 21b3cc2..86897a9 100644 (file)
@@ -212,6 +212,7 @@ char* get_hdr_field(char* const buf, char* const end, struct hdr_field* const hd
                case HDR_MAXFORWARDS_T:
                case HDR_AUTHORIZATION_T:
                case HDR_EXPIRES_T:
+               case HDR_MIN_EXPIRES_T:
                case HDR_PROXYAUTH_T:
                case HDR_PROXYREQUIRE_T:
                case HDR_UNSUPPORTED_T:
@@ -406,6 +407,10 @@ int parse_headers(struct sip_msg* const msg, const hdr_flags_t flags, const int
                                if (msg->expires==0) msg->expires = hf;
                                msg->parsed_flag|=HDR_EXPIRES_F;
                                break;
+                       case HDR_MIN_EXPIRES_T:
+                               if (msg->min_expires==0) msg->min_expires = hf;
+                               msg->parsed_flag|=HDR_MIN_EXPIRES_F;
+                               break;
                        case HDR_PROXYAUTH_T:
                                if (msg->proxy_auth==0) msg->proxy_auth = hf;
                                msg->parsed_flag|=HDR_PROXYAUTH_F;
index c4e426a..84604a9 100644 (file)
@@ -318,6 +318,7 @@ typedef struct sip_msg {
        struct hdr_field* ppi;
        struct hdr_field* path;
        struct hdr_field* privacy;
+       struct hdr_field* min_expires;
 
        struct msg_body* body;
 
index e736b7b..048ef77 100644 (file)
@@ -442,6 +442,7 @@ struct sip_msg*  sip_msg_shm_clone( struct sip_msg *org_msg, int *sip_msg_len,
                case HDR_CONTENTLENGTH_T:
                case HDR_RETRY_AFTER_T:
                case HDR_EXPIRES_T:
+               case HDR_MIN_EXPIRES_T:
                case HDR_SUPPORTED_T:
                case HDR_REQUIRE_T:
                case HDR_PROXYREQUIRE_T:
@@ -772,6 +773,11 @@ struct sip_msg*  sip_msg_shm_clone( struct sip_msg *org_msg, int *sip_msg_len,
                                new_msg->expires = new_hdr;
                        }
                        break;
+               case HDR_MIN_EXPIRES_T:
+                       if (!HOOK_SET(min_expires)) {
+                               new_msg->min_expires = new_hdr;
+                       }
+                       break;
                case HDR_PROXYAUTH_T:
                        if (!HOOK_SET(proxy_auth)) {
                                new_msg->proxy_auth = new_hdr;