| 71 | |
| 72 | |
| 73 | enum parse_sst_result |
| 74 | parse_session_expires_body( struct hdr_field *hf ) |
| 75 | { |
| 76 | register char *p = hf->body.s; |
| 77 | int pos = 0; |
| 78 | int len = hf->body.len; |
| 79 | char *q; |
| 80 | struct session_expires se = { 0, sst_refresher_unspecified }; |
| 81 | unsigned tok; |
| 82 | |
| 83 | if ( !p || len <= 0 ) { |
| 84 | LM_ERR(" no body for header field\n" ); |
| 85 | return parse_sst_header_not_found; |
| 86 | } |
| 87 | |
| 88 | /* skip whitespace */ |
| 89 | for ( ; pos < len && is_space(*p); ++pos, ++p ) |
| 90 | /*nothing*/; |
| 91 | |
| 92 | /* collect a number */ |
| 93 | for ( q = p; pos < len && is_num(*q); ++pos, ++q ) |
| 94 | se.interval = se.interval*10/*radix*/ + (*q - '0'); |
| 95 | |
| 96 | if ( q == p ) /*nothing parsed */ { |
| 97 | LM_ERR(" no expiry interval\n" ); |
| 98 | return parse_sst_no_value; |
| 99 | } |
| 100 | p = q; |
| 101 | |
| 102 | /* continue on with params */ |
| 103 | while ( pos < len ) { |
| 104 | |
| 105 | if ( *p == ';' ) { |
| 106 | ++p; ++pos; |
| 107 | |
| 108 | if ( pos + 4 < len ) { |
| 109 | switch ( lower_4bytes(read_4bytes(p)) ) { |
| 110 | case /*refr*/MAKE_4BYTES('r','e','f','r'): |
| 111 | if ( pos + 9 <= len |
| 112 | && lower_4bytes(read_4bytes(p+4)) |
| 113 | == /*eshe*/MAKE_4BYTES('e','s','h','e') |
| 114 | && lower_byte(*(p+8)) == 'r' |
| 115 | && *(p+9) == '=' ) { |
| 116 | tok = lower_3bytes( read_3bytes(p+10) ); |
| 117 | if ( tok == MAKE_3BYTES('u','a','c') ) { |
| 118 | se.refresher = sst_refresher_uac; |
| 119 | p += 13; pos += 13; |
| 120 | } |
| 121 | else if ( tok == MAKE_3BYTES('u','a','s') ) { |
| 122 | se.refresher = sst_refresher_uas; |
| 123 | p += 13; pos += 13; |
| 124 | } |
| 125 | else /* unrecognized refresher-param */ { |
| 126 | LM_ERR(" unrecognized refresher\n" ); |
| 127 | return parse_sst_parse_error; |
| 128 | } |
| 129 | } |
| 130 | else /* not "esher=" */ { |
no test coverage detected