diff options
Diffstat (limited to 'tinyNET/src/dhcp/tnet_dhcp_message.h')
-rwxr-xr-x | tinyNET/src/dhcp/tnet_dhcp_message.h | 257 |
1 files changed, 127 insertions, 130 deletions
diff --git a/tinyNET/src/dhcp/tnet_dhcp_message.h b/tinyNET/src/dhcp/tnet_dhcp_message.h index c7005fa..53ead75 100755 --- a/tinyNET/src/dhcp/tnet_dhcp_message.h +++ b/tinyNET/src/dhcp/tnet_dhcp_message.h @@ -2,19 +2,19 @@ * Copyright (C) 2010-2011 Mamadou Diop. * * Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> -* +* * This file is part of Open Source Doubango Framework. * * DOUBANGO is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. -* +* * DOUBANGO is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. -* +* * You should have received a copy of the GNU General Public License * along with DOUBANGO. * @@ -50,158 +50,155 @@ struct tnet_dhcp_ctx_s; /** List of all supported DHCP message (see RFC 2131). */ -typedef enum tnet_dhcp_message_type_e -{ - /**< DHCPDISCOVER - Client broadcast to locate available servers. - */ - dhcp_type_discover = 1, - - /**< DHCPOFFER - Server to client in response to DHCPDISCOVER with - offer of configuration parameters. - */ - dhcp_type_offer = 2, - - /**< DHCPREQUEST - Client message to servers either (a) requesting - offered parameters from one server and implicitly - declining offers from all others, (b) confirming - correctness of previously allocated address after, - e.g., system reboot, or (c) extending the lease on a - particular network address. - */ - dhcp_type_request = 3, - - /**< DHCPDECLINE - Client to server indicating network address is already +typedef enum tnet_dhcp_message_type_e { + /**< DHCPDISCOVER - Client broadcast to locate available servers. + */ + dhcp_type_discover = 1, + + /**< DHCPOFFER - Server to client in response to DHCPDISCOVER with + offer of configuration parameters. + */ + dhcp_type_offer = 2, + + /**< DHCPREQUEST - Client message to servers either (a) requesting + offered parameters from one server and implicitly + declining offers from all others, (b) confirming + correctness of previously allocated address after, + e.g., system reboot, or (c) extending the lease on a + particular network address. + */ + dhcp_type_request = 3, + + /**< DHCPDECLINE - Client to server indicating network address is already in use. - */ - dhcp_type_decline = 4, - - /**< DHCPACK - Server to client with configuration parameters, - including committed network address. - */ - dhcp_type_ack = 5, - - /**< DHCPNAK - Server to client indicating client's notion of network - address is incorrect (e.g., client has moved to new - subnet) or client's lease as expired - */ - dhcp_type_nack = 6, - - /**< DHCPRELEASE - Client to server relinquishing network address and - cancelling remaining lease. - */ - dhcp_type_release = 7, - - /**< DHCPINFORM - Client to server, asking only for local configuration - parameters; client already has externally configured - network address. - */ - dhcp_type_inform = 8, + */ + dhcp_type_decline = 4, + + /**< DHCPACK - Server to client with configuration parameters, + including committed network address. + */ + dhcp_type_ack = 5, + + /**< DHCPNAK - Server to client indicating client's notion of network + address is incorrect (e.g., client has moved to new + subnet) or client's lease as expired + */ + dhcp_type_nack = 6, + + /**< DHCPRELEASE - Client to server relinquishing network address and + cancelling remaining lease. + */ + dhcp_type_release = 7, + + /**< DHCPINFORM - Client to server, asking only for local configuration + parameters; client already has externally configured + network address. + */ + dhcp_type_inform = 8, } tnet_dhcp_message_type_t; /** DHCP message OP code / message type. */ -typedef enum tnet_dhcp_message_op_e -{ - dhcp_op_bootrequest = 1, - dhcp_op_bootreply = 2 +typedef enum tnet_dhcp_message_op_e { + dhcp_op_bootrequest = 1, + dhcp_op_bootreply = 2 } tnet_dhcp_message_op_t; /** BOOTP/DHCP message as per RFC 2131 subclause 2. */ -typedef struct tnet_dhcp_message_s -{ - TSK_DECLARE_OBJECT; - - /**< DHCP message type. Mandatory. - */ - tnet_dhcp_message_type_t type; - /* - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | op (1) | htype (1) | hlen (1) | hops (1) | - +---------------+---------------+---------------+---------------+ - | xid (4) | - +-------------------------------+-------------------------------+ - | secs (2) | flags (2) | - +-------------------------------+-------------------------------+ - | ciaddr (4) | - +---------------------------------------------------------------+ - | yiaddr (4) | - +---------------------------------------------------------------+ - | siaddr (4) | - +---------------------------------------------------------------+ - | giaddr (4) | - +---------------------------------------------------------------+ - | | - | chaddr (16) | - | | - | | - +---------------------------------------------------------------+ - | | - | sname (64) | - +---------------------------------------------------------------+ - | | - | file (128) | - +---------------------------------------------------------------+ - | | - | options (variable) | - +---------------------------------------------------------------+ - */ - - /**< Message op code / message type (1-byte). +typedef struct tnet_dhcp_message_s { + TSK_DECLARE_OBJECT; + + /**< DHCP message type. Mandatory. + */ + tnet_dhcp_message_type_t type; + /* + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | op (1) | htype (1) | hlen (1) | hops (1) | + +---------------+---------------+---------------+---------------+ + | xid (4) | + +-------------------------------+-------------------------------+ + | secs (2) | flags (2) | + +-------------------------------+-------------------------------+ + | ciaddr (4) | + +---------------------------------------------------------------+ + | yiaddr (4) | + +---------------------------------------------------------------+ + | siaddr (4) | + +---------------------------------------------------------------+ + | giaddr (4) | + +---------------------------------------------------------------+ + | | + | chaddr (16) | + | | + | | + +---------------------------------------------------------------+ + | | + | sname (64) | + +---------------------------------------------------------------+ + | | + | file (128) | + +---------------------------------------------------------------+ + | | + | options (variable) | + +---------------------------------------------------------------+ + */ + + /**< Message op code / message type (1-byte). 1 = BOOTREQUEST, 2 = BOOTREPLY - */ - tnet_dhcp_message_op_t op; - /**< Hardware address type, see ARP section in "Assigned Numbers" RFC; e.g., '1' = 10mb ethernet. - For more information see RFC 1340. - */ + */ + tnet_dhcp_message_op_t op; + /**< Hardware address type, see ARP section in "Assigned Numbers" RFC; e.g., '1' = 10mb ethernet. + For more information see RFC 1340. + */ tnet_hardware_type_t htype; - /**< Hardware address length (e.g. '6' for 10mb ethernet). tsk_strlen(chaddr). - */ + /**< Hardware address length (e.g. '6' for 10mb ethernet). tsk_strlen(chaddr). + */ uint8_t hlen; - /**< Client sets to zero, optionally used by relay agents when booting via a relay agent. - */ + /**< Client sets to zero, optionally used by relay agents when booting via a relay agent. + */ uint8_t hops; - /**< Transaction ID, a random number chosen by the client, used by the client - and server to associate messages and responses between a client and a server. - */ + /**< Transaction ID, a random number chosen by the client, used by the client + and server to associate messages and responses between a client and a server. + */ uint32_t xid; - /**< Filled in by client, seconds elapsed since client began address acquisition or renewal process. - */ + /**< Filled in by client, seconds elapsed since client began address acquisition or renewal process. + */ uint16_t secs; - /**< Flags (see figure 2) - */ + /**< Flags (see figure 2) + */ uint16_t flags; - /**< Client IP address; only filled in if client is in BOUND, RENEW or REBINDING - state and can respond to ARP requests. - */ + /**< Client IP address; only filled in if client is in BOUND, RENEW or REBINDING + state and can respond to ARP requests. + */ uint32_t ciaddr; - /**< 'your' (client) IP address. - */ + /**< 'your' (client) IP address. + */ uint32_t yiaddr; - /**< IP address of next server to use in bootstrap; - returned in DHCPOFFER, DHCPACK by server. - */ + /**< IP address of next server to use in bootstrap; + returned in DHCPOFFER, DHCPACK by server. + */ uint32_t siaddr; - /**< Relay agent IP address, used in booting via a relay agent. - */ + /**< Relay agent IP address, used in booting via a relay agent. + */ uint32_t giaddr; - /**< Client hardware address. - */ + /**< Client hardware address. + */ uint8_t chaddr[16]; - /**< Optional server host name, null terminated string. - */ + /**< Optional server host name, null terminated string. + */ uint8_t sname[64]; - /**<Boot file name, null terminated string; "generic" name or null in DHCPDISCOVER, - fully qualifieddirectory-path name in DHCPOFFER. - */ + /**<Boot file name, null terminated string; "generic" name or null in DHCPDISCOVER, + fully qualifieddirectory-path name in DHCPOFFER. + */ uint8_t file[128]; - /**Optional parameters field. See the options documents for a list of defined options. - For more information please refer to RFC 2132, 1497 and 1533. - */ + /**Optional parameters field. See the options documents for a list of defined options. + For more information please refer to RFC 2132, 1497 and 1533. + */ tnet_dhcp_options_L_t *options; } tnet_dhcp_message_t; |