-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
recv: Skeleton code for handling Request messages
- Loading branch information
1 parent
f958a97
commit c0fda09
Showing
7 changed files
with
102 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "recv.h" | ||
#include "recv_request.h" | ||
#include "tracing.h" | ||
|
||
#define infof(...) Infof(r->tracer, " " __VA_ARGS__) | ||
|
||
/* Dispatch a single message to the appropriate handler. */ | ||
int recvMessage(struct vr *v, struct vr_message *message) | ||
{ | ||
unsigned id = message->server_id; | ||
const char *address = message->server_address; | ||
int rv = 0; | ||
|
||
switch (message->type) { | ||
case VR_REQUEST: | ||
rv = recvRequest(v, id, address, &message->request); | ||
break; | ||
default: | ||
rv = VR_INVALID; | ||
break; | ||
}; | ||
|
||
if (rv != 0) { | ||
return rv; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
#undef infof |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* Receive a message. */ | ||
|
||
#ifndef RECV_H_ | ||
#define RECV_H_ | ||
|
||
#include "../include/vr.h" | ||
|
||
/* Function to be invoked upon receiving a message. */ | ||
int recvMessage(struct vr *r, struct vr_message *message); | ||
|
||
#endif /* RECV_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include "recv_request.h" | ||
|
||
int recvRequest(struct vr *v, | ||
unsigned id, | ||
const char *address, | ||
const struct vr_request *request) | ||
{ | ||
(void)v; | ||
(void)id; | ||
(void)address; | ||
(void)request; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* Receive a Request message. */ | ||
|
||
#ifndef RECV_REQUEST_H_ | ||
#define RECV_REQUEST_H_ | ||
|
||
#include "../include/vr.h" | ||
|
||
/* Process a Request message from the given server. */ | ||
int recvRequest(struct vr *v, | ||
unsigned id, | ||
const char *address, | ||
const struct vr_request *request); | ||
|
||
#endif /* RECV_REQUEST_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters