Skip to content

Commit

Permalink
ftp: Use new API naming scheme
Browse files Browse the repository at this point in the history
Issue: 4082

Rename the existing rs_* parsing functions (pasv, port, epsv, eprt) to
follow the new API nomenclature.
  • Loading branch information
jlucovsky committed Aug 23, 2024
1 parent 3f0010d commit 7b465d7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions rust/src/ftp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub fn ftp_pasv_response(i: &[u8]) -> IResult<&[u8], u16> {
}

#[no_mangle]
pub unsafe extern "C" fn rs_ftp_active_port(input: *const u8, len: u32) -> u16 {
pub unsafe extern "C" fn SCFTPParseActivePort(input: *const u8, len: u32) -> u16 {
let buf = build_slice!(input, len as usize);
match ftp_active_port(buf) {
Ok((_, dport)) => {
Expand All @@ -106,7 +106,7 @@ pub unsafe extern "C" fn rs_ftp_active_port(input: *const u8, len: u32) -> u16 {
}

#[no_mangle]
pub unsafe extern "C" fn rs_ftp_pasv_response(input: *const u8, len: u32) -> u16 {
pub unsafe extern "C" fn SCFTPParsePASVResponse(input: *const u8, len: u32) -> u16 {
let buf = std::slice::from_raw_parts(input, len as usize);
match ftp_pasv_response(buf) {
Ok((_, dport)) => {
Expand All @@ -123,7 +123,7 @@ pub unsafe extern "C" fn rs_ftp_pasv_response(input: *const u8, len: u32) -> u16
}

// 229 Entering Extended Passive Mode (|||48758|).
pub fn ftp_epsv_response(i: &[u8]) -> IResult<&[u8], u16> {
fn ftp_epsv_response(i: &[u8]) -> IResult<&[u8], u16> {
let (i, _) = tag("229")(i)?;
let (i, _) = take_until("|||")(i)?;
let (i, _) = tag("|||")(i)?;
Expand All @@ -134,7 +134,7 @@ pub fn ftp_epsv_response(i: &[u8]) -> IResult<&[u8], u16> {
}

// EPRT |2|2a01:e34:ee97:b130:8c3e:45ea:5ac6:e301|41813|
pub fn ftp_active_eprt(i: &[u8]) -> IResult<&[u8], u16> {
fn ftp_active_eprt(i: &[u8]) -> IResult<&[u8], u16> {
let (i, _) = tag("EPRT")(i)?;
let (i, _) = take_until("|")(i)?;
let (i, _) = tag("|")(i)?;
Expand All @@ -148,7 +148,7 @@ pub fn ftp_active_eprt(i: &[u8]) -> IResult<&[u8], u16> {
}

#[no_mangle]
pub unsafe extern "C" fn rs_ftp_active_eprt(input: *const u8, len: u32) -> u16 {
pub unsafe extern "C" fn SCFTPParseActiveEPRT(input: *const u8, len: u32) -> u16 {
let buf = build_slice!(input, len as usize);
match ftp_active_eprt(buf) {
Ok((_, dport)) => {
Expand All @@ -164,7 +164,7 @@ pub unsafe extern "C" fn rs_ftp_active_eprt(input: *const u8, len: u32) -> u16 {
return 0;
}
#[no_mangle]
pub unsafe extern "C" fn rs_ftp_epsv_response(input: *const u8, len: u32) -> u16 {
pub unsafe extern "C" fn SCFTPParseEPSVResponse(input: *const u8, len: u32) -> u16 {
let buf = std::slice::from_raw_parts(input, len as usize);
match ftp_epsv_response(buf) {
Ok((_, dport)) => {
Expand Down
8 changes: 4 additions & 4 deletions src/app-layer-ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ static AppLayerResult FTPParseRequest(Flow *f, void *ftp_state, AppLayerParserSt

static int FTPParsePassiveResponse(FtpState *state, const uint8_t *input, uint32_t input_len)
{
uint16_t dyn_port = rs_ftp_pasv_response(input, input_len);
uint16_t dyn_port = SCFTPParsePASVResponse(input, input_len);
if (dyn_port == 0) {
return -1;
}
Expand All @@ -559,7 +559,7 @@ static int FTPParsePassiveResponse(FtpState *state, const uint8_t *input, uint32

static int FTPParsePassiveResponseV6(FtpState *state, const uint8_t *input, uint32_t input_len)
{
uint16_t dyn_port = rs_ftp_epsv_response(input, input_len);
uint16_t dyn_port = SCFTPParseEPSVResponse(input, input_len);
if (dyn_port == 0) {
return -1;
}
Expand Down Expand Up @@ -640,7 +640,7 @@ static AppLayerResult FTPParseResponse(Flow *f, void *ftp_state, AppLayerParserS
break;

case FTP_COMMAND_EPRT:
dyn_port = rs_ftp_active_eprt(state->port_line, state->port_line_len);
dyn_port = SCFTPParseActiveEPRT(state->port_line, state->port_line_len);
if (dyn_port == 0) {
goto tx_complete;
}
Expand All @@ -652,7 +652,7 @@ static AppLayerResult FTPParseResponse(Flow *f, void *ftp_state, AppLayerParserS
break;

case FTP_COMMAND_PORT:
dyn_port = rs_ftp_active_port(state->port_line, state->port_line_len);
dyn_port = SCFTPParseActivePort(state->port_line, state->port_line_len);
if (dyn_port == 0) {
goto tx_complete;
}
Expand Down

0 comments on commit 7b465d7

Please sign in to comment.