aboutsummaryrefslogtreecommitdiff
path: root/client.c
diff options
context:
space:
mode:
authorGrissess <grissess@nexusg.org>2015-06-14 04:30:59 -0400
committerGrissess <grissess@nexusg.org>2015-06-14 04:30:59 -0400
commitb3606eb073651b92a7f3ba7df56d6a7d697bcc13 (patch)
treeec18209d58b63f18cbaaa7aaaed093ec2fe3627e /client.c
parent0e2f4d381644e062b840ec27cecd18e43b0c94be (diff)
Added a major packet type and cleaned up
Diffstat (limited to 'client.c')
-rw-r--r--client.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/client.c b/client.c
index 6e4ac34..830ef19 100644
--- a/client.c
+++ b/client.c
@@ -13,12 +13,16 @@
#define CLK_FREQ 1193180
int term;
+static int ident = 0x42454550;
-enum cmd_t {CMD_KA, CMD_PING, CMD_QUIT, CMD_PLAY};
+enum cmd_t {CMD_KA, CMD_PING, CMD_QUIT, CMD_PLAY, CMD_CAPS};
struct cmd_buffer {
int cmd;
- int data[8];
+ union {
+ int data[8];
+ char string[8*sizeof(int)];
+ };
};
void sigalrm(int sig) {
@@ -27,11 +31,15 @@ void sigalrm(int sig) {
int main(int argc, char **argv) {
struct sockaddr_in addr, remote;
- int sock, rlen = sizeof(remote), i;
+ int sock, rlen = sizeof(remote), i, len_uid = 0;
struct itimerval tmr;
struct cmd_buffer cmd;
struct sigaction sa;
+ if(argc > 1) {
+ len_uid = strlen(argv[1]);
+ }
+
if((term = open("/dev/console", O_WRONLY)) < 0) {
perror("open");
return 1;
@@ -80,6 +88,22 @@ int main(int argc, char **argv) {
setitimer(ITIMER_REAL, &tmr, NULL);
ioctl(term, KIOCSOUND, (int) (CLK_FREQ / cmd.data[2]));
break;
+
+ case CMD_CAPS:
+ cmd.data[0] = 1;
+ cmd.data[1] = ident;
+ for(i = 0; i < 6 * sizeof(int); i++) {
+ if(argc > 1 && i < len_uid) {
+ cmd.string[i+8] = argv[1][i];
+ } else {
+ cmd.string[i+8] = '\0';
+ }
+ }
+ for(i = 0; i < 8; i++) {
+ cmd.data[i] = htonl(cmd.data[i]);
+ }
+ sendto(sock, &cmd, sizeof(cmd), 0, (struct sockaddr *) &remote, rlen);
+ break;
default:
printf("WARNING: Unknown cmd %d\n", cmd.cmd);