packages feed

network-info 0.1 → 0.1.0.1

raw patch · 6 files changed

+67/−1 lines, 6 filesdep ~base

Dependency ranges changed: base

Files

+ README.mkd view
@@ -0,0 +1,15 @@+network-info+=============++This library provides simple read-only access to the local computer's+networking configuration. It is currently capable of getting a list of+all the network interfaces and their respective IPv4, IPv6 and MAC+addresses.++Compatibility+--------------++network-info has been tested and is known to work on Ubuntu 10.04 and+Windows XP. It probably works on other flavours of Linux and Windows as+well. I haven't tried to get it working on BSD or Mac OS X yet but it+should be quite similar if not the same as the code for Linux.
+ cbits/common.h view
@@ -0,0 +1,26 @@+inline void ipv4copy(ipv4 *dst, struct sockaddr *addr)+{+    *dst = ((struct sockaddr_in *)addr)->sin_addr.s_addr;+}++inline void ipv6copy(ipv6 *dst, struct sockaddr *addr)+{+    memcpy(dst, ((struct sockaddr_in6 *)addr)->sin6_addr.s6_addr, sizeof(ipv6));+}++inline int wcsempty(const wchar_t *str)+{+    return wcslen(str) == 0;+}++inline void wszcopy(wchar_t *dst, const wchar_t *src, size_t dst_size)+{+    wcsncpy(dst, src, dst_size - 1);+    dst[dst_size - 1] = '\0';+}++inline void mbswszcopy(wchar_t *dst, const char *src, size_t dst_size)+{+    mbstowcs(dst, src, dst_size - 1);+    dst[dst_size - 1] = '\0';+}
+ cbits/network.h view
@@ -0,0 +1,14 @@+#define NAME_SIZE (128+4)+#define MAC_SIZE 6++typedef long ipv4;+typedef long ipv6[4];++struct network_interface {+    wchar_t name[NAME_SIZE];+    ipv4 ip_address;+    ipv6 ip6_address;+    unsigned char mac_address[MAC_SIZE];+};++int c_get_network_interfaces(struct network_interface *ns, int max_ns);
network-info.cabal view
@@ -1,5 +1,5 @@ Name:                network-info-version:             0.1+version:             0.1.0.1 synopsis:            Access the local computer's basic network configuration description:         This library provides simple read-only access to the local computer's                      networking configuration. It is currently capable of getting a list of@@ -16,6 +16,13 @@ category:            Network build-type:          Simple cabal-version:       >=1.8.0.4++extra-source-files:+  cbits/common.h,+  cbits/network.h,+  README.mkd,+  run-tests.sh,+  run-tests.bat  source-repository head   type:     git
+ run-tests.bat view
@@ -0,0 +1,2 @@+@echo off
+cabal configure -ftest && cabal build && dist\build\test-network-info\test-network-info.exe
+ run-tests.sh view
@@ -0,0 +1,2 @@+#!/bin/bash+cabal configure -ftest && cabal build && dist/build/test-network-info/test-network-info