I am trying to write a code that reads line by line and stores it in a variable sdp. This is what I would paste in the console to be read and I want the sdp to appear in that same format.
The idea would be to read every line, and put a end of line character and for every read reallocating extra memory.
Here is the code I wrote:
printf("[Description]: ");
char *line;
size_t len = 0;
ssize_t read = 0;
char *sdp = (char*) malloc(sizeof(char));
while ((read = getline(&line, &len, stdin)) != -1 && all_space(line)) {
sdp = (char*) realloc (sdp,(sizeof(sdp)) +sizeof(line));
strcat(sdp, line);
strcat(sdp, "\r\n");
free(line);
}
printf("%s\n",sdp);
rtcSetRemoteDescription(peer->pc, sdp, "offer");
free(sdp);
This is what I am trying to read and store in the variable sdp
v=0
o=- 118260718 0 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 0.0.0.0
a=ice-ufrag:r4nc
a=ice-pwd:USf61+k7dRjSFJFZIlZkNn
a=ice-options:trickle
a=mid:0
a=setup:actpass
a=dtls-id:1
a=fingerprint:sha-256 21:C5:F4:72:3C:BA:4F:4A:DD:F1:14:C5:15:A9:57:4E:5B:61:44:CB:9B:7C:FC:2A:D3:0D:90:99:47:53:A9:57
a=sctp-port:5000
a=max-message-size:262144
But i keeping getting a problem, sdp doesnot store all the value and the result after printing is strange.
can someone help me
2020-05-11 21:24:28.287 DEBUG [15263] [rtc::InitLogger#34] Logger initialized
Peer created
Reached this point
***************************************************************************************
* 0: Exit / 1: Enter remote description / 2: Enter remote candidate / 3: Send message / 4: Print Connection Info *
[Command]: v=0
o=- 118260718 0 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 0.0.0.0
a=ice-ufrag:r4nc
a=ice-pwd:USf61+k7dRjSFJFZIlZkNn
a=ice-options:trickle
a=mid:0
a=setup:actpass
a=dtls-id:1
a=fingerprint:sha-256 21:C5:F4:72:3C:BA:4F:4A:DD:F1:14:C5:15:A9:57:4E:5B:61:44:CB:9B:7C:FC:2A:D3:0D:90:99:47:53:A9:57
a=sctp-port:5000
a=max-message-size:262144user#user-MXC6300:~/Desktop/WEBRTC/build$ o=- 118260718 0 IN IP4 127.0.0.1
118260718: command not found
user#user-MXC6300:~/Desktop/WEBRTC/build$ s=-
user#user-MXC6300:~/Desktop/WEBRTC/build$ t=0 0
0: command not found
user#user-MXC6300:~/Desktop/WEBRTC/build$ a=group:BUNDLE 0
0: command not found
user#user-MXC6300:~/Desktop/WEBRTC/build$ m=application 9 UDP/DTLS/SCTP webrtc-datachannel
9: command not found
user#user-MXC6300:~/Desktop/WEBRTC/build$ c=IN IP4 0.0.0.0
IP4: command not found
user#user-MXC6300:~/Desktop/WEBRTC/build$ a=ice-ufrag:r4nc
user#user-MXC6300:~/Desktop/WEBRTC/build$ a=ice-pwd:USf61+k7dRjSFJFZIlZkNn
user#user-MXC6300:~/Desktop/WEBRTC/build$ a=ice-options:trickle
user#user-MXC6300:~/Desktop/WEBRTC/build$ a=mid:0
user#user-MXC6300:~/Desktop/WEBRTC/build$ a=setup:actpass
user#user-MXC6300:~/Desktop/WEBRTC/build$ a=dtls-id:1
user#user-MXC6300:~/Desktop/WEBRTC/build$ a=fingerprint:sha-256 21:C5:F4:72:3C:BA:4F:4A:DD:F1:14:C5:15:A9:57:4E:5B:61:44:CB:9B:7C:FC:2A:D3:0D:90:99:47:53:A9:57
21:C5:F4:72:3C:BA:4F:4A:DD:F1:14:C5:15:A9:57:4E:5B:61:44:CB:9B:7C:FC:2A:D3:0D:90:99:47:53:A9:57: command not found
user#user-MXC6300:~/Desktop/WEBRTC/build$ a=sctp-port:5000
user#user-MXC6300:~/Desktop/WEBRTC/build$ a=max-message-size:262144
Related
I am unable to connect to PSql from my DigitalOcean server. This happened after resizing the droplet.
listen_addresses = '*' added to postgresql.conf
host all all 0.0.0.0/0 md5 added to pg_hba.conf
netstat -nlp displays the following:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 1705/redis-server 1
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 23688/unicorn.conf
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1693/nginx
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1390/sshd
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 1693/nginx
tcp6 0 0 :::22 :::* LISTEN 1390/sshd
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 [ ACC ] STREAM LISTENING 10806 1173/dbus-daemon /var/run/dbus/system_bus_socket
unix 2 [ ACC ] STREAM LISTENING 711 1213/systemd /run/systemd/private
unix 2 [ ACC ] STREAM LISTENING 11921 1213/systemd /run/systemd/journal/stdout
unix 2 [ ACC ] STREAM LISTENING 11924 1213/systemd /run/snapd.socket
unix 2 [ ACC ] STREAM LISTENING 11925 1213/systemd /run/snapd-snap.socket
unix 2 [ ACC ] STREAM LISTENING 2813 1449/acpid /var/run/acpid.socket
unix 2 [ ACC ] STREAM LISTENING 9801 1/init #/com/ubuntu/upstart
unix 2 [ ACC ] SEQPACKET LISTENING 427 708/systemd-udevd /run/udev/control
I am trying to use gcp to host my back end rest api. I have created successfully a vm instsnce ubuntu debian 9 , configured the firewall rules vpc network and now I have to to "make" it listen to some ports, in order the vm instance to accept requests from adresses. I followed the tutorials here: https://geekflare.com/gcp-load-balancer/ and https://www.scaleway.com/en/docs/how-to-configure-nginx-reverse-proxy/ , but neither of them works for me. Using load balancing and running the netstat -l in shh terimal , I get this :
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
udp 0 0 0.0.0.0:bootpc 0.0.0.0:*
udp 0 0 instance-group-2-ff:ntp 0.0.0.0:*
udp 0 0 localhost:ntp 0.0.0.0:*
udp 0 0 0.0.0.0:ntp 0.0.0.0:*
udp6 0 0 fe80::4001:aff:fea6:ntp [::]:*
udp6 0 0 localhost:ntp [::]:*
udp6 0 0 [::]:ntp [::]:*
and
from nginx :
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:http 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN
tcp6 0 0 [::]:http [::]:* LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
udp 0 0 0.0.0.0:bootpc 0.0.0.0:*
udp 0 0 instance-group-for-:ntp 0.0.0.0:*
udp 0 0 localhost:ntp 0.0.0.0:*
udp 0 0 0.0.0.0:ntp 0.0.0.0:*
udp6 0 0 fe80::4001:aff:fea6:ntp [::]:*
udp6 0 0 localhost:ntp [::]:*
udp6 0 0 [::]:ntp [::]:*
and when writing the external ip on web browser : 502 Bad Gateway nginx/1.10.3
The reverse-proxy.conf is :
server {
listen 80;
listen [::]:80;
access_log /var/log/nginx/reverse-access.log;
error_log /var/log/nginx/reverse-error.log;
location / {
proxy_pass http://external:80;
}
}
I also tested nginx and everything is ok.
Do you know maybe what is wrong? Any help would be really appreciated
Wired connection was not identified by Ubuntu.
Here's my result if I run ifconfig -a on terminal
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 308 bytes 22700 (22.7 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 308 bytes 22700 (22.7 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.42.0.249 netmask 255.255.255.0 broadcast 10.42.0.255
inet6 fe80::a78:589e:2107:b3c4 prefixlen 64 scopeid 0x20<link>
ether dc:53:60:e2:ce:99 txqueuelen 1000 (Ethernet)
RX packets 13416 bytes 9588247 (9.5 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 9109 bytes 1698278 (1.6 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Help me to get out of this
Thanks in Advance :)
The following helped me (I'm not quite sure why, but it did! :D)
Check ethernet state with
$ nmcli device
Check if there are errors or warnings from NetworkManager
$ systemctl status NetworkManager.service
Go root:
$ sudo -s
Delete all files in the directory /var/lib/NetworkManager/ except secret_key
$ cd /var/lib/NetworkManager/
$ rm -v !("secret_key")
Now reboot system and check ethernet state with nmcli device
If that does not help, you can create an empty file with this command and restart the computer again.
sudo touch /etc/NetworkManager/conf.d/10-globally-managed-devices.conf
Source: https://forum.ubuntuusers.de/topic/kein-netzzugriff/
So I wanted to create peer for webrtc in C, but I still don't quite get how the connection is made. I wanted to use the https://webrtc.github.io/samples/src/content/peerconnection/munge-sdp/ sample generating a SDP file in my computer, change the IP4 field (so i don't just do a loopback), put it in offer, do the same in another computer (to put in answer) [basically i'd do the signalling myself] to connect.
i tried it over my local network, but i failled miserably.
here is one of the SDP files
`
v=0
o=mozilla...THIS_IS_SDPARTA-52.4.0 7301737099351893139 0 IN IP4 0.0.0.0
s=-
t=0 0
a=fingerprint:sha-256 29:C1:12:C2:D7:03:B6:A8:E1:28:DC:DC:DE:A5:A0:0E:A8:D4:3A:CF:D5:67:9A:6B:4A:38:8C:DE:9C:ED:4E:D8
a=group:BUNDLE sdparta_0 sdparta_1 sdparta_2
a=ice-options:trickle
a=msid-semantic:WMS *
m=audio 9 UDP/TLS/RTP/SAVPF 109 9 0 8 101
c=IN IP4 0.0.0.0
a=sendrecv
a=extmap:1/sendonly urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=fmtp:109 maxplaybackrate=48000;stereo=1;useinbandfec=1
a=fmtp:101 0-15
a=ice-pwd:f0fa540801b8b01d2616d465cdbaf888
a=ice-ufrag:23f84f96
a=mid:sdparta_0
a=msid:{518019eb-2799-4525-ac2f-486dc4eb8ef4} {ebd29374-a915-41f1-868f-a5bca57540c1}
a=rtcp-mux
a=rtpmap:109 opus/48000/2
a=rtpmap:9 G722/8000/1
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000/1
a=setup:actpass
a=ssrc:3747370289 cname:{5339d74a-cea8-4286-9a6f-5c6682f03b4a}
m=video 9 UDP/TLS/RTP/SAVPF 120 121
c=IN IP4 0.0.0.0
a=sendrecv
a=fmtp:120 max-fs=12288;max-fr=60
a=fmtp:121 max-fs=12288;max-fr=60
a=ice-pwd:f0fa540801b8b01d2616d465cdbaf888
a=ice-ufrag:23f84f96
a=mid:sdparta_1
a=msid:{518019eb-2799-4525-ac2f-486dc4eb8ef4} {38ff8810-1ae3-4786-b95c-e945f649f032}
a=rtcp-fb:120 nack
a=rtcp-fb:120 nack pli
a=rtcp-fb:120 ccm fir
a=rtcp-fb:120 goog-remb
a=rtcp-fb:121 nack
a=rtcp-fb:121 nack pli
a=rtcp-fb:121 ccm fir
a=rtcp-fb:121 goog-remb
a=rtcp-mux
a=rtpmap:120 VP8/90000
a=rtpmap:121 VP9/90000
a=setup:actpass
a=ssrc:8090718 cname:{5339d74a-cea8-4286-9a6f-5c6682f03b4a}
m=application 9 DTLS/SCTP 5000
c=IN IP4 0.0.0.0
a=sendrecv
a=ice-pwd:f0fa540801b8b01d2616d465cdbaf888
a=ice-ufrag:23f84f96
a=mid:sdparta_2
a=sctpmap:5000 webrtc-datachannel 256
a=setup:actpass
a=ssrc:3024981980 cname:{5339d74a-cea8-4286-9a6f-5c6682f03b4a}
`
obs: i left the IP4 as 0.0.0.0 on purpose
obs2: I missed the ICE candidates, but not sure
I appreciate any help
no you can not. To connect to another PC you need a signaling server and exchange things like ice ufrag/pwd and the dtls fingerprints. Take a look at https://appr.tc/
I've try to get count of NIC RX rings from my programs via ETHTOOL API and
command ETHTOOL_GCHANNELS, but program returns error: "Operation not supported."
Sample code:
echannels.cmd = ETHTOOL_GCHANNELS;
req.ifr_data = (void*)&echannels;
if (ioctl(sock, SIOCETHTOOL, &req) != 0)
ERR("Can't get %s channels info! %s", nic, strerror(errno));
else
rx_no = echannels.rx_count;
Also i've try to get it from ethtool "ethtool -l eth0" with the same result:
#ethtool -l eth0
Channel parameters for eth0:
Cannot get device channel parameters
: Operation not supported
, but in /proc/interrupts i see that NIC have multiple RX rings binded to different CPU cores.
Anybody can tell me right way to get count of RX rings from C code?
I was looking to get the ring counts of my NICs as well. After talking with someone more knowledgeable than I (who also wasn't figuring it out), we came to the agreement that you might have to check the specs for your NIC; that it doesn't seem to be something directly available through ethtool.
However, this post also shows that, by checking the indirection table, it can show the RX ring (but not TX ring) count:
$ sudo ethtool -x eth0
RX flow hash indirection table for eth3 with 2 RX ring(s):
0: 0 1 0 1 0 1 0 1
8: 0 1 0 1 0 1 0 1
16: 0 1 0 1 0 1 0 1
24: 0 1 0 1 0 1 0 1
However, on one of my machines I see:
$ sudo ethtool -x enp9s0
Cannot get RX ring count: Operation not supported
This is in spite of the documentation for the NIC saying both:
"The 82574L supports two transmit descriptor rings"
"Figure 26 shows the structure of the two receive descriptor rings."
Hopefully either the -x option or checking the documentation for your NIC will help. It doesn't seem to be consistently and directly accessible via ethtool.