Skip to content

[Rust] Fixes to Net Module #1725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
24a6c29
chore(cargo): Add dependencies
IshanGrover2004 Aug 14, 2024
acfab3c
feat: Create new module `net` in lib_ccxr
IshanGrover2004 Aug 14, 2024
67cc60b
feat: Add block related functionality in `block.rs`
IshanGrover2004 Aug 14, 2024
54a672c
feat: Add `target.rs` module for sending data blocks related functions
IshanGrover2004 Aug 14, 2024
f3474d6
feat(modules): Add all necessary modules
IshanGrover2004 Aug 14, 2024
3dc6713
feat: Add `source.rs` module for reading data blocks related function…
IshanGrover2004 Aug 25, 2024
52d1130
feat: Add C equivalent functions in rust
IshanGrover2004 Aug 25, 2024
9ee6f81
feat(module): Add `net` module in `libccxr_export`
IshanGrover2004 Aug 25, 2024
d735f38
chore(cargo): Update Cargo.lock
IshanGrover2004 Aug 25, 2024
cf317d5
feat: Add C equivalent code in `libccxr_exports` & use in `networking.c`
IshanGrover2004 Aug 25, 2024
5e6cebf
chore: Remove unused imports
IshanGrover2004 Aug 25, 2024
9eda21a
chore(clippy): Fix clippy warnings
IshanGrover2004 Aug 25, 2024
778cf9d
Net Module: Fixes in parser.rs - removed an extra check
steel-bucket Aug 9, 2025
4c03f7f
Net Module: Fixes in block.rs - fixed formatting issues
steel-bucket Aug 9, 2025
d855afb
Net Module: Fixes in source.rs - rewrote UDP implementation and a few…
steel-bucket Aug 9, 2025
1ea6185
Net Module: Fixes in target.rs - fixed formatting issues
steel-bucket Aug 9, 2025
06dbf3c
Net module: Rebasing and formatting changes
steel-bucket Aug 9, 2025
ead8b81
Net module: Clashing names after rebase
steel-bucket Aug 9, 2025
f027dc5
Net module: Clippy errors
steel-bucket Aug 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/lib_ccx/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@ const char *srv_pwd;
unsigned char *srv_header;
size_t srv_header_len;

#ifndef DISABLE_RUST
extern void ccxr_connect_to_srv(const char *addr, const char *port, const char *cc_desc, const char *pwd);
extern void ccxr_net_send_header(const unsigned char *data, size_t len);
extern int ccxr_net_send_cc(const unsigned char *data, int length, void *private_data, struct cc_subtitle *sub);
extern void ccxr_net_check_conn();
extern void ccxr_net_send_epg(
const char *start,
const char *stop,
const char *title,
const char *desc,
const char *lang,
const char *category);
extern int ccxr_net_tcp_read(int socket, void *buffer, size_t length);
extern int ccxr_net_udp_read(int socket, void *buffer, size_t length, const char *src_str, const char *addr_str);
extern int ccxr_start_tcp_srv(const char *port, const char *pwd);
extern int ccxr_start_udp_srv(const char *src, const char *addr, unsigned port);
#endif

/*
* Established connection to specified address.
* Returns socked id
Expand Down Expand Up @@ -84,6 +102,9 @@ int set_nonblocking(int fd);

void connect_to_srv(const char *addr, const char *port, const char *cc_desc, const char *pwd)
{
#ifndef DISABLE_RUST
return ccxr_connect_to_srv(addr, port, cc_desc, pwd);
#endif
if (NULL == addr)
{
mprint("Server address is not set\n");
Expand Down Expand Up @@ -115,6 +136,9 @@ void connect_to_srv(const char *addr, const char *port, const char *cc_desc, con

void net_send_header(const unsigned char *data, size_t len)
{
#ifndef DISABLE_RUST
return ccxr_net_send_header(data, len);
#endif
assert(srv_sd > 0);

#if DEBUG_OUT
Expand All @@ -141,6 +165,9 @@ void net_send_header(const unsigned char *data, size_t len)

int net_send_cc(const unsigned char *data, int len, void *private_data, struct cc_subtitle *sub)
{
#ifndef DISABLE_RUST
return ccxr_net_send_cc(data, len, private_data, sub);
#endif
assert(srv_sd > 0);

#if DEBUG_OUT
Expand All @@ -160,6 +187,9 @@ int net_send_cc(const unsigned char *data, int len, void *private_data, struct c

void net_check_conn()
{
#ifndef DISABLE_RUST
return ccxr_net_check_conn();
#endif
time_t now;
static time_t last_ping = 0;
char c = 0;
Expand Down Expand Up @@ -221,6 +251,9 @@ void net_send_epg(
const char *lang,
const char *category)
{
#ifndef DISABLE_RUST
return ccxr_net_send_epg(start, stop, title, desc, lang, category);
#endif
size_t st;
size_t sp;
size_t t;
Expand Down Expand Up @@ -301,6 +334,9 @@ void net_send_epg(

int net_tcp_read(int socket, void *buffer, size_t length)
{
#ifndef DISABLE_RUST
return ccxr_net_tcp_read(socket, buffer, length);
#endif
assert(buffer != NULL);
assert(length > 0);

Expand Down Expand Up @@ -333,6 +369,9 @@ int net_tcp_read(int socket, void *buffer, size_t length)

int net_udp_read(int socket, void *buffer, size_t length, const char *src_str, const char *addr_str)
{
#ifndef DISABLE_RUST
return ccxr_net_udp_read(socket, buffer, length, src_str, addr_str);
#endif
assert(buffer != NULL);
assert(length > 0);

Expand Down Expand Up @@ -519,6 +558,9 @@ int tcp_connect(const char *host, const char *port)

int start_tcp_srv(const char *port, const char *pwd)
{
#ifndef DISABLE_RUST
return ccxr_start_tcp_srv(port, pwd);
#endif
if (NULL == port)
port = DFT_PORT;

Expand Down Expand Up @@ -974,6 +1016,10 @@ ssize_t read_byte(int fd, char *ch)

int start_upd_srv(const char *src_str, const char *addr_str, unsigned port)
{
#ifndef DISABLE_RUST
return ccxr_start_udp_srv(src_str, addr_str, port);
#endif

init_sockets();

in_addr_t src;
Expand Down
Loading
Loading