MCPcopy Create free account
hub / github.com/3proxy/3proxy / icq_srv

Function icq_srv

src/icqpr.c:183–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181
182
183static FILTER_ACTION icq_srv(void *fc, struct clientparam * param, unsigned char ** buf_p, int * bufsize_p, int ioffset, int * length_p){
184 unsigned char * start = *buf_p + ioffset;
185 int len = *length_p - ioffset;
186 struct icqstate *state = (struct icqstate *)fc;
187 int size;
188 int offset;
189
190 while (len > 0){
191 switch(state->state){
192 case ONBEGIN:
193
194 if((*start) == 0x2A) {
195 if(len < 6){
196 offset = (int)(start - *buf_p);
197 addbuffer(6-len, param, buf_p, bufsize_p, length_p);
198 start = *buf_p + offset;
199 len = (int)(*buf_p + *length_p - start);
200
201 }
202 state->state = ONCHAN;
203 }
204 else {
205 if(!state->leftinstate)param->srv->logfunc(param, (unsigned char *)"Warning: need resync");
206 state->leftinstate++;
207 if(state->leftinstate > 65535){
208 param->srv->logfunc(param, (unsigned char *)"Out of Sync");
209 return REJECT;
210 }
211 }
212 start++;
213 len--;
214 break;
215 case ONCHAN:
216 if (*start >= 10){
217 param->srv->logfunc(param, (unsigned char *)"Warning: Wrong channel");
218 state->state = ONBEGIN;
219 }
220 else {
221 state->state = ONSEQ1;
222 state->channel = *start;
223 start++;
224 len--;
225 }
226 break;
227 case ONSEQ1:
228 state->gotseq = (((unsigned)*start) << 8);
229 state->state = ONSEQ2;
230 *(start) = (state->seq>>8);
231 start++;
232 len--;
233 break;
234 case ONSEQ2:
235 state->gotseq += *start;
236 if(state->gotseq != state->srvseq){
237 unsigned char smallbuf[64];
238 if(((state->gotseq < state->srvseq) || ((state->gotseq - state->srvseq) > 10 )) && (!state->resyncseq || state->gotseq != state->resyncseq)){
239 sprintf((char *)smallbuf, "Warning: Wrong sequence, expected: %04hx got: %04hx", state->srvseq, state->gotseq);
240 param->srv->logfunc(param, smallbuf);

Callers

nothing calls this directly

Calls 2

addbufferFunction · 0.85
searchcookieFunction · 0.85

Tested by

no test coverage detected