By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,282 Members | 1,177 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,282 IT Pros & Developers. It's quick & easy.

Layer 2 socket connection

P: n/a
Hello all -

I'm looking at trying to write a python script to connect to a layer 2
bridge (no IP available).

Looking at the sockets function, it's not clear if I can connect using
only the mac address - it appears to want either a broadcast address
or a specific IP address.

Can anyone give me a clue on opening a layer 2 socket in Python?

Aug 15 '07 #1
Share this Question
Share on Google+
4 Replies

P: n/a
I'm looking at trying to write a python script to connect to a layer 2
bridge (no IP available).

Looking at the sockets function, it's not clear if I can connect using
only the mac address - it appears to want either a broadcast address
or a specific IP address.

Can anyone give me a clue on opening a layer 2 socket in Python?
If your operating system supports the PF_PACKET protocol family, you
can try to use that. Python only wraps the socket interface of the
operating system, so if the system's socket implementation has no
facility for that, Python cannot expose it to you, either.

Regards,
Martin
Aug 15 '07 #2

P: n/a
On Aug 15, 12:05 pm, "Martin v. Lwis"
<snip>
If your operating system supports the PF_PACKET protocol family, you
can try to use that. Python only wraps the socket interface of the
operating system, so if the system's socket implementation has no
facility for that, Python cannot expose it to you, either.

Regards,
Martin
I take it this means "Non-Unix variants" may have problems :)

Thanks, Martin. I'll have a look at that.

I'm working on a Linux platform, but there may be a need later on to
work with an MS platform as well (something for the boss).

Aug 15 '07 #3

P: n/a
On Aug 15, 7:21 pm, alisonken1 <alisonk...@gmail.comwrote:
Hello all -

I'm looking at trying to write a python script to connect to a layer 2
bridge (no IP available).

Looking at the sockets function, it's not clear if I can connect using
only the mac address - it appears to want either a broadcast address
or a specific IP address.

Can anyone give me a clue on opening a layer 2 socket in Python?
I use impacket for stuff like that, see http://oss.coresecurity.com/projects/impacket.html

Cheers

Rich.

Aug 16 '07 #4

P: n/a
On Aug 16, 5:03 am, "richmoor...@gmail.com" <richmoor...@gmail.com>
wrote:
<snip>
I use impacket for stuff like that, seehttp://oss.coresecurity.com/projects/impacket.html

Cheers

Rich.
Thanks, Rich - I'll have a look

Aug 16 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.