I am sponsoring this case for Max Zhen.  This project is to provide a
wrapper for dlpi(7p) functions that enables sending/receiving layer2
network packet directly from Python, and getting/setting link related
configuration.  The requested release binding is patch.

The interface and architecture are clear enough to be a self-review.
Of cause, if there is different opinion, I would like to shift it to a
regular fast-track.  Otherwise, case is "closed approved automatically".


Thanks,
Cecilia

------------------------------------------------------------------------
1. Introduction
     1.1. Project/Component Working Name:
         Python interface to dlpi(7P)
     1.2. Name of Document Author/Supplier:
         Author:  Max Zhen
     1.3  Date of This Document:
          11 August, 2008

4. Technical Description

4.1.  Introduction

     This case introduces the dlpi Python module.  It is a wrapper module
     for dlpi(7P) functions that enables sending/receiving layer2 network
     packet directly from Python, as well as getting/setting link related
     configuration.

     A patch binding is requested.

4.2. Python 'dlpi' module

     Classification of interfaces provided in this module is 'Committed'.
     The on-line help clearly shows all interfaces and their counterparts
     of dlpi functions in this module as below:

CLASSES
     __builtin__.object
         link

     class link(__builtin__.object)
      |  link(linkname, modes) -> link object
      |
      |  Open linkname in specified mode.
      |  Three modes are supported: PASSIVE, RAW, NATIVE.
      |  See dlpi_open(3DLPI).
      |
      |  Methods defined here:
      |
      |  __init__(...)
      |      x.__init__(...) initializes x; see x.__class__.__doc__ for 
signature
      |
      |  bind(...)
      |      bind(sap) -> unsigned int
      |
      |      Attempts to bind the link to specified sap, or ANY_SAP.
      |      Returns the real sap gets bound.
      |      See dlpi_bind(3DLPI).
      |
      |  disabmulti(...)
      |      disabmulti(address) -> None
      |
      |      Disable a specified multicast address on this link.
      |      See dlpi_disabmulti(3DLPI).
      |
      |  disabnotify(...)
      |      disabnotify(handle) -> argument object, or None
      |
      |      Disables the notification registration associated with handle.
      |      You should get this handle by calling enabnotify().
      |      Returns the argument passed in when registering the 
callback, or None.
      |      See dlpi_disabnotify(3DLPI).
      |
      |  enabmulti(...)
      |      enabmulti(address) -> None
      |
      |      Enable a specified multicast address on this link.
      |      See dlpi_enabmulti(3DLPI).
      |
      |  enabnotify(...)
      |      enabnotify(events, function[, arg]) -> unsigned long
      |
      |      Enables a notification callback for the set of specified 
events,
      |      which must be one or more (by a logical OR) events listed 
as below:
      |      NOTE_LINK_DOWN         Notify when link has gone down
      |      NOTE_LINK_UP           Notify when link has come up
      |      NOTE_PHYS_ADDR         Notify when address changes
      |      NOTE_SDU_SIZE          Notify when MTU changes
      |      NOTE_SPEED             Notify when speed changes
      |      NOTE_PROMISC_ON_PHYS   Notify when DL_PROMISC_PHYS is set
      |      NOTE_PROMISC_OFF_PHYS  Notify when DL_PROMISC_PHYS is cleared
      |      Returns a handle for this registration.
      |      See dlpi_enabnotify(3DLPI).
      |
      |  get_bcastaddr(...)
      |      get_bcastaddr() -> string
      |
      |      Returns the broadcast address of the link.
      |      See dlpi_info(3DLPI).
      |
      |  get_fd(...)
      |      get_fd() -> int
      |
      |      Returns the integer file descriptor that can be used to 
directly
      |      operate on the link.
      |      See dlpi_fd(3DLPI).
      |
      |  get_linkname(...)
      |      get_linkname() -> string
      |
      |      Returns the name of the link.
      |      See dlpi_linkname(3DLPI).
      |
      |  get_mactype(...)
      |      get_mactype() -> unsigned char
      |
      |      Returns MAC type of the link.
      |      See <sys/dlpi.h> for the list of possible MAC types.
      |      See dlpi_info(3DLPI).
      |
      |  get_physaddr(...)
      |      get_physaddr(addrtype) -> string
      |
      |      Addrtype can be any one of the value listed below:
      |      FACT_PHYS_ADDR    Factory physical address
      |      CURR_PHYS_ADDR    Current physical address
      |      Returns the corresponding physical address of the link.
      |      See dlpi_get_physaddr(3DLPI).
      |
      |  get_qos_range(...)
      |      get_qos_range() ->
      |              (unsigned int, (int, int), (int, int), (int, int), int)
      |
      |      Returns (qos type, (trans delay target, trans delay accept),
      |      (min priority, max priority), (min protection, max protection),
      |      residual err).
      |      Unsupported QOS range values are set to UNKNOWN.
      |      See dlpi_info(3DLPI).
      |
      |  get_qos_select(...)
      |      get_qos_select() -> (unsigned int, int, int, int)
      |
      |      Returns (qos type, trans delay, priority, residul err).
      |      Unsupported QOS parameters are set to UNKNOWN.
      |      See dlpi_info(3DLPI).
      |
      |  get_sap(...)
      |      get_sap() -> unsigned int
      |
      |      Returns the sap bound to this link.
      |      See dlpi_info(3DLPI).
      |
      |  get_sdu(...)
      |      get_sdu() -> (unsigned int, unsigned int)
      |
      |      Returns (max sdu, min sdu).
      |      See dlpi_info(3DLPI).
      |
      |  get_state(...)
      |      get_state() -> unsigned int
      |
      |      Returns current state of the link (either UNBOUND or IDLE).
      |      See dlpi_info(3DLPI).
      |
      |  get_timeout(...)
      |      get_timeout() -> int
      |
      |      Returns current time out value of the link.
      |      See dlpi_info(3DLPI).
      |
      |  promiscoff(...)
      |      promiscoff(level) -> None
      |
      |      Disables promiscuous mode for the link at levels:
      |      PROMISC_PHYS     Promiscuous mode at the physical level
      |      PROMISC_SAP      Promiscuous mode at the SAP level
      |      PROMISC_MULTI    Promiscuous mode for all multicast addresses
      |      See dlpi_promiscoff(3DLPI).
      |
      |  promiscon(...)
      |      promiscon(level) -> None
      |
      |      Enables promiscuous mode for the link at levels:
      |      PROMISC_PHYS     Promiscuous mode at the physical level
      |      PROMISC_SAP      Promiscuous mode at the SAP level
      |      PROMISC_MULTI    Promiscuous mode for all multicast addresses
      |      See dlpi_promiscon(3DLPI).
      |
      |  recv(...)
      |      recv(trunksize[, timeout]) -> (string, string)
      |
      |      Attempts to receive message over this link.
      |      You need to specify the trunk size for the received message.
      |      And you can specify timeout value in seconds.
      |      Returns (source address, message data).
      |      See dlpi_recv(3DLPI).
      |
      |  send(...)
      |      send(destaddr, message[, sap, minpri, maxpri]) -> None
      |
      |      Attempts to send message over this link to destaddr.
      |      You can specify new sap, and priority range (minpri, maxpri).
      |      See dlpi_send(3DLPI).
      |
      |  set_physaddr(...)
      |      set_physaddr(address) -> None
      |
      |      Sets the physical address of the link.
      |      See dlpi_set_physaddr(3DLPI).
      |
      |  set_timeout(...)
      |      set_timeout(timeout) -> None
      |
      |      Sets time out value of the link (default value: DEF_TIMEOUT).
      |      See dlpi_set_timeout(3DLPI).
      |
      |  unbind(...)
      |      unbind() -> None
      |
      |      Attempts to unbind the link from previously bound sap.
      |      See dlpi_unbind(3DLPI).
      |
      | 
----------------------------------------------------------------------
      |  Data and other attributes defined here:
      |
      |  __new__ = <built-in method __new__ of type object>
      |      T.__new__(S, ...) -> a new object with type S, a subtype of T

FUNCTIONS
     arptype(...)
         arptype(arptype) -> unsigned int

         Converts a DLPI MAC type to an ARP hardware type defined
          in <netinet/arp.h>
         See dlpi_arptype(3DLPI)

     iftype(...)
         iftype(iftype) -> unsigned int

         Converts a DLPI MAC type to a BSD socket interface type
         defined in <net/if_types.h>
         See dlpi_iftype(3DLPI)

     listlink(...)
         listlink() -> list

         Returns a list containing link names of all links on the system.

     mactype(...)
         mactype(mactype) -> string

         Returns a string that describes the specified mactype.
         Valid mac types are defined in <sys/dlpi.h>.
         See dlpi_mactype(3DLPI)

DATA
     ANY_SAP = 4294967295
     CURR_PHYS_ADDR = 2
     DEF_TIMEOUT = 5
     FACT_PHYS_ADDR = 1
     IDLE = 3
     NATIVE = 32
     NOTE_LINK_DOWN = 8
     NOTE_LINK_UP = 16
     NOTE_PHYS_ADDR = 1
     NOTE_PROMISC_OFF_PHYS = 4
     NOTE_PROMISC_ON_PHYS = 2
     NOTE_SDU_SIZE = 128
     NOTE_SPEED = 256
     PASSIVE = 2
     PROMISC_MULTI = 3
     PROMISC_PHYS = 1
     PROMISC_SAP = 2
     RAW = 4
     UNBOUND = 0
     UNKNOWN = -1

4.3.  References

   None


6. Resources and Schedule
     6.4. Steering Committee requested information
        6.4.1. Consolidation C-team Name:
                JDS
     6.5. ARC review type: FastTrack
     6.6. ARC Exposure: open

Reply via email to