Giter Site home page Giter Site logo

python-arpreq's Introduction

arpreq

https://travis-ci.org/sebschrader/python-arpreq.svg?branch=master https://img.shields.io/pypi/v/arpreq.svg?maxAge=2592000 https://img.shields.io/pypi/pyversions/arpreq.svg?maxAge=2592000 https://img.shields.io/pypi/implementation/arpreq.svg?maxAge=2592000 https://img.shields.io/pypi/wheel/arpreq.svg?maxAge=2592000 https://img.shields.io/pypi/l/arpreq.svg?maxAge=2592000

Python C extension to query the Kernel ARP cache for the MAC address of a given IP address.

Usage

The arpreq module exposes a single function arpreq, that will resolve a given IPv4 address into a MAC address.

An IP address can only be resolved to a MAC address if it is on the same subnet as your machine.

Let's assume your current machine has the address 192.168.1.10 and another machine with the address 192.168.1.1 is on the same subnet:

>>> import arpreq
>>> arpreq.arpreq('192.168.1.1')
'00:11:22:33:44:55'

If a IP address can not be resolved to an MAC address, None is returned.

>>> arpreq.arpreq('8.8.8.8') is None
True

IP addresses may be also be specified as int or rich IP address data type of the common ipaddr, ipaddress, or netaddr modules.

>>> arpreq.arpreq(0x7F000001)
'00:00:00:00:00:00'
>>> import netaddr
>>> arpreq.arpreq(netaddr.IPAddress('127.0.0.1'))
'00:00:00:00:00:00'
>>> import ipaddr # on Python 2
>>> arpreq.arpreq(ipaddr.IPv4Address('127.0.0.1'))
'00:00:00:00:00:00'
>>> import ipaddress
>>> arpreq.arpreq(ipaddress.IPv4Address(u'127.0.0.1'))
'00:00:00:00:00:00'

Supported Platforms

This extension has only been tested on Linux, it should however work on any platform that supports the SIOCGARP ioctl, which is virtually every BSD, Linux and Mac OS.

Changelog

v0.3.3 (2017-05-03)

  • Disable PEP-489 on PyPy3
  • Disable PyModule_GetState on PyPy3
  • Provide a Debian package

v0.3.2 (2017-05-03)

  • Support point-to-point veth pairs (See #6)
  • Accept unicode objects on Python 2 and bytes objects on Python 3 (See #5)
  • Some test improvements

v0.3.1 (2016-07-06)

  • Don't use private _PyErr_ChainExceptions (breaks on Debian Jessie)

v0.3.0 (2016-06-26)

  • Use PEP 489 multi-phase extension module initialization on Python 3.5+
  • Close socket if module initialization failed
  • Code cleanup

v0.2.1 (2016-06-26)

  • Fix memset overflow

v0.2.0 (2016-06-09)

  • Provide Python wheels
  • Support int and rich IP address objects as IP address arguments
  • Release the GIL during arpreq
  • Add units tests
  • Rework MAC string creation
  • Restructure module initialization

v0.1.0 (2015-11-28)

  • Initial release

python-arpreq's People

Contributors

sebschrader avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.