63 } |
63 } |
64 |
64 |
65 BPQBlock::~BPQBlock() |
65 BPQBlock::~BPQBlock() |
66 { |
66 { |
67 log_info_p(LOG, "BPQBlock: destructor"); |
67 log_info_p(LOG, "BPQBlock: destructor"); |
68 //TODO |
|
69 /* |
|
70 if ( query_val_ != NULL ){ |
68 if ( query_val_ != NULL ){ |
71 free(query_val_); |
69 free(query_val_); |
72 query_val_ = NULL; |
70 query_val_ = NULL; |
73 } |
71 } |
|
72 } |
|
73 /* |
|
74 int |
|
75 BPQBlock::format(char* buf, size_t sz) const |
|
76 { |
|
77 if ( kind_ == KIND_QUERY ) { |
|
78 return snprintf (buf, sz, "BPQ Query [%s] Matching Rule [%d]", |
|
79 query_val_, |
|
80 matching_rule_); |
|
81 } else if ( kind_ == KIND_RESPONSE ) { |
|
82 return snprintf (buf, sz, "BPQ Response [%s] Matching Rule [%d]", |
|
83 query_val_, |
|
84 matching_rule_); |
|
85 } else |
|
86 return snprintf (buf, sz, "INVALID BPQ KIND [%d]", kind_); |
|
87 } |
|
88 } |
|
89 |
|
90 void |
|
91 BPQBlock::format_verbose(oasys::StringBuffer* buf) const |
|
92 { |
|
93 if ( kind_ == KIND_QUERY ) |
|
94 buf->appendf(" BPQ Query:\n"); |
|
95 else if ( kind_ == KIND_RESPONSE ) |
|
96 buf->appendf(" BPQ Response:\n"); |
|
97 |
|
98 buf->appendf("Matching Rule: %d\n", matching_rule_); |
|
99 buf->appendf(" Query Length: %d\n", query_len_); |
|
100 buf->appendf(" Query Value: %s\n", query_val_); |
|
101 buf->appendf("\n"); |
|
102 |
|
103 } |
74 */ |
104 */ |
75 } |
|
76 |
|
77 int |
105 int |
78 BPQBlock::write_to_buffer(u_char* buf, size_t len) |
106 BPQBlock::write_to_buffer(u_char* buf, size_t len) |
79 { |
107 { |
80 int encoding_len=0; |
108 int encoding_len=0; |
81 u_int i=0, j=0; |
109 u_int i=0, j=0; |
129 len += SDNV::encoding_len(0); // todo: frag len |
157 len += SDNV::encoding_len(0); // todo: frag len |
130 return len; |
158 return len; |
131 } |
159 } |
132 |
160 |
133 bool |
161 bool |
134 BPQBlock::match(BPQBlock* other) const |
162 BPQBlock::match(const BPQBlock* other) const |
135 { |
163 { |
|
164 /* |
136 log_debug_p(LOG, "_BPQ_ Match: this(%s) other(%s)", |
165 log_debug_p(LOG, "_BPQ_ Match: this(%s) other(%s)", |
137 (char*)query_val_, |
166 (char*)query_val_, |
138 (char*)other->query_val()); |
167 (char*)other->query_val()); |
139 |
168 */ |
140 return query_len_ == other->query_len() && |
169 return query_len_ == other->query_len() && |
141 strncmp( (char*)query_val_, (char*)other->query_val(), |
170 strncmp( (char*)query_val_, (char*)other->query_val(), |
142 query_len_ ) == 0; |
171 query_len_ ) == 0; |
143 } |
172 } |
144 |
173 |
145 int |
174 int |
146 BPQBlock::initialise(BlockInfo* block) |
175 BPQBlock::initialise(BlockInfo* b) |
147 { |
176 { |
|
177 ASSERT ( b != NULL); |
|
178 |
|
179 BlockInfo* block = NULL; |
|
180 |
|
181 if ( b->source() != NULL ) { |
|
182 block = const_cast<BlockInfo*>(b->source()); |
|
183 } else { |
|
184 block = b; |
|
185 } |
|
186 |
148 int decoding_len=0; |
187 int decoding_len=0; |
149 u_int i=0, j=0; |
188 u_int i=0, j=0; |
150 u_int len = block->data_length(); |
189 u_int len = block->data_length(); |
151 u_int num_frags; |
190 u_int num_frags; |
152 u_char* buf = block->data(); |
191 u_char* buf = block->data(); |