[Dhcp-agent-commits] CVS: dhcp-agent dhcp-agent.h,1.21,1.22 dhcp-icmp.c,1.1.1.1,1.2 dhcp-sysconf.c,1
Status: Alpha
Brought to you by:
actmodern
|
From: Thamer Al-H. <act...@us...> - 2002-02-09 23:29:40
|
Update of /cvsroot/dhcp-agent/dhcp-agent
In directory usw-pr-cvs1:/tmp/cvs-serv6508
Modified Files:
dhcp-agent.h dhcp-icmp.c dhcp-sysconf.c
Log Message:
added icmp routines for mask discovery;
Index: dhcp-agent.h
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-agent.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** dhcp-agent.h 9 Feb 2002 16:34:42 -0000 1.21
--- dhcp-agent.h 9 Feb 2002 23:29:37 -0000 1.22
***************
*** 240,244 ****
typedef struct {
! int dummy;
} icmp_obj;
--- 240,245 ----
typedef struct {
! struct icmp_hdr icmp_header;
! union icmp_msg icmp_msg;
} icmp_obj;
Index: dhcp-icmp.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-icmp.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** dhcp-icmp.c 29 Jan 2002 18:05:05 -0000 1.1.1.1
--- dhcp-icmp.c 9 Feb 2002 23:29:37 -0000 1.2
***************
*** 38,39 ****
--- 38,115 ----
xfree(icmp);
}
+
+ void icmp_set_type(icmp_obj *icmp, uint8_t type)
+ {
+ icmp->icmp_header.icmp_type = type;
+ }
+
+ void icmp_set_code(icmp_obj *icmp, uint8_t code)
+ {
+ icmp->icmp_header.icmp_code = code;
+ }
+
+ void icmp_set_cksum(icmp_obj *icmp, uint16_t cksum)
+ {
+ icmp->icmp_header.icmp_cksum = cksum;
+ }
+
+ void icmp_mask_set_id(icmp_obj *icmp, uint32_t id)
+ {
+ icmp->icmp_msg.mask.icmp_id = htonl(id);
+ }
+
+ void icmp_mask_set_seq(icmp_obj *icmp, uint32_t seq)
+ {
+ icmp->icmp_msg.mask.icmp_seq = htonl(seq);
+ }
+
+ void icmp_mask_set_mask(icmp_obj *icmp, uint32_t mask)
+ {
+ icmp->icmp_msg.mask.icmp_mask = htonl(mask);
+ }
+
+ static void icmp_write_mask_packet_image(icmp_obj *icmp, unsigned char *packet)
+ {
+ memcpy(packet, &icmp->icmp_msg.mask.icmp_id,
+ sizeof(icmp->icmp_msg.mask.icmp_id));
+ packet += sizeof(icmp->icmp_msg.mask.icmp_id);
+
+ memcpy(packet, &icmp->icmp_msg.mask.icmp_seq,
+ sizeof(icmp->icmp_msg.mask.icmp_seq));
+ packet += sizeof(icmp->icmp_msg.mask.icmp_seq);
+
+ memcpy(packet, &icmp->icmp_msg.mask.icmp_mask,
+ sizeof(icmp->icmp_msg.mask.icmp_mask));
+
+ return;
+ }
+
+ void icmp_write_packet_image(icmp_obj *icmp, unsigned char *packet)
+ {
+
+ memcpy(packet, &icmp->icmp_header.icmp_type, sizeof(icmp->icmp_header.icmp_type));
+ packet += sizeof(icmp->icmp_header.icmp_type);
+
+ memcpy(packet, &icmp->icmp_header.icmp_code, sizeof(icmp->icmp_header.icmp_code));
+ packet += sizeof(icmp->icmp_header.icmp_code);
+
+ memcpy(packet, &icmp->icmp_header.icmp_cksum, sizeof(icmp->icmp_header.icmp_cksum));
+ packet += sizeof(icmp->icmp_header.icmp_cksum);
+
+ switch(ntohl(icmp->icmp_header.icmp_type)) {
+
+ /* both mask types have the same construction. */
+
+ case ICMP_MASK: /* fall through. */
+ case ICMP_MASKREPLY:
+
+ icmp_write_mask_packet_image(icmp, packet);
+ break;
+
+ default:
+ /* major error if we actually get here. */
+ fatal_error("icmp_write_packet_image() called with improper settings on icmp packet! aborting!");
+ }
+
+ return;
+ }
Index: dhcp-sysconf.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-sysconf.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** dhcp-sysconf.c 9 Feb 2002 15:50:30 -0000 1.6
--- dhcp-sysconf.c 9 Feb 2002 23:29:37 -0000 1.7
***************
*** 27,30 ****
--- 27,35 ----
#include <dhcp-agent.h>
+ /* Only use handlers here which can be done in any order.
+ * Some special handlers are done in a particular order
+ * before we run these routines.
+ */
+
sysconf_handler sysconf_handlers[] = {
{ NULL, }, /* 0 */ /* Pad -- don't handle here. */
|