/[svn]/hopm/branches/1.0.x/src/libopm/src/libopm.c
ViewVC logotype

Diff of /hopm/branches/1.0.x/src/libopm/src/libopm.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 5325 by michael, Thu Jan 1 20:09:33 2015 UTC revision 5326 by michael, Tue Jan 6 21:05:44 2015 UTC
# Line 70  static void libopm_do_writeready(OPM_T * Line 70  static void libopm_do_writeready(OPM_T *
70  static void libopm_do_hup(OPM_T *, OPM_SCAN_T *, OPM_CONNECTION_T *);  static void libopm_do_hup(OPM_T *, OPM_SCAN_T *, OPM_CONNECTION_T *);
71  static void libopm_do_read(OPM_T *, OPM_SCAN_T *, OPM_CONNECTION_T *);  static void libopm_do_read(OPM_T *, OPM_SCAN_T *, OPM_CONNECTION_T *);
72  static void libopm_do_openproxy(OPM_T *, OPM_SCAN_T *, OPM_CONNECTION_T *);  static void libopm_do_openproxy(OPM_T *, OPM_SCAN_T *, OPM_CONNECTION_T *);
   
73  static void libopm_do_callback(OPM_T *, OPM_REMOTE_T *, int, int);  static void libopm_do_callback(OPM_T *, OPM_REMOTE_T *, int, int);
74    
75  static OPM_REMOTE_T *libopm_setup_remote(OPM_REMOTE_T *, OPM_CONNECTION_T *);  static OPM_REMOTE_T *libopm_setup_remote(OPM_REMOTE_T *, OPM_CONNECTION_T *);
# Line 83  static OPM_REMOTE_T *libopm_setup_remote Line 82  static OPM_REMOTE_T *libopm_setup_remote
82   *    data).   *    data).
83   *   *
84   */   */
85    static OPM_PROTOCOL_T OPM_PROTOCOLS[] =
86  static OPM_PROTOCOL_T OPM_PROTOCOLS[] = {  {
87      {OPM_TYPE_HTTP,               libopm_proxy_http_write,     NULL},    { OPM_TYPE_HTTP,     libopm_proxy_http_write,     NULL },
88      {OPM_TYPE_SOCKS4,             libopm_proxy_socks4_write,   NULL},    { OPM_TYPE_SOCKS4,   libopm_proxy_socks4_write,   NULL },
89      {OPM_TYPE_SOCKS5,             libopm_proxy_socks5_write,   NULL},    { OPM_TYPE_SOCKS5,   libopm_proxy_socks5_write,   NULL },
90      {OPM_TYPE_ROUTER,             libopm_proxy_router_write,   NULL},    { OPM_TYPE_ROUTER,   libopm_proxy_router_write,   NULL },
91      {OPM_TYPE_WINGATE,            libopm_proxy_wingate_write,  NULL},    { OPM_TYPE_WINGATE,  libopm_proxy_wingate_write,  NULL },
92      {OPM_TYPE_HTTPPOST,           libopm_proxy_httppost_write, NULL}    { OPM_TYPE_HTTPPOST, libopm_proxy_httppost_write, NULL }
93  };  };
94    
   
   
   
95  /* opm_create  /* opm_create
96   *   *
97   *    Initialize a new scanner and return a pointer to it.   *    Initialize a new scanner and return a pointer to it.
98   *   *
99   * Parameters:   * Parameters:
100   *    None   *    None
101   *     *
102   * Return   * Return
103   *    Pointer to new OPM_T (scanner)   *    Pointer to new OPM_T (scanner)
104   */   */
105    OPM_T *
106  OPM_T *opm_create()  opm_create(void)
107  {  {
108     int i;    int i;
109     OPM_T *ret;    OPM_T *ret;
110    
111     ret = xcalloc(sizeof *ret);    ret = xcalloc(sizeof *ret);
112    
113     ret->config = libopm_config_create();    ret->config = libopm_config_create();
114     ret->scans = libopm_list_create();    ret->scans = libopm_list_create();
115     ret->queue = libopm_list_create();    ret->queue = libopm_list_create();
116     ret->protocols = libopm_list_create();    ret->protocols = libopm_list_create();
117     ret->fd_use = 0;    ret->fd_use = 0;
118    
119     /* Setup callbacks */    /* Setup callbacks */
120     ret->callbacks = xcalloc(sizeof(OPM_CALLBACK_T) * CBLEN);    ret->callbacks = xcalloc(sizeof(OPM_CALLBACK_T) * CBLEN);
121     for(i = 0; i < CBLEN; i++)  
122     {    for (i = 0; i < CBLEN; i++)
123        ret->callbacks[i].func = NULL;    {
124        ret->callbacks[i].data = NULL;      ret->callbacks[i].func = NULL;
125     }      ret->callbacks[i].data = NULL;
126      }
127    
128     return ret;    return ret;
129  }  }
130    
   
   
   
131  /* opm_remote_create  /* opm_remote_create
132   *   *
133   *    Create OPM_REMOTE_T struct, fill it with neccessary   *    Create OPM_REMOTE_T struct, fill it with neccessary
# Line 146  OPM_T *opm_create() Line 140  OPM_T *opm_create()
140   *    Address of OPM_REMOTE_T created   *    Address of OPM_REMOTE_T created
141   *   *
142   */   */
143    OPM_REMOTE_T *
144    opm_remote_create(const char *ip)
145    {
146      OPM_REMOTE_T *ret;
147    
148  OPM_REMOTE_T *opm_remote_create(const char *ip)    ret = xcalloc(sizeof *ret);
 {  
    OPM_REMOTE_T *ret;  
   
   
    ret = xcalloc(sizeof *ret);  
   
    /* Do initializations */  
    if(ip == NULL)  
       return NULL;  
149    
150     ret->ip = libopm_xstrdup(ip);    /* Do initializations */
151      if (ip == NULL)
152        return NULL;
153    
154     ret->port          = 0;    ret->ip = libopm_xstrdup(ip);
    ret->protocol      = 0;  
    ret->bytes_read    = 0;  
155    
156     ret->data          = NULL;    ret->port          = 0;
157      ret->protocol      = 0;
158      ret->bytes_read    = 0;
159      ret->data          = NULL;
160    
161     ret->protocols = libopm_list_create(); /* setup protocol list */    ret->protocols = libopm_list_create();  /* Setup protocol list */
162    
163     return ret;    return ret;
164  }  }
165    
   
   
166  /* opm_remote_free  /* opm_remote_free
167   *   *
168   *    Free OPM_REMOTE_T struct and cleanup   *    Free OPM_REMOTE_T struct and cleanup
# Line 183  OPM_REMOTE_T *opm_remote_create(const ch Line 173  OPM_REMOTE_T *opm_remote_create(const ch
173   * Return:   * Return:
174   *    None   *    None
175   */   */
176    void
177  void opm_remote_free(OPM_REMOTE_T *remote)  opm_remote_free(OPM_REMOTE_T *remote)
178  {  {
179      OPM_NODE_T *p, *next;
180      OPM_PROTOCOL_CONFIG_T *ppc;
181    
182     OPM_NODE_T *p, *next;    MyFree(remote->ip);
    OPM_PROTOCOL_CONFIG_T *ppc;  
183    
184     MyFree(remote->ip);    LIST_FOREACH_SAFE(p, next, remote->protocols->head)
185      {
186        ppc = p->data;
187    
188     LIST_FOREACH_SAFE(p, next, remote->protocols->head)      libopm_protocol_config_free(ppc);
189     {      libopm_list_remove(remote->protocols, p);
190        ppc = p->data;      libopm_node_free(p);
191      }
       libopm_protocol_config_free(ppc);  
       libopm_list_remove(remote->protocols, p);  
       libopm_node_free(p);  
    }  
192    
193     libopm_list_free(remote->protocols);    libopm_list_free(remote->protocols);
194    
195     MyFree(remote);    MyFree(remote);
196  }  }
197    
   
   
   
198  /* opm_callback  /* opm_callback
199   *    Register scanner level callback   *    Register scanner level callback
200   *   *
# Line 219  void opm_remote_free(OPM_REMOTE_T *remot Line 205  void opm_remote_free(OPM_REMOTE_T *remot
205   *    Error code   *    Error code
206   */   */
207    
208  OPM_ERR_T opm_callback(OPM_T *scanner, int type, OPM_CALLBACK_FUNC *function, void *data)  OPM_ERR_T
209    opm_callback(OPM_T *scanner, int type, OPM_CALLBACK_FUNC *function, void *data)
210  {  {
211     if(type < 0 || type >= (CBLEN + 1))    if (type < 0 || type >= (CBLEN + 1))
212        return OPM_ERR_CBNOTFOUND;      return OPM_ERR_CBNOTFOUND;
213    
214     scanner->callbacks[type].func = function;    scanner->callbacks[type].func = function;
215     scanner->callbacks[type].data = data;    scanner->callbacks[type].data = data;
216    
217     return OPM_SUCCESS;    return OPM_SUCCESS;
218  }  }
219    
   
   
   
220  /* opm_free  /* opm_free
221   *   *
222   *    Free OPM_T (scanner) and cleanup   *    Free OPM_T (scanner) and cleanup
# Line 243  OPM_ERR_T opm_callback(OPM_T *scanner, i Line 227  OPM_ERR_T opm_callback(OPM_T *scanner, i
227   * Return:   * Return:
228   *    None   *    None
229   */   */
230    void
231  void opm_free(OPM_T *scanner)  opm_free(OPM_T *scanner)
232  {  {
233     OPM_NODE_T *p, *next;    OPM_NODE_T *p, *next;
234     OPM_PROTOCOL_CONFIG_T *ppc;    OPM_PROTOCOL_CONFIG_T *ppc;
235     OPM_SCAN_T *scan;    OPM_SCAN_T *scan;
236    
237     libopm_config_free(scanner->config);    libopm_config_free(scanner->config);
238    
239      LIST_FOREACH_SAFE(p, next, scanner->protocols->head)
240      {
241        ppc = p->data;
242    
243        libopm_protocol_config_free(ppc);
244        libopm_list_remove(scanner->protocols, p);
245        libopm_node_free(p);
246      }
247    
248      LIST_FOREACH_SAFE(p, next, scanner->scans->head)
249      {
250        scan = p->data;
251    
252        libopm_scan_free(scan);
253        libopm_list_remove(scanner->scans, p);
254        libopm_node_free(p);
255      }
256    
257      LIST_FOREACH_SAFE(p, next, scanner->queue->head)
258      {
259        scan = p->data;
260    
261        libopm_scan_free(scan);
262        libopm_list_remove(scanner->queue, p);
263        libopm_node_free(p);
264      }
265    
266      libopm_list_free(scanner->protocols);
267      libopm_list_free(scanner->scans);
268      libopm_list_free(scanner->queue);
269    
270     LIST_FOREACH_SAFE(p, next, scanner->protocols->head)    MyFree(scanner->callbacks);
271     {    MyFree(scanner);
       ppc = p->data;  
   
       libopm_protocol_config_free(ppc);  
       libopm_list_remove(scanner->protocols, p);  
       libopm_node_free(p);  
    }  
   
    LIST_FOREACH_SAFE(p, next, scanner->scans->head)  
    {  
       scan = p->data;  
       libopm_scan_free(scan);  
       libopm_list_remove(scanner->scans, p);  
       libopm_node_free(p);  
    }  
   
    LIST_FOREACH_SAFE(p, next, scanner->queue->head)  
    {  
       scan = p->data;  
       libopm_scan_free(scan);  
       libopm_list_remove(scanner->queue, p);  
       libopm_node_free(p);  
    }  
   
    libopm_list_free(scanner->protocols);  
    libopm_list_free(scanner->scans);  
    libopm_list_free(scanner->queue);  
   
    MyFree(scanner->callbacks);  
    MyFree(scanner);  
272  }  }
273    
   
   
   
274  /* opm_config  /* opm_config
275   *   *
276   *    Wrapper to config_set. Set configuration variables   *    Wrapper to config_set. Set configuration variables
# Line 301  void opm_free(OPM_T *scanner) Line 284  void opm_free(OPM_T *scanner)
284   * Return:   * Return:
285   *    OPM_ERR_T containing error code   *    OPM_ERR_T containing error code
286   */   */
287    OPM_ERR_T
288  OPM_ERR_T opm_config(OPM_T *scanner, int key, const void *value)  opm_config(OPM_T *scanner, int key, const void *value)
289  {  {
290     return libopm_config_set((scanner->config), key, value);    return libopm_config_set((scanner->config), key, value);
291  }  }
292    
   
   
   
293  /* opm_addtype  /* opm_addtype
294   *   *
295   *    Add a proxy type and port to the list of protocols   *    Add a proxy type and port to the list of protocols
296   *    a scanner will use.   *    a scanner will use.
297   *   *
298   * Parameters:   * Parameters:
299   *    scanner: pointer to scanner struct   *    scanner: pointer to scanner struct
300   *    type:    type of proxy to scan (used in hashing to the functions)   *    type:    type of proxy to scan (used in hashing to the functions)
# Line 323  OPM_ERR_T opm_config(OPM_T *scanner, int Line 303  OPM_ERR_T opm_config(OPM_T *scanner, int
303   *    OPM_SUCCESS: Successful protocol add   *    OPM_SUCCESS: Successful protocol add
304   *    OPM_ERR_BADPROTOCOL: Protocol is unknown   *    OPM_ERR_BADPROTOCOL: Protocol is unknown
305   */   */
306    OPM_ERR_T
307  OPM_ERR_T opm_addtype(OPM_T *scanner, int type, unsigned short int port)  opm_addtype(OPM_T *scanner, int type, unsigned short int port)
308  {  {
309     unsigned int i;    unsigned int i;
   
    OPM_NODE_T *node;  
    OPM_PROTOCOL_CONFIG_T *protocol_config;  
   
    for(i = 0; i < sizeof(OPM_PROTOCOLS) / sizeof(OPM_PROTOCOL_T); i++)  
    {  
       if(type == OPM_PROTOCOLS[i].type)  
       {  
          protocol_config = libopm_protocol_config_create();  
310    
311           protocol_config->type = &OPM_PROTOCOLS[i];    OPM_NODE_T *node;
312           protocol_config->port = port;    OPM_PROTOCOL_CONFIG_T *protocol_config;
     
          node = libopm_node_create(protocol_config);  
          libopm_list_add(scanner->protocols, node);  
313    
314           return OPM_SUCCESS;    for (i = 0; i < sizeof(OPM_PROTOCOLS) / sizeof(OPM_PROTOCOL_T); i++)
315      {
316        if (type == OPM_PROTOCOLS[i].type)
317        {
318          protocol_config = libopm_protocol_config_create();
319          protocol_config->type = &OPM_PROTOCOLS[i];
320          protocol_config->port = port;
321    
322          node = libopm_node_create(protocol_config);
323          libopm_list_add(scanner->protocols, node);
324    
325          return OPM_SUCCESS;
326        }
327      }
328    
329        }    return OPM_ERR_BADPROTOCOL;
    }  
    return OPM_ERR_BADPROTOCOL;  
330  }  }
331    
   
   
332  /* opm_remote_addtype  /* opm_remote_addtype
333   *   *
334   *    Add a proxy type and port to the list of protocols   *    Add a proxy type and port to the list of protocols
# Line 365  OPM_ERR_T opm_addtype(OPM_T *scanner, in Line 342  OPM_ERR_T opm_addtype(OPM_T *scanner, in
342   *    OPM_SUCCESS: Successful protocol add   *    OPM_SUCCESS: Successful protocol add
343   *    OPM_ERR_BADPROTOCOL: Protocol is unknown   *    OPM_ERR_BADPROTOCOL: Protocol is unknown
344   */   */
   
345  OPM_ERR_T opm_remote_addtype(OPM_REMOTE_T *remote, int type, unsigned short int port)  OPM_ERR_T opm_remote_addtype(OPM_REMOTE_T *remote, int type, unsigned short int port)
346  {  {
347     unsigned int i;    unsigned int i;
   
    OPM_NODE_T *node;  
    OPM_PROTOCOL_CONFIG_T *protocol_config;  
348    
349     for(i = 0; i < sizeof(OPM_PROTOCOLS) / sizeof(OPM_PROTOCOL_T); i++)    OPM_NODE_T *node;
350     {    OPM_PROTOCOL_CONFIG_T *protocol_config;
       if(type == OPM_PROTOCOLS[i].type)  
       {  
          protocol_config = libopm_protocol_config_create();  
351    
352           protocol_config->type = &OPM_PROTOCOLS[i];    for (i = 0; i < sizeof(OPM_PROTOCOLS) / sizeof(OPM_PROTOCOL_T); i++)
353           protocol_config->port = port;    {
354        if (type == OPM_PROTOCOLS[i].type)
355        {
356          protocol_config = libopm_protocol_config_create();
357          protocol_config->type = &OPM_PROTOCOLS[i];
358          protocol_config->port = port;
359    
360          node = libopm_node_create(protocol_config);
361          libopm_list_add(remote->protocols, node);
362    
363          return OPM_SUCCESS;
364        }
365      }
366    
367           node = libopm_node_create(protocol_config);    return OPM_ERR_BADPROTOCOL;
          libopm_list_add(remote->protocols, node);  
   
          return OPM_SUCCESS;  
       }  
    }  
    return OPM_ERR_BADPROTOCOL;  
368  }  }
369    
   
   
   
370  /* libopm_protocol_create  /* libopm_protocol_create
371   *   *
372   *    Create OPM_PROTOCOL_T struct.   *    Create OPM_PROTOCOL_T struct.
# Line 406  OPM_ERR_T opm_remote_addtype(OPM_REMOTE_ Line 379  OPM_ERR_T opm_remote_addtype(OPM_REMOTE_
379   * XXX - does not appear to be used anywhere?   * XXX - does not appear to be used anywhere?
380   * -grifferz   * -grifferz
381   */   */
   
382  #if 0  #if 0
383  static OPM_PROTOCOL_T *libopm_protocol_create(void)  static OPM_PROTOCOL_T *libopm_protocol_create(void)
384  {  {
385     OPM_PROTOCOL_T *ret;    OPM_PROTOCOL_T *ret;
386     ret = xcalloc(sizeof(OPM_PROTOCOL_T));    ret = xcalloc(sizeof(OPM_PROTOCOL_T));
387    
388      ret->type           = 0;
389      ret->write_function = NULL;
390      ret->read_function  = NULL;
391    
392     ret->type           = 0;    return ret;
    ret->write_function = NULL;  
    ret->read_function  = NULL;  
     
    return ret;  
393  }  }
394  #endif  #endif
395    
   
396  /* libopm_protocol_free  /* libopm_protocol_free
397   *   *
398   *    Free an OPM_PROTOCOL_T struct. Assume that if   *    Free an OPM_PROTOCOL_T struct. Assume that if
399   *    format is not NULL, it is pointed to dynamically   *    format is not NULL, it is pointed to dynamically
400   *    allocated memory and free it.   *    allocated memory and free it.
401   *   *
402   * Parameters:   * Parameters:
403   *    protocol: struct to free   *    protocol: struct to free
404   *   *
405   * Return:   * Return:
406   *    None   *    None
407   *   *
408   * XXX - apparently no longer used?   * XXX - apparently no longer used?
409   *  -grifferz   *  -grifferz
410   */   */
   
411  #if 0  #if 0
412  static void libopm_protocol_free(OPM_PROTOCOL_T *protocol)  static void
413    libopm_protocol_free(OPM_PROTOCOL_T *protocol)
414  {  {
415     MyFree(protocol);    MyFree(protocol);
416  }  }
417  #endif  #endif
418    
   
   
419  /* libopm_protocol_config_create  /* libopm_protocol_config_create
420   *   *
421   *    Allocate and return address of a new OPM_PROTOCOL_CONFIG_T   *    Allocate and return address of a new OPM_PROTOCOL_CONFIG_T
# Line 457  static void libopm_protocol_free(OPM_PRO Line 426  static void libopm_protocol_free(OPM_PRO
426   * Return:   * Return:
427   *    Address of new OPM_PROTOCOL_CONFIG_T   *    Address of new OPM_PROTOCOL_CONFIG_T
428   */   */
429    static OPM_PROTOCOL_CONFIG_T *
430  static OPM_PROTOCOL_CONFIG_T *libopm_protocol_config_create(void)  libopm_protocol_config_create(void)
431  {  {
432     OPM_PROTOCOL_CONFIG_T *ret;    OPM_PROTOCOL_CONFIG_T *ret;
433     ret = xcalloc(sizeof *ret);    ret = xcalloc(sizeof *ret);
434    
435     return ret;    return ret;
436  }  }
437    
   
   
   
438  /* protocol_config_free  /* protocol_config_free
439   *   *
440   *    Free OPM_PROTOCOL_CONFIG_T struct   *    Free OPM_PROTOCOL_CONFIG_T struct
# Line 479  static OPM_PROTOCOL_CONFIG_T *libopm_pro Line 445  static OPM_PROTOCOL_CONFIG_T *libopm_pro
445   * Return:   * Return:
446   *    None   *    None
447   */   */
448    static void
449  static void libopm_protocol_config_free(OPM_PROTOCOL_CONFIG_T *protocol)  libopm_protocol_config_free(OPM_PROTOCOL_CONFIG_T *protocol)
450  {  {
451     MyFree(protocol);    MyFree(protocol);
452  }  }
453    
   
   
   
454  /* opm_scan  /* opm_scan
455   *   *
456   *    Scan remote host. The opm_scan function takes an OPM_REMOTE_T   *    Scan remote host. The opm_scan function takes an OPM_REMOTE_T
# Line 497  static void libopm_protocol_config_free( Line 460  static void libopm_protocol_config_free(
460   * Parameters:   * Parameters:
461   *    scanner: Scanner to scan host on   *    scanner: Scanner to scan host on
462   *    remote:  OPM_REMOTE_T defining remote host   *    remote:  OPM_REMOTE_T defining remote host
463   *       *
464   * Return:   * Return:
465   *    (to be written)   *    (to be written)
466   */   */
467    OPM_ERR_T
468  OPM_ERR_T opm_scan(OPM_T *scanner, OPM_REMOTE_T *remote)  opm_scan(OPM_T *scanner, OPM_REMOTE_T *remote)
469  {  {
470     OPM_SCAN_T *scan; /* New scan for OPM_T */    OPM_SCAN_T *scan;  /* New scan for OPM_T */
471     OPM_NODE_T *node;     /* Node we'll add scan to    OPM_NODE_T *node;  /* Node we'll add scan to when we link it to scans */
472                          when we link it to scans */    unsigned int fd_limit;
    unsigned int fd_limit;  
473    
474     fd_limit = *(int *) libopm_config(scanner->config, OPM_CONFIG_FD_LIMIT);    fd_limit = *(int *)libopm_config(scanner->config, OPM_CONFIG_FD_LIMIT);
475    
476     if(LIST_SIZE(scanner->protocols) == 0 &&    if (LIST_SIZE(scanner->protocols) == 0 &&
477        LIST_SIZE(remote->protocols) == 0)        LIST_SIZE(remote->protocols) == 0)
478     {      return OPM_ERR_NOPROTOCOLS;
       return OPM_ERR_NOPROTOCOLS;  
    }  
479    
480     scan = libopm_scan_create(scanner, remote);    scan = libopm_scan_create(scanner, remote);
481    
482     if(inet_pton(AF_INET, remote->ip, &(scan->addr.sa4.sin_addr) ) <= 0)    if (inet_pton(AF_INET, remote->ip, &(scan->addr.sa4.sin_addr) ) <= 0)
483     {    {
484        libopm_scan_free(scan);      libopm_scan_free(scan);
485        return OPM_ERR_BADADDR;      return OPM_ERR_BADADDR;
486     }    }
487    
488     node = libopm_node_create(scan);    node = libopm_node_create(scan);
489     libopm_list_add(scanner->queue, node);    libopm_list_add(scanner->queue, node);
490    
491     return OPM_SUCCESS;    return OPM_SUCCESS;
492  }  }
493    
   
   
   
494  /* opm_end  /* opm_end
495   *   *
496   *    End a scan prematurely.   *    End a scan prematurely.
# Line 542  OPM_ERR_T opm_scan(OPM_T *scanner, OPM_R Line 499  OPM_ERR_T opm_scan(OPM_T *scanner, OPM_R
499   *    scanner: Scanner to end scan on   *    scanner: Scanner to end scan on
500   *    remote: Pointer to remote struct to search for and end   *    remote: Pointer to remote struct to search for and end
501   *   *
502   * Return:   * Return:
503   *    No return. OPM_CALLBACK_END will still be called as normal.   *    No return. OPM_CALLBACK_END will still be called as normal.
504   */   */
505    void
506  void opm_end(OPM_T *scanner, OPM_REMOTE_T *remote)  opm_end(OPM_T *scanner, OPM_REMOTE_T *remote)
507  {  {
508     OPM_NODE_T *node1, *node2, *next1, *next2;    OPM_NODE_T *node1, *node2, *next1, *next2;
509      OPM_SCAN_T *scan;
510     OPM_SCAN_T *scan;    OPM_CONNECTION_T *conn;
511     OPM_CONNECTION_T *conn;  
512      /* End active scans */
513     /* End active scans */    opm_endscan(scanner, remote);
514     opm_endscan(scanner, remote);  
515      /*
516     /* Secondly remove all traces of it in the queue. Once removed we have to call     * Secondly remove all traces of it in the queue. Once removed we have to call
517        OPM_CALLBACK_END */     * OPM_CALLBACK_END
518       */
519     LIST_FOREACH_SAFE(node1, next1, scanner->queue->head)    LIST_FOREACH_SAFE(node1, next1, scanner->queue->head)
520     {    {
521        scan = node1->data;      scan = node1->data;
522        if(scan->remote == remote)  
523        if (scan->remote == remote)
524        {
525          /* Free all connections */
526          LIST_FOREACH_SAFE(node2, next2, scan->connections->head)
527        {        {
528           /* Free all connections */          conn = node2->data;
          LIST_FOREACH_SAFE(node2, next2, scan->connections->head)  
          {  
   
             conn = node2->data;  
   
             libopm_list_remove(scan->connections, node2);  
             libopm_connection_free(conn);  
             libopm_node_free(node2);  
             continue;  
          }  
   
          /* OPM_CALLBACK_END because check_closed normally handles this */  
          libopm_do_callback(scanner, scan->remote, OPM_CALLBACK_END, 0);  
529    
530           /* Free up the scan */          libopm_list_remove(scan->connections, node2);
531           libopm_list_remove(scanner->queue, node1);          libopm_connection_free(conn);
532           libopm_scan_free(scan);          libopm_node_free(node2);
533           libopm_node_free(node1);          continue;
534        }        }
    }  
 }  
   
535    
536          /* OPM_CALLBACK_END because check_closed normally handles this */
537          libopm_do_callback(scanner, scan->remote, OPM_CALLBACK_END, 0);
538    
539          /* Free up the scan */
540          libopm_list_remove(scanner->queue, node1);
541          libopm_scan_free(scan);
542          libopm_node_free(node1);
543        }
544      }
545    }
546    
547  /* opm_endscan  /* opm_endscan
548   *   *
# Line 603  void opm_end(OPM_T *scanner, OPM_REMOTE_ Line 557  void opm_end(OPM_T *scanner, OPM_REMOTE_
557   * Return:   * Return:
558   *    No return. OPM_CALLBACK_END will still be called as normal.   *    No return. OPM_CALLBACK_END will still be called as normal.
559   */   */
560    void
561  void opm_endscan(OPM_T *scanner, OPM_REMOTE_T *remote)  opm_endscan(OPM_T *scanner, OPM_REMOTE_T *remote)
562  {  {
563     OPM_NODE_T *node1, *node2;    OPM_NODE_T *node1, *node2;
564      OPM_SCAN_T *scan;
565     OPM_SCAN_T *scan;    OPM_CONNECTION_T *conn;
566     OPM_CONNECTION_T *conn;  
567      /*
568     /*     * First check to see if it's in the queue, if it is set all connections closed
569       First check to see if it's in the queue, if it is set all connections closed     * Next cycle of libopm_check_closed will take care of the garbage and handle
570       Next cycle of libopm_check_closed will take care of the garbage and handle     * OPM_CALLBACK_END
      OPM_CALLBACK_END  
571     */     */
572     LIST_FOREACH(node1, scanner->scans->head)    LIST_FOREACH(node1, scanner->scans->head)
573     {    {
574        scan = node1->data;      scan = node1->data;
575    
576        if(scan->remote == remote)      if (scan->remote == remote)
577        {
578          LIST_FOREACH(node2, scan->connections->head)
579        {        {
580           LIST_FOREACH(node2, scan->connections->head)          conn = (OPM_CONNECTION_T *) node2->data;
581           {          conn->state = OPM_STATE_CLOSED;
             conn = (OPM_CONNECTION_T *) node2->data;  
             conn->state = OPM_STATE_CLOSED;  
          }  
582        }        }
583     }      }
584      }
585  }  }
586    
587    /* opm_active
   
   
 /* opm_active  
588    
589        Return number of scans in a scanner left.        Return number of scans in a scanner left.
590    
# Line 644  void opm_endscan(OPM_T *scanner, OPM_REM Line 594  void opm_endscan(OPM_T *scanner, OPM_REM
594     Return:     Return:
595        Number of active scans, both queued and active.        Number of active scans, both queued and active.
596  */  */
597    size_t
598  size_t opm_active(OPM_T *scanner)  opm_active(OPM_T *scanner)
599  {  {
600      return LIST_SIZE(scanner->queue) + LIST_SIZE(scanner->scans);    return LIST_SIZE(scanner->queue) + LIST_SIZE(scanner->scans);
601  }  }
602    
   
   
603  /* scan_create  /* scan_create
604   *   *
605   *    Create new OPM_SCAN_T struct   *    Create new OPM_SCAN_T struct
606   *   *
607   * Parameters:   * Parameters:
608   *    scanner: Scanner the scan is being created for. This   *    scanner: Scanner the scan is being created for. This
609   *             is needed to get information on currently set   *             is needed to get information on currently set
610   *             protocols/config.   *             protocols/config.
# Line 666  size_t opm_active(OPM_T *scanner) Line 614  size_t opm_active(OPM_T *scanner)
614   * Return   * Return
615   *    Address of new struct   *    Address of new struct
616   */   */
617  static OPM_SCAN_T *libopm_scan_create(OPM_T *scanner, OPM_REMOTE_T *remote)  static OPM_SCAN_T *
618    libopm_scan_create(OPM_T *scanner, OPM_REMOTE_T *remote)
619  {  {
620     OPM_SCAN_T *ret;    OPM_SCAN_T *ret;
621     OPM_CONNECTION_T *conn;    OPM_CONNECTION_T *conn;
622     OPM_NODE_T *node, *p;    OPM_NODE_T *node, *p;
   
    ret = xcalloc(sizeof *ret);  
623    
624     ret->remote = remote;    ret = xcalloc(sizeof *ret);
    ret->connections = libopm_list_create();  
   
    /* Setup list of connections, one for each protocol */  
    LIST_FOREACH(p, scanner->protocols->head)  
    {  
       conn = libopm_connection_create();  
   
       conn->protocol = ((OPM_PROTOCOL_CONFIG_T *) p->data)->type;  
       conn->port     = ((OPM_PROTOCOL_CONFIG_T *) p->data)->port;  
   
       node = libopm_node_create(conn);  
625    
626        libopm_list_add(ret->connections, node);    ret->remote = remote;
627     }    ret->connections = libopm_list_create();
   
    /* Do the same for any specific protocols the remote struct might be configured  
       with */  
628    
629     LIST_FOREACH(p, remote->protocols->head)    /* Setup list of connections, one for each protocol */
630     {    LIST_FOREACH(p, scanner->protocols->head)
631        conn = libopm_connection_create();    {
632        conn = libopm_connection_create();
633    
634        conn->protocol = ((OPM_PROTOCOL_CONFIG_T *) p->data)->type;      conn->protocol = ((OPM_PROTOCOL_CONFIG_T *) p->data)->type;
635        conn->port     = ((OPM_PROTOCOL_CONFIG_T *) p->data)->port;      conn->port     = ((OPM_PROTOCOL_CONFIG_T *) p->data)->port;
636    
637        node = libopm_node_create(conn);      node = libopm_node_create(conn);
638    
639        libopm_list_add(ret->connections, node);      libopm_list_add(ret->connections, node);
640     }    }
641    
642     memset(&(ret->addr), 0, sizeof(opm_sockaddr));    /*
643       * Do the same for any specific protocols the remote struct might be configured with
644       */
645      LIST_FOREACH(p, remote->protocols->head)
646      {
647        conn = libopm_connection_create();
648    
649        conn->protocol = ((OPM_PROTOCOL_CONFIG_T *) p->data)->type;
650        conn->port     = ((OPM_PROTOCOL_CONFIG_T *) p->data)->port;
651    
652        node = libopm_node_create(conn);
653        libopm_list_add(ret->connections, node);
654      }
655    
656     return ret;    memset(&(ret->addr), 0, sizeof(opm_sockaddr));
657      return ret;
658  }  }
659    
   
   
   
660  /* scan_free  /* scan_free
661   *   *
662   *    Free and cleanup OPM_SCAN_T struct   *    Free and cleanup OPM_SCAN_T struct
# Line 723  static OPM_SCAN_T *libopm_scan_create(OP Line 667  static OPM_SCAN_T *libopm_scan_create(OP
667   * Return:   * Return:
668   *    None   *    None
669   */   */
670    static void
671  static void libopm_scan_free(OPM_SCAN_T *scan)  libopm_scan_free(OPM_SCAN_T *scan)
672  {  {
673     OPM_NODE_T *p, *next;    OPM_NODE_T *p, *next;
674     OPM_CONNECTION_T *conn;    OPM_CONNECTION_T *conn;
675    
676     LIST_FOREACH_SAFE(p, next, scan->connections->head)    LIST_FOREACH_SAFE(p, next, scan->connections->head)
677     {    {
678        conn = p->data;      conn = p->data;
       libopm_connection_free(conn);  
   
       libopm_list_remove(scan->connections, p);  
       libopm_node_free(p);  
    }  
    libopm_list_free(scan->connections);  
   
    MyFree(scan);  
 }  
679    
680        libopm_connection_free(conn);
681        libopm_list_remove(scan->connections, p);
682        libopm_node_free(p);
683      }
684    
685      libopm_list_free(scan->connections);
686    
687      MyFree(scan);
688    }
689    
690  /* connection_create  /* connection_create
691   *   *
# Line 755  static void libopm_scan_free(OPM_SCAN_T Line 697  static void libopm_scan_free(OPM_SCAN_T
697   * Return:   * Return:
698   *    Address of new OPM_CONNECTION_T   *    Address of new OPM_CONNECTION_T
699   */   */
700    static OPM_CONNECTION_T *
701  static OPM_CONNECTION_T *libopm_connection_create(void)  libopm_connection_create(void)
702  {  {
703     OPM_CONNECTION_T *ret;    OPM_CONNECTION_T *ret;
    ret = xcalloc(sizeof *ret);  
704    
705     ret->fd         = 0;    ret = xcalloc(sizeof *ret);
    ret->bytes_read = 0;  
    ret->readlen    = 0;  
    ret->protocol   = 0;  
    ret->port       = 0;  
   
    ret->state      = OPM_STATE_UNESTABLISHED;  
   
    return ret;  
 }  
706    
707      ret->fd         = 0;
708      ret->bytes_read = 0;
709      ret->readlen    = 0;
710      ret->protocol   = 0;
711      ret->port       = 0;
712    
713      ret->state      = OPM_STATE_UNESTABLISHED;
714    
715      return ret;
716    }
717    
718  /* connection_free  /* connection_free
719   *   *
# Line 785  static OPM_CONNECTION_T *libopm_connecti Line 725  static OPM_CONNECTION_T *libopm_connecti
725   * Return:   * Return:
726   *    None   *    None
727   */   */
728    static void
729  static void libopm_connection_free(OPM_CONNECTION_T *conn)  libopm_connection_free(OPM_CONNECTION_T *conn)
730  {  {
731     MyFree(conn);    MyFree(conn);
732  }  }
733    
   
734  /* opm_cycle  /* opm_cycle
735   *   *
736   *   Perform tasks (called by client's loop)   *   Perform tasks (called by client's loop)
# Line 801  static void libopm_connection_free(OPM_C Line 740  static void libopm_connection_free(OPM_C
740   *  Return:   *  Return:
741   *    None   *    None
742   */   */
743    void
744  void opm_cycle(OPM_T *scanner)  opm_cycle(OPM_T *scanner)
745  {  {
746     libopm_check_queue(scanner);      /* Move scans from the queue to the live scan list */    libopm_check_queue(scanner);      /* Move scans from the queue to the live scan list */
747     libopm_check_establish(scanner);  /* Make new connections if possible                */    libopm_check_establish(scanner);  /* Make new connections if possible                */
748     libopm_check_poll(scanner);       /* Poll connections for IO  and proxy test         */    libopm_check_poll(scanner);       /* Poll connections for IO  and proxy test         */
749     libopm_check_closed(scanner);     /* Check for closed or timed out connections       */    libopm_check_closed(scanner);     /* Check for closed or timed out connections       */
750  }  }
751    
   
   
   
752  /* check_queue  /* check_queue
753   *   *
754   * Move scans from the queue to the live scan list as long as there is   * Move scans from the queue to the live scan list as long as there is
# Line 824  void opm_cycle(OPM_T *scanner) Line 760  void opm_cycle(OPM_T *scanner)
760   * Return:   * Return:
761   *    None   *    None
762   */   */
763    static void
764  static void libopm_check_queue(OPM_T *scanner)  libopm_check_queue(OPM_T *scanner)
765  {  {
766     OPM_NODE_T *node;     OPM_NODE_T *node;
767     OPM_SCAN_T *scan;     OPM_SCAN_T *scan;
# Line 861  static void libopm_check_queue(OPM_T *sc Line 797  static void libopm_check_queue(OPM_T *sc
797    
798  }  }
799    
   
   
   
800  /* check_establish  /* check_establish
801   *   *
802   * Make new connections if there are free file descriptors and connections   * Make new connections if there are free file descriptors and connections
# Line 874  static void libopm_check_queue(OPM_T *sc Line 807  static void libopm_check_queue(OPM_T *sc
807   * Return:   * Return:
808   *   None   *   None
809   */   */
810    static void
811  static void libopm_check_establish(OPM_T *scanner)  libopm_check_establish(OPM_T *scanner)
812  {  {
813     OPM_NODE_T *node1, *node2;    OPM_NODE_T *node1, *node2;
814     OPM_SCAN_T *scan;    OPM_SCAN_T *scan;
815     OPM_CONNECTION_T *conn;    OPM_CONNECTION_T *conn;
816      unsigned int fd_limit;
817     unsigned int fd_limit;  
818      if (LIST_SIZE(scanner->scans) == 0)
819     if(LIST_SIZE(scanner->scans) == 0)      return;
820        return;  
821      fd_limit = *(int *)libopm_config(scanner->config, OPM_CONFIG_FD_LIMIT);
822     fd_limit = *(int *) libopm_config(scanner->config, OPM_CONFIG_FD_LIMIT);  
823      if (scanner->fd_use >= fd_limit)
824     if(scanner->fd_use >= fd_limit)      return;
825        return;  
826      LIST_FOREACH(node1, scanner->scans->head)
827     LIST_FOREACH(node1, scanner->scans->head)    {
828     {      scan = node1->data;
829        scan = node1->data;  
830        LIST_FOREACH(node2, scan->connections->head)      LIST_FOREACH(node2, scan->connections->head)
831        {      {
832           /* Only scan if we have free file descriptors */        /* Only scan if we have free file descriptors */
833           if(scanner->fd_use >= fd_limit)        if (scanner->fd_use >= fd_limit)
834              return;          return;
835    
836           conn = node2->data;        conn = node2->data;
837           if(conn->state == OPM_STATE_UNESTABLISHED)  
838              libopm_do_connect(scanner, scan, conn);        if (conn->state == OPM_STATE_UNESTABLISHED)
839        }          libopm_do_connect(scanner, scan, conn);
840     }      }
841      }
842  }  }
843    
   
   
   
844  /* check_closed  /* check_closed
845   *   *
846   * Check for connections which have timed out or are   * Check for connections which have timed out or are
# Line 925  static void libopm_check_establish(OPM_T Line 856  static void libopm_check_establish(OPM_T
856   * Return:   * Return:
857   *   None   *   None
858   */   */
859    static void
860  static void libopm_check_closed(OPM_T *scanner)  libopm_check_closed(OPM_T *scanner)
861  {  {
862    
863     time_t present;     time_t present;
# Line 995  static void libopm_check_closed(OPM_T *s Line 926  static void libopm_check_closed(OPM_T *s
926     }     }
927  }  }
928    
   
   
   
929  /* do_connect  /* do_connect
930   *   *
931   * Call socket() and connect() to start a scan.   * Call socket() and connect() to start a scan.
# Line 1008  static void libopm_check_closed(OPM_T *s Line 936  static void libopm_check_closed(OPM_T *s
936   * Return:   * Return:
937   *    None   *    None
938   */   */
939    static void
940  static void libopm_do_connect(OPM_T * scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T *conn)  libopm_do_connect(OPM_T * scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T *conn)
941  {  {
942     opm_sockaddr *bind_ip;     opm_sockaddr *bind_ip;
943    
# Line 1058  static void libopm_do_connect(OPM_T * sc Line 986  static void libopm_do_connect(OPM_T * sc
986     time(&(conn->creation));   /* Stamp creation time, for timeout */     time(&(conn->creation));   /* Stamp creation time, for timeout */
987  }  }
988    
   
989  /* check_poll  /* check_poll
990   *   *
991   * Check sockets for ready read/write   * Check sockets for ready read/write
# Line 1068  static void libopm_do_connect(OPM_T * sc Line 995  static void libopm_do_connect(OPM_T * sc
995   * Return:   * Return:
996   *    None   *    None
997   */   */
998    static void
999  static void libopm_check_poll(OPM_T *scanner)  libopm_check_poll(OPM_T *scanner)
1000  {  {
1001     OPM_NODE_T *node1, *node2;     OPM_NODE_T *node1, *node2;
1002     OPM_SCAN_T *scan;     OPM_SCAN_T *scan;
# Line 1164  static void libopm_check_poll(OPM_T *sca Line 1091  static void libopm_check_poll(OPM_T *sca
1091     }     }
1092  }  }
1093    
   
   
   
1094  /* do_readready  /* do_readready
1095   *   *
1096   *    Remote connection is read ready, read the data into a buffer and check it against   *    Remote connection is read ready, read the data into a buffer and check it against
# Line 1180  static void libopm_check_poll(OPM_T *sca Line 1104  static void libopm_check_poll(OPM_T *sca
1104   *    Return:   *    Return:
1105   *       None   *       None
1106   */   */
1107    static void
1108  static void libopm_do_readready(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T *conn)  libopm_do_readready(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T *conn)
1109  {  {
1110    
1111     int max_read;     int max_read;
# Line 1244  static void libopm_do_readready(OPM_T *s Line 1168  static void libopm_do_readready(OPM_T *s
1168     }     }
1169  }  }
1170    
   
   
   
1171  /* do_read  /* do_read
1172   *   *
1173   *    A line of data has been read from the socket, check it against   *    A line of data has been read from the socket, check it against
1174   *    target string.   *    target string.
1175   *   *
1176   *       *
1177   *   *
1178   *    Parameters:   *    Parameters:
1179   *       scanner: Scanner doing the scan   *       scanner: Scanner doing the scan
# Line 1262  static void libopm_do_readready(OPM_T *s Line 1183  static void libopm_do_readready(OPM_T *s
1183   *    Return:   *    Return:
1184   *       None   *       None
1185   */   */
1186    static void
1187  static void libopm_do_read(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T *conn)  libopm_do_read(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T *conn)
1188  {  {
1189     OPM_LIST_T *list;    OPM_LIST_T *list;
1190     OPM_NODE_T *node;    OPM_NODE_T *node;
1191     char *target_string;    char *target_string;
1192    
1193     /* Check readbuf against target strings */    /* Check readbuf against target strings */
1194     list = (OPM_LIST_T *) libopm_config(scanner->config, OPM_CONFIG_TARGET_STRING);    list = (OPM_LIST_T *)libopm_config(scanner->config, OPM_CONFIG_TARGET_STRING);
1195     LIST_FOREACH(node, list->head)  
1196     {    LIST_FOREACH(node, list->head)
1197        target_string = node->data;    {
1198        if(strstr(conn->readbuf, target_string))      target_string = node->data;
1199        {  
1200           libopm_do_openproxy(scanner, scan, conn);      if (strstr(conn->readbuf, target_string))
1201           break;      {
1202        }        libopm_do_openproxy(scanner, scan, conn);
1203     }        break;
1204        }
1205      }
1206  }  }
1207    
   
1208  /* do_openproxy  /* do_openproxy
1209   *   *
1210   *    An open proxy was found on connection conn. Cleanup the connection and   *    An open proxy was found on connection conn. Cleanup the connection and
# Line 1296  static void libopm_do_read(OPM_T *scanne Line 1218  static void libopm_do_read(OPM_T *scanne
1218   *    Return:   *    Return:
1219   *       None   *       None
1220   */   */
1221    static void
1222  static void libopm_do_openproxy(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T *conn)  libopm_do_openproxy(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T *conn)
1223  {  {
1224     OPM_REMOTE_T *remote;    OPM_REMOTE_T *remote;
1225    
1226     remote = scan->remote;    remote = scan->remote;
1227    
1228     /* Mark the connection for close */    /* Mark the connection for close */
1229     conn->state = OPM_STATE_CLOSED;    conn->state = OPM_STATE_CLOSED;
1230    
1231     /* Call client's open proxy callback */    /* Call client's open proxy callback */
1232     libopm_do_callback(scanner, libopm_setup_remote(scan->remote, conn), OPM_CALLBACK_OPENPROXY, 0);    libopm_do_callback(scanner, libopm_setup_remote(scan->remote, conn), OPM_CALLBACK_OPENPROXY, 0);
1233  }  }
1234    
   
   
   
1235  /*  do_writeready  /*  do_writeready
1236   *   *
1237   *    Remote connection is write ready, call the specific protocol   *    Remote connection is write ready, call the specific protocol
# Line 1326  static void libopm_do_openproxy(OPM_T *s Line 1245  static void libopm_do_openproxy(OPM_T *s
1245   *    Return:   *    Return:
1246   *       None   *       None
1247   */   */
1248    static void
1249  static void libopm_do_writeready(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T *conn)  libopm_do_writeready(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T *conn)
1250  {  {
1251     OPM_PROTOCOL_T *protocol;    OPM_PROTOCOL_T *protocol;
1252    
1253     protocol = conn->protocol;    protocol = conn->protocol;
1254    
1255     /* Call write function for specific protocol */    /* Call write function for specific protocol */
1256     if(protocol->write_function)    if (protocol->write_function)
1257        protocol->write_function(scanner, scan, conn);      protocol->write_function(scanner, scan, conn);
1258    
1259     /* Flag as NEGSENT so we don't have to send data again*/    /* Flag as NEGSENT so we don't have to send data again*/
1260     conn->state = OPM_STATE_NEGSENT;      conn->state = OPM_STATE_NEGSENT;
1261  }  }
1262    
   
   
   
1263  /* do_hup  /* do_hup
1264   *   *
1265   *    Connection ended prematurely   *    Connection ended prematurely
# Line 1356  static void libopm_do_writeready(OPM_T * Line 1272  static void libopm_do_writeready(OPM_T *
1272   * Return:   * Return:
1273   *       None   *       None
1274   */   */
1275    static void
1276  static void libopm_do_hup(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T *conn)  libopm_do_hup(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T *conn)
1277  {  {
1278     OPM_REMOTE_T *remote;    OPM_REMOTE_T *remote;
1279    
1280     remote = scan->remote;    remote = scan->remote;
1281    
1282    /* Mark the connection for close */    /* Mark the connection for close */
1283     conn->state = OPM_STATE_CLOSED;    conn->state = OPM_STATE_CLOSED;
1284    
1285     libopm_do_callback(scanner, libopm_setup_remote(scan->remote, conn), OPM_CALLBACK_NEGFAIL, 0);    libopm_do_callback(scanner, libopm_setup_remote(scan->remote, conn), OPM_CALLBACK_NEGFAIL, 0);
1286  }  }
1287    
   
   
   
1288  /* do_callback  /* do_callback
1289   *   *
1290   *    Call callback   *    Call callback
# Line 1384  static void libopm_do_hup(OPM_T *scanner Line 1297  static void libopm_do_hup(OPM_T *scanner
1297   * Return:   * Return:
1298   *    None   *    None
1299   */   */
1300    static void
1301  static void libopm_do_callback(OPM_T *scanner, OPM_REMOTE_T *remote, int type, int var)  libopm_do_callback(OPM_T *scanner, OPM_REMOTE_T *remote, int type, int var)
1302  {  {
1303     /* Callback is out of range */    /* Callback is out of range */
1304     if(type < 0 || type >= (CBLEN + 1))    if (type < 0 || type >= (CBLEN + 1))
1305        return;      return;
1306    
1307     if(scanner->callbacks[type].func)    if (scanner->callbacks[type].func)
1308        (scanner->callbacks[type].func) (scanner, remote, var, scanner->callbacks[type].data);      (scanner->callbacks[type].func)(scanner, remote, var, scanner->callbacks[type].data);
1309  }  }
1310    
   
   
   
1311  /* setup_remote  /* setup_remote
1312   *   *
1313   * Setup an OPM_REMOTE_T with information from an OPM_CONNECTION_T   * Setup an OPM_REMOTE_T with information from an OPM_CONNECTION_T
# Line 1405  static void libopm_do_callback(OPM_T *sc Line 1315  static void libopm_do_callback(OPM_T *sc
1315   *   *
1316   * Parameters:   * Parameters:
1317   *    remote, conn   *    remote, conn
1318   *   *
1319   * Return:   * Return:
1320   *    remote   *    remote
1321   */   */
1322    static OPM_REMOTE_T *
1323  static OPM_REMOTE_T *libopm_setup_remote(OPM_REMOTE_T *remote, OPM_CONNECTION_T *conn)  libopm_setup_remote(OPM_REMOTE_T *remote, OPM_CONNECTION_T *conn)
1324  {  {
1325     remote->port = conn->port;    remote->port = conn->port;
1326     remote->bytes_read = conn->bytes_read;    remote->bytes_read = conn->bytes_read;
1327     remote->protocol = conn->protocol->type;    remote->protocol = conn->protocol->type;
1328    
1329     return remote;    return remote;
1330  }  }

Legend:
Removed from v.5325  
changed lines
  Added in v.5326

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28