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 Jan 11, 2025
1 parent 8e7c6ef commit c9b564b
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 {
if input.is_null() {
return 0;
}
Expand All @@ -109,7 +109,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 {
if input.is_null() {
return 0;
}
Expand All @@ -129,7 +129,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 @@ -140,7 +140,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 @@ -154,7 +154,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 {
if input.is_null() {
return 0;
}
Expand All @@ -173,7 +173,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 {
if input.is_null() {
return 0;
}
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 @@ -554,7 +554,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 @@ -569,7 +569,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 @@ -651,7 +651,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 @@ -663,7 +663,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 c9b564b

Please sign in to comment.