469,641 Members | 1,184 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,641 developers. It's quick & easy.

Layer 2 socket connection

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
4 2916
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
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
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
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.

By using this site, you agree to our Privacy Policy and Terms of Use.