PageRenderTime 29ms CodeModel.GetById 11ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 0ms

/binding/win32/inaddr.d

http://github.com/wilkie/djehuty
D | 115 lines | 63 code | 19 blank | 33 comment | 0 complexity | 63721e571f916e042fb64042b8d39e7e MD5 | raw file
  1/*
  2 * inaddr.d
  3 *
  4 * This module binds inaddr.h to D. The original copyright notice is
  5 * preserved below.
  6 *
  7 * Author: Dave Wilkinson
  8 * Originated: November 25th, 2009
  9 *
 10 */
 11
 12module binding.win32.inaddr;
 13
 14import binding.win32.windef;
 15import binding.win32.winbase;
 16import binding.win32.winnt;
 17import binding.win32.inaddr;
 18
 19extern(System):
 20
 21/*++
 22
 23Copyright (c) Microsoft Corporation
 24
 25Module Name:
 26
 27    inaddr.h
 28
 29Environment:
 30
 31    user mode or kernel mode
 32
 33--*/
 34
 35//
 36// IPv4 Internet address
 37// This is an 'on-wire' format structure.
 38//
 39struct in_addr {
 40        union _inner_union {
 41                struct _inner_struct {
 42					UCHAR s_b1;
 43					UCHAR s_b2;
 44					UCHAR s_b3;
 45					UCHAR s_b4;
 46				}
 47				_inner_struct S_un_b;
 48                struct _inner_struct2 {
 49					USHORT s_w1;
 50					USHORT s_w2;
 51				}
 52				_inner_struct2 S_un_w;
 53                ULONG S_addr;
 54        }
 55		_inner_union S_un;
 56
 57		ULONG s_addr() {
 58			return S_un.S_addr;
 59		}
 60
 61		void s_addr(ULONG val) {
 62			S_un.S_addr = val;
 63		}
 64
 65		UCHAR s_host() {
 66			return S_un.S_un_b.s_b2;
 67		}
 68
 69		void s_host(UCHAR val) {
 70			S_un.S_un_b.s_b2 = val;
 71		}
 72
 73		UCHAR s_net() {
 74			return S_un.S_un_b.s_b1;
 75		}
 76
 77		void s_net(UCHAR val) {
 78			S_un.S_un_b.s_b1 = val;
 79		}
 80
 81		USHORT s_imp() {
 82			return S_un.S_un_w.s_w2;
 83		}
 84
 85		void s_imp(USHORT val) {
 86			S_un.S_un_w.s_w2 = val;
 87		}
 88
 89		UCHAR s_impno() {
 90			return S_un.S_un_b.s_b4;
 91		}
 92
 93		void s_impno(UCHAR val) {
 94			S_un.S_un_b.s_b4 = val;
 95		}
 96
 97		UCHAR s_lh() {
 98			return S_un.S_un_b.s_b3;
 99		}
100
101		void s_lh(UCHAR val) {
102			S_un.S_un_b.s_b3 = val;
103		}
104
105		//#define s_addr  S_un.S_addr /* can be used for most tcp & ip code */
106		//#define s_host  S_un.S_un_b.s_b2    // host on imp
107		//#define s_net   S_un.S_un_b.s_b1    // network
108		//#define s_imp   S_un.S_un_w.s_w2    // imp
109		//#define s_impno S_un.S_un_b.s_b4    // imp #
110		//#define s_lh    S_un.S_un_b.s_b3    // logical host
111}
112
113alias in_addr IN_ADDR;
114alias in_addr* PIN_ADDR;
115alias in_addr* LPIN_ADDR;