Giter Site home page Giter Site logo

ipv6_python's Introduction

Advanced IPv6 Socket Manipulation for Python

Description:

This rather simplistic extension module is intended to allow for more advanced
manipulation of IPv6 sockets in Python.  In particular, Python did not have an
easy means to interact with the flow label of a particular IPv6 socket.  This
extension currently allows for flow labels to be enabled on a socket and a
random flow label can be requested from the kernel.  In the future, additional
options may be added to facilitate additional flow label actions.

Installation:

This package is installed using distutils.  The most common approach is to run:

  python setup.py install

Usage:

  import ipv6

You can then pass an IPv6 socket to the function get_flow_label() to
apply a random flow label assigned by the kernel.  The first parameter
is the socket object or the integer file descriptor.  The remaining
parameters are optional depending on the state of your socket.  Here is
an example:

  sockaddr = ipv6.get_flow_label(sock,*sockaddr)

See https://docs.python.org/2/library/socket.html for info on sockaddr

The get_flow_label call returns a new sockaddr structure with the flowinfo
field set to newly created flow label assigned by the kernel.  You can then
send data as normal.

License:

This code is released under the NASA Open Source Agreement version 1.3

Simple Example:

# Send a single UDP packet
import socket
import ipv6
host = "::1"
port = 3300
data = "NASA"
resolve = socket.getaddrinfo(host, port, socket.AF_INET6, socket.SOCK_DGRAM)
(family, socktype, proto, _, sockaddr) = resolve[0]
sock = socket.socket(family, socktype, proto)
sockaddr = ipv6.get_flow_label(sock,*sockaddr)
print "Flow Label:",hex(sockaddr[2])
sock.sendto(data,sockaddr)

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.