51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 7113|回复: 4
打印 上一主题 下一主题

[原创] lrs_length_send如何使用?

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2009-1-16 10:17:19 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
缓冲区的数据修改为内存值如:0x01000000,
Send提示9013错误(缓冲区数据转换发生错误),
查找说是需要使用lrs_length_send函数,
对于这个函数不太了解,请教如何使用lrs_length_send函数?
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
发表于 2009-1-16 10:44:19 | 只看该作者
lrs_length_send

Example  Return Values  Parameterization  See Also  


Sends data of a specified length on a stream socket.

int lrs_length_send(char *socket_descriptor, char *buffer, int location_option,
[char* locators], [char* additional_params], LrsLastArg );

socket_descriptor  A descriptor identifying the socket.  
buffer  A descriptor identifying the buffer to send.  
location_option  The method with which to locate the field within the buffer that determines the length.
NoOption - 0
OffsetSize - 1
LeftRightBoundaries - 2
LeftBoundarySize - 3  
locator  The values to enable location of the length field within the buffer. You can use parameterization for these values.
For option 1, OffsetSize, use "Offset=xxx" (default=0) and "Size=xxx".
For option 2, LeftRightBoundaries, specify "LB=xxx", "RB=xxx, and the optional "Ordinal=" and "Offset=xxx".
For option 3, LeftBoundarySize, specify "Size=xxx", "LB=xxx", and the optional "Ordinal=" and "Offset=xxx".  
additional_params  How the length value within the buffer is formatted and further calculations of the length:
"Encoding=" - 0 for decimal (default), 1 for HEX
"Order=" - 0 for by host (default), 1 by network order scheme
"SubtractSize=" - 0 do not include the size of the data in its length (default), or 1, include the size of the data in its length.  
LrsLastArg  A marker indicating the end of the parameter list.  


The lrs_length_send function writes data of a specified length from sock_descriptor into buffer. It is useful when sending parameterized data, where the length of data can be different each time the function is called. lrs_length_send saves you from having to calculate the length each time as Vugen will automatically write the correct length of the data into the field specified by the locator and location_option arguments.

Vugen inserts the length in the buffer itself. The user must be aware where the length value is placed within the buffer (unless the NoOption option is chosen) and its location is specified by the parameters location_option and locators. lrs_length_send first obtains the value of length (hereafter called length) and afterwards writes length number of bytes from the socket_descriptor into buffer.

The socket_descriptor and buffer parameters are identical to the first two parameters of lrs_send.

The location_option parameters:

NoOption
- lrs_length_send will behave identically to lrs_send. That is, the amount of data to be send will not be limited to a specified length but by the socket buffer size.

OffsetSize
- length takes up size bytes and is placed offset bytes from the beginning of the buffer. The values for the offset and size are passed as locator parameters with the "Offset" and Size" identifiers (e.g. "Offset=6", "Size=4"). After locating the length field lrs_length_receive will write length number of bytes that directly follow it.
The default value of "Offset" is zero.

LeftRightBoundaries
- length is found between a left and right boundary. The values for both boundaries are passed as locator parameters using "LB" and "RB". The amount of data to write will be length number of bytes immediately following the right boundary. The locator parameters "Offset" and "Ordinal" may also be used.
If the left or right boundary is a binary value, specify this by appending /BIN to the option indicator e.g.

          "RB/BIN=\\x00\\x00\\x01\\x00\\x00\\x00"


LeftBoundarySize
- length is located after a left boundary and takes up size bytes. The values for the left boundary and size are passed as locator parameters "LB" and "Size", respectively. The locator parameters "Offset" and "Ordinal" may also be used as well as the /BIN indicator option.

The locator parameters:

Locator parameters may be used in conjunction by passing them as separate string parameters to lrs_length_send e.g. "LB=LeftLeft ", "Size=1", "Offset=18".

Use the "Offset" locator (e.g. "Offset=4") with the OffsetSize location_option, where Offset specifies how many bytes from the beginning of the buffer lies the length field .
Use "Offset" with the LeftRightBoundaries or LeftBoundarySize location_option where, in order to locate length, Offset number of bytes will be added to the left boundary. This is useful when there is always a specific number of bytes of unknown content following a known left boundary. For example, consider three characters, "ABC", that define the left boundary - if there are always 2 bytes of unknown content between "ABC" and length then pass "LB=ABC" and "Offset=2".

The "Ordinal" locator may be used with the LeftRightBoundaries or LeftBoundarySize location_option. It indicates that the length field begins after the ordinal instance of the left boundary. For example, if the left boundary, the string "ABC", appears many times in the buffer, then "Ordinal=2" specifies that you use the second instance of "ABC" to locating length.
Note that "Ordinal" can be used in conjunction with "Offset". length lies Offset bytes following the Ordinal instance of the left boundary.

The additional_params parameters:

These parameters indicate in what format the length field will be found. They can also be used in conjunction and are passed as separate string parameters to lrs_length_send e.g. "Order=1", "Encoding=1".
Some length fields in a buffer include their own length in the total value. SubtractSize enables you to subtract the length of the field from the total to enable
回复 支持 反对

使用道具 举报

该用户从未签到

3#
 楼主| 发表于 2009-1-16 14:29:33 | 只看该作者
lrs_length_send("socket1", "buf0", LeftRightBoundaries, "LB/BIN=\\x004\\x00\\x04\\x00",
            "RB/BIN=\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00", "Offset=0","size= 50 ",  LrsLastArg);

提示无法保存参数9015
回复 支持 反对

使用道具 举报

该用户从未签到

4#
发表于 2009-1-16 14:42:05 | 只看该作者
从二楼(版主)贴出的信息来看,你的错误貌似缺少一个返回值变量
“Return Values  Parameterization”
返回值应该是一个int型变量
你试试在你那句前面加上  XXX=
回复 支持 反对

使用道具 举报

该用户从未签到

5#
 楼主| 发表于 2009-1-16 14:46:02 | 只看该作者
原帖由 ★星の金币 于 2009-1-16 14:42 发表
从二楼(版主)贴出的信息来看,你的错误貌似缺少一个返回值变量
“Return Values  Parameterization”
返回值应该是一个int型变量
你试试在你那句前面加上  XXX=


这段文字是在帮助里面的,那是函数的返回值说明链接,
现在不确定如何添加左右边界值?直接使用TREE目录下的二进制数据提示9015错误!

[ 本帖最后由 wistaria 于 2009-1-16 14:55 编辑 ]
回复 支持 反对

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-11-14 13:02 , Processed in 0.096449 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表