IRDA(7)

πŸ“¦ version 0.9.18, in fedora 43, fedora 44

✨ IRDA(7) β€” the Linux-IrDA protocol stack, bestie edition ✨

okay so. sit down, grab a strawberry πŸ“, because we're about to talk about Linux-IrDA β€” and it's lowkey iconic. this is the irda manual, straight out of the Linux-IrDA man pages, and yes i'm about to make you obsessed with an infrared protocol stack. no cap. πŸ’…


🌸 SYNOPSIS 🌸

like, here's the vibe in code form. first you include the header, then you make your sockets:

#include <linux/irda.h>

stream_s = socket(PF_INET, SOCK_STREAM, 0);
seqpkt_s = socket(PF_INET, SOCK_SEQPACKET, 0);
dgram_s = socket(PF_INET, SOCK_DGRAM, IRDAPROTO_UNITDATA);
ultra_s = socket(PF_INET, SOCK_DGRAM, IRDAPROTO_ULTRA);

that's it. that's the whole entrance exam. πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

Linux-IrDA is a complete implementation of the various IrDA protocols and IrDA drivers for Linux. complete! not a demo, not a teaser, the whole thing. πŸ‘‘

The configuration of the low level of the IrDA stack (IrDA ports) and the various IrDA drivers are described in irattach(8).

The usage of the higher layers of the IrDA stack (IrCOMM, IrLPT, IrNET, IrLAN, OBEX...) are described in their respective man pages.

The core of the Linux-IrDA protocol stack is composed of the IrLAP, IrLMP, IrTTP and IrIAS protocols and is implemented as a kernel module. The programmer's interface for the IrDA stack is socket based. For more information on sockets, see socket(7).

note bestie: higher level IrDA protocols may offer a different programmer's interface. For example IrCOMM offers a TTY based interface and OBEX is available through a user space library. so don't come for the socket interface when you're using something else, they're different eras. 😭

πŸ’– SOCKETS TYPE πŸ’–

The Linux-IrDA socket interface offers 4 types of sockets. four. count 'em. each one's got main character energy in its own way:

  • Stream socket - SOCK_STREAM, 0 β€” Stream sockets provides a reliable, stream oriented, full duplex connection between two sockets on top of IrTTP, similar to TCP sockets. IrTTP guarantees that the data arrives in order and manages flow control, IrLAP retransmits lost packets. Stream sockets does not preserve record boundaries. (so like, boundaries? not a thing here. she's a continuous stream, she doesn't do edges ✨)
  • SeqPacket socket - SOCK_SEQPACKET, 0 β€” SeqPacket sockets provides a reliable, datagram oriented, full duplex connection between two sockets on top of IrTTP. IrTTP guarantees that the data arrives in order and manages flow control, IrLAP retransmits lost packets. SeqPacket sockets preserve record boundaries. Large datagrams will be fragmented as needed. (reliable and boundary-respecting? she's the whole package, honestly πŸ’…)
  • Datagram socket - SOCK_DGRAM, IRDAPROTO_UNITDATA β€” SeqPacket sockets provides a reliable, datagram oriented, full duplex connection between two sockets on top of IrLMP. There is no guarantee that the data arrives in order and there is no flow control, however IrLAP retransmits lost packets. Datagram sockets preserve record boundaries. No fragmentation is provided, datagrams larger than the IrDA link MTU are truncated or discarded. (yes, the original really does say "SeqPacket sockets" in this one's description β€” we're keeping it, character for character, i don't make the rules 🫢)
  • Ultra socket - SOCK_DGRAM, IRDAPROTO_ULTRA β€” Ultra sockets provides a connectionless, unreliable datagram packet service on top of IrLAP-Ultra. Ultra datagrams are sent and received only when no IrLAP connection is established and otherwise discarded. They are always transmitted at 9600 bauds. Datagrams may be lost or reordered, and there is no flow control. Ultra sockets preserve record boundaries. No fragmentation is provided, datagrams larger than the Ultra MTU (382 bytes) are truncated or discarded. (chaotic, unbothered, lowkey lost in the mail. we stan a reckless queen πŸ’€)

πŸŽ€ ADDRESS FORMAT πŸŽ€

An IrDA socket address is defined as a combination of an IrDA interface address and a service name. Service names are automatically resolved to lsap through the IrIAP protocol. cute, right?

struct sockaddr_irda {
    sa_family_t sir_family;   /* AF_IRDA */
    __u8        sir_lsap_sel; /* LSAP selector */
    __u32       sir_addr;     /* Device address */
    char        sir_name[25]; /* Usually <service>:IrDA:TinyTP */
};

breaking it down for you, bestie:

  • sin_family is always set to AF_IRDA.
  • sir_lsap_sel is usually not used.
  • sir_addr is the optional address of the peer (if no given the first peer discovered will be used).
  • sir_name is the service name of the socket.

πŸ”₯ SOCKET OPTIONS πŸ”₯

IrDA sockets supports some protocol specific socket options that can be set with setsockopt(2) and read with getsockopt(2). The socket option level for IrDA is SOL_IRLMP. remember that. it's the password. πŸ—οΈ

✨ Options that can be set:

  • IRLMP_IAS_SET β€” Set an entry in the local IAS database.
  • IRLMP_IAS_DEL β€” Delete an entry from the local IAS database.
  • IRLMP_MAX_SDU_SIZE β€” Set maximum receive MTU for SeqPacket sockets.
  • IRLMP_HINTS_SET β€” Set IrDA hint bits to be advertised to peers.
  • IRLMP_HINT_MASK_SET β€” Set IrDA hint bits filter to be used when performing discovery.

πŸ’œ Options that can be get:

  • IRLMP_ENUMDEVICES β€” Perform link level discovery and return the content of the discovery log.
  • IRLMP_MAX_SDU_SIZE β€” Get maximum receive MTU.
  • IRLMP_IAS_GET β€” Get an entry from the local IAS database.
  • IRLMP_IAS_QUERY β€” Query an entry in IAS database of a peer using IrIAP.
  • IRLMP_WAITDEVICE β€” Block until a new device is discovered. Experimental feature, use with caution.
⚠️ heads up gorgeous: IRLMP_WAITDEVICE is experimental. use with caution. it will simply block until a new device shows up, so don't be dramatic when your thread just sits there vibing. that's the feature working. πŸ™ˆ

🌈 AUTHOR 🌈

Jean Tourrilhes - jt@hpl.hp.com


🫢 SEE ALSO 🫢

irattach(8), irdadump(8), irnet(4), irnetd(8).


and that's the whole page, no crumbs left. this came to you from irda-utils, dated 2 May 2003 β€” vintage, but the lore is timeless. go forth and socket() responsibly, bestie. πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from