]> git.ipfire.org Git - people/ms/rstp.git/blob - rstplib/uid_sock.h
Use new RSTP library.
[people/ms/rstp.git] / rstplib / uid_sock.h
1 /************************************************************************
2 * RSTP library - Rapid Spanning Tree (802.1t, 802.1w)
3 * Copyright (C) 2001-2003 Optical Access
4 * Author: Alex Rozin
5 *
6 * This file is part of RSTP library.
7 *
8 * RSTP library is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by the
10 * Free Software Foundation; version 2.1
11 *
12 * RSTP library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with RSTP library; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA.
21 **********************************************************************/
22
23 #ifndef _UID_SOCKET_H__
24 #define _UID_SOCKET_H__
25
26 /* Socket API */
27
28 #include <sys/socket.h> /* basic socket definitions */
29 #include <netinet/in.h>
30 #include <linux/un.h> /* for Unix domain sockets */
31
32 #define UID_REPL_PATH "/tmp/UidSocketFile"
33
34 typedef struct sockaddr SA;
35
36 #define SOCKET_NAME_LENGTH 108
37 #define SIZE_OF_ADDRESS sizeof(struct sockaddr_un)
38
39 typedef enum {
40 UID_BIND_AS_CLIENT,
41 UID_BIND_AS_SERVER
42 } TYPE_OF_BINDING;
43
44
45 typedef char UID_SOCK_ID[SOCKET_NAME_LENGTH];
46
47 typedef struct{
48 int sock_fd;
49 struct sockaddr_un clientAddr;
50 struct sockaddr_un serverAddr; // Only for socket of UID_BIND_AS_CLIENT
51 UID_SOCK_ID socket_id;
52 TYPE_OF_BINDING binding;
53 } UID_SOCKET_T;
54
55 #define MESSAGE_SIZE 2048
56
57 int UiD_SocketInit(UID_SOCKET_T* sock,
58 UID_SOCK_ID id,
59 TYPE_OF_BINDING binding);
60
61 int UiD_SocketRecvfrom (UID_SOCKET_T* sock,
62 void* msg_buffer,
63 int buffer_size,
64 UID_SOCKET_T* sock_4_reply);
65
66 int UiD_SocketSendto (UID_SOCKET_T* sock,
67 void* msg_buffer,
68 int buffer_size);
69
70 int UiD_SocketClose(UID_SOCKET_T* sock);
71
72 int UiD_SocketSetReadTimeout (UID_SOCKET_T* s, int timeout);
73
74 int
75 UiD_SocketCompare (UID_SOCKET_T* s, UID_SOCKET_T* t);
76
77 #define GET_FILE_DESCRIPTOR(sock) (((UID_SOCKET_T*)sock)->sock_fd)
78
79 #endif /* _UID_SOCKET_H__ */
80
81