Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
062e09f3
Commit
062e09f3
authored
Sep 14, 2006
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provider for pre-V4.0 Proviw systems added
parent
214a53b4
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
2645 additions
and
0 deletions
+2645
-0
remote/exe/remote_pvd_pwrcli/src/os_linux/hw_x86/makefile
remote/exe/remote_pvd_pwrcli/src/os_linux/hw_x86/makefile
+12
-0
remote/exe/remote_pvd_pwrcli/src/os_linux/link_rule.mk
remote/exe/remote_pvd_pwrcli/src/os_linux/link_rule.mk
+8
-0
remote/exe/remote_pvd_pwrcli/src/remote_pvd_pwrcli.cpp
remote/exe/remote_pvd_pwrcli/src/remote_pvd_pwrcli.cpp
+662
-0
remote/exe/remote_pvd_pwrcli/src/remote_pvd_pwrcli.h
remote/exe/remote_pvd_pwrcli/src/remote_pvd_pwrcli.h
+68
-0
remote/exe/remote_pvd_pwrsrv/src/os_linux/hw_x86/makefile
remote/exe/remote_pvd_pwrsrv/src/os_linux/hw_x86/makefile
+12
-0
remote/exe/remote_pvd_pwrsrv/src/os_linux/link_rule.mk
remote/exe/remote_pvd_pwrsrv/src/os_linux/link_rule.mk
+8
-0
remote/exe/remote_pvd_pwrsrv/src/remote_pvd_pwrsrv.c
remote/exe/remote_pvd_pwrsrv/src/remote_pvd_pwrsrv.c
+488
-0
remote/lib/remote/src/remote_ndc.c
remote/lib/remote/src/remote_ndc.c
+755
-0
remote/lib/remote/src/remote_ndc.h
remote/lib/remote/src/remote_ndc.h
+43
-0
remote/lib/remote/src/remote_pvd_udp.c
remote/lib/remote/src/remote_pvd_udp.c
+419
-0
remote/lib/remote/src/remote_pvd_udp.h
remote/lib/remote/src/remote_pvd_udp.h
+170
-0
No files found.
remote/exe/remote_pvd_pwrcli/src/os_linux/hw_x86/makefile
0 → 100644
View file @
062e09f3
include
$(pwre_dir_symbols)
-include
$(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq
($($(type_name)_generic_mk),)
-include
$(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq
($($(type_name)_generic_mk),)
include
$(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
remote/exe/remote_pvd_pwrcli/src/os_linux/link_rule.mk
0 → 100644
View file @
062e09f3
ifndef
link_rule_mk
link_rule_mk
:=
1
link
=
$(ldxx)
$(elinkflags)
$(domap)
-o
$(export_exe)
\
$(export_obj)
$(objects)
$(rt_msg_eobjs)
\
-lpwr_remote
-lpwr_rt
-lpwr_co
-lpwr_msg_dummy
-lpthread
-lrt
-lm
endif
remote/exe/remote_pvd_pwrcli/src/remote_pvd_pwrcli.cpp
0 → 100644
View file @
062e09f3
/*
* Proview $Id: remote_pvd_pwrcli.cpp,v 1.1 2006-09-14 14:17:44 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
#include <vector.h>
#include <map.h>
#include <string.h>
#include <stdio.h>
#include <iostream.h>
#include <fstream.h>
#include "pwr.h"
#include "pwr_class.h"
#include "pwr_baseclasses.h"
#include "wb_vext.h"
#include "remote_pvd_pwrcli.h"
#include "remote_pvd_udp.h"
#include "rt_procom.h"
#include "rt_gdh.h"
#include "rt_gdh_msg.h"
#include "rs_remote_msg.h"
extern
"C"
{
#include "remote_ndc.h"
#include "rt_vol.h"
#include "rt_gdb.h"
#include "co_cdh.h"
#include "co_dcli.h"
}
class
subitem
{
public:
int
m_size
;
void
*
m_p
;
pwr_tCid
m_cid
;
int
m_offset
;
pwr_tOName
m_attr
;
pwr_tOid
m_oid
;
subitem
()
:
m_size
(
0
),
m_p
(
0
),
m_cid
(
0
),
m_offset
(
0
)
{
m_oid
=
pwr_cNObjid
;
strcpy
(
m_attr
,
""
);
}
subitem
(
int
size
,
pwr_tCid
cid
,
int
offset
,
char
*
attr
,
pwr_tOid
oid
)
:
m_size
(
size
),
m_cid
(
cid
),
m_offset
(
offset
),
m_oid
(
oid
)
{
strcpy
(
m_attr
,
attr
);
m_p
=
calloc
(
1
,
size
);
}
~
subitem
()
{
if
(
m_p
)
free
(
m_p
);
}
subitem
(
const
subitem
&
x
)
:
m_size
(
x
.
m_size
),
m_p
(
0
),
m_cid
(
x
.
m_cid
),
m_offset
(
x
.
m_offset
),
m_oid
(
x
.
m_oid
)
{
strcpy
(
m_attr
,
x
.
m_attr
);
if
(
x
.
m_p
)
{
m_p
=
malloc
(
m_size
);
memcpy
(
m_p
,
x
.
m_p
,
m_size
);
}
}
subitem
&
operator
=
(
const
subitem
&
x
)
{
m_size
=
x
.
m_size
;
m_cid
=
x
.
m_cid
;
m_offset
=
x
.
m_offset
;
strcpy
(
m_attr
,
x
.
m_attr
);
m_oid
=
x
.
m_oid
;
if
(
x
.
m_p
)
{
m_p
=
malloc
(
m_size
);
memcpy
(
m_p
,
x
.
m_p
,
m_size
);
}
else
m_p
=
0
;
return
*
this
;
}
};
typedef
map
<
int
,
subitem
>::
iterator
sublist_iterator
;
static
pwr_tVid
rpvd_vid
;
static
char
rpvd_vname
[
32
];
static
int
rpvd_opsys
;
static
map
<
int
,
subitem
>
rpvd_sublist
;
static
int
rpvd_id
=
1
;
void
remote_pvd_pwrcli
::
objectOid
(
co_procom
*
pcom
,
pwr_tOix
oix
)
{
rpvd_sMsgOid
msg
;
rpvd_sMsgObject
*
rmsg
;
pwr_tStatus
sts
;
msg
.
Type
=
rpvd_eMsg_Oid
;
msg
.
Id
=
rpvd_id
++
;
msg
.
Oid
.
oix
=
oix
;
msg
.
Oid
.
vid
=
rpvd_vid
;
sts
=
udp_Request
(
(
char
*
)
&
msg
,
sizeof
(
msg
),
(
char
**
)
&
rmsg
);
if
(
EVEN
(
sts
)
||
sts
==
REM__TIMEOUT
)
{
pcom
->
provideStatus
(
sts
);
return
;
}
if
(
rmsg
->
Id
!=
msg
.
Id
)
{
dispatch
(
pcom
,
(
rpvd_sMsg
*
)
rmsg
);
return
;
}
if
(
rmsg
->
Type
!=
rpvd_eMsg_Object
)
{
pcom
->
provideStatus
(
REM__DISORDER
);
return
;
}
if
(
EVEN
(
rmsg
->
Status
))
{
pcom
->
provideStatus
(
rmsg
->
Status
);
return
;
}
vector
<
procom_obj
>
m_list
;
for
(
int
i
=
0
;
i
<
rmsg
->
OSize
;
i
++
)
{
procom_obj
item
;
item
.
oix
=
rmsg
->
o
[
i
].
oix
;
item
.
fthoix
=
rmsg
->
o
[
i
].
fthoix
;
item
.
fchoix
=
rmsg
->
o
[
i
].
fchoix
;
item
.
lchoix
=
rmsg
->
o
[
i
].
lchoix
;
item
.
fwsoix
=
rmsg
->
o
[
i
].
fwsoix
;
item
.
bwsoix
=
rmsg
->
o
[
i
].
bwsoix
;
item
.
cid
=
rmsg
->
o
[
i
].
cid
;
strcpy
(
item
.
name
,
rmsg
->
o
[
i
].
name
);
m_list
.
push_back
(
item
);
}
pcom
->
provideObjects
(
GDH__SUCCESS
,
m_list
);
}
void
remote_pvd_pwrcli
::
objectName
(
co_procom
*
pcom
,
char
*
name
)
{
rpvd_sMsgObjectName
msg
;
rpvd_sMsgObject
*
rmsg
;
pwr_tStatus
sts
;
msg
.
Type
=
rpvd_eMsg_ObjectName
;
msg
.
Id
=
rpvd_id
++
;
strcpy
(
msg
.
Name
,
name
);
sts
=
udp_Request
(
(
char
*
)
&
msg
,
sizeof
(
msg
),
(
char
**
)
&
rmsg
);
if
(
EVEN
(
sts
)
||
sts
==
REM__TIMEOUT
)
{
pcom
->
provideStatus
(
sts
);
return
;
}
if
(
rmsg
->
Id
!=
msg
.
Id
)
{
dispatch
(
pcom
,
(
rpvd_sMsg
*
)
rmsg
);
return
;
}
if
(
rmsg
->
Type
!=
rpvd_eMsg_Object
)
{
pcom
->
provideStatus
(
REM__DISORDER
);
return
;
}
if
(
EVEN
(
rmsg
->
Status
))
{
pcom
->
provideStatus
(
rmsg
->
Status
);
return
;
}
vector
<
procom_obj
>
m_list
;
for
(
int
i
=
0
;
i
<
rmsg
->
OSize
;
i
++
)
{
procom_obj
item
;
item
.
oix
=
rmsg
->
o
[
i
].
oix
;
item
.
fthoix
=
rmsg
->
o
[
i
].
fthoix
;
item
.
fchoix
=
rmsg
->
o
[
i
].
fchoix
;
item
.
lchoix
=
rmsg
->
o
[
i
].
lchoix
;
item
.
fwsoix
=
rmsg
->
o
[
i
].
fwsoix
;
item
.
bwsoix
=
rmsg
->
o
[
i
].
bwsoix
;
item
.
cid
=
rmsg
->
o
[
i
].
cid
;
strcpy
(
item
.
name
,
rmsg
->
o
[
i
].
name
);
m_list
.
push_back
(
item
);
}
pcom
->
provideObjects
(
GDH__SUCCESS
,
m_list
);
}
void
remote_pvd_pwrcli
::
writeAttribute
(
co_procom
*
pcom
,
pwr_tOix
oix
,
unsigned
int
offset
,
unsigned
int
size
,
char
*
buffer
)
{
rpvd_sMsgWriteAttribute
msg
;
rpvd_sMsgAny
*
rmsg
;
pwr_tStatus
sts
;
pwr_tAttrRef
aref
;
pwr_tOName
aname
;
pwr_tCid
cid
;
msg
.
Type
=
rpvd_eMsg_WriteAttribute
;
msg
.
Id
=
rpvd_id
++
;
msg
.
Oid
.
oix
=
oix
;
msg
.
Oid
.
vid
=
rpvd_vid
;
msg
.
Size
=
size
;
memset
(
&
aref
,
0
,
sizeof
(
aref
));
aref
.
Objid
=
msg
.
Oid
;
aref
.
Offset
=
offset
;
aref
.
Size
=
size
;
sts
=
gdh_GetObjectClass
(
msg
.
Oid
,
&
cid
);
if
(
EVEN
(
sts
))
{
pcom
->
provideStatus
(
sts
);
return
;
}
sts
=
gdh_ClassAttrrefToAttr
(
cid
,
&
aref
,
aname
,
sizeof
(
aname
));
if
(
EVEN
(
sts
))
{
pcom
->
provideStatus
(
sts
);
return
;
}
strcpy
(
msg
.
Attribute
,
aname
);
// TODO Float conversion
if
(
rpvd_opsys
==
0
||
rpvd_opsys
==
gdbroot
->
my_node
->
os
)
memcpy
(
&
msg
.
Value
,
buffer
,
size
);
else
{
gdb_sNode
n
;
gdb_sClass
*
cp
;
int
rsize
;
memset
(
&
n
,
0
,
sizeof
(
n
));
n
.
os
=
(
co_eOS
)
rpvd_opsys
;
rsize
=
aref
.
Size
;
cp
=
(
gdb_sClass
*
)
hash_Search
(
&
sts
,
gdbroot
->
cid_ht
,
&
cid
);
if
(
cp
!=
NULL
)
{
rndc_ConvertData
(
&
sts
,
&
n
,
cp
,
&
msg
.
Value
,
buffer
,
(
pwr_tUInt32
*
)
&
rsize
,
ndc_eOp_decode
,
aref
.
Offset
,
0
);
}
}
sts
=
udp_Request
(
(
char
*
)
&
msg
,
sizeof
(
msg
),
(
char
**
)
&
rmsg
);
if
(
EVEN
(
sts
)
||
sts
==
REM__TIMEOUT
)
{
pcom
->
provideStatus
(
sts
);
return
;
}
if
(
rmsg
->
Id
!=
msg
.
Id
)
{
dispatch
(
pcom
,
(
rpvd_sMsg
*
)
rmsg
);
return
;
}
if
(
rmsg
->
Type
!=
rpvd_eMsg_Status
)
{
pcom
->
provideStatus
(
REM__DISORDER
);
return
;
}
pcom
->
provideStatus
(
rmsg
->
Status
);
}
void
remote_pvd_pwrcli
::
readAttribute
(
co_procom
*
pcom
,
pwr_tOix
oix
,
unsigned
int
offset
,
unsigned
int
size
)
{
rpvd_sMsgReadAttribute
msg
;
rpvd_sMsgAttribute
*
rmsg
;
pwr_tStatus
sts
;
pwr_tAttrRef
aref
;
pwr_tOName
aname
;
pwr_tCid
cid
;
msg
.
Type
=
rpvd_eMsg_ReadAttribute
;
msg
.
Id
=
rpvd_id
++
;
msg
.
Oid
.
oix
=
oix
;
msg
.
Oid
.
vid
=
rpvd_vid
;
memset
(
&
aref
,
0
,
sizeof
(
aref
));
aref
.
Objid
=
msg
.
Oid
;
aref
.
Offset
=
offset
;
aref
.
Size
=
size
;
sts
=
gdh_GetObjectClass
(
msg
.
Oid
,
&
cid
);
if
(
EVEN
(
sts
))
{
pcom
->
provideStatus
(
sts
);
return
;
}
sts
=
gdh_ClassAttrrefToAttr
(
cid
,
&
aref
,
aname
,
sizeof
(
aname
));
if
(
EVEN
(
sts
))
{
pcom
->
provideStatus
(
sts
);
return
;
}
strcpy
(
msg
.
Attribute
,
aname
);
sts
=
udp_Request
(
(
char
*
)
&
msg
,
sizeof
(
msg
),
(
char
**
)
&
rmsg
);
if
(
EVEN
(
sts
)
||
sts
==
REM__TIMEOUT
)
{
pcom
->
provideStatus
(
sts
);
return
;
}
if
(
rmsg
->
Id
!=
msg
.
Id
)
{
dispatch
(
pcom
,
(
rpvd_sMsg
*
)
rmsg
);
return
;
}
if
(
rmsg
->
Type
!=
rpvd_eMsg_Attribute
)
{
pcom
->
provideStatus
(
REM__DISORDER
);
return
;
}
if
(
EVEN
(
rmsg
->
Status
))
{
pcom
->
provideStatus
(
rmsg
->
Status
);
return
;
}
// TODO Float conversion !!!
if
(
rpvd_opsys
==
0
||
rpvd_opsys
==
gdbroot
->
my_node
->
os
)
{
void
*
p
=
&
rmsg
->
Value
;
pcom
->
provideAttr
(
GDH__SUCCESS
,
oix
,
rmsg
->
Size
,
p
);
}
else
{
gdb_sNode
n
;
gdb_sClass
*
cp
;
void
*
p
=
NULL
;
memset
(
&
n
,
0
,
sizeof
(
n
));
n
.
os
=
(
co_eOS
)
rpvd_opsys
;
p
=
malloc
(
rmsg
->
Size
);
size
=
aref
.
Size
;
cp
=
(
gdb_sClass
*
)
hash_Search
(
&
sts
,
gdbroot
->
cid_ht
,
&
cid
);
if
(
cp
!=
NULL
)
{
rndc_ConvertData
(
&
sts
,
&
n
,
cp
,
p
,
&
rmsg
->
Value
,
(
pwr_tUInt32
*
)
&
size
,
ndc_eOp_encode
,
aref
.
Offset
,
0
);
pcom
->
provideAttr
(
GDH__SUCCESS
,
oix
,
rmsg
->
Size
,
p
);
}
}
}
void
remote_pvd_pwrcli
::
dispatch
(
co_procom
*
pcom
,
rpvd_sMsg
*
msg
)
{
pwr_tStatus
sts
;
switch
(
msg
->
Any
.
Type
)
{
case
rpvd_eMsg_NodeUp
:
{
rpvd_sMsgAny
rmsg
;
printf
(
"NodeUp
\n
"
);
rmsg
.
Type
=
REM__SUCCESS
;
rmsg
.
Id
=
msg
->
Any
.
Id
;
sts
=
udp_Send
(
(
char
*
)
&
rmsg
,
sizeof
(
rmsg
));
pcom
->
flushNodes
();
subRestore
();
break
;
}
default:
;
}
}
void
remote_pvd_pwrcli
::
receive
(
co_procom
*
pcom
)
{
rpvd_sMsgAny
*
msg
;
pwr_tStatus
sts
;
// Get any message
sts
=
udp_Receive
(
(
char
**
)
&
msg
,
20
);
if
(
ODD
(
sts
)
&&
sts
!=
REM__TIMEOUT
)
{
dispatch
(
pcom
,
(
rpvd_sMsg
*
)
msg
);
}
}
void
remote_pvd_pwrcli
::
cyclic
(
co_procom
*
pcom
)
{
// Get any message
receive
(
pcom
);
// Get subscribed values
subRequest
(
pcom
);
}
void
remote_pvd_pwrcli
::
subRestore
()
{
rpvd_sMsgSubAdd
msg
;
rpvd_sMsgAny
*
rmsg
;
pwr_tStatus
sts
;
for
(
sublist_iterator
it
=
rpvd_sublist
.
begin
();
it
!=
rpvd_sublist
.
end
();
it
++
)
{
msg
.
Type
=
rpvd_eMsg_SubAdd
;
msg
.
Id
=
rpvd_id
++
;
msg
.
Oid
=
it
->
second
.
m_oid
;
strcpy
(
msg
.
Attribute
,
it
->
second
.
m_attr
);
msg
.
Rix
=
it
->
first
;
msg
.
Size
=
it
->
second
.
m_size
;
sts
=
udp_Request
(
(
char
*
)
&
msg
,
sizeof
(
msg
),
(
char
**
)
&
rmsg
);
}
}
void
remote_pvd_pwrcli
::
subAssociateBuffer
(
co_procom
*
pcom
,
void
**
buff
,
int
oix
,
int
offset
,
int
size
,
pwr_tSubid
subid
)
{
rpvd_sMsgSubAdd
msg
;
rpvd_sMsgAny
*
rmsg
;
pwr_tStatus
sts
;
pwr_tAttrRef
aref
;
pwr_tOName
aname
;
pwr_tCid
cid
;
msg
.
Type
=
rpvd_eMsg_SubAdd
;
msg
.
Id
=
rpvd_id
++
;
msg
.
Oid
.
oix
=
oix
;
msg
.
Oid
.
vid
=
rpvd_vid
;
memset
(
&
aref
,
0
,
sizeof
(
aref
));
aref
.
Objid
=
msg
.
Oid
;
aref
.
Offset
=
offset
;
aref
.
Size
=
size
;
sts
=
gdh_GetObjectClass
(
msg
.
Oid
,
&
cid
);
if
(
EVEN
(
sts
))
{
pcom
->
provideStatus
(
sts
);
return
;
}
sts
=
gdh_ClassAttrrefToAttr
(
cid
,
&
aref
,
aname
,
sizeof
(
aname
));
if
(
EVEN
(
sts
))
{
pcom
->
provideStatus
(
sts
);
return
;
}
strcpy
(
msg
.
Attribute
,
aname
);
msg
.
Rix
=
subid
.
rix
;
msg
.
Size
=
size
;
sts
=
udp_Request
(
(
char
*
)
&
msg
,
sizeof
(
msg
),
(
char
**
)
&
rmsg
);
if
(
EVEN
(
sts
)
||
sts
==
REM__TIMEOUT
)
{
pcom
->
provideStatus
(
sts
);
return
;
}
if
(
rmsg
->
Id
!=
msg
.
Id
)
{
dispatch
(
pcom
,
(
rpvd_sMsg
*
)
rmsg
);
return
;
}
if
(
rmsg
->
Type
!=
rpvd_eMsg_Status
)
{
pcom
->
provideStatus
(
REM__DISORDER
);
return
;
}
if
(
EVEN
(
rmsg
->
Status
))
{
pcom
->
provideStatus
(
rmsg
->
Status
);
return
;
}
pcom
->
provideStatus
(
rmsg
->
Status
);
if
(
ODD
(
rmsg
->
Status
))
{
// Add to local list
subitem
s
(
size
,
cid
,
offset
,
msg
.
Attribute
,
msg
.
Oid
);
rpvd_sublist
[
subid
.
rix
]
=
s
;
*
buff
=
rpvd_sublist
[
subid
.
rix
].
m_p
;
}
}
void
remote_pvd_pwrcli
::
subDisassociateBuffer
(
co_procom
*
pcom
,
pwr_tSubid
subid
)
{
rpvd_sMsgSubRemove
msg
;
rpvd_sMsgAny
*
rmsg
;
pwr_tStatus
sts
;
// Remove from local list
sublist_iterator
it
=
rpvd_sublist
.
find
(
subid
.
rix
);
if
(
it
!=
rpvd_sublist
.
end
())
rpvd_sublist
.
erase
(
it
);
// Send message
msg
.
Type
=
rpvd_eMsg_SubRemove
;
msg
.
Id
=
rpvd_id
++
;
msg
.
Rix
=
subid
.
rix
;
sts
=
udp_Request
(
(
char
*
)
&
msg
,
sizeof
(
msg
),
(
char
**
)
&
rmsg
);
if
(
EVEN
(
sts
)
||
sts
==
REM__TIMEOUT
)
{
pcom
->
provideStatus
(
sts
);
return
;
}
if
(
rmsg
->
Id
!=
msg
.
Id
)
{
dispatch
(
pcom
,
(
rpvd_sMsg
*
)
rmsg
);
return
;
}
if
(
rmsg
->
Type
!=
rpvd_eMsg_Status
)
{
pcom
->
provideStatus
(
REM__DISORDER
);
return
;
}
pcom
->
provideStatus
(
rmsg
->
Status
);
}
void
remote_pvd_pwrcli
::
subRequest
(
co_procom
*
pcom
)
{
rpvd_sMsgAny
msg
;
rpvd_sMsgSubSend
*
rmsg
;
pwr_tStatus
sts
;
char
*
subp
;
int
rix
;
int
size
;
msg
.
Type
=
rpvd_eMsg_SubRequest
;
msg
.
Id
=
rpvd_id
++
;
for
(;;)
{
sts
=
udp_Send
(
(
char
*
)
&
msg
,
sizeof
(
msg
));
if
(
EVEN
(
sts
))
return
;
sts
=
udp_Receive
(
(
char
**
)
&
rmsg
,
5000
);
if
(
EVEN
(
sts
)
||
sts
==
REM__TIMEOUT
)
return
;
if
(
rmsg
->
Id
!=
msg
.
Id
)
{
dispatch
(
pcom
,
(
rpvd_sMsg
*
)
rmsg
);
return
;
}
// Unpack the message
subp
=
(
char
*
)
&
rmsg
->
Data
;
while
(
*
(
int
*
)
subp
!=
-
1
)
{
rix
=
*
(
int
*
)
subp
;
subp
+=
4
;
size
=
*
(
int
*
)
subp
;
subp
+=
4
;
sublist_iterator
it
=
rpvd_sublist
.
find
(
rix
);
if
(
it
!=
rpvd_sublist
.
end
())
{
// TODO Data conversion !!!
if
(
rpvd_opsys
==
0
||
rpvd_opsys
==
gdbroot
->
my_node
->
os
)
{
memcpy
(
it
->
second
.
m_p
,
subp
,
it
->
second
.
m_size
);
}
else
{
gdb_sNode
n
;
gdb_sClass
*
cp
;
int
size
;
memset
(
&
n
,
0
,
sizeof
(
n
));
n
.
os
=
(
co_eOS
)
rpvd_opsys
;
n
.
fm
.
b
.
bo
=
co_eBO_little
;
n
.
netver
=
gdbroot
->
my_node
->
netver
;
size
=
it
->
second
.
m_size
;
cp
=
(
gdb_sClass
*
)
hash_Search
(
&
sts
,
gdbroot
->
cid_ht
,
&
it
->
second
.
m_cid
);
if
(
cp
!=
NULL
)
{
rndc_ConvertData
(
&
sts
,
&
n
,
cp
,
it
->
second
.
m_p
,
subp
,
(
pwr_tUInt32
*
)
&
size
,
ndc_eOp_encode
,
it
->
second
.
m_offset
,
0
);
}
}
}
subp
+=
size
;
}
if
(
!
rmsg
->
More
)
break
;
}
}
void
remote_pvd_pwrcli
::
nodeUp
()
{
rpvd_sMsgAny
msg
;
rpvd_sMsgAny
*
rmsg
;
pwr_tStatus
sts
;
msg
.
Type
=
rpvd_eMsg_NodeUp
;
msg
.
Id
=
rpvd_id
++
;
sts
=
udp_Request
(
(
char
*
)
&
msg
,
sizeof
(
msg
),
(
char
**
)
&
rmsg
);
if
(
EVEN
(
sts
)
||
sts
==
REM__TIMEOUT
)
{
}
}
void
usage
()
{
cout
<<
"remote_pvd_pwrcli Proview provider client"
<<
endl
<<
endl
<<
"Arguments: "
<<
endl
<<
" 1 Remote address"
<<
endl
<<
" 2 Remote host name"
<<
endl
<<
" 3 Remote volume id"
<<
endl
<<
" 4 Remote volume name"
<<
endl
<<
" 5 Server identity (optional, default 200)"
<<
endl
<<
" 6 Udp port number (optional, default 3051)"
<<
endl
<<
" 7 Remote operating system (optional)"
<<
endl
<<
endl
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
pwr_tStatus
sts
;
char
remote_address
[
40
];
char
remote_host_name
[
40
];
char
remote_vid
[
40
];
char
remote_volume_name
[
40
];
int
udp_port
;
int
server_id
;
/* Read arguments */
if
(
argc
<
5
)
{
usage
();
exit
(
0
);
}
strcpy
(
remote_address
,
argv
[
1
]);
strcpy
(
remote_host_name
,
argv
[
2
]);
strcpy
(
remote_vid
,
argv
[
3
]);
strcpy
(
remote_volume_name
,
argv
[
4
]);
if
(
argc
>=
6
)
{
sts
=
sscanf
(
argv
[
5
],
"%d"
,
&
server_id
);
if
(
sts
!=
1
)
{
usage
();
exit
(
0
);
}
}
else
server_id
=
200
;
if
(
argc
>=
7
)
{
sts
=
sscanf
(
argv
[
6
],
"%d"
,
&
udp_port
);
if
(
sts
!=
1
)
{
usage
();
exit
(
0
);
}
}
else
udp_port
=
3051
;
if
(
argc
>=
8
)
{
sts
=
sscanf
(
argv
[
7
],
"%d"
,
&
rpvd_opsys
);
if
(
sts
!=
1
)
{
usage
();
exit
(
0
);
}
}
else
rpvd_opsys
=
0
;
cdh_StringToVolumeId
(
remote_vid
,
&
rpvd_vid
);
strcpy
(
rpvd_vname
,
remote_volume_name
);
sts
=
udp_Init
(
remote_address
,
remote_host_name
,
udp_port
);
if
(
EVEN
(
sts
))
{
exit
(
0
);
}
remote_pvd_pwrcli
provider
(
pvd_eEnv_Rt
);
rt_procom
procom
(
&
provider
,
errh_eAnix_appl20
,
// Application index
"remote_pvd_pwrcli"
,
// Process name
server_id
,
// Sid
rpvd_vid
,
// Vid
rpvd_vname
,
// Volume name
0
);
// Global
procom
.
init
();
provider
.
nodeUp
();
procom
.
mainLoop
();
}
remote/exe/remote_pvd_pwrcli/src/remote_pvd_pwrcli.h
0 → 100644
View file @
062e09f3
/*
* Proview $Id: remote_pvd_pwrcli.h,v 1.1 2006-09-14 14:17:44 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
#ifndef remote_pvd_pwrcli_h
#define remote_pvd_pwrcli_h
#include "co_provider.h"
#include "co_procom.h"
#include "remote_pvd_udp.h"
class
remote_pvd_pwrcli
:
public
co_provider
{
public:
remote_pvd_pwrcli
(
pvd_eEnv
env
=
pvd_eEnv_Rt
)
:
co_provider
(
env
)
{}
virtual
void
object
(
co_procom
*
pcom
)
{}
virtual
void
objectOid
(
co_procom
*
pcom
,
pwr_tOix
oix
);
virtual
void
objectName
(
co_procom
*
pcom
,
char
*
name
);
virtual
void
objectBody
(
co_procom
*
pcom
,
pwr_tOix
oix
)
{}
virtual
void
createObject
(
co_procom
*
pcom
,
pwr_tOix
destoix
,
int
desttype
,
pwr_tCid
cid
,
char
*
name
)
{}
virtual
void
moveObject
(
co_procom
*
pcom
,
pwr_tOix
oix
,
pwr_tOix
destoix
,
int
desttype
)
{}
virtual
void
copyObject
(
co_procom
*
pcom
,
pwr_tOix
oix
,
pwr_tOix
destoix
,
int
desttype
,
char
*
name
)
{}
virtual
void
deleteObject
(
co_procom
*
pcom
,
pwr_tOix
oix
)
{}
virtual
void
deleteFamily
(
co_procom
*
pcom
,
pwr_tOix
oix
)
{}
virtual
void
renameObject
(
co_procom
*
pcom
,
pwr_tOix
oix
,
char
*
name
)
{}
virtual
void
writeAttribute
(
co_procom
*
pcom
,
pwr_tOix
oix
,
unsigned
int
offset
,
unsigned
int
size
,
char
*
buffer
);
virtual
void
readAttribute
(
co_procom
*
pcom
,
pwr_tOix
oix
,
unsigned
int
offset
,
unsigned
int
size
);
virtual
void
subAssociateBuffer
(
co_procom
*
pcom
,
void
**
buff
,
int
oix
,
int
offset
,
int
size
,
pwr_tSubid
sid
);
virtual
void
subDisassociateBuffer
(
co_procom
*
pcom
,
pwr_tSubid
sid
);
virtual
void
commit
(
co_procom
*
pcom
)
{}
virtual
void
abort
(
co_procom
*
pcom
)
{}
virtual
void
save
(
pwr_tStatus
*
sts
)
{}
virtual
void
load
(
pwr_tStatus
*
rsts
)
{}
virtual
void
cyclic
(
co_procom
*
pcom
);
void
subRequest
(
co_procom
*
pcom
);
void
receive
(
co_procom
*
pcom
);
void
dispatch
(
co_procom
*
pcom
,
rpvd_sMsg
*
msg
);
void
nodeUp
();
void
subRestore
();
vector
<
procom_obj
>
m_list
;
};
#endif
remote/exe/remote_pvd_pwrsrv/src/os_linux/hw_x86/makefile
0 → 100644
View file @
062e09f3
include
$(pwre_dir_symbols)
-include
$(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq
($($(type_name)_generic_mk),)
-include
$(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq
($($(type_name)_generic_mk),)
include
$(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
remote/exe/remote_pvd_pwrsrv/src/os_linux/link_rule.mk
0 → 100644
View file @
062e09f3
ifndef
link_rule_mk
link_rule_mk
:=
1
link
=
$(ldxx)
$(elinkflags)
$(domap)
-o
$(export_exe)
\
$(export_obj)
$(objects)
$(rt_msg_eobjs)
\
-lpwr_remote
-lpwr_rt
-lpwr_co
-lpwr_msg_dummy
-lpthread
-lrt
-lm
endif
remote/exe/remote_pvd_pwrsrv/src/remote_pvd_pwrsrv.c
0 → 100644
View file @
062e09f3
/*
* Proview $Id: remote_pvd_pwrsrv.c,v 1.1 2006-09-14 14:17:44 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
#include <string.h>
#include <stdio.h>
#include "pwr.h"
#include "pwr_class.h"
#include "pwr_baseclasses.h"
#include "remote_pvd_udp.h"
#include "rt_gdh.h"
#include "rt_gdh_msg.h"
#include "rs_remote_msg.h"
#include "co_cdh.h"
#include "co_dcli.h"
typedef
struct
sSubItem
{
int
rix
;
pwr_tObjid
oid
;
pwr_tObjName
attribute
;
int
size
;
void
*
p
;
pwr_tRefId
dlid
;
struct
sSubItem
*
next
;
struct
sSubItem
*
prev
;
}
pwrsrv_sSubItem
;
static
pwrsrv_sSubItem
*
pwrsrv_sublist
=
0
;
static
void
pwrsrv_Oid
(
rpvd_sMsgOid
*
msg
)
{
rpvd_sMsgObject
rmsg
;
pwr_tOid
fth
;
pwr_tOid
fch
;
pwr_tOid
lch
;
pwr_tOid
bws
;
pwr_tOid
fws
;
pwr_tCid
cid
;
pwr_tObjName
name
;
pwr_tOid
o
;
pwr_tStatus
sts
;
pwr_tOid
plist
[
200
];
int
psize
=
0
;
int
i
,
j
;
char
*
s
;
rmsg
.
Type
=
rpvd_eMsg_Object
;
rmsg
.
Id
=
msg
->
Id
;
rmsg
.
Status
=
1
;
rmsg
.
Oid
=
msg
->
Oid
;
sts
=
gdh_GetObjectClass
(
msg
->
Oid
,
&
cid
);
if
(
EVEN
(
sts
))
{
rmsg
.
Status
=
sts
;
udp_Send
(
(
char
*
)
&
rmsg
,
sizeof
(
rmsg
));
return
;
}
plist
[
psize
++
]
=
msg
->
Oid
;
for
(
sts
=
gdh_GetParent
(
plist
[
psize
-
1
],
&
o
);
ODD
(
sts
);
sts
=
gdh_GetParent
(
plist
[
psize
-
1
],
&
o
))
{
plist
[
psize
++
]
=
o
;
}
/* Add volume object */
plist
[
psize
].
oix
=
0
;
plist
[
psize
++
].
vid
=
msg
->
Oid
.
vid
;
for
(
j
=
0
;
j
<
psize
;
j
++
)
{
i
=
psize
-
j
-
1
;
sts
=
gdh_GetObjectClass
(
plist
[
i
],
&
cid
);
if
(
i
==
psize
-
1
)
{
/* Volume object */
fth
.
oix
=
0
;
sts
=
gdh_GetRootList
(
&
fch
);
if
(
EVEN
(
sts
))
{
fch
.
oix
=
0
;
lch
.
oix
=
0
;
}
else
{
sts
=
1
;
for
(
lch
=
fch
;
ODD
(
sts
);
sts
=
gdh_GetNextSibling
(
lch
,
&
o
))
{
lch
=
o
;
}
}
fws
.
oix
=
0
;
bws
.
oix
=
0
;
sts
=
gdh_ObjidToName
(
plist
[
i
],
name
,
sizeof
(
name
),
cdh_mName_volume
);
if
(
(
s
=
strrchr
(
name
,
':'
)))
*
s
=
0
;
}
else
{
sts
=
gdh_GetParent
(
plist
[
i
],
&
fth
);
if
(
EVEN
(
sts
))
fth
.
oix
=
0
;
sts
=
gdh_GetChild
(
plist
[
i
],
&
fch
);
if
(
EVEN
(
sts
))
{
fch
.
oix
=
0
;
lch
.
oix
=
0
;
}
else
{
lch
=
fch
;
for
(
sts
=
gdh_GetNextSibling
(
lch
,
&
o
);
ODD
(
sts
);
sts
=
gdh_GetNextSibling
(
lch
,
&
o
))
{
lch
=
o
;
}
}
sts
=
gdh_GetNextSibling
(
plist
[
i
],
&
fws
);
if
(
EVEN
(
sts
))
fws
.
oix
=
rmsg
.
o
[
j
-
1
].
fchoix
;
sts
=
gdh_GetPreviousSibling
(
plist
[
i
],
&
bws
);
if
(
EVEN
(
sts
))
bws
.
oix
=
rmsg
.
o
[
j
-
1
].
lchoix
;
sts
=
gdh_ObjidToName
(
plist
[
i
],
name
,
sizeof
(
name
),
cdh_mName_object
);
}
rmsg
.
o
[
j
].
oix
=
plist
[
i
].
oix
;
rmsg
.
o
[
j
].
fthoix
=
fth
.
oix
;
rmsg
.
o
[
j
].
fchoix
=
fch
.
oix
;
rmsg
.
o
[
j
].
lchoix
=
lch
.
oix
;
rmsg
.
o
[
j
].
fwsoix
=
fws
.
oix
;
rmsg
.
o
[
j
].
bwsoix
=
bws
.
oix
;
rmsg
.
o
[
j
].
cid
=
cid
;
strcpy
(
rmsg
.
o
[
j
].
name
,
name
);
}
rmsg
.
OSize
=
psize
;
udp_Send
(
(
char
*
)
&
rmsg
,
sizeof
(
rmsg
));
}
static
void
pwrsrv_ObjectName
(
rpvd_sMsgObjectName
*
msg
)
{
rpvd_sMsgOid
m
;
pwr_tStatus
sts
;
/* Simulate an oid request */
m
.
Type
=
rpvd_eMsg_Oid
;
m
.
Id
=
msg
->
Id
;
sts
=
gdh_NameToObjid
(
msg
->
Name
,
&
m
.
Oid
);
if
(
EVEN
(
sts
))
{
rpvd_sMsgObject
rmsg
;
rmsg
.
Type
=
rpvd_eMsg_Object
;
rmsg
.
Id
=
msg
->
Id
;
rmsg
.
Status
=
sts
;
udp_Send
(
(
char
*
)
&
rmsg
,
sizeof
(
rmsg
));
return
;
}
pwrsrv_Oid
(
&
m
);
}
static
void
pwrsrv_ReadAttribute
(
rpvd_sMsgReadAttribute
*
msg
)
{
rpvd_sMsgAttribute
rmsg
;
pwr_tAName
name
;
pwr_tUInt32
asize
,
aoffs
,
aelem
;
pwr_tTypeId
atid
;
pwr_tStatus
sts
;
rmsg
.
Type
=
rpvd_eMsg_Attribute
;
rmsg
.
Id
=
msg
->
Id
;
rmsg
.
Status
=
1
;
rmsg
.
Oid
=
msg
->
Oid
;
strcpy
(
rmsg
.
Attribute
,
msg
->
Attribute
);
sts
=
gdh_ObjidToName
(
msg
->
Oid
,
name
,
sizeof
(
name
),
cdh_mName_volumeStrict
);
if
(
EVEN
(
sts
))
{
rmsg
.
Status
=
sts
;
udp_Send
(
(
char
*
)
&
rmsg
,
sizeof
(
rmsg
));
return
;
}
strcat
(
name
,
"."
);
strcat
(
name
,
msg
->
Attribute
);
sts
=
gdh_GetAttributeCharacteristics
(
name
,
&
atid
,
&
asize
,
&
aoffs
,
&
aelem
);
if
(
EVEN
(
sts
))
{
rmsg
.
Status
=
sts
;
udp_Send
(
(
char
*
)
&
rmsg
,
sizeof
(
rmsg
));
return
;
}
sts
=
gdh_GetObjectInfo
(
name
,
&
rmsg
.
Value
,
asize
);
rmsg
.
Status
=
sts
;
rmsg
.
Size
=
asize
;
rmsg
.
Tid
=
atid
;
udp_Send
(
(
char
*
)
&
rmsg
,
sizeof
(
rmsg
));
}
static
void
pwrsrv_WriteAttribute
(
rpvd_sMsgWriteAttribute
*
msg
)
{
rpvd_sMsgAny
rmsg
;
pwr_tAName
name
;
pwr_tUInt32
asize
,
aoffs
,
aelem
;
pwr_tTypeId
atid
;
pwr_tStatus
sts
;
rmsg
.
Type
=
rpvd_eMsg_Status
;
rmsg
.
Id
=
msg
->
Id
;
sts
=
gdh_ObjidToName
(
msg
->
Oid
,
name
,
sizeof
(
name
),
cdh_mName_volumeStrict
);
if
(
EVEN
(
sts
))
{
rmsg
.
Status
=
sts
;
udp_Send
(
(
char
*
)
&
rmsg
,
sizeof
(
rmsg
));
return
;
}
strcat
(
name
,
"."
);
strcat
(
name
,
msg
->
Attribute
);
sts
=
gdh_GetAttributeCharacteristics
(
name
,
&
atid
,
&
asize
,
&
aoffs
,
&
aelem
);
if
(
EVEN
(
sts
))
{
rmsg
.
Status
=
sts
;
udp_Send
(
(
char
*
)
&
rmsg
,
sizeof
(
rmsg
));
return
;
}
sts
=
gdh_SetObjectInfo
(
name
,
&
msg
->
Value
,
msg
->
Size
);
rmsg
.
Status
=
sts
;
udp_Send
(
(
char
*
)
&
rmsg
,
sizeof
(
rmsg
));
}
static
void
pwrsrv_SubAdd
(
rpvd_sMsgSubAdd
*
msg
)
{
rpvd_sMsgAny
rmsg
;
pwr_tAName
name
;
pwr_tUInt32
asize
,
aoffs
,
aelem
;
pwr_tTypeId
atid
;
pwr_tStatus
sts
;
pwrsrv_sSubItem
*
si
;
void
*
p
;
pwr_tRefId
dlid
;
rmsg
.
Type
=
rpvd_eMsg_Status
;
rmsg
.
Id
=
msg
->
Id
;
/* Check that this rix doesn't exist */
for
(
si
=
pwrsrv_sublist
;
si
;
si
=
si
->
next
)
{
if
(
si
->
rix
==
msg
->
Rix
)
{
return
;
}
}
sts
=
gdh_ObjidToName
(
msg
->
Oid
,
name
,
sizeof
(
name
),
cdh_mName_volumeStrict
);
if
(
EVEN
(
sts
))
{
rmsg
.
Status
=
sts
;
udp_Send
(
(
char
*
)
&
rmsg
,
sizeof
(
rmsg
));
return
;
}
strcat
(
name
,
"."
);
strcat
(
name
,
msg
->
Attribute
);
sts
=
gdh_GetAttributeCharacteristics
(
name
,
&
atid
,
&
asize
,
&
aoffs
,
&
aelem
);
if
(
EVEN
(
sts
))
{
rmsg
.
Status
=
sts
;
udp_Send
(
(
char
*
)
&
rmsg
,
sizeof
(
rmsg
));
return
;
}
/* Direct link to atttribute */
sts
=
gdh_RefObjectInfo
(
name
,
&
p
,
&
dlid
,
asize
);
if
(
EVEN
(
sts
))
{
rmsg
.
Status
=
sts
;
udp_Send
(
(
char
*
)
&
rmsg
,
sizeof
(
rmsg
));
return
;
}
/* Insert first in sublist */
si
=
(
pwrsrv_sSubItem
*
)
calloc
(
1
,
sizeof
(
pwrsrv_sSubItem
));
si
->
oid
=
msg
->
Oid
;
strcpy
(
si
->
attribute
,
msg
->
Attribute
);
si
->
size
=
asize
;
si
->
rix
=
msg
->
Rix
;
si
->
p
=
p
;
si
->
dlid
=
dlid
;
si
->
next
=
pwrsrv_sublist
;
if
(
si
->
next
)
si
->
next
->
prev
=
si
;
pwrsrv_sublist
=
si
;
printf
(
"SubAdd: %d %s
\n
"
,
msg
->
Rix
,
name
);
rmsg
.
Status
=
GDH__SUCCESS
;
udp_Send
(
(
char
*
)
&
rmsg
,
sizeof
(
rmsg
));
}
static
void
pwrsrv_SubRemove
(
rpvd_sMsgSubRemove
*
msg
)
{
rpvd_sMsgAny
rmsg
;
pwrsrv_sSubItem
*
si
;
rmsg
.
Type
=
rpvd_eMsg_Status
;
rmsg
.
Id
=
msg
->
Id
;
// Remove and unref
for
(
si
=
pwrsrv_sublist
;
si
;
si
=
si
->
next
)
{
if
(
si
->
rix
==
msg
->
Rix
)
{
gdh_UnrefObjectInfo
(
si
->
dlid
);
if
(
si
->
prev
)
si
->
prev
->
next
=
si
->
next
;
else
pwrsrv_sublist
=
si
->
next
;
if
(
si
->
next
)
si
->
next
->
prev
=
si
->
prev
;
free
(
(
char
*
)
si
);
break
;
}
}
printf
(
"SubRemove: %d
\n
"
,
msg
->
Rix
);
rmsg
.
Status
=
GDH__SUCCESS
;
udp_Send
(
(
char
*
)
&
rmsg
,
sizeof
(
rmsg
));
}
static
void
pwrsrv_SubSend
(
rpvd_sMsgAny
*
m
)
{
rpvd_sMsgSubSend
msg
;
rpvd_sMsgAny
rmsg
;
pwrsrv_sSubItem
*
si
;
char
*
subp
;
int
msize
;
pwr_tStatus
sts
;
msg
.
Type
=
rpvd_eMsg_SubSend
;
msg
.
Id
=
m
->
Id
;
msg
.
Status
=
GDH__SUCCESS
;
msg
.
More
=
0
;
subp
=
(
char
*
)
&
msg
.
Data
;
for
(
si
=
pwrsrv_sublist
;
si
;
si
=
si
->
next
)
{
if
(
subp
-
(
char
*
)
&
msg
.
Data
+
8
+
si
->
size
+
4
>
sizeof
(
msg
.
Data
))
{
/* Buffer is full, send */
*
(
int
*
)
subp
=
-
1
;
msg
.
More
=
1
;
msize
=
subp
-
(
char
*
)
&
msg
+
4
;
sts
=
udp_Send
(
(
char
*
)
&
msg
,
msize
);
if
(
EVEN
(
sts
))
return
;
sts
=
udp_Receive
(
(
char
**
)
&
rmsg
,
1000
);
if
(
EVEN
(
sts
)
||
sts
==
REM__TIMEOUT
)
return
;
subp
=
(
char
*
)
&
msg
.
Data
;
msg
.
More
=
0
;
}
*
(
int
*
)
subp
=
si
->
rix
;
subp
+=
4
;
*
(
int
*
)
subp
=
si
->
size
;
subp
+=
4
;
memcpy
(
subp
,
si
->
p
,
si
->
size
);
subp
+=
si
->
size
;
}
*
(
int
*
)
subp
=
-
1
;
msize
=
subp
-
(
char
*
)
&
msg
+
4
;
udp_Send
(
(
char
*
)
&
msg
,
msize
);
}
static
void
pwrsrv_NodeUp
(
rpvd_sMsgAny
*
msg
)
{
rpvd_sMsgAny
rmsg
;
pwrsrv_sSubItem
*
si
,
*
si_next
;
rmsg
.
Type
=
rpvd_eMsg_Status
;
rmsg
.
Id
=
msg
->
Id
;
rmsg
.
Status
=
GDH__SUCCESS
;
/* Remove all subcli */
for
(
si
=
pwrsrv_sublist
;
si
;
si
=
si_next
)
{
si_next
=
si
->
next
;
free
(
(
char
*
)
si
);
}
pwrsrv_sublist
=
0
;
udp_Send
(
(
char
*
)
&
rmsg
,
sizeof
(
rmsg
));
}
void
usage
()
{
printf
(
"remote_pvd_pwrsrv Proview provider server
\n\n
"
);
printf
(
"Arguments:
\n
"
);
printf
(
" 1 Remote address
\n
"
);
printf
(
" 2 Remote host name
\n
"
);
printf
(
" 3 Udp port number (optional)
\n\n
"
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
pwr_tStatus
sts
;
char
remote_address
[
40
];
char
remote_host_name
[
40
];
rpvd_sMsg
*
msg
;
rpvd_sMsgAny
umsg
;
rpvd_sMsgAny
*
rmsg
;
int
udp_port
;
/* Read arguments */
if
(
argc
<
3
)
{
usage
();
exit
(
0
);
}
strcpy
(
remote_address
,
argv
[
1
]);
strcpy
(
remote_host_name
,
argv
[
2
]);
if
(
argc
>=
4
)
{
sts
=
sscanf
(
argv
[
3
],
"%d"
,
&
udp_port
);
if
(
sts
!=
1
)
{
usage
();
exit
(
0
);
}
}
else
udp_port
=
3051
;
sts
=
udp_Init
(
remote_address
,
remote_host_name
,
udp_port
);
if
(
EVEN
(
sts
))
{
exit
(
0
);
}
sts
=
gdh_Init
(
"remote_pvd_pwrsrv"
);
if
(
EVEN
(
sts
))
return
sts
;
umsg
.
Type
=
rpvd_eMsg_NodeUp
;
umsg
.
Id
=
0
;
sts
=
udp_Request
(
(
char
*
)
&
umsg
,
sizeof
(
umsg
),
(
char
**
)
&
rmsg
);
if
(
ODD
(
sts
)
&&
sts
!=
REM__TIMEOUT
&&
ODD
(
rmsg
->
Status
))
printf
(
"Link up
\n
"
);
for
(;;)
{
sts
=
udp_Receive
(
(
char
**
)
&
msg
,
5000
);
if
(
sts
==
REM__TIMEOUT
)
{
printf
(
"Alive
\n
"
);
}
else
if
(
ODD
(
sts
))
{
switch
(
msg
->
Any
.
Type
)
{
case
rpvd_eMsg_Oid
:
pwrsrv_Oid
(
&
msg
->
Oid
);
break
;
case
rpvd_eMsg_ObjectName
:
pwrsrv_ObjectName
(
&
msg
->
ObjectName
);
break
;
case
rpvd_eMsg_ReadAttribute
:
pwrsrv_ReadAttribute
(
&
msg
->
ReadAttribute
);
break
;
case
rpvd_eMsg_WriteAttribute
:
pwrsrv_WriteAttribute
(
&
msg
->
WriteAttribute
);
break
;
case
rpvd_eMsg_SubAdd
:
pwrsrv_SubAdd
(
&
msg
->
SubAdd
);
break
;
case
rpvd_eMsg_SubRemove
:
pwrsrv_SubRemove
(
&
msg
->
SubRemove
);
break
;
case
rpvd_eMsg_SubRequest
:
pwrsrv_SubSend
(
&
msg
->
Any
);
break
;
case
rpvd_eMsg_NodeUp
:
pwrsrv_NodeUp
(
&
msg
->
Any
);
break
;
}
}
}
}
remote/lib/remote/src/remote_ndc.c
0 → 100644
View file @
062e09f3
/*
* Proview $Id: remote_ndc.c,v 1.1 2006-09-14 14:17:44 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* remote_ndc.c -- Network data conversion. */
#include "pwr.h"
#include "pwr_class.h"
#include "rt_gdh_msg.h"
#include "rt_errh.h"
#include "rt_pool.h"
#include "rt_vol.h"
#include "rt_net.h"
#include "rt_cvol.h"
#include "rt_cvolc.h"
#include "rt_ndc.h"
#include "rt_ndc_msg.h"
#include "rt_cmvolc.h"
/* Vax f-float on a little endian machine.
3 2 2 1 1 1 0 0 0 0
1 4 3 6 5 4 8 7 6 0
+---------------+---------------+-+-------------+-+-------------+
| fraction 15 <- 0 |s| exponent : | f 22 <- 16 |
+---------------+---------------+-+-------------+-+-------------+
1 0 0 0 0 0 0 2 1
5 8 7 0 7 1 0 2 6
*/
union
vax_f_le
{
unsigned
int
i
;
struct
{
unsigned
int
f22_16
:
7
;
unsigned
int
exp
:
8
;
unsigned
int
sign
:
1
;
unsigned
int
f15_0
:
16
;
}
b
;
};
/* Vax f-float on a big endian machine.
+-+-------------+ +-+-------------+ +---------------+ +---------------+
: | f 22 <- 16 | |s| exponent : : 15 <- 0 | | fraction :
+-+-------------+ +-+-------------+ +---------------+ +---------------+
0 2 1 0 0 0 0 1 0
0 2 6 7 1 7 0 5 8
0 0 0 1 1 1 2 2 3
0 7 8 5 6 7 3 4 1
+---------------+---------------+-+-------------+-+-------------+
| fraction 0 -> 15 |s| exponent : | f 16 -> 22 |
+---------------+---------------+-+-------------+-+-------------+
0 0 0 1 0 0 1 2
0 7 8 5 0 7 6 2
*/
union
vax_f_be
{
unsigned
int
i
;
struct
{
unsigned
int
f0_15
:
16
;
unsigned
int
sign
:
1
;
unsigned
int
exp
:
8
;
unsigned
int
f16_22
:
7
;
}
b
;
};
/* IEEE single on a little endian machine.
3 2 2 1 1 0 0 0
1 4 3 6 5 8 7 0
+-+-------------+-+-------------+---------------+---------------+
|s| exponent : | fraction 22 <- 0 : |
+-+-------------+-+-------------+---------------+---------------+
0 0 2 1 1 0
7 0 2 6 5 0
*/
union
i3e_s_le
{
unsigned
int
i
;
struct
{
unsigned
int
f22_0
:
23
;
unsigned
int
exp
:
8
;
unsigned
int
sign
:
1
;
}
b
;
struct
{
unsigned
int
f15_0
:
16
;
unsigned
int
f22_16
:
7
;
unsigned
int
exp
:
8
;
unsigned
int
sign
:
1
;
}
v
;
};
/* IEEE single on a big endian machine.
0 0 0 1 1 2 2 3
0 7 8 5 6 3 4 1
+-+-------------+-+-------------+---------------+---------------+
|s| exponent : | fraction 0 -> 22 : |
+-+-------------+-+-------------+---------------+---------------+
0 0 0 0 0 0 2
0 6 7 0 6 7 2
*/
union
i3e_s_be
{
unsigned
int
i
;
struct
{
unsigned
int
sign
:
1
;
unsigned
int
exp
:
8
;
unsigned
int
f0_22
:
23
;
}
b
;
struct
{
unsigned
int
sign
:
1
;
unsigned
int
exp
:
8
;
unsigned
int
f0_6
:
7
;
unsigned
int
f7_22
:
16
;
}
v
;
};
#define VAX_F_BIAS 0x81
#define I3E_S_BIAS 0x7f
#define VAX_D_BIAS 0x81
#define VAX_G_BIAS 0x401
#define I3E_D_BIAS 0x3ff
#define IBYTE0(i) ((i >> 0x18) & 0x000000ff)
#define IBYTE1(i) ((i >> 0x08) & 0x0000ff00)
#define IBYTE2(i) ((i << 0x08) & 0x00ff0000)
#define IBYTE3(i) ((i << 0x18) & 0xff000000)
#define ENDIAN_SWAP_INT(t, s)\
{int i = *(int *)s; *(int *)t = (IBYTE0(i) | IBYTE1(i) | IBYTE2(i) | IBYTE3(i));}
#define SBYTE0(s) ((s >> 0x08) & 0x00ff)
#define SBYTE1(s) ((s << 0x08) & 0xff00)
#define ENDIAN_SWAP_SHORT(t, s)\
{short int i = *(short *)s; *(short *)t = (SBYTE0(i) | SBYTE1(i));}
#if 0
# define ENDIAN_SWAP_BOOL(t, s) (*(int *)t = (0 != *(int *)s))
#else
# define ENDIAN_SWAP_BOOL(t, s) ENDIAN_SWAP_INT(t, s)
#endif
#define touchObject(op) if (op != NULL && op->l.flags.b.isCached) cvolc_TouchObject(op)
union
{
float
ff
;
int
ii
;
short
int
sii
;
char
cc
[
4
];
}
intern
;
union
{
unsigned
int
ii
;
char
cc
[
4
];
}
tmp
;
/*************************************************************************
*
* Float32_AXP_(&intel)
*
* Example: Mess->VaxValue = Intel_Vax_Float(&Value);
* Description: Convert from Intel-float into VAX f-float
* Integer function in Lynx
*
*************************************************************************
*************************************************************************/
int
Float32_AXP
(
float
*
intel
)
{
char
c
;
intern
.
ff
=
*
intel
;
/* Factor 4 */
if
(((
intern
.
cc
[
3
]
&
127
)
==
0
)
&&
((
intern
.
cc
[
2
]
&
128
)
==
0
))
intern
.
ff
=
0
.
0
;
else
if
((
intern
.
cc
[
3
]
&
127
)
==
127
)
{
if
(
intern
.
ff
>
0
.
0
)
intern
.
ii
=
0x7fffffff
;
else
intern
.
ii
=
0xffffffff
;
}
else
intern
.
ff
*=
4
;
/* Byte order */
c
=
intern
.
cc
[
0
];
intern
.
cc
[
0
]
=
intern
.
cc
[
2
];
intern
.
cc
[
2
]
=
c
;
c
=
intern
.
cc
[
1
];
intern
.
cc
[
1
]
=
intern
.
cc
[
3
];
intern
.
cc
[
3
]
=
c
;
return
intern
.
ii
;
/* Return with answer */
}
/*************************************************************************
*
* AXP_Float32(&axp)
*
* Example: Value = VaxIntel_Float(&Mess->VaxValue);
* Description: Convert from VAX f-float into Intel-float
* Floatfunction in Lynx
*
*************************************************************************
*************************************************************************/
float
AXP_Float32
(
int
*
axp
)
{
char
*
p
;
/* Pointer to ieee data-area */
p
=
(
char
*
)
axp
;
/* Pointer to buffer */
intern
.
cc
[
2
]
=
*
p
++
;
/* Get data in the right order */
intern
.
cc
[
3
]
=
*
p
++
;
intern
.
cc
[
0
]
=
*
p
++
;
intern
.
cc
[
1
]
=
*
p
;
return
intern
.
ff
/
4
;
}
/* . */
static
pwr_tBoolean
decode_aref
(
int
count
,
int
asize
,
char
*
tp
,
char
*
sp
,
int
*
size
)
{
for
(;
count
>
0
&&
*
size
>=
sizeof
(
pwr_sAttrRef
);
count
--
)
{
ENDIAN_SWAP_INT
(
tp
,
sp
);
tp
+=
sizeof
(
int
);
sp
+=
sizeof
(
int
);
ENDIAN_SWAP_INT
(
tp
,
sp
);
tp
+=
sizeof
(
int
);
sp
+=
sizeof
(
int
);
ENDIAN_SWAP_INT
(
tp
,
sp
);
tp
+=
sizeof
(
int
);
sp
+=
sizeof
(
int
);
ENDIAN_SWAP_INT
(
tp
,
sp
);
tp
+=
sizeof
(
int
);
sp
+=
sizeof
(
int
);
ENDIAN_SWAP_INT
(
tp
,
sp
);
tp
+=
sizeof
(
int
);
sp
+=
sizeof
(
int
);
ENDIAN_SWAP_INT
(
tp
,
sp
);
tp
+=
sizeof
(
int
);
sp
+=
sizeof
(
int
);
*
size
-=
sizeof
(
pwr_sAttrRef
);
}
return
TRUE
;
}
/* . */
static
pwr_tBoolean
decode_bool
(
int
count
,
int
asize
,
char
*
tp
,
char
*
sp
,
int
*
size
)
{
for
(;
count
>
0
&&
*
size
>=
sizeof
(
int
);
count
--
)
{
ENDIAN_SWAP_BOOL
(
tp
,
sp
);
tp
+=
sizeof
(
int
);
sp
+=
sizeof
(
int
);
*
size
-=
sizeof
(
int
);
}
return
TRUE
;
}
/* . */
static
pwr_tBoolean
decode_copy
(
int
count
,
int
asize
,
char
*
tp
,
char
*
sp
,
int
*
size
)
{
if
(
tp
!=
sp
)
memcpy
(
tp
,
sp
,
MIN
(
asize
,
*
size
));
*
size
=
(
*
size
>=
asize
?
*
size
-
asize
:
0
);
return
TRUE
;
}
/* . */
static
pwr_tBoolean
decode_null
(
int
count
,
int
asize
,
char
*
tp
,
char
*
sp
,
int
size
)
{
return
FALSE
;
}
static
pwr_tBoolean
encode_vms_sfloat
(
int
count
,
int
asize
,
char
*
tp
,
char
*
sp
,
int
*
size
)
{
float
f
;
for
(;
count
>
0
&&
*
size
>=
sizeof
(
float
);
count
--
)
{
f
=
AXP_Float32
(
(
int
*
)
sp
);
memcpy
(
tp
,
&
f
,
sizeof
(
f
));
tp
+=
sizeof
(
float
);
sp
+=
sizeof
(
float
);
*
size
-=
sizeof
(
float
);
}
return
TRUE
;
}
static
pwr_tBoolean
encode_intel_sfloat
(
int
count
,
int
asize
,
char
*
tp
,
char
*
sp
,
int
*
size
)
{
for
(;
count
>
0
&&
*
size
>=
sizeof
(
float
);
count
--
)
{
ENDIAN_SWAP_INT
(
tp
,
sp
);
tp
+=
sizeof
(
float
);
sp
+=
sizeof
(
float
);
*
size
-=
sizeof
(
float
);
}
return
TRUE
;
}
static
pwr_tBoolean
decode_vms_sfloat
(
int
count
,
int
asize
,
char
*
tp
,
char
*
sp
,
int
*
size
)
{
int
vf
;
for
(;
count
>
0
&&
*
size
>=
sizeof
(
float
);
count
--
)
{
vf
=
Float32_AXP
(
(
float
*
)
sp
);
memcpy
(
tp
,
&
vf
,
sizeof
(
vf
));
tp
+=
sizeof
(
float
);
sp
+=
sizeof
(
float
);
*
size
-=
sizeof
(
float
);
}
return
TRUE
;
}
static
pwr_tBoolean
decode_intel_sfloat
(
int
count
,
int
asize
,
char
*
tp
,
char
*
sp
,
int
*
size
)
{
for
(;
count
>
0
&&
*
size
>=
sizeof
(
float
);
count
--
)
{
ENDIAN_SWAP_INT
(
tp
,
sp
);
tp
+=
sizeof
(
float
);
sp
+=
sizeof
(
float
);
*
size
-=
sizeof
(
float
);
}
return
TRUE
;
}
static
pwr_tBoolean
decode_int
(
int
count
,
int
asize
,
char
*
tp
,
char
*
sp
,
int
*
size
)
{
for
(;
count
>
0
&&
*
size
>=
sizeof
(
int
);
count
--
)
{
ENDIAN_SWAP_INT
(
tp
,
sp
);
tp
+=
sizeof
(
int
);
sp
+=
sizeof
(
int
);
*
size
-=
sizeof
(
int
);
}
return
TRUE
;
}
static
pwr_tBoolean
decode_2_int
(
int
count
,
int
asize
,
char
*
tp
,
char
*
sp
,
int
*
size
)
{
for
(
count
*=
2
;
count
>
0
&&
*
size
>=
sizeof
(
int
);
count
--
)
{
ENDIAN_SWAP_INT
(
tp
,
sp
);
tp
+=
sizeof
(
int
);
sp
+=
sizeof
(
int
);
*
size
-=
sizeof
(
int
);
}
return
TRUE
;
}
/* Convert a short integer.
NOTA BENE A short occupies 4 bytes in the Proview rtdb
and thus this routine is not currently used. */
static
pwr_tBoolean
decode_short
(
int
count
,
int
asize
,
char
*
tp
,
char
*
sp
,
int
*
size
)
{
for
(;
count
>
0
&&
*
size
>=
sizeof
(
short
);
count
--
)
{
ENDIAN_SWAP_SHORT
(
tp
,
sp
);
tp
+=
sizeof
(
short
);
sp
+=
sizeof
(
short
);
*
size
-=
sizeof
(
short
);
}
return
TRUE
;
}
/* Convert a tiny integer (8 bits).
NOTA BENE A tiny occupies 4 bytes in the Proview rtdb
and thus this routine is not currently used. */
static
pwr_tBoolean
decode_tiny
(
int
count
,
int
asize
,
char
*
tp
,
char
*
sp
,
int
*
size
)
{
for
(;
count
>
0
&&
*
size
>=
sizeof
(
char
);
count
--
)
{
*
tp
++
=
*
sp
++
;
(
*
size
)
--
;
}
return
TRUE
;
}
#if 0
static pwr_tBoolean (*decode[pwr_eTix_])() = {
decode_null, /* pwr_eTix__ */
decode_bool, /* pwr_eTix_Boolean */
decode_sfloat, /* pwr_eTix_Float32 */
decode_copy, /* pwr_eTix_Float64 */
decode_tiny, /* pwr_eTix_Char */
decode_tiny, /* pwr_eTix_Int8 */
decode_short, /* pwr_eTix_Int16 */
decode_int, /* pwr_eTix_Int32 */
decode_tiny, /* pwr_eTix_UInt8 */
decode_short, /* pwr_eTix_UInt16 */
decode_int, /* pwr_eTix_UInt32 */
decode_2_int, /* pwr_eTix_Objid */
decode_copy, /* pwr_eTix_Buffer */
decode_copy, /* pwr_eTix_String */
decode_int, /* pwr_eTix_Enum */
decode_null, /* pwr_eTix_Struct */
decode_int, /* pwr_eTix_Mask */
decode_null, /* pwr_eTix_Array */
decode_2_int, /* pwr_eTix_Time */
decode_copy, /* pwr_eTix_Text */
decode_aref, /* pwr_eTix_AttrRef */
decode_2_int, /* pwr_eTix_UInt64 */
decode_2_int, /* pwr_eTix_Int64 */
decode_int, /* pwr_eTix_ClassId */
decode_int, /* pwr_eTix_TypeId */
decode_int, /* pwr_eTix_VolumeId */
decode_int, /* pwr_eTix_ObjectIx */
decode_2_int, /* pwr_eTix_RefId */
decode_2_int, /* pwr_eTix_DeltaTime */
};
static pwr_tBoolean (*encode[pwr_eTix_])() = {
decode_null, /* pwr_eTix__ */
decode_bool, /* pwr_eTix_Boolean */
encode_sfloat, /* pwr_eTix_Float32 */
decode_null, /* pwr_eTix_Float64 */
decode_tiny, /* pwr_eTix_Char */
decode_tiny, /* pwr_eTix_Int8 */
decode_short, /* pwr_eTix_Int16 */
decode_int, /* pwr_eTix_Int32 */
decode_tiny, /* pwr_eTix_UInt8 */
decode_short, /* pwr_eTix_UInt16 */
decode_int, /* pwr_eTix_UInt32 */
decode_2_int, /* pwr_eTix_Objid */
decode_copy, /* pwr_eTix_Buffer */
decode_copy, /* pwr_eTix_String */
decode_int, /* pwr_eTix_Enum */
decode_null, /* pwr_eTix_Struct */
decode_int, /* pwr_eTix_Mask */
decode_null, /* pwr_eTix_Array */
decode_2_int, /* pwr_eTix_Time */
decode_copy, /* pwr_eTix_Text */
decode_aref, /* pwr_eTix_AttrRef */
decode_2_int, /* pwr_eTix_UInt64 */
decode_2_int, /* pwr_eTix_Int64 */
decode_int, /* pwr_eTix_ClassId */
decode_int, /* pwr_eTix_TypeId */
decode_int, /* pwr_eTix_VolumeId */
decode_int, /* pwr_eTix_ObjectIx */
decode_2_int, /* pwr_eTix_RefId */
decode_2_int, /* pwr_eTix_DeltaTime */
};
#endif
static
pwr_tBoolean
(
*
decode_vms_to_linx86
[
pwr_eTix_
])()
=
{
decode_null
,
/* pwr_eTix__ */
decode_copy
,
/* pwr_eTix_Boolean */
decode_vms_sfloat
,
/* pwr_eTix_Float32 */
decode_copy
,
/* pwr_eTix_Float64 */
decode_copy
,
/* pwr_eTix_Char */
decode_copy
,
/* pwr_eTix_Int8 */
decode_copy
,
/* pwr_eTix_Int16 */
decode_copy
,
/* pwr_eTix_Int32 */
decode_copy
,
/* pwr_eTix_UInt8 */
decode_copy
,
/* pwr_eTix_UInt16 */
decode_copy
,
/* pwr_eTix_UInt32 */
decode_copy
,
/* pwr_eTix_Objid */
decode_copy
,
/* pwr_eTix_Buffer */
decode_copy
,
/* pwr_eTix_String */
decode_copy
,
/* pwr_eTix_Enum */
decode_null
,
/* pwr_eTix_Struct */
decode_copy
,
/* pwr_eTix_Mask */
decode_null
,
/* pwr_eTix_Array */
decode_copy
,
/* pwr_eTix_Time */
decode_copy
,
/* pwr_eTix_Text */
decode_copy
,
/* pwr_eTix_AttrRef */
decode_copy
,
/* pwr_eTix_UInt64 */
decode_copy
,
/* pwr_eTix_Int64 */
decode_copy
,
/* pwr_eTix_ClassId */
decode_copy
,
/* pwr_eTix_TypeId */
decode_copy
,
/* pwr_eTix_VolumeId */
decode_copy
,
/* pwr_eTix_ObjectIx */
decode_copy
,
/* pwr_eTix_RefId */
decode_copy
,
/* pwr_eTix_DeltaTime */
};
static
pwr_tBoolean
(
*
encode_vms_to_linx86
[
pwr_eTix_
])()
=
{
decode_null
,
/* pwr_eTix__ */
decode_copy
,
/* pwr_eTix_Boolean */
encode_vms_sfloat
,
/* pwr_eTix_Float32 */
decode_null
,
/* pwr_eTix_Float64 */
decode_copy
,
/* pwr_eTix_Char */
decode_copy
,
/* pwr_eTix_Int8 */
decode_copy
,
/* pwr_eTix_Int16 */
decode_copy
,
/* pwr_eTix_Int32 */
decode_copy
,
/* pwr_eTix_UInt8 */
decode_copy
,
/* pwr_eTix_UInt16 */
decode_copy
,
/* pwr_eTix_UInt32 */
decode_copy
,
/* pwr_eTix_Objid */
decode_copy
,
/* pwr_eTix_Buffer */
decode_copy
,
/* pwr_eTix_String */
decode_copy
,
/* pwr_eTix_Enum */
decode_null
,
/* pwr_eTix_Struct */
decode_copy
,
/* pwr_eTix_Mask */
decode_null
,
/* pwr_eTix_Array */
decode_copy
,
/* pwr_eTix_Time */
decode_copy
,
/* pwr_eTix_Text */
decode_copy
,
/* pwr_eTix_AttrRef */
decode_copy
,
/* pwr_eTix_UInt64 */
decode_copy
,
/* pwr_eTix_Int64 */
decode_copy
,
/* pwr_eTix_ClassId */
decode_copy
,
/* pwr_eTix_TypeId */
decode_copy
,
/* pwr_eTix_VolumeId */
decode_copy
,
/* pwr_eTix_ObjectIx */
decode_copy
,
/* pwr_eTix_RefId */
decode_copy
,
/* pwr_eTix_DeltaTime */
};
/**
* @note There is no support for double.
* if we want to implement it we have too look at the OS to decide what
* format to use. Because for backward compatibility is the float format set
* to vaxF for VAX to AXP and not vaxD and vaxG.
*/
pwr_tBoolean
rndc_ConvertData
(
pwr_tStatus
*
sts
,
const
gdb_sNode
*
np
,
gdb_sClass
*
cp
,
void
*
tp
,
/* Address of target. */
const
void
*
sp
,
/* Address of source. */
pwr_tUInt32
*
size
,
/* Size of source. */
ndc_eOp
op
,
pwr_tUInt32
offset
,
pwr_tUInt32
offs
)
{
int
i
;
int
base
;
gdb_sAttribute
*
ap
;
pwr_tUInt32
aoffs
;
pwr_tUInt32
count
;
/* The new way, convert if different co_mFormat
* The old way, always convert if different OS
*/
if
((
np
->
netver
>=
net_cFirstCclassVersion
&&
np
->
fm
.
m
==
gdbroot
->
my_node
->
fm
.
m
)
||
(
np
->
netver
<
net_cFirstCclassVersion
&&
np
->
os
==
gdbroot
->
my_node
->
os
&&
np
->
fm
.
b
.
bo
==
gdbroot
->
my_node
->
fm
.
b
.
bo
))
{
if
(
tp
!=
sp
)
memcpy
(
tp
,
sp
,
*
size
);
return
TRUE
;
}
/* Find attribute. */
for
(
i
=
0
,
ap
=
cp
->
attr
;
i
<
cp
->
acount
;
i
++
,
ap
++
)
if
(
offset
<=
ap
->
moffset
)
break
;
if
(
i
>=
cp
->
acount
)
pwr_Return
(
NO
,
sts
,
NDC__OFFSET
);
if
(
offset
==
0
)
base
=
0
;
else
base
=
ap
->
offs
;
switch
(
op
)
{
case
ndc_eOp_encode
:
for
(;
i
<
cp
->
acount
&&
*
size
>
0
;
i
++
,
ap
++
)
{
if
(
ap
->
flags
.
b
.
isclass
)
{
gdb_sClass
*
lcp
;
lcp
=
hash_Search
(
sts
,
gdbroot
->
cid_ht
,
&
ap
->
tid
);
/* Single attribute or array */
/* Loop n:o element */
aoffs
=
0
;
/* Attribute offset - source */
for
(
count
=
ap
->
elem
;
count
>
0
&&
*
size
>
0
;
count
--
)
{
rndc_ConvertData
(
sts
,
np
,
lcp
,
tp
,
sp
,
size
,
op
,
(
offset
-
ap
->
offs
)
%
(
ap
->
size
/
ap
->
elem
),
ap
->
offs
-
base
+
aoffs
+
offs
);
aoffs
+=
ap
->
size
/
ap
->
elem
;
}
}
else
{
if
(
!
encode_vms_to_linx86
[
pwr_Tix
(
ap
->
type
)](
ap
->
elem
,
ap
->
size
,
(
char
*
)
tp
+
(
ap
->
offs
-
base
+
offs
),
(
char
*
)
sp
+
(
ap
->
offs
-
base
+
offs
),
size
))
pwr_Return
(
NO
,
sts
,
NDC__CONVERT
);
}
}
break
;
case
ndc_eOp_decode
:
for
(;
i
<
cp
->
acount
&&
*
size
>
0
;
i
++
,
ap
++
)
{
if
(
ap
->
flags
.
b
.
isclass
)
{
gdb_sClass
*
lcp
;
lcp
=
hash_Search
(
sts
,
gdbroot
->
cid_ht
,
&
ap
->
tid
);
/* Single attribute or array */
/* Loop n:o element */
aoffs
=
0
;
/* Attribute offset - source */
for
(
count
=
ap
->
elem
;
count
>
0
&&
*
size
>
0
;
count
--
)
{
rndc_ConvertData
(
sts
,
np
,
lcp
,
tp
,
sp
,
size
,
op
,
(
offset
-
ap
->
offs
)
%
(
ap
->
size
/
ap
->
elem
),
ap
->
offs
-
base
+
aoffs
+
offs
);
aoffs
+=
ap
->
size
/
ap
->
elem
;
}
}
else
{
if
(
!
decode_vms_to_linx86
[
pwr_Tix
(
ap
->
type
)](
ap
->
elem
,
ap
->
size
,
(
char
*
)
tp
+
(
ap
->
offs
-
base
+
offs
),
(
char
*
)
sp
+
(
ap
->
offs
-
base
+
offs
),
size
))
pwr_Return
(
NO
,
sts
,
NDC__CONVERT
);
}
}
break
;
default:
{
char
ebuf
[
80
];
sprintf
(
ebuf
,
"unknown op: %d"
,
op
);
errh_Bugcheck
(
NDC__OP
,
ebuf
);
}
break
;
}
pwr_Return
(
YES
,
sts
,
NDC__SUCCESS
);
}
remote/lib/remote/src/remote_ndc.h
0 → 100644
View file @
062e09f3
/*
* Proview $Id: remote_ndc.h,v 1.1 2006-09-14 14:17:44 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef remote_ndc_h
#define remote_ndc_h
/* remote_ndc.h -- Network data conversion. */
#ifndef rt_ndc_h
# include "rt_ndc.h"
#endif
pwr_tBoolean
rndc_ConvertData
(
pwr_tStatus
*
sts
,
const
gdb_sNode
*
np
,
gdb_sClass
*
cp
,
void
*
tp
,
/* Address of target. */
const
void
*
sp
,
/* Address of source. */
pwr_tUInt32
*
size
,
/* Size of source. */
ndc_eOp
op
,
pwr_tUInt32
offset
,
pwr_tUInt32
offs
);
#endif
remote/lib/remote/src/remote_pvd_udp.c
0 → 100644
View file @
062e09f3
/*
* Proview $Id: remote_pvd_udp.c,v 1.1 2006-09-14 14:17:44 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include "rs_remote_msg.h"
#include "remote_pvd_udp.h"
#define STX 2
#define ETB 15
#define ENQ 5
#define ACK 6
#define UDP_MAX_SIZE 32768
#define TIME_INCR 0.02
#define errh_Error printf
#define errh_Info printf
fd_set
fds
;
/* For select call */
typedef
struct
{
unsigned
char
protocol_id
[
2
];
unsigned
short
int
msg_size
;
unsigned
short
int
msg_id
[
2
];
}
udp_header
;
int
my_socket
;
/* My socket */
struct
sockaddr_in
my_addr
;
/* My named socket description */
struct
sockaddr_in
their_addr
;
/* Remote socket description */
struct
sockaddr_in
dual_addr
;
/* Maybe a dual socket description */
typedef
struct
{
int
LocalPort
;
int
RemotePort
;
char
RemoteHostName
[
32
];
char
RemoteAddress
[
32
];
int
LinkUp
;
int
KeepaliveDiff
;
int
MaxBuffers
;
int
DisableHeader
;
int
Receive
;
int
ErrCount
;
int
Disable
;
}
*
udp_tCtx
;
static
udp_tCtx
udp_ctx
=
0
;
#if 0
static void RemoteSleep(float time)
{
struct timespec rqtp, rmtp;
rqtp.tv_sec = 0;
rqtp.tv_nsec = (long int) (time * 1000000000);
nanosleep(&rqtp, &rmtp);
return;
}
#endif
void
udp_Disable
()
{
udp_ctx
->
Disable
=
1
;
}
void
udp_Enable
()
{
udp_ctx
->
Disable
=
0
;
}
static
int
CreateSocket
(
udp_tCtx
ctx
)
{
int
sts
;
unsigned
char
badr
[
4
];
unsigned
int
iadr
[
4
]
=
{
-
1
,
-
1
,
-
1
,
-
1
};
struct
hostent
*
he
;
struct
sockaddr_in
address
;
socklen_t
address_len
=
sizeof
(
struct
sockaddr_in
);
/* Create a socket for UDP */
my_socket
=
socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
if
(
my_socket
<
0
)
{
errh_Error
(
"Socket, %d"
,
my_socket
);
return
0
;
}
if
(
ctx
->
LocalPort
!=
0
)
{
/* Set local port */
my_addr
.
sin_family
=
AF_INET
;
my_addr
.
sin_port
=
htons
(
ctx
->
LocalPort
);
/* Bind the created socket */
sts
=
bind
(
my_socket
,
(
struct
sockaddr
*
)
&
my_addr
,
sizeof
(
my_addr
));
if
(
sts
!=
0
)
{
errh_Error
(
"Bind, %d"
,
sts
);
return
0
;
}
}
else
{
getsockname
(
my_socket
,
(
struct
sockaddr
*
)
&
address
,
&
address_len
);
ctx
->
LocalPort
=
ntohs
(
address
.
sin_port
);
}
/* Initialize remote address structure */
their_addr
.
sin_family
=
AF_INET
;
their_addr
.
sin_port
=
htons
(
ctx
->
RemotePort
);
sscanf
((
char
*
)
&
(
ctx
->
RemoteAddress
),
"%d.%d.%d.%d"
,
&
iadr
[
0
],
&
iadr
[
1
],
&
iadr
[
2
],
&
iadr
[
3
]);
/* If none or invalid ip-address is given, use hostname to get hostent struct,
otherwise use the given ip address directly */
if
((
iadr
[
0
]
<
0
||
iadr
[
0
]
>
255
)
||
(
iadr
[
0
]
<
0
||
iadr
[
0
]
>
255
)
||
(
iadr
[
0
]
<
0
||
iadr
[
0
]
>
255
)
||
(
iadr
[
0
]
<
0
||
iadr
[
0
]
>
255
))
{
he
=
gethostbyname
(
ctx
->
RemoteHostName
);
if
(
he
)
{
memcpy
(
&
their_addr
.
sin_addr
,
he
->
h_addr
,
4
);
sprintf
(
ctx
->
RemoteAddress
,
"%s"
,
inet_ntoa
(
their_addr
.
sin_addr
));
}
else
{
errh_Error
(
"Unknown host, %s"
,
ctx
->
RemoteHostName
);
return
0
;
}
}
else
{
badr
[
0
]
=
(
unsigned
char
)
iadr
[
0
];
badr
[
1
]
=
(
unsigned
char
)
iadr
[
1
];
badr
[
2
]
=
(
unsigned
char
)
iadr
[
2
];
badr
[
3
]
=
(
unsigned
char
)
iadr
[
3
];
memcpy
(
&
their_addr
.
sin_addr
,
&
badr
,
4
);
}
ctx
->
LinkUp
=
0
;
ctx
->
KeepaliveDiff
=
0
;
return
1
;
}
pwr_tStatus
udp_Request
(
char
*
sendbuf
,
int
sendbuf_size
,
char
**
rcvbuf
)
{
int
i
;
pwr_tStatus
sts
;
int
tmo
=
100
;
if
(
udp_ctx
->
Disable
)
return
REM__DISABLED
;
for
(
i
=
0
;
i
<
5
;
i
++
)
{
sts
=
udp_Send
(
sendbuf
,
sendbuf_size
);
if
(
EVEN
(
sts
))
return
sts
;
sts
=
udp_Receive
(
rcvbuf
,
tmo
);
if
(
sts
!=
REM__TIMEOUT
)
return
sts
;
tmo
=
tmo
*
2
;
}
if
(
udp_ctx
->
LinkUp
)
{
printf
(
"UDP link Down to node %s
\n
"
,
udp_ctx
->
RemoteHostName
);
udp_ctx
->
LinkUp
=
0
;
}
return
sts
;
}
pwr_tStatus
udp_Send
(
char
*
buf
,
int
buf_size
)
{
int
status
;
udp_tCtx
ctx
=
udp_ctx
;
static
struct
message_s
{
udp_header
header
;
char
data
[
UDP_MAX_SIZE
];
}
message
;
if
(
ctx
->
Disable
)
return
REM__DISABLED
;
message
.
header
.
protocol_id
[
0
]
=
STX
;
message
.
header
.
protocol_id
[
1
]
=
ETB
;
message
.
header
.
msg_size
=
htons
(
buf_size
+
sizeof
(
udp_header
));
memcpy
(
&
message
.
data
,
buf
,
buf_size
);
if
(
ctx
->
DisableHeader
)
status
=
sendto
(
my_socket
,
&
message
.
data
,
buf_size
,
0
,
(
struct
sockaddr
*
)
&
their_addr
,
sizeof
(
struct
sockaddr
));
else
status
=
sendto
(
my_socket
,
&
message
,
buf_size
+
sizeof
(
udp_header
),
0
,
(
struct
sockaddr
*
)
&
their_addr
,
sizeof
(
struct
sockaddr
));
return
REM__SUCCESS
;
}
pwr_tStatus
udp_Receive
(
char
**
buff
,
int
tmo
)
{
static
char
buf
[
UDP_MAX_SIZE
];
char
unknown
[
24
];
unsigned
char
badr
[
24
];
char
*
datapos
;
int
datasize
;
struct
sockaddr_in
from
;
unsigned
int
fromlen
;
int
size
;
unsigned
int
sts
;
udp_header
header
;
udp_tCtx
ctx
=
udp_ctx
;
struct
timeval
tv
;
if
(
ctx
->
Disable
)
return
REM__DISABLED
;
tv
.
tv_sec
=
tmo
/
1000
;
tv
.
tv_usec
=
(
tmo
-
tv
.
tv_sec
*
1000
)
*
1000
;
FD_ZERO
(
&
fds
);
FD_SET
(
my_socket
,
&
fds
);
sts
=
select
(
32
,
&
fds
,
NULL
,
NULL
,
&
tv
);
switch
(
sts
)
{
case
0
:
/* Timeout */
return
REM__TIMEOUT
;
case
-
1
:
errh_Error
(
"Select, %d"
,
sts
);
exit
(
0
);
default:
;
}
/* We have made a select, so we're pretty sure there is something to take */
fromlen
=
sizeof
(
struct
sockaddr
);
size
=
recvfrom
(
my_socket
,
&
buf
,
sizeof
(
buf
),
0
,
(
struct
sockaddr
*
)
&
from
,
&
fromlen
);
if
(
size
<
0
)
{
/* Definitly error */
errh_Info
(
"UDP Receive fail %s"
,
ctx
->
RemoteHostName
);
ctx
->
ErrCount
++
;
return
(
-
1
);
}
if
(
memcmp
(
&
from
.
sin_addr
,
&
their_addr
.
sin_addr
,
sizeof
(
struct
in_addr
))
!=
0
)
{
/*from.sin_port != their_addr.sin_port*/
memcpy
(
&
badr
,
&
from
.
sin_addr
,
4
);
sprintf
(
unknown
,
"%d.%d.%d.%d"
,
badr
[
0
],
badr
[
1
],
badr
[
2
],
badr
[
3
]);
errh_Info
(
"UDP Receive from unknown source %s"
,
unknown
);
ctx
->
ErrCount
++
;
return
(
1
);
}
/* Set link up */
if
(
ctx
->
LinkUp
==
0
)
{
errh_Info
(
"UDP link up %s"
,
ctx
->
RemoteHostName
);
ctx
->
LinkUp
=
1
;
}
if
(
size
>
0
&&
ctx
->
DisableHeader
)
{
datapos
=
buf
;
datasize
=
sizeof
(
buf
);
}
else
if
(
size
>=
8
)
{
memcpy
(
&
header
,
&
buf
,
sizeof
(
udp_header
));
/* Convert the header to host byte order */
header
.
msg_size
=
ntohs
(
header
.
msg_size
);
header
.
msg_id
[
0
]
=
ntohs
(
header
.
msg_id
[
0
]);
header
.
msg_id
[
1
]
=
ntohs
(
header
.
msg_id
[
1
]);
if
(
header
.
protocol_id
[
0
]
==
STX
&&
size
==
header
.
msg_size
)
{
if
(
header
.
protocol_id
[
1
]
==
ETB
||
header
.
protocol_id
[
1
]
==
ENQ
)
{
if
(
header
.
msg_id
[
0
]
==
0
&&
header
.
msg_id
[
1
]
==
0
)
{
/* Keepalive */
ctx
->
KeepaliveDiff
--
;
}
else
{
/* Data */
datapos
=
((
char
*
)
&
buf
)
+
sizeof
(
udp_header
);
datasize
=
header
.
msg_size
-
sizeof
(
udp_header
);
printf
(
"%s"
,
datapos
);
}
}
else
{
/* Weird header */
ctx
->
ErrCount
++
;
errh_Info
(
"UDP receive weird header %s, %02x %02x %04x %04x %04x"
,
ctx
->
RemoteHostName
,
header
.
protocol_id
[
0
],
header
.
protocol_id
[
1
],
header
.
msg_size
,
header
.
msg_id
[
0
],
header
.
msg_id
[
1
]);
}
}
else
{
/* Weird header */
ctx
->
ErrCount
++
;
errh_Info
(
"UDP receive weird header %s, %02x %02x %04x %04x %04x"
,
ctx
->
RemoteHostName
,
header
.
protocol_id
[
0
],
header
.
protocol_id
[
1
],
header
.
msg_size
,
header
.
msg_id
[
0
],
header
.
msg_id
[
1
]);
}
}
else
{
/* Not a remtrans UPD message */
ctx
->
ErrCount
++
;
errh_Info
(
"UDP receive weird message %s"
,
ctx
->
RemoteHostName
);
}
*
buff
=
datapos
;
return
1
;
}
pwr_tStatus
udp_Init
(
char
*
remote_address
,
char
*
remote_host_name
,
int
port
)
{
pwr_tStatus
sts
;
udp_tCtx
ctx
=
calloc
(
1
,
sizeof
(
*
ctx
));
ctx
->
LocalPort
=
port
;
ctx
->
RemotePort
=
port
;
ctx
->
DisableHeader
=
1
;
strcpy
(
ctx
->
RemoteAddress
,
remote_address
);
strcpy
(
ctx
->
RemoteHostName
,
remote_host_name
);
sts
=
CreateSocket
(
ctx
);
if
(
EVEN
(
sts
))
return
sts
;
udp_ctx
=
ctx
;
return
1
;
}
#if 0
int main(int argc, char *argv[])
{
struct timeval tv;
int sts;
udp_tCtx ctx = calloc( 1, sizeof(*ctx));
ctx->LocalPort = 3051;
ctx->RemotePort = 3051;
ctx->DisableHeader = 1;
/* Read arguments */
if (argc >= 2)
strcpy(ctx->RemoteAddress, argv[1]);
else {
printf( "Invalid arguments\n");
exit(0);
}
if (argc >= 3)
strcpy(ctx->RemoteHostName, argv[2]);
if ( argc >= 4)
ctx->Receive = 1;
CreateSocket( ctx);
for (;;) {
RemoteSleep(TIME_INCR);
if ( ctx->Receive) {
tv.tv_sec = 0;
tv.tv_usec = 0;
FD_ZERO(&fds);
FD_SET(my_socket, &fds);
sts = select(32, &fds, NULL, NULL, &tv);
if (sts > 0) UdpReceive( ctx);
if (sts < 0) {
errh_Error("Select, %d", sts);
exit(0);
}
}
else {
UdpSend( ctx, "Hej hopp", 8);
}
}
}
#endif
remote/lib/remote/src/remote_pvd_udp.h
0 → 100644
View file @
062e09f3
/*
* Proview $Id: remote_pvd_udp.h,v 1.1 2006-09-14 14:17:44 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
#ifndef remote_pvd_udp_h
#define remote_pvd_udp_h
#include "pwr.h"
#if defined __cplusplus
extern
"C"
{
#endif
typedef
struct
{
int
cid
;
pwr_tOix
oix
;
pwr_tOix
fthoix
;
pwr_tOix
bwsoix
;
pwr_tOix
fwsoix
;
pwr_tOix
fchoix
;
pwr_tOix
lchoix
;
char
name
[
32
];
}
rpvd_sObject
;
typedef
enum
{
rpvd_eMsg_Oid
,
rpvd_eMsg_ObjectName
,
rpvd_eMsg_Object
,
rpvd_eMsg_ReadAttribute
,
rpvd_eMsg_WriteAttribute
,
rpvd_eMsg_Attribute
,
rpvd_eMsg_Status
,
rpvd_eMsg_SubAdd
,
rpvd_eMsg_SubRemove
,
rpvd_eMsg_SubSend
,
rpvd_eMsg_SubRequest
,
rpvd_eMsg_NodeUp
}
rpvd_eMsg
;
typedef
struct
{
int
Type
;
int
Id
;
int
Status
;
}
rpvd_sMsgAny
;
typedef
struct
{
int
Type
;
int
Id
;
int
Status
;
pwr_tOid
Oid
;
}
rpvd_sMsgOid
;
typedef
struct
{
int
Type
;
int
Id
;
int
Status
;
pwr_tOName
Name
;
}
rpvd_sMsgObjectName
;
typedef
struct
{
int
Type
;
int
Id
;
int
Status
;
pwr_tOid
Oid
;
int
OSize
;
rpvd_sObject
o
[
136
];
}
rpvd_sMsgObject
;
typedef
struct
{
int
Type
;
int
Id
;
int
Status
;
pwr_tOid
Oid
;
pwr_tOName
Attribute
;
}
rpvd_sMsgReadAttribute
;
typedef
struct
{
int
Type
;
int
Id
;
int
Status
;
pwr_tOid
Oid
;
pwr_tOName
Attribute
;
int
Size
;
pwr_tTypeId
Tid
;
char
Value
[
1000
];
}
rpvd_sMsgAttribute
;
typedef
struct
{
int
Type
;
int
Id
;
int
Status
;
pwr_tOid
Oid
;
pwr_tOName
Attribute
;
int
Size
;
pwr_tTypeId
Tid
;
char
Value
[
1000
];
}
rpvd_sMsgWriteAttribute
;
typedef
struct
{
int
Type
;
int
Id
;
int
Status
;
pwr_tOid
Oid
;
pwr_tOName
Attribute
;
int
Size
;
pwr_tTypeId
Tid
;
int
Rix
;
}
rpvd_sMsgSubAdd
;
typedef
struct
{
int
Type
;
int
Id
;
int
Status
;
int
Rix
;
}
rpvd_sMsgSubRemove
;
typedef
struct
{
int
Type
;
int
Id
;
int
Status
;
int
More
;
char
Data
[
8184
];
}
rpvd_sMsgSubSend
;
typedef
union
{
rpvd_sMsgAny
Any
;
rpvd_sMsgOid
Oid
;
rpvd_sMsgObjectName
ObjectName
;
rpvd_sMsgObject
Object
;
rpvd_sMsgReadAttribute
ReadAttribute
;
rpvd_sMsgWriteAttribute
WriteAttribute
;
rpvd_sMsgAttribute
Attribute
;
rpvd_sMsgSubAdd
SubAdd
;
rpvd_sMsgSubRemove
SubRemove
;
rpvd_sMsgSubSend
SubSend
;
}
rpvd_sMsg
;
void
udp_Disable
();
void
udp_Enable
();
pwr_tStatus
udp_Send
(
char
*
buf
,
int
buf_size
);
pwr_tStatus
udp_Receive
(
char
**
buff
,
int
tmo
);
pwr_tStatus
udp_Request
(
char
*
sendbuf
,
int
sendbuf_size
,
char
**
rcvbuf
);
pwr_tStatus
udp_Init
(
char
*
remote_address
,
char
*
remote_host_name
,
int
port
);
#if defined __cplusplus
}
#endif
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment