

DOCUMENTATION for ec_threads.c

HOW TO CREATE THREADS INSIDE ETTERCAP

===============================================================================

ettercap uses the pthread library.

the file ec_threads.c gives to the developer some wrapper to create ettercap
threads.

in the file ec_thread.h we find these funcions:

char * ECThread_getname(pthread_t id);

   to get the name of a thread. this is only useful for debugging information.
   the DEBUG_MSG macro prints the name of the thread and then the message, so 
   you can easily know which thread is doing what.


void ECThread_register(pthread_t id, char * name);

   to give a name to a thread. or to rename an existent one.


pthread_t ECThread_create(char * name, void *(*function)(void *), void *args);

   to create a thread.
   the second parameter is the funcion that will become the main of the
   thread.


void ECThread_destroy(pthread_t id);

   to kill a thread.
   etterap uses the pthread_join inside this function.
   this is because we have to wait that the thread has finished its clead up
   before continuing with other operation.
   this is very important for the arp poisoner thread that needs to re-arp the
   cache before ettercap exits.


ettercap maintains a global list where all the thread information are stored.

struct thread_list {
   char name[10];
   pthread_t id;
   LIST_ENTRY (thread_list) next;
};

LIST_HEAD(, thread_list) thread_list_head;
         

however you don't need to access this list directly because you can (and you
have to) manipulate it through the funcions explained above.


EOF
