#ifndef CONFIG_H
#define CONFIG_H
-#include "libopm.h"
+#include "libopm.h"
typedef struct _opm_config_hash OPM_CONFIG_HASH_T;
-struct _opm_config_hash {
- int key;
- int type;
+struct _opm_config_hash
+{
+ int key;
+ int type;
};
void libopm_config_free(OPM_CONFIG_T *);
int libopm_config_gettype(int);
OPM_CONFIG_T *libopm_config_create(void);
OPM_ERR_T libopm_config_set(OPM_CONFIG_T *, int , const void *);
-
-
#endif /* CONFIG_H */
* 59 Temple Place - Suite 330
* Boston, MA 02111-1307, USA.
*
- *
+ *
*/
#include "setup.h"
* scanner: Scanner the scan is being created for. This
* is needed to get information on currently set
* protocols/config.
- *
+ *
* remote: Remote host this scan will be scanning
- *
+ *
* Return
* Address of new struct
*/
*
* Parametsr:
* scan: Scan struct to free
- *
+ *
* Return:
* None
*/
* Move scans from the queue to the live scan list as long as there is
* room.
*
- * Parameters:
+ * Parameters:
* scanner: Scanner to check queue on
*
* Return:
}
/* check_closed
- *
+ *
* Check for connections which have timed out or are
* closed. Connections timed out still need to be closed.
*
* Parametsr:
* scan: Scan struct containing the connection
* conn: Connection to establish
- * Return:
+ * Return:
* None
*/
static void
/* do_readready
*
- * Remote connection is read ready, read the data into a buffer and check it against
- * the target_string if neccessary
+ * Remote connection is read ready, read the data into a buffer and check it against
+ * the target_string if neccessary
*
* Parameters:
* scanner: Scanner doing the scan
/* do_openproxy
*
- * An open proxy was found on connection conn. Cleanup the connection and
+ * An open proxy was found on connection conn. Cleanup the connection and
* call the appropriate callback to let the client know the proxy was found.
*
* Parameters:
}
/* do_callback
- *
+ *
* Call callback
*
* Parameters:
#include "opm_common.h"
#include "opm.h"
-#define CBLEN 5 /* Number of callback functions */
-#define READBUFLEN 128 /* Size of conn->readbuf */
-#define SENDBUFLEN 512 /* Size of sendbuffer in proxy.c */
+#define CBLEN 5 /* Number of callback functions */
+#define READBUFLEN 128 /* Size of conn->readbuf */
+#define SENDBUFLEN 512 /* Size of sendbuffer in proxy.c */
typedef struct _OPM_SCAN OPM_SCAN_T;
typedef struct _OPM_CONNECTION OPM_CONNECTION_T;
typedef struct _OPM_PROTOCOL_CONFIG OPM_PROTOCOL_CONFIG_T;
typedef struct _OPM_PROTOCOL OPM_PROTOCOL_T;
-/* Types of hard coded proxy READ/WRITE functions which are
- setup in a table in libopm.c */
-
+/*
+ * Types of hard coded proxy READ/WRITE functions which are
+ * setup in a table in libopm.c
+ */
typedef int OPM_PROXYWRITE_T (OPM_T *, OPM_SCAN_T *, OPM_CONNECTION_T *);
typedef int OPM_PROXYREAD_T (OPM_T *, OPM_SCAN_T *, OPM_CONNECTION_T *);
-struct _OPM_SCAN {
- opm_sockaddr addr; /* Address in byte order of remote client */
- OPM_REMOTE_T *remote; /* Pointed to the OPM_REMOTE_T for this scan, passed by client */
- OPM_LIST_T *connections; /* List of individual connections of this scan (1 for each protocol) */
+struct _OPM_SCAN
+{
+ opm_sockaddr addr; /* Address in byte order of remote client */
+ OPM_REMOTE_T *remote; /* Pointed to the OPM_REMOTE_T for this scan, passed by client */
+ OPM_LIST_T *connections; /* List of individual connections of this scan (1 for each protocol) */
};
-struct _OPM_CONNECTION {
-
- OPM_PROTOCOL_T *protocol; /* Pointer to specific protocol this connection handles */
- unsigned short int port; /* Some protocols have multiple ports, eg. HTTP */
-
- int fd; /* Allocated file descriptor, 0 if not yet allocated */
- unsigned short int bytes_read; /* Bytes read so far in this connection */
- char readbuf[READBUFLEN + 1]; /* 128 byte read buffer, anything over 128 is probably not of use */
- unsigned short int readlen; /* Length of readbuf */
- unsigned short int state; /* State of connection */
- time_t creation; /* When this connection was established */
+struct _OPM_CONNECTION
+{
+ OPM_PROTOCOL_T *protocol; /* Pointer to specific protocol this connection handles */
+ unsigned short int port; /* Some protocols have multiple ports, eg. HTTP */
+ int fd; /* Allocated file descriptor, 0 if not yet allocated */
+ unsigned short int bytes_read; /* Bytes read so far in this connection */
+ char readbuf[READBUFLEN + 1]; /* 128 byte read buffer, anything over 128 is probably not of use */
+ unsigned short int readlen; /* Length of readbuf */
+ unsigned short int state; /* State of connection */
+ time_t creation; /* When this connection was established */
};
struct _OPM_PROTOCOL_CONFIG
{
- OPM_PROTOCOL_T *type; /* Protocol type */
- unsigned short int port; /* Port to connect on */
-
+ OPM_PROTOCOL_T *type; /* Protocol type */
+ unsigned short int port; /* Port to connect on */
};
struct _OPM_PROTOCOL
{
- int type; /* Protocol type */
-
- OPM_PROXYWRITE_T *write_function; /* Write function handler for this protocol */
- OPM_PROXYREAD_T *read_function; /* Read function handler for this protocol */
+ int type; /* Protocol type */
+ OPM_PROXYWRITE_T *write_function; /* Write function handler for this protocol */
+ OPM_PROXYREAD_T *read_function; /* Read function handler for this protocol */
};
-
#endif /* LIBOPM_H */
typedef void OPM_CALLBACK_FUNC (OPM_T *, OPM_REMOTE_T *, int, void *);
-struct _OPM_CALLBACK {
- OPM_CALLBACK_FUNC *func;
- void *data;
+struct _OPM_CALLBACK
+{
+ OPM_CALLBACK_FUNC *func;
+ void *data;
};
-struct _OPM_CONFIG {
- void **vars;
+struct _OPM_CONFIG
+{
+ void **vars;
};
-struct _OPM {
- OPM_CONFIG_T *config; /* Individual scanner configuration */
- OPM_LIST_T *queue; /* List of scans in the queue (not yet established) */
- OPM_LIST_T *scans; /* List of scans (each scan containing a list of connections) */
- OPM_LIST_T *protocols; /* List of protocols this scanner handles */
- unsigned int fd_use; /* Number of file descriptors in use */
-
- OPM_CALLBACK_T *callbacks; /* Scanner wide callbacks */
+struct _OPM
+{
+ OPM_CONFIG_T *config; /* Individual scanner configuration */
+ OPM_LIST_T *queue; /* List of scans in the queue (not yet established) */
+ OPM_LIST_T *scans; /* List of scans (each scan containing a list of connections) */
+ OPM_LIST_T *protocols; /* List of protocols this scanner handles */
+ unsigned int fd_use; /* Number of file descriptors in use */
+ OPM_CALLBACK_T *callbacks; /* Scanner wide callbacks */
};
-struct _OPM_REMOTE {
-
- char *ip; /* Readable IP address */
-
- unsigned short int port; /* Port passed back on certain callbacks */
- unsigned short int protocol; /* Protocol passed back on certain callbacks */
- unsigned short int bytes_read; /* Bytes read passed back on certain callbacks */
-
- OPM_LIST_T *protocols; /* Remote specific protocols */
-
- void *data; /* Arbitrary data that the client can point to for any purpose*/
+struct _OPM_REMOTE
+{
+ char *ip; /* Readable IP address */
+ unsigned short int port; /* Port passed back on certain callbacks */
+ unsigned short int protocol; /* Protocol passed back on certain callbacks */
+ unsigned short int bytes_read; /* Bytes read passed back on certain callbacks */
+ OPM_LIST_T *protocols; /* Remote specific protocols */
+ void *data; /* Arbitrary data that the client can point to for any purpose*/
};
OPM_T *opm_create(void);
void opm_cycle(OPM_T *);
size_t opm_active(OPM_T *);
-
#endif /* OPM_H */
typedef struct _libopm_list OPM_LIST_T;
-struct _libopm_list {
-
+struct _libopm_list
+{
struct _libopm_node *head;
struct _libopm_node *tail;
-
int elements;
};
-struct _libopm_node {
-
- struct _libopm_node *next;
- struct _libopm_node *prev;
-
- void *data;
+struct _libopm_node
+{
+ struct _libopm_node *next;
+ struct _libopm_node *prev;
+ void *data;
};
-
#endif /* OPM_COMMON_H */
#define OPM_SUCCESS 1
/* Configuration Errors */
-#define OPM_ERR_BADKEY 2 /* Unknown or bad key value */
-#define OPM_ERR_BADVALUE 3 /* Bad value matching key */
-#define OPM_ERR_BADPROTOCOL 4 /* Unknown protocol in config */
+#define OPM_ERR_BADKEY 2 /* Unknown or bad key value */
+#define OPM_ERR_BADVALUE 3 /* Bad value matching key */
+#define OPM_ERR_BADPROTOCOL 4 /* Unknown protocol in config */
/* Read Errors */
-#define OPM_ERR_MAX_READ 5 /* Socket reached MAX_READ */
+#define OPM_ERR_MAX_READ 5 /* Socket reached MAX_READ */
/* Callback Registration Errors */
-#define OPM_ERR_CBNOTFOUND 6 /* Callback is out of range */
+#define OPM_ERR_CBNOTFOUND 6 /* Callback is out of range */
/* opm_scan errors */
-#define OPM_ERR_BADADDR 7 /* IP in remote struct is bad */
-#define OPM_ERR_NOPROTOCOLS 8 /* No protocols to scan! */
+#define OPM_ERR_BADADDR 7 /* IP in remote struct is bad */
+#define OPM_ERR_NOPROTOCOLS 8 /* No protocols to scan! */
/* bind/connect errors */
-#define OPM_ERR_BIND 9 /* Error binding to BIND_IP */
-#define OPM_ERR_NOFD 10/* Unable to allocate file descriptor */
+#define OPM_ERR_BIND 9 /* Error binding to BIND_IP */
+#define OPM_ERR_NOFD 10 /* Unable to allocate file descriptor */
#endif /* LIBOPM_ERROR_H */
#define OPM_STATE_CLOSED 4
-/* Callbacks -- If more callback types are added,
- CBLEN will need to be changed in libopm.h accordingly */
-
+/*
+ * Callbacks -- If more callback types are added, CBLEN will
+ * need to be changed in libopm.h accordingly
+ */
#define OPM_CALLBACK_OPENPROXY 0 /* An open proxy has been found REMOTE/SCANNER */
#define OPM_CALLBACK_NEGFAIL 1 /* Negotiation to a proxy has failed REMOTE/SCANNER */
#define OPM_CALLBACK_END 2 /* A scan has ended REMOTE/SCANNER */
scan_port = *(int *)libopm_config(scanner->config, OPM_CONFIG_SCAN_PORT);
if (inet_pton(AF_INET, scan_ip, &addr) <= 0)
- ; /* handle error */
+ ; /* handle error */
laddr = htonl(addr.s_addr);
int libopm_proxy_wingate_write(OPM_T *, OPM_SCAN_T *, OPM_CONNECTION_T *);
int libopm_proxy_router_write(OPM_T *, OPM_SCAN_T *, OPM_CONNECTION_T *);
int libopm_proxy_httppost_write(OPM_T *, OPM_SCAN_T *, OPM_CONNECTION_T *);
-
-
#endif /* PROXY_H */