File: Wrapper.cs

package info (click to toggle)
aircrack-ng 1%3A1.6%2Bgit20210130.91820bc-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 19,056 kB
  • sloc: ansic: 67,045; cs: 5,392; sh: 3,773; python: 2,565; pascal: 1,074; asm: 570; makefile: 253; cpp: 46
file content (149 lines) | stat: -rw-r--r-- 5,038 bytes parent folder | download | duplicates (22)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// Copyright 2006 Alp Toker <alp@atoker.com>
// This software is made available under the MIT License
// See COPYING for details

using System;
using System.Collections.Generic;
using System.IO;

namespace NDesk.DBus
{
	//TODO: complete and use these wrapper classes
	//not sure exactly what I'm thinking but there seems to be sense here

	//FIXME: signature sending/receiving is currently ambiguous in this code
	//FIXME: in fact, these classes are totally broken and end up doing no-op, do not use without understanding the problem
	class MethodCall
	{
		public Message message = new Message ();

		public MethodCall (ObjectPath path, string @interface, string member, string destination, Signature signature)
		{
			message.Header.MessageType = MessageType.MethodCall;
			message.ReplyExpected = true;
			message.Header.Fields[FieldCode.Path] = path;
			if (@interface != null)
				message.Header.Fields[FieldCode.Interface] = @interface;
			message.Header.Fields[FieldCode.Member] = member;
			message.Header.Fields[FieldCode.Destination] = destination;
			//TODO: consider setting Sender here for p2p situations
			//this will allow us to remove the p2p hacks in MethodCall and Message
#if PROTO_REPLY_SIGNATURE
			//TODO
#endif
			//message.Header.Fields[FieldCode.Signature] = signature;
			//use the wrapper in Message because it checks for emptiness
			message.Signature = signature;
		}

		public MethodCall (Message message)
		{
			this.message = message;
			Path = (ObjectPath)message.Header.Fields[FieldCode.Path];
			if (message.Header.Fields.ContainsKey (FieldCode.Interface))
				Interface = (string)message.Header.Fields[FieldCode.Interface];
			Member = (string)message.Header.Fields[FieldCode.Member];
			Destination = (string)message.Header.Fields[FieldCode.Destination];
			//TODO: filled by the bus so reliable, but not the case for p2p
			//so we make it optional here, but this needs some more thought
			if (message.Header.Fields.ContainsKey (FieldCode.Sender))
				Sender = (string)message.Header.Fields[FieldCode.Sender];
#if PROTO_REPLY_SIGNATURE
			//TODO: note that an empty ReplySignature should really be treated differently to the field not existing!
			if (message.Header.Fields.ContainsKey (FieldCode.ReplySignature))
				ReplySignature = (Signature)message.Header.Fields[FieldCode.ReplySignature];
			else
				ReplySignature = Signature.Empty;
#endif
			//Signature = (Signature)message.Header.Fields[FieldCode.Signature];
			//use the wrapper in Message because it checks for emptiness
			Signature = message.Signature;
		}

		public ObjectPath Path;
		public string Interface;
		public string Member;
		public string Destination;
		public string Sender;
#if PROTO_REPLY_SIGNATURE
		public Signature ReplySignature;
#endif
		public Signature Signature;
	}

	class MethodReturn
	{
		public Message message = new Message ();

		public MethodReturn (uint reply_serial)
		{
			message.Header.MessageType = MessageType.MethodReturn;
			message.Header.Flags = HeaderFlag.NoReplyExpected | HeaderFlag.NoAutoStart;
			message.Header.Fields[FieldCode.ReplySerial] = reply_serial;
			//signature optional?
			//message.Header.Fields[FieldCode.Signature] = signature;
		}

		public MethodReturn (Message message)
		{
			this.message = message;
			ReplySerial = (uint)message.Header.Fields[FieldCode.ReplySerial];
		}

		public uint ReplySerial;
	}

	class Error
	{
		public Message message = new Message ();

		public Error (string error_name, uint reply_serial)
		{
			message.Header.MessageType = MessageType.Error;
			message.Header.Flags = HeaderFlag.NoReplyExpected | HeaderFlag.NoAutoStart;
			message.Header.Fields[FieldCode.ErrorName] = error_name;
			message.Header.Fields[FieldCode.ReplySerial] = reply_serial;
		}

		public Error (Message message)
		{
			this.message = message;
			ErrorName = (string)message.Header.Fields[FieldCode.ErrorName];
			ReplySerial = (uint)message.Header.Fields[FieldCode.ReplySerial];
			//Signature = (Signature)message.Header.Fields[FieldCode.Signature];
		}

		public string ErrorName;
		public uint ReplySerial;
		//public Signature Signature;
	}

	class Signal
	{
		public Message message = new Message ();

		public Signal (ObjectPath path, string @interface, string member)
		{
			message.Header.MessageType = MessageType.Signal;
			message.Header.Flags = HeaderFlag.NoReplyExpected | HeaderFlag.NoAutoStart;
			message.Header.Fields[FieldCode.Path] = path;
			message.Header.Fields[FieldCode.Interface] = @interface;
			message.Header.Fields[FieldCode.Member] = member;
		}

		public Signal (Message message)
		{
			this.message = message;
			Path = (ObjectPath)message.Header.Fields[FieldCode.Path];
			Interface = (string)message.Header.Fields[FieldCode.Interface];
			Member = (string)message.Header.Fields[FieldCode.Member];
			if (message.Header.Fields.ContainsKey (FieldCode.Sender))
				Sender = (string)message.Header.Fields[FieldCode.Sender];
		}

		public ObjectPath Path;
		public string Interface;
		public string Member;
		public string Sender;
	}
}