// ---------------------------------------------------------------------------- // Copyright (C) 2008, Sealevel Systems // // For help please contact us by email at support@sealevel.com. // // $Id: cethernet.h,v 1.6 2008/09/24 13:47:40 thomasw Exp $ // ---------------------------------------------------------------------------- #ifndef CETHERNET_H__ #define CETHERNET_H__ // This is for inclusion by the C++ wrapper. #ifdef __cplusplus extern "C" { #endif // ---------------------------------------------------------------------------- // | Structs used in this library. | // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- /// \ingroup group_cethernet_all /// \brief The device type -- SeaIO_Ethernet or SeaLink_Dev. /// In the windows version of this library, this function can find both types /// of devices. To make things simpler, this version of CEthernet only works /// with SeaIO_Ethernet devices. // ---------------------------------------------------------------------------- typedef enum ceth_device_type { SeaIO_Ethernet = 1, ///< Ethernet enabled SeaIO devices. SeaLink_Dev = 2, ///< Skeletal SeaLink device support. Sealevel_All_Devices = 99 ///< Any type. } ceth_device_type; // ---------------------------------------------------------------------------- /// \ingroup group_cethernet_all /// \brief The type of information to set with the set_information function. /// You may optionally OR two of the commands together. You cannot OR SetDHCP /// and SetIPAddress. If you do OR one of the IP related functions with /// SetName, the name parameter should be the last parameter. // ---------------------------------------------------------------------------- typedef enum ceth_set_types { SetIPAddress = 1, ///< Option to set a device's IP address. SetName = 4, ///< Option to set the device's name. SetDHCP = 2 ///< Option to enable DHCP mode. } ceth_set_types; // ---------------------------------------------------------------------------- /// \ingroup group_cethernet_all /// \brief An IP, NetMask, or GateWay Address. /// This is a union which will allow you to access the data in one of three /// data type methods -- long (all 4 bytes at once), short (2 bytes at a time), /// or char (1 byte at a time). If you access the data 1 byte at a time, through /// the c array, each octet is the same as the human readable ip address. ie the /// first octet (0) in the IP 192.168.0.1 can be accessed through /// ceth_ip_addr.c[2]. // ---------------------------------------------------------------------------- typedef union ceth_ip_addr { unsigned long i; ///< Access all 4 bytes at once. unsigned short s[2]; ///< Access to two bytes at a time. unsigned char c[4]; ///< Access to each individual byte. } ceth_ip_addr; // ---------------------------------------------------------------------------- /// \ingroup group_cethernet_all /// \brief This is a MAC address storage struct. /// This struct can only be accessed one byte at a time. // ---------------------------------------------------------------------------- typedef struct ceth_addr_info { unsigned char c[6]; ///< The six byte of the MAC address. } ceth_addr_info; // ---------------------------------------------------------------------------- /// \ingroup group_cethernet_all /// \brief This is the device info struct. /// find_devices() expects a list of this structs. The data fields of this /// struct are filled in in find_device(). Please note that the MAC address can /// only be retrieved as a privileged user (RAW Sockets). // ---------------------------------------------------------------------------- typedef struct ceth_device { ceth_device_type type; ///< SeaLink or SeaIO. ceth_addr_info mac_address; ///< Device MAC address. ceth_ip_addr ip_address; ///< IP address. ceth_ip_addr net_mask; ///< Device Netmask. ceth_ip_addr gateway; ///< Device Gateway. char name[20]; ///< Device name (max 8 bytes). unsigned char dhcp_enabled; ///< Is DHCP mode enabled? struct ceth_device *next; ///< Pointer to next device. void *prop_data; ///< Skeleton. Unused. } ceth_device, *ceth_device_p; // ---------------------------------------------------------------------------- // | The C library function prototypes. | // ---------------------------------------------------------------------------- ceth_device *CEthernet_Alloc(int number); void CEthernet_Free(ceth_device *list); int CEthernet_find_devices(ceth_device_type type, int num, ceth_device *list); int CEthernet_set_information(ceth_device *device, ceth_set_types command, ...); int CEthernet_recover_module(ceth_device *device); // ---------------------------------------------------------------------------- // | The C++ class! | // ---------------------------------------------------------------------------- #ifdef __cplusplus } class CCEthernet { public: ceth_device *Alloc(int number); void Free(ceth_device *list); int find_devices(ceth_device_type type, int number, ceth_device *list); int set_information(ceth_device *device, ceth_set_types command, ...); int recover_module(ceth_device *device); }; #endif //__cplusplus #endif //CETHERNET_H__