[Israel.pm] problem with send()

Semuel Fomberg semuel at semuel.co.il
Mon Jan 9 17:08:10 PST 2006


Hello There.

Are you sure that the DHCP protocol is working on UDP and not on ICMP or
something like that?
(If I got the protocol name a bit wrong, it's because my memory on there
protocols is totally rusty)
because if it works on ICMP, opening a UDP socket won't do you any good.

Have fun,
Semuel.

-----Original Message-----
From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il] On
Behalf Of Levenglick Dov-RM07994
Sent: Monday, January 09, 2006 2:45 PM
To: 'perl at perl.org.il'
Subject: [Israel.pm] problem with send()

Hi,
I am constantly getting this message "couldn't send DHCP reply (Unknown
error)" from the attached script. Does anyone know how I can get some
more information on why this is failing? I assume that it is to do with
the fact the socket is not connected; however I can't connect to a DHCP
client since its IP address has not yet been assigned. 
If I am totally off track, please tell me. Either way, HELP!!!


#!/usr/local/bin/perl5.6.1

use strict;
use warnings;
use IO::Socket::INET;
use Net::DHCP::Packet;
use Net::TFTPd;

my $msg;
my $sock = IO::Socket::INET->new(
	LocalAddr => '223.31.95.191',
	LocalPort => 67, 
	Proto => "udp", 
	Broadcast => 1
) or die "socket: $@";

# wait for DHCP request to come in
$sock->recv($msg, 1024);
my $req = Net::DHCP::Packet->new($msg);
# create DHCP reply
my $dhcp_reply = Net::DHCP::Packet->new(
	op 	=> Net::DHCP::Packet::BOOTREPLY(),
	htype 	=> 1,
	hlen	=> 6,
	ciaddr 	=> '223.31.95.200',
	yiaddr 	=> '223.31.95.191',
	siaddr 	=> '223.31.95.191',
	file 	=> 'tftp_file',
	xid	=> $req->getOption('xid'),
	flags	=> 0x0000,
);	
# send DHCP reply
$sock->send($dhcp_reply->serialize(), MSG_DONTROUTE ) or die "couldn't
send DHCP reply ($!)\n";

 
Best Regards,
Dov Levenglick
DSP SoC System and Applications Engineer,
Network and Computing Systems Group
Freescale Semiconductor Israel
Tel. +972-9-952-2804
The information contained in this email is classified as:
[ ] General Business Information
[ ] Freescale Internal Use Only
[ ] Freescale Confidential Propriety
[x] Personal Memorandum
 


_______________________________________________
Perl mailing list
Perl at perl.org.il
http://perl.org.il/mailman/listinfo/perl




-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.15/223 - Release Date:
06/01/2006






More information about the Perl mailing list