Add constants and syscall for if_nametoindex

This commit is contained in:
Eugen Wissner 2018-08-22 06:59:38 +02:00
parent c205c087a4
commit 0fc0aa23f7
5 changed files with 276 additions and 0 deletions

View File

@ -34,6 +34,18 @@ _D5tanya3sys5linux7syscallQiFNbNilllZl:
ret
// 3 parameters.
.globl _D5tanya3sys5linux7syscallQiFNbNillllZl
.type _D5tanya3sys5linux7syscallQiFNbNillllZl, @function
_D5tanya3sys5linux7syscallQiFNbNillllZl:
movq %rcx, %rax
syscall
ret
// 6 parameters.
.globl _D5tanya3sys5linux7syscallQiFNbNilllllllZl
.type _D5tanya3sys5linux7syscallQiFNbNilllllllZl, @function

View File

@ -17,6 +17,9 @@ version (TanyaNative):
extern ptrdiff_t syscall(ptrdiff_t, ptrdiff_t, ptrdiff_t)
@nogc nothrow @system;
extern ptrdiff_t syscall(ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t)
@nogc nothrow @system;
extern ptrdiff_t syscall(ptrdiff_t,
ptrdiff_t,
ptrdiff_t,
@ -38,6 +41,10 @@ extern ptrdiff_t syscall_(ptrdiff_t, ptrdiff_t, ptrdiff_t)
@nogc nothrow pure @system;
pragma(mangle, getOverloadMangling!1)
extern ptrdiff_t syscall(ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t)
@nogc nothrow pure @system;
pragma(mangle, getOverloadMangling!2)
extern ptrdiff_t syscall_(ptrdiff_t,
ptrdiff_t,
ptrdiff_t,

View File

@ -0,0 +1,78 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* Copyright: Eugene Wissner 2018.
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
* Mozilla Public License, v. 2.0).
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
* Source: $(LINK2 https://github.com/caraus-ecms/tanya/blob/master/source/tanya/sys/posix/ioctl.d,
* tanya/sys/posix/ioctl.d)
*/
module tanya.sys.posix.ioctl;
version (TanyaNative):
enum
{
SIOCADDRT = 0x890B, // Add routing table entry.
SIOCDELRT = 0x890C, // Delete routing table entry.
SIOCRTMSG = 0x890D, // Call to routing system.
SIOCGIFNAME = 0x8910, // Get iface name.
SIOCSIFLINK = 0x8911, // Set iface channel.
SIOCGIFCONF = 0x8912, // Get iface list.
SIOCGIFFLAGS = 0x8913, // Get flags.
SIOCSIFFLAGS = 0x8914, // Set flags.
SIOCGIFADDR = 0x8915, // Get PA address.
SIOCSIFADDR = 0x8916, // Set PA address.
SIOCGIFDSTADDR = 0x8917, // Get remote PA address.
SIOCSIFDSTADDR = 0x8918, // Set remote PA address.
SIOCGIFBRDADDR = 0x8919, // Get broadcast PA address.
SIOCSIFBRDADDR = 0x891a, // Set broadcast PA address.
SIOCGIFNETMASK = 0x891b, // Get network PA mask.
SIOCSIFNETMASK = 0x891c, // Set network PA mask.
SIOCGIFMETRIC = 0x891d, // Get metric.
SIOCSIFMETRIC = 0x891e, // Set metric.
SIOCGIFMEM = 0x891f, // Get memory address (BSD).
SIOCSIFMEM = 0x8920, // Set memory address (BSD).
SIOCGIFMTU = 0x8921, // Get MTU size.
SIOCSIFMTU = 0x8922, // Set MTU size.
SIOCSIFNAME = 0x8923, // Set interface name.
SIOCSIFHWADDR = 0x8924, // Set hardware address.
SIOCGIFENCAP = 0x8925, // Get/set encapsulations.
SIOCSIFENCAP = 0x8926,
SIOCGIFHWADDR = 0x8927, // Get hardware address.
SIOCGIFSLAVE = 0x8929, // Driver slaving support.
SIOCSIFSLAVE = 0x8930,
SIOCADDMULTI = 0x8931, // Multicast address lists.
SIOCDELMULTI = 0x8932,
SIOCGIFINDEX = 0x8933, // Name -> if_index mapping.
SIOGIFINDEX = SIOCGIFINDEX, // Misprint compatibility.
SIOCSIFPFLAGS = 0x8934, // Set/get extended flags set.
SIOCGIFPFLAGS = 0x8935,
SIOCDIFADDR = 0x8936, // Delete PA address.
SIOCSIFHWBROADCAST = 0x8937, // Set hardware broadcast address.
SIOCGIFCOUNT = 0x8938, // Get number of devices.
SIOCGIFBR = 0x8940, // Bridging support.
SIOCSIFBR = 0x8941, // Set bridging options.
SIOCGIFTXQLEN = 0x8942, // Get the tx queue length.
SIOCSIFTXQLEN = 0x8943, // Set the tx queue length.
SIOCDARP = 0x8953, // Delete ARP table entry.
SIOCGARP = 0x8954, // Get ARP table entry.
SIOCSARP = 0x8955, // Set ARP table entry.
SIOCDRARP = 0x8960, // Delete RARP table entry.
SIOCGRARP = 0x8961, // Get RARP table entry.
SIOCSRARP = 0x8962, // Set RARP table entry.
SIOCGIFMAP = 0x8970, // Get device parameters.
SIOCSIFMAP = 0x8971, // Set device parameters.
SIOCADDDLCI = 0x8980, // Create new DLCI device.
SIOCDELDLCI = 0x8981, // Delete DLCI device.
}

View File

@ -0,0 +1,27 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* Copyright: Eugene Wissner 2018.
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
* Mozilla Public License, v. 2.0).
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
* Source: $(LINK2 https://github.com/caraus-ecms/tanya/blob/master/source/tanya/sys/posix/net/if_.d,
* tanya/sys/posix/net/if_.d)
*/
module tanya.sys.posix.net.if_;
version (TanyaNative):
enum size_t IF_NAMESIZE = 16;
struct ifreq
{
char[IF_NAMESIZE] ifr_name;
union
{
int ifr_ifindex;
}
}

View File

@ -0,0 +1,152 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* Copyright: Eugene Wissner 2018.
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
* Mozilla Public License, v. 2.0).
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
* Source: $(LINK2 https://github.com/caraus-ecms/tanya/blob/master/source/tanya/sys/posix/socket.d,
* tanya/sys/posix/socket.d)
*/
module tanya.sys.posix.socket;
version (TanyaNative):
/*
* Protocol families.
*/
enum
{
PF_UNSPEC = 0, // Unspecified.
PF_LOCAL = 1, // Local to host (pipes and file-domain).
PF_UNIX = PF_LOCAL, // POSIX name for PF_LOCAL.
PF_FILE = PF_LOCAL, // Another non-standard name for PF_LOCAL.
PF_INET = 2, // IP protocol family.
PF_AX25 = 3, // Amateur Radio AX.25.
PF_IPX = 4, // Novell Internet Protocol.
PF_APPLETALK = 5, // Appletalk DDP.
PF_NETROM = 6, // Amateur radio NetROM.
PF_BRIDGE = 7, // Multiprotocol bridge.
PF_ATMPVC = 8, // ATM PVCs.
PF_X25 = 9, // Reserved for X.25 project.
PF_INET6 = 10, // IP version 6.
PF_ROSE = 11, // Amateur Radio X.25 PLP.
PF_DECnet = 12, // Reserved for DECnet project.
PF_NETBEUI = 13, // Reserved for 802.2LLC project.
PF_SECURITY = 14, // Security callback pseudo AF.
PF_KEY = 15, // PF_KEY key management API.
PF_NETLINK = 16, // Kernel user interface device.
PF_ROUTE = PF_NETLINK, // Alias to emulate 4.4BSD.
PF_PACKET = 17, // Packet family.
PF_ASH = 18, // Ash.
PF_ECONET = 19, // Acorn Econet.
PF_ATMSVC = 20, // ATM SVCs.
PF_RDS = 21, // RDS sockets.
PF_SNA = 22, // Linux SNA Project.
PF_IRDA = 23, // IRDA sockets.
PF_PPPOX = 24, // PPPoX sockets.
PF_WANPIPE = 25, // Wanpipe API sockets.
PF_LLC = 26, // Linux LLC.
PF_IB = 27, // Native InfiniBand address.
PF_MPLS = 28, // MPLS.
PF_CAN = 29, // Controller Area Network.
PF_TIPC = 30, // TIPC sockets.
PF_BLUETOOTH = 31, // Bluetooth sockets.
PF_IUCV = 32, // IUCV sockets.
PF_RXRPC = 33, // RxRPC sockets.
PF_ISDN = 34, // mISDN sockets.
PF_PHONET = 35, // Phonet sockets.
PF_IEEE802154 = 36, // IEEE 802.15.4 sockets.
PF_CAIF = 37, // CAIF sockets.
PF_ALG = 38, // Algorithm sockets.
PF_NFC = 39, // NFC sockets.
PF_VSOCK = 40, // vSockets.
PF_MAX = 41, // For now.
}
/*
* Address families.
*/
enum
{
AF_UNSPEC = PF_UNSPEC,
AF_LOCAL = PF_LOCAL,
AF_UNIX = PF_UNIX,
AF_FILE = PF_FILE,
AF_INET = PF_INET,
AF_AX25 = PF_AX25,
AF_IPX = PF_IPX,
AF_APPLETALK = PF_APPLETALK,
AF_NETROM = PF_NETROM,
AF_BRIDGE = PF_BRIDGE,
AF_ATMPVC = PF_ATMPVC,
AF_X25 = PF_X25,
AF_INET6 = PF_INET6,
AF_ROSE = PF_ROSE,
AF_DECnet = PF_DECnet,
AF_NETBEUI = PF_NETBEUI,
AF_SECURITY = PF_SECURITY,
AF_KEY = PF_KEY,
AF_NETLINK = PF_NETLINK,
AF_ROUTE = PF_ROUTE,
AF_PACKET = PF_PACKET,
AF_ASH = PF_ASH,
AF_ECONET = PF_ECONET,
AF_ATMSVC = PF_ATMSVC,
AF_RDS = PF_RDS,
AF_SNA = PF_SNA,
AF_IRDA = PF_IRDA,
AF_PPPOX = PF_PPPOX,
AF_WANPIPE = PF_WANPIPE,
AF_LLC = PF_LLC,
AF_IB = PF_IB,
AF_MPLS = PF_MPLS,
AF_CAN = PF_CAN,
AF_TIPC = PF_TIPC,
AF_BLUETOOTH = PF_BLUETOOTH,
AF_IUCV = PF_IUCV,
AF_RXRPC = PF_RXRPC,
AF_ISDN = PF_ISDN,
AF_PHONET = PF_PHONET,
AF_IEEE802154 = PF_IEEE802154,
AF_CAIF = PF_CAIF,
AF_ALG = PF_ALG,
AF_NFC = PF_NFC,
AF_VSOCK = PF_VSOCK,
AF_MAX = PF_MAX,
}
/*
* Types of sockets.
*/
enum
{
// Sequenced, reliable, connection-based byte streams.
SOCK_STREAM = 1,
// Connectionless, unreliable datagrams of fixed maximum length.
SOCK_DGRAM = 2,
// Raw protocol interface.
SOCK_RAW = 3,
// Reliably-delivered messages.
SOCK_RDM = 4,
// Sequenced, reliable, connection-based, datagrams of fixed maximum
// length.
SOCK_SEQPACKET = 5,
// Datagram Congestion Control Protocol.
SOCK_DCCP = 6,
// Linux specific way of getting packets at the dev level. For writing rarp
// and other similar things on the user level.
SOCK_PACKET = 10,
}
/*
* Flags to be ORed into the type parameter of socket and socketpair and used
* for the flags parameter of paccept.
*/
enum
{
SOCK_CLOEXEC = 0x80000, // Atomically set close-on-exec flag for the new descriptor(s).
SOCK_NONBLOCK = 0x800, // Atomically mark descriptor(s) as non-blocking.
}