ILXBufferUtil

new ILXBufferUtil()

Since:
  • BIP-IP TMOS 13.0

The ILXBufferUtil Class provides F5 implemented commands to do common operations on buffers, s pecifically including:

  • Search: Find matching bytes
  • Replace: Find and replace bytes
  • ReplaceAt: Replace some subsection with bytes
  • Insert: Insert new bytes
  • Append: Append bytes
  • Erase: Erase some subsection

Note: The ILXBufferUtil class has already been instantiated in the f5-nodejs module, therefore methods can be used directly from the ILXBufferUtil object. See examples below.

Example:

 var f5 = require('f5-nodejs');

var buffToBeSeached = new Buffer('010203040506', 'hex');
var seachBytes = new Buffer('03', 'hex');

// Search for first occurance of seachBytes in buffToBeSeached
var result2 = f5.ILXBufferUtil.search(buffToBeSeached, seachBytes);
console.log('Found at idx:', result1); // Outputs "Found at idx: 2"

Methods

append(buf, bytes)→ {buffer}

Append a byte sequence, i.e., insert it at the end

Parameters:

Name Type Description
buf
buffer source buffer
bytes
string | buffer byte sequence to append

Returns:

Type Description
buffer new buffer with the appended byte sequence

erase(buf, offset, len)→ {buffer}

Erase some portion of a buffer

Parameters:

Name Type Description
buf
buffer source buffer
offset
number offset of the byte sequence to erase
len
number length of the byte sequence to erase

Returns:

Type Description
buffer new buffer with the erased chunk

insert(buf, bytes, offset)→ {buffer}

Insert a new byte sequence into the buffer.

Parameters:

Name Type Description
buf
buffer source buffer
bytes
string | buffer byte sequence to insert
offset
number offset where to insert the byte sequence to

Returns:

Type Description
buffer new modified buffer with the inserted byte sequence

replace(buffer, old, repl, result, [options])→ {buffer}

Search for and replace a byte sequence in the buffer, starting at offset.

Parameters:

Name Type Attributes Description
buffer
buffer   source buffer
old
string | buffer   byte sequence or string to replace
repl
string | buffer   byte sequence of string to replace with
result
objecT  

the result object where to put the replace results to

Pro

perties
name:prope

rties

N a m e T y p e D e s c r i p t i o n
r e p l a c e d a r r a y [ o u t ] [ r e a d - o n l y ] a f t e r t h e f u n c t i o n r e t u r n s t h e l i s t w i l l c o n t a i n t h e l i s t o f r e p l a c e d t o k e n s ‘ i n d e x e s . I f t h e o p t i o n s . r e p l a c e d i s e m p t y - n o m a t c h e s w e r e f o u n d .
options
object <optional>

search options/options

Pro

perties
name:prope

rties-1

+—+—+—+– -+—+ | N | T | A | D

D |
a | y | t | e | e |
m | p | t | f | s |
e | e | r | a | c |
| | i | u | r |
| | b | l | i |
| | u | t | p |
| | t | | t |
| | e | | i |
| | s | | o |
| | | | n |

+===+===+===+== =+===+ | : | n | < | 0

o |
: | u | o | | f |
| m | p | | f |
| b | t | | s |
| e | i | | e |
| r | o | | t |
o | | n | | t |
f | | a | | o |
f | | l | | s |
s | | > | | t |
e | | | | a |
t | | | | r |
| | | | t |
| | | | s |
| | | | e |
| | | | a |
| | | | r |
| | | | c |
| | | | h |
| | | | f |
| | | | r |
| | | | o |
| | | | m |

+—+—+—+– -+—+ | : | b | < | f

r |
: | o | o | a | e |
| o | p | l | p |
| l | t | s | l |
| e | i | e | a |
| a | o | | c |
a | n | n | | e |
l | | a | | a |
l | | l | | l |
| | > | | l |
| | | | m |
| | | | a |
| | | | t |
| | | | c |
| | | | h |
| | | | e |
| | | | s |
| | | | . |
| | | | F |
| | | | i |
| | | | r |
| | | | s |
| | | | t |
| | | | o |
| | | | n |
| | | | e |
| | | | o |
| | | | t |
| | | | h |
| | | | e |
| | | | r |
| | | | w |
| | | | i |
| | | | s |
| | | | e |
| | | | . |

+—+—+—+– -+—+ | : | b | < | f

p |
: | o | o | a | e |
| o | p | l | r |
| l | t | s | f |
| e | i | e | o |
| a | o | | r |
i | n | n | | m |
c | | a | | c |
a | | l | | a |
s | | > | | s |
e | | | | e |
| | | | i |
| | | | n |
| | | | s |
| | | | e |
| | | | n |
| | | | s |
| | | | i |
| | | | t |
| | | | i |
| | | | v |
| | | | e |
| | | | s |
| | | | e |
| | | | a |
| | | | r |
| | | | c |
| | | | h |

+—+—+—+– -+—+

Returns:

Type Description
buffer
  • new modified buffer with the replaced byte sequence(s).

replaceAt(buffer, repl, offset, [options])→ {buffer}

Replace an arbitrary subsection (from offset to offset+len) with a new byte sequence.

Parameters:

Name Type Attributes Description
buffer
buffer   source buffer
repl
string | buffer   byte sequence or string to replace
offset
number   offset of the start position
options
object <optional>

replace options

Pro

perties
name:prope

rties-2

+—+—+—+– -+—+ | N | T | A | D

D |
a | y | t | e | e |
m | p | t | f | s |
e | e | r | a | c |
| | i | u | r |
| | b | l | i |
| | u | t | p |
| | t | | t |
| | e | | i |
| | s | | o |
| | | | n |

+===+===+===+== =+===+ | : | n | < | e

l |
: | u | o | n | e |
| m | p | d | n |
| b | t | o | g |
| e | i | f | t |
| r | o | b | h |
l | | n | u | o |
e | | a | f | f |
n | | l | f | t |
g | | > | e | h |
t | | | r | e |
h | | | | b |
| | | | y |
| | | | t |
| | | | e |
| | | | s |
| | | | e |
| | | | q |
| | | | u |
| | | | e |
| | | | n |
| | | | c |
| | | | e |
| | | | t |
| | | | o |
| | | | r |
| | | | e |
| | | | p |
| | | | l |
| | | | a |
| | | | c |
| | | | e |

+—+—+—+– -+—+

Returns:

Type Description
buffer new buffer with the replaced byte sequence.

rsearch(buffer, bytes, options)→ {number}

Reverse search for a byte sequence in the buffer. Matches left to right, i.e., (“abcd123”, “123”) will return 4; With offset argument, (“abcd123efg123”, “123”, { offset : 10 }) will return 5.

Parameters:

Name Type Description
buffer
buffer source buffer
bytes
string | buffer byte sequence or string to search for
options
object

search options

Propertie

s
name:properties-

3

N a m e T y p e A t t r i b u t e s D e f a u l t D e s c r i p t i o n
o f f s e t n u m b e r < o p t i o n a l > 0 o f f s e t t o s t a r t s e a r c h f r o m
i c a s e b o o l e a n < o p t i o n a l > f a l s e p e r f o r m c a s e i n s e n s i t i v e s e a r c h

Returns:

Type Description
number -1 or the index found at

search(buffer, bytes, [options])→ {number}

Search for a byte sequence in the buffer.

Parameters:

Name Type Attributes Description
buffer
buffer   source buffer
bytes
string | buffer   byte sequence or string to search for
options
object <optional>

search options

Pro

perties
name:prope

rties-4

+—+—+—+– -+—+ | N | T | A | D

D |
a | y | t | e | e |
m | p | t | f | s |
e | e | r | a | c |
| | i | u | r |
| | b | l | i |
| | u | t | p |
| | t | | t |
| | e | | i |
| | s | | o |
| | | | n |

+===+===+===+== =+===+ | : | n | < | 0

o |
: | u | o | | f |
| m | p | | f |
| b | t | | s |
| e | i | | e |
| r | o | | t |
o | | n | | t |
f | | a | | o |
f | | l | | s |
s | | > | | t |
e | | | | a |
t | | | | r |
| | | | t |
| | | | s |
| | | | e |
| | | | a |
| | | | r |
| | | | c |
| | | | h |
| | | | f |
| | | | r |
| | | | o |
| | | | m |

+—+—+—+– -+—+ | : | b | < | f

p |
: | o | o | a | e |
| o | p | l | r |
| l | t | s | f |
| e | i | e | o |
| a | o | | r |
i | n | n | | m |
c | | a | | c |
a | | l | | a |
s | | > | | s |
e | | | | e |
| | | | i |
| | | | n |
| | | | s |
| | | | e |
| | | | n |
| | | | s |
| | | | i |
| | | | t |
| | | | i |
| | | | v |
| | | | e |
| | | | s |
| | | | e |
| | | | a |
| | | | r |
| | | | c |
| | | | h |

+—+—+—+– -+—+

Returns:

Type Description
number -1 or the index found at

The BIG-IP API Reference documentation contains community-contributed content. F5 does not monitor or control community code contributions. We make no guarantees or warranties regarding the available code, and it may contain errors, defects, bugs, inaccuracies, or security vulnerabilities. Your access to and use of any code available in the BIG-IP API reference guides is solely at your own risk.